aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorMohamed Hubail <mohamed.hubail@array.world>2025-04-27 17:13:04 +0300
committerGitHub <noreply@github.com>2025-04-27 07:13:04 -0700
commit641e567f975feab3815b47c7d29e6148e07afa77 (patch)
tree9289267736bf6b27ad6a18d7fd786adb07924117 /lua
parentfix(rust_analyzer): scheduled vim.notify in on_exit of vim.system(#3793) (diff)
downloadnvim-lspconfig-641e567f975feab3815b47c7d29e6148e07afa77.tar
nvim-lspconfig-641e567f975feab3815b47c7d29e6148e07afa77.tar.gz
nvim-lspconfig-641e567f975feab3815b47c7d29e6148e07afa77.tar.bz2
nvim-lspconfig-641e567f975feab3815b47c7d29e6148e07afa77.tar.lz
nvim-lspconfig-641e567f975feab3815b47c7d29e6148e07afa77.tar.xz
nvim-lspconfig-641e567f975feab3815b47c7d29e6148e07afa77.tar.zst
nvim-lspconfig-641e567f975feab3815b47c7d29e6148e07afa77.zip
feat(util): support "package.json5" #3794
Problem: Root detection fails when using `package.json5`. #3710 Solution: Modify `insert_package_json` to support `package.json5`.
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/util.lua7
1 files changed, 3 insertions, 4 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 915e1b41..a8cf7439 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -46,14 +46,13 @@ end
function M.insert_package_json(config_files, field, fname)
local path = vim.fn.fnamemodify(fname, ':h')
- local root_with_package = vim.fs.dirname(vim.fs.find('package.json', { path = path, upward = true })[1])
+ local root_with_package = vim.fs.find({ 'package.json', 'package.json5' }, { path = path, upward = true })[1]
if root_with_package then
-- only add package.json if it contains field parameter
- local path_sep = iswin and '\\' or '/'
- for line in io.lines(root_with_package .. path_sep .. 'package.json') do
+ for line in io.lines(root_with_package) do
if line:find(field) then
- config_files[#config_files + 1] = 'package.json'
+ config_files[#config_files + 1] = vim.fs.basename(root_with_package)
break
end
end