diff --git a/autoload/presence.vim b/autoload/presence.vim index 6203145..7b2adfa 100644 --- a/autoload/presence.vim +++ b/autoload/presence.vim @@ -8,6 +8,7 @@ function presence#SetAutoCmds() autocmd VimLeavePre * lua package.loaded.presence:handle_vim_leave_pre() autocmd WinEnter * lua package.loaded.presence:handle_win_enter() autocmd WinLeave * lua package.loaded.presence:handle_win_leave() + autocmd BufEnter * lua package.loaded.presence:handle_buf_enter() autocmd BufAdd * lua package.loaded.presence:handle_buf_add() endif augroup END diff --git a/lua/presence/init.lua b/lua/presence/init.lua index 9d5ffba..7304e98 100644 --- a/lua/presence/init.lua +++ b/lua/presence/init.lua @@ -863,6 +863,13 @@ end function Presence:handle_focus_gained() self.log:debug("Handling FocusGained event...") + -- Skip a potentially extraneous update call on initial startup if tmux is being used + -- (See https://github.com/neovim/neovim/issues/14572) + if next(self.last_activity) == nil and os.getenv("TMUX") then + self.log:debug("Skipping presence update for FocusGained event triggered by tmux...") + return + end + if vim.bo.filetype == "qf" then self.log:debug("Skipping presence update for quickfix window...") return @@ -921,6 +928,18 @@ function Presence:handle_win_leave() end) end +-- BufEnter events force-update the presence for the current buffer unless it's a quickfix window +function Presence:handle_buf_enter() + self.log:debug("Handling BufEnter event...") + + if vim.bo.filetype == "qf" then + self.log:debug("Skipping presence update for quickfix window...") + return + end + + self:update() +end + -- WinLeave events cancel the current buffer presence function Presence:handle_buf_add() self.log:debug("Handling BufAdd event...")