From 7d854464d9b1bd386b0eaf25f38ac3b96dd1fc18 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Sat, 1 Mar 2025 01:17:54 +0000 Subject: [PATCH] lazyvim: absorb all langs They don't cause errors, but have barely been tested. --- nvim/lua/plugins/lang/cmake.lua | 60 ++++++++++++ nvim/lua/plugins/lang/cpp.lua | 26 ++--- nvim/lua/plugins/lang/docker.lua | 38 ++++++++ nvim/lua/plugins/lang/git.lua | 19 ++++ nvim/lua/plugins/lang/go.lua | 147 +++++++++++++++++++++++++++++ nvim/lua/plugins/lang/haskell.lua | 89 +++++++++++++++++ nvim/lua/plugins/lang/json.lua | 39 ++++++++ nvim/lua/plugins/lang/markdown.lua | 119 +++++++++++++++++++++++ nvim/lua/plugins/lang/nix.lua | 19 ++++ nvim/lua/plugins/lang/python.lua | 110 ++++++++++----------- nvim/lua/plugins/lang/ruby.lua | 54 +++++++++++ nvim/lua/plugins/lang/rust.lua | 117 +++++++++++++++++++++++ nvim/lua/plugins/lang/tex.lua | 44 +++++++++ nvim/lua/plugins/lang/toml.lua | 8 ++ nvim/lua/plugins/lang/yaml.lua | 64 +++++++++++++ 15 files changed, 875 insertions(+), 78 deletions(-) create mode 100644 nvim/lua/plugins/lang/cmake.lua create mode 100644 nvim/lua/plugins/lang/docker.lua create mode 100644 nvim/lua/plugins/lang/git.lua create mode 100644 nvim/lua/plugins/lang/go.lua create mode 100644 nvim/lua/plugins/lang/haskell.lua create mode 100644 nvim/lua/plugins/lang/json.lua create mode 100644 nvim/lua/plugins/lang/markdown.lua create mode 100644 nvim/lua/plugins/lang/nix.lua create mode 100644 nvim/lua/plugins/lang/ruby.lua create mode 100644 nvim/lua/plugins/lang/rust.lua create mode 100644 nvim/lua/plugins/lang/tex.lua create mode 100644 nvim/lua/plugins/lang/toml.lua create mode 100644 nvim/lua/plugins/lang/yaml.lua diff --git a/nvim/lua/plugins/lang/cmake.lua b/nvim/lua/plugins/lang/cmake.lua new file mode 100644 index 0000000..2e76835 --- /dev/null +++ b/nvim/lua/plugins/lang/cmake.lua @@ -0,0 +1,60 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "cmake" } }, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.diagnostics.cmake_lint, + }) + end, + }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + cmake = { "cmakelint" }, + }, + }, + }, + { + "mason.nvim", + opts = { ensure_installed = { "cmakelang", "cmakelint" } }, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + neocmake = {}, + }, + }, + }, + { + "Civitasv/cmake-tools.nvim", + lazy = true, + init = function() + local loaded = false + local function check() + local cwd = vim.uv.cwd() + if vim.fn.filereadable(cwd .. "/CMakeLists.txt") == 1 then + require("lazy").load({ plugins = { "cmake-tools.nvim" } }) + loaded = true + end + end + check() + vim.api.nvim_create_autocmd("DirChanged", { + callback = function() + if not loaded then + check() + end + end, + }) + end, + opts = {}, + }, +} diff --git a/nvim/lua/plugins/lang/cpp.lua b/nvim/lua/plugins/lang/cpp.lua index 596c2ea..d3153db 100644 --- a/nvim/lua/plugins/lang/cpp.lua +++ b/nvim/lua/plugins/lang/cpp.lua @@ -2,11 +2,7 @@ return { -- Add C/C++ to treesitter { "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - if type(opts.ensure_installed) == "table" then - vim.list_extend(opts.ensure_installed, { "c", "cpp" }) - end - end, + opts = { ensure_installed = { "c", "cpp" } }, }, { @@ -48,7 +44,7 @@ return { -- Ensure mason installs the server clangd = { keys = { - { "cR", "ClangdSwitchSourceHeader", desc = "Switch Source/Header (C/C++)" }, + { "ch", "ClangdSwitchSourceHeader", desc = "Switch Source/Header (C/C++)" }, }, root_dir = function(fname) return require("lspconfig.util").root_pattern( "compile_commands.json", "compile_flags.txt")(fname) @@ -84,32 +80,24 @@ return { }, setup = { clangd = function(_, opts) - local clangd_ext_opts = require("lazyvim.util").opts("clangd_extensions.nvim") + local clangd_ext_opts = rmz.lazy.opts("clangd_extensions.nvim") require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts })) return false end, }, }, }, - - -- { - -- "blink.cmp", + -- { "blink.cmp", -- opts = function(_, opts) -- -- TODO: make sure this works -- table.insert(opts.fuzzy.sorts, 1, require("clangd_extensions.cmp_scores")) -- end, -- }, - - { - "mfussenegger/nvim-dap", + { "mfussenegger/nvim-dap", dependencies = { -- Ensure C/C++ debugger is installed "williamboman/mason.nvim", - opts = function(_, opts) - if type(opts.ensure_installed) == "table" then - vim.list_extend(opts.ensure_installed, { "codelldb" }) - end - end, + opts = { ensure_installed = { "codelldb" } }, }, opts = function() local dap = require("dap") @@ -142,7 +130,7 @@ return { type = "codelldb", request = "attach", name = "Attach to process", - processId = require("dap.utils").pick_process, + pid = require("dap.utils").pick_process, cwd = "${workspaceFolder}", }, } diff --git a/nvim/lua/plugins/lang/docker.lua b/nvim/lua/plugins/lang/docker.lua new file mode 100644 index 0000000..e375fa4 --- /dev/null +++ b/nvim/lua/plugins/lang/docker.lua @@ -0,0 +1,38 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "dockerfile" } }, + }, + { + "mason.nvim", + opts = { ensure_installed = { "hadolint" } }, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.diagnostics.hadolint, + }) + end, + }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + dockerfile = { "hadolint" }, + }, + }, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + dockerls = {}, + docker_compose_language_service = {}, + }, + }, + }, +} diff --git a/nvim/lua/plugins/lang/git.lua b/nvim/lua/plugins/lang/git.lua new file mode 100644 index 0000000..a45d4da --- /dev/null +++ b/nvim/lua/plugins/lang/git.lua @@ -0,0 +1,19 @@ +return { + -- Treesitter git support + { "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "git_config", "gitcommit", "git_rebase", "gitignore", "gitattributes" } }, + }, + + { + "hrsh7th/nvim-cmp", + optional = true, + dependencies = { + { "petertriho/cmp-git", opts = {} }, + }, + ---@module 'cmp' + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + table.insert(opts.sources, { name = "git" }) + end, + }, +} diff --git a/nvim/lua/plugins/lang/go.lua b/nvim/lua/plugins/lang/go.lua new file mode 100644 index 0000000..d63a201 --- /dev/null +++ b/nvim/lua/plugins/lang/go.lua @@ -0,0 +1,147 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "go", "gomod", "gowork", "gosum" } }, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + gopls = { + settings = { + gopls = { + gofumpt = true, + codelenses = { + gc_details = false, + generate = true, + regenerate_cgo = true, + run_govulncheck = true, + test = true, + tidy = true, + upgrade_dependency = true, + vendor = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + analyses = { + fieldalignment = true, + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true, + }, + usePlaceholders = true, + completeUnimported = true, + staticcheck = true, + directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" }, + semanticTokens = true, + }, + }, + }, + }, + setup = { + gopls = function(_, opts) + -- workaround for gopls not supporting semanticTokensProvider + -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 + rmz.lsp.on_attach(function(client, _) + if not client.server_capabilities.semanticTokensProvider then + local semantic = client.config.capabilities.textDocument.semanticTokens + client.server_capabilities.semanticTokensProvider = { + full = true, + legend = { + tokenTypes = semantic.tokenTypes, + tokenModifiers = semantic.tokenModifiers, + }, + range = true, + } + end + end, "gopls") + -- end workaround + end, + }, + }, + }, + -- Ensure Go tools are installed + { + "williamboman/mason.nvim", + opts = { ensure_installed = { "goimports", "gofumpt" } }, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + dependencies = { + { + "williamboman/mason.nvim", + opts = { ensure_installed = { "gomodifytags", "impl" } }, + }, + }, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.code_actions.gomodifytags, + nls.builtins.code_actions.impl, + nls.builtins.formatting.goimports, + nls.builtins.formatting.gofumpt, + }) + end, + }, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + go = { "goimports", "gofumpt" }, + }, + }, + }, + { + "mfussenegger/nvim-dap", + optional = true, + dependencies = { + { + "williamboman/mason.nvim", + opts = { ensure_installed = { "delve" } }, + }, + { + "leoluz/nvim-dap-go", + opts = {}, + }, + }, + }, + { + "nvim-neotest/neotest", + optional = true, + dependencies = { + "fredrikaverpil/neotest-golang", + }, + opts = { + adapters = { + ["neotest-golang"] = { + -- Here we can set options for neotest-golang, e.g. + -- go_test_args = { "-v", "-race", "-count=1", "-timeout=60s" }, + dap_go_enabled = true, -- requires leoluz/nvim-dap-go + }, + }, + }, + }, + + -- Filetype icons + { + "echasnovski/mini.icons", + opts = { + file = { + [".go-version"] = { glyph = "", hl = "MiniIconsBlue" }, + }, + filetype = { + gotmpl = { glyph = "󰟓", hl = "MiniIconsGrey" }, + }, + }, + }, +} diff --git a/nvim/lua/plugins/lang/haskell.lua b/nvim/lua/plugins/lang/haskell.lua new file mode 100644 index 0000000..b1c67ff --- /dev/null +++ b/nvim/lua/plugins/lang/haskell.lua @@ -0,0 +1,89 @@ +return { + + -- Add Haskell to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "haskell" } }, + }, + + { + "mrcjkb/haskell-tools.nvim", + version = "^3", + ft = { "haskell", "lhaskell", "cabal", "cabalproject" }, + dependencies = { + { "nvim-telescope/telescope.nvim", optional = true }, + }, + config = function() + local ok, telescope = pcall(require, "telescope") + if ok then + telescope.load_extension("ht") + end + end, + }, + + { + "williamboman/mason.nvim", + opts = { ensure_installed = { "haskell-language-server" } }, + }, + + { + "mfussenegger/nvim-dap", + optional = true, + dependencies = { + { + "williamboman/mason.nvim", + opts = { ensure_installed = { "haskell-debug-adapter" } }, + }, + }, + }, + + { + "nvim-neotest/neotest", + optional = true, + dependencies = { + { "mrcjkb/neotest-haskell" }, + }, + opts = { + adapters = { + ["neotest-haskell"] = {}, + }, + }, + }, + + { + "mrcjkb/haskell-snippets.nvim", + dependencies = { "l3mon4d3/luasnip" }, + ft = { "haskell", "lhaskell", "cabal", "cabalproject" }, + config = function() + local haskell_snippets = require("haskell-snippets").all + require("luasnip").add_snippets("haskell", haskell_snippets, { key = "haskell" }) + end, + }, + + { + "luc-tielen/telescope_hoogle", + ft = { "haskell", "lhaskell", "cabal", "cabalproject" }, + dependencies = { + { "nvim-telescope/telescope.nvim" }, + }, + config = function() + local ok, telescope = pcall(require, "telescope") + if ok then + telescope.load_extension("hoogle") + end + end, + }, + + -- Make sure lspconfig doesn't start hls, + -- as it conflicts with haskell-tools + { + "neovim/nvim-lspconfig", + opts = { + setup = { + hls = function() + return true + end, + }, + }, + }, +} diff --git a/nvim/lua/plugins/lang/json.lua b/nvim/lua/plugins/lang/json.lua new file mode 100644 index 0000000..88acd8c --- /dev/null +++ b/nvim/lua/plugins/lang/json.lua @@ -0,0 +1,39 @@ +return { + -- add json to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "json5" } }, + }, + + -- yaml schema support + { + "b0o/SchemaStore.nvim", + lazy = true, + version = false, -- last release is way too old + }, + + -- correctly setup lspconfig + { + "neovim/nvim-lspconfig", + opts = { + -- make sure mason installs the server + servers = { + jsonls = { + -- lazy-load schemastore when needed + on_new_config = function(new_config) + new_config.settings.json.schemas = new_config.settings.json.schemas or {} + vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas()) + end, + settings = { + json = { + format = { + enable = true, + }, + validate = { enable = true }, + }, + }, + }, + }, + }, + }, +} diff --git a/nvim/lua/plugins/lang/markdown.lua b/nvim/lua/plugins/lang/markdown.lua new file mode 100644 index 0000000..a4862e3 --- /dev/null +++ b/nvim/lua/plugins/lang/markdown.lua @@ -0,0 +1,119 @@ +return { + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters = { + ["markdown-toc"] = { + condition = function(_, ctx) + for _, line in ipairs(vim.api.nvim_buf_get_lines(ctx.buf, 0, -1, false)) do + if line:find("") then + return true + end + end + end, + }, + ["markdownlint-cli2"] = { + condition = function(_, ctx) + local diag = vim.tbl_filter(function(d) + return d.source == "markdownlint" + end, vim.diagnostic.get(ctx.buf)) + return #diag > 0 + end, + }, + }, + formatters_by_ft = { + ["markdown"] = { "prettier", "markdownlint-cli2", "markdown-toc" }, + ["markdown.mdx"] = { "prettier", "markdownlint-cli2", "markdown-toc" }, + }, + }, + }, + { + "williamboman/mason.nvim", + opts = { ensure_installed = { "markdownlint-cli2", "markdown-toc" } }, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.diagnostics.markdownlint_cli2, + }) + end, + }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + markdown = { "markdownlint-cli2" }, + }, + }, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + marksman = {}, + }, + }, + }, + + -- Markdown preview + { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = function() + require("lazy").load({ plugins = { "markdown-preview.nvim" } }) + vim.fn["mkdp#util#install"]() + end, + keys = { + { + "cp", + ft = "markdown", + "MarkdownPreviewToggle", + desc = "Markdown Preview", + }, + }, + config = function() + vim.cmd([[do FileType]]) + end, + }, + + { + "MeanderingProgrammer/render-markdown.nvim", + opts = { + code = { + sign = false, + width = "block", + right_pad = 1, + }, + heading = { + sign = false, + icons = {}, + }, + checkbox = { + enabled = false, + }, + }, + ft = { "markdown", "norg", "rmd", "org", "codecompanion" }, + config = function(_, opts) + require("render-markdown").setup(opts) + Snacks.toggle({ + name = "Render Markdown", + get = function() + return require("render-markdown.state").enabled + end, + set = function(enabled) + local m = require("render-markdown") + if enabled then + m.enable() + else + m.disable() + end + end, + }):map("um") + end, + }, +} diff --git a/nvim/lua/plugins/lang/nix.lua b/nvim/lua/plugins/lang/nix.lua new file mode 100644 index 0000000..e524602 --- /dev/null +++ b/nvim/lua/plugins/lang/nix.lua @@ -0,0 +1,19 @@ +return { + { "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "nix" } }, + }, + { "neovim/nvim-lspconfig", + opts = { + servers = { + -- nil_ls = {}, -- FIXME: this causes big CPU usage when tried to be installed and eventually just fails + }, + }, + }, + { "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + nix = { "nixfmt" }, + }, + }, + }, +} diff --git a/nvim/lua/plugins/lang/python.lua b/nvim/lua/plugins/lang/python.lua index 899bfb3..09ee671 100644 --- a/nvim/lua/plugins/lang/python.lua +++ b/nvim/lua/plugins/lang/python.lua @@ -1,65 +1,46 @@ return { - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - if type(opts.ensure_installed) == "table" then - vim.list_extend(opts.ensure_installed, { "ninja", "python", "rst", "toml" }) - end - end, + { "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "ninja", "rst" } }, }, - { - "neovim/nvim-lspconfig", + { "neovim/nvim-lspconfig", opts = { - ---@type lspconfig.options servers = { - pyright = {}, ruff = { - root_dir = function(fname) - return require("lspconfig.util").root_pattern("pyproject.toml", "setup.cfg", "ruff.toml")(fname) - end, + cmd_env = { RUFF_TRACE = "messages" }, + init_options = { + settings = { + logLevel = "error", + }, + }, keys = { { "co", - function() - vim.lsp.buf.code_action({ - apply = true, - context = { - only = { "source.organizeImports" }, - diagnostics = {}, - }, - }) - end, + rmz.lsp.action["source.organizeImports"], desc = "Organize Imports", }, }, }, - pylsp = { - settings = { - pylsp = { - plugins = { - autopep8 = { enabled = false }, - flake8 = { enabled = false }, - mccabe = { enabled = false }, - pycodestyle = { enabled = false }, - pydocstyle = { enabled = false }, - pyflakes = { enabled = false }, -- covered by flake8 - } - } - } - } }, setup = { - ruff_lsp = function() - require("lazyvim.util").lsp.on_attach(function(client, _) - if client.name == "ruff_lsp" then - -- Disable hover in favor of Pyright - client.server_capabilities.hoverProvider = false - end - end) + ["ruff"] = function() + rmz.lsp.on_attach(function(client, _) + -- Disable hover in favor of Pyright + client.server_capabilities.hoverProvider = false + end, "ruff") end, }, }, }, + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + local servers = { "pyright", "ruff"} + for _, server in ipairs(servers) do + opts.servers[server] = opts.servers[server] or {} + opts.servers[server].enabled = server == lsp or server == ruff + end + end, + }, { "nvim-neotest/neotest", dependencies = { @@ -76,7 +57,6 @@ return { "mfussenegger/nvim-dap", dependencies = { "mfussenegger/nvim-dap-python", - -- stylua: ignore keys = { { "dPt", function() require('dap-python').test_method() end, desc = "Debug Method", ft = "python" }, { "dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" }, @@ -87,22 +67,34 @@ return { end, }, }, - { - "linux-cultist/venv-selector.nvim", + { "jay-babu/mason-nvim-dap.nvim", + opts = { + handlers = { + python = function() end, + }, + ensure_installed = { "python" }, + }, + }, + { "linux-cultist/venv-selector.nvim", enabled = false, + -- TODO needs fd to be installed (I don't know what that is) + branch = "regexp", -- Use this branch for the new version cmd = "VenvSelect", - opts = function(_, opts) - if require("lazyvim.util").has("nvim-dap-python") then - opts.dap_enabled = true - end - return vim.tbl_deep_extend("force", opts, { - name = { - "venv", - ".venv", - "env", - ".env", + opts = { + settings = { + options = { + notify_user_on_venv_activation = true, }, - }) + }, + }, + -- Call config for python files and load the cached venv automatically + ft = "python", + keys = { { "cv", ":VenvSelect", desc = "Select VirtualEnv", ft = "python" } }, + }, + { "hrsh7th/nvim-cmp", + optional = true, + opts = function(_, opts) + opts.auto_brackets = opts.auto_brackets or {} + table.insert(opts.auto_brackets, "python") end, - keys = { { "cv", ":VenvSelect", desc = "Select VirtualEnv" } }, }, } diff --git a/nvim/lua/plugins/lang/ruby.lua b/nvim/lua/plugins/lang/ruby.lua new file mode 100644 index 0000000..d434dcf --- /dev/null +++ b/nvim/lua/plugins/lang/ruby.lua @@ -0,0 +1,54 @@ +return { + { "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "ruby" } }, + }, + { "neovim/nvim-lspconfig", + ---@class PluginLspOpts + opts = { + ---@type lspconfig.options + servers = { + ruby_lsp = { enabled = true, }, + rubocop = { enabled = true, }, + }, + }, + }, + { "williamboman/mason.nvim", + opts = { ensure_installed = { "erb-formatter", "erb-lint" } }, + }, + { + "mfussenegger/nvim-dap", + dependencies = { + "suketa/nvim-dap-ruby", + config = function() + require("dap-ruby").setup() + end, + }, + }, + { "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + ruby = { "rubocop" }, + eruby = { "erb_format" }, + }, + }, + }, + { "nvim-neotest/neotest", + dependencies = { + "olimorris/neotest-rspec", + }, + opts = { + adapters = { + ["neotest-rspec"] = { + -- NOTE: By default neotest-rspec uses the system wide rspec gem instead of the one through bundler + -- rspec_cmd = function() + -- return vim.tbl_flatten({ + -- "bundle", + -- "exec", + -- "rspec", + -- }) + -- end, + }, + }, + }, + }, +} diff --git a/nvim/lua/plugins/lang/rust.lua b/nvim/lua/plugins/lang/rust.lua new file mode 100644 index 0000000..97f9718 --- /dev/null +++ b/nvim/lua/plugins/lang/rust.lua @@ -0,0 +1,117 @@ +return { + { "Saecki/crates.nvim", + event = { "BufRead Cargo.toml" }, + opts = { + completion = { + crates = { + enabled = true, + }, + }, + lsp = { + enabled = true, + actions = true, + completion = true, + hover = true, + }, + }, + }, + { "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "rust", "ron" } }, + }, + { "williamboman/mason.nvim", + optional = true, + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "codelldb" }) + end, + }, + { "mrcjkb/rustaceanvim", + version = vim.fn.has("nvim-0.10.0") == 0 and "^4" or false, + ft = { "rust" }, + opts = { + server = { + on_attach = function(_, bufnr) + vim.keymap.set("n", "cR", function() + vim.cmd.RustLsp("codeAction") + end, { desc = "Code Action", buffer = bufnr }) + vim.keymap.set("n", "dr", function() + vim.cmd.RustLsp("debuggables") + end, { desc = "Rust Debuggables", buffer = bufnr }) + end, + default_settings = { + -- rust-analyzer language server configuration + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + buildScripts = { + enable = true, + }, + }, + -- Add clippy lints for Rust if using rust-analyzer + checkOnSave = true, + -- Enable diagnostics if using rust-analyzer + diagnostics = { + enable = true, + }, + procMacro = { + enable = true, + ignored = { + ["async-trait"] = { "async_trait" }, + ["napi-derive"] = { "napi" }, + ["async-recursion"] = { "async_recursion" }, + }, + }, + files = { + excludeDirs = { + ".direnv", + ".git", + ".github", + ".gitlab", + "bin", + "node_modules", + "target", + "venv", + ".venv", + }, + }, + }, + }, + }, + }, + config = function(_, opts) + local package_path = require("mason-registry").get_package("codelldb"):get_install_path() + local codelldb = package_path .. "/extension/adapter/codelldb" + local library_path = package_path .. "/extension/lldb/lib/liblldb.dylib" + local uname = io.popen("uname"):read("*l") + if uname == "Linux" then + library_path = package_path .. "/extension/lldb/lib/liblldb.so" + end + opts.dap = { + adapter = require("rustaceanvim.config").get_codelldb_adapter(codelldb, library_path), + } + vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {}) + if vim.fn.executable("rust-analyzer") == 0 then + rmz.lazy.error( + "**rust-analyzer** not found in PATH, please install it.\nhttps://rust-analyzer.github.io/", + { title = "rustaceanvim" } + ) + end + end, + }, + { "neovim/nvim-lspconfig", + opts = { + servers = { + rust_analyzer = { enabled = false }, -- rustaceanvim is used instead + }, + }, + }, + { "nvim-neotest/neotest", + optional = true, + opts = { + adapters = { + ["rustaceanvim.neotest"] = {}, + }, + }, + }, +} diff --git a/nvim/lua/plugins/lang/tex.lua b/nvim/lua/plugins/lang/tex.lua new file mode 100644 index 0000000..0d0fdb4 --- /dev/null +++ b/nvim/lua/plugins/lang/tex.lua @@ -0,0 +1,44 @@ +return { + -- Add BibTeX/LaTeX to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.highlight = opts.highlight or {} + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "bibtex" }) + end + if type(opts.highlight.disable) == "table" then + vim.list_extend(opts.highlight.disable, { "latex" }) + else + opts.highlight.disable = { "latex" } + end + end, + }, + + { + "lervag/vimtex", + lazy = false, -- lazy-loading will disable inverse search + config = function() + vim.g.vimtex_mappings_disable = { ["n"] = { "K" } } -- disable `K` as it conflicts with LSP hover + vim.g.vimtex_quickfix_method = vim.fn.executable("pplatex") == 1 and "pplatex" or "latexlog" + end, + keys = { + { "l", "", desc = "+vimtex", ft = "tex" }, + }, + }, + + -- Correctly setup lspconfig for LaTeX 🚀 + { + "neovim/nvim-lspconfig", + optional = true, + opts = { + servers = { + texlab = { + keys = { + { "K", "(vimtex-doc-package)", desc = "Vimtex Docs", silent = true }, + }, + }, + }, + }, + }, +} diff --git a/nvim/lua/plugins/lang/toml.lua b/nvim/lua/plugins/lang/toml.lua new file mode 100644 index 0000000..9020962 --- /dev/null +++ b/nvim/lua/plugins/lang/toml.lua @@ -0,0 +1,8 @@ +return { + "neovim/nvim-lspconfig", + opts = { + servers = { + taplo = {}, + }, + }, +} diff --git a/nvim/lua/plugins/lang/yaml.lua b/nvim/lua/plugins/lang/yaml.lua new file mode 100644 index 0000000..977590f --- /dev/null +++ b/nvim/lua/plugins/lang/yaml.lua @@ -0,0 +1,64 @@ +return { + -- yaml schema support + { + "b0o/SchemaStore.nvim", + lazy = true, + version = false, -- last release is way too old + }, + + -- correctly setup lspconfig + { + "neovim/nvim-lspconfig", + opts = { + -- make sure mason installs the server + servers = { + yamlls = { + -- Have to add this for yamlls to understand that we support line folding + capabilities = { + textDocument = { + foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, + }, + }, + }, + -- lazy-load schemastore when needed + on_new_config = function(new_config) + new_config.settings.yaml.schemas = vim.tbl_deep_extend( + "force", + new_config.settings.yaml.schemas or {}, + require("schemastore").yaml.schemas() + ) + end, + settings = { + redhat = { telemetry = { enabled = false } }, + yaml = { + keyOrdering = false, + format = { + enable = true, + }, + validate = true, + schemaStore = { + -- Must disable built-in schemaStore support to use + -- schemas from SchemaStore.nvim plugin + enable = false, + -- Avoid TypeError: Cannot read properties of undefined (reading 'length') + url = "", + }, + }, + }, + }, + }, + setup = { + yamlls = function() + -- Neovim < 0.10 does not have dynamic registration for formatting + if vim.fn.has("nvim-0.10") == 0 then + rmz.lsp.on_attach(function(client, _) + client.server_capabilities.documentFormattingProvider = true + end, "yamlls") + end + end, + }, + }, + }, +} -- 2.48.1