Closed phha closed 1 year ago
Better to use TermOpen
autocmd for binding terminal keybindings. See https://github.com/numToStr/FTerm.nvim/pull/68#issuecomment-1228532830
I thought about using autocommands and indeed it would work for the specific case here. But being able to access the buffer id programmatically would open up a lot of other possibilities as well. Also notice how the autocommand solution requires a lot of boilerplate code and care to make sure everything is cleaned up again. Is there a specific reason why you are hesitant to add this functionality? I haven’t looked at the code but I figured that FTerm would need to hold a reference to the buffer internally anyway and it’s simply a matter of exposing it.
But being able to access the buffer id programmatically would open up a lot of other possibilities as well.
Huh, Is autocmd not a programmatic access? What other possibilities you are looking for?
Also notice how the autocommand solution requires a lot of boilerplate code and care to make sure everything is cleaned up again.
Boilerplate? Using TermOpen
and TermClose
is literally the right way to do it.
Your example code will only run on startup not every time when terminal opens, which is totally useless. And afterward you need to clean your buffer keybinds when buffer is destroyed or when terminal exits unless you decide not to do it.
Is there a specific reason why you are hesitant to add this functionality? I haven’t looked at the code but I figured that FTerm would need to hold a reference to the buffer internally anyway and it’s simply a matter of exposing it.
I won't add needless features when there is a vim-ish and right way to do it. And yes, you could access the buffer id via uvicorn.buf
but it'll be nil
on startup.
Is it possible to get the buffer number of a custom terminal? I would like to be able to set a custom keymap for a specific terminal. This would also be useful for other buffer-local settings. Something like the (not working) example below: