aboutsummaryrefslogtreecommitdiff
path: root/lua/cmake/autocmds.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/cmake/autocmds.lua')
-rw-r--r--lua/cmake/autocmds.lua72
1 files changed, 36 insertions, 36 deletions
diff --git a/lua/cmake/autocmds.lua b/lua/cmake/autocmds.lua
index 5bbfbe8..a584b52 100644
--- a/lua/cmake/autocmds.lua
+++ b/lua/cmake/autocmds.lua
@@ -7,45 +7,45 @@ local autocmds = {}
local cmake_nvim_augroup = vim.api.nvim_create_augroup("CMake", {})
function autocmds.set_on_variants()
- vim.api.nvim_create_autocmd({ "BufWritePost" }, {
- group = cmake_nvim_augroup,
- pattern = constants.variants_yaml_filename,
- callback = function(args)
- actions.reset_project()
- end,
- desc = "Setup project after saving variants",
- })
+ vim.api.nvim_create_autocmd({ "BufWritePost" }, {
+ group = cmake_nvim_augroup,
+ pattern = constants.variants_yaml_filename,
+ callback = function(args)
+ actions.reset_project()
+ end,
+ desc = "Setup project after saving variants",
+ })
end
function autocmds.setup()
- if config.generate_after_save then
- vim.api.nvim_create_autocmd({ "BufWritePost" }, {
- group = cmake_nvim_augroup,
- pattern = constants.cmakelists,
- callback = function(args)
- actions.generate()
- end,
- desc = "Generate project after saving CMakeLists.txt",
- })
- end
- --NOTE: this autocmd was written only to handle very rare case when inside directory
- --without CMakeLists.txt neovim starts like `nvim CMakeLists.txt`. In this case initial
- --setup will not make the affect and to correctry process the file save, we need to create
- --this autocommand so it reinitializes the project if it has not been done before. IMHO this
- --is not the best way to do this. Also, if newly buffer associated with CMakeLists.txt will not
- --be saved and just closed, but user will continue to use nvim, CMake commands still will be
- --able while it sholdn't. Two options is give up or handle all this corner cases
- --
- -- if config.generate_after_save then
- -- vim.api.nvim_create_autocmd({ "BufEnter" }, {
- -- group = cmake_nvim_augroup,
- -- pattern = constants.cmakelists,
- -- callback = function(args)
- -- actions.reset_project({ first_time_only = true })
- -- end,
- -- desc = "Set up project on open CMakeLists.txt if not set before",
- -- })
- -- end
+ if config.generate_after_save then
+ vim.api.nvim_create_autocmd({ "BufWritePost" }, {
+ group = cmake_nvim_augroup,
+ pattern = constants.cmakelists,
+ callback = function(args)
+ actions.generate()
+ end,
+ desc = "Generate project after saving CMakeLists.txt",
+ })
+ end
+ --NOTE: this autocmd was written only to handle very rare case when inside directory
+ --without CMakeLists.txt neovim starts like `nvim CMakeLists.txt`. In this case initial
+ --setup will not make the affect and to correctry process the file save, we need to create
+ --this autocommand so it reinitializes the project if it has not been done before. IMHO this
+ --is not the best way to do this. Also, if newly buffer associated with CMakeLists.txt will not
+ --be saved and just closed, but user will continue to use nvim, CMake commands still will be
+ --able while it sholdn't. Two options is give up or handle all this corner cases
+ --
+ -- if config.generate_after_save then
+ -- vim.api.nvim_create_autocmd({ "BufEnter" }, {
+ -- group = cmake_nvim_augroup,
+ -- pattern = constants.cmakelists,
+ -- callback = function(args)
+ -- actions.reset_project({ first_time_only = true })
+ -- end,
+ -- desc = "Set up project on open CMakeLists.txt if not set before",
+ -- })
+ -- end
end
return autocmds