
Research
/Security News
60 Malicious Ruby Gems Used in Targeted Credential Theft Campaign
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
coc-snippets
Advanced tools
Snippets solution for coc.nvim
Snippet preview requires neovim 0.4 or latest vim8
It's capable of:
snippets.editSnippets
command for edit user snippets of current filetype.Note: some features of ultisnips and snipmate format snippets not supported, checkout Ultisnips features.
:CocList snippets
.Ultisnips provider need pythonx support on (neo)vim, to check the feature exists, try:
:echo has('pythonx')
On neovim, run command:
:checkhealth
and make sure you have Python 3 provider for neovim installed.
On vim8, run command:
:pyx print(1)
in your vim, if it throws, it means your vim is not compiled with python support or the python dynamic lib required by vim is missing(or broken).
Note: some python code may require python feature that not supported by the python interpreter used by vim, error will throw on that case.
Error will be shown when pythonx
with (neo)vim can't work, fix pythonx
support or disable ultisnips support by add "snippets.ultisnips.enable": false
in your configuration file.
In your vim/neovim, run command:
:CocInstall coc-snippets
" Use <C-l> for trigger snippet expand.
imap <C-l> <Plug>(coc-snippets-expand)
" Use <C-j> for select text for visual placeholder of snippet.
vmap <C-j> <Plug>(coc-snippets-select)
" Use <C-j> for jump to next placeholder, it's default of coc.nvim
let g:coc_snippet_next = '<c-j>'
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim
let g:coc_snippet_prev = '<c-k>'
" Use <C-j> for both expand and jump (make expand higher priority.)
imap <C-j> <Plug>(coc-snippets-expand-jump)
" Use <leader>x for convert visual selected code to snippet
xmap <leader>x <Plug>(coc-convert-snippet)
Make <tab>
used for trigger completion, completion confirm, snippet expand and jump like VSCode.
inoremap <silent><expr> <TAB>
\ pumvisible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:coc_snippet_next = '<tab>'
Note: coc#_select_confirm()
helps select first complete item when there's
no complete item selected, neovim 0.4 or latest vim8 required for this function
work as expected.
Some ultisnips features are not supported:
b
, w
and i
.extends
, priority
and clearsnippets
command in snippet file.m
, empty line in snippet not have indentation with coc.nvim.t
, s
.pre_expand
, post_expand
and jump
(can't support).Note: python regex in snippet are converted to javascript regex, however,
some regex patterns can't be supported by javascript, including
(?x)
(?s)
\Z
(?(id/name)yes-pattern|no-pattern)
.
snippets.priority
: priority of snippets source, default 90
.
snippets.editSnippetsCommand
: Open command used for snippets.editSnippets command, use coc.preferences.jumpCommand by default.
snippets.trace
: Trace level of snippets channel.
snippets.excludePatterns
: List of filepath patterns to exclude, $HOME
and other environment variables are expanded.
snippets.extends
: extends filetype's snippets with other filetypes, example:
{
"cpp": ["c"],
"javascriptreact": ["javascript"],
"typescript": ["javascript"]
}
snippets.userSnippetsDirectory
, Directory that contains custom user ultisnips snippets, use ultisnips in extension root by default.
snippets.shortcut
, shortcut in completion menu, default S
.
snippets.autoTrigger
: enable auto trigger for auto trigger ultisnips snippets, default true
.
snippets.triggerCharacters
: trigger characters for completion, default []
.
snippets.loadFromExtensions
: load snippets from coc.nvim extensions, default: true
.
snippets.loadVSCodeProjectSnippets
: Load code snippets in folder ${workspaceFolder}/.vscode, default: true
.
snippets.textmateSnippetsRoots
: absolute directories that contains textmate/VSCode snippets to load.
snippets.ultisnips.enable
: enable load UltiSnips snippets, default true
.
snippets.ultisnips.trace
: Trace verbose snippet information, default false
.
snippets.ultisnips.directories
: directories that searched for snippet files,
could be subfolder in every $runtimepath or absolute paths, default: ["UltiSnips"]
snippets.snipmate.enable
: enable load snipmate snippets, default true
.
snippets.snipmate.author
: author name used for g:snips_author
snippets.snipmate.trace
: Trace verbose snippet information, default false
.
:CocList snippets
to open snippets list.:CocCommand snippets.editSnippets
to edit user snippet of current filetype.:CocCommand snippets.openSnippetFiles
to open snippet files of current filetype.:CocCommand snippets.openOutput
to open output channel of snippets.Q: How to check if a snippet successfully loaded?
A: Use command :CocCommand workspace.showOutput snippets
Q: Some ultisnips snippet not works as expected.
A: Reformat after change of placeholder feature can't be supported for now, and some regex pattern can't be converted to javascript regex pattern, so the snippet can be failed to load.
Q: Where to get snippets?
A: One solution is install honza/vim-snippets which is widely used.
Q: Get error message ModuleNotFoundError: No module named 'vimsnippets'
A: Make sure honza/vim-snippets in
your vim's &runtimepath
.
Q: Do I need to install Ultisnips.
A: No! This extension is designed to work with or without Ultisnips, you can still install Ultisnips, but this extension would not run any code or read configuration from it.
Q: How to check jumpable or expandable at current position.
A: Use functions provided by coc.nvim: coc#expandable()
coc#jumpable()
and coc#expandableOrJumpable()
.
Q: It doesn't load snippets from vim-go.
A: It uses g:UltiSnipsSnippetDirectories
which is not supported, you can
add settings:
snippets.ultisnips.directories: [
"UltiSnips",
"gosnippets/UltiSnips"
],
to load it.
Q: How could I add custom UltiSnips snippets.
A: You can create snippet files in folder: $VIMCONFIG/coc/ultisnips
, use
command :CocCommand snippets.editSnippets
to open user snippet of current
filetype.
If you like this extension, consider supporting me on Patreon or PayPal:
MIT
3.0.3
FAQs
Snippets extension for coc.nvim
The npm package coc-snippets receives a total of 808 weekly downloads. As such, coc-snippets popularity was classified as not popular.
We found that coc-snippets demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.