fix: explicitly pass treesitter language to get_node()
#795
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 callsget_node_at_cursor
, which in turn callsvim.treesitter.get_node()
.If
get_node()
is called without an explicit treesitter language, it'll attempt to deduce that language from the filetype. The filetypeorg-roam-node-buffer
isn't associated with theorg
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 callsorgmode.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()
andts_utils.restart_highlighting()
.