All Projects → neoclide → Coc Snippets

neoclide / Coc Snippets

Snippets solution for coc.nvim

Projects that are alternatives of or similar to Coc Snippets

Nvcode
An IDE layer for Neovim with sane defaults. Completely free and community driven.
Stars: ✭ 6,714 (+1127.42%)
Mutual labels:  neovim, snippets
Ncm R
R autocompletion for Neovim and vim 8 📝 📊 ⚡️
Stars: ✭ 102 (-81.35%)
Mutual labels:  snippets, neovim
Vim Vsnip
Snippet plugin for vim/nvim that supports LSP/VSCode's snippet format.
Stars: ✭ 224 (-59.05%)
Mutual labels:  snippets, neovim
Neovim Init.vim
🏮 The perfect Neovim configuration for productive people who wants to level up their Vim experience with a clean, minimal-looking aesthetic, as well as a highly extensible, easily customizable set of popular tools and shortcuts to boost productivity. 🏮
Stars: ✭ 440 (-19.56%)
Mutual labels:  neovim
Tmux Complete.vim
Vim plugin for insert mode completion of words in adjacent tmux panes
Stars: ✭ 447 (-18.28%)
Mutual labels:  neovim
Asynctasks.vim
🚀 Modern Task System for Project Building, Testing and Deploying !!
Stars: ✭ 495 (-9.51%)
Mutual labels:  neovim
Comfortable Motion.vim
Brings physics-based smooth scrolling to the Vim world!
Stars: ✭ 543 (-0.73%)
Mutual labels:  neovim
Deoplete Go
Asynchronous Go completion for Neovim. deoplete source for Go.
Stars: ✭ 433 (-20.84%)
Mutual labels:  neovim
Vscode Angular Snippets
Angular Snippets for VS Code
Stars: ✭ 530 (-3.11%)
Mutual labels:  snippets
Ivim
I love Vim, and I also love modifying it to be more convenient and efficient. So I name it "ivim"! Welcome to contribute to ivim.
Stars: ✭ 476 (-12.98%)
Mutual labels:  neovim
30 Seconds Of Swift Code
A Swift implementation of 30-seconds-of-code: A curated collection of useful Swift 4 snippets that you can understand in 30 seconds or less.
Stars: ✭ 476 (-12.98%)
Mutual labels:  snippets
Vscode R
R Extension for Visual Studio Code (execution, snippet, lint, R documantation, R Markdown)
Stars: ✭ 445 (-18.65%)
Mutual labels:  snippets
Vim Markdown Composer
An asynchronous markdown preview plugin for Vim and Neovim.
Stars: ✭ 501 (-8.41%)
Mutual labels:  neovim
Nvim Compe
Auto completion plugin for nvim that written in Lua.
Stars: ✭ 433 (-20.84%)
Mutual labels:  neovim
Vim Doge
(Do)cumentation (Ge)nerator 10+ languages 📚 Generate proper code documentation skeletons with a single keypress. ⚡️🔥
Stars: ✭ 533 (-2.56%)
Mutual labels:  neovim
Vscode Es7 Javascript React Snippets
Extension for Javascript/React snippets with search supporting ES7 and babel features
Stars: ✭ 435 (-20.48%)
Mutual labels:  snippets
Ranger.vim
Ranger integration in vim and neovim
Stars: ✭ 510 (-6.76%)
Mutual labels:  neovim
Vim Chat
💜 Chatting plugin for neovim and vim8
Stars: ✭ 475 (-13.16%)
Mutual labels:  neovim
Vim Deus
🌙 A better color scheme for the late night coder
Stars: ✭ 466 (-14.81%)
Mutual labels:  neovim
Falcon
A colour scheme for terminals, Vim and friends.
Stars: ✭ 483 (-11.7%)
Mutual labels:  neovim

coc-snippets

Snippets solution for coc.nvim

2019-03-23 00_09_39

Snippet preview requires neovim 0.4 or latest vim8

It's capable of:

  • Load UltiSnips snippets.
  • Load snipmate snippets.
  • Load VSCode snippets from coc extensions.
  • Load VSCode snippets from custom directories.
  • Load UltiSnips snippets from configured folder.
  • Provide snippets as completion items.
  • Provide expand and expandOrJump keymaps for snippet.
  • Provide snippets list for edit snippet.
  • Provide snippets.editSnippets command for edit user snippets of current filetype.

Note: some features of ultisnips and snipmate format snippets not supported, checkout faq.

Why?

  • Use same keys for jump placeholder.
  • Nested snippet support.
  • Always async, never slows you down.
  • Improved match for complete items with TextEdit support.
  • Edit snippets of current buffer by :CocList snippets, sorted by mru.

Supporting

If you like my work, consider supporting me on Patreon or PayPal:

Patreon donate button PayPal donate button

Install

In your vim/neovim, run command:

:CocInstall coc-snippets

Examples

" 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.

Ultisnips features

Some ultisnips features are not supported:

  • [x] Position check of trigger option, including b, w and i.
  • [x] Execute vim, python and shell code in snippet.
  • [x] extends, priority and clearsnippets command in snippet file.
  • [x] Visual placeholder.
  • [x] Placeholder and variable transform.
  • [x] Expression snippet.
  • [x] Automatic trigger snippet.
  • [x] Context snippets.
  • [x] Support loading snipmate snippets.
  • [ ] Execute shell code with custom shabang (will not support).
  • [ ] Automatic reformat snippet after change of placeholder (can't support).
  • [ ] Format related snippet options, including t, s and m (can't support).
  • [ ] Snippet actions (can't support).

Note: python regex in snippet are converted to javascript regex, however, some regex patterns can't be supported by javascript, including \u (?s) \Z (?(id/name)yes-pattern|no-pattern).

Options

  • 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.enableStatusItem: Enable status item in g:coc_status used for statusline.

  • 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.textmateSnippetsRoots: absolute directories that contains textmate/VSCode snippets to load.

  • snippets.ultisnips.enable: enable load UltiSnips snippets, default true.

  • snippets.ultisnips.usePythonx: use pythonx for eval python code when possible, default true.

  • snippets.ultisnips.pythonVersion: when usePythonx is false, python version to use for python code, default to 3.

  • 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

Commands

  • Use :CocList snippets to open snippets list.
  • Use :CocCommand snippets.editSnippets to edit user snippet of current filetype.
  • Use :CocCommand snippets.openSnippetFiles to open snippet files of current filetype.

F.A.Q

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: 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.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].