Closed nyngwang closed 1 year ago
I'm curious, what are you trying to achieve with these autocommands?
[...], what are you trying to achieve with these autocommands?
Basically active_in_terminals = false
+ auto_enable = true
with a note that the minimap should only be enabled when it on a floating window, but the latter is buggy (it produce a similar error about invalid something, so I decided to do it myself)
TL;DR: I think the two events Term{Enter, Open}
should be added when you're closing the minimap given auto_enable = true
.
I just resolved it after some trying:
vim.api.nvim_create_autocmd({
'TermEnter', 'TermOpen', -- for me these two events seem to be the key!
'BufLeave'
}, {
group = curfile_augroup,
callback = function ()
require('codewindow').close_minimap()
end
})
vim.api.nvim_create_autocmd({ 'BufEnter' }, {
group = curfile_augroup,
callback = vim.schedule_wrap(function ()
if vim.api.nvim_win_get_config(0).relative == 'editor' then
require('codewindow').open_minimap()
end
end)
})
Try putting in the terminal's filetype into the "exclude_filetypes" table. If you are using floaterm, this would be floaterm, but ymmv. auto_enable iirc works off of that table
It doesn't work, and I think that is unrelated to my problem because the error was triggered when I closed the floating window in my demo. (I did try exclude_filetypes
with fzf
for fzf-lua, but again it didn't solve it.)
Interesting, anyways, if you could solve the problem, that's great. The project is very much in need of a proper rewrite anyways, I'll see what I can do then.
It might be that some API calls can be protected by checking whether or not it's valid using
nvim_buf_is_valid
.https://github.com/gorbit99/codewindow.nvim/assets/24765272/a9c34d2e-6644-419c-b014-2c6131fa6feb
These are the two
autocmd
s I used in the DEMO: (with the augroup name removed.)