garymjr / nvim-snippets

Snippet support using native neovim snippets
MIT License
193 stars 14 forks source link

improve documentation with examples. #7

Open monoira opened 2 months ago

monoira commented 2 months ago

setting up this plugin with custom vscode snippets is way too hard for me. documentation is way too small and not noobie-friendly.

I have to go back to luasnip until documentation becomes better.

chrisgrieser commented 2 months ago

@monoira The readme of nvim-scissors has an intro into how to use vscode snippets which you might find helpful: https://github.com/chrisgrieser/nvim-scissors?tab=readme-ov-file#example-for-the-vscode-style-snippet-format

garymjr commented 2 months ago

I do need to spend some time adding/improving documentation. I'll try to find some time this weekend to start working on this.

Mr-LLLLL commented 2 months ago

not worked according README setting

kevinm6 commented 1 month ago

@monoira and @Mr-LLLLL , you could take a look into my config, especially the snippet expansion and the config for nvim-snippets to make it works.

It should be pretty straightforward, even if I’m using a personal fork of friendly-snippets.

The expansion should be this or equivalent with Lazy.nvim

{
  "hrsh7th/nvim-cmp",
  event = { "InsertEnter", "CmdlineEnter" },
  opts = function(_, o)
    o.snippet = {
      expand = function(args)
        vim.snippet.expand(args.body)
      end,
    }
    -- other opts
}

and the config for nvim-snippets similar to

{
  "garymjr/nvim-snippets",
  event = "InsertEnter",
  -- this is for a custom fork of friendly-snippets located in `dev` folder (check Lazy.nvim for docs)
  dependencies = { "kevinm6/snippets", dev = true },
  opts = function(_, o)
    o.extended_filetypes = {
      typescript = { "javascript", "tsdoc” },
      javascript = { "jsdoc” },
      html = { "css", "javascript” },
      lua = { "luadoc” },
      python = { "python-docstring” },
      java = { "javadoc", "java-testing” },
      sh = { "shelldoc” },
      php = { "phpdoc” },
      ruby = { "rdoc” },
      quarto = { "markdown” },
      rmarkdown = { "markdown” },
    }
    -- location used to find `package.json` or snippets with valid file/folder structure
    o.search_paths = { vim.env.HOME .. "/dev/snippets" }

    -- other opts
}
ChillerDragon commented 1 month ago

@kevinm6 you can press Y on github to get a permanent link. Yours are 404 already after 14 hours :c

kevinm6 commented 1 month ago

@kevinm6 you can press Y on github to get a permanent link. Yours are 404 already after 14 hours :c

I did, but I was on mobile and I pasted the wrong link..! Try now

towry commented 1 month ago

Here is an usage example with fzf-lua (without nvim-cmp):

<c-x><c-e> to trigger the picker:

https://github.com/towry/nvim/blob/e0dc02c216467bf0609024ba8c60501003daf087/lua/user/plugins/finder.lua#L903

https://github.com/towry/nvim/blob/e0dc02c216467bf0609024ba8c60501003daf087/lua/userlib/snippets/init.lua#L32

https://github.com/garymjr/nvim-snippets/assets/8279858/f612dd95-5efc-403f-b36a-4612319d94cd

Mr-LLLLL commented 1 month ago

@monoira and @Mr-LLLLL , you could take a look into my config, especially the snippet expansion and the config for nvim-snippets to make it works.

It should be pretty straightforward, even if I’m using a personal fork of friendly-snippets.

The expansion should be this or equivalent with Lazy.nvim

{
  "hrsh7th/nvim-cmp”,
  event = { "InsertEnter", "CmdlineEnter” },
  opts = function(_, o)
    o.snippet = {
      expand = function(args)
        vim.snippet.expand(args.body)
      end,
    }
    -- other opts
}

and the config for nvim-snippets similar to

{
  "garymjr/nvim-snippets”,
  event = “InsertEnter”,
  -- this is for a custom fork of friendly-snippets located in `dev` folder (check Lazy.nvim for docs)
  dependencies = { "kevinm6/snippets", dev = true },
  opts = function(_, o)
    o.extended_filetypes = {
      typescript = { "javascript", "tsdoc” },
      javascript = { "jsdoc” },
      html = { "css", "javascript” },
      lua = { "luadoc” },
      python = { "python-docstring” },
      java = { "javadoc", "java-testing” },
      sh = { "shelldoc” },
      php = { "phpdoc” },
      ruby = { "rdoc” },
      quarto = { "markdown” },
      rmarkdown = { "markdown” },
    }
    -- location used to find `package.json` or snippets with valid file/folder structure
    o.search_paths = { vim.env.HOME .. "/dev/snippets” } -- location used to find `package.json` or snippets with valid file/folder structure

    -- other opts
}

thank you very much. it worked.

aymericderazey commented 1 month ago

Does someone has an exemple on how to use this plugin with user defined snippets for Typescript ? Thank you.