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

LuaSnip Source Cache Is Not Cleared When Snippets Are Updated #662

Closed
2 tasks done
Sahas-Ananth opened this issue Dec 19, 2024 · 2 comments · Fixed by #664
Closed
2 tasks done

LuaSnip Source Cache Is Not Cleared When Snippets Are Updated #662

Sahas-Ananth opened this issue Dec 19, 2024 · 2 comments · Fixed by #664
Labels
bug Something isn't working

Comments

@Sahas-Ananth
Copy link
Contributor

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

Currently, when LuaSnippets are added or modified in their respective files, the internal cache of the luasnip source is not automatically cleared. This necessitates either a manual call to the API's reload function or a full Neovim restart to reflect the updated snippets. This behavior disrupts workflow and reduces usability.

LuaSnip provides the following events:

  • LuasnipSnippetsAdded: Triggered when snippets are added or modified.
  • LuasnipCleanup: Triggered when all snippets need to be cleared.

However, the cache is not automatically refreshed upon emitting these events, which prevents users from seeing updated snippets.

While related issues (#603 and #615) have discussed this problem, the existing fix still requires manual intervention or a restart, which does not fully resolve the issue.

I have addressed this issue in my fork. If you're interested, I can submit a PR with the fix.

Relevant configuration

{
  'saghen/blink.cmp',
  version = 'v0.*',
  -- !Important! Make sure you're using the latest release of LuaSnip
  -- `main` does not work at the moment
  dependencies = { 'L3MON4D3/LuaSnip', version = 'v2.*' },
  opts = {
    snippets = {
      expand = function(snippet) require('luasnip').lsp_expand(snippet) end,
      active = function(filter)
        if filter and filter.direction then
          return require('luasnip').jumpable(filter.direction)
        end
        return require('luasnip').in_snippet()
      end,
      jump = function(direction) require('luasnip').jump(direction) end,
    },
    sources = {
      default = { 'lsp', 'path', 'luasnip', 'buffer' },
    },
  }
}

neovim version

v0.10.1

blink.cmp version: branch, tag, or commit

Branch: main, Commit: 07665c3

@Sahas-Ananth Sahas-Ananth added the bug Something isn't working label Dec 19, 2024
@Saghen
Copy link
Owner

Saghen commented Dec 19, 2024

Pr would be great, thanks!

@Sahas-Ananth
Copy link
Contributor Author

Sahas-Ananth commented Dec 19, 2024

Great just made PR #664 check it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants