From 0660a9446d4515c9755573152ce944ebf2f019fc Mon Sep 17 00:00:00 2001 From: Daniil Rozanov <daniilrozzanov@gmail.com> Date: Fri, 26 Apr 2024 03:33:49 +0300 Subject: 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 --- lua/cmake/actions.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lua/cmake/actions.lua') 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) -- cgit v1.2.3