mirror of
https://github.com/DefectingCat/dotfiles
synced 2025-07-15 16:51:36 +00:00
153 lines
3.3 KiB
Lua
153 lines
3.3 KiB
Lua
local on_attach = require("plugins.configs.lspconfig").on_attach
|
|
local capabilities = require("plugins.configs.lspconfig").capabilities
|
|
|
|
local lspconfig = require("lspconfig")
|
|
local util = require("lspconfig/util")
|
|
|
|
local function organize_imports()
|
|
local params = {
|
|
command = "_typescript.organizeImports",
|
|
arguments = { vim.api.nvim_buf_get_name(0) },
|
|
}
|
|
vim.lsp.buf.execute_command(params)
|
|
end
|
|
|
|
require("mason-lspconfig").setup_handlers({
|
|
function(server)
|
|
if server == "rust_analyzer" then
|
|
return nil
|
|
end
|
|
lspconfig[server].setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
})
|
|
end,
|
|
})
|
|
|
|
--[[ lspconfig.rust_analyzer.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
["rust-analyzer"] = {
|
|
standalone = true,
|
|
files = {
|
|
excludeDirs = {
|
|
".flatpak-builder",
|
|
"_build",
|
|
".dart_tool",
|
|
".flatpak-builder",
|
|
".git",
|
|
".gitlab",
|
|
".gitlab-ci",
|
|
".gradle",
|
|
".idea",
|
|
".next",
|
|
".project",
|
|
".scannerwork",
|
|
".settings",
|
|
".venv",
|
|
"archetype-resources",
|
|
"bin",
|
|
"hooks",
|
|
"node_modules",
|
|
"po",
|
|
"screenshots",
|
|
"target",
|
|
"out",
|
|
"../out",
|
|
"../node_modules",
|
|
"../.next",
|
|
},
|
|
},
|
|
},
|
|
procMacro = {
|
|
enable = true,
|
|
ignored = {
|
|
["async-trait"] = { "async_trait" },
|
|
["napi-derive"] = { "napi" },
|
|
["async-recursion"] = { "async_recursion" },
|
|
},
|
|
},
|
|
},
|
|
}) ]]
|
|
|
|
lspconfig.tsserver.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
init_options = {
|
|
preferences = {
|
|
disableSuggestions = true,
|
|
},
|
|
},
|
|
commands = {
|
|
OrganizeImports = {
|
|
organize_imports,
|
|
description = "Organize Imports",
|
|
},
|
|
},
|
|
})
|
|
|
|
lspconfig.pylsp.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
filetypes = { "python" },
|
|
settings = {
|
|
pylsp = {
|
|
plugins = {
|
|
pycodestyle = {
|
|
ignore = { "W391" },
|
|
maxLineLength = 100,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
lspconfig.gopls.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
cmd = { "gopls" },
|
|
cmd_env = {
|
|
GOFLAGS = "-tags=test,e2e_test,integration_test,acceptance_test",
|
|
},
|
|
filetypes = { "go", "gomod", "gowork", "gotmpl" },
|
|
root_dir = util.root_pattern("go.work", "go.mod", ".git"),
|
|
settings = {
|
|
gopls = {
|
|
completeUnimported = true,
|
|
usePlaceholders = true,
|
|
analyses = {
|
|
unusedparams = true,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
lspconfig.jsonls.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
json = {
|
|
schemas = require("schemastore").json.schemas(),
|
|
validate = { enable = true },
|
|
},
|
|
},
|
|
})
|
|
|
|
lspconfig.yamlls.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
yaml = {
|
|
schemaStore = {
|
|
-- You must disable built-in schemaStore support if you want to use
|
|
-- this plugin and its advanced options like `ignore`.
|
|
enable = false,
|
|
-- Avoid TypeError: Cannot read properties of undefined (reading 'length')
|
|
url = "",
|
|
},
|
|
schemas = require("schemastore").yaml.schemas(),
|
|
},
|
|
},
|
|
})
|