{"id":13479430,"url":"https://github.com/neoclide/coc-snippets","last_synced_at":"2025-10-24T02:50:16.504Z","repository":{"id":41280895,"uuid":"163420599","full_name":"neoclide/coc-snippets","owner":"neoclide","description":"Snippets solution for coc.nvim","archived":false,"fork":false,"pushed_at":"2025-03-30T12:40:23.000Z","size":1072,"stargazers_count":975,"open_issues_count":3,"forks_count":43,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-14T12:09:29.613Z","etag":null,"topics":["coc","neovim","snippets","ultisnips","vim"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neoclide.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"chemzqm","custom":"https://paypal.me/chezqm"}},"created_at":"2018-12-28T14:47:05.000Z","updated_at":"2025-04-11T14:16:48.000Z","dependencies_parsed_at":"2024-01-10T20:11:10.816Z","dependency_job_id":"93c271a0-b14c-40c1-9f3e-ba0f283657aa","html_url":"https://github.com/neoclide/coc-snippets","commit_stats":null,"previous_names":[],"tags_count":131,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoclide%2Fcoc-snippets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoclide%2Fcoc-snippets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoclide%2Fcoc-snippets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoclide%2Fcoc-snippets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neoclide","download_url":"https://codeload.github.com/neoclide/coc-snippets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248877958,"owners_count":21176244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coc","neovim","snippets","ultisnips","vim"],"created_at":"2024-07-31T16:02:15.971Z","updated_at":"2025-10-24T02:50:11.455Z","avatar_url":"https://github.com/neoclide.png","language":"TypeScript","funding_links":["https://patreon.com/chemzqm","https://paypal.me/chezqm","https://www.patreon.com/chemzqm","https://www.paypal.com/paypalme/chezqm"],"categories":["TypeScript","Language Support","vim","Vim Snippet"],"sub_categories":[],"readme":"# coc-snippets\n\nSnippets solution for [coc.nvim](https://github.com/neoclide/coc.nvim)\n\n![2019-03-23 00_09_39](https://user-images.githubusercontent.com/251450/54837017-62891300-4d00-11e9-9e53-49742a1a33f2.gif)\n\n_Snippet preview requires [neovim 0.4 or latest vim8](https://github.com/neoclide/coc.nvim/wiki/F.A.Q#how-to-make-preview-window-shown-aside-with-pum)_\n\nIt's capable of:\n\n- Load UltiSnips snippets.\n- Load snipmate snippets.\n- Load VSCode snippets from coc.nvim extensions.\n- Load VSCode snippets from custom directories.\n- Load VSCode snippets from `${workspaceFolder}/.vscode`.\n- Load UltiSnips snippets from configured folder.\n- Load massCode snippets from running massCode application (disabled by default).\n- Create massCode snippets through the `snippets.editMassCodeSnippets` command.\n- Provide snippets as completion items.\n- Provide expand and expandOrJump keymaps for snippet.\n- Provide snippets list for edit snippet.\n- Provide `snippets.editSnippets` command for edit user snippets of current filetype.\n\n**Note:** some features of ultisnips and snipmate format snippets not supported,\ncheckout [Ultisnips features](#ultisnips-features).\n\n## Why?\n\n- Use same keys for jump placeholder.\n- Nested snippet support.\n- Always async, never slows you down.\n- Preview snippet context in float window/popup.\n- Improved match for complete items with TextEdit support.\n- Edit snippets of current buffer by `:CocList snippets`.\n\n## Python support\n\nUltisnips provider needs pythonx support on (neo)vim, to check the feature exists,\ntry:\n\n```vim\n:echo has('pythonx')\n```\n\nOn neovim, run command:\n\n```vim\n:checkhealth\n```\nIf it is not installed, run:\n```shell\npip install pynvim\n```\n\nand make sure you have Python 3 provider for neovim installed.\n\nOn vim8, run command:\n\n```vim\n:pyx print(1)\n```\n\nin your vim, if it throws, it means your vim is not compiled with python support\nor the python dynamic lib required by vim is missing(or broken).\n\n**Note:** some python code may require python feature that not supported by the\npython interpreter used by vim, error will throw on that case.\n\n~Error will be shown when `pythonx` with (neo)vim can't work, fix `pythonx`\nsupport or disable ultisnips support by add `\"snippets.ultisnips.enable\": false`\nin your configuration file.~\n\n## Install\n\nIn your vim/neovim, run command:\n\n```\n:CocInstall coc-snippets\n```\n\n## Examples\n\n```vim\n\" Use \u003cC-l\u003e for trigger snippet expand.\nimap \u003cC-l\u003e \u003cPlug\u003e(coc-snippets-expand)\n\n\" Use \u003cC-j\u003e for select text for visual placeholder of snippet.\nvmap \u003cC-j\u003e \u003cPlug\u003e(coc-snippets-select)\n\n\" Use \u003cC-j\u003e for jump to next placeholder, it's default of coc.nvim\nlet g:coc_snippet_next = '\u003cc-j\u003e'\n\n\" Use \u003cC-k\u003e for jump to previous placeholder, it's default of coc.nvim\nlet g:coc_snippet_prev = '\u003cc-k\u003e'\n\n\" Use \u003cC-j\u003e for both expand and jump (make expand higher priority.)\nimap \u003cC-j\u003e \u003cPlug\u003e(coc-snippets-expand-jump)\n\n\" Use \u003cleader\u003ex for convert visual selected code to snippet\nxmap \u003cleader\u003ex  \u003cPlug\u003e(coc-convert-snippet)\n```\n\nMake `\u003ctab\u003e` used for trigger completion, completion confirm, snippet expand and jump like VSCode.\n\n**Note** from coc.nvim 0.0.82, functions starts with `coc#pum` should be used for\ncustom completion of coc.nvim.\n\n```vim\ninoremap \u003csilent\u003e\u003cexpr\u003e \u003cTAB\u003e\n      \\ coc#pum#visible() ? coc#_select_confirm() :\n      \\ coc#expandableOrJumpable() ? \"\\\u003cC-r\u003e=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\\\u003cCR\u003e\" :\n      \\ CheckBackspace() ? \"\\\u003cTAB\u003e\" :\n      \\ coc#refresh()\n\nfunction! CheckBackspace() abort\n  let col = col('.') - 1\n  return !col || getline('.')[col - 1]  =~# '\\s'\nendfunction\n\nlet g:coc_snippet_next = '\u003ctab\u003e'\n```\n\n## Ultisnips features\n\nSome ultisnips features are **not** supported:\n\n- [x] Position check of trigger option, including `b`, `w` and `i`.\n- [x] Execute vim, python and shell code in snippet.\n- [x] `extends`, `priority` and `clearsnippets` command in snippet file.\n- [x] Visual placeholder.\n- [x] Placeholder and variable transform.\n- [x] Expression snippet.\n- [x] Automatic trigger snippet.\n- [x] Context snippets.\n- [x] Support loading snipmate snippets.\n- [x] Replacement String, (:h UltiSnips-replacement-string), requires latest coc.nvim.\n- [x] Update python code block after change of placeholder.\n- [ ] Execute shell code with custom shabang (will not support).\n- [x] Option `m`, trim all whitespaces from right side of snippet lines.\n- [x] Reformat snippet options, including `t`, `s`.\n- [x] All snippet actions including `pre_expand`, `post_expand` and `jump` (can't support).\n- [x] `snip.expand_anon()` and other properties with UltiSnips actions.\n\n**Note**: `snip.expand_anon` expand the snippet in async manner by use timer\nwhen used with `pre_expand` and `post_expand` action, which means the state is\nlost in your python script (should only happens on some rare cases).\n\n**Note**: python regex in snippet are converted to javascript regex, however,\nsome regex patterns can't be supported by javascript, including\n`(?x)` `(?s)` `\\Z` `(?(id/name)yes-pattern|no-pattern)`.\n\n## Functions\n\n- `coc#expandable()` return `1` when can do snippet expand.\n- `coc#jumpable()` return `1` when snippet activated and can jump to next placeholder.\n- `coc#expandableOrJumpable()` return `1` when can do snippet expand or can jump\n  to next placeholder.\n\n## Key-mappings\n\n**Note** you can't use `noremap` with `\u003cPlug\u003e` key-mappings.\n\n- `\u003cPlug\u003e(coc-convert-snippet)` Create new snippet with current selected text,\n  visual mode only.\n- `\u003cPlug\u003e(coc-snippets-expand)` Expand snippet with current inserted text,\n  insert mode only.\n- `\u003cPlug\u003e(coc-snippets-expand-async)` None block variant of\n`\u003cPlug\u003e(coc-snippets-expand)`.\n- `\u003cPlug\u003e(coc-snippets-expand-jump)` Expand snippet or jump to next placeholder\n  of current snippet when possible, insert mode only.\n- `\u003cPlug\u003e(coc-snippets-expand-jump-async)` None block variant of\n`\u003cPlug\u003e(coc-snippets-expand-jump)`.\n- `\u003cPlug\u003e(coc-snippets-select)` Remove selected text and save to\n  `g:coc_selected_text` which will replace `$VISUAL` on next snippet expand.\n\n## Commands\n\n- Use `:CocList snippets` to open snippets list used by current buffer, the last\n  used snippet item would be preselected.\n- Use `:CocCommand snippets.openSnippetFiles` to choose and open a snippet file\n  that used by current document.\n- Use `:CocCommand snippets.editSnippets` to edit user's ultisnips snippets of\n  current document filetype.\n- Use `:CocCommand snippets.openOutput` to open output channel of snippets.\n- Use `:CocCommand snippets.addFiletypes` to add additional filetypes of current\n  buffer.\n\nUse `b:coc_snippets_filetypes` to add additional filetypes on buffer create.\n\n## Options\n\n- `snippets.priority`: Completion source priority of snippets.  Default: `90`\n- `snippets.editSnippetsCommand`: Open command used for snippets.editSnippets command, use coc.preferences.jumpCommand by default.  Default: `\"\"`\n- `snippets.trace`: Trace level of snippets channel, used for textmate snippets only.  Default: `\"error\"`\n    Valid options: [\"error\",\"verbose\"]\n- `snippets.excludePatterns`: List of minimatch patterns for filepath to exclude, support expand homedir and environment variables.  Default: `[]`\n- `snippets.loadFromExtensions`: Enable load snippets from extensions.  Default: `true`\n- `snippets.textmateSnippetsRoots`: List of directories that contains textmate/VSCode snippets to load.  Default: `[]`\n- `snippets.loadVSCodeProjectSnippets`: Load code snippets in folder ${workspaceFolder}/.vscode  Default: `true`\n- `snippets.extends`: Configure filetypes to inherit with, ex: {\"cpp\": [\"c\"], \"javascriptreact\": [\"javascript\"]}  Default: `{}`\n- `snippets.userSnippetsDirectory`: Directory that contains custom user ultisnips snippets, use ultisnips in extension root of coc.nvim by default.  Default: `\"\"`\n- `snippets.shortcut`: Shortcut in completion menu.  Default: `\"S\"`\n- `snippets.triggerCharacters`: Trigger characters for trigger snippets completion.  Default: `[]`\n- `snippets.disableSyntaxes`: Disable snippets completion when syntax name matches one of disabled syntaxes.  Default: `[]`\n- `snippets.execContext`: Execute a snippet's context (if it exists) to check if the snippet should be shown in completion menu  Default: `false`\n- `snippets.autoTrigger`: Enable trigger auto trigger snippet after type character.  Default: `true`\n- `snippets.ultisnips.enable`: Enable load snippets from ultisnips folders.  Default: `true`\n- `snippets.ultisnips.pythonPrompt`: Show prompt for user when python not supported on vim.  Default: `true`\n- `snippets.ultisnips.trace`: Trace verbose snippet information.  Default: `false`\n- `snippets.ultisnips.directories`: Directories that searched for ultisnips snippet files, could be directory as subfolder in $runtimepath or absolute paths.  Default: `[\"UltiSnips\"]`\n- `snippets.massCode.enable`: Enable load snippets from MassCode.  Default: `false`\n- `snippets.massCode.host`: Http host of MassCode.  Default: `\"localhost\"`\n- `snippets.massCode.port`: Http port of MassCode.  Default: `3033`\n- `snippets.massCode.trace`: Trace verbose snippet information.  Default: `false`\n- `snippets.snipmate.enable`: Load snipmate snippets from snippets directory in runtimepath.  Default: `true`\n- `snippets.snipmate.trace`: Trace verbose snippet information.  Default: `false`\n- `snippets.snipmate.author`: Author name used for g:snips_author  Default: `\"\"`\n## F.A.Q\n\n**Q:** How to add snippet filetypes on buffer create?\n\n**A:** Use autocmd like: `autocmd BufRead *.md let b:coc_snippets_filetypes = ['tex']`\n\n**Q:** How to trigger snippets completion when type special characters?\n\n**A:** Use configuration like: `\"snippets.triggerCharacters\": [\"'\"]`.\n\n**Q:** How to check if a snippet successfully loaded?\n\n**A:** Use command `:CocCommand workspace.showOutput snippets`\n\n**Q:** Some ultisnips snippet not works as expected.\n\n**A:** Reformat after change of placeholder feature can't be supported for now,\nand some regex pattern can't be converted to javascript regex pattern, so the\nsnippet can be failed to load.\n\n**Q:** Where to get snippets?\n\n**A:** One solution is install [honza/vim-snippets](https://github.com/honza/vim-snippets) which is widely used.\nTo create snippets yourself:\n\n- For Ultisnips, create `${filetype}.snippets` in `\"snippets.ultisnips.directories\"`\n- For snipmate snippets, create `${filetype}.snippets` in `snippets` folder\n  under your vim's `runtimepath`.\n- For VSCode snippets, create `${filetype}.json` in your `\"snippets.textmateSnippetsRoots\"`.\n\n**Q:** Get error message `ModuleNotFoundError: No module named 'vimsnippets'`\n\n**A:** Make sure [honza/vim-snippets](https://github.com/honza/vim-snippets) in\nyour vim's `\u0026runtimepath`.\n\n**Q:** Do I need to install [Ultisnips](https://github.com/SirVer/ultisnips).\n\n**A:** No! This extension is designed to work with or without Ultisnips, you can\nstill install Ultisnips, but this extension would not run any code or read\nconfiguration from it.\n\n**Q:** How to check jumpable or expandable at current position.\n\n**A:** Use functions provided by coc.nvim: `coc#expandable()` `coc#jumpable()` and `coc#expandableOrJumpable()`.\n\n**Q:** How could I add custom UltiSnips snippets.\n\n**A:** You can create snippet files in folder: `$VIMCONFIG/coc/ultisnips`, use\ncommand `:CocCommand snippets.editSnippets` to open user snippet of current\nfiletype.\n\n## Supporting\n\nIf you like this extension, consider supporting me on Patreon or PayPal:\n\n\u003ca href=\"https://www.patreon.com/chemzqm\"\u003e\u003cimg src=\"https://c5.patreon.com/external/logo/become_a_patron_button.png\" alt=\"Patreon donate button\" /\u003e \u003c/a\u003e\n\u003ca href=\"https://www.paypal.com/paypalme/chezqm\"\u003e\u003cimg src=\"https://werwolv.net/assets/paypal_banner.png\" alt=\"PayPal donate button\" /\u003e \u003c/a\u003e\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneoclide%2Fcoc-snippets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneoclide%2Fcoc-snippets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneoclide%2Fcoc-snippets/lists"}