bamonroe / rnoweb-nvim

A neovim plugin for rnoweb files
MIT License
19 stars 3 forks source link

Errors with `superscript` and `subscript` queries. #5

Closed v3natio closed 3 months ago

v3natio commented 3 months ago

Recently, after updating tree-sitter, I've been getting the following error.

Error detected while processing CursorHold Autocommands for "*.tex":
Error executing lua callback: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:252: Query error at 2:7. Impossible pattern:
      (word) @tval (#set! @tval "kind" "superscript")
      ^

stack traceback:
        [C]: in function '_ts_parse_query'
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:252: in function 'fn'
        /usr/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'parse'
        /home/venatio/rnoweb-nvim/lua/rnoweb-nvim/symbols.lua:683: in function 'get_queries'
        /home/venatio/rnoweb-nvim/lua/rnoweb-nvim/init.lua:122: in function 'fn'
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:491: in function 'for_each_tree'
        /home/venatio/rnoweb-nvim/lua/rnoweb-nvim/init.lua:118: in function 'mask_texsym'
        /home/venatio/rnoweb-nvim/lua/rnoweb-nvim/init.lua:152: in function 'refresh'
        /home/venatio/rnoweb-nvim/plugin/init.lua:27: in function </home/venatio/rnoweb-nvim/plugin/init.lua:22>

So the two offending queries are:

table.insert(M.queries.latex, {
  fn = "subsuper",
  query = [[
    (superscript
    (word) @tval (#set! @tval "kind" "superscript")
    )
  ]],
})

table.insert(M.queries.latex, {
  fn = "subsuper",
  query = [[
    (subscript
    (word) @tval (#set! @tval "kind" "subscript")
    )
  ]],
})

and if I replace them with a more general approach to match child nodes:

table.insert(M.queries.latex, {
  fn = "subsuper",
  query = [[
    (superscript
    (_) @tval
    (#set! @tval "kind" "superscript")
    )
  ]],
})

table.insert(M.queries.latex, {
  fn = "subsuper",
  query = [[
    (subscript
    (_) @tval
    (#set! @tval "kind" "subscript")
    )
  ]],
})

I haven't noticed any difference with using this new pattern match, to the previous one (before the errors), but perhaps that's due to the use I've given them.

Feel free to let me know if this is an isolated issue on my part, otherwise I'll gladly introduce a PR.

bamonroe commented 3 months ago

Thanks for the issue report! Please do open a pull request. I'll be able to test it in a few other environments easily. If I don't find any conflicts I'll merge it in.

v3natio commented 3 months ago

Fixed with #6