Somehow marksman also does this?
As for treesitter (norg) it may be because treesitter includes the
newline and the next line indent until the next heading, so the line of
the next heading is included in the range of the previous heading. We
manually -1 on the range end line to fix it.
Closes#37
Almost completely refactored the UI parts outline.nvim to use a Sidebar
object that implements an outline window. In init.lua, we can then store
a table of the outline for each tabpage ID.
When tabs are closed the outline is closed and sidebar reset
responsibly.
This simplifies `init.lua` quite a lot, making it the highest level
control center for the outline elements.
All lua APIs and commands should work as before.
Closes#35
Previously the treesitter javascript parser would treat `<></>`
specially and emit a `jsx_fragment`. We were checking for this type here
(from symbols-outline.nvim), though we did not include `jsx_fragment` in
the parse_ts function to even look for it.
jsx_fragment was recently removed from treesitter parser to reduce
complexity, so we will treat all jsx_element's without a `name` field in
`jsx_opening_element` as the shorthand fragment.
Using "Fragment" as the name in this case makes it look exactly the same
as if the user used `<Fragment></Fragment>` instead.
The check for `jsx_fragment` is still kept in case an older version of
the parser is still used, it can probably be removed next year.
Ref:
- tree-sitter/tree-sitter-javascript#227
- Closes#3
- Ref: simrat39/symbols-outline.nvim#190
Norg contains indents and different types of verbatim tags, I was rather
lazy to read the spec properly and parse norg using regex line-by-line
like markdown, so used treesitter instead. The only requirement is the
`norg` parser for treesitter to be installed. Tested on nvim 0.7.2.
This should lead the way for supporting vimdoc files in a similar
manner.
Documentation for how external providers could look like as of now has
been added.
In the future we could let the provider determine what to do for each
keymap, such as `goto_location` and `toggle_preview`. This would allow
the zk extension[1] to work properly without having to override existing
functions (bad practice).
[1]: https://github.com/mickael-menu/zk-nvim/discussions/134
Option to auto unfold when there is only N root nodes in outline.
Defaults to 1, meaning if there is only one 'root' parent, it should
always be unfolded.
This is useful if the entire file is a single function or a single
'return'.
The old auto_unfold_hover option **still works as expected**.