Age | Commit message (Collapse) | Author |
|
I've gone back and forth between tabs and 4-space indentation in
Objective-C. Currently working on a project that uses tab indentation so
sticking with that for now.
|
|
I wanted the built-in `comments` setting to automatically insert the
comment leader when wrapping.
|
|
Vlime includes a bunch of mappings, but some of them are shadowed by own
mappings. The plugin doesn't include any corresponding ex-style
commands. Change the <LocalLeader> in Lisp files to <Space> to give me
access to all of Vlime's mappings.
|
|
Add Common Lisp indentation settings.
|
|
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.
|
|
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.
|
|
In case I need to add logs for debugging.
|
|
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.
|
|
|
|
|
|
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.
|
|
Faster than using `cargo build` for a feedback cycle.
|
|
Take advantage of the Rust Vim plugin's additional language-specific
features, like `///` and `//!` comment handling.
|
|
|
|
Rust style seems to prefer trailing commas.
|
|
Enable `gf` and related commands to work by setting the proper 'path',
and ensuring the `.js` suffix is used on files.
|
|
Append a trailing comma when unwrapping arguments.
|
|
Vim-Go has a `:GoIfErr` command, which inserts an `if err != nil` check.
Add a mapping for it to make it quicker to access.
|
|
This adds a trailing comma when using ArgWrap. Go requires trailing
commas, otherwise it reports compilation errors.
|
|
|
|
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.
|
|
|
|
Use `z<C-^>` to swap between test and implementation files. Gives me a
faster way to navigate.
|
|
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.
|
|
Add bindings to insert `debugger` statements in JavaScript.
|
|
Now that I effectively removed the `checktime` augroup in
cc86bdf4af5212a3b2a7960e65c402eac71091c1, this is no longer necessary.
Also, it errors because `checktime` no longer exists.
|
|
This mapping conflicted with the `<leader>cf` mapping in my `vimrc` that
copies the current filename/relative path to the clipboard.
|
|
This seemed to cause files I opened with Netrw to have `set nowrap`,
overriding the `set wrap` I have in my vimrc.
|
|
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.
|
|
* Set 'commentstring'
* Fix comment wrapping by adding `--` to 'comments'. Otherwise no
leading comment markers would be inserted when text wrapped to the
next line.
|
|
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.
|
|
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.
|
|
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/
|
|
Don't preserve indentation on empty lines in JavaScript files.
|
|
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.
|
|
|
|
Make it faster to compile tests without running them.
|
|
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.
|
|
Mappings to build projects and run tests.
|
|
Use FSwitch to swap .h and .m files in the current window when `<C-^>`
is pressed.
|
|
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.
|
|
Use the plugin's ftplugin. This gives us the proper comment string.
|
|
Set the correct comment string for make.
|
|
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++.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|