There are two important hotkeys
-
coq_settings.keymap.jump_to_mark
: jump to next edit region. (default<c-h>
) -
coq_settings.keymap.eval_snips
: evaluate document / visual seleciton as snippets (unbound by default)
coq.nvim
comes with a ridiculous amount of snippets by default.
To disable: simply do not install coq.artifacts
.
Note: *
and _
is are special wildcard filetypes.
-
:COQsnips edit
-- edits snippet for current filetype -
<eval_snips>
-- live repl to ensure snippet is what you want -
:COQsnips compile
-- boom, you are good to do
:COQsnips compile
coq.nvim
requires you to compile the snippets before they can be loaded. This is to ensure zero snippet errors during runtime.
coq
will only accept snippets with valid grammar, and has built-in repl to help you on that.
You need to bound coq_settings.keymap.eval_snips
to a key first.
ie. let g:coq_settings = { 'keymap.eval_snips': '<leader>j' }
Now entering <leader>j
under normal mode will evaluate current document, and under visual mode will evaluate only the visual seleciton.
User snippets must use the LSP grammar.
The LSP grammar is very similar to various VIM snip dialects, but has a formal specification.
snippet rubocopde
# rubocop:disable Style::MultilineBlockChain
$CLIPBOARD
# rubocop:enable Style::MultilineBlockChain
The document format is extremely simple:
Basically a subset of neosnippet
comment ::= '#' .*
extends ::= 'extends' match (', ' match)*
snippet ::= snipstart ('\n' label)? ('\n' alias)* '\n' snipbody
snipstart ::= 'snippet' match
label ::= 'abbr' body
alias ::= 'alias' body
snipbody ::= indent body ('\n' indent body)*
indent ::= (\s | \t)+
match ::= [^\s]+
body :: .*
-
For
<dirname>/<filename>.snip
, the snippets' filetype is<filename>
-
Doesn't matter what indentation is used, as long as it's consistent
-
The syntax highlighter comes with error highlights
Note: _abbr_
is label only, does not affect suggestions, _alias_
is suggestion only, does not affect label
# a comment
snippet snip
alias s
snippet ${0:name}
alias ${1:altname}
${2:snippet}
Inside all coq-user-snippets/
folders in your runtimepath
. AKA first it will lookup where your init.vim
is stored, then it will look inside each of your plugins.
$NVIM_HOME
|- ./init.vim
|- ./coq-user-snippets/*.snip
You can also set coq_settings.clients.snippets.user_path
to load from a custom location.
There is a convenience command:
" <filetype> can be omitted if current document has a filetype
:COQsnips edit <filetype>
To edit snippets for a particular filetype.
The default path is normally under $NVIM_HOME/coq-user-snippets/
, but if coq_settings.clients.snippets.user_path
is set, that is used instead.
To see where snippets are currently stored, there is also
:COQsnips cd
:COQsnips ls
Set coq_settings.clients.snippets.warn
to []
to disable warnings.