Files
nvim-config/lua/plugins/lspconfig.lua

183 lines
6.2 KiB
Lua

-- 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 {
{
"neovim/nvim-lspconfig",
opts = {
servers = {
-- -----------------------------------------------------------------
-- Go
-- -----------------------------------------------------------------
gopls = {
root_markers = { "go.work", "go.mod", ".git" },
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" },
},
},
cmd_env = {
GOEXPERIMENT = "jsonv2",
},
},
-- -----------------------------------------------------------------
-- Zig
-- -----------------------------------------------------------------
zig = {
root_markers = { "build.zig", "build.zig.zon" },
settings = {
zls = {
enable_build_on_save = true,
-- "watch" or specify a step name your build.zig defines
build_on_save_step = "install",
semantic_tokens = "full",
enable_inlay_hints = true,
inlay_hints_show_parameter_name = true,
inlay_hints_show_builtin = true,
inlay_hints_show_variable_type_hints = true,
warn_style = true,
},
},
},
-- -----------------------------------------------------------------
-- Lua
-- -----------------------------------------------------------------
lua_ls = {
root_markers = {
".luarc.json",
".luarc.jsonc",
".luacheckrc",
".stylua.toml",
"stylua.toml",
"selene.toml",
"selene.yml",
".git",
},
settings = {
Lua = {
workspace = { checkThirdParty = false },
completion = { callSnippet = "Replace" },
diagnostics = { globals = { "vim" } },
},
},
},
-- -----------------------------------------------------------------
-- TypeScript / JavaScript
-- -----------------------------------------------------------------
ts_ls = {
root_markers = { "tsconfig.json", "jsconfig.json", "package.json", ".git" },
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_markers = { "package.json", ".git" },
filetypes = { "html", "templ" },
},
cssls = {
root_markers = { "package.json", ".git" },
},
jsonls = {
root_markers = { "package.json", ".git" },
},
yamlls = {
root_markers = { "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_markers = { ".marksman.toml", ".git" },
},
sqlls = {
root_markers = { ".sqllsrc.json", "sqlls.json", ".git" },
},
dockerls = {},
docker_compose_language_server = {},
},
},
},
}