Commit 56c8246
authored
fix: explicitly pass treesitter language to
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>get_node() (#795)1 parent 7226791 commit 56c8246
File tree
3 files changed
+5
-3
lines changed- lua/orgmode
- colors/highlighter
- ui
- utils/treesitter
3 files changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
0 commit comments