chopsticks/lua/plugins/lsp.lua
2025-06-25 09:48:07 +08:00

179 lines
4.2 KiB
Lua

return {
-- tools
{
"williamboman/mason.nvim",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed, {
"stylua",
"selene",
"luacheck",
"shellcheck",
"shfmt",
"tailwindcss-language-server",
"typescript-language-server",
"css-lsp",
"clangd",
})
end,
},
-- lsp servers
{
"neovim/nvim-lspconfig",
opts = {
inlay_hints = { enabled = false },
---@type lspconfig.options
servers = {
cssls = {},
tailwindcss = {
root_dir = function(...)
return require("lspconfig.util").root_pattern(".git")(...)
end,
},
tsserver = {
root_dir = function(...)
return require("lspconfig.util").root_pattern(".git")(...)
end,
single_file_support = false,
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = "literal",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = false,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
javascript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
},
},
html = {},
yamlls = {
settings = {
yaml = {
keyOrdering = false,
},
},
},
lua_ls = {
-- enabled = false,
single_file_support = true,
settings = {
Lua = {
workspace = {
checkThirdParty = false,
},
completion = {
workspaceWord = true,
callSnippet = "Both",
},
misc = {
parameters = {
-- "--log-level=trace",
},
},
hint = {
enable = true,
setType = false,
paramType = true,
paramName = "Disable",
semicolon = "Disable",
arrayIndex = "Disable",
},
doc = {
privateName = { "^_" },
},
type = {
castNumberToInteger = true,
},
diagnostics = {
disable = { "incomplete-signature-doc", "trailing-space" },
-- enable = false,
groupSeverity = {
strong = "Warning",
strict = "Warning",
},
groupFileStatus = {
["ambiguity"] = "Opened",
["await"] = "Opened",
["codestyle"] = "None",
["duplicate"] = "Opened",
["global"] = "Opened",
["luadoc"] = "Opened",
["redefined"] = "Opened",
["strict"] = "Opened",
["strong"] = "Opened",
["type-check"] = "Opened",
["unbalanced"] = "Opened",
["unused"] = "Opened",
},
unusedLocalExclude = { "_*" },
},
format = {
enable = false,
defaultConfig = {
indent_style = "space",
indent_size = "2",
continuation_indent_size = "2",
},
},
},
},
},
gopls = {
settings = {
gopls = {
analyses = {
unusedparams = true,
shadow = true,
},
staticcheck = true,
},
},
},
clangd = {
cmd = { "clangd", "--background-index" },
filetypes = { "c", "cpp", "objc", "objcpp" },
root_dir = function(...)
return require("lspconfig.util").root_pattern(
"compile_commands.json",
"compile_flags.txt",
".git"
)(...)
end,
},
},
setup = {},
},
},
{
"neovim/nvim-lspconfig",
opts = function()
local keys = require("lazyvim.plugins.lsp.keymaps").get()
vim.list_extend(keys, {
{
"gd",
function()
-- DO NOT RESUSE WINDOW
require("telescope.builtin").lsp_definitions({ reuse_win = false })
end,
desc = "Goto Definition",
has = "definition",
},
})
end,
},
}