]> git.rmz.io Git - dotfiles.git/commitdiff
lazyvim: absorb all langs
authorSamir Benmendil <me@rmz.io>
Sat, 1 Mar 2025 01:17:54 +0000 (01:17 +0000)
committerSamir Benmendil <me@rmz.io>
Sun, 2 Mar 2025 16:17:49 +0000 (16:17 +0000)
They don't cause errors, but have barely been tested.

15 files changed:
nvim/lua/plugins/lang/cmake.lua [new file with mode: 0644]
nvim/lua/plugins/lang/cpp.lua
nvim/lua/plugins/lang/docker.lua [new file with mode: 0644]
nvim/lua/plugins/lang/git.lua [new file with mode: 0644]
nvim/lua/plugins/lang/go.lua [new file with mode: 0644]
nvim/lua/plugins/lang/haskell.lua [new file with mode: 0644]
nvim/lua/plugins/lang/json.lua [new file with mode: 0644]
nvim/lua/plugins/lang/markdown.lua [new file with mode: 0644]
nvim/lua/plugins/lang/nix.lua [new file with mode: 0644]
nvim/lua/plugins/lang/python.lua
nvim/lua/plugins/lang/ruby.lua [new file with mode: 0644]
nvim/lua/plugins/lang/rust.lua [new file with mode: 0644]
nvim/lua/plugins/lang/tex.lua [new file with mode: 0644]
nvim/lua/plugins/lang/toml.lua [new file with mode: 0644]
nvim/lua/plugins/lang/yaml.lua [new file with mode: 0644]

diff --git a/nvim/lua/plugins/lang/cmake.lua b/nvim/lua/plugins/lang/cmake.lua
new file mode 100644 (file)
index 0000000..2e76835
--- /dev/null
@@ -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 = {},
+  },
+}
index 596c2ea4845536aecb27673e45df602c737c3187..d3153dbdeb892f94bcc28f10b40f49278e19f75d 100644 (file)
@@ -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 = {
-            { "<leader>cR", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
+            { "<leader>ch", "<cmd>ClangdSwitchSourceHeader<cr>", 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 (file)
index 0000000..e375fa4
--- /dev/null
@@ -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 (file)
index 0000000..a45d4da
--- /dev/null
@@ -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 (file)
index 0000000..d63a201
--- /dev/null
@@ -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 (file)
index 0000000..b1c67ff
--- /dev/null
@@ -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 (file)
index 0000000..88acd8c
--- /dev/null
@@ -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 (file)
index 0000000..a4862e3
--- /dev/null
@@ -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("<!%-%- toc %-%->") 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 = {
+      {
+        "<leader>cp",
+        ft = "markdown",
+        "<cmd>MarkdownPreviewToggle<cr>",
+        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("<leader>um")
+    end,
+  },
+}
diff --git a/nvim/lua/plugins/lang/nix.lua b/nvim/lua/plugins/lang/nix.lua
new file mode 100644 (file)
index 0000000..e524602
--- /dev/null
@@ -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" },
+      },
+    },
+  },
+}
index 899bfb36cdf3da4d9439017f7d0d179576289a1c..09ee671ab8249e474acb4fe06cf090a642100c2c 100644 (file)
@@ -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 = {
             {
               "<leader>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 = {
         { "<leader>dPt", function() require('dap-python').test_method() end, desc = "Debug Method", ft = "python" },
         { "<leader>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 = { { "<leader>cv", "<cmd>:VenvSelect<cr>", 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 = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv" } },
   },
 }
diff --git a/nvim/lua/plugins/lang/ruby.lua b/nvim/lua/plugins/lang/ruby.lua
new file mode 100644 (file)
index 0000000..d434dcf
--- /dev/null
@@ -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 (file)
index 0000000..97f9718
--- /dev/null
@@ -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", "<leader>cR", function()
+            vim.cmd.RustLsp("codeAction")
+          end, { desc = "Code Action", buffer = bufnr })
+          vim.keymap.set("n", "<leader>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 (file)
index 0000000..0d0fdb4
--- /dev/null
@@ -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 = {
+      { "<localLeader>l", "", desc = "+vimtex", ft = "tex" },
+    },
+  },
+
+  -- Correctly setup lspconfig for LaTeX 🚀
+  {
+    "neovim/nvim-lspconfig",
+    optional = true,
+    opts = {
+      servers = {
+        texlab = {
+          keys = {
+            { "<Leader>K", "<plug>(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 (file)
index 0000000..9020962
--- /dev/null
@@ -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 (file)
index 0000000..977590f
--- /dev/null
@@ -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,
+      },
+    },
+  },
+}