diff options
author | Daniil Rozanov <daniilrozzanov@gmail.com> | 2024-04-26 02:09:30 +0300 |
---|---|---|
committer | Daniil Rozanov <daniilrozzanov@gmail.com> | 2024-04-26 02:09:30 +0300 |
commit | 93945a96daad5db8f91b07d1aef65b3ec6f758fb (patch) | |
tree | 92b061bfffcf58515bb4c04ed448364262d67341 /lua/cmake/init.lua | |
parent | 8d05fcaaeb1442c709f148ff934d92900743f051 (diff) |
feat: autocommands to regenerate and reset project
One autocommand generates project after saving CMakeLists.txt, and other sets up all project after saving variants
Diffstat (limited to 'lua/cmake/init.lua')
-rw-r--r-- | lua/cmake/init.lua | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lua/cmake/init.lua b/lua/cmake/init.lua index d53e074..dcead08 100644 --- a/lua/cmake/init.lua +++ b/lua/cmake/init.lua @@ -1,5 +1,10 @@ local config = require("cmake.config") local commands = require("cmake.commands") +local autocmds = require("cmake.autocmds") +local utils = require("cmake.utils") +local constants = require("cmake.constants") + +local uv = vim.uv or vim.loop local M = {} @@ -7,12 +12,23 @@ function M.setup(opts) opts = opts or {} config.setup(opts) if vim.fn.executable(config.cmake.cmake_path) then - commands.register_commands() - require("cmake.capabilities").setup(function() - require("cmake.project").setup(opts) + utils.file_exists(vim.fs.joinpath(uv.cwd(), constants.cmakelists), function(cmake_lists_exists) + if cmake_lists_exists then + require("cmake.capabilities").setup(function() + vim.schedule(function() + autocmds.setuo() + commands.register_commands() + end) + require("cmake.project").setup() + end) + else + end end) else - vim.notify("CMake: " .. config.cmake.cmake_path .. " is not executable", vim.log.levels.WARN) + vim.notify( + "CMake: " .. config.cmake.cmake_path .. " is not executable. Plugin is unavailable", + vim.log.levels.WARN + ) end end |