quangnguyen30192 / cmp-nvim-ultisnips

nvim-cmp source for ultisnips
Apache License 2.0
144 stars 19 forks source link

Fix snippet doesnt work in comments or kdoc. #89

Closed chau-bao-long closed 1 year ago

chau-bao-long commented 1 year ago

https://github.com/quangnguyen30192/cmp-nvim-ultisnips/assets/20348662/27102f9d-6d89-472c-9233-f97e56a9c503

As you can see on the screen recording, event TextChangedI make snippet stop working in comment block or KDoc (in kotlin). I'm not sure about the root cause but my concern is whether we can remove this event from autocmd set filetype or not? @quangnguyen30192

quangnguyen30192 commented 1 year ago

I could not reproduce on my own. 😔 May you check whether any conflicts happen to TextChangedI event on your local config :verbose autocmd TextChangedI

With the feature of treesitter-aware snippets, we need TextChangedI event.

quangnguyen30192 commented 1 year ago

If you see you don't need treesitter-aware feature. You can just use the default one (snippets will be loaded by the filetype only)

require("cmp_nvim_ultisnips").setup {
  filetype_source = "ultisnips_default",
  show_snippets = "all",
  documentation = function(snippet)
    return snippet.description
  end
}

Then there's no autocmd setup. Refer to the docs for more info. Cheers

chau-bao-long commented 1 year ago

I could not reproduce on my own. 😔 May you check whether any conflicts happen to TextChangedI event on your local config :verbose autocmd TextChangedI

With the feature of treesitter-aware snippets, we need TextChangedI event.

Have you checked it with Kdoc? Here is my autocmd list

:verbose autocmd TextChangedI
--- Autocommands ---
UltiSnips_AutoTrigger  TextChangedI
    *         call UltiSnips#TrackChange()
        Last set from ~/.vim/plugged/ultisnips/plugin/UltiSnips.vim line 40
IndentBlanklineAutogroup  TextChangedI
    *         IndentBlanklineRefresh
        Last set from ~/.vim/plugged/indent-blankline.nvim/plugin/indent_blankline.vim line 36
matchparen  TextChangedI
    *         call s:Highlight_Matching_Pair()
        Last set from /opt/homebrew/Cellar/neovim/0.9.1/share/nvim/runtime/plugin/matchparen.vim line 25
___cmp___  TextChangedI
    *         <Lua 65: ~/.vim/plugged/nvim-cmp/lua/cmp/utils/autocmd.lua:22> [nvim-cmp: autocmd: TextChangedI]
        Last set from Lua
cmp_nvim_ultisnips  TextChangedI
    *         lua require("cmp_nvim_ultisnips.treesitter").set_filetype()
        Last set from ~/.vim/plugged/cmp-nvim-ultisnips/autoload/cmp_nvim_ultisnips.vim line 74
quangnguyen30192 commented 1 year ago

I've checked in Kdocs and had no issues. Here's my autocmd list on TextChangedI

___cmp___  TextChangedI
    *         <Lua 54: ~/.local/share/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/utils/autocmd.lua:22> [nvim-cmp: autocmd: TextChangedI]
        Last set from Lua line 23
CmpDebounceAuGroup  TextChangedI
    *         lua require('modules.completion.debounce').debounce()
        Last set from Lua line 23
UltiSnips_AutoTrigger  TextChangedI
    *         call UltiSnips#TrackChange()
        Last set from ~/dev/local/share/nvim/plugged/ultisnips/plugin/UltiSnips.vim line 40
IndentBlanklineAutogroup  TextChangedI
    *         IndentBlanklineRefresh
        Last set from ~/dev/local/share/nvim/site/pack/packer/start/indent-blankline.nvim/plugin/indent_blankline.vim line 36
cmp_nvim_ultisnips  TextChangedI
    *         lua require("cmp_nvim_ultisnips.treesitter").set_filetype()
        Last set from ~/dev/local/share/nvim/site/pack/packer/start/cmp-nvim-ultisnips/autoload/cmp_nvim_ultisnips.vim line 74