style: run prettier on README

This commit is contained in:
Steven Arcangeli 2022-01-01 16:05:51 -08:00
parent d8de41d3e1
commit c6d1679070
3 changed files with 140 additions and 111 deletions

View file

@ -69,16 +69,21 @@ def read_section(filename: str, start_pat: str, end_pat: str) -> List[str]:
def update_treesitter_languages():
languages = sorted(os.listdir(os.path.join(ROOT, "queries")))
language_lines = ["\n"] + [f" * {l}\n" for l in languages] + ["\n"]
language_lines = ["\n"] + [f"- {l}\n" for l in languages] + ["\n"]
replace_section(
README, r"^\s*<summary>Supported languages", r"^[^\s]", language_lines
README, r"^\s*<summary>Supported 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'^require\("aerial"\).setup\(', r"^}\)$", opt_lines)
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)
)
@ -94,18 +99,22 @@ def update_default_bindings():
bindings = json.loads(txt)
except json.JSONDecodeError as e:
raise Exception(f"Json decode error: {txt}") from e
lhs = ["---"]
rhs = ["-------"]
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 + "\n" for left, right in zip(lhs, rhs)
"| " + left.ljust(max_lhs) + " | " + right.ljust(max_rhs) + " |\n"
for left, right in zip(lhs, rhs)
]
replace_section(README, r"^Key.*Command", r"^\s*$", lines)
replace_section(README, r"^\|\s*Key.*Command", r"^\s*$", lines)
def main() -> None:

224
README.md
View file

@ -1,88 +1,98 @@
# aerial.nvim
A code outline window for skimming and quick navigation
* [Requirements](#requirements)
* [Installation](#installation)
* [Setup](#setup)
* [LSP](#lsp)
* [Treesitter](#treesitter)
* [Markdown](#markdown)
* [Keymaps](#keymaps)
* [Commands](#commands)
* [Options](#options)
* [Default keybindings](#default-keybindings)
* [Third-party integrations](#third-party-integrations)
* [Telescope](#telescope)
* [Fzf](#fzf)
* [Lualine](#lualine)
* [Highlight](#highlight)
* [FAQ](#faq)
- [Requirements](#requirements)
- [Installation](#installation)
- [Setup](#setup)
- [LSP](#lsp)
- [Treesitter](#treesitter)
- [Markdown](#markdown)
- [Keymaps](#keymaps)
- [Commands](#commands)
- [Options](#options)
- [Default keybindings](#default-keybindings)
- [Third-party integrations](#third-party-integrations)
- [Telescope](#telescope)
- [Fzf](#fzf)
- [Lualine](#lualine)
- [Highlight](#highlight)
- [FAQ](#faq)
https://user-images.githubusercontent.com/506791/122652728-18688500-d0f5-11eb-80aa-910f7e6a5f46.mp4
## Requirements
* Neovim 0.5+
* One or more of the following:
* A working LSP setup (see [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig))
* [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) with languages installed
- Neovim 0.5+
- One or more of the following:
- A working LSP setup (see [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig))
- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) with languages installed
## Installation
aerial supports all the usual plugin managers
<details>
<summary>Packer</summary>
```lua
require('packer').startup(function()
use {'stevearc/aerial.nvim'}
end)
```
```lua
require('packer').startup(function()
use {'stevearc/aerial.nvim'}
end)
```
</details>
<details>
<summary>Paq</summary>
```lua
require "paq" {
{'stevearc/aerial.nvim'};
}
```
```lua
require "paq" {
{'stevearc/aerial.nvim'};
}
```
</details>
<details>
<summary>vim-plug</summary>
```vim
Plug 'stevearc/aerial.nvim'
```
```vim
Plug 'stevearc/aerial.nvim'
```
</details>
<details>
<summary>dein</summary>
```vim
call dein#add('stevearc/aerial.nvim')
```
```vim
call dein#add('stevearc/aerial.nvim')
```
</details>
<details>
<summary>Pathogen</summary>
```sh
git clone --depth=1 https://github.com/stevearc/aerial.nvim.git ~/.vim/bundle/
```
```sh
git clone --depth=1 https://github.com/stevearc/aerial.nvim.git ~/.vim/bundle/
```
</details>
<details>
<summary>Neovim native package</summary>
```sh
git clone --depth=1 https://github.com/stevearc/aerial.nvim.git \
"${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/pack/aerial/start/aerial.nvim
```
```sh
git clone --depth=1 https://github.com/stevearc/aerial.nvim.git \
"${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/pack/aerial/start/aerial.nvim
```
</details>
## Setup
Aerial can display document symbols from a couple of sources; you will need to
follow the setup steps for at least one of them. You can configure your
preferred source(s) with the `backends` option (see [Options](#options)). The
@ -116,26 +126,27 @@ automatically fetch symbols from treesitter.
<details>
<summary>Supported languages</summary>
* bash
* c
* c_sharp
* cpp
* dart
* go
* java
* javascript
* json
* lua
* markdown
* python
* rst
* ruby
* rust
* typescript
* vim
- bash
- c
- c_sharp
- cpp
- dart
- go
- java
- javascript
- json
- lua
- markdown
- python
- rst
- ruby
- rust
- typescript
- vim
Don't see your language here? [Request support for
it](https://github.com/stevearc/aerial.nvim/issues/new?assignees=stevearc&labels=enhancement&template=feature-request--treesitter-language-.md&title=)
</details>
### Markdown
@ -170,28 +181,28 @@ require("aerial").setup({
## 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
`AerialClose` | | Close the aerial window
`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
`AerialTreeSyncFolds` | | Sync code folding with current tree state
`AerialInfo` | | Print out debug info related to aerial
| 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 |
| `AerialClose` | | Close the aerial window |
| `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 |
| `AerialTreeSyncFolds` | | Sync code folding with current tree state |
| `AerialInfo` | | Print out debug info related to aerial |
## Options
If you want to change the default behavior of aerial, call the `setup` function:
```lua
-- Call the setup function to change the default behavior
require("aerial").setup({
-- Priority list of preferred backends for aerial.
-- This can be a filetype map (see :help aerial-filetype-map)
@ -276,6 +287,10 @@ require("aerial").setup({
-- "auto" will set it to true if nvim-web-devicons or lspkind-nvim is installed.
nerd_font = "auto",
-- Call this function when aerial attaches to a buffer.
-- Useful for setting keymaps. Takes a single `bufnr` argument.
on_attach = nil,
-- If true, open aerial automatically when entering a new buffer.
-- This can be a filetype map (see :help aerial-filetype-map)
open_automatic = false,
@ -344,33 +359,33 @@ These are the values used for configuring icons, highlight groups, and
filtering.
## Default Keybindings
The default keybindings in the aerial window. You can add your own in
`ftplugin/aerial.vim`, and remove these by setting `g:aerial_default_bindings =
0`.
Key | Command
--- | -------
`?` | Show default keymaps
`<CR>` | Jump to the symbol under the cursor
`<C-v>` | Jump to the symbol in a vertical split
`<C-s>` | Jump to the symbol in a horizontal split
`p` | Scroll to the symbol (stay in aerial buffer)
`<C-j>` | Go down one line and scroll to that symbol
`<C-k>` | Go up one line and scroll to that symbol
`{` | Jump to the previous symbol
`}` | Jump to the next symbol
`[[` | Jump up the tree, moving backwards
`]]` | Jump up the tree, moving forwards
`q` | Close the aerial window
`o`/`za` | Toggle the symbol under the cursor open/closed
`O`/`zA` | Recursive toggle the symbol under the cursor open/closed
`l`/`zo` | Expand the symbol under the cursor
`L`/`zO` | Recursive expand the symbol under the cursor
`h`/`zc` | Collapse the symbol under the cursor
`H`/`zC` | Recursive collapse the symbol under the cursor
`zR` | Expand all nodes in the tree
`zM` | Collapse all nodes in the tree
`zx`/`zX` | Sync code folding to the tree (useful if they get out of sync)
The default keybindings in the aerial window. You can add your own in
`ftplugin/aerial.vim`, and remove these by setting `g:aerial_default_bindings = 0`.
| Key | Command |
| --------- | -------------------------------------------------------------- |
| `?` | Show default keymaps |
| `<CR>` | Jump to the symbol under the cursor |
| `<C-v>` | Jump to the symbol in a vertical split |
| `<C-s>` | Jump to the symbol in a horizontal split |
| `p` | Scroll to the symbol (stay in aerial buffer) |
| `<C-j>` | Go down one line and scroll to that symbol |
| `<C-k>` | Go up one line and scroll to that symbol |
| `{` | Jump to the previous symbol |
| `}` | Jump to the next symbol |
| `[[` | Jump up the tree, moving backwards |
| `]]` | Jump up the tree, moving forwards |
| `q` | Close the aerial window |
| `o`/`za` | Toggle the symbol under the cursor open/closed |
| `O`/`zA` | Recursive toggle the symbol under the cursor open/closed |
| `l`/`zo` | Expand the symbol under the cursor |
| `L`/`zO` | Recursive expand the symbol under the cursor |
| `h`/`zc` | Collapse the symbol under the cursor |
| `H`/`zC` | Recursive collapse the symbol under the cursor |
| `zR` | Expand all nodes in the tree |
| `zM` | Collapse all nodes in the tree |
| `zx`/`zX` | Sync code folding to the tree (useful if they get out of sync) |
## Third-party integrations
@ -395,6 +410,7 @@ require('telescope').load_extension('aerial')
If you have [fzf](https://github.com/junegunn/fzf.vim) installed you can trigger
fuzzy finding with `:call aerial#fzf()`. To create a mapping:
```vim
nmap <silent> <leader>ds <cmd>call aerial#fzf()<cr>
```

View file

@ -172,6 +172,10 @@ Configure aerial by calling the setup() function.
-- "auto" will set it to true if nvim-web-devicons or lspkind-nvim is installed.
nerd_font = "auto",
-- Call this function when aerial attaches to a buffer.
-- Useful for setting keymaps. Takes a single `bufnr` argument.
on_attach = nil,
-- If true, open aerial automatically when entering a new buffer.
-- This can be a filetype map (see :help aerial-filetype-map)
open_automatic = false,