[Feature Request] Open Codi fullscreen in a 50/50 vertical split with an empty buffer #94
I came here to request a feature for this (awesome) plugin.
Out of the box Codi will always open with a fixed width next to the current buffer. In most of my use-cases I am debugging a large-ish file and I only want to focus on a small part of it, perhaps run some sample code to grasp exactly how it works or experiment with some new code or quickly demonstrate some feature etc...
What I wanted was essentially the following:
In this case, there are no "Actual results" I can offer. I have however, written a sample implementation of this functionality in my vimrc. It basically comes down to this:
fun! s:FullscreenScratch() " store filetype and bufnr of current buffer " for later reference let current_buf_ft = &ft let current_buf_num = bufnr('%') " create a new empty tab and set it up tabe | setlocal buftype=nofile noswapfile modifiable buflisted " set filetype to that of original source file " e.g. ruby / python / w/e Codi supports let &filetype = current_buf_ft " since it is fullscreen, I'd like a 50/50 split let g:codi#width = winwidth(winnr()) / 2 " create a buffer local mapping that overrides the " outer one to delete the current scratch buffer instead " when the buffer is destroyed, this mapping will be " destroyed with it and the next <Leader><Leader> " will spawn a new fullscreen scratch window again " we do not have to unmap as this mapping will be " automatically destroyed alongside the buffer. nmap <silent><buffer> <Leader><Leader> :silent! q!<Cr> " everything is setup, filetype is set " let Codi do the rest :) Codi endfun " create a mapping to call the fullscreen scratch wrapper nmap <silent> <Leader><Leader> :call <SID>FullscreenScratch()<Cr>
The above function will always create a new empty tab with a
When LeaderLeader is pressed again, the current buffer will be destroyed and you will be returned where you left off.
I tested this snippet in the following Vim versions, each one working as expected:
OS + version: macOS 10.13.6
Note: One issue I see here is that
That's pretty much it, let me know if it is something worthwhile, I've already got my polyfill which works but wouldn't mind writing a proper PR for this either. I am quite busy this week but I could send a proposal somewhere next week if there is any interest.
If one of you implements it before I can, please by all means go ahead too :)
The text was updated successfully, but these errors were encountered:
Hi @SidOfc, thanks for the feature request and the work you've done thus far on it! I think the notion of a fullscreen scratch is really workflow dependent, so I'm a bit hesitant to include it in the plugin. The code to configure it, as you have shown, is about a dozen lines long, so people can include it in their vimrc (like you have) on a want-to-use basis.
However, I do like the idea of percentage-based splits; maybe we can parse
I also think you bring up a good point that all of Codi's configuration is global. I would be open to adding configuration via local variables, to reduce the pain of one-off invocations with special settings.
Hi @metakirby5, I completely understand that this feature is heavily workflow inspired and therefore may not be the right fit for the plugin. It could be a tip or trick in either a wiki or readme as well, I will look into adding this snippet somewhere other than this issue so that anyone can use this code.
I would also love to see percentage support for
It would even reduce the required snippet code and as you can see, it really only takes one line to do, maybe 2 when combining with user input. I could also write a PR for that instead, shouldn't take too long and I think I could even do it somewhere this week.
I'm not exactly sure of a way to do one-off's for a particular invocation but that too sounds awesome!
P.S. All this basically comes after playing around with it for about half an hour and being completely sold from that moment, thank you so much for providing us all with something like Codi 👍 😻