]> git.rmz.io Git - dotfiles.git/blobdiff - nvim/lua/plugins/lang/cmake.lua
lazyvim: absorb all langs
[dotfiles.git] / nvim / lua / plugins / lang / cmake.lua
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 = {},
+  },
+}