diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-05-23 13:31:11 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-05-23 13:33:40 +0200 |
commit | fd9b0ecef4142a62b45404700ba1cff488f84a73 (patch) | |
tree | ef6c1f74f05a2220a41ccff4b0890c39229f32f7 /modules/home/conf/nvim/plgs/lsp | |
parent | refactor(pkgs): Categorize into `by-name` shards (diff) | |
download | nixos-config-fd9b0ecef4142a62b45404700ba1cff488f84a73.tar.gz nixos-config-fd9b0ecef4142a62b45404700ba1cff488f84a73.zip |
refactor(modules/home): Setup as "normal" NixOS module
Diffstat (limited to 'modules/home/conf/nvim/plgs/lsp')
14 files changed, 258 insertions, 0 deletions
diff --git a/modules/home/conf/nvim/plgs/lsp/default.nix b/modules/home/conf/nvim/plgs/lsp/default.nix new file mode 100644 index 00000000..b7c1e174 --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/default.nix @@ -0,0 +1,29 @@ +{...}: { + imports = [ + ./keymaps + ./servers + ]; + programs.nixvim.plugins.lsp = { + enable = true; + onAttach = + "" + # + '' + # function(client, bufnr) + # -- Enable completion triggered by <c-x><c-o> + # -- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + # end + # '' + ; + preConfig = '' + vim.diagnostic.config({ + underline = true, + -- virtual_text = true, + virtual_text = { + source = "always", -- Or "if_many" + }, + update_in_insert = true, + severity_sort = true, + }, nil); + ''; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/keymaps/default.nix b/modules/home/conf/nvim/plgs/lsp/keymaps/default.nix new file mode 100644 index 00000000..e176461e --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/keymaps/default.nix @@ -0,0 +1,72 @@ +{...}: { + programs.nixvim = { + plugins.lsp.keymaps = { + diagnostic = { + "N" = { + action = "goto_prev"; + desc = "go to previous diagnostic message"; + }; + "T" = { + action = "goto_next"; + desc = "go to next diagnostic message"; + }; + "<space>e" = { + action = "open_float"; + desc = "open float for the symbol"; + }; + "<space>gq" = { + action = "setloclist"; + desc = "add buffer diagnostic to the location list (quick-fix)"; + }; + }; + lspBuf = { + "<space>gD" = { + action = "declaration"; + desc = "[G]o to [d]eclaration"; + }; + "<space>hi" = { + action = "hover"; + desc = "Display [h]over [i]nformation"; + }; + "<space>sh" = { + action = "signature_help"; + desc = "Display [s]ignature [h]elp"; + }; + "<space>wa" = { + action = "add_workspace_folder"; + desc = "[W]orkspace folder [a]dd"; + }; + "<space>wr" = { + action = "remove_workspace_folder"; + desc = "[W]orkspace folder [r]emove"; + }; + "<space>rn" = { + action = "rename"; + desc = "[R]e[n]ame the item under the cursor"; + }; + "<space>ca" = { + action = "code_action"; + desc = "Open the [c]ode [a]ction menu"; + }; + }; + }; + keymaps = [ + { + key = "<space>f"; + action = "function() vim.lsp.buf.format { async = true } end"; + lua = true; + options.desc = "[F]ormat the current buffer (asynchronously)"; + } + { + key = "<space>wl"; + action = '' + function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end + ''; + lua = true; + options.desc = "[W]orkspace folders [l]ist"; + } + ]; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/default.nix b/modules/home/conf/nvim/plgs/lsp/servers/default.nix new file mode 100644 index 00000000..1f59ae4e --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/default.nix @@ -0,0 +1,15 @@ +{...}: { + imports = [ + # ./servers/pylyzer.nix + ./servers/bashls.nix + ./servers/ccls.nix + ./servers/quick-lint-js.nix + ./servers/ltex.nix + ./servers/lua-ls.nix + ./servers/nil_ls.nix + ./servers/openscad.nix + ./servers/ruff-lsp.nix + ./servers/rust-analyzer.nix + ./servers/texlab.nix + ]; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/bashls.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/bashls.nix new file mode 100644 index 00000000..0577a335 --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/bashls.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + bashls.enable = true; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/ccls.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/ccls.nix new file mode 100644 index 00000000..0698bcce --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/ccls.nix @@ -0,0 +1,5 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + ccls.enable = true; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/ltex.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/ltex.nix new file mode 100644 index 00000000..3224bc41 --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/ltex.nix @@ -0,0 +1,39 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + ltex = let + filetypes = [ + "java" + "cpp" + "shell" + "bash" + + "bibtex" + "context" + "context.tex" + "latex" + "tex" + + "markdown" + "org" + "restructuredtext" + "rsweave" + + "git-commit" + "gitcommit" + + "mail" + ]; + in { + enable = true; + inherit filetypes; + settings = { + enabled = filetypes; + completionEnabled = false; + language = "en-CA"; + additionalRules = { + enablePickyRules = true; + }; + }; + }; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/lua-ls.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/lua-ls.nix new file mode 100644 index 00000000..5a44b500 --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/lua-ls.nix @@ -0,0 +1,8 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + lua-ls = { + enable = true; + settings.telemetry.enable = false; + }; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/nil_ls.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/nil_ls.nix new file mode 100644 index 00000000..f0cccbdc --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/nil_ls.nix @@ -0,0 +1,10 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + nil_ls = { + enable = true; + settings = { + formatting.command = ["alejandra"]; + }; + }; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/openscad.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/openscad.nix new file mode 100644 index 00000000..a0221cc4 --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/openscad.nix @@ -0,0 +1,17 @@ +{pkgs, ...}: { + programs.nixvim = { + extraConfigLuaPost = + /* + lua + */ + '' + require('lspconfig').openscad_lsp.setup{ + cmd = {"openscad-lsp", "--stdio", "--fmt-style", "WebKit"}, + } + ''; + extraPackages = with pkgs; [ + openscad-lsp + clang-tools # Need to satisfy `clang-format` (which is used by openscad-lsp) + ]; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/pylyzer.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/pylyzer.nix new file mode 100644 index 00000000..b1042221 --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/pylyzer.nix @@ -0,0 +1,12 @@ +{pkgs, ...}: { + programs.nixvim = { + extraConfigLuaPost = + /* + lua + */ + '' + require('lspconfig').pylyzer.setup{} + ''; + extraPackages = with pkgs; [pylyzer]; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/quick-lint-js.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/quick-lint-js.nix new file mode 100644 index 00000000..23c3054a --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/quick-lint-js.nix @@ -0,0 +1,15 @@ +{pkgs, ...}: { + programs.nixvim = { + extraConfigLuaPost = + /* + lua + */ + '' + require('lspconfig').quick_lint_js.setup{ + } + ''; + extraPackages = with pkgs; [ + quick-lint-js + ]; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/ruff-lsp.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/ruff-lsp.nix new file mode 100644 index 00000000..3eeb495a --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/ruff-lsp.nix @@ -0,0 +1,10 @@ +{pkgs, ...}: { + programs.nixvim = { + plugins.lsp.servers = { + ruff-lsp = { + enable = true; + }; + }; + extraPackages = with pkgs; [ruff]; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/rust-analyzer.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/rust-analyzer.nix new file mode 100644 index 00000000..d58c8f1b --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/rust-analyzer.nix @@ -0,0 +1,14 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + rust-analyzer = { + enable = true; + settings = { + typing.autoClosingAngleBrackets.enable = true; + }; + # NOTE: These should be provided by the devenv, to support nightly and + # such things <2023-11-25> + installCargo = false; + installRustc = false; + }; + }; +} diff --git a/modules/home/conf/nvim/plgs/lsp/servers/servers/texlab.nix b/modules/home/conf/nvim/plgs/lsp/servers/servers/texlab.nix new file mode 100644 index 00000000..59af8d39 --- /dev/null +++ b/modules/home/conf/nvim/plgs/lsp/servers/servers/texlab.nix @@ -0,0 +1,7 @@ +{...}: { + programs.nixvim.plugins.lsp.servers = { + texlab = { + enable = true; + }; + }; +} |