From 3182811b8daa83db4786a5921328252a56f4d1fd Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 27 Jan 2026 11:45:35 +0300 Subject: [PATCH 1/4] docs/manual: describe registring custom LSPs in the language section Signed-off-by: NotAShelf Change-Id: I776aa1283b0d89016a4eb0de2b67e2f86a6a6964 --- docs/manual/configuring/languages/lsp.md | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/docs/manual/configuring/languages/lsp.md b/docs/manual/configuring/languages/lsp.md index 2ddc08b5..847924aa 100644 --- a/docs/manual/configuring/languages/lsp.md +++ b/docs/manual/configuring/languages/lsp.md @@ -21,3 +21,43 @@ vim.languages.java = { }; } ``` + +## Custom LSP Servers {#ch-custom-lsp-servers} + +Neovim 0.11, in an effort to improve the out-of-the-box experience of Neovim, +has introduced a new `vim.lsp` API that can be used to register custom LSP +servers with ease. In **nvf**, this translates to the custom `vim.lsp` API that +can be used to register servers that are not present in existing language +modules. + +The {option}`vim.lsp.servers` submodule can be used to modify existing LSP +definitions OR register your own custom LSPs respectively. For example, if you'd +like to avoid having NVF pull the LSP packages you may modify the start command +to use a string, which will cause the LSP API to discover LSP servers from +{env}`PATH`. For example: + +```nix +{lib, ...}: { + vim.lsp.servers = { + # Get `basedpyright-langserver` from PATH, e.g., a dev shell. + basedpyright.cmd = lib.mkForce ["basedpyright-langserver" "--stdio"]; + + # Define a custom LSP entry using `vim.lsp.servers`: + ty = { + cmd = lib.mkDefault [(lib.getExe pkgs.ty) "server"]; + filetypes = ["python"]; + root_markers = [ + ".git" + "pyproject.toml" + "setup.cfg" + "requirements.txt" + "Pipfile" + "pyrightconfig.json" + ]; + + # If your LSP accepts custom settings. See `:help lsp-config` for more details + # on available fields. This is a freeform field. + settings.ty = { /* ... */ }; + }; +} +``` From 80506176567f47eb8062e4cd658d90befab96f84 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 27 Jan 2026 11:50:45 +0300 Subject: [PATCH 2/4] docs/manual: add custom keybinds section; minor wording tweaks Co-Authored-by: horriblename Signed-off-by: NotAShelf Change-Id: Idefa75ca9a92f89d008977a88066515d6a6a6964 --- docs/manual/configuring.md | 1 + docs/manual/configuring/keybinds.md | 38 +++++++++++++++++++ docs/manual/configuring/overriding-plugins.md | 3 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 docs/manual/configuring/keybinds.md diff --git a/docs/manual/configuring.md b/docs/manual/configuring.md index 9a1b71cf..ce455ea7 100644 --- a/docs/manual/configuring.md +++ b/docs/manual/configuring.md @@ -17,6 +17,7 @@ configuring/custom-package.md configuring/custom-plugins.md configuring/overriding-plugins.md configuring/languages.md +configuring/keybinds.md configuring/dags.md configuring/dag-entries.md configuring/autocmds.md diff --git a/docs/manual/configuring/keybinds.md b/docs/manual/configuring/keybinds.md new file mode 100644 index 00000000..401799c1 --- /dev/null +++ b/docs/manual/configuring/keybinds.md @@ -0,0 +1,38 @@ +# Custom keymaps {#ch-keymaps} + +Some plugin modules provide keymap options for your convenience. If a keymap is +not provided by such module options, you may easily register your own custom +keymaps via {option}`vim.keymaps`. + +```nix +{ + config.vim.keymaps = [ + { + key = "m"; + mode = "n"; + silent = true; + action = ":make"; + } + { + key = "l"; + mode = ["n" "x"]; + silent = true; + action = "cnext"; + } + { + key = "k"; + mode = ["n" "x"]; + + # While `lua` is `true`, `action` is expected to be + # a valid Lua expression. + lua = true; + action = '' + function() + require('foo').do_thing() + print('did thing') + end + ''; + } + ]; +} +``` diff --git a/docs/manual/configuring/overriding-plugins.md b/docs/manual/configuring/overriding-plugins.md index 55979ce7..ad681517 100644 --- a/docs/manual/configuring/overriding-plugins.md +++ b/docs/manual/configuring/overriding-plugins.md @@ -14,11 +14,12 @@ vim.pluginOverrides = { rev = ""; hash = ""; }; + # It's also possible to use a flake input lazydev-nvim = inputs.lazydev-nvim; # Or a local path lazydev-nvim = ./lazydev; - # Or a npins pin... etc + # Or a npins pin nvfetcher source, etc. }; ``` From 33cc70b4db47a13383606fd997579110b146c936 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 27 Jan 2026 12:07:50 +0300 Subject: [PATCH 3/4] treesitter: move autogroup definition to augroup module Signed-off-by: NotAShelf Change-Id: I1a2f5e47b4d9457a91a84802944ea06f6a6a6964 --- modules/plugins/treesitter/config.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index 899e7c19..ab7d2cae 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -21,9 +21,18 @@ in { treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars; - pluginRC.treesitter-autocommands = entryAfter ["basic"] '' - vim.api.nvim_create_augroup("nvf_treesitter", { clear = true }) + # Define the autogroup for treesitter here rather than in the Lua snippet + # to allow overriding more easily. Should be highly unlikely that a user + # wants to override, but not impossible. + augroups = [ + { + enable = true; + name = "nvf_treesitter"; + clear = true; + } + ]; + pluginRC.treesitter-autocommands = entryAfter ["basic"] '' ${lib.optionalString cfg.highlight.enable '' -- Enable treesitter highlighting for all filetypes vim.api.nvim_create_autocmd("FileType", { @@ -54,6 +63,7 @@ in { callback = function() vim.wo[0][0].foldmethod = "expr" vim.wo[0][0].foldexpr = "v:lua.vim.treesitter.foldexpr()" + -- This is optional, but is set rather as a sane default. -- If unset, opened files will be folded by automatically as -- the files are opened From 100d9e59a1a6a1ec78abba4d906e86e76ba871b5 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 27 Jan 2026 16:10:19 +0300 Subject: [PATCH 4/4] Revert "treesitter: move autogroup definition to augroup module" This reverts commit 33cc70b4db47a13383606fd997579110b146c936. Signed-off-by: NotAShelf Change-Id: Ida7d935c48909fdfa9978b6e199f222a6a6a6964 --- modules/plugins/treesitter/config.nix | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index ab7d2cae..899e7c19 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -21,18 +21,9 @@ in { treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars; - # Define the autogroup for treesitter here rather than in the Lua snippet - # to allow overriding more easily. Should be highly unlikely that a user - # wants to override, but not impossible. - augroups = [ - { - enable = true; - name = "nvf_treesitter"; - clear = true; - } - ]; - pluginRC.treesitter-autocommands = entryAfter ["basic"] '' + vim.api.nvim_create_augroup("nvf_treesitter", { clear = true }) + ${lib.optionalString cfg.highlight.enable '' -- Enable treesitter highlighting for all filetypes vim.api.nvim_create_autocmd("FileType", { @@ -63,7 +54,6 @@ in { callback = function() vim.wo[0][0].foldmethod = "expr" vim.wo[0][0].foldexpr = "v:lua.vim.treesitter.foldexpr()" - -- This is optional, but is set rather as a sane default. -- If unset, opened files will be folded by automatically as -- the files are opened