-
Notifications
You must be signed in to change notification settings - Fork 2
Description
I like this, though there are some things that I think need hardening/fixing and some that will enhance it (most of which I have done, except part of point 5 and all of point 7). I have it ready for a PR, but did not want to send it unannounced with so many changes - here is my updated forked version.
- Before v9.0 patch 1112 <C-_> will not work on Windows - refer patch 9.0.1112: test_mswin_event() can hang. A solution is to default map
<C-=>=for the "FontSizeMinus" function when using a Windows version before that. It is a little clunky, but does the job. - In Windows, the <C-Scroll*> mappings will not work before v8.2 patch 5069, though they do no harm. Refer
patch 8.2.5069: various warnings from clang on MS-Windows. - In Neovim,
has("GUI_running")returns 1 (at least in the version I use just for testing; I don't use Neovim other than for that). So, it's probably best to include a specific test for Neovim, i.e.,has('neovim'), though it's only needed in the vimscript version because the new (see the point following) vim9script version's test will exclude it anyway. (NB: Neovim returns 801 forv:version.) - Since it is only relevant to the Vim GUI, it will only ever be a Vim plugin (so, never Neovim). In that context, and with the majority of Vim users probably using version 9, using vim9script makes sense. So, that's what I've done. The simplest way to have both scripts running in parallel (for the few people who may use different GUI versions, including some older ones) is to have both
change_font_size_vim9script.vimandchange_font_size.vimtest for version 8.2 with/without patch 4807. (Note that vim9script works before v9.0, not just wherehas('vim9script'), so a good cut-off point, I think, is patch 8.2.4807: processing key eveints in Win32 GUI is not ideal, because that patch fixed<C-{whatever}>. (Before that patch,<C-{whatever}>mappings do nothing). - Use
mapargto ensure users' existing mappings are not overwritten and usemap <silent> <Plug>too. The problem for the vimscript version, however, is that<C-{whatever}>does not work in version 8.2 before patch 4807 (in Windows at least, as noted). I did some testing using<F10>to<F12>, but it seems pretty flaky in Windows, and I don't want to burn more time testing it. (Using this Win64 zip version), amongst others in determining the points above in relation to version capability.) - Using
has('gui_gtk')covers both 2 and 3, so is a simple refinement. - Although it's not wrong to recommend putting the script(s) directly into the
.vim/pluginorvimfiles\plugindirectory, it would be better recommending using the packages approach (outlined at:h packages). That is, using.vim/pack/{whatever}/start(or.vim/pack/{whatever}/opt, and calling it from your.gvimrc, which is probably preferable in this instance too, especially if you use console and GUI. That's because it would mean you then only source the script(s) when using the GUI rather than relying on the test in the script itself to finish when using console Vim). I've not updated the README.md in relation to this, but you could consider it - check out this README of mine if you like. - Incidental: I popped in a GIF of it working in Debian WSL. You may want to look at your GIF - it is huge, comparatively.
That's about it. It's your repository so, if you're okay with what I have done, and are happy for a PR, let me know (and I'll make it and you can consider the few loose ends like point 5 after that).
I love the concept, btw, having stuffed around changing font sizes in the past, so thanks for putting it out there. (I will be taking the vim9script into my .gvimrc and _gvimrc directly because I prefer to have fewer plugins, and this is a pretty short script so only a small addition really.)