aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/toggle_option_flag.vim
Commit message (Collapse)AuthorAgeFilesLines
* Move lots of local Vim config into vim/afterTom Ryder2017-11-121-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a relatively drastic change that should have been done progressively, but I got carried away in ripping everything out and putting it back in again. Reading the documentation for writing a Vim script (:help usr_41.txt), I am convinced that all of the content that was in the vim/ftplugin directory and some of the vim/indent directory actually belonged in vim/after/ftplugin and vim/after/indent respectively. This is because the section on filetypes makes the distinction between replacing the core filetype or indent plugins and merely adding to or editing them after the fact; from :help ftplugin: > If you do want to use the default plugin, but overrule one of the > settings, you can write the different setting in a script: > > setlocal textwidth=70 > > Now write this in the "after" directory, so that it gets sourced after > the distributed "vim.vim" ftplugin after-directory. For Unix this > would be "~/.vim/after/ftplugin/vim.vim". Note that the default > plugin will have set "b:did_ftplugin", but it is ignored here. Therefore, I have deleted the user_indent.vim and user_ftplugin.vim plugins and their documentation that I wrote, and their ftplugin.vim and indent.vim shims in ~/.vim, in an attempt to make these plugins elegantly undo-ready, and instead embraced the way the documentation and $VIMRUNTIME structure seems to suggest. I broke the ftplugin files up by function and put them under subdirectories of vim/after named by filetype, as the 'runtimepath' layout permits. In doing so, I also carefully applied the documentation's advice: * Short-circuiting repeated loads * Checking for existing mappings using the <Plug> prefix approach * Avoiding repeated function declarations overwriting each other * Guarding against 'cpotions' mangling things (by simply short-circuiting if 'compatible' is set). I've made the b:undo_ftplugin and b:undo_indent commands less forgiving, and append commands to it inline with the initial establishment of the setup they're reversing, including checking that the b:undo_* variable actually exists in the first place. For the indentation scripts, however, three of the four files originally in vim/indent actually do belong there: 1. csv.vim, because it doesn't have an indent file in the core. 2. tsv.vim, because it doesn't have an indent file in the core. 3. php.vim, because it does what ftplugins are allowed to do in preventing the core indent rules from running at all. The indent/vim.vim rules, however, have been moved to after/indent/vim.vim, because the tweaks it makes for two-space indentation are designed to supplement the core indent rules, not replace them. Finally, I've adjusted Makefile targets accordingly for the above, given the vim/ftplugin directory is now empty and there are three new directories in vim/after to install. We wrap these under a single `install-vim-after` parent target for convenience. The `install-vim-after-ftplugin` target accommodates the additional level of filetype directories beneath it.
* Refactor toggle_option_flag.vimTom Ryder2017-11-061-23/+58
| | | | | | | | | | Got carried away and rewrote a lot of this all in one hit. * Show single-line error messages with an s:Error() function * Flag early errors on nonexistent options * Test for the flag both before and after trying to toggle it to use as the basis for error reporting and return value, in a new s:Has() function
* Correct a commentTom Ryder2017-11-061-1/+1
| | | | This likely got butchered by a wayward search-and-replace.
* Use stridx() instead of very-nomagic regex matchTom Ryder2017-11-061-9/+10
| | | | | I couldn't find this function at first, but it's what I need: a way to check whether a string appears in another one.
* Use strlen() instead of len()Tom Ryder2017-11-061-1/+1
| | | | | | strlen() is older, and also more specific to what we want to do. len() just happens to work on strings, but was introduced for counting Lists and Dictionaries.
* Escape option value assign correctlyTom Ryder2017-11-061-1/+1
| | | | This allows e.g.: ':ToggleOptionFlag fillchars diff: '; note the whitespace!
* Extend toggle_option_flag.vim for string flagsTom Ryder2017-11-061-13/+22
| | | | | | | | This commit extends toggle_option_flag.vim to allow the exported commands to toggle values of more than one character, for comma-separated options like 'switchbuf', e.g.: :ToggleOptionFlag switchbuf useopen
* Rename l:op to l:operation for clarityTom Ryder2017-11-061-3/+3
| | | | Just to avoid confusing it with something like l:option.
* Separate command building from execution in toggleTom Ryder2017-11-061-3/+7
| | | | | These are functionally equivalent; it's just clearer and more editing-friendly to do one thing at a time.
* Use idiomatic VimL regex for param validationTom Ryder2017-11-061-2/+2
| | | | \a and \L are, I think, perlre-style VimL regex inventions.
* Restore some judicious \m\C hedging in VimTom Ryder2017-11-061-2/+2
| | | | | These are technically not really needed, but this is more consistent with good style recommendations in the Google VimScript style guide.
* Caution about :execute not eval() in VimL commentsTom Ryder2017-11-061-3/+3
| | | | May as well refer to the actual command I'm using.
* Don't overwrite plugin-specified user commandsTom Ryder2017-11-061-2/+2
| | | | | | | | | | | | | The Google Vimscript Style Guide says: <https://google.github.io/styleguide/vimscriptguide.xml#Commands> > Excluding [!] prevents your plugin from silently clobbering existing > commands. Command conflicts should be resolved by the user. This makes sense to me as we can think of <Plug> mapping and user commands as being the user-accessible portion of the interface, rather than the functions which can be properly namespaced with autoload#Syntax(), if exposed at all.
* Complete ToggleOptionFlag commands with opt namesTom Ryder2017-11-061-2/+2
| | | | | Only a small subset of option names actually apply, so I'm not entirely sure this is actually better than nothing.
* Add short-circuit boilerplate to pluginsTom Ryder2017-11-041-40/+44
| | | | | | | | | | | | | | | | | | | | Set a g:loaded_* flag to prevent repeated reloads, and refuse to load at all if &compatible is set or if required features are missing. Some more accommodating plugins avoid the problems 'compatible' causes by saving its value at startup into a script variable, setting the option to the Vim default, and then restoring it when the plugin is done, to prevent any of its flags from interfering in the plugin code: let s:save_cpo = &cpo set cpo&vim ... let &cpo = s:save_cpo unlet s:save_cpo I don't want this boilerplate, so I'm going to do what Tim Pope's modules seem to, and just have the plugin refuse to do a single thing if 'compatible' is set.
* Merge branch 'feature/space-dots' into developTom Ryder2017-11-041-1/+1
|\ | | | | | | | | * feature/space-dots: Use spaces around concat dots in VimL consistently
| * Use spaces around concat dots in VimL consistentlyTom Ryder2017-11-041-1/+1
| |
* | Adjust plugin code layout a lotTom Ryder2017-11-041-7/+13
|/ | | | | | | | | | | | | Including renaming big_file.vim and accompanying functions yet again, to big_file_options.vim. Trying to keep complex autocmd and mapping definitions on long lines broken up semantically; definition and options on one line, patterns or mapping key on the next, and the command to run on the last. Also trying to make sure that <silent>, <buffer>, and <unique> are applied in the correct places, and that all mapping commands are using the :<C-U> idiom for the command prefix.
* Rename toggle plugin again, use commands not funcsTom Ryder2017-11-041-0/+44
This method makes a bit more sense, and amounts to slightly less verbose mapping commands. It does really on the +user_commands feature being available, however.