From 63a60e5b37bdab7ff0cdd8395db5ee70383b5c77 Mon Sep 17 00:00:00 2001 From: redjax Date: Tue, 30 Sep 2025 17:22:13 -0400 Subject: [PATCH] fix(lsp): Fix LSP configurations for nvim and nvim-work profiles --- config/nvim-work/lua/lsp/bundle.lua | 26 +- config/nvim-work/lua/lsp/core.lua | 41 ++- config/nvim-work/lua/lsp/lsp-auto-servers.lua | 283 +++++++++++++++++ config/nvim-work/lua/lsp/plugins/mason.lua | 27 +- config/nvim-work/lua/lsp/plugins/none_ls.lua | 212 ++++++------- config/nvim-work/lua/lsp/servers/bicep.lua | 25 ++ config/nvim-work/lua/lsp/servers/csv.lua | 9 + config/nvim-work/lua/lsp/servers/docker.lua | 23 ++ config/nvim-work/lua/lsp/servers/go.lua | 21 ++ config/nvim-work/lua/lsp/servers/json.lua | 39 +++ config/nvim-work/lua/lsp/servers/markdown.lua | 11 + .../nvim-work/lua/lsp/servers/powershell.lua | 74 ++--- config/nvim-work/lua/lsp/servers/python.lua | 21 +- config/nvim-work/lua/lsp/servers/sql.lua | 30 ++ .../nvim-work/lua/lsp/servers/terraform.lua | 19 ++ config/nvim-work/lua/lsp/servers/yaml.lua | 57 ++++ config/nvim/lua/lsp/bundle.lua | 26 +- config/nvim/lua/lsp/core.lua | 41 ++- config/nvim/lua/lsp/lsp-auto-servers.lua | 286 ++++++++++++++++++ config/nvim/lua/lsp/plugins/none_ls.lua | 212 ++++++------- config/nvim/lua/lsp/servers/bicep.lua | 25 ++ config/nvim/lua/lsp/servers/csv.lua | 9 + config/nvim/lua/lsp/servers/docker.lua | 23 ++ config/nvim/lua/lsp/servers/go.lua | 21 ++ config/nvim/lua/lsp/servers/json.lua | 15 + config/nvim/lua/lsp/servers/markdown.lua | 11 + config/nvim/lua/lsp/servers/powershell.lua | 74 ++--- config/nvim/lua/lsp/servers/python.lua | 21 +- config/nvim/lua/lsp/servers/sql.lua | 40 +++ config/nvim/lua/lsp/servers/terraform.lua | 20 ++ config/nvim/lua/lsp/servers/yaml.lua | 37 +++ 31 files changed, 1393 insertions(+), 386 deletions(-) create mode 100644 config/nvim-work/lua/lsp/lsp-auto-servers.lua create mode 100644 config/nvim-work/lua/lsp/servers/bicep.lua create mode 100644 config/nvim-work/lua/lsp/servers/csv.lua create mode 100644 config/nvim-work/lua/lsp/servers/docker.lua create mode 100644 config/nvim-work/lua/lsp/servers/json.lua create mode 100644 config/nvim-work/lua/lsp/servers/markdown.lua create mode 100644 config/nvim-work/lua/lsp/servers/sql.lua create mode 100644 config/nvim-work/lua/lsp/servers/terraform.lua create mode 100644 config/nvim-work/lua/lsp/servers/yaml.lua create mode 100644 config/nvim/lua/lsp/lsp-auto-servers.lua create mode 100644 config/nvim/lua/lsp/servers/bicep.lua create mode 100644 config/nvim/lua/lsp/servers/csv.lua create mode 100644 config/nvim/lua/lsp/servers/docker.lua create mode 100644 config/nvim/lua/lsp/servers/json.lua create mode 100644 config/nvim/lua/lsp/servers/markdown.lua create mode 100644 config/nvim/lua/lsp/servers/sql.lua create mode 100644 config/nvim/lua/lsp/servers/terraform.lua create mode 100644 config/nvim/lua/lsp/servers/yaml.lua diff --git a/config/nvim-work/lua/lsp/bundle.lua b/config/nvim-work/lua/lsp/bundle.lua index cb05666e..cfd195ae 100644 --- a/config/nvim-work/lua/lsp/bundle.lua +++ b/config/nvim-work/lua/lsp/bundle.lua @@ -13,12 +13,34 @@ return { "nvimtools/none-ls.nvim", }, config = function() - local auto_servers = require("lsp.auto_servers") - local ensure_installed = auto_servers.get and auto_servers.get() or {} + local lsp_auto_servers = require("lsp.lsp-auto-servers") + local ensure_installed = lsp_auto_servers.get and lsp_auto_servers.get() or {} -- Call your core setup function with the dynamic server list require("lsp.core").setup(ensure_installed) + -- Load and apply enhanced server configurations + local server_configs = lsp_auto_servers.load_server_configs() + + -- Apply enhanced configurations for specific servers using modern vim.lsp.config API + for server_name, config in pairs(server_configs) do + if config.settings then + -- Find the actual LSP server names for this configuration + if config.servers then + for _, server in ipairs(config.servers) do + if vim.tbl_contains(ensure_installed, server) then + vim.lsp.config[server] = { + settings = config.settings[server] or config.settings, + filetypes = config.filetypes, + root_dir = vim.fs.root, + single_file_support = true, + } + end + end + end + end + end + -- Setup signature if present local signature = require("lsp.plugins.signature") if signature.config then diff --git a/config/nvim-work/lua/lsp/core.lua b/config/nvim-work/lua/lsp/core.lua index a931f745..528dc2aa 100644 --- a/config/nvim-work/lua/lsp/core.lua +++ b/config/nvim-work/lua/lsp/core.lua @@ -54,24 +54,28 @@ function M.setup(ensure_installed) require("mason-lspconfig").setup({ ensure_installed = ensure_installed, handlers = { - -- default handler + -- default handler using modern vim.lsp.config API function(server_name) - require("lspconfig")[server_name].setup { + vim.lsp.config[server_name] = { capabilities = M.capabilities, on_attach = M.on_attach, + root_dir = vim.fs.root, + single_file_support = true, } end, ["sqls"] = function() - require("lspconfig").sqls.setup { + vim.lsp.config.sqls = { on_attach = function(client, bufnr) require('sqls').on_attach(client, bufnr) M.on_attach(client, bufnr) end, capabilities = M.capabilities, + root_dir = vim.fs.root, + single_file_support = true, } end, ["lua_ls"] = function() - require("lspconfig").lua_ls.setup { + vim.lsp.config.lua_ls = { settings = { Lua = { diagnostics = { globals = { "vim" } }, @@ -80,18 +84,25 @@ function M.setup(ensure_installed) }, capabilities = M.capabilities, on_attach = M.on_attach, + root_dir = vim.fs.root, + single_file_support = true, } end, ["powershell_es"] = function() - local powershell_config = require("lsp.servers.powershell").powershell_es() - if powershell_config then - powershell_config.capabilities = M.capabilities - powershell_config.on_attach = M.on_attach - require("lspconfig").powershell_es.setup(powershell_config) + local powershell_servers = require("lsp.servers.powershell") + if powershell_servers and powershell_servers.settings then + vim.lsp.config.powershell_es = { + settings = powershell_servers.settings.powershell, + capabilities = M.capabilities, + on_attach = M.on_attach, + filetypes = powershell_servers.filetypes, + root_dir = vim.fs.root, + single_file_support = true, + } end end, ["pyright"] = function() - require("lspconfig").pyright.setup { + vim.lsp.config.pyright = { settings = { python = { analysis = { @@ -101,10 +112,12 @@ function M.setup(ensure_installed) }, capabilities = M.capabilities, on_attach = M.on_attach, + root_dir = vim.fs.root, + single_file_support = true, } end, ["gopls"] = function() - require("lspconfig").gopls.setup { + vim.lsp.config.gopls = { settings = { gopls = { analyses = { @@ -116,10 +129,12 @@ function M.setup(ensure_installed) }, capabilities = M.capabilities, on_attach = M.on_attach, + root_dir = vim.fs.root, + single_file_support = true, } end, ["yamlls"] = function() - require("lspconfig").yamlls.setup { + vim.lsp.config.yamlls = { settings = { yaml = { schemas = require('schemastore').yaml.schemas(), @@ -128,6 +143,8 @@ function M.setup(ensure_installed) }, capabilities = M.capabilities, on_attach = M.on_attach, + root_dir = vim.fs.root, + single_file_support = true, } end, }, diff --git a/config/nvim-work/lua/lsp/lsp-auto-servers.lua b/config/nvim-work/lua/lsp/lsp-auto-servers.lua new file mode 100644 index 00000000..8d066e22 --- /dev/null +++ b/config/nvim-work/lua/lsp/lsp-auto-servers.lua @@ -0,0 +1,283 @@ +-- LSP Auto Servers with comprehensive language support +-- Automatically detects available tools and configures appropriate LSP servers + +local M = {} + +local function has(cmd) + return vim.fn.executable(cmd) == 1 +end + +-- Map of LSP servers to required external tools +local server_tool_requirements = { + -- Core language servers + bicep = "az", -- Requires Azure CLI + bashls = function() + return has("bash") or has("sh") or has("zsh") + end, + dockerls = "docker", + gopls = "go", + lua_ls = "lua", + marksman = function() + return has("marksman") or has("cargo") + end, + pyright = function() + return has("python") or has("python3") + end, + powershell_es = function() + return has("pwsh") or has("powershell") + end, + rust_analyzer = "cargo", + terraformls = "terraform", + + -- YAML and configuration + yamlls = "npm", + jsonls = "node", + + -- SQL servers + sqlls = "go", + + -- Web/CSS/HTML (npm-based) + ansiblels = "ansible", + azure_pipelines_ls = "npm", + css_variables = "npm", + cssls = "npm", + cssmodules_ls = "npm", + docker_compose_language_service = "docker", + eslint = "node", + gh_actions_ls = "npm", + html = "npm", + svelte = "npm", + vue_ls = "npm", + + -- Go tools + golangci_lint_ls = "golangci-lint", + sqls = "go", + + -- Cargo-based tools + gitlab_ci_ls = "cargo", + markdown_oxide = "cargo", + + -- Additional tools + postgres_lsp = "psql", + superhtml = nil, + tflint = "tflint", +} + +M.defaults = { + base = { + "lua_ls", + "yamlls", + "jsonls", + }, + conditional = { + -- These are checked dynamically based on tool availability + "bashls", + "powershell_es", + "pyright", + "gopls", + "rust_analyzer", + "dockerls", + "terraformls", + "bicep", + "sqlls", + "marksman", -- Moved to conditional since it requires cargo + }, + npm = { + "eslint", + "html", + "cssls", + "azure_pipelines_ls", + "gh_actions_ls", + }, + go = { + "golangci_lint_ls", + "sqls", + }, + cargo = { + "gitlab_ci_ls", + "markdown_oxide", + }, + specialized = { + "postgres_lsp", + "tflint", + "superhtml", + } +} + +-- Enhanced get function that checks tool availability +function M.get() + local available_servers = {} + + -- Always include base servers + for _, server in ipairs(M.defaults.base) do + table.insert(available_servers, server) + end + + -- Check conditional servers + for _, server in ipairs(M.defaults.conditional) do + local requirement = server_tool_requirements[server] + local should_include = false + + if type(requirement) == "function" then + should_include = requirement() + elseif type(requirement) == "string" then + should_include = has(requirement) + elseif requirement == nil then + should_include = true + end + + if should_include then + table.insert(available_servers, server) + end + end + + -- Add npm servers if Node.js is available + if has("node") or has("npm") then + for _, server in ipairs(M.defaults.npm) do + table.insert(available_servers, server) + end + end + + -- Add Go servers if Go is available + if has("go") then + for _, server in ipairs(M.defaults.go) do + table.insert(available_servers, server) + end + end + + -- Add Cargo servers if Rust is available + if has("cargo") then + for _, server in ipairs(M.defaults.cargo) do + table.insert(available_servers, server) + end + end + + -- Add specialized servers (check individually) + for _, server in ipairs(M.defaults.specialized) do + local requirement = server_tool_requirements[server] + if requirement == nil or (type(requirement) == "string" and has(requirement)) then + table.insert(available_servers, server) + end + end + + return available_servers +end + +-- Function to get tools for Mason installation +function M.get_mason_tools() + local tools = { + -- Core tools always installed + "stylua", + "shellcheck", + "shfmt", + "prettier", + "yaml-language-server", + "json-lsp", + } + + -- Language-specific tools based on availability + if has("cargo") then + table.insert(tools, "marksman") + end + + if has("python") or has("python3") then + vim.list_extend(tools, { + "pyright", + "flake8", + "black", + "isort", + "mypy" + }) + end + + if has("bash") or has("sh") or has("zsh") then + table.insert(tools, "bash-language-server") + end + + if has("pwsh") or has("powershell") then + table.insert(tools, "powershell-editor-services") + end + + if has("go") then + vim.list_extend(tools, { + "gopls", + "gofumpt", + "goimports", + "golines" + }) + end + + if has("cargo") then + table.insert(tools, "rust-analyzer") + end + + if has("docker") then + vim.list_extend(tools, { + "dockerfile-language-server", + "hadolint" + }) + end + + if has("terraform") then + vim.list_extend(tools, { + "terraform-ls", + "tflint" + }) + end + + if has("az") then + table.insert(tools, "bicep-lsp") + end + + if has("node") or has("npm") then + vim.list_extend(tools, { + "typescript-language-server", + "eslint_d" + }) + end + + -- Additional linters and formatters + vim.list_extend(tools, { + "yamllint", + "actionlint", + "sqlls", + }) + + return tools +end + +-- Load server configurations from individual files +function M.load_server_configs() + local configs = {} + local server_files = { + "yaml", + "docker", + "terraform", + "json", + "sql", + "go", + "python", + "bicep", + "powershell", + "csv", + "markdown", + } + + for _, file in ipairs(server_files) do + local ok, config = pcall(require, "lsp.servers." .. file) + if ok and config then + -- Check if the config has a condition function + if config.condition then + if config.condition() then + configs[config.name] = config + end + else + configs[config.name] = config + end + end + end + + return configs +end + +return M \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/plugins/mason.lua b/config/nvim-work/lua/lsp/plugins/mason.lua index 2abbc680..cdb443c6 100644 --- a/config/nvim-work/lua/lsp/plugins/mason.lua +++ b/config/nvim-work/lua/lsp/plugins/mason.lua @@ -1,30 +1,13 @@ return { "mason-org/mason.nvim", opts = function(_, opts) - -- Detect platform - local is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1 + -- Use the LSP auto servers to get comprehensive tool list + local lsp_auto_servers = require("lsp.lsp-auto-servers") + local mason_tools = lsp_auto_servers.get_mason_tools() - -- Base tools for all platforms - local base_tools = { - "stylua", - "shellcheck", - "shfmt", - "flake8", - "bash-language-server", -- Bash LSP for all platforms - } + -- Ensure we have the tools needed + opts.ensure_installed = mason_tools - -- Windows-specific tools - local windows_tools = { - "powershell-editor-services", -- PowerShell LSP - } - - -- Combine tools based on platform - local ensure_installed = base_tools - if is_windows then - vim.list_extend(ensure_installed, windows_tools) - end - - opts.ensure_installed = ensure_installed return opts end, } \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/plugins/none_ls.lua b/config/nvim-work/lua/lsp/plugins/none_ls.lua index f1569e92..1e164834 100644 --- a/config/nvim-work/lua/lsp/plugins/none_ls.lua +++ b/config/nvim-work/lua/lsp/plugins/none_ls.lua @@ -6,129 +6,97 @@ return { config = function() local null_ls = require("null-ls") + -- Helper function to check if a tool is available + local function has_tool(tool) + return vim.fn.executable(tool) == 1 + end + + -- Build sources list based on available tools + local sources = {} + + -- Always available built-ins (no external dependencies) + table.insert(sources, null_ls.builtins.hover.dictionary) + table.insert(sources, null_ls.builtins.completion.spell) + + -- Conditionally add tools based on availability + if has_tool("stylua") then + table.insert(sources, null_ls.builtins.formatting.stylua) + end + + if has_tool("prettier") then + table.insert(sources, null_ls.builtins.formatting.prettier) + end + + if has_tool("actionlint") then + table.insert(sources, null_ls.builtins.diagnostics.actionlint) + end + + if has_tool("shfmt") then + table.insert(sources, null_ls.builtins.formatting.shfmt) + end + + if has_tool("shellcheck") then + table.insert(sources, null_ls.builtins.diagnostics.shellcheck) + end + + -- Markdown tools (only if available) + if has_tool("markdownlint") then + table.insert(sources, null_ls.builtins.diagnostics.markdownlint) + end + + if has_tool("textlint") then + table.insert(sources, null_ls.builtins.diagnostics.textlint) + end + + if has_tool("proselint") then + table.insert(sources, null_ls.builtins.diagnostics.proselint) + end + + -- Python tools + if has_tool("black") then + table.insert(sources, null_ls.builtins.formatting.black) + end + + if has_tool("isort") then + table.insert(sources, null_ls.builtins.formatting.isort) + end + + -- Go tools + if has_tool("gofmt") then + table.insert(sources, null_ls.builtins.formatting.gofmt) + end + + if has_tool("goimports") then + table.insert(sources, null_ls.builtins.formatting.goimports) + end + + if has_tool("golangci-lint") then + table.insert(sources, null_ls.builtins.diagnostics.golangci_lint) + end + + -- YAML tools + if has_tool("yamllint") then + table.insert(sources, null_ls.builtins.diagnostics.yamllint) + end + + -- Terraform tools + if has_tool("terraform") then + table.insert(sources, null_ls.builtins.formatting.terraform_fmt) + table.insert(sources, null_ls.builtins.diagnostics.terraform_validate) + end + + if has_tool("tflint") then + table.insert(sources, null_ls.builtins.diagnostics.tflint) + end + + -- SQL tools + if has_tool("sqlfmt") then + table.insert(sources, null_ls.builtins.formatting.sqlfmt) + end + null_ls.setup({ - sources = { - -- Misc - null_ls.builtins.hover.dictionary, - null_ls.builtins.hover.printenv, - - -- Formatters - null_ls.builtins.formatting.stylua, - null_ls.builtins.formatting.prettier, - null_ls.builtins.formatting.treefmt, - - -- Stylelint - null_ls.builtins.formatting.stylelint, - - -- Completion/snippets/spelling - null_ls.builtins.completion.luasnip, - null_ls.builtins.completion.nvim_snippets, - null_ls.builtins.completion.spell, - - -- GitHub Actions - null_ls.builtins.diagnostics.actionlint, - - -- Shell - null_ls.builtins.formatting.shfmt, - null_ls.builtins.formatting.shellharden, - - -- Markdown - null_ls.builtins.diagnostics.alex, - null_ls.builtins.diagnostics.markdownlint, - null_ls.builtins.diagnostics.markdownlint_cli2, - null_ls.builtins.diagnostics.textlint, - null_ls.builtins.formatting.mdformat, - null_ls.builtins.formatting.remark, - null_ls.builtins.formatting.textlint, - - -- Ansible - null_ls.builtins.diagnostics.ansiblelint, - - -- Django - null_ls.builtins.diagnostics.djlint, - null_ls.builtins.formatting.djhtml, - - -- .env - null_ls.builtins.diagnostics.dotenv_linter, - - -- Go - null_ls.builtins.code_actions.gomodifytags, - null_ls.builtins.diagnostics.golangci_lint, - null_ls.builtins.diagnostics.staticcheck, - null_ls.builtins.formatting.gofmt, - null_ls.builtins.formatting.goimports, - null_ls.builtins.formatting.goimports_reviser, - null_ls.builtins.formatting.golines, - - -- Python - null_ls.builtins.formatting.isort, - null_ls.builtins.formatting.black, - null_ls.builtins.formatting.pyink, - - -- Nix - null_ls.builtins.diagnostics.statix, - null_ls.builtins.diagnostics.deadnix, - null_ls.builtins.formatting.alejandra, - null_ls.builtins.formatting.nixfmt, - null_ls.builtins.formatting.nixpkgs_fmt, - null_ls.builtins.formatting.nix_flake_fmt, - - -- Git commit messages - null_ls.builtins.diagnostics.gitlint, - - -- HCL - null_ls.builtins.formatting.hclfmt, - - -- Opentofu - null_ls.builtins.diagnostics.opentofu_validate, - null_ls.builtins.formatting.opentofu_fmt, - - -- Terraform - null_ls.builtins.diagnostics.terraform_validate, - null_ls.builtins.diagnostics.terragrunt_validate, - null_ls.builtins.diagnostics.tfsec, - null_ls.builtins.formatting.terraform_fmt, - null_ls.builtins.formatting.terragrunt_fmt, - - -- Prose - null_ls.builtins.diagnostics.proselint, - null_ls.builtins.diagnostics.write_good, - - -- Salt - null_ls.builtins.diagnostics.saltlint, - - -- JSON - null_ls.builtins.diagnostics.spectral, - - -- YAML - null_ls.builtins.diagnostics.yamllint, - null_ls.builtins.formatting.yamlfix, - null_ls.builtins.formatting.yamlfmt, - - -- SQL - null_ls.builtins.diagnostics.sqruff, - null_ls.builtins.formatting.pg_format, - null_ls.builtins.formatting.sqlfmt, - null_ls.builtins.formatting.sqlformat, - null_ls.builtins.formatting.sql_formatter, - - -- CSS - null_ls.builtins.diagnostics.stylelint, - - -- HTML/XML/etc. - null_ls.builtins.diagnostics.tidy, - null_ls.builtins.formatting.htmlbeautifier, - null_ls.builtins.formatting.xmllint, - - -- C# - null_ls.builtins.formatting.csharpier, - - -- NGINX - null_ls.builtins.formatting.nginx_beautifier, - - -- NodeJS - null_ls.builtins.formatting.npm_groovy_lint, - }, + sources = sources, + debug = false, -- Set to true if you want to see debug info }) end, } \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/servers/bicep.lua b/config/nvim-work/lua/lsp/servers/bicep.lua new file mode 100644 index 00000000..b092ec7f --- /dev/null +++ b/config/nvim-work/lua/lsp/servers/bicep.lua @@ -0,0 +1,25 @@ +return { + name = "bicep", + servers = { "bicep" }, + tools = { "bicep-lsp" }, + settings = { + bicep = { + -- Enable experimental features + experimental = { + resourceTyping = true, + }, + -- Format settings + formatter = { + insertFinalNewline = true, + indentKind = "Space", + indentSize = 2, + }, + -- Completion settings + completion = { + showSnippets = true, + showDescriptions = true, + }, + }, + }, + filetypes = { "bicep" }, +} \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/servers/csv.lua b/config/nvim-work/lua/lsp/servers/csv.lua new file mode 100644 index 00000000..9db99d51 --- /dev/null +++ b/config/nvim-work/lua/lsp/servers/csv.lua @@ -0,0 +1,9 @@ +return { + name = "csv", + servers = {}, + tools = {}, + -- CSV support through treesitter and rainbow-csv plugin + treesitter = { "csv" }, + settings = {}, + filetypes = { "csv", "tsv" }, +} \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/servers/docker.lua b/config/nvim-work/lua/lsp/servers/docker.lua new file mode 100644 index 00000000..62baf510 --- /dev/null +++ b/config/nvim-work/lua/lsp/servers/docker.lua @@ -0,0 +1,23 @@ +-- Docker Language Server configuration +-- Supports Dockerfile LSP and linting + +return { + name = "docker", + servers = { "dockerls" }, + config = function() + return { + dockerls = { + filetypes = { "dockerfile" }, + settings = { + docker = { + languageserver = { + formatter = { + ignoreMultilineInstructions = true, + }, + }, + }, + }, + } + } + end, +} \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/servers/go.lua b/config/nvim-work/lua/lsp/servers/go.lua index d7a6b3d5..e013d74c 100644 --- a/config/nvim-work/lua/lsp/servers/go.lua +++ b/config/nvim-work/lua/lsp/servers/go.lua @@ -1,4 +1,25 @@ return { name = "go", servers = { "gopls", "golangci_lint_ls", "sqls" }, + tools = { "gopls", "golangci-lint", "gofumpt", "goimports", "gomodifytags", "impl", "delve" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + shadow = true, + fieldalignment = true, + nilness = true, + unusedwrite = true, + useany = true, + }, + staticcheck = true, + gofumpt = true, + semanticTokens = true, + usePlaceholders = true, + completeUnimported = true, + matcher = "fuzzy", + experimentalPostfixCompletions = true, + buildFlags = { "-tags", "integration" }, + }, + }, } diff --git a/config/nvim-work/lua/lsp/servers/json.lua b/config/nvim-work/lua/lsp/servers/json.lua new file mode 100644 index 00000000..65346ed8 --- /dev/null +++ b/config/nvim-work/lua/lsp/servers/json.lua @@ -0,0 +1,39 @@ +-- JSON Language Server configuration with schemas +-- Supports various JSON configuration files + +return { + name = "json", + servers = { "jsonls" }, + config = function() + return { + jsonls = { + settings = { + json = { + schemas = { + { + fileMatch = { "package.json" }, + url = "https://json.schemastore.org/package.json", + }, + { + fileMatch = { "tsconfig*.json" }, + url = "https://json.schemastore.org/tsconfig.json", + }, + { + fileMatch = { ".prettierrc", ".prettierrc.json", "prettier.config.json" }, + url = "https://json.schemastore.org/prettierrc.json", + }, + { + fileMatch = { ".eslintrc", ".eslintrc.json" }, + url = "https://json.schemastore.org/eslintrc.json", + }, + { + fileMatch = { "azure-pipelines.json", ".azure-pipelines.json" }, + url = "https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json", + }, + }, + }, + }, + } + } + end, +} \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/servers/markdown.lua b/config/nvim-work/lua/lsp/servers/markdown.lua new file mode 100644 index 00000000..d436f24d --- /dev/null +++ b/config/nvim-work/lua/lsp/servers/markdown.lua @@ -0,0 +1,11 @@ +return { + name = "markdown", + servers = {}, -- Disable marksman for now since it's causing crashes + tools = { "prettier" }, + settings = {}, + filetypes = { "markdown", "md" }, + -- Disabled until marksman issues are resolved + condition = function() + return false -- Completely disable for now + end, +} \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/servers/powershell.lua b/config/nvim-work/lua/lsp/servers/powershell.lua index eb8336b8..b7b2d731 100644 --- a/config/nvim-work/lua/lsp/servers/powershell.lua +++ b/config/nvim-work/lua/lsp/servers/powershell.lua @@ -1,47 +1,31 @@ --- PowerShell LSP server configuration --- Cross-platform: works on Windows, Linux, and macOS when PowerShell is installed - -local M = {} - -function M.powershell_es() - -- Only configure if PowerShell is actually available - local pwsh_available = vim.fn.executable("pwsh") == 1 - local powershell_available = vim.fn.executable("powershell") == 1 - - if not (pwsh_available or powershell_available) then - return nil - end - - return { - filetypes = { "ps1", "psm1", "psd1" }, - root_dir = function(fname) - return require("lspconfig.util").find_git_ancestor(fname) or vim.fn.getcwd() - end, - single_file_support = true, - settings = { - powershell = { - codeFormatting = { - Preset = "OTBS", -- One True Brace Style - openBraceOnSameLine = true, - newLineAfterOpenBrace = true, - newLineAfterCloseBrace = true, - pipelineIndentationStyle = "IncreaseIndentationAfterEveryPipeline", - whitespaceBeforeOpenBrace = true, - whitespaceBeforeOpenParen = true, - whitespaceAroundOperator = true, - whitespaceAfterSeparator = true, - ignoreOneLineBlock = true, - }, - scriptAnalysis = { - enable = true, - settingsPath = "", - }, - developer = { - editorServicesLogLevel = "Normal", - }, +return { + name = "powershell", + servers = { "powershell_es" }, + tools = { "powershell-editor-services" }, + settings = { + powershell = { + codeFormatting = { + preset = "OTBS", + openBraceOnSameLine = true, + newLineAfterOpenBrace = true, + newLineAfterCloseBrace = true, + pipelineIndentationStyle = "IncreaseIndentationForFirstPipeline", + whitespaceBeforeOpenBrace = true, + whitespaceBeforeOpenParen = true, + whitespaceAroundOperator = true, + whitespaceAfterSeparator = true, + ignoreOneLineBlock = true, + alignPropertyValuePairs = true, + }, + scriptAnalysis = { + enable = true, + settingsPath = "", + }, + developer = { + editorServicesLogLevel = "Normal", + bundledModulesPath = "", }, }, - } -end - -return M \ No newline at end of file + }, + filetypes = { "ps1", "psm1", "psd1" }, +} \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/servers/python.lua b/config/nvim-work/lua/lsp/servers/python.lua index b9120f97..527d10bf 100644 --- a/config/nvim-work/lua/lsp/servers/python.lua +++ b/config/nvim-work/lua/lsp/servers/python.lua @@ -1,4 +1,23 @@ return { name = "python", - servers = { "pyright" }, + servers = { "pyright", "ruff_lsp" }, + tools = { "pyright", "ruff", "black", "isort", "mypy", "pylint", "flake8" }, + settings = { + pyright = { + disableOrganizeImports = true, -- Using ruff + analysis = { + autoSearchPaths = true, + diagnosticMode = "workspace", + useLibraryCodeForTypes = true, + typeCheckingMode = "basic", + }, + }, + ruff_lsp = { + init_options = { + settings = { + args = {}, + }, + }, + }, + }, } diff --git a/config/nvim-work/lua/lsp/servers/sql.lua b/config/nvim-work/lua/lsp/servers/sql.lua new file mode 100644 index 00000000..c9b6ad4f --- /dev/null +++ b/config/nvim-work/lua/lsp/servers/sql.lua @@ -0,0 +1,30 @@ +-- SQL Language Server configuration +-- Supports multiple SQL database types + +return { + name = "sql", + servers = { "sqlls" }, + config = function() + return { + sqlls = { + filetypes = { "sql", "mysql", "pgsql", "plsql" }, + settings = { + sqlLanguageServer = { + connections = { + -- Add your database connections here + -- Example for PostgreSQL: + -- { + -- name = "postgres_local", + -- adapter = "postgresql", + -- host = "localhost", + -- port = 5432, + -- user = "postgres", + -- database = "mydb" + -- } + }, + }, + }, + } + } + end, +} \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/servers/terraform.lua b/config/nvim-work/lua/lsp/servers/terraform.lua new file mode 100644 index 00000000..8ccd3183 --- /dev/null +++ b/config/nvim-work/lua/lsp/servers/terraform.lua @@ -0,0 +1,19 @@ +-- Terraform Language Server configuration +-- Supports Terraform LSP with validation + +return { + name = "terraform", + servers = { "terraformls" }, + config = function() + return { + terraformls = { + filetypes = { "terraform", "tf", "terraform-vars" }, + settings = { + terraform = { + validate = true, + }, + }, + } + } + end, +} \ No newline at end of file diff --git a/config/nvim-work/lua/lsp/servers/yaml.lua b/config/nvim-work/lua/lsp/servers/yaml.lua new file mode 100644 index 00000000..710bee30 --- /dev/null +++ b/config/nvim-work/lua/lsp/servers/yaml.lua @@ -0,0 +1,57 @@ +-- YAML Language Server configuration with DevOps schemas +-- Supports Azure DevOps, GitHub Actions, Docker Compose, and Kubernetes + +return { + name = "yaml", + servers = { "yamlls" }, + config = function() + return { + yamlls = { + settings = { + yaml = { + hover = true, + completion = true, + validate = true, + schemaStore = { + enable = true, + url = "https://www.schemastore.org/api/json/catalog.json", + }, + schemas = { + -- Azure DevOps Pipelines + ["https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/service-schema.json"] = { + "azure-pipelines.yml", + "azure-pipelines.yaml", + ".azure-pipelines.yml", + ".azure-pipelines.yaml", + "pipelines/*.yml", + "pipelines/*.yaml", + ".azure/pipelines/*.yml", + ".azure/pipelines/*.yaml", + }, + -- GitHub Actions + ["https://json.schemastore.org/github-workflow.json"] = { + ".github/workflows/*.yml", + ".github/workflows/*.yaml", + }, + -- GitHub Action (single) + ["https://json.schemastore.org/github-action.json"] = { + "action.yml", + "action.yaml", + }, + -- Docker Compose + ["https://json.schemastore.org/docker-compose.json"] = { + "docker-compose.yml", + "docker-compose.yaml", + "compose.yml", + "compose.yaml", + }, + -- Kubernetes + ["https://json.schemastore.org/kustomization.json"] = "kustomization.yaml", + ["https://kubernetesjsonschema.dev/v1.18.0-standalone-strict/all.json"] = "*.k8s.yaml", + }, + }, + }, + } + } + end, +} \ No newline at end of file diff --git a/config/nvim/lua/lsp/bundle.lua b/config/nvim/lua/lsp/bundle.lua index cb05666e..cfd195ae 100644 --- a/config/nvim/lua/lsp/bundle.lua +++ b/config/nvim/lua/lsp/bundle.lua @@ -13,12 +13,34 @@ return { "nvimtools/none-ls.nvim", }, config = function() - local auto_servers = require("lsp.auto_servers") - local ensure_installed = auto_servers.get and auto_servers.get() or {} + local lsp_auto_servers = require("lsp.lsp-auto-servers") + local ensure_installed = lsp_auto_servers.get and lsp_auto_servers.get() or {} -- Call your core setup function with the dynamic server list require("lsp.core").setup(ensure_installed) + -- Load and apply enhanced server configurations + local server_configs = lsp_auto_servers.load_server_configs() + + -- Apply enhanced configurations for specific servers using modern vim.lsp.config API + for server_name, config in pairs(server_configs) do + if config.settings then + -- Find the actual LSP server names for this configuration + if config.servers then + for _, server in ipairs(config.servers) do + if vim.tbl_contains(ensure_installed, server) then + vim.lsp.config[server] = { + settings = config.settings[server] or config.settings, + filetypes = config.filetypes, + root_dir = vim.fs.root, + single_file_support = true, + } + end + end + end + end + end + -- Setup signature if present local signature = require("lsp.plugins.signature") if signature.config then diff --git a/config/nvim/lua/lsp/core.lua b/config/nvim/lua/lsp/core.lua index a931f745..528dc2aa 100644 --- a/config/nvim/lua/lsp/core.lua +++ b/config/nvim/lua/lsp/core.lua @@ -54,24 +54,28 @@ function M.setup(ensure_installed) require("mason-lspconfig").setup({ ensure_installed = ensure_installed, handlers = { - -- default handler + -- default handler using modern vim.lsp.config API function(server_name) - require("lspconfig")[server_name].setup { + vim.lsp.config[server_name] = { capabilities = M.capabilities, on_attach = M.on_attach, + root_dir = vim.fs.root, + single_file_support = true, } end, ["sqls"] = function() - require("lspconfig").sqls.setup { + vim.lsp.config.sqls = { on_attach = function(client, bufnr) require('sqls').on_attach(client, bufnr) M.on_attach(client, bufnr) end, capabilities = M.capabilities, + root_dir = vim.fs.root, + single_file_support = true, } end, ["lua_ls"] = function() - require("lspconfig").lua_ls.setup { + vim.lsp.config.lua_ls = { settings = { Lua = { diagnostics = { globals = { "vim" } }, @@ -80,18 +84,25 @@ function M.setup(ensure_installed) }, capabilities = M.capabilities, on_attach = M.on_attach, + root_dir = vim.fs.root, + single_file_support = true, } end, ["powershell_es"] = function() - local powershell_config = require("lsp.servers.powershell").powershell_es() - if powershell_config then - powershell_config.capabilities = M.capabilities - powershell_config.on_attach = M.on_attach - require("lspconfig").powershell_es.setup(powershell_config) + local powershell_servers = require("lsp.servers.powershell") + if powershell_servers and powershell_servers.settings then + vim.lsp.config.powershell_es = { + settings = powershell_servers.settings.powershell, + capabilities = M.capabilities, + on_attach = M.on_attach, + filetypes = powershell_servers.filetypes, + root_dir = vim.fs.root, + single_file_support = true, + } end end, ["pyright"] = function() - require("lspconfig").pyright.setup { + vim.lsp.config.pyright = { settings = { python = { analysis = { @@ -101,10 +112,12 @@ function M.setup(ensure_installed) }, capabilities = M.capabilities, on_attach = M.on_attach, + root_dir = vim.fs.root, + single_file_support = true, } end, ["gopls"] = function() - require("lspconfig").gopls.setup { + vim.lsp.config.gopls = { settings = { gopls = { analyses = { @@ -116,10 +129,12 @@ function M.setup(ensure_installed) }, capabilities = M.capabilities, on_attach = M.on_attach, + root_dir = vim.fs.root, + single_file_support = true, } end, ["yamlls"] = function() - require("lspconfig").yamlls.setup { + vim.lsp.config.yamlls = { settings = { yaml = { schemas = require('schemastore').yaml.schemas(), @@ -128,6 +143,8 @@ function M.setup(ensure_installed) }, capabilities = M.capabilities, on_attach = M.on_attach, + root_dir = vim.fs.root, + single_file_support = true, } end, }, diff --git a/config/nvim/lua/lsp/lsp-auto-servers.lua b/config/nvim/lua/lsp/lsp-auto-servers.lua new file mode 100644 index 00000000..73567971 --- /dev/null +++ b/config/nvim/lua/lsp/lsp-auto-servers.lua @@ -0,0 +1,286 @@ +-- LSP Auto Servers with comprehensive language support +-- Automatically detects available tools and configures appropriate LSP servers + +local M = {} + +local function has(cmd) + return vim.fn.executable(cmd) == 1 +end + +-- Map of LSP servers to required external tools +local server_tool_requirements = { + -- Core language servers + bicep = "az", -- Requires Azure CLI + bashls = function() + return has("bash") or has("sh") or has("zsh") + end, + dockerls = "docker", + gopls = "go", + lua_ls = "lua", + marksman = function() + return has("marksman") or has("cargo") + end, + pyright = function() + return has("python") or has("python3") + end, + powershell_es = function() + return has("pwsh") or has("powershell") + end, + rust_analyzer = "cargo", + terraformls = "terraform", + + -- YAML and configuration + yamlls = "npm", + jsonls = "node", + + -- SQL servers + sqlls = "go", + + -- Web/CSS/HTML (npm-based) + ansiblels = "ansible", + azure_pipelines_ls = "npm", + css_variables = "npm", + cssls = "npm", + cssmodules_ls = "npm", + docker_compose_language_service = "docker", + eslint = "node", + gh_actions_ls = "npm", + html = "npm", + svelte = "npm", + vue_ls = "npm", + + -- Go tools + golangci_lint_ls = "golangci-lint", + sqls = "go", + + -- Cargo-based tools + gitlab_ci_ls = "cargo", + markdown_oxide = "cargo", + + -- Additional tools + postgres_lsp = "psql", + superhtml = nil, + tflint = "tflint", +} + +M.defaults = { + base = { + "lua_ls", + "yamlls", + "jsonls", + }, + conditional = { + -- These are checked dynamically based on tool availability + "bashls", + "powershell_es", + "pyright", + "gopls", + "rust_analyzer", + "dockerls", + "terraformls", + "bicep", + "sqlls", + "marksman", -- Moved to conditional since it requires cargo + }, + npm = { + "eslint", + "html", + "cssls", + "azure_pipelines_ls", + "gh_actions_ls", + }, + go = { + "golangci_lint_ls", + "sqls", + }, + cargo = { + "gitlab_ci_ls", + "markdown_oxide", + }, + specialized = { + "postgres_lsp", + "tflint", + "superhtml", + } +} + +-- Enhanced get function that checks tool availability +function M.get() + local available_servers = {} + + -- Always include base servers + for _, server in ipairs(M.defaults.base) do + table.insert(available_servers, server) + end + + -- Check conditional servers + for _, server in ipairs(M.defaults.conditional) do + local requirement = server_tool_requirements[server] + local should_include = false + + if type(requirement) == "function" then + should_include = requirement() + elseif type(requirement) == "string" then + should_include = has(requirement) + elseif requirement == nil then + should_include = true + end + + if should_include then + table.insert(available_servers, server) + end + end + + -- Add npm servers if Node.js is available + if has("node") or has("npm") then + for _, server in ipairs(M.defaults.npm) do + table.insert(available_servers, server) + end + end + + -- Add Go servers if Go is available + if has("go") then + for _, server in ipairs(M.defaults.go) do + table.insert(available_servers, server) + end + end + + -- Add Cargo servers if Rust is available + if has("cargo") then + for _, server in ipairs(M.defaults.cargo) do + table.insert(available_servers, server) + end + end + + -- Add specialized servers (check individually) + for _, server in ipairs(M.defaults.specialized) do + local requirement = server_tool_requirements[server] + if requirement == nil or (type(requirement) == "string" and has(requirement)) then + table.insert(available_servers, server) + end + end + + return available_servers +end + +-- Function to get tools for Mason installation +function M.get_mason_tools() + local tools = { + -- Core tools always installed + "stylua", + "shellcheck", + "shfmt", + "prettier", + "yaml-language-server", + "json-lsp", + } + + -- Language-specific tools based on availability + if has("cargo") then + table.insert(tools, "marksman") + end + + if has("python") or has("python3") then + vim.list_extend(tools, { + "pyright", + "ruff-lsp", + "flake8", + "black", + "isort", + "mypy" + }) + end + + if has("bash") or has("sh") or has("zsh") then + table.insert(tools, "bash-language-server") + end + + if has("pwsh") or has("powershell") then + table.insert(tools, "powershell-editor-services") + end + + if has("go") then + vim.list_extend(tools, { + "gopls", + "golangci-lint-langserver", + "gofumpt", + "goimports", + "golines" + }) + end + + if has("cargo") then + table.insert(tools, "rust-analyzer") + end + + if has("docker") then + vim.list_extend(tools, { + "dockerfile-language-server", + "docker-compose-language-service", + "hadolint" + }) + end + + if has("terraform") then + vim.list_extend(tools, { + "terraform-ls", + "tflint" + }) + end + + if has("az") then + table.insert(tools, "bicep-lsp") + end + + if has("node") or has("npm") then + vim.list_extend(tools, { + "typescript-language-server", + "eslint_d" + }) + end + + -- Additional linters and formatters + vim.list_extend(tools, { + "yamllint", + "actionlint", + "sqlls", + }) + + return tools +end + +-- Load server configurations from individual files +function M.load_server_configs() + local configs = {} + local server_files = { + "yaml", + "docker", + "terraform", + "json", + "sql", + "go", + "python", + "bicep", + "powershell", + "csv", + "markdown", + } + + for _, file in ipairs(server_files) do + local ok, config = pcall(require, "lsp.servers." .. file) + if ok and config then + -- Check if the config has a condition function + if config.condition then + if config.condition() then + configs[config.name] = config + end + else + configs[config.name] = config + end + end + end + + return configs +end + +return M \ No newline at end of file diff --git a/config/nvim/lua/lsp/plugins/none_ls.lua b/config/nvim/lua/lsp/plugins/none_ls.lua index f1569e92..1e164834 100644 --- a/config/nvim/lua/lsp/plugins/none_ls.lua +++ b/config/nvim/lua/lsp/plugins/none_ls.lua @@ -6,129 +6,97 @@ return { config = function() local null_ls = require("null-ls") + -- Helper function to check if a tool is available + local function has_tool(tool) + return vim.fn.executable(tool) == 1 + end + + -- Build sources list based on available tools + local sources = {} + + -- Always available built-ins (no external dependencies) + table.insert(sources, null_ls.builtins.hover.dictionary) + table.insert(sources, null_ls.builtins.completion.spell) + + -- Conditionally add tools based on availability + if has_tool("stylua") then + table.insert(sources, null_ls.builtins.formatting.stylua) + end + + if has_tool("prettier") then + table.insert(sources, null_ls.builtins.formatting.prettier) + end + + if has_tool("actionlint") then + table.insert(sources, null_ls.builtins.diagnostics.actionlint) + end + + if has_tool("shfmt") then + table.insert(sources, null_ls.builtins.formatting.shfmt) + end + + if has_tool("shellcheck") then + table.insert(sources, null_ls.builtins.diagnostics.shellcheck) + end + + -- Markdown tools (only if available) + if has_tool("markdownlint") then + table.insert(sources, null_ls.builtins.diagnostics.markdownlint) + end + + if has_tool("textlint") then + table.insert(sources, null_ls.builtins.diagnostics.textlint) + end + + if has_tool("proselint") then + table.insert(sources, null_ls.builtins.diagnostics.proselint) + end + + -- Python tools + if has_tool("black") then + table.insert(sources, null_ls.builtins.formatting.black) + end + + if has_tool("isort") then + table.insert(sources, null_ls.builtins.formatting.isort) + end + + -- Go tools + if has_tool("gofmt") then + table.insert(sources, null_ls.builtins.formatting.gofmt) + end + + if has_tool("goimports") then + table.insert(sources, null_ls.builtins.formatting.goimports) + end + + if has_tool("golangci-lint") then + table.insert(sources, null_ls.builtins.diagnostics.golangci_lint) + end + + -- YAML tools + if has_tool("yamllint") then + table.insert(sources, null_ls.builtins.diagnostics.yamllint) + end + + -- Terraform tools + if has_tool("terraform") then + table.insert(sources, null_ls.builtins.formatting.terraform_fmt) + table.insert(sources, null_ls.builtins.diagnostics.terraform_validate) + end + + if has_tool("tflint") then + table.insert(sources, null_ls.builtins.diagnostics.tflint) + end + + -- SQL tools + if has_tool("sqlfmt") then + table.insert(sources, null_ls.builtins.formatting.sqlfmt) + end + null_ls.setup({ - sources = { - -- Misc - null_ls.builtins.hover.dictionary, - null_ls.builtins.hover.printenv, - - -- Formatters - null_ls.builtins.formatting.stylua, - null_ls.builtins.formatting.prettier, - null_ls.builtins.formatting.treefmt, - - -- Stylelint - null_ls.builtins.formatting.stylelint, - - -- Completion/snippets/spelling - null_ls.builtins.completion.luasnip, - null_ls.builtins.completion.nvim_snippets, - null_ls.builtins.completion.spell, - - -- GitHub Actions - null_ls.builtins.diagnostics.actionlint, - - -- Shell - null_ls.builtins.formatting.shfmt, - null_ls.builtins.formatting.shellharden, - - -- Markdown - null_ls.builtins.diagnostics.alex, - null_ls.builtins.diagnostics.markdownlint, - null_ls.builtins.diagnostics.markdownlint_cli2, - null_ls.builtins.diagnostics.textlint, - null_ls.builtins.formatting.mdformat, - null_ls.builtins.formatting.remark, - null_ls.builtins.formatting.textlint, - - -- Ansible - null_ls.builtins.diagnostics.ansiblelint, - - -- Django - null_ls.builtins.diagnostics.djlint, - null_ls.builtins.formatting.djhtml, - - -- .env - null_ls.builtins.diagnostics.dotenv_linter, - - -- Go - null_ls.builtins.code_actions.gomodifytags, - null_ls.builtins.diagnostics.golangci_lint, - null_ls.builtins.diagnostics.staticcheck, - null_ls.builtins.formatting.gofmt, - null_ls.builtins.formatting.goimports, - null_ls.builtins.formatting.goimports_reviser, - null_ls.builtins.formatting.golines, - - -- Python - null_ls.builtins.formatting.isort, - null_ls.builtins.formatting.black, - null_ls.builtins.formatting.pyink, - - -- Nix - null_ls.builtins.diagnostics.statix, - null_ls.builtins.diagnostics.deadnix, - null_ls.builtins.formatting.alejandra, - null_ls.builtins.formatting.nixfmt, - null_ls.builtins.formatting.nixpkgs_fmt, - null_ls.builtins.formatting.nix_flake_fmt, - - -- Git commit messages - null_ls.builtins.diagnostics.gitlint, - - -- HCL - null_ls.builtins.formatting.hclfmt, - - -- Opentofu - null_ls.builtins.diagnostics.opentofu_validate, - null_ls.builtins.formatting.opentofu_fmt, - - -- Terraform - null_ls.builtins.diagnostics.terraform_validate, - null_ls.builtins.diagnostics.terragrunt_validate, - null_ls.builtins.diagnostics.tfsec, - null_ls.builtins.formatting.terraform_fmt, - null_ls.builtins.formatting.terragrunt_fmt, - - -- Prose - null_ls.builtins.diagnostics.proselint, - null_ls.builtins.diagnostics.write_good, - - -- Salt - null_ls.builtins.diagnostics.saltlint, - - -- JSON - null_ls.builtins.diagnostics.spectral, - - -- YAML - null_ls.builtins.diagnostics.yamllint, - null_ls.builtins.formatting.yamlfix, - null_ls.builtins.formatting.yamlfmt, - - -- SQL - null_ls.builtins.diagnostics.sqruff, - null_ls.builtins.formatting.pg_format, - null_ls.builtins.formatting.sqlfmt, - null_ls.builtins.formatting.sqlformat, - null_ls.builtins.formatting.sql_formatter, - - -- CSS - null_ls.builtins.diagnostics.stylelint, - - -- HTML/XML/etc. - null_ls.builtins.diagnostics.tidy, - null_ls.builtins.formatting.htmlbeautifier, - null_ls.builtins.formatting.xmllint, - - -- C# - null_ls.builtins.formatting.csharpier, - - -- NGINX - null_ls.builtins.formatting.nginx_beautifier, - - -- NodeJS - null_ls.builtins.formatting.npm_groovy_lint, - }, + sources = sources, + debug = false, -- Set to true if you want to see debug info }) end, } \ No newline at end of file diff --git a/config/nvim/lua/lsp/servers/bicep.lua b/config/nvim/lua/lsp/servers/bicep.lua new file mode 100644 index 00000000..b092ec7f --- /dev/null +++ b/config/nvim/lua/lsp/servers/bicep.lua @@ -0,0 +1,25 @@ +return { + name = "bicep", + servers = { "bicep" }, + tools = { "bicep-lsp" }, + settings = { + bicep = { + -- Enable experimental features + experimental = { + resourceTyping = true, + }, + -- Format settings + formatter = { + insertFinalNewline = true, + indentKind = "Space", + indentSize = 2, + }, + -- Completion settings + completion = { + showSnippets = true, + showDescriptions = true, + }, + }, + }, + filetypes = { "bicep" }, +} \ No newline at end of file diff --git a/config/nvim/lua/lsp/servers/csv.lua b/config/nvim/lua/lsp/servers/csv.lua new file mode 100644 index 00000000..9db99d51 --- /dev/null +++ b/config/nvim/lua/lsp/servers/csv.lua @@ -0,0 +1,9 @@ +return { + name = "csv", + servers = {}, + tools = {}, + -- CSV support through treesitter and rainbow-csv plugin + treesitter = { "csv" }, + settings = {}, + filetypes = { "csv", "tsv" }, +} \ No newline at end of file diff --git a/config/nvim/lua/lsp/servers/docker.lua b/config/nvim/lua/lsp/servers/docker.lua new file mode 100644 index 00000000..6e3988c2 --- /dev/null +++ b/config/nvim/lua/lsp/servers/docker.lua @@ -0,0 +1,23 @@ +return { + name = "docker", + servers = { "dockerls", "docker_compose_language_service" }, + tools = { "dockerfile-language-server", "docker-compose-language-service", "hadolint" }, + settings = { + dockerls = { + settings = { + docker = { + languageserver = { + formatter = { + ignoreMultilineInstructions = true, + }, + }, + }, + }, + }, + docker_compose_language_service = { + -- Docker Compose LSP settings + settings = {}, + }, + }, + filetypes = { "dockerfile", "docker-compose" }, +} \ No newline at end of file diff --git a/config/nvim/lua/lsp/servers/go.lua b/config/nvim/lua/lsp/servers/go.lua index d7a6b3d5..e013d74c 100644 --- a/config/nvim/lua/lsp/servers/go.lua +++ b/config/nvim/lua/lsp/servers/go.lua @@ -1,4 +1,25 @@ return { name = "go", servers = { "gopls", "golangci_lint_ls", "sqls" }, + tools = { "gopls", "golangci-lint", "gofumpt", "goimports", "gomodifytags", "impl", "delve" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + shadow = true, + fieldalignment = true, + nilness = true, + unusedwrite = true, + useany = true, + }, + staticcheck = true, + gofumpt = true, + semanticTokens = true, + usePlaceholders = true, + completeUnimported = true, + matcher = "fuzzy", + experimentalPostfixCompletions = true, + buildFlags = { "-tags", "integration" }, + }, + }, } diff --git a/config/nvim/lua/lsp/servers/json.lua b/config/nvim/lua/lsp/servers/json.lua new file mode 100644 index 00000000..7a42099d --- /dev/null +++ b/config/nvim/lua/lsp/servers/json.lua @@ -0,0 +1,15 @@ +return { + name = "json", + servers = { "jsonls" }, + tools = { "json-lsp", "prettier" }, + settings = { + jsonls = { + schemas = require("schemastore").json.schemas(), + validate = { enable = true }, + format = { + enable = true, + }, + }, + }, + filetypes = { "json", "jsonc" }, +} \ No newline at end of file diff --git a/config/nvim/lua/lsp/servers/markdown.lua b/config/nvim/lua/lsp/servers/markdown.lua new file mode 100644 index 00000000..d436f24d --- /dev/null +++ b/config/nvim/lua/lsp/servers/markdown.lua @@ -0,0 +1,11 @@ +return { + name = "markdown", + servers = {}, -- Disable marksman for now since it's causing crashes + tools = { "prettier" }, + settings = {}, + filetypes = { "markdown", "md" }, + -- Disabled until marksman issues are resolved + condition = function() + return false -- Completely disable for now + end, +} \ No newline at end of file diff --git a/config/nvim/lua/lsp/servers/powershell.lua b/config/nvim/lua/lsp/servers/powershell.lua index eb8336b8..b7b2d731 100644 --- a/config/nvim/lua/lsp/servers/powershell.lua +++ b/config/nvim/lua/lsp/servers/powershell.lua @@ -1,47 +1,31 @@ --- PowerShell LSP server configuration --- Cross-platform: works on Windows, Linux, and macOS when PowerShell is installed - -local M = {} - -function M.powershell_es() - -- Only configure if PowerShell is actually available - local pwsh_available = vim.fn.executable("pwsh") == 1 - local powershell_available = vim.fn.executable("powershell") == 1 - - if not (pwsh_available or powershell_available) then - return nil - end - - return { - filetypes = { "ps1", "psm1", "psd1" }, - root_dir = function(fname) - return require("lspconfig.util").find_git_ancestor(fname) or vim.fn.getcwd() - end, - single_file_support = true, - settings = { - powershell = { - codeFormatting = { - Preset = "OTBS", -- One True Brace Style - openBraceOnSameLine = true, - newLineAfterOpenBrace = true, - newLineAfterCloseBrace = true, - pipelineIndentationStyle = "IncreaseIndentationAfterEveryPipeline", - whitespaceBeforeOpenBrace = true, - whitespaceBeforeOpenParen = true, - whitespaceAroundOperator = true, - whitespaceAfterSeparator = true, - ignoreOneLineBlock = true, - }, - scriptAnalysis = { - enable = true, - settingsPath = "", - }, - developer = { - editorServicesLogLevel = "Normal", - }, +return { + name = "powershell", + servers = { "powershell_es" }, + tools = { "powershell-editor-services" }, + settings = { + powershell = { + codeFormatting = { + preset = "OTBS", + openBraceOnSameLine = true, + newLineAfterOpenBrace = true, + newLineAfterCloseBrace = true, + pipelineIndentationStyle = "IncreaseIndentationForFirstPipeline", + whitespaceBeforeOpenBrace = true, + whitespaceBeforeOpenParen = true, + whitespaceAroundOperator = true, + whitespaceAfterSeparator = true, + ignoreOneLineBlock = true, + alignPropertyValuePairs = true, + }, + scriptAnalysis = { + enable = true, + settingsPath = "", + }, + developer = { + editorServicesLogLevel = "Normal", + bundledModulesPath = "", }, }, - } -end - -return M \ No newline at end of file + }, + filetypes = { "ps1", "psm1", "psd1" }, +} \ No newline at end of file diff --git a/config/nvim/lua/lsp/servers/python.lua b/config/nvim/lua/lsp/servers/python.lua index b9120f97..527d10bf 100644 --- a/config/nvim/lua/lsp/servers/python.lua +++ b/config/nvim/lua/lsp/servers/python.lua @@ -1,4 +1,23 @@ return { name = "python", - servers = { "pyright" }, + servers = { "pyright", "ruff_lsp" }, + tools = { "pyright", "ruff", "black", "isort", "mypy", "pylint", "flake8" }, + settings = { + pyright = { + disableOrganizeImports = true, -- Using ruff + analysis = { + autoSearchPaths = true, + diagnosticMode = "workspace", + useLibraryCodeForTypes = true, + typeCheckingMode = "basic", + }, + }, + ruff_lsp = { + init_options = { + settings = { + args = {}, + }, + }, + }, + }, } diff --git a/config/nvim/lua/lsp/servers/sql.lua b/config/nvim/lua/lsp/servers/sql.lua new file mode 100644 index 00000000..b12b21ec --- /dev/null +++ b/config/nvim/lua/lsp/servers/sql.lua @@ -0,0 +1,40 @@ +return { + name = "sql", + servers = { "sqlls", "sqls" }, + tools = { "sqlls", "sqls" }, + settings = { + sqlls = { + connections = { + { + driver = "postgresql", + dataSourceName = "host=127.0.0.1 port=5432 user=postgres password= dbname=postgres sslmode=disable", + }, + { + driver = "mysql", + dataSourceName = "root:password@tcp(127.0.0.1:3306)/", + }, + { + driver = "sqlserver", + dataSourceName = "sqlserver://username:password@localhost/instance?database=dbname", + }, + }, + }, + sqls = { + connections = { + { + driver = "postgresql", + dataSourceName = "host=127.0.0.1 port=5432 user=postgres password= dbname=postgres sslmode=disable", + }, + { + driver = "mysql", + dataSourceName = "root:password@tcp(127.0.0.1:3306)/", + }, + { + driver = "mssql", + dataSourceName = "sqlserver://username:password@localhost/instance?database=dbname", + }, + }, + }, + }, + filetypes = { "sql", "mysql", "plsql" }, +} \ No newline at end of file diff --git a/config/nvim/lua/lsp/servers/terraform.lua b/config/nvim/lua/lsp/servers/terraform.lua new file mode 100644 index 00000000..6b0c4f30 --- /dev/null +++ b/config/nvim/lua/lsp/servers/terraform.lua @@ -0,0 +1,20 @@ +return { + name = "terraform", + servers = { "terraformls", "tflint" }, + tools = { "terraform-ls", "tflint" }, + settings = { + terraformls = { + experimentalFeatures = { + validateOnSave = true, + prefillRequiredFields = true, + }, + validation = { + enableEnhancedValidation = true, + }, + }, + tflint = { + -- TFLint configuration + }, + }, + filetypes = { "terraform", "tf", "terraform-vars" }, +} \ No newline at end of file diff --git a/config/nvim/lua/lsp/servers/yaml.lua b/config/nvim/lua/lsp/servers/yaml.lua new file mode 100644 index 00000000..c80c0a0d --- /dev/null +++ b/config/nvim/lua/lsp/servers/yaml.lua @@ -0,0 +1,37 @@ +return { + name = "yaml", + servers = { "yamlls" }, + tools = { "yaml-language-server", "yamllint", "actionlint" }, + settings = { + yamlls = { + schemaStore = { + enable = true, + url = "https://www.schemastore.org/api/json/catalog.json", + }, + schemas = { + kubernetes = "*.yaml", + ["http://json.schemastore.org/github-workflow"] = ".github/workflows/*", + ["http://json.schemastore.org/github-action"] = ".github/action.{yml,yaml}", + ["http://json.schemastore.org/ansible-stable-2.9"] = "roles/tasks/*.{yml,yaml}", + ["http://json.schemastore.org/prettierrc"] = ".prettierrc.{yml,yaml}", + ["http://json.schemastore.org/kustomization"] = "kustomization.{yml,yaml}", + ["http://json.schemastore.org/ansible-playbook"] = "*play*.{yml,yaml}", + ["http://json.schemastore.org/chart"] = "Chart.{yml,yaml}", + ["https://json.schemastore.org/dependabot-v2"] = ".github/dependabot.{yml,yaml}", + ["https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"] = "*gitlab-ci*.{yml,yaml}", + ["https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"] = "*api*.{yml,yaml}", + ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "*docker-compose*.{yml,yaml}", + ["https://raw.githubusercontent.com/argoproj/argo-workflows/master/api/jsonschema/schema.json"] = "*flow*.{yml,yaml}", + }, + validate = true, + completion = true, + hover = true, + format = { + enable = true, + singleQuote = false, + bracketSpacing = true, + }, + }, + }, + filetypes = { "yaml", "yml" }, +} \ No newline at end of file