Hopefully the fix *crosses fingers*
This commit is contained in:
@@ -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 = {},
|
||||
|
||||
Reference in New Issue
Block a user