doc: rework documentation generation

This commit is contained in:
Steven Arcangeli 2022-10-21 12:26:47 -07:00
parent d67b06e80f
commit f5ecd1ee9d
12 changed files with 945 additions and 330 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
layout python

161
.github/generate.py vendored Executable file
View file

@ -0,0 +1,161 @@
import json
import os
import os.path
import re
import subprocess
from functools import lru_cache
from typing import List
from nvim_doc_tools import (
Command,
LuaParam,
Vimdoc,
VimdocSection,
commands_from_json,
dedent,
format_md_commands,
format_md_table,
format_vimdoc_commands,
generate_md_toc,
indent,
leftright,
parse_functions,
read_nvim_json,
read_section,
render_md_api,
render_vimdoc_api,
replace_section,
wrap,
)
HERE = os.path.dirname(__file__)
ROOT = os.path.abspath(os.path.join(HERE, os.path.pardir))
README = os.path.join(ROOT, "README.md")
DOC = os.path.join(ROOT, "doc")
VIMDOC = os.path.join(DOC, "aerial.txt")
def update_treesitter_languages():
languages = sorted(os.listdir(os.path.join(ROOT, "queries")))
language_lines = ["\n"] + [f"- {l}\n" for l in languages] + ["\n"]
replace_section(
README,
r"^\s*<summary>Supported treesitter languages",
r"^[^\s\-]",
language_lines,
)
def update_config_options():
config_file = os.path.join(ROOT, "lua", "aerial", "config.lua")
opt_lines = read_section(config_file, r"^\s*local default_options =", r"^}$")
replace_section(
README,
r"^\-\- Call the setup function",
r"^}\)$",
['require("aerial").setup({\n'] + opt_lines,
)
replace_section(
VIMDOC, r'^\s*require\("aerial"\)\.setup', r"^\s*}\)$", indent(opt_lines, 4)
)
def update_md_api():
funcs = parse_functions(os.path.join(ROOT, "lua", "aerial", "init.lua"))
lines = ["\n"] + render_md_api(funcs, 2) + ["\n"]
api_doc = os.path.join(DOC, "api.md")
replace_section(
api_doc,
r"^<!-- API -->$",
r"^<!-- /API -->$",
lines,
)
toc = ["\n"] + generate_md_toc(api_doc) + ["\n"]
replace_section(
api_doc,
r"^<!-- TOC -->$",
r"^<!-- /TOC -->$",
toc,
)
replace_section(
README,
r"^<!-- API -->$",
r"^<!-- /API -->$",
toc,
)
def update_readme_toc():
toc = ["\n"] + generate_md_toc(README) + ["\n"]
replace_section(
README,
r"^<!-- TOC -->$",
r"^<!-- /TOC -->$",
toc,
)
@lru_cache
def get_commands() -> List[Command]:
return commands_from_json(read_nvim_json('require("aerial").get_all_commands()'))
def update_md_commands():
commands = get_commands()
lines = ["\n"] + format_md_commands(commands) + ["\n"]
replace_section(
README,
r"^## Commands",
r"^#",
lines,
)
def get_options_vimdoc() -> "VimdocSection":
section = VimdocSection("options", "aerial-options")
config_file = os.path.join(ROOT, "lua", "aerial", "config.lua")
opt_lines = read_section(config_file, r"^local default_options =", r"^}$")
lines = ["\n", ">\n", ' require("aerial").setup({\n']
lines.extend(indent(opt_lines, 4))
lines.extend([" })\n", "<\n"])
section.body = lines
return section
def get_commands_vimdoc() -> "VimdocSection":
section = VimdocSection("Commands", "aerial-commands", ["\n"])
commands = get_commands()
section.body.extend(format_vimdoc_commands(commands))
return section
def get_notes_vimdoc() -> "VimdocSection":
section = VimdocSection("Notes", "aerial-notes")
section.body.extend(read_section(VIMDOC, "^NOTES", r"^[=\-]"))
return section
def generate_vimdoc():
doc = Vimdoc("aerial.txt", "aerial")
funcs = parse_functions(os.path.join(ROOT, "lua", "aerial", "init.lua"))
doc.sections.extend(
[
get_options_vimdoc(),
get_commands_vimdoc(),
VimdocSection("API", "aerial-api", render_vimdoc_api("aerial", funcs)),
get_notes_vimdoc(),
]
)
with open(VIMDOC, "w", encoding="utf-8") as ofile:
ofile.writelines(doc.render())
def main() -> None:
"""Update the README"""
update_treesitter_languages()
update_config_options()
update_md_commands()
update_md_api()
update_readme_toc()
generate_vimdoc()

31
.github/main.py vendored Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env python
import argparse
import os
import sys
HERE = os.path.dirname(__file__)
ROOT = os.path.abspath(os.path.join(HERE, os.path.pardir))
DOC = os.path.join(ROOT, "doc")
def main() -> None:
"""Generate docs"""
sys.path.append(HERE)
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument("command", choices=["generate", "lint"])
args = parser.parse_args()
if args.command == "generate":
import generate
generate.main()
elif args.command == "lint":
from nvim_doc_tools import lint_md_links
files = [os.path.join(ROOT, "README.md")] + [
os.path.join(DOC, file) for file in os.listdir(DOC) if file.endswith(".md")
]
lint_md_links.main(ROOT, files)
if __name__ == "__main__":
main()

1
.github/nvim_doc_tools vendored Submodule

@ -0,0 +1 @@
Subproject commit 96e7b98ec289710b0337d8255629ca2814247b9e

View file

@ -1,128 +0,0 @@
#!/usr/bin/env python
import json
import os
import os.path
import re
import subprocess
from typing import List
HERE = os.path.dirname(__file__)
ROOT = os.path.abspath(os.path.join(HERE, os.path.pardir))
README = os.path.join(ROOT, "README.md")
DOC = os.path.join(ROOT, "doc", "aerial.txt")
def indent(lines: List[str], amount: int) -> List[str]:
ret = []
for line in lines:
if amount >= 0:
ret.append(" " * amount + line)
else:
space = re.match(r"[ \t]+", line)
if space:
ret.append(line[min(abs(amount), space.span()[1]) :])
else:
ret.append(line)
return ret
def replace_section(file: str, start_pat: str, end_pat: str, lines: List[str]) -> None:
prefix_lines: List[str] = []
postfix_lines: List[str] = []
file_lines = prefix_lines
found_section = False
with open(file, "r", encoding="utf-8") as ifile:
inside_section = False
for line in ifile:
if inside_section:
if re.match(end_pat, line):
inside_section = False
file_lines = postfix_lines
file_lines.append(line)
else:
if re.match(start_pat, line):
inside_section = True
found_section = True
file_lines.append(line)
if inside_section or not found_section:
raise Exception(f"could not find file section {start_pat}")
all_lines = prefix_lines + lines + postfix_lines
with open(file, "w", encoding="utf-8") as ofile:
ofile.write("".join(all_lines))
def read_section(filename: str, start_pat: str, end_pat: str) -> List[str]:
lines = []
with open(filename, "r", encoding="utf-8") as ifile:
inside_section = False
for line in ifile:
if inside_section:
if re.match(end_pat, line):
break
lines.append(line)
elif re.match(start_pat, line):
inside_section = True
return lines
def update_treesitter_languages():
languages = sorted(os.listdir(os.path.join(ROOT, "queries")))
language_lines = ["\n"] + [f"- {l}\n" for l in languages] + ["\n"]
replace_section(
README, r"^\s*<summary>Supported treesitter languages", r"^[^\s\-]", language_lines
)
def update_config_options():
config_file = os.path.join(ROOT, "lua", "aerial", "config.lua")
opt_lines = read_section(config_file, r"^\s*local default_options =", r"^}$")
replace_section(
README,
r"^\-\- Call the setup function",
r"^}\)$",
['require("aerial").setup({\n'] + opt_lines,
)
replace_section(
DOC, r'^\s*require\("aerial"\)\.setup', r"^\s*}\)$", indent(opt_lines, 4)
)
def update_default_bindings():
code, txt = subprocess.getstatusoutput(
"""nvim --headless --noplugin -u /dev/null -c 'set runtimepath+=.' -c 'lua print(vim.json.encode(require("aerial.bindings").keys))' +qall"""
)
if code != 0:
raise Exception(f"Error updating default bindings: {txt}")
try:
bindings = json.loads(txt)
except json.JSONDecodeError as e:
raise Exception(f"Json decode error: {txt}") from e
lhs = []
rhs = []
for keys, _command, desc in bindings:
if not isinstance(keys, list):
keys = [keys]
lhs.append("/".join([f"`{key}`" for key in keys]))
rhs.append(desc)
max_lhs = max(map(len, lhs))
max_rhs = max(map(len, rhs))
lhs.insert(0, "-" * max_lhs)
rhs.insert(0, "-" * max_rhs)
lines = [
"| " + left.ljust(max_lhs) + " | " + right.ljust(max_rhs) + " |\n"
for left, right in zip(lhs, rhs)
]
replace_section(README, r"^\|\s*Key.*Command", r"^\s*$", lines)
def main() -> None:
"""Update the README"""
update_treesitter_languages()
update_config_options()
update_default_bindings()
if __name__ == "__main__":
main()

1
.gitignore vendored
View file

@ -39,3 +39,4 @@ luac.out
*.x86_64
*.hex
.direnv/

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule ".github/nvim_doc_tools"]
path = .github/nvim_doc_tools
url = https://github.com/stevearc/nvim_doc_tools

152
README.md
View file

@ -2,19 +2,23 @@
A code outline window for skimming and quick navigation
<!-- TOC -->
- [Requirements](#requirements)
- [Installation](#installation)
- [Setup](#setup)
- [Keymaps](#keymaps)
- [Commands](#commands)
- [Options](#options)
- [Third-party integrations](#third-party-integrations)
- [Telescope](#telescope)
- [Fzf](#fzf)
- [fzf](#fzf)
- [Lualine](#lualine)
- [Highlight](#highlight)
- [API](#api)
- [FAQ](#faq)
<!-- /TOC -->
https://user-images.githubusercontent.com/506791/122652728-18688500-d0f5-11eb-80aa-910f7e6a5f46.mp4
## Requirements
@ -96,7 +100,16 @@ Somewhere in your init.lua you will need to call `aerial.setup()`. See below for
[a full list of options](#options).
```lua
require('aerial').setup({})
require('aerial').setup({
-- optionally use on_attach to set keymaps when aerial has attached to a buffer
on_attach = function(bufnr)
-- Jump forwards/backwards with '{' and '}'
vim.keymap.set('n', '{', '<cmd>AerialPrev<CR>', {buffer = bufnr})
vim.keymap.set('n', '}', '<cmd>AerialNext<CR>', {buffer = bufnr})
end
})
-- You probably also want to set a keymap to toggle aerial
vim.keymap.set('n', '<leader>a', '<cmd>AerialToggle!<CR>')
```
In addition, you will need to have either Treesitter or a working LSP client. You can configure your preferred source(s) with the `backends` option (see [Options](#options)). The default is to prefer Treesitter when it's available and fall back to LSP.
@ -139,49 +152,21 @@ it](https://github.com/stevearc/aerial.nvim/issues/new?assignees=stevearc&labels
</details>
### Keymaps
While not required, you may want to add some keymaps for aerial. The best way to
do this is with the `on_attach` option:
```lua
require("aerial").setup({
on_attach = function(bufnr)
-- Toggle the aerial window with <leader>a
vim.keymap.set('n', '<leader>a', '<cmd>AerialToggle!<CR>', {buffer = bufnr})
-- Jump forwards/backwards with '{' and '}'
vim.keymap.set('n', '{', '<cmd>AerialPrev<CR>', {buffer = bufnr})
vim.keymap.set('n', '}', '<cmd>AerialNext<CR>', {buffer = bufnr})
-- Jump up the tree with '[[' or ']]'
vim.keymap.set('n', '[[', '<cmd>AerialPrevUp<CR>', {buffer = bufnr})
vim.keymap.set('n', ']]', '<cmd>AerialNextUp<CR>', {buffer = bufnr})
end
})
```
## Commands
| Command | arg | description |
| ---------------------------- | ---------------------- | -------------------------------------------------------------------------- |
| `AerialToggle[!]` | `left`/`right`/`float` | Open or close the aerial window. With `[!]` cursor stays in current window |
| `AerialOpen[!]` | `left`/`right`/`float` | Open the aerial window. With `[!]` cursor stays in current window |
| `AerialOpenAll` | | Open an aerial window for each visible window |
| `AerialClose` | | Close the aerial window |
| `AerialCloseAll` | | Close all visible aerial windows |
| `AerialCloseAllButCurrent` | | Close all visible aerial windows except for the focused one |
| `AerialPrev` | N=1 | Jump backwards N symbols |
| `AerialNext` | N=1 | Jump forwards N symbols |
| `AerialPrevUp` | N=1 | Jump up the tree N levels, moving backwards |
| `AerialNextUp` | N=1 | Jump up the tree N levels, moving forwards |
| `AerialGo` | N=1, `v`/`h` | Jump to the Nth symbol |
| `AerialTreeOpen[!]` | | Expand tree at current location. `[!]` makes it recursive. |
| `AerialTreeClose[!]` | | Collapse tree at current location. `[!]` makes it recursive. |
| `AerialTreeToggle[!]` | | Toggle tree at current location. `[!]` makes it recursive. |
| `AerialTreeOpenAll` | | Open all tree nodes |
| `AerialTreeCloseAll` | | Collapse all tree nodes |
| `AerialTreeSetCollapseLevel` | N | Collapse symbols at a depth greater than N (0 collapses all) |
| `AerialTreeSyncFolds` | | Sync code folding with current tree state |
| `AerialInfo` | | Print out debug info related to aerial |
| Command | Args | Description |
| -------------------- | ------------------ | ------------------------------------------------------------------------ |
| `AerialToggle[!]` | `left/right/float` | Open or close the aerial window. With `!` cursor stays in current window |
| `AerialOpen[!]` | `left/right/float` | Open the aerial window. With `!` cursor stays in current window |
| `AerialOpenAll` | | Open an aerial window for each visible window. |
| `AerialClose` | | Close the aerial window. |
| `AerialCloseAll` | | Close all visible aerial windows. |
| `[count]AerialNext` | | Jump forwards {count} symbols (default 1). |
| `[count]AerialPrev` | | Jump backwards [count] symbols (default 1). |
| `[count]AerialGo[!]` | | Jump to the [count] symbol (default 1). |
| `AerialInfo` | | Print out debug info related to aerial. |
## Options
@ -224,8 +209,46 @@ require("aerial").setup({
-- unsupported - close aerial when attaching to a buffer that has no symbol source
close_automatic_events = {},
-- Set to false to remove the default keybindings for the aerial buffer
default_bindings = true,
-- Keymaps in aerial window. Can be any value that `vim.keymap.set` accepts.
-- Additionally, if it is a string that matches "aerial.<name>",
-- it will use the function at require("aerial.action").<name>
-- Set to `false` to remove a keymap
keymaps = {
["?"] = "actions.show_help",
["g?"] = "actions.show_help",
["<CR>"] = "actions.jump",
["<2-LeftMouse>"] = "actions.jump",
["<C-v>"] = "actions.jump_vsplit",
["<C-s>"] = "actions.jump_split",
["p"] = "actions.scroll",
["<C-j>"] = "actions.down_and_scroll",
["<C-k>"] = "actions.up_and_scroll",
["{"] = "actions.prev",
["}"] = "actions.next",
["[["] = "actions.prev_up",
["]]"] = "actions.next_up",
["q"] = "actions.close",
["o"] = "actions.tree_toggle",
["za"] = "actions.tree_toggle",
["O"] = "actions.tree_toggle_recursive",
["zA"] = "actions.tree_toggle_recursive",
["l"] = "actions.tree_open",
["zo"] = "actions.tree_open",
["L"] = "actions.tree_open_recursive",
["zO"] = "actions.tree_open_recursive",
["h"] = "actions.tree_close",
["zc"] = "actions.tree_close",
["H"] = "actions.tree_close_recursive",
["zC"] = "actions.tree_close_recursive",
["zR"] = "actions.tree_open_all",
["zM"] = "actions.tree_close_all",
["zx"] = "actions.tree_sync_folds",
["zX"] = "actions.tree_sync_folds",
},
-- When true, don't load aerial until a command or function is called
-- Defaults to true, unless `on_attach` is provided, then it defaults to false
lazy_load = true,
-- Disable aerial on files with this many lines
disable_max_lines = 10000,
@ -331,12 +354,11 @@ require("aerial").setup({
nerd_font = "auto",
-- Call this function when aerial attaches to a buffer.
-- Useful for setting keymaps. Takes a single `bufnr` argument.
on_attach = nil,
on_attach = function(bufnr) end,
-- Call this function when aerial first sets symbols on a buffer.
-- Takes a single `bufnr` argument.
on_first_symbols = nil,
on_first_symbols = function(bufnr) end,
-- Automatically open aerial when entering supported buffers.
-- This can be a function (see :help aerial-open-automatic)
@ -533,6 +555,38 @@ hi AerialGuide1 guifg=Red
hi AerialGuide2 guifg=Blue
```
## API
<!-- API -->
- [setup(opts)](#setupopts)
- [is_open(opts)](#is_openopts)
- [close()](#close)
- [close_all()](#close_all)
- [close_all_but_current()](#close_all_but_current)
- [open(opts)](#openopts)
- [open_all()](#open_all)
- [focus()](#focus)
- [toggle(opts)](#toggleopts)
- [select(opts)](#selectopts)
- [next(step)](#nextstep)
- [prev(step)](#prevstep)
- [next_up(count)](#next_upcount)
- [prev_up(count)](#prev_upcount)
- [get_location(exact)](#get_locationexact)
- [tree_close_all(bufnr)](#tree_close_allbufnr)
- [tree_open_all(bufnr)](#tree_open_allbufnr)
- [tree_set_collapse_level(bufnr, level)](#tree_set_collapse_levelbufnr-level)
- [tree_open(opts)](#tree_openopts)
- [tree_close(opts)](#tree_closeopts)
- [tree_toggle(opts)](#tree_toggleopts)
- [sync_folds(bufnr)](#sync_foldsbufnr)
- [info()](#info)
- [num_symbols(bufnr)](#num_symbolsbufnr)
- [was_closed(default)](#was_closeddefault)
<!-- /API -->
## FAQ
**Q: I accidentally opened a file into the aerial window and it looks bad. How can I prevent this from happening?**

View file

@ -1,109 +1,16 @@
*aerial.txt*
*Aerial* *aerial* *aerial.nvim*
===============================================================================
CONTENTS *aerial-contents*
--------------------------------------------------------------------------------
CONTENTS *aerial-contents*
1. Commands........................................|aerial-commands|
2. Options.........................................|aerial-options|
3. Notes...........................................|aerial-notes|
1. Options..................................................|aerial-options|
2. Commands................................................|aerial-commands|
3. Api..........................................................|aerial-api|
4. Notes......................................................|aerial-notes|
===============================================================================
COMMANDS *aerial-commands*
--------------------------------------------------------------------------------
OPTIONS *aerial-options*
*:AerialToggle*
:AerialToggle[!] [direction]
Open or close the aerial window. [direction] can be `left`,
`right`, or `float`. If without [!] the cursor will jump to the aerial
window if it was opened.
*:AerialOpen*
:AerialOpen[!] [direction]
Open the aerial window. [direction] can be either `left`, `right`, or
`float`. If without [!] the cursor will jump to the aerial window.
*:AerialOpenAll*
:AerialOpenAll
Open an aerial window for each visible window.
*:AerialClose*
:AerialClose
Close the aerial window.
*:AerialCloseAll*
:AerialCloseAll
Close all visible aerial windows.
*:AerialCloseAllButCurrent*
:AerialCloseAllButCurrent
Close all visible aerial windows except for the one currently focused
or for the currently focused window.
*:AerialInfo*
:AerialInfo
Print out debug info related to aerial.
*:AerialNext*
:[count]AerialNext
Jump forwards [count] symbols (default 1).
*:AerialPrev*
:[count]AerialPrev
Jump backwards [count] symbols (default 1).
*:AerialNextUp*
:[count]AerialNextUp
Jump up the tree [count] levels, moving forwards in the file
(default 1).
*:AerialPrevUp*
:[count]AerialPrevUp
Jump up the tree [count] levels, moving backwards in the file
(default 1).
*:AerialGo*
:[count]AerialGo[!] [split]
Jump to the [count] symbol (default 1). If with [!] and inside aerial
window, the cursor will stay in the aerial window. [split] can be "v"
to open a new vertical split, or "h" to open a horizontal split.
[split] can also be a raw vim command, such as "belowright split".
This command respects |switchbuf|=uselast
*:AerialTreeOpen*
:AerialTreeOpen[!]
Expand the tree at the current location. If with [!] then will expand
recursively.
*:AerialTreeClose*
:AerialTreeClose
Collapse the tree at the current location. If with [!] then will
collapse recursively.
*:AerialTreeToggle*
:AerialTreeToggle
Toggle the tree at the current location. If with [!] then will toggle
recursively.
*:AerialTreeOpenAll*
:AerialTreeOpenAll
Expand all the tree nodes.
*:AerialTreeCloseAll*
:AerialTreeCloseAll
Collapse all the tree nodes.
*:AerialTreeSetCollapseLevel*
:AerialTreeSetCollapseLevel
Collapse symbols at a depth greater than N (0 collapses all)
*:AerialTreeSyncFolds*
:AerialTreeSyncFolds
Sync code folding with current tree state. This ignores the
link_tree_to_folds setting.
===============================================================================
OPTIONS *aerial-options*
Configure aerial by calling the setup() function.
>
require("aerial").setup({
-- Priority list of preferred backends for aerial.
@ -142,8 +49,46 @@ Configure aerial by calling the setup() function.
-- unsupported - close aerial when attaching to a buffer that has no symbol source
close_automatic_events = {},
-- Set to false to remove the default keybindings for the aerial buffer
default_bindings = true,
-- Keymaps in aerial window. Can be any value that `vim.keymap.set` accepts.
-- Additionally, if it is a string that matches "aerial.<name>",
-- it will use the function at require("aerial.action").<name>
-- Set to `false` to remove a keymap
keymaps = {
["?"] = "actions.show_help",
["g?"] = "actions.show_help",
["<CR>"] = "actions.jump",
["<2-LeftMouse>"] = "actions.jump",
["<C-v>"] = "actions.jump_vsplit",
["<C-s>"] = "actions.jump_split",
["p"] = "actions.scroll",
["<C-j>"] = "actions.down_and_scroll",
["<C-k>"] = "actions.up_and_scroll",
["{"] = "actions.prev",
["}"] = "actions.next",
["[["] = "actions.prev_up",
["]]"] = "actions.next_up",
["q"] = "actions.close",
["o"] = "actions.tree_toggle",
["za"] = "actions.tree_toggle",
["O"] = "actions.tree_toggle_recursive",
["zA"] = "actions.tree_toggle_recursive",
["l"] = "actions.tree_open",
["zo"] = "actions.tree_open",
["L"] = "actions.tree_open_recursive",
["zO"] = "actions.tree_open_recursive",
["h"] = "actions.tree_close",
["zc"] = "actions.tree_close",
["H"] = "actions.tree_close_recursive",
["zC"] = "actions.tree_close_recursive",
["zR"] = "actions.tree_open_all",
["zM"] = "actions.tree_close_all",
["zx"] = "actions.tree_sync_folds",
["zX"] = "actions.tree_sync_folds",
},
-- When true, don't load aerial until a command or function is called
-- Defaults to true, unless `on_attach` is provided, then it defaults to false
lazy_load = true,
-- Disable aerial on files with this many lines
disable_max_lines = 10000,
@ -249,12 +194,11 @@ Configure aerial by calling the setup() function.
nerd_font = "auto",
-- Call this function when aerial attaches to a buffer.
-- Useful for setting keymaps. Takes a single `bufnr` argument.
on_attach = nil,
on_attach = function(bufnr) end,
-- Call this function when aerial first sets symbols on a buffer.
-- Takes a single `bufnr` argument.
on_first_symbols = nil,
on_first_symbols = function(bufnr) end,
-- Automatically open aerial when entering supported buffers.
-- This can be a function (see :help aerial-open-automatic)
@ -340,8 +284,239 @@ Configure aerial by calling the setup() function.
})
<
===============================================================================
NOTES *aerial-notes*
--------------------------------------------------------------------------------
COMMANDS *aerial-commands*
AerialToggle[!] `left/right/float` *:AerialToggle*
Open or close the aerial window. With `!` cursor stays in current window
AerialOpen[!] `left/right/float` *:AerialOpen*
Open the aerial window. With `!` cursor stays in current window
AerialOpenAll *:AerialOpenAll*
Open an aerial window for each visible window.
AerialClose *:AerialClose*
Close the aerial window.
AerialCloseAll *:AerialCloseAll*
Close all visible aerial windows.
[count]AerialNext *:AerialNext*
Jump forwards {count} symbols (default 1).
[count]AerialPrev *:AerialPrev*
Jump backwards [count] symbols (default 1).
[count]AerialGo[!] *:AerialGo*
Jump to the [count] symbol (default 1).
If with [!] and inside aerial window, the cursor will stay in the aerial
window. [split] can be "v" to open a new vertical split, or "h" to open a
horizontal split. [split] can also be a raw vim command, such as "belowright
split". This command respects |switchbuf|=uselast
AerialInfo *:AerialInfo*
Print out debug info related to aerial.
--------------------------------------------------------------------------------
API *aerial-api*
setup({opts}) *aerial.setup*
Initialize aerial
Parameters:
{opts} `nil|table`
is_open({opts}): boolean *aerial.is_open*
Returns true if aerial is open for the current window or buffer (returns
false inside an aerial buffer)
Parameters:
{opts} `nil|table`
{bufnr} `nil|integer`
{winid} `nil|integer`
close() *aerial.close*
Close the aerial window.
close_all() *aerial.close_all*
Close all visible aerial windows.
close_all_but_current() *aerial.close_all_but_current*
Close all visible aerial windows except for the one currently focused or for
the currently focused window.
open({opts}) *aerial.open*
Open the aerial window for the current buffer.
Parameters:
{opts} `nil|table`
{focus} `boolean` If true, jump to aerial window if it is opened
(default true)
{direction} `"left"|"right"|"float"` Direction to open aerial window
open_all() *aerial.open_all*
Open an aerial window for each visible window.
focus() *aerial.focus*
Jump to the aerial window for the current buffer, if it is open
toggle({opts}) *aerial.toggle*
Open or close the aerial window for the current buffer.
Parameters:
{opts} `nil|table`
{focus} `boolean` If true, jump to aerial window if it is opened
(default true)
{direction} `"left"|"right"|"float"` Direction to open aerial window
select({opts}) *aerial.select*
Jump to a specific symbol.
Parameters:
{opts} `nil|table`
{index} `nil|integer` The symbol to jump to. If nil, will jump to the
symbol under the cursor (in the aerial buffer)
{split} `nil|string` Jump to the symbol in a new split. Can be "v" for
vertical or "h" for horizontal. Can also be a raw command to
execute (e.g. "belowright split")
{jump} `nil|boolean` If false and in the aerial window, do not leave
the aerial window. (Default true)
next({step}) *aerial.next*
Jump forwards in the symbol list.
Parameters:
{step} `nil|integer` Number of symbols to jump by (default 1)
prev({step}) *aerial.prev*
Jump backwards in the symbol list.
Parameters:
{step} `nil|integer` Number of symbols to jump by (default 1)
next_up({count}) *aerial.next_up*
Jump to a symbol higher in the tree, moving forwards
Parameters:
{count} `nil|integer` How many levels to jump up (default 1)
prev_up({count}) *aerial.prev_up*
Jump to a symbol higher in the tree, moving backwards
Parameters:
{count} `nil|integer` How many levels to jump up (default 1)
get_location({exact}): table *aerial.get_location*
Get a list representing the symbol path to the current location.
Parameters:
{exact} `nil|boolean` If true, only return symbols if we are exactly
inside the hierarchy. When false, will return the closest symbol.
Returns:
`table` []
Note:
Returns empty list if none found or in an invalid buffer.
Items have the following keys:
name The name of the symbol
kind The SymbolKind of the symbol
icon The icon that represents the symbol
tree_close_all({bufnr}) *aerial.tree_close_all*
Collapse all nodes in the symbol tree
Parameters:
{bufnr} `nil|integer`
tree_open_all({bufnr}) *aerial.tree_open_all*
Expand all nodes in the symbol tree
Parameters:
{bufnr} `nil|integer`
tree_set_collapse_level({bufnr}, {level}) *aerial.tree_set_collapse_level*
Set the collapse level of the symbol tree
Parameters:
{bufnr} `integer`
{level} `integer` 0 is all closed, use 99 to open all
tree_open({opts}) *aerial.tree_open*
Open the tree at the selected location
Parameters:
{opts} `nil|table`
{index} `nil|integer` The index of the symbol to perform the action
on. Defaults to cursor location.
{fold} `nil|boolean` If false, do not modify folds regardless of
'link_tree_to_folds' setting. (default true)
{recurse} `nil|boolean` If true, perform the action recursively on all
children (default false)
{bubble} `nil|boolean` If true and current symbol has no children,
perform the action on the nearest parent (default true)
tree_close({opts}) *aerial.tree_close*
Collapse the tree at the selected location
Parameters:
{opts} `nil|table`
{index} `nil|integer` The index of the symbol to perform the action
on. Defaults to cursor location.
{fold} `nil|boolean` If false, do not modify folds regardless of
'link_tree_to_folds' setting. (default true)
{recurse} `nil|boolean` If true, perform the action recursively on all
children (default false)
{bubble} `nil|boolean` If true and current symbol has no children,
perform the action on the nearest parent (default true)
tree_toggle({opts}) *aerial.tree_toggle*
Toggle the collapsed state at the selected location
Parameters:
{opts} `nil|table`
{index} `nil|integer` The index of the symbol to perform the action
on. Defaults to cursor location.
{fold} `nil|boolean` If false, do not modify folds regardless of
'link_tree_to_folds' setting. (default true)
{recurse} `nil|boolean` If true, perform the action recursively on all
children (default false)
{bubble} `nil|boolean` If true and current symbol has no children,
perform the action on the nearest parent (default true)
sync_folds({bufnr}) *aerial.sync_folds*
Sync code folding with the current tree state.
Parameters:
{bufnr} `integer`
Note:
Ignores the 'link_tree_to_folds' config option.
info(): table *aerial.info*
Get debug info for aerial
num_symbols({bufnr}): integer *aerial.num_symbols*
Returns the number of symbols for the buffer
Parameters:
{bufnr} `integer`
was_closed({default}): nil|boolean *aerial.was_closed*
Returns true if the user has manually closed aerial. Will become false if
the user opens aerial again.
Parameters:
{default} `nil|boolean`
--------------------------------------------------------------------------------
NOTES *aerial-notes*
*aerial-filetype-map*
Certain options can be configured per-filetype by passing in a table. "_" will
@ -422,5 +597,5 @@ Struct
TypeParameter
Variable
===============================================================================
vim:ft=help:et:ts=2:sw=2:sts=2:norl
================================================================================
vim:tw=80:ts=2:ft=help:norl:syntax=help:

284
doc/api.md Normal file
View file

@ -0,0 +1,284 @@
# API
<!-- TOC -->
- [setup(opts)](#setupopts)
- [is_open(opts)](#is_openopts)
- [close()](#close)
- [close_all()](#close_all)
- [close_all_but_current()](#close_all_but_current)
- [open(opts)](#openopts)
- [open_all()](#open_all)
- [focus()](#focus)
- [toggle(opts)](#toggleopts)
- [select(opts)](#selectopts)
- [next(step)](#nextstep)
- [prev(step)](#prevstep)
- [next_up(count)](#next_upcount)
- [prev_up(count)](#prev_upcount)
- [get_location(exact)](#get_locationexact)
- [tree_close_all(bufnr)](#tree_close_allbufnr)
- [tree_open_all(bufnr)](#tree_open_allbufnr)
- [tree_set_collapse_level(bufnr, level)](#tree_set_collapse_levelbufnr-level)
- [tree_open(opts)](#tree_openopts)
- [tree_close(opts)](#tree_closeopts)
- [tree_toggle(opts)](#tree_toggleopts)
- [sync_folds(bufnr)](#sync_foldsbufnr)
- [info()](#info)
- [num_symbols(bufnr)](#num_symbolsbufnr)
- [was_closed(default)](#was_closeddefault)
<!-- /TOC -->
<!-- API -->
## setup(opts)
`setup(opts)` \
Initialize aerial
| Param | Type | Desc |
| ----- | ------------ | ---- |
| opts | `nil\|table` | |
## is_open(opts)
`is_open(opts): boolean` \
Returns true if aerial is open for the current window or buffer (returns false inside an aerial buffer)
| Param | Type | Desc | |
| ----- | ------------ | -------------- | --- |
| opts | `nil\|table` | | |
| | bufnr | `nil\|integer` | |
| | winid | `nil\|integer` | |
## close()
`close()` \
Close the aerial window.
## close_all()
`close_all()` \
Close all visible aerial windows.
## close_all_but_current()
`close_all_but_current()` \
Close all visible aerial windows except for the one currently focused or for the currently focused window.
## open(opts)
`open(opts)` \
Open the aerial window for the current buffer.
| Param | Type | Desc | |
| ----- | ------------ | -------------------------- | ------------------------------------------------------------- |
| opts | `nil\|table` | | |
| | focus | `boolean` | If true, jump to aerial window if it is opened (default true) |
| | direction | `"left"\|"right"\|"float"` | Direction to open aerial window |
## open_all()
`open_all()` \
Open an aerial window for each visible window.
## focus()
`focus()` \
Jump to the aerial window for the current buffer, if it is open
## toggle(opts)
`toggle(opts)` \
Open or close the aerial window for the current buffer.
| Param | Type | Desc | |
| ----- | ------------ | -------------------------- | ------------------------------------------------------------- |
| opts | `nil\|table` | | |
| | focus | `boolean` | If true, jump to aerial window if it is opened (default true) |
| | direction | `"left"\|"right"\|"float"` | Direction to open aerial window |
## select(opts)
`select(opts)` \
Jump to a specific symbol.
| Param | Type | Desc | |
| ----- | ------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| opts | `nil\|table` | | |
| | index | `nil\|integer` | The symbol to jump to. If nil, will jump to the symbol under the cursor (in the aerial buffer) |
| | split | `nil\|string` | Jump to the symbol in a new split. Can be "v" for vertical or "h" for horizontal. Can also be a raw command to execute (e.g. "belowright split") |
| | jump | `nil\|boolean` | If false and in the aerial window, do not leave the aerial window. (Default true) |
## next(step)
`next(step)` \
Jump forwards in the symbol list.
| Param | Type | Desc |
| ----- | -------------- | ---------------------------------------- |
| step | `nil\|integer` | Number of symbols to jump by (default 1) |
## prev(step)
`prev(step)` \
Jump backwards in the symbol list.
| Param | Type | Desc |
| ----- | -------------- | ---------------------------------------- |
| step | `nil\|integer` | Number of symbols to jump by (default 1) |
## next_up(count)
`next_up(count)` \
Jump to a symbol higher in the tree, moving forwards
| Param | Type | Desc |
| ----- | -------------- | -------------------------------------- |
| count | `nil\|integer` | How many levels to jump up (default 1) |
## prev_up(count)
`prev_up(count)` \
Jump to a symbol higher in the tree, moving backwards
| Param | Type | Desc |
| ----- | -------------- | -------------------------------------- |
| count | `nil\|integer` | How many levels to jump up (default 1) |
## get_location(exact)
`get_location(exact): table` \
Get a list representing the symbol path to the current location.
| Param | Type | Desc |
| ----- | -------------- | ---------------------------------------------------------------------------------------------------------------- |
| exact | `nil\|boolean` | If true, only return symbols if we are exactly inside the hierarchy. When false, will return the closest symbol. |
Returns:
| Type | Desc |
| ----- | ---- |
| table | [] |
**Note:**
<pre>
Returns empty list if none found or in an invalid buffer.
Items have the following keys:
name The name of the symbol
kind The SymbolKind of the symbol
icon The icon that represents the symbol
</pre>
## tree_close_all(bufnr)
`tree_close_all(bufnr)` \
Collapse all nodes in the symbol tree
| Param | Type | Desc |
| ----- | -------------- | ---- |
| bufnr | `nil\|integer` | |
## tree_open_all(bufnr)
`tree_open_all(bufnr)` \
Expand all nodes in the symbol tree
| Param | Type | Desc |
| ----- | -------------- | ---- |
| bufnr | `nil\|integer` | |
## tree_set_collapse_level(bufnr, level)
`tree_set_collapse_level(bufnr, level)` \
Set the collapse level of the symbol tree
| Param | Type | Desc |
| ----- | --------- | ----------------------------------- |
| bufnr | `integer` | |
| level | `integer` | 0 is all closed, use 99 to open all |
## tree_open(opts)
`tree_open(opts)` \
Open the tree at the selected location
| Param | Type | Desc | |
| ----- | ------------ | -------------- | --------------------------------------------------------------------------------------------------- |
| opts | `nil\|table` | | |
| | index | `nil\|integer` | The index of the symbol to perform the action on. Defaults to cursor location. |
| | fold | `nil\|boolean` | If false, do not modify folds regardless of 'link_tree_to_folds' setting. (default true) |
| | recurse | `nil\|boolean` | If true, perform the action recursively on all children (default false) |
| | bubble | `nil\|boolean` | If true and current symbol has no children, perform the action on the nearest parent (default true) |
## tree_close(opts)
`tree_close(opts)` \
Collapse the tree at the selected location
| Param | Type | Desc | |
| ----- | ------------ | -------------- | --------------------------------------------------------------------------------------------------- |
| opts | `nil\|table` | | |
| | index | `nil\|integer` | The index of the symbol to perform the action on. Defaults to cursor location. |
| | fold | `nil\|boolean` | If false, do not modify folds regardless of 'link_tree_to_folds' setting. (default true) |
| | recurse | `nil\|boolean` | If true, perform the action recursively on all children (default false) |
| | bubble | `nil\|boolean` | If true and current symbol has no children, perform the action on the nearest parent (default true) |
## tree_toggle(opts)
`tree_toggle(opts)` \
Toggle the collapsed state at the selected location
| Param | Type | Desc | |
| ----- | ------------ | -------------- | --------------------------------------------------------------------------------------------------- |
| opts | `nil\|table` | | |
| | index | `nil\|integer` | The index of the symbol to perform the action on. Defaults to cursor location. |
| | fold | `nil\|boolean` | If false, do not modify folds regardless of 'link_tree_to_folds' setting. (default true) |
| | recurse | `nil\|boolean` | If true, perform the action recursively on all children (default false) |
| | bubble | `nil\|boolean` | If true and current symbol has no children, perform the action on the nearest parent (default true) |
## sync_folds(bufnr)
`sync_folds(bufnr)` \
Sync code folding with the current tree state.
| Param | Type | Desc |
| ----- | --------- | ---- |
| bufnr | `integer` | |
**Note:**
<pre>
Ignores the 'link_tree_to_folds' config option.
</pre>
## info()
`info(): table` \
Get debug info for aerial
## num_symbols(bufnr)
`num_symbols(bufnr): integer` \
Returns the number of symbols for the buffer
| Param | Type | Desc |
| ----- | --------- | ---- |
| bufnr | `integer` | |
## was_closed(default)
`was_closed(default): nil|boolean` \
Returns true if the user has manually closed aerial. Will become false if the user opens aerial again.
| Param | Type | Desc |
| ------- | -------------- | ---- |
| default | `nil\|boolean` | |
<!-- /API -->

View file

@ -1,25 +1,16 @@
:AerialClose aerial.txt /*:AerialClose*
:AerialCloseAll aerial.txt /*:AerialCloseAll*
:AerialCloseAllButCurrent aerial.txt /*:AerialCloseAllButCurrent*
:AerialGo aerial.txt /*:AerialGo*
:AerialInfo aerial.txt /*:AerialInfo*
:AerialNext aerial.txt /*:AerialNext*
:AerialNextUp aerial.txt /*:AerialNextUp*
:AerialOpen aerial.txt /*:AerialOpen*
:AerialOpenAll aerial.txt /*:AerialOpenAll*
:AerialPrev aerial.txt /*:AerialPrev*
:AerialPrevUp aerial.txt /*:AerialPrevUp*
:AerialToggle aerial.txt /*:AerialToggle*
:AerialTreeClose aerial.txt /*:AerialTreeClose*
:AerialTreeCloseAll aerial.txt /*:AerialTreeCloseAll*
:AerialTreeOpen aerial.txt /*:AerialTreeOpen*
:AerialTreeOpenAll aerial.txt /*:AerialTreeOpenAll*
:AerialTreeSetCollapseLevel aerial.txt /*:AerialTreeSetCollapseLevel*
:AerialTreeSyncFolds aerial.txt /*:AerialTreeSyncFolds*
:AerialTreeToggle aerial.txt /*:AerialTreeToggle*
Aerial aerial.txt /*Aerial*
SymbolKind aerial.txt /*SymbolKind*
aerial aerial.txt /*aerial*
aerial-api aerial.txt /*aerial-api*
aerial-close-behavior aerial.txt /*aerial-close-behavior*
aerial-commands aerial.txt /*aerial-commands*
aerial-contents aerial.txt /*aerial-contents*
@ -28,7 +19,32 @@ aerial-filter aerial.txt /*aerial-filter*
aerial-notes aerial.txt /*aerial-notes*
aerial-open-automatic aerial.txt /*aerial-open-automatic*
aerial-options aerial.txt /*aerial-options*
aerial.close aerial.txt /*aerial.close*
aerial.close_all aerial.txt /*aerial.close_all*
aerial.close_all_but_current aerial.txt /*aerial.close_all_but_current*
aerial.focus aerial.txt /*aerial.focus*
aerial.get_location aerial.txt /*aerial.get_location*
aerial.info aerial.txt /*aerial.info*
aerial.is_open aerial.txt /*aerial.is_open*
aerial.next aerial.txt /*aerial.next*
aerial.next_up aerial.txt /*aerial.next_up*
aerial.num_symbols aerial.txt /*aerial.num_symbols*
aerial.nvim aerial.txt /*aerial.nvim*
aerial.open aerial.txt /*aerial.open*
aerial.open_all aerial.txt /*aerial.open_all*
aerial.prev aerial.txt /*aerial.prev*
aerial.prev_up aerial.txt /*aerial.prev_up*
aerial.select aerial.txt /*aerial.select*
aerial.setup aerial.txt /*aerial.setup*
aerial.sync_folds aerial.txt /*aerial.sync_folds*
aerial.toggle aerial.txt /*aerial.toggle*
aerial.tree_close aerial.txt /*aerial.tree_close*
aerial.tree_close_all aerial.txt /*aerial.tree_close_all*
aerial.tree_open aerial.txt /*aerial.tree_open*
aerial.tree_open_all aerial.txt /*aerial.tree_open_all*
aerial.tree_set_collapse_level aerial.txt /*aerial.tree_set_collapse_level*
aerial.tree_toggle aerial.txt /*aerial.tree_toggle*
aerial.txt aerial.txt /*aerial.txt*
aerial.was_closed aerial.txt /*aerial.was_closed*
if aerial.txt /*if*
symbol aerial.txt /*symbol*

View file

@ -14,7 +14,7 @@ local commands = {
cmd = "AerialToggle",
args = "`left/right/float`",
func = "toggle",
def = {
defn = {
desc = "Open or close the aerial window. With `!` cursor stays in current window",
nargs = "?",
bang = true,
@ -25,7 +25,7 @@ local commands = {
cmd = "AerialOpen",
args = "`left/right/float`",
func = "open",
def = {
defn = {
desc = "Open the aerial window. With `!` cursor stays in current window",
nargs = "?",
bang = true,
@ -35,21 +35,21 @@ local commands = {
{
cmd = "AerialOpenAll",
func = "open_all",
def = {
defn = {
desc = "Open an aerial window for each visible window.",
},
},
{
cmd = "AerialClose",
func = "close",
def = {
defn = {
desc = "Close the aerial window.",
},
},
{
cmd = "AerialCloseAll",
func = "close_all",
def = {
defn = {
desc = "Close all visible aerial windows.",
},
},
@ -60,14 +60,14 @@ local commands = {
alternative = "aerial.close_all_but_current()",
help = "aerial.close_all_but_current",
},
def = {
defn = {
desc = "Close all visible aerial windows except for the one currently focused or for the currently focused window.",
},
},
{
cmd = "AerialNext",
func = "next",
def = {
defn = {
desc = "Jump forwards {count} symbols (default 1).",
count = 1,
},
@ -75,7 +75,7 @@ local commands = {
{
cmd = "AerialPrev",
func = "prev",
def = {
defn = {
desc = "Jump backwards [count] symbols (default 1).",
count = 1,
},
@ -87,7 +87,7 @@ local commands = {
alternative = "aerial.up()",
help = "aerial.up",
},
def = {
defn = {
desc = "Jump up the tree [count] levels, moving forwards in the file (default 1).",
count = 1,
},
@ -99,7 +99,7 @@ local commands = {
alternative = "aerial.up()",
help = "aerial.up",
},
def = {
defn = {
desc = "Jump up the tree [count] levels, moving backwards in the file (default 1).",
count = 1,
},
@ -107,12 +107,13 @@ local commands = {
{
cmd = "AerialGo",
func = "go",
def = {
desc = 'Jump to the [count] symbol (default 1). If with [!] and inside aerial window, the cursor will stay in the aerial window. [split] can be "v" to open a new vertical split, or "h" to open a horizontal split. [split] can also be a raw vim command, such as "belowright split". This command respects switchbuf=uselast',
defn = {
desc = "Jump to the [count] symbol (default 1).",
count = 1,
bang = true,
nargs = "?",
},
long_desc = 'If with [!] and inside aerial window, the cursor will stay in the aerial window. [split] can be "v" to open a new vertical split, or "h" to open a horizontal split. [split] can also be a raw vim command, such as "belowright split". This command respects |switchbuf|=uselast',
},
{
cmd = "AerialTreeOpen",
@ -121,7 +122,7 @@ local commands = {
alternative = "aerial.tree_open()",
help = "aerial.tree_cmd",
},
def = {
defn = {
desc = "Expand the tree at the current location. If with [!] then will expand recursively.",
bang = true,
},
@ -133,7 +134,7 @@ local commands = {
alternative = "aerial.tree_close()",
help = "aerial.tree_close",
},
def = {
defn = {
desc = "Collapse the tree at the current location. If with [!] then will collapse recursively.",
bang = true,
},
@ -145,7 +146,7 @@ local commands = {
alternative = "aerial.tree_toggle()",
help = "aerial.tree_toggle",
},
def = {
defn = {
desc = "Toggle the tree at the current location. If with [!] then will toggle recursively.",
bang = true,
},
@ -157,7 +158,7 @@ local commands = {
alternative = "aerial.tree_open_all()",
help = "aerial.tree_open_all",
},
def = {
defn = {
desc = "Expand all the tree nodes.",
},
},
@ -168,7 +169,7 @@ local commands = {
alternative = "aerial.tree_close_all()",
help = "aerial.tree_close_all",
},
def = {
defn = {
desc = "Collapse all the tree nodes.",
},
},
@ -179,18 +180,19 @@ local commands = {
alternative = "aerial.tree_sync_folds()",
help = "aerial.tree_sync_folds",
},
def = {
defn = {
desc = "Sync code folding with current tree state. This ignores the link_tree_to_folds setting.",
},
},
{
cmd = "AerialTreeSetCollapseLevel",
func = "tree_set_collapse_level",
args = "N",
deprecated = {
alternative = "aerial.tree_set_collapse_level()",
help = "aerial.tree_set_collapse_level",
},
def = {
defn = {
desc = "Collapse symbols at a depth greater than N (0 collapses all)",
nargs = 1,
},
@ -198,7 +200,7 @@ local commands = {
{
cmd = "AerialInfo",
func = "info",
def = {
defn = {
desc = "Print out debug info related to aerial.",
},
},
@ -234,7 +236,7 @@ local function create_commands()
lazy("command", v.func)(...)
end
end
vim.api.nvim_create_user_command(v.cmd, callback, v.def)
vim.api.nvim_create_user_command(v.cmd, callback, v.defn)
end
end
@ -307,8 +309,7 @@ M.setup = function(opts)
end
end
---Returns true if aerial is open for the current window or buffer
---(returns false inside an aerial buffer)
---Returns true if aerial is open for the current window or buffer (returns false inside an aerial buffer)
---@param opts nil|table
--- bufnr nil|integer
--- winid nil|integer
@ -448,11 +449,11 @@ end
---@param exact nil|boolean If true, only return symbols if we are exactly inside the hierarchy. When false, will return the closest symbol.
---@return table[]
---@note
---Returns empty list if none found or in an invalid buffer.
---Items have the following keys:
--- name The name of the symbol
--- kind The SymbolKind of the symbol
--- icon The icon that represents the symbol
--- Returns empty list if none found or in an invalid buffer.
--- Items have the following keys:
--- name The name of the symbol
--- kind The SymbolKind of the symbol
--- icon The icon that represents the symbol
M.get_location = function(exact)
do_setup()
local config = require("aerial.config")
@ -530,8 +531,9 @@ M.tree_close = lazy("tree", "close")
M.tree_toggle = lazy("tree", "toggle")
---Sync code folding with the current tree state.
---Ignores the 'link_tree_to_folds' config option.
---@param bufnr integer
---@note
--- Ignores the 'link_tree_to_folds' config option.
M.sync_folds = function(bufnr)
do_setup()
local fold = require("aerial.fold")
@ -583,10 +585,9 @@ M.num_symbols = function(bufnr)
end
end
---Returns true if the user has manually closed aerial.
---Will become false if the user opens aerial again.
---@param default? boolean
---@return boolean|nil
---Returns true if the user has manually closed aerial. Will become false if the user opens aerial again.
---@param default nil|boolean
---@return nil|boolean
M.was_closed = function(default)
if was_closed == nil then
return default
@ -597,4 +598,19 @@ end
_G.aerial_foldexpr = lazy("fold", "foldexpr")
---Used for documentation generation
---@private
M.get_all_commands = function()
local cmds = vim.deepcopy(commands)
for _, v in ipairs(cmds) do
-- Remove all function values from the command definition so we can serialize it
for k, param in pairs(v.defn) do
if type(param) == "function" then
v.defn[k] = nil
end
end
end
return cmds
end
return M