Compare commits
2 Commits
3b11323f80
...
e53cf715f5
Author | SHA1 | Date |
---|---|---|
|
e53cf715f5 | |
|
39a2d68c8c |
|
@ -15,6 +15,24 @@ local M = {
|
|||
return false
|
||||
end,
|
||||
},
|
||||
lsp_servers = {
|
||||
code = {
|
||||
"lua_ls",
|
||||
"gopls",
|
||||
"clangd",
|
||||
"bashls",
|
||||
"yamlls",
|
||||
"ts_ls",
|
||||
"rust_analyzer",
|
||||
"ruff",
|
||||
},
|
||||
format_lint = {
|
||||
"goimports",
|
||||
"gofumpt",
|
||||
},
|
||||
mason_ensure_installed = { "lua_ls", "bashls", "bacon", "rust-analyzer" },
|
||||
treesitter_ensure_installed = { "go", "rust", "python" },
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
-- Get all LSP servers to configure
|
||||
local function get_all_servers()
|
||||
local servers = {}
|
||||
local commons = require("commons")
|
||||
|
||||
-- Use configured LSP servers from commons
|
||||
for _, server in ipairs(commons.lsp_servers.code) do
|
||||
servers[server] = true
|
||||
end
|
||||
|
||||
-- Auto-detect LSP servers installed by Mason using mason-lspconfig
|
||||
local ok, mason_lspconfig = pcall(require, "mason-lspconfig")
|
||||
|
@ -11,29 +17,34 @@ local function get_all_servers()
|
|||
end
|
||||
end
|
||||
|
||||
-- If no servers detected, fall back to common servers that might be system-installed
|
||||
if vim.tbl_isempty(servers) then
|
||||
local fallback_servers = {
|
||||
"lua_ls",
|
||||
}
|
||||
for _, server in pairs(fallback_servers) do
|
||||
servers[server] = true
|
||||
end
|
||||
end
|
||||
|
||||
return servers
|
||||
end
|
||||
|
||||
-- Configure a single LSP server
|
||||
local function configure_server(server, lspconfig, capabilities)
|
||||
local ok, settings = pcall(require, "lsp." .. server)
|
||||
if ok then
|
||||
if lspconfig then
|
||||
settings.capabilities = capabilities
|
||||
lspconfig[server].setup(settings)
|
||||
-- Only attempt to load .lua files from lsp folder
|
||||
local lsp_config_path = "lsp." .. server
|
||||
local lua_file_path = vim.fn.stdpath("config") .. "/lua/lsp/" .. server .. ".lua"
|
||||
|
||||
-- Check if the .lua file exists
|
||||
if vim.fn.filereadable(lua_file_path) == 1 then
|
||||
local ok, settings = pcall(require, lsp_config_path)
|
||||
if ok then
|
||||
if lspconfig then
|
||||
settings.capabilities = capabilities
|
||||
lspconfig[server].setup(settings)
|
||||
else
|
||||
vim.lsp.config(server, settings)
|
||||
vim.lsp.enable(server)
|
||||
end
|
||||
else
|
||||
vim.lsp.config(server, settings)
|
||||
vim.lsp.enable(server)
|
||||
-- Fallback to default config if .lua file exists but fails to load
|
||||
if lspconfig then
|
||||
lspconfig[server].setup({ capabilities = capabilities })
|
||||
else
|
||||
vim.lsp.config(server, {})
|
||||
vim.lsp.enable(server)
|
||||
end
|
||||
end
|
||||
else
|
||||
if lspconfig then
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
return {
|
||||
-- Command to start the language server
|
||||
-- This should match the executable name installed by Mason or system package manager
|
||||
cmd = { "pyright" },
|
||||
|
||||
-- File types that should automatically attach this LSP server
|
||||
filetypes = { "python" },
|
||||
|
||||
|
@ -22,27 +18,20 @@ return {
|
|||
-- Server-specific settings (varies by language server)
|
||||
-- Check your language server's documentation for available options
|
||||
settings = {
|
||||
python = {
|
||||
basedpyright = {
|
||||
analysis = {
|
||||
autoImportCompletions = true,
|
||||
ignorePatterns = { "*.pyi" },
|
||||
diagnosticSeverityOverrides = {
|
||||
reportAny = false,
|
||||
reportExplicitAny = false,
|
||||
},
|
||||
typeCheckingMode = "standard",
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
diagnosticMode = "workspace",
|
||||
disableOrganizeImports = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Optional: Additional capabilities (usually handled globally)
|
||||
-- capabilities = require("blink.cmp").get_lsp_capabilities(),
|
||||
|
||||
-- Optional: Custom initialization options
|
||||
-- init_options = {
|
||||
-- hostInfo = "neovim",
|
||||
-- },
|
||||
|
||||
-- Optional: Custom handlers for LSP methods
|
||||
-- handlers = {
|
||||
-- ["textDocument/hover"] = vim.lsp.with(
|
||||
-- vim.lsp.handlers.hover,
|
||||
-- { border = "rounded" }
|
||||
-- ),
|
||||
-- },
|
||||
}
|
|
@ -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,
|
||||
},
|
||||
}
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
return {
|
||||
cmd_env = { RUFF_TRACE = "messages" },
|
||||
init_options = {
|
||||
settings = {
|
||||
logLevel = "error",
|
||||
},
|
||||
},
|
||||
keys = { { "<leader>co", function() end, desc = "Organize Imports" } },
|
||||
}
|
|
@ -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 = "",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
|
@ -19,9 +19,8 @@ return {
|
|||
},
|
||||
formatters_by_ft = {
|
||||
lua = { "stylua" },
|
||||
python = { "black" },
|
||||
rust = { "rustfmt" },
|
||||
javascript = { "prettier", stop_after_first = true },
|
||||
javascript = { "biome" },
|
||||
sh = { "shfmt" },
|
||||
xml = { "xmlformat" },
|
||||
},
|
||||
|
|
|
@ -3,15 +3,8 @@ return {
|
|||
cmd = "Mason",
|
||||
build = ":MasonUpdate",
|
||||
opts_extend = { "ensure_installed" },
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
-- Formatters and tools
|
||||
"stylua",
|
||||
-- LSP servers (will be auto-detected by mason-lspconfig)
|
||||
"lua-language-server",
|
||||
"gopls",
|
||||
"pyright"
|
||||
}
|
||||
opts = {
|
||||
ensure_installed = {},
|
||||
},
|
||||
event = "VeryLazy",
|
||||
config = function(_, opts)
|
||||
|
|
|
@ -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" },
|
||||
|
|
Loading…
Reference in New Issue