languages.lua
1 return { 2 { 3 "windwp/nvim-autopairs", 4 config = function() 5 require("nvim-autopairs").setup({}) 6 end, 7 }, 8 { 9 "neovim/nvim-lspconfig", 10 dependencies = { 11 { "mason-org/mason.nvim", opts = {} }, 12 "mason-org/mason-lspconfig.nvim", 13 "WhoIsSethDaniel/mason-tool-installer.nvim", 14 }, 15 config = function() -- 16 require("mason").setup() 17 require("mason-lspconfig").setup({ 18 ensure_installed = { 19 "bashls", 20 "dockerls", 21 "docker_compose_language_service", 22 "lua_ls", 23 "html", 24 "markdown_oxide", 25 "postgres_lsp", 26 "ruff", 27 "yamlls", 28 "basedpyright", 29 }, 30 automatic_installation = true, 31 }) 32 33 -- local lspconfig = require("lspconfig") 34 vim.lsp.config["bashls"] = { 35 cmd = { "bash-language-server", "start" }, 36 } 37 38 vim.lsp.config["dockerls"] = { 39 cmd = { "docker-langserver", "--stdio" }, 40 filetypes = { "dockerfile" }, 41 root_markers = { { "compose.yaml", "compose.yml", "Dockerfile" }, ".git" }, 42 } 43 44 vim.lsp.config["docker_compose_language_service"] = { 45 cmd = { "docker-compose-language-server", "--stdio" }, 46 filetypes = { "yaml" }, 47 root_markers = { { "compose.yaml", "compose.yml", "Dockerfile" }, ".git" }, 48 } 49 50 vim.lsp.config["lua_ls"] = { 51 cmd = { "lua-language-server" }, 52 filetypes = { "lua" }, 53 root_markers = { { ".luarc.json", ".luarc.jsonc", ".stylua.toml", ".luacheckrc" }, ".git" }, 54 } 55 56 vim.lsp.config["markdown_oxide"] = { 57 cmd = { "oxi" }, 58 filetypes = { "markdown" }, 59 root_markers = { {}, ".git" }, 60 } 61 62 vim.lsp.config["yamlls"] = { 63 cmd = { "yaml-language-server", "--stdio" }, 64 filetypes = { "yaml" }, 65 root_markers = { { ".yamllint", ".yamllint.yml", ".yamllint.yaml" }, ".git" }, 66 } 67 vim.lsp.config["basedpyright"] = { 68 cmd = { "basedpyright", "--lsp" }, 69 filetypes = { "python" }, 70 root_markers = { { "pyproject.toml" }, ".git" }, 71 } 72 73 vim.lsp.config["ruff"] = { 74 cmd = { "ruff", "check" }, 75 filetypes = { "python" }, 76 root_markers = { { "pyproject.toml" }, ".git" }, 77 } 78 79 vim.api.nvim_create_autocmd("LspAttach", { 80 group = vim.api.nvim_create_augroup("UserLspConfig", {}), 81 callback = function(ev) 82 local opts = { buffer = ev.buf } 83 vim.keymap.set( 84 "n", 85 "gd", 86 vim.lsp.buf.definition, 87 vim.tbl_extend("force", opts, { desc = "go to definition" }) 88 ) 89 vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) 90 vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts) 91 end, 92 }) 93 end, 94 }, 95 { 96 "nvim-mini/mini.completion", 97 config = function() 98 require("mini.completion").setup({}) 99 end, 100 }, 101 -- { 102 -- "mfussenegger/nvim-lint", 103 -- config = function() 104 -- require("lint").linters_by_ft = { 105 -- actionlint = { "actionlint" }, 106 -- dockerfile = { "hadolint" }, 107 -- haskell = { "hlint" }, 108 -- json = { "jq" }, 109 -- lua = { "luacheck" }, 110 -- markdown = { "markdownlint-cli2" }, 111 -- python = { "ruff" }, 112 -- text = { "vale" }, 113 -- } 114 -- end, 115 -- }, 116 { 117 "stevearc/conform.nvim", 118 config = function() 119 require("conform").setup({ 120 notify_on_error = true, 121 notify_no_formatters = true, 122 formatters_by_ft = { 123 bash = { 124 "shellcheck", 125 "shellharden", 126 "shfmt", 127 }, 128 docker = { "dockerfmt" }, 129 gerkin = { "ghokin" }, 130 go = { "gofmt" }, 131 haskell = { "hindent", "stylish-haskell" }, 132 html = { "html_beautify" }, 133 json = { "jq" }, 134 just = { "just" }, 135 lua = { "stylua", "lua-format" }, 136 markdown = { "markdownlint-cli2" }, 137 nix = { "alejandra", "nixpkgs-fmt" }, 138 nu = { "nufmt" }, 139 pyproject = { "pyproject-fmt" }, 140 python = { "isort", "ruff" }, 141 sql = { "sqlfmt" }, 142 yaml = { "yamlfmt", "yq" }, 143 _ = { 144 "squeeze_blanks", 145 "trim_whitespace", 146 "trim_newlines", 147 }, 148 }, 149 format_on_save = { 150 timeout_ms = 500, 151 lsp_format = "fallback", 152 }, 153 }) 154 end, 155 }, 156 { 157 "AckslD/nvim-FeMaco.lua", 158 config = function() 159 require("femaco").setup({}) 160 require("which-key").add({ "<leader>cb", "<cmd>FeMaco<cr>", desc = "code block editor" }) 161 end, 162 }, 163 { 164 "nvim-treesitter/nvim-treesitter", 165 config = function() 166 require("nvim-treesitter.configs").setup({ 167 auto_install = true, 168 ensure_installed = { 169 "bash", 170 "c", 171 "diff", 172 "html", 173 "json", 174 "latex", 175 "lua", 176 "luadoc", 177 "make", 178 "markdown", 179 "markdown_inline", 180 "nix", 181 "regex", 182 "query", 183 "sql", 184 "terraform", 185 "toml", 186 "vim", 187 "vimdoc", 188 "xml", 189 "yaml", 190 }, 191 highlight = { 192 enable = true, 193 additional_vim_regex_highlighting = false, 194 }, 195 indent = { 196 enable = true, 197 }, 198 }) 199 end, 200 -- treesitter-textobjects = { 201 -- enable = true; 202 -- lspInterop.enable = true; 203 -- move.enable = true; 204 -- select.enable = true; 205 -- }; 206 }, 207 { 208 "folke/trouble.nvim", 209 dependencies = { "nvim-tree/nvim-web-devicons" }, 210 opts = {}, 211 config = function() 212 require("trouble").setup({}) 213 local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } 214 for type, icon in pairs(signs) do 215 local hl = "DiagnosticSign" .. type 216 vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) 217 end 218 219 vim.diagnostic.config({ 220 virtual_text = true, 221 signs = true, 222 update_in_insert = false, 223 underline = true, 224 severity_sort = true, 225 float = { 226 focusable = false, 227 style = "minimal", 228 border = "rounded", 229 source = "always", 230 header = "", 231 prefix = "", 232 }, 233 }) 234 end, 235 keys = { 236 { "<leader>xx", "<cmd>Trouble diagnostics toggle<cr>", desc = "Diagnostics (Trouble)" }, 237 { "<leader>xX", "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = "Buffer Diagnostics (Trouble)" }, 238 { "<leader>xq", "<cmd>Trouble qflist toggle<cr>", desc = "Quickfix List (Trouble)" }, 239 }, 240 }, 241 }