-
Notifications
You must be signed in to change notification settings - Fork 11
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
'org-roam-node-buffer' is not a valid language name #49
Comments
Fixes chipsenkbeil/org-roam.nvim#49 Org-roam offers a "node buffer", a sidebar that shows information such as backlinks from other locations to the current headline/file. The node buffer allows previewing the location of such a backlink. This inserts orgmode syntax into a buffer with filetype `org-roam-node-buffer`. If virtual indent is enabled, it'll attempt to deduce the virtual indent of the preview. This in turn calls `closest_headline_node()`, which in turn calls `get_node_at_cursor`, which in turn calls `vim.treesitter.get_node()`. If `get_node()` is called without an explicit treesitter language, it'll attempt to deduce that language from the filetype. The filetype `org-roam-node-buffer` isn't associated with the `org` language (and I don't think it *should*), so this call fails. This fixes the issue by explicitly passing `{ lang = 'org' }` in all instances where the language *may* be deduced. I think this is acceptable because if someone calls `orgmode.utils.treesitter.get_node()` AFAIK is only ever called on text that is org syntax. While making this change, I grepped for other treesitter calls with an optional language argument. Where I found them, I passed it explicitly as well. AFAICT, this is only `Stars:on_line()` and `ts_utils.restart_highlighting()`.
Fixes chipsenkbeil/org-roam.nvim#49 Org-roam offers a "node buffer", a sidebar that shows information such as backlinks from other locations to the current headline/file. The node buffer allows previewing the location of such a backlink. This inserts orgmode syntax into a buffer with filetype `org-roam-node-buffer`. If virtual indent is enabled, it'll attempt to deduce the virtual indent of the preview. This in turn calls `closest_headline_node()`, which in turn calls `get_node_at_cursor`, which in turn calls `vim.treesitter.get_node()`. If `get_node()` is called without an explicit treesitter language, it'll attempt to deduce that language from the filetype. The filetype `org-roam-node-buffer` isn't associated with the `org` language (and I don't think it *should*), so this call fails. This fixes the issue by explicitly passing `{ lang = 'org' }` in all instances where the language *may* be deduced. I think this is acceptable because if someone calls `orgmode.utils.treesitter.get_node()` AFAIK is only ever called on text that is org syntax. While making this change, I grepped for other treesitter calls with an optional language argument. Where I found them, I passed it explicitly as well. AFAICT, this is only `Stars:on_line()` and `ts_utils.restart_highlighting()`.
The problem seems to be this line: https://github.com/nvim-orgmode/orgmode/blob/e365b85b4a5bfea507d77a16a7b66d8c6860e9b7/lua/orgmode/utils/treesitter/init.lua#L21: function M.get_node_at_cursor(cursor)
M.parse_current_file()
if not cursor then
return vim.treesitter.get_node()
end
return vim.treesitter.get_node({
bufnr = 0,
pos = { cursor[1] - 1, cursor[2] },
})
end where orgmode calls The way I see it, there are two ways to fix this:
Personally, I think the first option makes more sense. I've submitted nvim-orgmode/orgmode#795 so if and when that PR is accepted, this should work without updates to org-roam itself. |
Fixes chipsenkbeil/org-roam.nvim#49 Org-roam offers a "node buffer", a sidebar that shows information such as backlinks from other locations to the current headline/file. The node buffer allows previewing the location of such a backlink. This inserts orgmode syntax into a buffer with filetype `org-roam-node-buffer`. If virtual indent is enabled, it'll attempt to deduce the virtual indent of the preview. This in turn calls `closest_headline_node()`, which in turn calls `get_node_at_cursor`, which in turn calls `vim.treesitter.get_node()`. If `get_node()` is called without an explicit treesitter language, it'll attempt to deduce that language from the filetype. The filetype `org-roam-node-buffer` isn't associated with the `org` language (and I don't think it *should*), so this call fails. This fixes the issue by explicitly passing `{ lang = 'org' }` in all instances where the language *may* be deduced. I think this is acceptable because if someone calls `orgmode.utils.treesitter.get_node()` AFAIK is only ever called on text that is org syntax. While making this change, I grepped for other treesitter calls with an optional language argument. Where I found them, I passed it explicitly as well. AFAICT, this is only `Stars:on_line()` and `ts_utils.restart_highlighting()`.
Fixes chipsenkbeil/org-roam.nvim#49 Org-roam offers a "node buffer", a sidebar that shows information such as backlinks from other locations to the current headline/file. The node buffer allows previewing the location of such a backlink. This inserts orgmode syntax into a buffer with filetype `org-roam-node-buffer`. If virtual indent is enabled, it'll attempt to deduce the virtual indent of the preview. This in turn calls `closest_headline_node()`, which in turn calls `get_node_at_cursor`, which in turn calls `vim.treesitter.get_node()`. If `get_node()` is called without an explicit treesitter language, it'll attempt to deduce that language from the filetype. The filetype `org-roam-node-buffer` isn't associated with the `org` language (and I don't think it *should*), so this call fails. This fixes the issue by explicitly passing `{ lang = 'org' }` in all instances where the language *may* be deduced. I think this is acceptable because if someone calls `orgmode.utils.treesitter.get_node()` AFAIK is only ever called on text that is org syntax. While making this change, I grepped for other treesitter calls with an optional language argument. Where I found them, I passed it explicitly as well. AFAICT, this is only `Stars:on_line()` and `ts_utils.restart_highlighting()`. Co-authored-by: troiganto <troiganto@proton.me>
The fix just got merged, so the error should no longer appear after an update! |
Can confirm that as of nvim-orgmode/orgmode@56c8246, this has been fixed. Thanks @troiganto for getting this resolved upstream! |
Encountered in neovim 0.10 when attempting to expand a backlink. Must be something I missed when adding support for neovim 0.10. I'm assuming they changed how creating a parser works. I'm assuming that I'm setting the filetype to this somewhere, and neovim is trying to do virtual identation, a feature new to neovim 0.10 that I have enabled. Not sure why it's happening for a non-org buffer, though.
The text was updated successfully, but these errors were encountered: