misc: update lsp config

main
maye 2025-09-04 11:04:51 +08:00
parent 3b11323f80
commit 39a2d68c8c
9 changed files with 109 additions and 2 deletions

View File

@ -15,6 +15,9 @@ local M = {
return false
end,
},
lsp_servers = {
"goimports", "gofumpt", "basedpyright"
}
}
return M

2
lua/lsp/bacon-ls.lua Normal file
View File

@ -0,0 +1,2 @@
---@type vim.lsp.Config
return {}

28
lua/lsp/basedpyright.lua Normal file
View File

@ -0,0 +1,28 @@
return {
-- File types that should automatically attach this LSP server
filetypes = { "python" },
-- Root directory markers - LSP will search for these files/directories
-- to determine the project root. Nested arrays indicate equal priority.
-- The first match wins within each priority level.
root_markers = {
"pyproject.toml",
"setup.py",
"setup.cfg",
"requirements.txt",
"pyrightconfig.json",
".git",
".hg",
},
-- Server-specific settings (varies by language server)
-- Check your language server's documentation for available options
settings = {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
},
},
},
}

33
lua/lsp/clangd.lua Normal file
View File

@ -0,0 +1,33 @@
---@type vim.lsp.Config
return {
keys = {
{ "<leader>ch", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
},
root_dir = function(name)
return require("lspconfig.util").root_pattern(
"Makefile",
"configure.ac",
"configure.in",
"config.h.in",
"meson.build",
"meson_options.txt",
"build.ninja"
)(fname) or require("lspconfig.util").root_pattern("compile_commands.json", "compile_flags.txt")(fname) or require(
"lspconfig.util"
).find_git_ancestor(name)
end,
cmd = {
"clangd",
"--background-index",
"--clang-tidy",
"--header-insertion=iwyu",
"--completion-arg-placeholders",
"--function-arg-placeholders",
"--fallback-style=llvm",
},
init_options = {
usePlaceholders = true,
completeUnimported = true,
clangdFileStatus = true,
},
}

View File

@ -1,6 +1,5 @@
---@type vim.lsp.Config
return {
cmd = { "gopls" },
filetypes = { "go", "gomod", "gosum" },
root_markers = {
"go.mod",
@ -8,8 +7,21 @@ return {
},
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,
},
analyses = {
nliness = true,
unusedparams = true,
unusedwrite = true,
},
hints = {
assignVariableTypes = true,
@ -20,8 +32,10 @@ return {
parameterNames = true,
rangeVariableTypes = true,
},
usePlaceholders = true,
completeUnimported = true,
staticcheck = true,
gofumpt = true,
directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" },
semanticTokens = true,
},
},

24
lua/lsp/yamlls.lua Normal file
View File

@ -0,0 +1,24 @@
return {
capabilities = {
textDocument = {
foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
},
},
},
settings = {
redhat = { telemetry = { enabled = false } },
yaml = {
keyOrdering = false,
format = {
enable = true,
},
validate = true,
schemaStore = {
enable = false,
url = "",
},
},
},
}

View File

@ -18,6 +18,9 @@ return {
words = { enabled = false },
},
keys = {
{ "<leader>,", function() Snacks.picker.buffers() end, desc = "Buffers" },
{ "<leader>:", function() Snacks.picker.command_history() end, desc = "Command History" },
{ "<leader>n", function() Snacks.picker.notifications() end, desc = "Notification History" },
{ "<leader>e", function() Snacks.explorer() end, desc = "Snack File Explorer" },
{ "<leader><space>", function() Snacks.picker.smart() end, desc = "Smart Find Files" },
{ "<leader>fg", function() Snacks.picker.git_files() end, desc = "Find Git Files" },