refactored plugins and configurations
This commit is contained in:
170
lua/plugins/lspconfig.lua
Normal file
170
lua/plugins/lspconfig.lua
Normal file
@@ -0,0 +1,170 @@
|
||||
-- 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
|
||||
|
||||
return {
|
||||
-- LSP configuration
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
-- ─────────────────────────────────────────────────────────────────
|
||||
-- Go
|
||||
-- ─────────────────────────────────────────────────────────────────
|
||||
gopls = {
|
||||
root_dir = make_root_detector({ "go.work", "go.mod" }),
|
||||
settings = {
|
||||
gopls = {
|
||||
gofumpt = true,
|
||||
codelenses = {
|
||||
gc_details = false,
|
||||
generate = true,
|
||||
regenerate_cgo = true,
|
||||
run_govulncheck = true,
|
||||
test = true,
|
||||
tidy = true,
|
||||
upgrade_dependency = true,
|
||||
vendor = true,
|
||||
},
|
||||
hints = {
|
||||
assignVariableTypes = true,
|
||||
compositeLiteralFields = true,
|
||||
compositeLiteralTypes = true,
|
||||
constantValues = true,
|
||||
functionTypeParameters = true,
|
||||
parameterNames = true,
|
||||
rangeVariableTypes = true,
|
||||
},
|
||||
analyses = {
|
||||
fieldalignment = true,
|
||||
nilness = true,
|
||||
unusedparams = true,
|
||||
unusedwrite = true,
|
||||
useany = true,
|
||||
},
|
||||
usePlaceholders = true,
|
||||
completeUnimported = true,
|
||||
staticcheck = true,
|
||||
directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" },
|
||||
semanticTokens = true,
|
||||
expandWorkspaceToModule = true,
|
||||
experimentalPostfixCompletions = true,
|
||||
["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 = { checkThirdParty = false },
|
||||
completion = { callSnippet = "Replace" },
|
||||
diagnostics = { globals = { "vim" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────
|
||||
-- TypeScript / JavaScript
|
||||
-- ─────────────────────────────────────────────────────────────────
|
||||
ts_ls = {
|
||||
root_dir = make_root_detector({ "tsconfig.json", "jsconfig.json", "package.json" }),
|
||||
settings = {
|
||||
typescript = {
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = "all",
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = true,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
},
|
||||
},
|
||||
javascript = {
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = "all",
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = true,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────
|
||||
-- Web (HTML / CSS / JSON / YAML)
|
||||
-- ─────────────────────────────────────────────────────────────────
|
||||
html = {
|
||||
root_dir = make_root_detector({ "package.json", ".git" }),
|
||||
filetypes = { "html", "templ" },
|
||||
},
|
||||
|
||||
cssls = {
|
||||
root_dir = make_root_detector({ "package.json", ".git" }),
|
||||
},
|
||||
|
||||
jsonls = {
|
||||
root_dir = make_root_detector({ "package.json", ".git" }),
|
||||
},
|
||||
|
||||
yamlls = {
|
||||
root_dir = make_root_detector({ "package.json", ".git" }),
|
||||
settings = {
|
||||
yaml = {
|
||||
keyOrdering = false,
|
||||
schemas = {
|
||||
["https://json.schemastore.org/github-workflow.json"] = "/.github/workflows/*",
|
||||
["https://json.schemastore.org/docker-compose.json"] = "docker-compose*.yml",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- ─────────────────────────────────────────────────────────────────
|
||||
-- Markdown / SQL / Docker
|
||||
-- ─────────────────────────────────────────────────────────────────
|
||||
marksman = {
|
||||
root_dir = make_root_detector({ ".marksman.toml", ".git" }),
|
||||
},
|
||||
|
||||
sqlls = {
|
||||
root_dir = make_root_detector({ ".sqllsrc.json", "sqlls.json", ".git" }),
|
||||
},
|
||||
|
||||
dockerls = {},
|
||||
docker_compose_language_server = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user