From 4e5e6b18facfe34a7b629615ff6f77d6d8bef4ed Mon Sep 17 00:00:00 2001 From: redjax Date: Tue, 30 Sep 2025 16:40:10 -0400 Subject: [PATCH] fix(lsp): Add more LSPs to lazyvim --- .../lua/plugins/00-lazyvim-imports.lua | 11 +- config/nvim-lazyvim/lua/plugins/cmp.lua | 66 +++++- .../lua/plugins/lsp-comprehensive.lua | 182 +++++++++++++++++ .../lua/plugins/lsp-csv-support.lua | 49 +++++ .../lua/plugins/lsp-devops-support.lua | 138 +++++++++++++ .../lua/plugins/lsp-docker-support.lua | 168 +++++++++++++++ .../lua/plugins/lsp-filetype-support.lua | 193 ++++++++++++++++++ .../lua/plugins/lsp-sql-support.lua | 116 +++++++++++ config/nvim-lazyvim/lua/plugins/mason.lua | 59 ++++-- 9 files changed, 963 insertions(+), 19 deletions(-) create mode 100644 config/nvim-lazyvim/lua/plugins/lsp-comprehensive.lua create mode 100644 config/nvim-lazyvim/lua/plugins/lsp-csv-support.lua create mode 100644 config/nvim-lazyvim/lua/plugins/lsp-devops-support.lua create mode 100644 config/nvim-lazyvim/lua/plugins/lsp-docker-support.lua create mode 100644 config/nvim-lazyvim/lua/plugins/lsp-filetype-support.lua create mode 100644 config/nvim-lazyvim/lua/plugins/lsp-sql-support.lua diff --git a/config/nvim-lazyvim/lua/plugins/00-lazyvim-imports.lua b/config/nvim-lazyvim/lua/plugins/00-lazyvim-imports.lua index 5d5b467..5715f01 100644 --- a/config/nvim-lazyvim/lua/plugins/00-lazyvim-imports.lua +++ b/config/nvim-lazyvim/lua/plugins/00-lazyvim-imports.lua @@ -5,9 +5,18 @@ return { -- Note: lazyvim.plugins is imported in lua/config/lazy.lua -- We only need to import extras here, in the correct order - -- Import LazyVim extras + -- Import LazyVim language extras { import = "lazyvim.plugins.extras.lang.typescript" }, { import = "lazyvim.plugins.extras.lang.json" }, + { import = "lazyvim.plugins.extras.lang.python" }, + { import = "lazyvim.plugins.extras.lang.go" }, + { import = "lazyvim.plugins.extras.lang.yaml" }, + { import = "lazyvim.plugins.extras.lang.markdown" }, + { import = "lazyvim.plugins.extras.lang.terraform" }, + + -- Import LazyVim tool extras + { import = "lazyvim.plugins.extras.formatting.prettier" }, + { import = "lazyvim.plugins.extras.linting.eslint" }, -- Configure LazyVim colorscheme { diff --git a/config/nvim-lazyvim/lua/plugins/cmp.lua b/config/nvim-lazyvim/lua/plugins/cmp.lua index 3967405..09e2eaa 100644 --- a/config/nvim-lazyvim/lua/plugins/cmp.lua +++ b/config/nvim-lazyvim/lua/plugins/cmp.lua @@ -1,12 +1,74 @@ return { { "hrsh7th/nvim-cmp", - dependencies = { "hrsh7th/cmp-emoji" }, + dependencies = { + "hrsh7th/cmp-emoji", + "hrsh7th/cmp-path", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-cmdline", + "f3fora/cmp-spell", + "ray-x/cmp-treesitter", + }, ---@param opts cmp.ConfigSchema opts = function(_, opts) + local cmp = require("cmp") + -- Ensure opts.sources exists before inserting opts.sources = opts.sources or {} - table.insert(opts.sources, { name = "emoji" }) + + -- Add additional completion sources + vim.list_extend(opts.sources, { + { name = "emoji" }, + { name = "path" }, + { name = "treesitter", group_index = 2 }, + { name = "spell", group_index = 2 }, + }) + + -- Enhanced sorting + opts.sorting = { + priority_weight = 2, + comparators = { + cmp.config.compare.offset, + cmp.config.compare.exact, + cmp.config.compare.score, + cmp.config.compare.recently_used, + cmp.config.compare.locality, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, + }, + } + + -- File type specific configurations + vim.api.nvim_create_autocmd("FileType", { + pattern = { "yaml", "yml" }, + callback = function() + cmp.setup.buffer({ + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "path" }, + { name = "spell" }, + }), + }) + end, + }) + + vim.api.nvim_create_autocmd("FileType", { + pattern = { "terraform", "tf" }, + callback = function() + cmp.setup.buffer({ + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "path" }, + }), + }) + end, + }) + + return opts end, }, } \ No newline at end of file diff --git a/config/nvim-lazyvim/lua/plugins/lsp-comprehensive.lua b/config/nvim-lazyvim/lua/plugins/lsp-comprehensive.lua new file mode 100644 index 0000000..a5916dd --- /dev/null +++ b/config/nvim-lazyvim/lua/plugins/lsp-comprehensive.lua @@ -0,0 +1,182 @@ +-- Comprehensive LSP configuration for multiple languages and file types +-- Covers: Python, PowerShell, Bash, Azure Bicep, DevOps pipelines, GitHub Actions, +-- YAML, CSV, Go, Markdown, SQL, Terraform, Docker/Dockerfile + +return { + "neovim/nvim-lspconfig", + dependencies = { + "mason.nvim", + "mason-org/mason-lspconfig.nvim", + }, + opts = function(_, opts) + local function has(cmd) + return vim.fn.executable(cmd) == 1 + end + + opts.servers = opts.servers or {} + + -- YAML LSP - essential for Azure DevOps, GitHub Actions, Kubernetes, etc. + opts.servers.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", + }, + }, + }, + } + + -- Terraform LSP + opts.servers.terraformls = { + filetypes = { "terraform", "tf", "terraform-vars" }, + settings = { + terraform = { + validate = true, + }, + }, + } + + -- Dockerfile LSP + opts.servers.dockerls = { + filetypes = { "dockerfile" }, + settings = { + docker = { + languageserver = { + formatter = { + ignoreMultilineInstructions = true, + }, + }, + }, + }, + } + + -- Azure Bicep LSP (when Azure CLI is available) + if has("az") then + opts.servers.bicep = { + filetypes = { "bicep" }, + settings = {}, + } + end + + -- Markdown LSP + opts.servers.marksman = { + filetypes = { "markdown", "md" }, + settings = {}, + } + + -- Go LSP (enhanced configuration) + if has("go") then + opts.servers.gopls = { + settings = { + gopls = { + analyses = { + unusedparams = true, + shadow = true, + fieldalignment = true, + nilness = true, + }, + staticcheck = true, + gofumpt = true, + usePlaceholders = true, + completeUnimported = true, + directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" }, + }, + }, + } + end + + -- SQL LSPs + opts.servers.sqlls = { + filetypes = { "sql", "mysql", "pgsql" }, + settings = {}, + } + + -- Enhanced Python LSP + if has("python") or has("python3") then + opts.servers.pyright = { + settings = { + python = { + analysis = { + typeCheckingMode = "basic", + autoSearchPaths = true, + useLibraryCodeForTypes = true, + autoImportCompletions = true, + }, + }, + }, + } + end + + -- JSON LSP with schema support for various file types + opts.servers.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", + }, + }, + }, + }, + } + + -- CSV LSP (using rainbow_csv for syntax highlighting) + -- Note: This is handled by the rainbow_csv plugin, not LSP + + return opts + end, +} \ No newline at end of file diff --git a/config/nvim-lazyvim/lua/plugins/lsp-csv-support.lua b/config/nvim-lazyvim/lua/plugins/lsp-csv-support.lua new file mode 100644 index 0000000..d951bec --- /dev/null +++ b/config/nvim-lazyvim/lua/plugins/lsp-csv-support.lua @@ -0,0 +1,49 @@ +-- CSV file handling with Rainbow CSV plugin +-- Provides syntax highlighting and table operations for CSV files + +return { + { + "mechatroner/rainbow_csv", + ft = { "csv", "tsv", "csv_semicolon", "csv_whitespace", "csv_pipe", "rfc_csv" }, + config = function() + -- Rainbow CSV configuration + vim.g.rainbow_csv_max_columns = 100 + vim.g.rainbow_csv_delim_policy = "quoted" + + -- Key mappings for CSV operations + vim.api.nvim_create_autocmd("FileType", { + pattern = { "csv", "tsv" }, + callback = function() + local opts = { buffer = true, silent = true } + vim.keymap.set("n", "ca", ":RainbowAlign", + vim.tbl_extend("force", opts, { desc = "Align CSV columns" })) + vim.keymap.set("n", "cs", ":RainbowShrink", + vim.tbl_extend("force", opts, { desc = "Shrink CSV columns" })) + vim.keymap.set("n", "cq", ":RainbowMultiDelim", + vim.tbl_extend("force", opts, { desc = "Query CSV" })) + end, + }) + end, + }, + + -- Enhanced completion for CSV files + { + "hrsh7th/nvim-cmp", + dependencies = { "mechatroner/rainbow_csv" }, + opts = function(_, opts) + -- Add CSV-specific completion sources when in CSV files + vim.api.nvim_create_autocmd("FileType", { + pattern = { "csv", "tsv" }, + callback = function() + local cmp = require("cmp") + cmp.setup.buffer({ + sources = cmp.config.sources({ + { name = "buffer" }, + { name = "path" }, + }), + }) + end, + }) + end, + }, +} \ No newline at end of file diff --git a/config/nvim-lazyvim/lua/plugins/lsp-devops-support.lua b/config/nvim-lazyvim/lua/plugins/lsp-devops-support.lua new file mode 100644 index 0000000..bf03243 --- /dev/null +++ b/config/nvim-lazyvim/lua/plugins/lsp-devops-support.lua @@ -0,0 +1,138 @@ +-- DevOps and CI/CD support for Azure DevOps and GitHub Actions +-- Includes specialized configurations for pipeline files + +return { + -- YAML LSP with DevOps-specific schemas (already covered in lsp-comprehensive.lua) + + -- GitHub Actions syntax highlighting and validation + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { + "yaml", + "dockerfile", + "bash", + "json", + }) + return opts + end, + }, + + -- File type detection for DevOps files + { + "nvim-treesitter/nvim-treesitter", + init = function() + vim.filetype.add({ + filename = { + ["azure-pipelines.yml"] = "yaml.azure-pipelines", + ["azure-pipelines.yaml"] = "yaml.azure-pipelines", + [".azure-pipelines.yml"] = "yaml.azure-pipelines", + [".azure-pipelines.yaml"] = "yaml.azure-pipelines", + }, + pattern = { + -- Azure DevOps pipeline files + [".*/%.azure/pipelines/.*%.ya?ml"] = "yaml.azure-pipelines", + [".*/pipelines/.*%.ya?ml"] = "yaml.azure-pipelines", + + -- GitHub Actions workflow files + [".*/.github/workflows/.*%.ya?ml"] = "yaml.github-workflow", + + -- GitHub Action definition files + [".*/action%.ya?ml"] = "yaml.github-action", + + -- Docker compose files + [".*/docker%-compose.*%.ya?ml"] = "yaml.docker-compose", + [".*/compose%.ya?ml"] = "yaml.docker-compose", + }, + }) + end, + }, + + -- DevOps-specific keymaps and settings + { + "LazyVim/LazyVim", + opts = function() + -- Azure DevOps pipeline settings + vim.api.nvim_create_autocmd("FileType", { + pattern = { "yaml.azure-pipelines" }, + callback = function() + vim.opt_local.commentstring = "# %s" + vim.opt_local.shiftwidth = 2 + vim.opt_local.tabstop = 2 + + -- Azure DevOps specific keymaps + local opts = { buffer = true, silent = true } + vim.keymap.set("n", "ap", ":!az pipelines run --name %:t:r", + vim.tbl_extend("force", opts, { desc = "Run Azure Pipeline" })) + end, + }) + + -- GitHub Actions workflow settings + vim.api.nvim_create_autocmd("FileType", { + pattern = { "yaml.github-workflow" }, + callback = function() + vim.opt_local.commentstring = "# %s" + vim.opt_local.shiftwidth = 2 + vim.opt_local.tabstop = 2 + + -- GitHub Actions specific keymaps + local opts = { buffer = true, silent = true } + vim.keymap.set("n", "ga", ":!gh workflow run %:t", + vim.tbl_extend("force", opts, { desc = "Run GitHub Action" })) + end, + }) + + -- Docker Compose settings + vim.api.nvim_create_autocmd("FileType", { + pattern = { "yaml.docker-compose" }, + callback = function() + vim.opt_local.commentstring = "# %s" + vim.opt_local.shiftwidth = 2 + vim.opt_local.tabstop = 2 + + -- Docker Compose specific keymaps + local opts = { buffer = true, silent = true } + vim.keymap.set("n", "dc", ":!docker-compose up -d", + vim.tbl_extend("force", opts, { desc = "Docker Compose Up" })) + vim.keymap.set("n", "dd", ":!docker-compose down", + vim.tbl_extend("force", opts, { desc = "Docker Compose Down" })) + end, + }) + end, + }, + + -- Linting for GitHub Actions and Azure DevOps + { + "mason-org/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { + "actionlint", -- GitHub Actions linter + "yamllint", -- YAML linter + }) + return opts + end, + }, + + -- Null-ls integration for DevOps linting + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = opts.sources or {} + vim.list_extend(opts.sources, { + -- GitHub Actions linting + nls.builtins.diagnostics.actionlint.with({ + filetypes = { "yaml.github-workflow" }, + }), + -- YAML linting + nls.builtins.diagnostics.yamllint.with({ + filetypes = { "yaml", "yaml.azure-pipelines", "yaml.github-workflow", "yaml.docker-compose" }, + }), + }) + return opts + end, + }, +} \ No newline at end of file diff --git a/config/nvim-lazyvim/lua/plugins/lsp-docker-support.lua b/config/nvim-lazyvim/lua/plugins/lsp-docker-support.lua new file mode 100644 index 0000000..c5e272c --- /dev/null +++ b/config/nvim-lazyvim/lua/plugins/lsp-docker-support.lua @@ -0,0 +1,168 @@ +-- Docker and Docker Compose LSP support +-- Includes Dockerfile LSP, Docker Compose YAML support, and linting (no custom keybindings) + +return { + -- Dockerfile LSP + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + opts.servers = opts.servers or {} + + -- Dockerfile Language Server + opts.servers.dockerls = { + filetypes = { "dockerfile" }, + settings = { + docker = { + languageserver = { + formatter = { + ignoreMultilineInstructions = true, + }, + }, + }, + }, + } + + return opts + end, + }, + + -- Docker tools via Mason + { + "mason-org/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + + -- Docker tools + vim.list_extend(opts.ensure_installed, { + "dockerfile-language-server", -- Dockerfile LSP + "hadolint", -- Dockerfile linter + }) + + return opts + end, + }, + + -- Enhanced treesitter support for Docker files + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { + "dockerfile", + }) + return opts + end, + }, + + -- File type detection for Docker files + { + "nvim-treesitter/nvim-treesitter", + init = function() + vim.filetype.add({ + filename = { + ["Dockerfile"] = "dockerfile", + ["dockerfile"] = "dockerfile", + ["Containerfile"] = "dockerfile", + ["containerfile"] = "dockerfile", + ["docker-compose.yml"] = "yaml.docker-compose", + ["docker-compose.yaml"] = "yaml.docker-compose", + ["compose.yml"] = "yaml.docker-compose", + ["compose.yaml"] = "yaml.docker-compose", + }, + pattern = { + -- Dockerfile variants + [".*/Dockerfile.*"] = "dockerfile", + [".*/dockerfile.*"] = "dockerfile", + [".*/Containerfile.*"] = "dockerfile", + [".*/containerfile.*"] = "dockerfile", + + -- Docker Compose variants + [".*/docker%-compose.*%.ya?ml"] = "yaml.docker-compose", + [".*/compose.*%.ya?ml"] = "yaml.docker-compose", + [".*%-compose%.ya?ml"] = "yaml.docker-compose", + [".*/docker/compose.*%.ya?ml"] = "yaml.docker-compose", + }, + }) + end, + }, + + -- Docker-specific settings (no keymaps) + { + "LazyVim/LazyVim", + opts = function() + -- Dockerfile settings + vim.api.nvim_create_autocmd("FileType", { + pattern = { "dockerfile" }, + callback = function() + vim.opt_local.commentstring = "# %s" + vim.opt_local.shiftwidth = 2 + vim.opt_local.tabstop = 2 + vim.opt_local.expandtab = true + end, + }) + + -- Docker Compose settings + vim.api.nvim_create_autocmd("FileType", { + pattern = { "yaml.docker-compose" }, + callback = function() + vim.opt_local.commentstring = "# %s" + vim.opt_local.shiftwidth = 2 + vim.opt_local.tabstop = 2 + vim.opt_local.expandtab = true + end, + }) + end, + }, + + -- Linting integration for Docker files + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = opts.sources or {} + vim.list_extend(opts.sources, { + -- Dockerfile linting + nls.builtins.diagnostics.hadolint.with({ + filetypes = { "dockerfile" }, + }), + }) + return opts + end, + }, + + -- Enhanced completion for Docker files + { + "hrsh7th/nvim-cmp", + opts = function(_, opts) + -- Docker-specific completion sources + vim.api.nvim_create_autocmd("FileType", { + pattern = { "dockerfile" }, + callback = function() + local cmp = require("cmp") + cmp.setup.buffer({ + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "path" }, + }), + }) + end, + }) + + vim.api.nvim_create_autocmd("FileType", { + pattern = { "yaml.docker-compose" }, + callback = function() + local cmp = require("cmp") + cmp.setup.buffer({ + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "path" }, + }), + }) + end, + }) + end, + }, +} \ No newline at end of file diff --git a/config/nvim-lazyvim/lua/plugins/lsp-filetype-support.lua b/config/nvim-lazyvim/lua/plugins/lsp-filetype-support.lua new file mode 100644 index 0000000..cbd6c0a --- /dev/null +++ b/config/nvim-lazyvim/lua/plugins/lsp-filetype-support.lua @@ -0,0 +1,193 @@ +-- Additional file type support and treesitter configurations +-- Ensures all mentioned languages have proper syntax highlighting and parsing + +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + + -- Ensure all required parsers are installed + vim.list_extend(opts.ensure_installed, { + -- Core languages + "lua", + "vim", + "vimdoc", + "query", + + -- Programming languages + "python", + "go", + "rust", + "c", + "cpp", + "javascript", + "typescript", + "tsx", + + -- Shell scripting + "bash", + + -- Configuration and data formats + "yaml", + "json", + "toml", + "ini", + "csv", + + -- Infrastructure as Code + "terraform", + "hcl", + "dockerfile", + + -- Documentation + "markdown", + "markdown_inline", + "rst", + + -- Database + "sql", + + -- Web technologies + "html", + "css", + "scss", + + -- Version control + "git_config", + "git_rebase", + "gitcommit", + "gitignore", + "gitattributes", + + -- Other useful formats + "regex", + "http", + "diff", + }) + + -- Enhanced treesitter configuration + opts.highlight = opts.highlight or {} + opts.highlight.enable = true + opts.highlight.additional_vim_regex_highlighting = false + + opts.indent = opts.indent or {} + opts.indent.enable = true + + opts.incremental_selection = opts.incremental_selection or {} + opts.incremental_selection.enable = true + opts.incremental_selection.keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + } + + return opts + end, + }, + + -- Additional file type associations + { + "nvim-treesitter/nvim-treesitter", + init = function() + vim.filetype.add({ + extension = { + -- Infrastructure as Code + tf = "terraform", + tfvars = "terraform", + bicep = "bicep", + + -- Shell scripts + ps1 = "ps1", + psm1 = "ps1", + psd1 = "ps1", + + -- Configuration files + conf = "conf", + env = "sh", + + -- Data files + csv = "csv", + tsv = "csv", + + -- SQL variants + pgsql = "sql", + mysql = "sql", + + -- YAML variants + yml = "yaml", + yaml = "yaml", + }, + filename = { + -- Configuration files + [".env"] = "sh", + [".env.local"] = "sh", + [".env.development"] = "sh", + [".env.production"] = "sh", + + -- Docker files + ["Dockerfile"] = "dockerfile", + ["dockerfile"] = "dockerfile", + + -- CI/CD files + [".gitlab-ci.yml"] = "yaml", + ["Jenkinsfile"] = "groovy", + }, + pattern = { + -- Environment files + ["%.env%..*"] = "sh", + + -- Terraform files + [".*%.tf"] = "terraform", + [".*%.tfvars"] = "terraform", + + -- Docker files + [".*/Dockerfile.*"] = "dockerfile", + + -- Shell scripts without extension + [".*"] = { + function(path, buf) + local first_line = vim.api.nvim_buf_get_lines(buf, 0, 1, false)[1] or "" + if first_line:match("^#!/.*sh") or first_line:match("^#!/bin/bash") then + return "bash" + elseif first_line:match("^#!/.*pwsh") or first_line:match("^#!/.*powershell") then + return "ps1" + elseif first_line:match("^#!/.*python") then + return "python" + end + end, + }, + }, + }) + end, + }, + + -- Enhanced folding with treesitter + { + "kevinhwang91/nvim-ufo", + dependencies = { + "kevinhwang91/promise-async", + "nvim-treesitter/nvim-treesitter", + }, + event = "BufReadPost", + opts = { + provider_selector = function(bufnr, filetype, buftype) + return { "treesitter", "indent" } + end, + }, + config = function(_, opts) + require("ufo").setup(opts) + + -- Set fold settings + vim.o.foldcolumn = "1" + vim.o.foldlevel = 99 + vim.o.foldlevelstart = 99 + vim.o.foldenable = true + + -- Fold keymaps + vim.keymap.set("n", "zR", require("ufo").openAllFolds, { desc = "Open all folds" }) + vim.keymap.set("n", "zM", require("ufo").closeAllFolds, { desc = "Close all folds" }) + end, + }, +} \ No newline at end of file diff --git a/config/nvim-lazyvim/lua/plugins/lsp-sql-support.lua b/config/nvim-lazyvim/lua/plugins/lsp-sql-support.lua new file mode 100644 index 0000000..e6b2c8d --- /dev/null +++ b/config/nvim-lazyvim/lua/plugins/lsp-sql-support.lua @@ -0,0 +1,116 @@ +-- SQL support for PostgreSQL, MySQL, and Microsoft SQL Server +-- Includes LSP, formatting, and database-specific configurations + +return { + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + opts.servers = opts.servers or {} + + -- SQL Language Server + opts.servers.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" + -- } + }, + }, + }, + } + + return opts + end, + }, + + -- SQL formatter and linter + { + "mason-org/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { + "sqlls", -- SQL Language Server + "sqlfluff", -- SQL linter and formatter + "sql-formatter", -- SQL formatter + }) + return opts + end, + }, + + -- SQL syntax highlighting and file type detection + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { + "sql", + }) + return opts + end, + }, + + -- SQL file type associations + { + "nvim-treesitter/nvim-treesitter", + init = function() + -- File type associations + vim.filetype.add({ + extension = { + sql = "sql", + pgsql = "pgsql", + mysql = "mysql", + psql = "pgsql", + }, + pattern = { + [".*%.sql"] = "sql", + [".*%.pgsql"] = "pgsql", + [".*%.mysql"] = "mysql", + [".*%.psql"] = "pgsql", + }, + }) + end, + }, + + -- Formatting configuration for SQL + { + "stevearc/conform.nvim", + optional = true, + opts = function(_, opts) + opts.formatters_by_ft = opts.formatters_by_ft or {} + opts.formatters_by_ft.sql = { "sqlfluff" } + opts.formatters_by_ft.mysql = { "sqlfluff" } + opts.formatters_by_ft.pgsql = { "sqlfluff" } + return opts + end, + }, + + -- SQL keymaps and settings + { + "LazyVim/LazyVim", + opts = function() + -- SQL-specific settings + vim.api.nvim_create_autocmd("FileType", { + pattern = { "sql", "mysql", "pgsql" }, + callback = function() + -- Set SQL-specific options + vim.opt_local.commentstring = "-- %s" + vim.opt_local.iskeyword:append("@-@") + + -- SQL-specific keymaps + local opts = { buffer = true, silent = true } + vim.keymap.set("n", "sf", ":!sqlfluff format %", + vim.tbl_extend("force", opts, { desc = "Format SQL file" })) + end, + }) + end, + }, +} \ No newline at end of file diff --git a/config/nvim-lazyvim/lua/plugins/mason.lua b/config/nvim-lazyvim/lua/plugins/mason.lua index 3dfaced..3f16a80 100644 --- a/config/nvim-lazyvim/lua/plugins/mason.lua +++ b/config/nvim-lazyvim/lua/plugins/mason.lua @@ -6,49 +6,76 @@ return { return vim.fn.executable(cmd) == 1 end - -- Base tools for all platforms + -- Essential tools for all platforms local base_tools = { - "stylua", -- Lua formatter - "shellcheck", -- Shell script linter - "shfmt", -- Shell script formatter + "stylua", -- Lua formatter + "shellcheck", -- Shell script linter + "shfmt", -- Shell script formatter + "prettier", -- Multi-language formatter (JSON, YAML, Markdown, etc.) + "marksman", -- Markdown LSP + "yaml-language-server", -- YAML LSP + "json-lsp", -- JSON LSP + "terraform-ls", -- Terraform LSP + "sqlls", -- SQL LSP } - -- Conditional tools based on what's available + -- Language-specific tools based on availability local conditional_tools = {} -- Python tools (if Python is available) if has("python") or has("python3") then - table.insert(conditional_tools, "flake8") - table.insert(conditional_tools, "black") + table.insert(conditional_tools, "pyright") -- Python LSP + table.insert(conditional_tools, "flake8") -- Python linter + table.insert(conditional_tools, "black") -- Python formatter + table.insert(conditional_tools, "isort") -- Python import sorter + table.insert(conditional_tools, "mypy") -- Python type checker end - -- Bash LSP (if any shell is available) + -- Shell tools (if any shell is available) if has("bash") or has("sh") or has("zsh") then - table.insert(conditional_tools, "bash-language-server") + table.insert(conditional_tools, "bash-language-server") -- Bash LSP end - -- PowerShell LSP (if PowerShell is available) + -- PowerShell tools (if PowerShell is available) if has("pwsh") or has("powershell") then - table.insert(conditional_tools, "powershell-editor-services") + table.insert(conditional_tools, "powershell-editor-services") -- PowerShell LSP end -- Node.js tools (if Node is available) if has("node") or has("npm") then - table.insert(conditional_tools, "prettier") - table.insert(conditional_tools, "eslint_d") + table.insert(conditional_tools, "eslint_d") -- JavaScript linter + table.insert(conditional_tools, "typescript-language-server") -- TypeScript LSP end -- Go tools (if Go is available) if has("go") then - table.insert(conditional_tools, "gopls") - table.insert(conditional_tools, "gofumpt") + table.insert(conditional_tools, "gopls") -- Go LSP + table.insert(conditional_tools, "gofumpt") -- Go formatter + table.insert(conditional_tools, "goimports") -- Go import formatter + table.insert(conditional_tools, "golines") -- Go line length formatter end -- Rust tools (if Cargo is available) if has("cargo") then - table.insert(conditional_tools, "rust-analyzer") + table.insert(conditional_tools, "rust-analyzer") -- Rust LSP end + -- Azure tools (if Azure CLI is available) + if has("az") then + table.insert(conditional_tools, "bicep-lsp") -- Azure Bicep LSP + end + + -- Docker tools (if Docker is available) + if has("docker") then + table.insert(conditional_tools, "dockerfile-language-server") -- Dockerfile LSP + table.insert(conditional_tools, "hadolint") -- Dockerfile linter + end + + -- Additional formatters and linters + table.insert(conditional_tools, "yamllint") -- YAML linter + table.insert(conditional_tools, "actionlint") -- GitHub Actions linter + table.insert(conditional_tools, "tflint") -- Terraform linter + -- Combine all tools local ensure_installed = base_tools vim.list_extend(ensure_installed, conditional_tools)