diff --git a/profiles/dnscrypt/cloaking_rules b/profiles/dnscrypt/cloaking_rules index 6cbe72f..ca9ef31 100644 --- a/profiles/dnscrypt/cloaking_rules +++ b/profiles/dnscrypt/cloaking_rules @@ -1 +1,2 @@ *.localhost localhost +*.notatld.localhost localhost diff --git a/users/modules/neovim/default.nix b/users/modules/neovim/default.nix index 3ac1c7d..6d2b848 100644 --- a/users/modules/neovim/default.nix +++ b/users/modules/neovim/default.nix @@ -5,12 +5,12 @@ let in { imports = [ + ./nvim-lsp.nix ./js.nix - ./go.nix ./rust.nix - ./web_dev.nix - ./other_langs.nix + ./nix.nix ]; + options.mae.nvim = { enable = mkEnableOption "enable neovim"; }; @@ -38,22 +38,8 @@ in set number set autoindent - set completeopt=menuone,noinsert,noselect set shortmess+=c - ''; - coc.pluginConfig = '' - nmap (coc-rename) - nmap (coc-codeaction-line) - - " Remap and for scroll float windows/popups. - if has('nvim-0.4.0') || has('patch-8.2.0750') - nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" - endif + set completeopt=menuone,noinsert,noselect ''; }; }; diff --git a/users/modules/neovim/go.nix b/users/modules/neovim/go.nix deleted file mode 100644 index b794acf..0000000 --- a/users/modules/neovim/go.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ lib, pkgs, config, ... }: -let - cfg = config.mae.nvim.go; -in -with lib; -{ - options.mae.nvim.go = { - enable = mkEnableOption "Enable go support in nvim"; - }; - config.programs.neovim = mkIf cfg.enable { - coc.enable = true; - plugins = with pkgs.vimPlugins; [ - pkgs.go-fold-if-err-nil - coc-go - ]; - }; -} diff --git a/users/modules/neovim/js.nix b/users/modules/neovim/js.nix index f210c4e..7b54abe 100644 --- a/users/modules/neovim/js.nix +++ b/users/modules/neovim/js.nix @@ -1,26 +1,41 @@ { lib, pkgs, config, ... }: let + typescript-lsp = pkgs.nodePackages.typescript-language-server; + tsserver-path = "${pkgs.nodePackages.typescript}/lib/node_modules/typescript/lib"; cfg = config.mae.nvim; in with lib; { options.mae.nvim.js = { tsserver.enable = mkEnableOption "Enable js/ts support in nvim with tsserver"; + deno.enable = mkEnableOption "Enable deno support in nvim"; }; - config = mkIf cfg.js.tsserver.enable { - programs.neovim = { - coc.enable = true; - plugins = with pkgs.vimPlugins; [ - coc-tsserver - { - plugin = vim-jsdoc; - config = '' - let g:jsdoc_formatter = "tsdoc" - let g:typescript_indent_disable = 1 + config = mkMerge [ + (mkIf cfg.js.deno.enable + { + mae.nvim.lsp.servers.denols = { + enable = true; + script = '' + { + cmd = { "${pkgs.deno}/bin/deno", "lsp" }, + single_file_support = false, + } ''; - } - ]; - }; - }; + }; + } + ) + (mkIf + cfg.js.tsserver.enable + { + mae.nvim.lsp.servers.tsserver = { + enable = true; + script = '' + { + cmd = { "${typescript-lsp}/bin/typescript-language-server", "--stdio", "--tsserver-path", "${tsserver-path}" } + } + ''; + }; + }) + ]; } diff --git a/users/modules/neovim/nix.nix b/users/modules/neovim/nix.nix new file mode 100644 index 0000000..84fcb62 --- /dev/null +++ b/users/modules/neovim/nix.nix @@ -0,0 +1,21 @@ +{ lib, pkgs, config, ... }: +let + cfg = config.mae.nvim; +in +with lib; +{ + options.mae.nvim.nix.enable = mkEnableOption "Enable nix support in nvim"; + config = mkIf cfg.nix.enable { + programs.neovim = { + plugins = with pkgs.vimPlugins; [ + vim-nix + ]; + }; + mae.nvim.lsp.servers.rnix = { + enable = true; + script = '' { + cmd = { "${pkgs.rnix-lsp}/bin/rnix-lsp" } + }''; + }; + }; +} diff --git a/users/modules/neovim/nvim-lsp.nix b/users/modules/neovim/nvim-lsp.nix new file mode 100644 index 0000000..9b21984 --- /dev/null +++ b/users/modules/neovim/nvim-lsp.nix @@ -0,0 +1,49 @@ +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.mae.nvim; + lspLangConfigType = types.submodule { + options = { + enable = mkEnableOption "Enable named lsp lang config"; + script = mkOption { + type = types.lines; + default = "{}"; + }; + }; + }; + mkLspLangConfig = name: cfg: '' + require'lspconfig'["${name}"].setup(require'coq'.lsp_ensure_capabilities(${cfg.script})) + ''; + mkLspLangConfigs = cfgs: lib.strings.concatStringsSep "\n" ((lib.attrsets.mapAttrsToList mkLspLangConfig cfgs)); +in +{ + options.mae.nvim.lsp = { + enable = mkEnableOption "Enable lsp support in nvim with nvim-lspconfig and cmp-nvim"; + servers = mkOption { + type = types.attrsOf lspLangConfigType; + default = [ ]; + }; + }; + + config = mkIf cfg.lsp.enable { + programs.neovim = { + plugins = with pkgs.vimPlugins; [ + { + plugin = coq_nvim; + config = '' + vim.g.coq_settings = { + xdg = true, + auto_start = true + } + ''; + type = "lua"; + } + { + plugin = nvim-lspconfig; + config = mkLspLangConfigs cfg.lsp.servers; + type = "lua"; + } + ]; + }; + }; +} diff --git a/users/modules/neovim/other_langs.nix b/users/modules/neovim/other_langs.nix deleted file mode 100644 index b1fafa1..0000000 --- a/users/modules/neovim/other_langs.nix +++ /dev/null @@ -1,68 +0,0 @@ -{ lib, pkgs, config, ... }: -let - cfg = config.mae.nvim; -in -with lib; -{ - imports = [ - # Lua - ({ ... }: { - options.mae.nvim.lua.enable = mkEnableOption "Enable lua support in nvim"; - config.programs.neovim = mkIf cfg.lua.enable - { - coc.enable = true; - coc.settings.languageserver.lua = mkIf cfg.lua.enable { - command = "${pkgs.sumneko-lua-language-server}/bin/lua-language-server"; - rootPatterns = [ ".git" ]; - filetypes = [ - "lua" - ]; - }; - }; - }) - # Nix - ({ ... }: { - options.mae.nvim.nix.enable = mkEnableOption "Enable nix support in nvim"; - config.programs.neovim = mkIf cfg.nix.enable - { - plugins = with pkgs.vimPlugins; [ - vim-nix - ]; - coc.enable = true; - coc.settings.languageserver.nix = mkIf cfg.nix.enable { - "command" = "${pkgs.rnix-lsp}/bin/rnix-lsp"; - "filetypes" = [ - "nix" - ]; - }; - }; - }) - # Clangd - ({ ... }: { - options.mae.nvim.clangd.enable = mkEnableOption "Enable clangd support in nvim"; - config.programs.neovim = mkIf cfg.clangd.enable - { - plugins = with pkgs.vimPlugins; [ - coc-clangd - ]; - coc.enable = true; - coc.settings = { - "clangd.checkUpdates" = false; - # Use whatever clangd is in path for dependency reasons I think I don't remember at this point - "clangd.path" = "clangd"; - }; - }; - }) - # Python - ({ ... }: { - options.mae.nvim.python.enable = mkEnableOption "Enable python support in nvim"; - config.programs.neovim = mkIf cfg.python.enable - { - coc.enable = true; - plugins = with pkgs.vimPlugins; [ - coc-pyright - ]; - }; - }) - ]; -} diff --git a/users/modules/neovim/rust.nix b/users/modules/neovim/rust.nix index 41d4402..b4972bd 100644 --- a/users/modules/neovim/rust.nix +++ b/users/modules/neovim/rust.nix @@ -1,23 +1,19 @@ { lib, pkgs, config, ... }: let - cfg = config.mae.nvim.rust; + cfg = config.mae.nvim; in with lib; { - options.mae.nvim.rust = { - enable = mkEnableOption "Enable rust support in nvim"; - }; - config.programs.neovim = mkIf cfg.enable { - coc.enable = true; - plugins = with pkgs.vimPlugins; [ - coc-rust-analyzer - ]; - coc.settings = { - "rust-analyzer.server.path" = "${pkgs.rust-analyzer-nightly}/bin/rust-analyzer"; - "rust-analyzer.updates.prompt" = false; - "rust-analyzer.updates.checkOnStartup" = false; - "rust-analyzer.cargo.loadOutDirsFromCheck" = true; - "rust-analyzer.procMacro.enable" = true; + options.mae.nvim.rust.enable = lib.mkEnableOption "Enable rust language support in neovim"; + + config = mkIf cfg.rust.enable { + mae.nvim.lsp.servers.rust_analyzer = { + enable = true; + script = '' + { + cmd = { "${pkgs.rust-analyzer}/bin/rust-analyzer" } + } + ''; }; }; } diff --git a/users/modules/neovim/web_dev.nix b/users/modules/neovim/web_dev.nix deleted file mode 100644 index c7c35a3..0000000 --- a/users/modules/neovim/web_dev.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ lib, pkgs, config, ... }: -let - cfg = config.mae.nvim; -in -with lib; -{ - options.mae.nvim.web = { - enable = mkEnableOption "Enable webdev support in nvim"; - }; - options.mae.nvim.js = { - enable = mkEnableOption "Enable js/ts support in nvim"; - }; - - config = mkMerge [ - (mkIf cfg.js.enable { - programs.neovim = { - coc.enable = true; - plugins = with pkgs.vimPlugins; [ - coc-tsserver - { - plugin = vim-jsdoc; - config = '' - let g:jsdoc_formatter = "tsdoc" - let g:typescript_indent_disable = 1 - ''; - } - ]; - }; - }) - (mkIf cfg.web.enable { - mae.nvim.js.enable = true; - programs.neovim = { - coc.enable = true; - plugins = with pkgs.vimPlugins; [ - coc-emmet - coc-html - ]; - }; - }) - ]; -} diff --git a/users/profiles/neovim/default.nix b/users/profiles/neovim/default.nix index 438b923..7bfde99 100644 --- a/users/profiles/neovim/default.nix +++ b/users/profiles/neovim/default.nix @@ -2,10 +2,12 @@ { mae.nvim = { enable = true; - # js.tsserver.enable = true; + lsp.enable = true; + js.tsserver.enable = true; + js.deno.enable = true; nix.enable = true; rust.enable = true; - clangd.enable = true; - python.enable = true; + #clangd.enable = true; + #python.enable = true; }; }