diff options
-rw-r--r-- | lua/cmake/config.lua | 3 | ||||
-rw-r--r-- | lua/cmake/terminal.lua | 16 |
2 files changed, 16 insertions, 3 deletions
diff --git a/lua/cmake/config.lua b/lua/cmake/config.lua index 55ba38b..6ac5856 100644 --- a/lua/cmake/config.lua +++ b/lua/cmake/config.lua @@ -16,7 +16,8 @@ ---@field parallel_jobs? number By specifying a number, you can define how many jobs are run in parallel during the build ---@field build_directory string Build directory template ---@field environment {[string]:string} Environment for all `cmake` commands ----@field build_environment {[string]:string} Environment for all `cmake --build` commands +---@field configure_environment {[string]:string} Environment for all `cmake -B ...` commands +---@field build_environment {[string]:string} Environment for all `cmake --build ...` commands ---@class CMakeVariant ---@field default string Default choice diff --git a/lua/cmake/terminal.lua b/lua/cmake/terminal.lua index d1d8a75..689590f 100644 --- a/lua/cmake/terminal.lua +++ b/lua/cmake/terminal.lua @@ -12,6 +12,13 @@ local cmake = { local runnable +local scroll_to_bottom = function() + local info = vim.api.nvim_get_mode() + if info and (info.mode == "n" or info.mode == "nt") then + vim.cmd("normal! G") + end +end + local prepare_cmake_buf = function() if cmake.bufnr and api.nvim_buf_is_valid(cmake.bufnr) then api.nvim_buf_delete(cmake.bufnr, { force = true }) @@ -28,12 +35,17 @@ local termopen = function(command, opts) -- detach = 1, cwd = command.cwd, env = command.env, - clear_env = config.clear_env, + clear_env = config.cmake_terminal.clear_env, + on_stdout = function(_, data, _) + api.nvim_buf_call(cmake.bufnr, scroll_to_bottom) + end, on_exit = function(pid, code, event) if code == 0 then command.after_success() if config.cmake_terminal.close_on_exit == "success" or config.cmake_terminal.close_on_exit == true then - api.nvim_win_close(cmake.window, true) + if api.nvim_win_is_valid(cmake.window) then + api.nvim_win_close(cmake.window, true) + end end if config.notification.after == "success" or config.notification.after == true then vim.notify( |