1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

neovim: Add missing newlines to init.lua

When generating `init.lua` the Lua config would be placed immediately
after the nvim config without a new line.

```
vim.cmd [[source /nix/store/cs3al9x1ml5ds3n6n433wcdxp89awac4-nvim-init-home-manager.vim]]--first line of Lua config
```

This change places a newline after each config portion.

```
vim.cmd [[source /nix/store/cs3al9x1ml5ds3n6n433wcdxp89awac4-nvim-init-home-manager.vim]]
--first line of Lua config
```
This commit is contained in:
Joe Wasson 2023-08-13 00:02:34 -07:00 committed by Matthieu Coudron
parent 8765d4e38a
commit 29078da204
3 changed files with 48 additions and 20 deletions

View file

@ -392,26 +392,25 @@ in {
home.sessionVariables = mkIf cfg.defaultEditor { EDITOR = "nvim"; };
xdg.configFile =
let hasLuaConfig = hasAttr "lua" config.programs.neovim.generatedConfigs;
in mkMerge (
# writes runtime
(map (x: x.runtime) pluginsNormalized) ++ [{
"nvim/init.lua" = let
luaRcContent =
lib.optionalString (neovimConfig.neovimRcContent != "")
"vim.cmd [[source ${
pkgs.writeText "nvim-init-home-manager.vim"
neovimConfig.neovimRcContent
}]]" + config.programs.neovim.extraLuaConfig
+ lib.optionalString hasLuaConfig
config.programs.neovim.generatedConfigs.lua;
in mkIf (luaRcContent != "") { text = luaRcContent; };
"nvim/coc-settings.json" = mkIf cfg.coc.enable {
source = jsonFormat.generate "coc-settings.json" cfg.coc.settings;
};
}]);
xdg.configFile = let
hasLuaConfig = hasAttr "lua" config.programs.neovim.generatedConfigs;
vimRcContent = lib.optionalString (neovimConfig != "") pkgs.writeText
"nvim-init-home-manager.vim" neovimConfig.neovimRcContent;
luaRcContent = lib.concatStringsSep "\n" (lib.remove "" [
(lib.optionalString (vimRcContent != "")
"vim.cmd [[source ${vimRcContent}]]")
(config.programs.neovim.extraLuaConfig)
(lib.optionalString hasLuaConfig
config.programs.neovim.generatedConfigs.lua)
]);
in mkMerge (
# writes runtime
(map (x: x.runtime) pluginsNormalized) ++ [{
"nvim/init.lua" = mkIf (luaRcContent != "") { text = luaRcContent; };
"nvim/coc-settings.json" = mkIf cfg.coc.enable {
source = jsonFormat.generate "coc-settings.json" cfg.coc.settings;
};
}]);
programs.neovim.finalPackage = pkgs.wrapNeovimUnstable cfg.package
(neovimConfig // {

View file

@ -6,4 +6,5 @@
# waiting for a nixpkgs patch
neovim-no-init = ./no-init.nix;
neovim-extra-lua-init = ./extra-lua-init.nix;
neovim-init-newline = ./init-newline.nix;
}

View file

@ -0,0 +1,28 @@
{ config, lib, pkgs, ... }:
with lib;
let
extraConfig = ''
echo extraConfigVim
'';
in {
config = {
programs.neovim = {
enable = true;
inherit extraConfig;
extraLuaConfig = ''
-- extraLuaConfig
'';
};
nmt.script = ''
nvimFolder="home-files/.config/nvim"
assertFileContent "$nvimFolder/init.lua" ${
pkgs.writeText "init.lua-expected" ''
vim.cmd [[source ${
pkgs.writeText "nvim-init-home-manager.vim" extraConfig
}]]
-- extraLuaConfig
''
}
'';
};
}