aboutsummaryrefslogtreecommitdiffstats
path: root/lsp
diff options
context:
space:
mode:
authorApocalypse <249175311@qq.com>2025-11-17 04:18:11 +0800
committerGitHub <noreply@github.com>2025-11-16 12:18:11 -0800
commit781e4bdf427d0fb17ceef2ee4db172a29825fd73 (patch)
tree4778bd0bf808bed0e9b4c5fa76a18730ccaec08f /lsp
parentdocs: update configs.md (diff)
downloadnvim-lspconfig-781e4bdf427d0fb17ceef2ee4db172a29825fd73.tar
nvim-lspconfig-781e4bdf427d0fb17ceef2ee4db172a29825fd73.tar.gz
nvim-lspconfig-781e4bdf427d0fb17ceef2ee4db172a29825fd73.tar.bz2
nvim-lspconfig-781e4bdf427d0fb17ceef2ee4db172a29825fd73.tar.lz
nvim-lspconfig-781e4bdf427d0fb17ceef2ee4db172a29825fd73.tar.xz
nvim-lspconfig-781e4bdf427d0fb17ceef2ee4db172a29825fd73.tar.zst
nvim-lspconfig-781e4bdf427d0fb17ceef2ee4db172a29825fd73.zip
fix(lsp): improve ts_ls root detection for deno projects #4193
Refactor project root detection logic to properly exclude ts_ls when deno.json/deno.lock are at the same or higher level than project markers. Co-authored-by: yzs <yuanzishuai@qq.com>
Diffstat (limited to 'lsp')
-rw-r--r--lsp/ts_ls.lua10
1 files changed, 4 insertions, 6 deletions
diff --git a/lsp/ts_ls.lua b/lsp/ts_ls.lua
index 8b77c6a5..cc588007 100644
--- a/lsp/ts_ls.lua
+++ b/lsp/ts_ls.lua
@@ -62,16 +62,14 @@ return {
-- Give the root markers equal priority by wrapping them in a table
root_markers = vim.fn.has('nvim-0.11.3') == 1 and { root_markers, { '.git' } }
or vim.list_extend(root_markers, { '.git' })
-
-- exclude deno
- if vim.fs.root(bufnr, { 'deno.json', 'deno.lock' }) then
+ local deno_path = vim.fs.root(bufnr, { 'deno.json', 'deno.lock' })
+ local project_root = vim.fs.root(bufnr, { root_markers })
+ if deno_path and not project_root or #deno_path >= #project_root then
return
end
-
-- We fallback to the current working directory if no project root is found
- local project_root = vim.fs.root(bufnr, root_markers) or vim.fn.getcwd()
-
- on_dir(project_root)
+ on_dir(project_root or vim.fn.getcwd())
end,
handlers = {
-- handle rename request for certain code actions like extracting functions / types