diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2025-05-04 14:11:18 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-04 14:11:18 -0700 |
| commit | 2a6517453feb6f00e3d64bcb4fde61934897f4bd (patch) | |
| tree | dc681744b655f6eb40478ef6d7ae5495686f2b71 /lua | |
| parent | feat: support :LspStart/LspRestart in Nvim 0.11.2+ #3734 (diff) | |
| download | nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar.gz nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar.bz2 nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar.lz nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar.xz nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.tar.zst nvim-lspconfig-2a6517453feb6f00e3d64bcb4fde61934897f4bd.zip | |
fix(configs): eliminate some usages of root_pattern #3820
Problem:
`root_pattern` is not necessary for non-glob patterns.
Solution:
Replace non-glob cases with `vim.fs.root()`..
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/util.lua | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 2807edf3..5d9c213c 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -24,6 +24,9 @@ local function escape_wildcards(path) return path:gsub('([%[%]%?%*])', '\\%1') end +--- Returns a function which matches a filepath against the given glob/wildcard patterns. +--- +--- Also works with zipfile:/tarfile: buffers (via `strip_archive_subpath`). function M.root_pattern(...) local patterns = M.tbl_flatten { ... } return function(startpath) @@ -44,6 +47,11 @@ function M.root_pattern(...) end end +--- Appends package.json-like files to the `config_files` list if `field` +--- is found in any such file in any ancestor of `fname`. +--- +--- NOTE: this does a "breadth-first" search, so is broken for multi-project workspaces: +--- https://github.com/neovim/nvim-lspconfig/issues/3818#issuecomment-2848836794 function M.insert_package_json(config_files, field, fname) local path = vim.fn.fnamemodify(fname, ':h') local root_with_package = vim.fs.find({ 'package.json', 'package.json5' }, { path = path, upward = true })[1] |
