aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/util.lua
diff options
context:
space:
mode:
authorRaphael <glepnir@neovim.pro>2023-04-12 11:52:32 +0800
committerGitHub <noreply@github.com>2023-04-12 11:52:32 +0800
commit6fe69025b8825029ea9bf291ab3b1750f9bcb39e (patch)
tree7de8870070292ddacc9bf80c43c138eef7f865a3 /lua/lspconfig/util.lua
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-6fe69025b8825029ea9bf291ab3b1750f9bcb39e.tar
nvim-lspconfig-6fe69025b8825029ea9bf291ab3b1750f9bcb39e.tar.gz
nvim-lspconfig-6fe69025b8825029ea9bf291ab3b1750f9bcb39e.tar.bz2
nvim-lspconfig-6fe69025b8825029ea9bf291ab3b1750f9bcb39e.tar.lz
nvim-lspconfig-6fe69025b8825029ea9bf291ab3b1750f9bcb39e.tar.xz
nvim-lspconfig-6fe69025b8825029ea9bf291ab3b1750f9bcb39e.tar.zst
nvim-lspconfig-6fe69025b8825029ea9bf291ab3b1750f9bcb39e.zip
fix(eslint): get root patterns by given path (#2556)
Diffstat (limited to 'lua/lspconfig/util.lua')
-rw-r--r--lua/lspconfig/util.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 8725413b..5aff4f39 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -487,15 +487,16 @@ function M.find_package_json_ancestor(startpath)
end)
end
-function M.insert_package_json(config_files, field)
- local root_with_package = M.find_package_json_ancestor(vim.fn.expand '%:p:h')
+function M.insert_package_json(config_files, field, fname)
+ local path = vim.fn.fnamemodify(fname, ':h')
+ local root_with_package = M.find_package_json_ancestor(path)
if root_with_package then
-- only add package.json if it contains field parameter
local path_sep = is_windows and '\\' or '/'
for line in io.lines(root_with_package .. path_sep .. 'package.json') do
if line:find(field) then
- table.insert(config_files, 'package.json')
+ config_files[#config_files + 1] = 'package.json'
break
end
end