Age | Commit message (Collapse) | Author |
|
|
|
|
|
Set up formatting for the current buffer using 'prettier'.
|
|
I added these mappings before I developed a set of consistent
cross-language build, test, etc. mappings.
Re-use the mappings I came up with for adding a debugger line in Ruby.
These are much easier to type than the current Leader commands.
|
|
|
|
|
|
|
|
All the OCaml code I've read so far uses two-space indentation.
|
|
By default it's '/* %s */' which I don't like for line comments.
|
|
Previously, the cursor would be at the bottom or the loaded
documentation. It's more practical to start at the beginning.
Also remove the empty first line.
|
|
Get 'godoc' syntax highlighting.
|
|
These were a holdover from when the lines were in a map binding. They're
unnecessary now that they've been moved to a function.
|
|
This re-enables `K` keyworkprg functionality for the `GoDoc` command,
this time using my custom version.
|
|
Override the `GoDoc` command from 'vim-go'. That one produces docs
without the "-all" flag, and there's no option to enable "all". This
gives me all the documentation for a package.
This isn't as useful yet, as it breaks the `K` keywordprg.
|
|
|
|
Provide the option to use a `<Space>` as a leader in addition to my
normal Leader, since it can be quicker for some commands.
|
|
I've been editing email headers in Vim recently (previously I only did
that in Mutt's line editor). With automatic formatting, the headers can
get messed up due to reflow. Add bindings so we can quickly disable
automatic paragraph formatting when we need to.
|
|
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/
|