garymjr / nvim-snippets

Snippet support using native neovim snippets
MIT License
215 stars 13 forks source link

feature: expand or jump #43

Open saifulapm opened 2 months ago

saifulapm commented 2 months ago

Hi, In Luasnip, I prefer using <C-j> and <C-k> for snippet expanding/jumping. But here We can only jump if snippet already expanded. I didn't find anything that can solve my problem.

If I don't use cmp then how we can expand snippet ?

If req is a snippet for require() then after typing req then If I press , it should expand snippet.

This is the pull request what I have added in my nvim config. May be I was wrong. May be there is a better way to do this. I am new in Neovim. Sorry If I make something wrong.

Here is my <C-j> and <C-k> mapping.

vim.keymap.set({ "i", "s" }, "<C-j>", function()
  require("snippets").expand_or_jump()
end, { desc = "Snippet Expand/Jump Next" })

vim.keymap.set({ "i", "s" }, "<C-k>", function()
  if vim.snippet.active({ direction = -1 }) then
    vim.schedule(function()
      vim.snippet.jump(-1)
    end)
  end
end, { desc = "Snippet Jump Prev" })

Just add this feature if it's missing.

Thanks