aboutsummaryrefslogtreecommitdiff
path: root/vim/ftplugin
AgeCommit message (Collapse)AuthorFilesLines
2017-11-08Correct prefix for b:undo_* variableTom Ryder1-1/+1
This was causing nasty errors whenever I started editing a Perl file.
2017-11-08Use "nunmap" not "unmap" for b:undo_* varTom Ryder2-5/+5
We only want to remove the normal mode mapping, since that's all we set.
2017-11-08Remove null command from b:undo_* variablesTom Ryder3-6/+6
I didn't realise that a null command at the front of .e.g '|cmd|cmd2' printed the current line! Removed that.
2017-11-08Use consistent/thorough ftplugin/indent unloadingTom Ryder7-7/+32
Unload all maps too, with silent! in case they don't exist.
2017-11-08Break a long conditional in vim/ftdetect/sh.vimTom Ryder1-1/+2
Just for legibility.
2017-11-08Rename b:check and b:lint with sh_ prefixTom Ryder1-9/+9
Just to reduce the chance of colliding with existing buffer variable names.
2017-11-08Remove overkill defined-and-false check of sh varsTom Ryder1-4/+4
syntax/sh.vim only uses the existence of these variables for its checks and as far as I can see never their actual values, so let's not overdo things.
2017-11-08Clear b:check/lint in ftdetect/sh.vim b:undoTom Ryder1-1/+1
2017-11-08Move ftplugin/sh.vim b:undo def to end of fileTom Ryder1-2/+4
2017-11-08Use correct undo variable name in ftplugin/sh.vimTom Ryder1-1/+1
This was likely a copy-paste error.
2017-11-08Use sh.vim local vars not global POSIX hacksTom Ryder1-19/+14
Rather than setting g:is_posix and working around core syntax/sh.vim's ideas about Korn and POSIX shells, forego sh.vim's efforts to guess what shell the system /bin/sh is entirely. It's irrelevant to me anyway, since I'll often be writing shell scripts to run on an entirely different system. Instead, if we have a #!/bin/sh shebang reflected in the b:is_sh variable set by core filetype.vim, and we don't have any other buffer-level indication of what shell this is, assume it's POSIX, because I very rarely write Bourne. Then, after the syntax file is loaded, clear away all but one of the resulting b:is_* variables. I have a feeling this is going to end with me re-implementing this syntax file, possibly as separate sh.vim, bash.vim, and ksh.vim files.
2017-11-07Add user_ftplugin.vim and user_indent.vim pluginsTom Ryder4-28/+8
This reverts commit 09b83b6 and replaces it with a working version. Because of the order in which the autocmd hooks run, the attempted method of adding unloading instructions for my custom ftplugin and indent rules to the b:undo_ftplugin and b:undo_indent doesn't actually work. This is because the custom rules for both groups from ~/.vim are sourced *first*, before their core versions, so the changes the custom rules made to b:undo_ftplugin and b:undo_indent are simply clobbered by the core version when it loads itself. Therefore we need to arrange for two things: 1. A custom variable needs to be checked and executed when the filetype changes to revert the changes for the custom ftplugin or indent rules. 2. That execution needs to take place *first* when the filetype changes. I wrote two simple plugins with very similar code that are designed to run as a user's custom ftplugin.vim and indent.vim implementations, running before their brethren in the Vim core, and setting up an autocmd hook to :execute b:undo_user_ftplugin and b:undo_user_indent plugin respectively. This seemed to work well, so I've implemented it. It involves adding a shim to ~/.vim/indent.vim and ~/.vim/ftplugin.vim to "preload" the plugin when the `filetype indent plugin on` call is made. I've added that to the relevant Makefile targets.
2017-11-07Use b:undo variables correctlyTom Ryder4-0/+36
Setting or adding to b:undo_indent and b:undo_ftplugin variables, which I only learned about just now, allows me to avoid the _GLOBAL.vim hack and remove some files from both vim/indent/ and vim/ftplugin/. These variables aren't subjected to :execute automatically in anything older than Vim 7.0, but I don't think that's too much of a concern as the only real reason they're needed are for changing filetypes in the same buffer, which doesn't happen that often anyway.
2017-11-05Put missing exclamation mark back into shell checkTom Ryder1-1/+1
Looks like this was mistakenly omitted in commit 09f8635.
2017-11-04Simplify shell linting code with single varsTom Ryder1-8/+8
Put the entire command line for the determined check and lint into the variable, so it can just be directly executed.
2017-11-04Adjust plugin code layout a lotTom Ryder4-15/+26
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.
2017-11-04Add lint mapping for VimscriptTom Ryder1-0/+5
Runs `vint -s`; the -s includes stylistic suggestions.
2017-11-04Add check and lint mappings for shell scriptTom Ryder1-0/+22
The commands to use in this case are dependent on the particular shell being used.
2017-11-04Add tidy mapping for HTMLTom Ryder1-0/+4
This mapping mirrors the one for Perl that passes the content of the buffer through a program to tidy it (i.e. not merely check but actively change it). The tidy(1) option chosen here, -quiet, is the bare minimum to make this invocation useful. We would never want the boilerplate it otherwise emits to be in the buffer after a call. Everything else should be applied in a configuration file, which I'll do in a separate feature.
2017-11-04Break long lines in check/lint/tidy mappingsTom Ryder2-5/+12
2017-11-04Make all lint/check/tidy maps local and silentTom Ryder2-5/+5
That is, apply <buffer> and <silent> to each of them, to make them only apply to the current buffer and to prevent them from echoing the command they're running.
2017-11-03Improve comments on check/lint/tidy mapsTom Ryder2-4/+4
2017-11-03Use long form options for tidy(1) Vim callTom Ryder1-2/+2
2017-11-03Use direct :write !cmd instead of shellescape()Tom Ryder2-17/+7
This is a much better method of calling external programs on the buffer's contents, not just because it avoids the mess of :execute evaluation but also because it doesn't require that there actually be a filename for the current buffer. This drastically simplifies the HTML tidy(1) call in particular.
2017-11-03Use full ':execute' not just ':exe' in VimLTom Ryder2-3/+3
We should probably avoid this sort of abbreviation in scripts.
2017-11-03Check for availability of Vim shellescape()Tom Ryder2-10/+17
It doesn't seem to be in very old Vims; worth testing for to avoid errors if I try to use the function.
2017-11-03Revert "Adjust UrlLink() to yank word without t...Tom Ryder1-3/+1
I thought text objects were introduced to Vim a lot later than they actually were; this works fine even in Vim 6, so I'll leave it as it's nicer. This reverts commit ffb5cbc7c681e2fdcb780dbdc51cf3458a937791.
2017-11-03Adjust UrlLink() to yank word without text objectsTom Ryder1-1/+3
2017-11-03Refactor UrlLink() function normal! commandsTom Ryder1-2/+10
Tidy up the 'normal!' commands and comment them in appropriate groups. Take advantage of the natural command-termination at the end of a 'normal!' string to end insert mode. It would be better to do all of this with pure VimL functions, but I don't know how yet.
2017-11-03Use single quotes for HTML link mapping :executeTom Ryder1-2/+2
Saves some backslashing, just like in shell and Perl!
2017-11-03Refactor HTML tidy(1) mappingTom Ryder1-1/+4
Move the logic into a script function. Use single quotes for the strings, too, since we don't need interpolation.
2017-11-03Use <Leader>/<LocalLeader> correctly in Vim configTom Ryder2-5/+5
From ":help <LocalLeader>": > In a global plugin <Leader> should be used and in a filetype plugin > <LocalLeader>. "mapleader" and "maplocalleader" can be equal.
2017-10-30Apply name conventions, scoping to Vim identifiersTom Ryder1-2/+2
The Google VimScript Style Guide says <https://google.github.io/styleguide/vimscriptguide.xml#Naming>: >In general, use plugin-names-like-this, FunctionNamesLikeThis, >CommandNamesLikeThis, augroup_names_like_this, >variable_names_like_this. Adjusted variable, function, and `augroup` names accordingly, including setting script scope for some of the functions and their calls (`s:` and `<SID>` prefixes). Initially I tried using `prefix#`, but it turns out that this is a namespacing contention for publically callable functions like `pathogen#infect`, and none of these functions need to be publically callable.
2017-10-30Merge branch 'vim/vint'Tom Ryder1-4/+4
The Vim configuration, excluding the submodule plugin bundles, now passes a strict run of the vim-vint tool. There's also now a `lint-vim` target in the Makefile.
2017-10-30Move non-indent HTML Vim config indent->ftpluginTom Ryder1-0/+11
This was mistakenly moved along with some indentation settings in 9858af6.
2017-10-30Rearrange and better explain ksh syntax workaroundTom Ryder1-4/+19
Move the rule setting the custom b:is_ksh variable used for this workaround (established in 52615f6) into an ftplugin file, rather than into ftdetect; the latter seems a much more appropriate place since by this point we've definitely decided the file type is "sh". From the revised comment in this changeset: >Setting g:is_posix above also prompts Vim's core syntax/sh.vim script >to set g:is_kornshell and thereby b:is_kornshell to the same value as >g:is_posix. > >That's very confusing, so before it happens we'll copy b:is_kornshell's >value as determined by filetype.vim and ~/.vim/ftdetect/sh.vim into a >custom variable b:is_ksh, before its meaning gets confused. > >b:is_ksh as a name is more inline with b:is_bash and b:is_sh, anyway, >so we'll just treat b:is_kornshell like it's both misnamed and broken. > >We can then switch on our custom variable in ~/.vim/after/syntax/sh.vim >to apply settings that actually *are* unique to Korn shell and its >derivatives.
2017-10-30Move filetype-specific indent options into indent/Tom Ryder8-54/+0
I'm still getting used to the structure of the configuration here, and had mistakenly put these indent-related settings into files in the ftplugin directory.
2017-10-30Add some more file-specific indent preferencesTom Ryder5-0/+33
For some languages in which I write often: C, HTML, Perl, PHP, and shell scripts. All of these values presently match the defaults specified in config/indent.vim, but for languages I commonly use it's probably appropriate to have files to set the indent settings explicitly anyway, especially if we switched from a filetype with different values.
2017-10-30Add detection, tweak indent/whitespace for CSV/TSVTom Ryder2-0/+6
Vim does not seem to have any built-in detection or settings for CSV or TSV files, so I've added a couple here, based on filename patterns matching the .csv and .tsv extensions. If either of these types are detected, the 'autoindent' and 'expandtab' options are both switched off, as they're undesirable, especially in TSVs where a literal tab is almost certainly what's intended. Ideally, these same two setting would apply to any filetype not otherwise categorisable, but I can't figure out a way to do that safely yet; there was an attempt made in d3d998c.
2017-10-30Move vim/after/ftplugin files into vim/ftpluginTom Ryder5-0/+34
None of the settings in here need to be run after the core configuration files are loaded, so I'll put them in a slightly more accessible or logical place. This adds a new target `install-vim-ftplugin`, and makes that a prerequisite of the `install-vim` target.