diff --git a/lua/commons/init.lua b/lua/commons/init.lua index 4437914..ea67b00 100644 --- a/lua/commons/init.lua +++ b/lua/commons/init.lua @@ -15,9 +15,24 @@ local M = { return false end, }, - lsp_servers = { - "goimports", "gofumpt", "basedpyright" - } + 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 diff --git a/lua/functions/lsp.lua b/lua/functions/lsp.lua index 6f3850f..8af3481 100644 --- a/lua/functions/lsp.lua +++ b/lua/functions/lsp.lua @@ -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 diff --git a/lua/lsp/bacon-ls.lua b/lua/lsp/bacon-ls.lua deleted file mode 100644 index 0dca34d..0000000 --- a/lua/lsp/bacon-ls.lua +++ /dev/null @@ -1,2 +0,0 @@ ----@type vim.lsp.Config -return {} diff --git a/lua/lsp/basedpyright.lua b/lua/lsp/basedpyright.lua index 7af0faa..8193e78 100644 --- a/lua/lsp/basedpyright.lua +++ b/lua/lsp/basedpyright.lua @@ -18,10 +18,19 @@ 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, }, }, }, diff --git a/lua/lsp/pyright.lua.bak b/lua/lsp/pyright.lua.bak deleted file mode 100644 index 4625225..0000000 --- a/lua/lsp/pyright.lua.bak +++ /dev/null @@ -1,48 +0,0 @@ -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" }, - - -- 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, - }, - }, - }, - - -- 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" } - -- ), - -- }, -} diff --git a/lua/lsp/ruff.lua b/lua/lsp/ruff.lua new file mode 100644 index 0000000..28ea748 --- /dev/null +++ b/lua/lsp/ruff.lua @@ -0,0 +1,9 @@ +return { + cmd_env = { RUFF_TRACE = "messages" }, + init_options = { + settings = { + logLevel = "error", + }, + }, + keys = { { "co", function() end, desc = "Organize Imports" } }, +} diff --git a/lua/lsp/rust_analyzer.lua.bak b/lua/lsp/rust_analyzer.lua similarity index 100% rename from lua/lsp/rust_analyzer.lua.bak rename to lua/lsp/rust_analyzer.lua diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index 603dc91..992e27e 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -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" }, }, diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index 90f68b6..5c15798 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -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)