garymjr / nvim-snippets

Snippet support using native neovim snippets
MIT License
239 stars 15 forks source link

No idea how to get this to work #54

Open baronyoung opened 2 months ago

baronyoung commented 2 months ago

The readme has this: { "Say hello to the world": { "prefix": ["hw", "hello"], "body": "Hello, ${1:world}!$0" } }

Where does this go? A file in ~/.config/nvim/lua/config/snippets? What's the filename? Is that all that goes in the file? I'm using a mostly vanilla lazyVim setup and this plugin is included.

zmunk commented 2 months ago

+1

kevinm6 commented 2 months ago

@baronyoung , @zmunk

{
  "Say hello to the world": {
    "prefix": ["hw", "hello"],
    "body": "Hello, ${1:world}!$0"
  }
}

Where does this go? A file in ~/.config/nvim/lua/config/snippets? What's the filename? Is that all that goes in the file? I'm using a mostly vanilla lazyVim setup and this plugin is included.

Since it has support for Friendly Snippets, you could follow that structure or use also a package.json from #31 .

Example of package.json { “name”: “snippets”, “contributes”: { “snippets”: [ { “language”: [ “javascript”, “typescript" ], “path”: “./javascript.json" } } \n Here, two filetypes are associated to the same .json file

Basically the following structure should work (I’m using my own fork of friendly-snippets, so I didn’t tested it):

DIR: ~/.config/nvim/snippets/

~/.config/nvim/snippets/
    ├── global.json
    ├── markdown.json
    └── <filetype>.json

global.json or all.json are the ones loaded for every filetype, while markdown.json are snippets loaded on buffers that match the filetype.

You could have folders to split multiple snippets for the same filetype, like

~/.config/nvim/snippets/
    ├── global.json
    ├── markdown.json
    ├── <filetype>.json
    └── lua
         ├── lua.json
         ├── luadoc.json
         └── nvim_lua.json

where lua in this case is a folder with the specific snippets for it

vricop commented 1 week ago

I’m not able to make it work either. No matter what. I’m using Lazy package manager.

I’d like to remove luasnip and use this one. I’m only using LSP snippets features in luasnip.

@kevinm6 I saw your fork, I’ll try it later today. Thanks!