[Idea] Allow defining the filetype of the scratch buffer
Closed this issue · 5 comments
At vim-pandoc/vim-pantondoc, user @michelk has suggested this:
For example: While being in a block like
``` bash cd blub ```
I would like to press, say s, which drops me into a buffer with filetype >bash. Saving and closing the buffer should insert the contents into my markdown >document.
Instead of implementing this ourselves at vim-pantondoc, I think we should provide integration with your plugin. However, we would need to be able to define the filetype for the narrowed scratch buffer, which I don't believe you currently support (you currently copy that from the source buffer, if I understand it correctly).
I think I can implement this by myself and send you the patches through a pull request, but some hints or comments would be appreciated. Do you believe this should modify this plugin's current commands and functions, or should it exists as a different command?
I'll create a prototype implementation of the feature request at vim-pantondoc so I have a better idea of what's needed. I'll keep you updated.
Hi Felipe!
On Fr, 13 Jun 2014, Felipe Morales wrote:
At vim-pandoc/vim-pantondoc, user @michelk has suggested this:
For example: While being in a block like
``` bash cd blub ```
I would like to press, say s, which drops me into a buffer with filetype >bash. Saving and closing the buffer should insert the contents into my markdown >document.
Instead of implementing this ourselves at vim-pantondoc, I think we should provide integration with your plugin. However, we would need to be able to define the filetype for the narrowed scratch buffer, which I don't believe you currently support (you currently copy that from the source buffer, if I understand it correctly).
I think I can implement this by myself and send you the patches through a pull request, but some or comments hints would be appreciated. Do you believe this should modify this plugin's current commands and functions, or should it exists as a different command?
I'll create a prototype implementation of the feature request at vim-pantondoc so I have a better idea of what's needed. I'll keep you updated.
Thanks for your nice feedback. Using hooks, it should be certainly
possible what you want. Have a look at :h NR-hooks (basically you simply
set the variable b:nrrw_aucmd_create='set ft=bash' and create the
narrowed window and that window will have the bash filetype set).
If that doesn't work for, we can still go by your patch (for whatever
you had in mind how that should work). But let's discuss this later, if
hooks are not suitable.
Best,
Christian
Letzte Worte von Tarzan:
"Welcher Idiot hat die Liane eingeseift?"
Oh, this is excellent! I didn't notice the hooks functionality, but I think that should be enough for our use case. Thanks!
Hi again. I've built a prototype for the nrrwrgn integration code for vim-pandoc, but I've found an issue. The filetype
setting I pass using the create hook is being overriden by the call to SetOptions
in line 873 of autoload/nrrwrgn.vim
. Shouldn't lines 865-867 go after that call?
The prototype is available here, if you want to check it out (please note the BodyRange function is bugged, and it won't work in some cases).
Oh that is probably right. I just fixed it
Excellent, thanks. I've already implemented the NrrwRgn integration functionality for vim-pandoc, and with this I believe it is complete (I now think using the hooks variables might be a bit overkill, but it might be more useful later). I'm closing this issue, since it feels resolved. ;)