updated editor and lsp
This commit is contained in:
@@ -1,6 +1,21 @@
|
||||
-- LSP Configuration
|
||||
-- Extends LazyVim's built-in LSP support
|
||||
|
||||
-- Helper function for monorepo root detection
|
||||
-- Finds nearest project marker, with fallback to git root
|
||||
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
|
||||
|
||||
return {
|
||||
-- Mason: manage LSP servers, linters, formatters
|
||||
{
|
||||
@@ -40,6 +55,8 @@ return {
|
||||
servers = {
|
||||
-- Go
|
||||
gopls = {
|
||||
-- Root detection: find go.work first, then go.mod, then git root
|
||||
root_dir = make_root_detector({ "go.work", "go.mod" }),
|
||||
settings = {
|
||||
gopls = {
|
||||
gofumpt = true,
|
||||
@@ -74,12 +91,19 @@ return {
|
||||
staticcheck = true,
|
||||
directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" },
|
||||
semanticTokens = true,
|
||||
-- Monorepo/workspace support
|
||||
expandWorkspaceToModule = true,
|
||||
experimentalPostfixCompletions = true,
|
||||
-- Handle multiple modules
|
||||
["build.standaloneTags"] = { "ignore" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Lua
|
||||
lua_ls = {
|
||||
root_dir = make_root_detector({ ".luarc.json", ".luarc.jsonc", ".luacheckrc", ".stylua.toml", "stylua.toml",
|
||||
"selene.toml", "selene.yml" }),
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = {
|
||||
@@ -97,6 +121,8 @@ return {
|
||||
|
||||
-- TypeScript/JavaScript
|
||||
ts_ls = {
|
||||
-- Root detection: find nearest tsconfig/package.json
|
||||
root_dir = make_root_detector({ "tsconfig.json", "jsconfig.json", "package.json" }),
|
||||
settings = {
|
||||
typescript = {
|
||||
inlayHints = {
|
||||
@@ -125,17 +151,23 @@ return {
|
||||
|
||||
-- HTML
|
||||
html = {
|
||||
root_dir = make_root_detector({ "package.json", ".git" }),
|
||||
filetypes = { "html", "templ" },
|
||||
},
|
||||
|
||||
-- CSS
|
||||
cssls = {},
|
||||
cssls = {
|
||||
root_dir = make_root_detector({ "package.json", ".git" }),
|
||||
},
|
||||
|
||||
-- JSON
|
||||
jsonls = {},
|
||||
jsonls = {
|
||||
root_dir = make_root_detector({ "package.json", ".git" }),
|
||||
},
|
||||
|
||||
-- YAML
|
||||
yamlls = {
|
||||
root_dir = make_root_detector({ "package.json", ".git" }),
|
||||
settings = {
|
||||
yaml = {
|
||||
keyOrdering = false,
|
||||
@@ -148,10 +180,14 @@ return {
|
||||
},
|
||||
|
||||
-- Markdown
|
||||
marksman = {},
|
||||
marksman = {
|
||||
root_dir = make_root_detector({ ".marksman.toml", ".git" }),
|
||||
},
|
||||
|
||||
-- SQL
|
||||
sqlls = {},
|
||||
sqlls = {
|
||||
root_dir = make_root_detector({ ".sqllsrc.json", "sqlls.json", ".git" }),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user