aboutsummaryrefslogtreecommitdiffstats
path: root/lsp/denols.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lsp/denols.lua')
-rw-r--r--lsp/denols.lua19
1 files changed, 18 insertions, 1 deletions
diff --git a/lsp/denols.lua b/lsp/denols.lua
index a55aa87a..b5d9ffe2 100644
--- a/lsp/denols.lua
+++ b/lsp/denols.lua
@@ -75,7 +75,24 @@ return {
'typescriptreact',
'typescript.tsx',
},
- root_markers = { 'deno.json', 'deno.jsonc', '.git' },
+ root_dir = function(bufnr, on_dir)
+ -- The project root is where the LSP can be started from
+ local root_markers = { 'deno.lock' }
+ -- 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 non-deno projects (npm, yarn, pnpm, bun)
+ local non_deno_path = vim.fs.root(
+ bufnr,
+ { 'package.json', 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock' }
+ )
+ local project_root = vim.fs.root(bufnr, root_markers)
+ if non_deno_path and (not project_root or #non_deno_path >= #project_root) then
+ return
+ end
+ -- We fallback to the current working directory if no project root is found
+ on_dir(project_root or vim.fn.getcwd())
+ end,
settings = {
deno = {
enable = true,