aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/configs/angularls.lua2
-rw-r--r--lua/lspconfig/configs/astro.lua2
-rw-r--r--lua/lspconfig/configs/glint.lua2
-rw-r--r--lua/lspconfig/configs/mdx_analyzer.lua2
-rw-r--r--lua/lspconfig/configs/relay_lsp.lua2
-rw-r--r--lua/lspconfig/configs/rome.lua2
-rw-r--r--lua/lspconfig/configs/tailwindcss.lua7
-rw-r--r--lua/lspconfig/configs/volar.lua2
-rw-r--r--lua/lspconfig/util.lua13
9 files changed, 16 insertions, 18 deletions
diff --git a/lua/lspconfig/configs/angularls.lua b/lua/lspconfig/configs/angularls.lua
index 0f4d042f..c704f508 100644
--- a/lua/lspconfig/configs/angularls.lua
+++ b/lua/lspconfig/configs/angularls.lua
@@ -4,7 +4,7 @@ local util = require 'lspconfig.util'
-- in order to use your projects configured versions.
-- This defaults to the vim cwd, but will get overwritten by the resolved root of the file.
local function get_probe_dir(root_dir)
- local project_root = util.find_node_modules_ancestor(root_dir)
+ local project_root = vim.fs.find('node_modules', { path = root_dir, upward = true })[1]
return project_root and (project_root .. '/node_modules') or ''
end
diff --git a/lua/lspconfig/configs/astro.lua b/lua/lspconfig/configs/astro.lua
index 5151937a..ce54391b 100644
--- a/lua/lspconfig/configs/astro.lua
+++ b/lua/lspconfig/configs/astro.lua
@@ -1,7 +1,7 @@
local util = require 'lspconfig.util'
local function get_typescript_server_path(root_dir)
- local project_root = util.find_node_modules_ancestor(root_dir)
+ local project_root = vim.fs.find('node_modules', { path = root_dir, upward = true })[1]
return project_root and (util.path.join(project_root, 'node_modules', 'typescript', 'lib')) or ''
end
diff --git a/lua/lspconfig/configs/glint.lua b/lua/lspconfig/configs/glint.lua
index 1d991cff..370d2797 100644
--- a/lua/lspconfig/configs/glint.lua
+++ b/lua/lspconfig/configs/glint.lua
@@ -4,7 +4,7 @@ return {
default_config = {
cmd = { 'glint-language-server' },
on_new_config = function(config, new_root_dir)
- local project_root = util.find_node_modules_ancestor(new_root_dir)
+ local project_root = vim.fs.find('node_modules', { path = new_root_dir, upward = true })[1]
-- Glint should not be installed globally.
local node_bin_path = util.path.join(project_root, 'node_modules', '.bin')
local path = node_bin_path .. util.path.path_separator .. vim.env.PATH
diff --git a/lua/lspconfig/configs/mdx_analyzer.lua b/lua/lspconfig/configs/mdx_analyzer.lua
index 1dfbcb5a..311d90de 100644
--- a/lua/lspconfig/configs/mdx_analyzer.lua
+++ b/lua/lspconfig/configs/mdx_analyzer.lua
@@ -1,7 +1,7 @@
local util = require 'lspconfig.util'
local function get_typescript_server_path(root_dir)
- local project_root = util.find_node_modules_ancestor(root_dir)
+ local project_root = vim.fs.find('node_modules', { path = root_dir, upward = true })[1]
return project_root and (util.path.join(project_root, 'node_modules', 'typescript', 'lib')) or ''
end
diff --git a/lua/lspconfig/configs/relay_lsp.lua b/lua/lspconfig/configs/relay_lsp.lua
index 66e00384..a0ebaf63 100644
--- a/lua/lspconfig/configs/relay_lsp.lua
+++ b/lua/lspconfig/configs/relay_lsp.lua
@@ -23,7 +23,7 @@ return {
},
root_dir = util.root_pattern('relay.config.*', 'package.json'),
on_new_config = function(config, root_dir)
- local project_root = util.find_node_modules_ancestor(root_dir)
+ local project_root = vim.fs.find('node_modules', { path = root_dir, upward = true })[1]
local node_bin_path = util.path.join(project_root, 'node_modules', '.bin')
local compiler_cmd = { util.path.join(node_bin_path, 'relay-compiler'), '--watch' }
local path = node_bin_path .. util.path.path_separator .. vim.env.PATH
diff --git a/lua/lspconfig/configs/rome.lua b/lua/lspconfig/configs/rome.lua
index 6847c0d4..831469e4 100644
--- a/lua/lspconfig/configs/rome.lua
+++ b/lua/lspconfig/configs/rome.lua
@@ -13,7 +13,7 @@ return {
},
root_dir = function(fname)
return util.find_package_json_ancestor(fname)
- or util.find_node_modules_ancestor(fname)
+ or vim.fs.find('node_modules', { path = fname, upward = true })[1]
or util.find_git_ancestor(fname)
end,
single_file_support = true,
diff --git a/lua/lspconfig/configs/tailwindcss.lua b/lua/lspconfig/configs/tailwindcss.lua
index 599cbed9..56ed05b4 100644
--- a/lua/lspconfig/configs/tailwindcss.lua
+++ b/lua/lspconfig/configs/tailwindcss.lua
@@ -109,9 +109,10 @@ return {
'postcss.config.cjs',
'postcss.config.mjs',
'postcss.config.ts'
- )(fname) or util.find_package_json_ancestor(fname) or util.find_node_modules_ancestor(fname) or util.find_git_ancestor(
- fname
- )
+ )(fname) or util.find_package_json_ancestor(fname) or vim.fs.find(
+ 'node_modules',
+ { path = fname, upward = true }
+ )[1] or util.find_git_ancestor(fname)
end,
},
docs = {
diff --git a/lua/lspconfig/configs/volar.lua b/lua/lspconfig/configs/volar.lua
index d4a65e4c..d0fa2e4d 100644
--- a/lua/lspconfig/configs/volar.lua
+++ b/lua/lspconfig/configs/volar.lua
@@ -1,7 +1,7 @@
local util = require 'lspconfig.util'
local function get_typescript_server_path(root_dir)
- local project_root = util.find_node_modules_ancestor(root_dir)
+ local project_root = vim.fs.find('node_modules', { path = root_dir, upward = true })[1]
return project_root and (util.path.join(project_root, 'node_modules', 'typescript', 'lib')) or ''
end
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 1b186e85..7b894ee3 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -246,14 +246,6 @@ function M.find_git_ancestor(startpath)
end)
end
-function M.find_node_modules_ancestor(startpath)
- return M.search_ancestors(startpath, function(path)
- if vim.fn.isdirectory(M.path.join(path, 'node_modules')) == 1 then
- return path
- end
- end)
-end
-
function M.find_package_json_ancestor(startpath)
return M.search_ancestors(startpath, function(path)
local jsonpath = M.path.join(path, 'package.json')
@@ -400,4 +392,9 @@ function M.find_mercurial_ancestor(startpath)
return vim.fs.find('.hg', { path = startpath, upward = true })[1]
end
+--- @deprecated use `vim.fs.find('node_modules', { path = startpath, upward = true })[1]` instead
+function M.find_node_modules_ancestor(startpath)
+ return vim.fs.find('node_modules', { path = startpath, upward = true })[1]
+end
+
return M