aboutsummaryrefslogtreecommitdiffstats
path: root/ftplugin
AgeCommit message (Collapse)Author
2021-01-26Add ftplugin/lisp.vimTeddy Wing
Add Common Lisp indentation settings.
2020-10-04ftplugin/vim.vim: Activate the built-in Vim ftpluginTeddy Wing
I was bemoaning the lack of `fo+=c` in Vim files, so decided to look over the contents of `$VIMRUNTIME/ftplugin/vim.vim`. Since I didn't find anything there that wasn't to my liking, I decided to activate the whole ftplugin.
2020-10-04ftplugin/typescript.vim: Make `gf` open `index.ts` if path is directoryTeddy Wing
In TypeScript and Node.js, you can import a file `./directory/index.ts` by importing `./directory`. I wanted `gf` and friends to open the `index` file if the import refers to a directory. By default, `gf` opens the directory using Netrw. At first tried to do this by setting 'includeexpr' as follows: setlocal includeexpr=<SID>FindFile(v:fname) function! s:FindFile(fname) echom 'FindFile: ' . a:fname if filereadable(a:fname) return a:fname endif return a:fname . '/index' endfunction This gave me the following error: E120: Using <SID> not in a script context: <SID>FindFile so I tried removing `<SID>`: setlocal includeexpr=FindFile(v:fname) function! FindFile(fname) echom 'FindFile: ' . a:fname if filereadable(a:fname) return a:fname endif return a:fname . '/index.ts' endfunction The problem was, my 'includeexpr' function wasn't getting executed every time I used `gf`, only some times. And it never ran when I used `gf` on a directory. After asking on Freenode#vim, 'crose' made the following suggestion: augroup typescript_maybe_append_filename au! au BufEnter * if expand('<amatch>')->isdirectory() \ | call s:maybe_append_filename() \ | endif augroup END fu s:maybe_append_filename() abort if getbufvar('#', '&ft', '') == 'typescript' exe 'e ' .. expand('%:p') .. 'index.ts' endif endfu This works, but it adds the Netrw directory buffer to the jumplist, and feels more like a mitigation than a solution. I looked at the following language ftplugins for inspiration: * .../vim/8.2.1650/share/vim/vim82/ftplugin/ruby.vim * https://github.com/moll/vim-node/blob/master/autoload/node.vim These prompted me to override `gf` with a custom mapping since it looked like 'includeexpr' wasn't going to be the right tool for this. The `s:FindFile()` function has similar logic, but is now written as a map rhs function, taking into account the different ways of invoking `gf`. When defined as a script-local function, I at first kept getting this error using `gf` on a directory: E127: Cannot redefine function <SNR>111_FindFile: It is in use Thanks to Ingo Karkat (https://stackoverflow.com/users/813602/ingo-karkat) and this Stack Overflow answer which describes how to keep the function in the same file (so I didn't have to move it to an autoload function) and still prevent it from being redefined: https://stackoverflow.com/questions/22633115/why-do-i-get-e127-from-this-vimscript/22633702#22633702 I needed to prepend `<C-v>` to the `<C-w>` characters in the map function calls because these would actually run in the command line, deleting the preceding word, and messing up the mapping. In order to pass those `<C-w>` characters in the string arguments, I needed to escape them with `<C-v>`, even though it resulted in non-obvious looking code.
2020-09-07ftplugin/go.vim: Run shell tests with verbose flagTeddy Wing
In case I need to add logs for debugging.
2020-08-31ftplugin/go.vim: Create test file on alternate if it doesn't existTeddy Wing
When switching to a file's alternate (its test file), create the test if the file doesn't exist. By default, a warning is issued if the file doesn't exist. I wanted an easier way to create the test file. Previously I'd use: :e %:h<Tab><C-f>bbi_test<CR> This uses the function that the `Plug` mappings call under the hood, and turns on the `-bang` argument to have it create the test file if it doesn't exist.
2020-08-02ftplugin/rust.vim: Fix spacingTeddy Wing
2020-08-02ftplugin/rust.vim: Add mapping to run testsTeddy Wing
2020-07-27ftplugin/go.vim: Add mapping to run package tests with terminal outputTeddy Wing
The Vim-Go mappings run the tests in a job and add results to the Quickfix list. Add a new mapping that doesn't use Quickfix, and instead just runs the test command for the package that contains the current file, outputting the results to standard output. Gives me an additional alternative to view test results.
2020-07-19ftplugin/rust.vim: Add a command to run `cargo check`Teddy Wing
Faster than using `cargo build` for a feedback cycle.
2020-07-19ftplugin/rust.vim: Activate Rust plugin's ftpluginTeddy Wing
Take advantage of the Rust Vim plugin's additional language-specific features, like `///` and `//!` comment handling.
2020-07-17ftplugin/rust.vim: Add mappings to build and runTeddy Wing
2020-07-17ftplugin/rust.vim: Turn on `b:argwrap_tail_comma`Teddy Wing
Rust style seems to prefer trailing commas.
2020-07-04projects/aodocs.vim: Set 'path' for UFO extension projectTeddy Wing
Enable `gf` and related commands to work by setting the proper 'path', and ensuring the `.js` suffix is used on files.
2020-06-15ftplugin/python.vim: Turn on `b:argwrap_tail_comma`Teddy Wing
Append a trailing comma when unwrapping arguments.
2020-06-15ftplugin/go.vim: Add `Ze` mapping to insert `if err` blockTeddy Wing
Vim-Go has a `:GoIfErr` command, which inserts an `if err != nil` check. Add a mapping for it to make it quicker to access.
2020-06-01ftplugin/go.vim: Turn on `b:argwrap_tail_comma`Teddy Wing
This adds a trailing comma when using ArgWrap. Go requires trailing commas, otherwise it reports compilation errors.
2020-05-08ftplugin/typescript.vim: Set 'commentstring'Teddy Wing
2020-03-25ftplugin/todo.vim: Highlight `todoUnimportant` as a light greyTeddy Wing
These are by default highlighted as `Ignore`, which makes them the same colour as finished and deleted to-dos. Set them to a light grey colour to make them more readable.
2020-03-12ftplugin/go.vim: Add a mapping to open the alternate file in a splitTeddy Wing
2020-02-26ftplugin/go.vim: Add mapping to show alternate fileTeddy Wing
Use `z<C-^>` to swap between test and implementation files. Gives me a faster way to navigate.
2020-02-26ftplugin/go.vim: Enable the vim-go ftpluginTeddy Wing
Enable extra mappings, text objects, etc. provided by vim-go. Wanted function scoped motions and text objects, and this was the easy way to get them.
2019-11-04Add ftplugin/javascript.vimTeddy Wing
Add bindings to insert `debugger` statements in JavaScript.
2019-10-21Remove ftplugin/gitcommit_pullreq_editmsg.vimTeddy Wing
Now that I effectively removed the `checktime` augroup in cc86bdf4af5212a3b2a7960e65c402eac71091c1, this is no longer necessary. Also, it errors because `checktime` no longer exists.
2019-09-26ftplugin/go.vim: Change `<leader>cf` mapping to `<leader>cd`Teddy Wing
This mapping conflicted with the `<leader>cf` mapping in my `vimrc` that copies the current filename/relative path to the clipboard.
2019-08-01ftplugin/netrw.vim: Remove `nowrap` from `g:netrw_bufsettings`Teddy Wing
This seemed to cause files I opened with Netrw to have `set nowrap`, overriding the `set wrap` I have in my vimrc.
2019-07-21Add ftplugin/gitcommit_pullreq_editmsg.vimTeddy Wing
Disable 'better autoread' for PULLREQ_EDITMSG files. GitHub's `hub` CLI may be doing some polling on the file or something because I keep getting prompts to "Load file" after a while when writing pull request descriptions.
2019-06-20Add ftplugin/lua.vimTeddy Wing
* Set 'commentstring' * Fix comment wrapping by adding `--` to 'comments'. Otherwise no leading comment markers would be inserted when text wrapped to the next line.
2019-06-17vimrc: Don't preserve indentation on empty linesTeddy Wing
Over the years and as I've been using Vim, I've gradually stopped liking this style, and now prefer blank lines without whitespace. Rather than continuing to override the default for different filetypes, it feels like it's time to change the default.
2019-06-08vimrc: Move RSpec mappings to ftplugin/ruby.vimTeddy Wing
Since I'm not writing Ruby regularly right now, move these mappings to the Ruby ftplugin so I don't accidentally try to run a spec in another language where it makes no sense.
2019-06-05ftplugin/gitcommit.vim: Turn on 'formatoptions' `n`Teddy Wing
This formats numbered lists so that they wrap to the beginning of the text, instead of being flush with the number. Before: 1. A list that goes beyond the text width and wraps to the number. After: 1. A list that goes beyond the text width and wraps to the text. Thanks to this blog post from Edward Yang for prompting me to read the |fo-table| help again more closely: http://blog.ezyang.com/2010/03/vim-textwidth/
2019-06-01Add ftplugin/javascript.vimTeddy Wing
Don't preserve indentation on empty lines in JavaScript files.
2019-05-17ftplugin/go.vim: Add a mapping to run `goimports`Teddy Wing
Sometimes the run-on-save functionality doesn't work. This gives me a quick way to run the formatter when it doesn't happen automatically.
2019-05-17ftplugin/gitcommit.vim: Turn on spell checking in Git commitsTeddy Wing
2019-05-17ftplugin/go.vim: Add mapping to `:GoTestCompile`Teddy Wing
Make it faster to compile tests without running them.
2019-05-17ftplugin/go.vim: Make `go run` mapping run root main packageTeddy Wing
The `Plug` mapping wasn't finding my `main` package from a sub-package. Change it to force running for the main package in the `pwd` directory.
2019-05-10ftplugin/go.vim: Add a few mappings to Vim-GoTeddy Wing
Mappings to build projects and run tests.
2018-12-13ftplugin/objc.vim: Switch alternates on <C-^>Teddy Wing
Use FSwitch to swap .h and .m files in the current window when `<C-^>` is pressed.
2018-11-24ftplugin/todo.vim: Don't change highlighting of non-todo filesTeddy Wing
Previously, the custom highlighting I had added for TODO files would infect the highlighting of all other files in the same Vim session. Only change the highlighting of the `todoUndone` group so that it doesn't affect anything else.
2018-11-24Add ftplugin/dome_key.vimTeddy Wing
Use the plugin's ftplugin. This gives us the proper comment string.
2018-11-24Add ftplugin/make.vimTeddy Wing
Set the correct comment string for make.
2018-11-24Add ftplugin/objc{,pp}.vimTeddy Wing
Filetype plugins for Objective-C. Turns out editing ObjC in Vim is somewhat surprisingly whoppingly better than Xcode. This gets indentation set to 4-space tabs and sets the comment correct prefix (Tcomment forces /* ... */). Include `objcpp` also because ObjC header files get recognised by Vim as ObjC++.
2018-02-13ftplugin/mail.vim: Activate Vim's mail ftpluginTeddy Wing
I was using a different machine and composing an email, but there I wasn't getting a `textwidth` setting of 72. Instead it was unset. Ensure the default mail ftplugin gets sourced so we get the proper `textwidth`, plus some other niceties.
2017-12-05ftplugin/ruby.vim: Add mapping to reset the Rails test databaseTeddy Wing
Occasionally I need to drop and reload the Rails test database. Recently I've been working on something that requires a "truncation"-cleaned test, and have had to reset my database regularly while writing the test to eliminate inconsistent state. This command gives me the ability to reset with a single key press. I've been testing it out for a few days in a Vim session and have found it very helpful.
2017-12-05ftplugin/ruby.vim: Add `RubyNewHashSyntax` commandTeddy Wing
I've had to use a similar pattern a couple of times in the past to convert files or sections of files from the old Ruby hash syntax (`:key => 'value'`) to the new syntax (`key: 'value'`). Give the pattern and substitution a command to make it readily available the next time I need to use it.
2017-11-14Add ftplugin/slim.vimTeddy Wing
Ugh, I hate Slim. But I increasingly have to deal with it in projects. Fix what's within our power to fix, and give ourselves Ruby indentation in Slim files.
2017-09-22ftplugin/ruby.vim: Add command to stop SpringTeddy Wing
I love Spring, it makes it so much nicer to run tests in Rails apps. That's why I set 'vim-rspec' to use it. However, sometimes it gets confused and doesn't load the latest code, and a load error occurs. Recently I started a new project and those errors occur every few times I run the tests. It's absolutely unbearable. To make life a tiny bit easier, make a command that allows us to stop Spring from Vim, to avoid having to <C-z> and type the command by hand. You can tell I was frustrated when I decided to make this command.
2017-08-10Add ftplugin/haskell.vimTeddy Wing
Add syntax formatting settings for Haskell. Want 4-space tabs and a maximum of 80 characters per line. Using this style guide: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md
2017-04-29Add ftplugin/gitcommit_gitcha.vimTeddy Wing
Unlet `b:did_ftplugin` to allow 'vim-gitcha' to work. By default we override `b:did_ftplugin` to disable filetype plugins, but here we want the ftplugin to work.
2017-03-09ftplugin/ruby.vim: Add maps to insert debug breakpointsTeddy Wing
Make it easier to insert `byebug` debug statements. Currently working in Rails so assuming `byebug` is already required. Might want to add new maps or modify these later if I end up needing to do a `require 'byebug'` beforehand. These keys didn't seem to be used for anything, so I figured they would be a nice quick combination for this. Didn't really feel like adding a long leader command to do it.
2017-03-05ftplugin/mail.vim: Don't start wrapped lines with '*'Teddy Wing
When writing bulleted lists, don't start wrapped lines with '*'. Just wrote a mail message an noticed this was a problem. Copied my gitcommit.vim config to resolve this.