From ec54d14e0ad816e4099738a2b8f8e61ed3c9430e Mon Sep 17 00:00:00 2001 From: Alexis Tacnet Date: Thu, 11 Sep 2025 05:31:23 +0200 Subject: fix: ts/js LSPs require lockfile #4062 Problem: Some projects don't have a lockfile. Solution: - Fallback to ".git" as a lower-priority root-marker (Nvim 0.11.3+). - Fallback to CWD. --- lsp/tsgo.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lsp/tsgo.lua') diff --git a/lsp/tsgo.lua b/lsp/tsgo.lua index 3b26ad10..3ef9a921 100644 --- a/lsp/tsgo.lua +++ b/lsp/tsgo.lua @@ -32,11 +32,10 @@ return { -- manager lock file. local root_markers = { 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock', '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 } or root_markers - local project_root = vim.fs.root(bufnr, root_markers) - if not project_root then - return - end + root_markers = vim.fn.has('nvim-0.11.3') == 1 and { root_markers, { '.git' } } + or vim.list_extend(root_markers, { '.git' }) + -- 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) end, -- cgit v1.2.3-70-g09d2