neovim: configure coc.nvim via nix
Alan Pearce alan@alanpearce.eu
Sat, 12 Dec 2020 21:46:43 +0100
3 files changed, 35 insertions(+), 7 deletions(-)
A user/modules/nvim-coc.nix
@@ -0,0 +1,25 @@+{ config, lib, pkgs, ... }: + +with lib; + +let + inherit (pkgs) stdenv; + cfg = config.programs.neovim.coc; +in +{ + options.programs.neovim.coc = { + config = mkOption { + type = types.attrs; + default = {}; + description = '' + Settings for coc.nvim + ''; + }; + }; + + config = { + xdg.configFile."nvim/coc-settings.json" = { + source = pkgs.writeText "coc-settings.json" (builtins.toJSON cfg.config); + }; + }; +}
D user/nvim/coc-settings.json
@@ -1,5 +0,0 @@-{ - "json.enable": true, - "suggest.enablePreview": true -} -
M user/settings/base.nix → user/settings/base.nix
@@ -1,6 +1,10 @@ { config, lib, pkgs, ... }: { + imports = [ + ../modules/nvim-coc.nix + ]; + # Let Home Manager install and manage itself. programs.home-manager.enable = true; manual = { @@ -31,9 +35,13 @@ ]; opt = [ ]; }; }; + coc = { + config = { + "json.enable" = true; + "suggest.enablePreview" = true; + }; + }; }; - xdg.configFile."nvim/coc-settings.json".source = ../nvim/coc-settings.json; - home.sessionVariables = { EMAIL = "alan@alanpearce.eu"; XDG_CACHE_HOME = if pkgs.stdenv.isDarwin then "$HOME/Library/Caches/XDG" else "$HOME/.cache"; XDG_CONFIG_HOME = "$HOME/.config";