diff options
| -rw-r--r-- | configs/.ycm_extra_conf.py | 18 | ||||
| -rw-r--r-- | configs/plugins.vimrc | 3 | ||||
| -rw-r--r-- | modules/vim.nix | 21 |
3 files changed, 40 insertions, 2 deletions
diff --git a/configs/.ycm_extra_conf.py b/configs/.ycm_extra_conf.py new file mode 100644 index 0000000..abaa723 --- /dev/null +++ b/configs/.ycm_extra_conf.py @@ -0,0 +1,18 @@ +def Settings(**kwargs): + return {"ls": language_server_settings(kwargs["language"])} + + +def language_server_settings(language): + match language: + case "nix": + return nil_settings() + case _: + return {} + + +def nil_settings(): + return { + "formatting": { + "command": ["nixfmt"], + }, + } diff --git a/configs/plugins.vimrc b/configs/plugins.vimrc index cdc2a88..92d499d 100644 --- a/configs/plugins.vimrc +++ b/configs/plugins.vimrc @@ -2,6 +2,9 @@ " YOUCOMPLETEME: +let g:ycm_extra_conf_globlist = ['/nix/store/*'] +let g:ycm_global_ycm_extra_conf = '@ycm_extra_conf@' + let g:ycm_language_server = \ [ \ { diff --git a/modules/vim.nix b/modules/vim.nix index ceceac5..1913197 100644 --- a/modules/vim.nix +++ b/modules/vim.nix @@ -1,4 +1,9 @@ -{ pkgs, auxiliaryPkgs, ... }: +{ + lib, + pkgs, + auxiliaryPkgs, + ... +}: let configs = [ @@ -6,7 +11,19 @@ let ../configs/plugins.vimrc ]; - customRC = with builtins; foldl' (r: f: r + (readFile f)) "" configs; + configVars = { + "@ycm_extra_conf@" = ../configs/.ycm_extra_conf.py; + }; + + processRCFile = + f: + with builtins; + (replaceStrings + (lib.attrNames configVars) + (map toString (lib.attrValues configVars)) + (readFile f)); + + customRC = builtins.foldl' (r: f: r + (processRCFile f)) "" configs; vim-configured = with pkgs; |
