diff options
author | Daniil Rozanov <daniilrozzanov@gmail.com> | 2024-04-26 03:33:49 +0300 |
---|---|---|
committer | Daniil Rozanov <daniilrozzanov@gmail.com> | 2024-04-26 03:33:49 +0300 |
commit | 0660a9446d4515c9755573152ce944ebf2f019fc (patch) | |
tree | b587c6de58d6475feadade022fa918d15a3eba74 /lua/cmake/actions.lua | |
parent | a21a7207041754efdc811493ea131b6dd2d0f944 (diff) |
fix: better autocmds
Correctly process case when neovim opened witn nvim CMakeLists.txt command. At the moment of first setup CMakeLists.txt does not exists, so we need to setup project on BufEnter if it was not inisialized before
Diffstat (limited to 'lua/cmake/actions.lua')
-rw-r--r-- | lua/cmake/actions.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lua/cmake/actions.lua b/lua/cmake/actions.lua index 4008f7c..8c5a300 100644 --- a/lua/cmake/actions.lua +++ b/lua/cmake/actions.lua @@ -27,8 +27,17 @@ local default_build_exe_opts = { }, } +M.reset_project = function(opts) + require("cmake.project").setup(opts) +end + M.generate = function(opts) - pr.create_fileapi_query({ idx = pr.current_generate_option_idx() }, function() + local idx = pr.current_generate_option_idx() + if not idx then + vim.notify("CMake: no project to generate") + return + end + pr.create_fileapi_query({ idx = idx }, function() vim.schedule(function() t.cmake_execute(pr.current_generate_option().generate_command, default_generate_exe_opts) end) |