Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve documentation with examples. #7

Open
monoira opened this issue May 20, 2024 · 12 comments
Open

improve documentation with examples. #7

monoira opened this issue May 20, 2024 · 12 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@monoira
Copy link

monoira commented May 20, 2024

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
Copy link
Contributor

@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
Copy link
Owner

garymjr commented May 24, 2024

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

@garymjr garymjr added documentation Improvements or additions to documentation good first issue Good for newcomers labels May 24, 2024
@Mr-LLLLL
Copy link

not worked according README setting

@kevinm6
Copy link

kevinm6 commented May 29, 2024

@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
Copy link

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

@kevinm6
Copy link

kevinm6 commented May 30, 2024

@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
Copy link

towry commented May 30, 2024

@Mr-LLLLL
Copy link

@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
Copy link

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

@monoira
Copy link
Author

monoira commented Oct 10, 2024

Documentation is still not good enough for this plugin to count as drop-in-replacement for luasnip for me.
I am still on lazyvim + luasnip. I want to change luasnip for this if it's possible to use custom vscode snippets with this plugin but currently it's all way too complicated as a drop-in-replacement for luasnip.
Maybe someone will make video or something about going from lazyVim + luasnip to lazyVim + nvim-snippets,
But until then I have to stick around with luaSnip.

@przepompownia
Copy link

przepompownia commented Oct 20, 2024

none-ls users can add such source:

local none = require('null-ls')

local nvimSnippets = {
  name = 'nvim_snippets',
  method = none.methods.COMPLETION,
  filetypes = {},
  generator = {
    fn = function (params, done)
      local items = {}
      local snips = require('snippets').get_loaded_snippets()
      local targets = vim.tbl_filter(function (item)
        return string.match(item.prefix, '^' .. params.word_to_complete)
      end, snips)
      for _, item in ipairs(targets) do
        table.insert(items, {
          label = item.prefix,
          kind = vim.lsp.protocol.CompletionItemKind.Snippet,
          insertTextFormat = vim.lsp.protocol.InsertTextFormat.Snippet,
          detail = item.description,
          insertText = (type(item.body) == 'table') and table.concat(item.body, '\n') or item.body,
          insertTextMode = 2,
        })
      end
      done({{items = items, isIncomplete = #items == 0}})
    end,
    async = true,
  },
}

none.register(nvimSnippets)

(based on vsnip source distributed with the plugin).

@przepompownia
Copy link

I converted it into completion source nvimtools/none-ls.nvim#201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

9 participants