Get_parser function does open the buffer

Hello, I’m one of the core developers of Neorg, and I’m primarily focused on integrating a task management workflow called GTD (getting things done) in Neorg.

I already have created some views to nicely display tasks and projects, which are being fetched from different .norg (our custom filetype) buffers in some directory.

In the process of parsing the files to extract informations, I do these steps (for each file):

  1. Get file uri with vim.uri_from_fname()
  2. Get buffer with vim.uri_to_bufnr()
  3. Get the file AST with vim.treesitter.get_parser(bufnr, "norg")

It seems that the get_parser function does open the buffer (in background), causing me to receive messages like these:

But more importantly, I’m worried for performance issues, because our plugin does some icon concealing when a buffer is opened.

Is it possible to get the AST without opening the buffers ?

This is how I do it in orgmode.nvim. This parses the tree with the buffer content, which I previously read either via fs or nvim_buf_get_lines.

2 Likes

Helo @kristijanhusak, thanks a lot for your response.
I’m sorry for not having answered quickly, and I just want you to know that I used your suggestion for Neorg GTD.
I hope you’re doing well,

Cheers,
Danymat.

1 Like