Skip to content

Commit

Permalink
Use buffer-local autocommand
Browse files Browse the repository at this point in the history
  • Loading branch information
xzbdmw committed Jul 26, 2024
1 parent b623cae commit 9f6fb1c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lua/rustaceanvim/commands/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ local function render_ansi_code_diagnostic(rendered_diagnostic)
close_events = { 'CursorMoved', 'BufHidden', 'InsertCharPre' },
})
)
local autocmd_id = vim.api.nvim_create_autocmd('WinEnter', {
vim.api.nvim_create_autocmd('WinEnter', {
callback = function(args)
if args.buf == bufnr then
vim.api.nvim_feedkeys(
Expand All @@ -275,16 +275,12 @@ local function render_ansi_code_diagnostic(rendered_diagnostic)
)
end
end,
buffer = bufnr,
})

local chanid = vim.api.nvim_open_term(bufnr, {})
vim.api.nvim_create_autocmd('WinClosed', {
once = true,
pattern = tostring(winnr),
callback = function()
vim.api.nvim_del_autocmd(autocmd_id)
end,
})
vim.api.nvim_chan_send(chanid, vim.trim('1. Open in split\r\n' .. '---\r\n' .. rendered_diagnostic))

_window_state.float_winnr = winnr
set_close_keymaps(bufnr)
set_split_open_keymap(bufnr, winnr, function()
Expand Down

0 comments on commit 9f6fb1c

Please sign in to comment.