frozolotl / tree-sitter-typst

A tree-sitter grammar for the typst typesetting language with a focus on correctness
European Union Public License 1.2
76 stars 3 forks source link

neovim supporting #2

Closed ayoubelmhamdi closed 1 year ago

ayoubelmhamdi commented 1 year ago

Try to useit in neovim but not work

    local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
    parser_config.typst = {
      install_info = {
        url = '/data/github/tree-sitter-typst',
        files = { 'src/parser.c' },
        branch = 'main',
      },
      filetype = 'typst', -- if filetype does not agrees with parser name
    }

it is should be in the path like:

queries/{language}/{locals,highlights,textobjects}.scm
ln -s /data/github/tree-sitter-typst/queries/highlights.scm \
    ~/.config/nvim/after/plugin
Error executing lua callback: Failed to load parser for language 'typst': uv_dlopen: /home/mhamdi/.local/share/nvim/lazy/nv
im-treesitter/parser/typst.so: undefined symbol: tree_sitter_typst_external_scanner_create
stack traceback:
        [C]: in function '_ts_add_language'
        /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:99: in function 'add'
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:85: in function 'new'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:61: in function '_create_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:131: in function 'get_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:469: in function 'start'
        ...m/lazy/nvim-treesitter/lua/nvim-treesitter/highlight.lua:20: in function 'attach'
        ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:509: in function 'attach_module'
        ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:532: in function 'reattach_module'
        ...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:133: in function <...vim/lazy/nvim-treesitter/lua/nvim-
treesitter/configs.lua:132>
Slickytail commented 1 year ago

You need to include the scanner file: files = { 'src/parser.c' , 'src/scanner.cc'},

ayoubelmhamdi commented 1 year ago

the error is gone, but there no highlighting

slashformotion commented 1 year ago

works on helix, try with the latest commit

ayoubelmhamdi commented 1 year ago

yah it work, the problem is come from my colorscheme that not detected it, because it is detected by Playground plugins, i will try to override my theme or using some tree-sitter query to make the typst query understand by Any theme.

frozolotl commented 1 year ago

I previously did not close it because it showed not yet correct parsing of code.

Now I'm closing this issue because I think that would be better served by a separate issue if necessary.

peng1999 commented 9 months ago

i will try to override my theme or using some tree-sitter query to make the typst query understand by Any theme.

@ayoubelmhamdi Did you make the query that understands by nvim theme? Could you please open source the query file somewhere?

TheZoq2 commented 6 months ago

Now that nvim-treesitter more closely aligns with the helix highlight groups https://github.com/nvim-treesitter/nvim-treesitter/commit/1ae9b0e4558fe7868f8cda2db65239cfb14836d0, this works almost out of the box with neovim

However, as pointed out in the initial message in this issue, neovim assumes queries to be in queries/typst/{highlight,indent}.scm rather than just queries/{highlights,indent}.scm

Since the helix workflow in the readme relies on symlinking these things anyway, would you be open to moving the files to make use with nvim easier. In my fork where I made this move, the installation is as easy as

Plug 'https://github.com/TheZoq2/tree-sitter-typst'
require'nvim-treesitter.install'.prefer_git = true
parser_config.typst = {
  install_info = {
    url = "https://github.com/frozolotl/tree-sitter-typst.git", -- local path or git repo
    files = {"src/parser.c", "src/scanner.cc"},
  },
  filetype = "typst", -- if filetype does not match the parser name
}
frozolotl commented 6 months ago

Since the helix workflow in the readme relies on symlinking these things anyway, would you be open to moving the files to make use with nvim easier. In my fork where I made this move, the installation is as easy as

That sounds like a great idea! Since you already did the work, would you be willig to create a pull request?