1
0
Fork 0
mirror of https://github.com/jiriks74/presence.nvim synced 2024-12-27 18:42:35 +01:00

Re-add BufEnter autocmd and handle tmux bug

Fixes #19
This commit is contained in:
Andrew Kwon 2021-06-07 20:03:19 -07:00
parent 81c3cc0100
commit f4c1e227be
2 changed files with 20 additions and 0 deletions

View file

@ -8,6 +8,7 @@ function presence#SetAutoCmds()
autocmd VimLeavePre * lua package.loaded.presence:handle_vim_leave_pre() autocmd VimLeavePre * lua package.loaded.presence:handle_vim_leave_pre()
autocmd WinEnter * lua package.loaded.presence:handle_win_enter() autocmd WinEnter * lua package.loaded.presence:handle_win_enter()
autocmd WinLeave * lua package.loaded.presence:handle_win_leave() 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() autocmd BufAdd * lua package.loaded.presence:handle_buf_add()
endif endif
augroup END augroup END

View file

@ -863,6 +863,13 @@ end
function Presence:handle_focus_gained() function Presence:handle_focus_gained()
self.log:debug("Handling FocusGained event...") 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 if vim.bo.filetype == "qf" then
self.log:debug("Skipping presence update for quickfix window...") self.log:debug("Skipping presence update for quickfix window...")
return return
@ -921,6 +928,18 @@ function Presence:handle_win_leave()
end) end)
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 -- WinLeave events cancel the current buffer presence
function Presence:handle_buf_add() function Presence:handle_buf_add()
self.log:debug("Handling BufAdd event...") self.log:debug("Handling BufAdd event...")