mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/lsp/servers: replace rootDir
with rootMarkers
nvim-lspconfig historically used `root_dir`, along with util functions like `root_pattern`. Now that neovim's own LSP API is used, `root_dir` appears to be subtly different and `root_markers` is introduced to replace `util.root_pattern`. Since we cannot easily warn about the `root_dir` differences, it can usually be replaced with `root_markers`, and can still be manually configured via `extraOptions` if needed; the simplest approach here is to remove the `rootDir` option.
This commit is contained in:
parent
a21504f2b0
commit
b72ba2e4e2
2 changed files with 23 additions and 9 deletions
|
@ -106,10 +106,16 @@ in
|
||||||
`:LspStart` (|lspconfig-commands|).
|
`:LspStart` (|lspconfig-commands|).
|
||||||
'';
|
'';
|
||||||
|
|
||||||
rootDir = lib.nixvim.defaultNullOpts.mkLuaFn "nil" ''
|
rootMarkers = lib.nixvim.defaultNullOpts.mkListOf types.str null ''
|
||||||
A function (or function handle) which returns the root of the project used to
|
A list of files that mark the root of the project/workspace.
|
||||||
determine if lspconfig should launch a new language server, or attach a previously
|
|
||||||
launched server when you open a new buffer matching the filetype of the server.
|
Vim's LSP will try to share the same language server instance for all
|
||||||
|
buffers matching `filetypes` within the same project.
|
||||||
|
|
||||||
|
A new server instance is only spawned when opening a buffer with a
|
||||||
|
different project root.
|
||||||
|
|
||||||
|
See `:h lsp-config` and `:h vim.fs.root()`.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
onAttach = lib.nixvim.mkCompositeOption "Server specific on_attach behavior." {
|
onAttach = lib.nixvim.mkCompositeOption "Server specific on_attach behavior." {
|
||||||
|
@ -149,7 +155,7 @@ in
|
||||||
name = serverName;
|
name = serverName;
|
||||||
extraOptions = {
|
extraOptions = {
|
||||||
inherit (cfg) cmd filetypes autostart;
|
inherit (cfg) cmd filetypes autostart;
|
||||||
root_dir = cfg.rootDir;
|
root_markers = cfg.rootMarkers;
|
||||||
on_attach = lib.nixvim.ifNonNull' cfg.onAttach (
|
on_attach = lib.nixvim.ifNonNull' cfg.onAttach (
|
||||||
lib.nixvim.mkRaw ''
|
lib.nixvim.mkRaw ''
|
||||||
function(client, bufnr)
|
function(client, bufnr)
|
||||||
|
@ -183,6 +189,13 @@ in
|
||||||
(lib.mkRemovedOptionModule (
|
(lib.mkRemovedOptionModule (
|
||||||
basePluginPath ++ [ "extraSettings" ]
|
basePluginPath ++ [ "extraSettings" ]
|
||||||
) "You can use `${basePluginPathString}.extraOptions.settings` instead.")
|
) "You can use `${basePluginPathString}.extraOptions.settings` instead.")
|
||||||
|
(lib.mkRemovedOptionModule (basePluginPath ++ [ "rootDir" ]) ''
|
||||||
|
|
||||||
|
nvim-lspconfig has switched from its own `root_dir` implementation to using neovim's built-in LSP API.
|
||||||
|
|
||||||
|
In most cases you can use `${opts.rootMarkers}` instead. It should be a list of files that mark the root of the project.
|
||||||
|
In more complex cases you can still use `${opts.extraOptions}.root_dir`.
|
||||||
|
'')
|
||||||
]
|
]
|
||||||
++ lib.optional (args ? extraConfig) (
|
++ lib.optional (args ? extraConfig) (
|
||||||
lib.nixvim.plugins.utils.applyExtraConfig {
|
lib.nixvim.plugins.utils.applyExtraConfig {
|
||||||
|
|
|
@ -84,12 +84,13 @@
|
||||||
filetypes = [ "python" ];
|
filetypes = [ "python" ];
|
||||||
autostart = false;
|
autostart = false;
|
||||||
};
|
};
|
||||||
# rootDir
|
# rootMarkers
|
||||||
tinymist = {
|
tinymist = {
|
||||||
enable = true;
|
enable = true;
|
||||||
rootDir = ''
|
rootMarkers = [
|
||||||
require 'lspconfig.util'.root_pattern('.git', 'main.typ')
|
".git"
|
||||||
'';
|
"main.typ"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue