Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuki-yano/tsnip.nvim
https://github.com/yuki-yano/tsnip.nvim
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yuki-yano/tsnip.nvim
- Owner: yuki-yano
- License: mit
- Created: 2022-01-23T03:46:34.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-10T07:59:04.000Z (about 1 year ago)
- Last Synced: 2024-10-15T18:44:08.225Z (2 months ago)
- Language: TypeScript
- Size: 33.2 KB
- Stars: 22
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tsnip.nvim
Plugin to expand snippets written in Pure TypeScript(Deno).
This plugin depends on [denops.vim](https://github.com/vim-denops/denops.vim).
## Demo
https://user-images.githubusercontent.com/5423775/150894287-0d17e966-7cab-4953-9b69-a8c54f511284.mp4
## Installation
### Required
- [denops.vim](https://github.com/vim-denops/denops.vim)
- [nui.nvim](https://github.com/MunifTanjim/nui.nvim) (optional: provides rich input UI)## Usage
Can be used with [coc.nvim](https://github.com/neoclide/coc.nvim) or
[ddc.vim](https://github.com/Shougo/ddc.vim). Place the snippet file in
`~/.vim/tsnip/{filetype}.ts`.### coc.nvim
```vim
:CocInstall coc-tsnip
```### ddc.nvim
```vim
call ddc#custom#patch_global('sources', ['tsnip'])
```## Example
`~/.vim/tsnip/typescriptreact.ts`
```typescript
import { Snippet } from "https://deno.land/x/[email protected]/mod.ts";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 ?? ""})`,
};export default {
state
}
```