tsnip.nvim
Plugin to expand snippets written in Pure TypeScript(Deno).
This plugin depends on denops.vim.
Demo
tsnip_demo.mp4
Installation
Required
Usage
Can be used with coc.nvim or
ddc.vim. Place the snippet file in
~/.vim/tsnip/{filetype}.ts
.
coc.nvim
:CocInstall coc-tsnip
ddc.nvim
call ddc#custom#patch_global('sources', ['tsnip'])
Example
~/.vim/tsnip/typescriptreact.ts
import { Snippet } from "https://deno.land/x/[email protected]/mod.ts";
export const state: Snippet = {
name: "useState",
text: "const [${1:state}, set${State}] = useState(${2:default_value})",
params: [
{
name: "state",
type: "single_line",
},
{
name: "default_value",
type: "single_line",
},
],
render: ({ state, default_value }) =>
`const [${state?.text ?? ""}, set${
state != null
? `${state.text?.charAt(0).toUpperCase()}${state.text?.slice(1)}`
: ""
}] = useState(${default_value?.text ?? ""})`,
};