- Notifications
You must be signed in to change notification settings - Fork0
Snippet plugin for vim/nvim that supports LSP/VSCode's snippet format.
License
dezza/vim-vsnip
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
VSCode(LSP)'s snippet feature in vim/nvim.
- Nested placeholders
- You can define snippet like
console.log($1${2:, $1})$0
- You can define snippet like
- Nested snippet expansion
- You can expand snippet even if you already activated other snippet (it will be merged as one snippet)
- Load snippet from VSCode extension
- If you install VSCode extension via
Plug 'golang/vscode-go', vsnip will load those snippets.
- If you install VSCode extension via
- Support many LSP-client & completion-engine byvim-vsnip-integ
- Vim script interpolation
- You can use Vim script interpolation as
${VIM:...Vim script expression...}.
- You can use Vim script interpolation as
- SnipMate-like syntax support
- Snippet files in SnipMate format with the extension
.snippetscan be load. - NOTE: Full compatibility is not guaranteed. It is intended to easily create user-defined snippets.
- Snippet files in SnipMate format with the extension
- Pure Vim script
- Well tested (neovim/0.4.4, vim/8.0.1567)
- Support VSCode snippet format
- Provide integration with many plugins
friendly-snippets - Set of preconfigured snippets for all kind of programming languages that integrates really well withvim-vsnip, so all users can benefit from them and not to worry about setting up snippets on their own.
You can use your favorite plugin managers to install this plugin.
Plug'hrsh7th/vim-vsnip'Plug'hrsh7th/vim-vsnip-integ'calldein#add('hrsh7th/vim-vsnip')calldein#add('hrsh7th/vim-vsnip-integ')NeoBundle'hrsh7th/vim-vsnip'NeoBundle'hrsh7th/vim-vsnip-integ'
" NOTE: You can use other key to expand snippet." Expandimap<expr><C-j>vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>'smap<expr><C-j>vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>'" Expand or jumpimap<expr><C-l>vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>'smap<expr><C-l>vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>'" Jump forward or backwardimap<expr><Tab>vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'smap<expr><Tab>vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'imap<expr><S-Tab>vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'smap<expr><S-Tab>vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'" Select or cut text to use as $TM_SELECTED_TEXT in the next snippet." See https://github.com/hrsh7th/vim-vsnip/pull/50nmaps<Plug>(vsnip-select-text)xmaps<Plug>(vsnip-select-text)nmapS<Plug>(vsnip-cut-text)xmapS<Plug>(vsnip-cut-text)" If you want to use snippet for multiple filetypes, you can `g:vsnip_filetypes` for it.letg:vsnip_filetypes= {}letg:vsnip_filetypes.javascriptreact= ['javascript']letg:vsnip_filetypes.typescriptreact= ['typescript']
Snippet file will store tog:vsnip_snippet_dir per filetype.
- Open some file (example:
Sample.js) - Invoke
:VsnipOpencommand. - Edit snippet.
{"Class": {"prefix": ["class"],"body": ["/**"," * @author ${VIM:\\$USER}"," */","class $1 ${2:extends ${3:Parent} }{","\tconstructor() {","\t\t$0","\t}","}" ],"description":"Class definition template." }}The snippet format was described inhere orhere.
You can insert the filename viafname\<Plug>(vsnip-expand).
{"filename": {"prefix": ["fname"],"body":"$TM_FILENAME_BASE" }}You can fill$TM_SELECTED_TEXT by<Plug>(vsnip-select-text) or<Plug>(vsnip-cut-text).
{"log": {"prefix": ["log"],"body":"console.log(${1:$TM_SELECTED_TEXT});" }}You can insert value by Vim script expression.
{"user": {"prefix":"username","body":"${VIM:\\$USER}" }}You can insert UUID via python.
{"uuid": {"prefix":"uuid","body": ["${VIM:system('python -c\"import uuid, sys;sys.stdout.write(str(uuid.uuid4()))\"')}" ] }}NOTE:$VIM is only in vsnip. So that makes to lost the snippet portability.
You can runnpm run test after installvim-themis.
- compute the
user-diff...s:Session.flush_changes - reflect the
user-diffto snippet ast ...s:Snippet.follow - reflect the
sync-diffto buffer content ...s:Snippet.sync & s:Session.flush_changes
About
Snippet plugin for vim/nvim that supports LSP/VSCode's snippet format.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Languages
- Vim Script98.4%
- Lua1.5%
- Vim Snippet0.1%

