Skip to content

Commit

Permalink
fix(tpipeline): dismiss CursorHold event if neovim is no longer foc…
Browse files Browse the repository at this point in the history
…used
  • Loading branch information
WilliamHsieh committed Nov 13, 2024
1 parent fde2a9f commit 8d08332
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions config/nvim/lua/plugins/tpipeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ end

function M.config()
local augroup = vim.api.nvim_create_augroup("dotfiles_tpipeline_integration", { clear = true })
local focused = true

-- cache status-bg
local neovim_status_style = nil
Expand Down Expand Up @@ -70,11 +71,20 @@ function M.config()

-- matched tmux status style and statusline
vim.api.nvim_create_autocmd({ "ColorScheme", "FocusGained" }, {
callback = function()
callback = function(e)
if e.event == "FocusGained" then
focused = true
end

vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
once = true,
group = vim.api.nvim_create_augroup("dotfiles_force_update_tpipeline", { clear = true }),
callback = function()
-- check if neovim is still focused
if not focused then
return
end

-- color
if tmux_status_style ~= neovim_status_style then
set_tmux_status_style(neovim_status_style)
Expand All @@ -93,7 +103,10 @@ function M.config()

-- reset tmux status style
vim.api.nvim_create_autocmd("FocusLost", {
callback = function()
callback = function(e)
if e.event == "FocusLost" then
focused = false
end
if tmux_status_style ~= neovim_status_style then
unset_tmux_option("status-style")
end
Expand Down

0 comments on commit 8d08332

Please sign in to comment.