From f00fac336338cb502462b721f20d93e61ad4d1a8 Mon Sep 17 00:00:00 2001 From: Samuel O'Neal Date: Wed, 20 May 2026 13:27:29 -0600 Subject: [PATCH] Hopefully the fix *crosses fingers* --- lua/plugins/lspconfig.lua | 47 +++++++++++++++------------------------ 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index f86ddd0..bc79aea 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -1,24 +1,12 @@ --- LSP Configuration --- Extends LazyVim's built-in LSP support - --- Root detection: nearest project marker, falling back to git root. --- The require is inside the returned function so lspconfig.util is loaded --- lazily at attach time, not at module load. -local function make_root_detector(markers) - return function(fname) - local util = require("lspconfig.util") - -- First try language-specific markers (nearest to file) - local root = util.root_pattern(unpack(markers))(fname) - if root then - return root - end - -- Fallback to git root - return util.root_pattern(".git")(fname) - end -end +-- LSP server configurations +-- Extends LazyVim's nvim-lspconfig setup via opts.servers. +-- +-- Uses `root_markers` (Neovim 0.11+ vim.lsp.config API) instead of a custom +-- root_dir function. root_markers is a list of filenames that, when found +-- walking upward from the buffer, identify the workspace root. `.git` is +-- always listed last as a fallback. return { - -- LSP configuration { "neovim/nvim-lspconfig", opts = { @@ -27,7 +15,7 @@ return { -- Go -- ───────────────────────────────────────────────────────────────── gopls = { - root_dir = make_root_detector({ "go.work", "go.mod" }), + root_markers = { "go.work", "go.mod", ".git" }, settings = { gopls = { gofumpt = true, @@ -73,7 +61,7 @@ return { -- Lua -- ───────────────────────────────────────────────────────────────── lua_ls = { - root_dir = make_root_detector({ + root_markers = { ".luarc.json", ".luarc.jsonc", ".luacheckrc", @@ -81,7 +69,8 @@ return { "stylua.toml", "selene.toml", "selene.yml", - }), + ".git", + }, settings = { Lua = { workspace = { checkThirdParty = false }, @@ -95,7 +84,7 @@ return { -- TypeScript / JavaScript -- ───────────────────────────────────────────────────────────────── ts_ls = { - root_dir = make_root_detector({ "tsconfig.json", "jsconfig.json", "package.json" }), + root_markers = { "tsconfig.json", "jsconfig.json", "package.json", ".git" }, settings = { typescript = { inlayHints = { @@ -126,20 +115,20 @@ return { -- Web (HTML / CSS / JSON / YAML) -- ───────────────────────────────────────────────────────────────── html = { - root_dir = make_root_detector({ "package.json", ".git" }), + root_markers = { "package.json", ".git" }, filetypes = { "html", "templ" }, }, cssls = { - root_dir = make_root_detector({ "package.json", ".git" }), + root_markers = { "package.json", ".git" }, }, jsonls = { - root_dir = make_root_detector({ "package.json", ".git" }), + root_markers = { "package.json", ".git" }, }, yamlls = { - root_dir = make_root_detector({ "package.json", ".git" }), + root_markers = { "package.json", ".git" }, settings = { yaml = { keyOrdering = false, @@ -155,11 +144,11 @@ return { -- Markdown / SQL / Docker -- ───────────────────────────────────────────────────────────────── marksman = { - root_dir = make_root_detector({ ".marksman.toml", ".git" }), + root_markers = { ".marksman.toml", ".git" }, }, sqlls = { - root_dir = make_root_detector({ ".sqllsrc.json", "sqlls.json", ".git" }), + root_markers = { ".sqllsrc.json", "sqlls.json", ".git" }, }, dockerls = {},