MAJOR: Refactor configuration structure
The details of the change is documented in the readme. If your config stops working, I'm fully responsible :)
This commit is contained in:
277
README.md
277
README.md
@@ -59,12 +59,39 @@ outline.
|
|||||||
This section may be relevant to you if your existing config uses the mentioned
|
This section may be relevant to you if your existing config uses the mentioned
|
||||||
features:
|
features:
|
||||||
|
|
||||||
|
- **Config**: Configuration options have been significantly restructured to
|
||||||
|
provide better consistency and understandability. Please see the [default config](#configuration) for an example of the full list.
|
||||||
|
- Options that control the looks
|
||||||
|
and behaviour of outline window is now moved to `outline_window` table;
|
||||||
|
- Options that control the items that show up are now in `outline_items`
|
||||||
|
- Options for the preview window is in `preview_window`.
|
||||||
|
- Symbol icons are now in `symbols.icons`, symbol blacklists are in
|
||||||
|
`symbols.blacklist`
|
||||||
|
- Lsp blacklists are now in `providers.lsp.blacklist_clients`.
|
||||||
|
- Fold options are now in `symbol_folding` with `fold_markers` being
|
||||||
|
`symbol_folding.markers`, consistent to `guides.markers`.
|
||||||
|
|
||||||
|
The reasoning for the above is simple. When you see 'border' under
|
||||||
|
`preview_window` you can directly infer it controls the border for the preview
|
||||||
|
window. Previously, for example, when you see `winblend` or `wrap`: is it for
|
||||||
|
the outline window or the preview window? Furthermore, this change also aids
|
||||||
|
extensibility to the configuration, and avoids cluttering the root setup opts
|
||||||
|
namespace.
|
||||||
|
|
||||||
|
If you disagree with this decision, you are always free to switch back to the
|
||||||
|
original symbols-outline.nvim, or you could pin a commit in this fork if you
|
||||||
|
still want to use the features and fixes from here.
|
||||||
|
|
||||||
- **Config**: `keymaps.focus_location` RENAMED to `keymaps.peek_location` to
|
- **Config**: `keymaps.focus_location` RENAMED to `keymaps.peek_location` to
|
||||||
avoid confusion with focus window commands.
|
avoid confusion with focus window commands.
|
||||||
|
|
||||||
- **Config**: Marker icons used for guides can now be customized. `show_guides`
|
- **Config**: Marker icons used for guides can now be customized. `show_guides`
|
||||||
REMOVED in favor of `guides.enabled`.
|
REMOVED in favor of `guides.enabled`.
|
||||||
|
|
||||||
|
You can set `guides = false` to disable guides altogether, or set `guides =
|
||||||
|
true` to enable it but use default configuration for the guides. Otherwise,
|
||||||
|
please use `guides.enabled` if your configuration for `guides` is a table.
|
||||||
|
|
||||||
- **Behaviour**: Removed hover floating window from `toggle_preview`.
|
- **Behaviour**: Removed hover floating window from `toggle_preview`.
|
||||||
- Instead, you can set `open_hover_on_preview=true` (true by default) so that
|
- Instead, you can set `open_hover_on_preview=true` (true by default) so that
|
||||||
the `hover_symbol` action can be triggered when `toggle_preview`is
|
the `hover_symbol` action can be triggered when `toggle_preview`is
|
||||||
@@ -113,7 +140,8 @@ for a screenshot)
|
|||||||
- Added function and command to show provider and outline window status,
|
- Added function and command to show provider and outline window status,
|
||||||
somewhat like `:LspInfo`.
|
somewhat like `:LspInfo`.
|
||||||
|
|
||||||
- Move down/up by one line and peek_location immediately.
|
- Move down/up by one line and peek_location immediately, default bindings are
|
||||||
|
`<C-j>` and `<C-k>` just like Aerial.
|
||||||
|
|
||||||
- Flash highlight when using goto/peek location.
|
- Flash highlight when using goto/peek location.
|
||||||
|
|
||||||
@@ -125,7 +153,7 @@ for a screenshot)
|
|||||||
- New restore location keymap option to go back to corresponding outline
|
- New restore location keymap option to go back to corresponding outline
|
||||||
location synced with code (see config `restore_location`).
|
location synced with code (see config `restore_location`).
|
||||||
|
|
||||||
Screen recordings of some of the features is shown at the bottom of the readme.
|
Screen recordings of some of the features is shown at the [bottom of the readme](#recipes).
|
||||||
|
|
||||||
## PRs
|
## PRs
|
||||||
|
|
||||||
@@ -279,11 +307,12 @@ Table of contents
|
|||||||
* [Setup](#setup)
|
* [Setup](#setup)
|
||||||
* [Configuration](#configuration)
|
* [Configuration](#configuration)
|
||||||
* [Terminology](#terminology)
|
* [Terminology](#terminology)
|
||||||
* [Options](#options)
|
* [Default options](#default-options)
|
||||||
* [Commands](#commands)
|
* [Commands](#commands)
|
||||||
* [Lua API](#lua-api)
|
|
||||||
* [Default keymaps](#default-keymaps)
|
* [Default keymaps](#default-keymaps)
|
||||||
* [Highlights](#highlights)
|
* [Highlights](#highlights)
|
||||||
|
* [Lua API](#lua-api)
|
||||||
|
* [Tips](#tips)
|
||||||
* [Recipes](#recipes)
|
* [Recipes](#recipes)
|
||||||
|
|
||||||
<!-- mtoc end -->
|
<!-- mtoc end -->
|
||||||
@@ -295,17 +324,15 @@ Table of contents
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Use `hedyhli/symbols-outline.nvim` if you wish to use this fork.
|
|
||||||
|
|
||||||
Packer:
|
Packer:
|
||||||
```lua
|
```lua
|
||||||
use 'simrat39/symbols-outline.nvim'
|
use 'hedyhli/symbols-outline.nvim'
|
||||||
```
|
```
|
||||||
|
|
||||||
Lazy:
|
Lazy:
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
"simrat39/symbols-outline.nvim",
|
"hedyhli/symbols-outline.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
-- Example mapping to toggle outline
|
-- Example mapping to toggle outline
|
||||||
vim.keymap.set("n", "<leader>tt", "<cmd>SymbolsOutline<CR>",
|
vim.keymap.set("n", "<leader>tt", "<cmd>SymbolsOutline<CR>",
|
||||||
@@ -321,11 +348,11 @@ Lazy:
|
|||||||
Lazy with lazy-loading:
|
Lazy with lazy-loading:
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
"simrat39/symbols-outline.nvim",
|
"hedyhli/symbols-outline.nvim",
|
||||||
cmd = { "SymbolsOutline", "SymbolsOutlineOpen" },
|
cmd = { "SymbolsOutline", "SymbolsOutlineOpen" },
|
||||||
keys = {
|
keys = {
|
||||||
-- Example mapping to toggle outline
|
-- Example mapping to toggle outline
|
||||||
{ "<leader>tt", "<cmd>SymbolsOutline<CR>", desc = "Toggle outline window" },
|
{ "<leader>tt", "<cmd>SymbolsOutline<CR>", desc = "Toggle outline" },
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
-- Your setup opts here
|
-- Your setup opts here
|
||||||
@@ -350,8 +377,14 @@ require("symbols-outline").setup({})
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
The configuration structure has been heavily improved and refactored in this
|
||||||
|
plugin. For details and reasoning, see [breaking changes](#-breaking-changes).
|
||||||
|
|
||||||
### Terminology
|
### Terminology
|
||||||
|
|
||||||
|
Check this list if you there's any confusion with the terms used in the
|
||||||
|
configuration.
|
||||||
|
|
||||||
- **Provider**: Source of the items in the outline view. Could be LSP, CoC, etc.
|
- **Provider**: Source of the items in the outline view. Could be LSP, CoC, etc.
|
||||||
- **Node**: An item in the outline view
|
- **Node**: An item in the outline view
|
||||||
- **Fold**: Collapse a collapsible node
|
- **Fold**: Collapse a collapsible node
|
||||||
@@ -363,46 +396,22 @@ require("symbols-outline").setup({})
|
|||||||
provided by provider.
|
provided by provider.
|
||||||
- **Focus**: Which window the cursor is in
|
- **Focus**: Which window the cursor is in
|
||||||
|
|
||||||
### Options
|
### Default options
|
||||||
|
|
||||||
Pass a table to the setup call with your configuration options.
|
Pass a table to the setup call with your configuration options.
|
||||||
|
|
||||||
Default values are shown:
|
Default values are shown:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local opts = {
|
{
|
||||||
|
outline_window = {
|
||||||
-- Where to open the split window: right/left
|
-- Where to open the split window: right/left
|
||||||
position = 'right',
|
position = 'right',
|
||||||
-- Whether width is relative to existing windows
|
|
||||||
relative_width = true,
|
|
||||||
-- Percentage or integer of columns
|
-- Percentage or integer of columns
|
||||||
width = 25,
|
width = 25,
|
||||||
|
-- Whether width is relative to existing windows
|
||||||
|
relative_width = true,
|
||||||
|
|
||||||
-- Whether to highlight the currently hovered symbol (high cpu usage)
|
|
||||||
highlight_hovered_item = true,
|
|
||||||
-- Options for outline guides.
|
|
||||||
-- Only in this fork
|
|
||||||
guides = {
|
|
||||||
enabled = true,
|
|
||||||
markers = {
|
|
||||||
bottom = '└',
|
|
||||||
middle = '├',
|
|
||||||
vertical = '│',
|
|
||||||
horizontal = '─',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
-- Automatically open preview of code on hover
|
|
||||||
auto_preview = false,
|
|
||||||
-- Automatically open hover_symbol when opening toggle_preview (see keymaps).
|
|
||||||
-- If you disable this you can still open hover_symbol using your keymap
|
|
||||||
-- below.
|
|
||||||
-- Only in this fork
|
|
||||||
open_hover_on_preview = true,
|
|
||||||
-- Border option for floating preview window.
|
|
||||||
-- Options include: single/double/rounded/solid/shadow or an array of border
|
|
||||||
-- characters.
|
|
||||||
-- See :help nvim_open_win() and search for "border" option.
|
|
||||||
border = 'single',
|
|
||||||
-- Behaviour changed in this fork:
|
-- Behaviour changed in this fork:
|
||||||
-- Auto close the outline window if goto_location is triggered and not for
|
-- Auto close the outline window if goto_location is triggered and not for
|
||||||
-- peek_location
|
-- peek_location
|
||||||
@@ -415,6 +424,19 @@ local opts = {
|
|||||||
show_numbers = false,
|
show_numbers = false,
|
||||||
show_relative_numbers = false,
|
show_relative_numbers = false,
|
||||||
show_cursorline = true, -- Only in this fork
|
show_cursorline = true, -- Only in this fork
|
||||||
|
|
||||||
|
-- Whether to wrap long lines, or let them flow off the window
|
||||||
|
wrap = false,
|
||||||
|
-- Only in this fork:
|
||||||
|
-- Whether to focus on the outline window when it is opened.
|
||||||
|
-- Set to false to remain focus on your previous buffer when opening
|
||||||
|
-- symbols-outline.
|
||||||
|
focus_on_open = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
outline_items = {
|
||||||
|
-- Whether to highlight the currently hovered symbol (high cpu usage)
|
||||||
|
highlight_hovered_item = true,
|
||||||
-- Show extra details with the symbols (lsp dependent)
|
-- Show extra details with the symbols (lsp dependent)
|
||||||
show_symbol_details = true,
|
show_symbol_details = true,
|
||||||
-- Only in this fork.
|
-- Only in this fork.
|
||||||
@@ -422,23 +444,48 @@ local opts = {
|
|||||||
-- Why? See this comment:
|
-- Why? See this comment:
|
||||||
-- https://github.com/simrat39/symbols-outline.nvim/issues/212#issuecomment-1793503563
|
-- https://github.com/simrat39/symbols-outline.nvim/issues/212#issuecomment-1793503563
|
||||||
show_symbol_lineno = false,
|
show_symbol_lineno = false,
|
||||||
-- Highlight group for the preview background
|
},
|
||||||
preview_bg_highlight = 'Pmenu',
|
|
||||||
|
-- Options for outline guides.
|
||||||
|
-- Only in this fork
|
||||||
|
guides = {
|
||||||
|
enabled = true,
|
||||||
|
markers = {
|
||||||
|
bottom = '└',
|
||||||
|
middle = '├',
|
||||||
|
vertical = '│',
|
||||||
|
horizontal = '─',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
symbol_folding = {
|
||||||
-- Depth past which nodes will be folded by default
|
-- Depth past which nodes will be folded by default
|
||||||
autofold_depth = nil,
|
autofold_depth = nil,
|
||||||
-- Automatically unfold hovered symbol
|
-- Automatically unfold hovered symbol
|
||||||
auto_unfold_hover = true,
|
auto_unfold_hover = true,
|
||||||
fold_markers = { '', '' },
|
markers = { '', '' },
|
||||||
-- Whether to wrap long lines, or let them flow off the window
|
},
|
||||||
wrap = false,
|
|
||||||
|
|
||||||
-- Only in this fork:
|
preview_window = {
|
||||||
-- Whether to focus on the outline window when it is opened.
|
-- Automatically open preview of code location when navigating outline window
|
||||||
-- Set to false to remain focus on your previous buffer when opening
|
auto_preview = false,
|
||||||
-- symbols-outline.
|
-- Automatically open hover_symbol when opening preview (see keymaps for
|
||||||
focus_on_open = true,
|
-- hover_symbol).
|
||||||
|
-- If you disable this you can still open hover_symbol using your keymap
|
||||||
|
-- below.
|
||||||
|
-- Only in this fork
|
||||||
|
open_hover_on_preview = true,
|
||||||
|
-- Border option for floating preview window.
|
||||||
|
-- Options include: single/double/rounded/solid/shadow or an array of border
|
||||||
|
-- characters.
|
||||||
|
-- See :help nvim_open_win() and search for "border" option.
|
||||||
|
border = 'single',
|
||||||
|
border_hl = 'Pmenu',
|
||||||
|
-- Highlight group for the preview background
|
||||||
|
bg_hl = 'Pmenu',
|
||||||
-- Pseudo-transparency of the preview window
|
-- Pseudo-transparency of the preview window
|
||||||
winblend = 0
|
winblend = 0
|
||||||
|
},
|
||||||
|
|
||||||
-- These keymaps can be a string or a table for multiple keys
|
-- These keymaps can be a string or a table for multiple keys
|
||||||
keymaps = {
|
keymaps = {
|
||||||
@@ -479,14 +526,19 @@ local opts = {
|
|||||||
up_and_goto = '<C-k>',
|
up_and_goto = '<C-k>',
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Lsp clients to ignore
|
providers = {
|
||||||
lsp_blacklist = {},
|
lsp = {
|
||||||
-- Symbols to ignore.
|
-- Lsp client names to ignore
|
||||||
-- Possible values: lua/symbols-outline/symbols.lua
|
blacklist_clients = {},
|
||||||
symbol_blacklist = {},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
symbols = {
|
symbols = {
|
||||||
-- Changed in this fork
|
-- Symbols to ignore.
|
||||||
|
-- Possible values are the Keys in the icons table below.
|
||||||
|
blacklist = {},
|
||||||
|
-- Changed in this fork to fix deprecated icons not showing.
|
||||||
|
icons = {
|
||||||
File = { icon = "", hl = "@text.uri" },
|
File = { icon = "", hl = "@text.uri" },
|
||||||
Module = { icon = "", hl = "@namespace" },
|
Module = { icon = "", hl = "@namespace" },
|
||||||
Namespace = { icon = "", hl = "@namespace" },
|
Namespace = { icon = "", hl = "@namespace" },
|
||||||
@@ -515,16 +567,17 @@ local opts = {
|
|||||||
TypeParameter = { icon = "𝙏", hl = "@parameter" },
|
TypeParameter = { icon = "𝙏", hl = "@parameter" },
|
||||||
Component = { icon = "", hl = "@function" },
|
Component = { icon = "", hl = "@function" },
|
||||||
Fragment = { icon = "", hl = "@constant" },
|
Fragment = { icon = "", hl = "@constant" },
|
||||||
-- ccls
|
-- Added ccls symbols in this fork
|
||||||
TypeAlias = { icon = ' ', hl = '@type' },
|
TypeAlias = { icon = ' ', hl = '@type' },
|
||||||
Parameter = { icon = ' ', hl = '@parameter' },
|
Parameter = { icon = ' ', hl = '@parameter' },
|
||||||
StaticMethod = { icon = ' ', hl = '@function' },
|
StaticMethod = { icon = ' ', hl = '@function' },
|
||||||
Macro = { icon = ' ', hl = '@macro' },
|
Macro = { icon = ' ', hl = '@macro' },
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
To find out exactly what some of the options do, check out the
|
To find out exactly what some of the options do, please see the
|
||||||
[recipes](#recipes) section of the readme at the bottom for screen-recordings.
|
[recipes](#recipes) section of the readme at the bottom for screen-recordings.
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
@@ -576,7 +629,47 @@ To find out exactly what some of the options do, check out the
|
|||||||
With bang, it can be understood as the converse of `focus_location`.
|
With bang, it can be understood as the converse of `focus_location`.
|
||||||
|
|
||||||
|
|
||||||
### Lua API
|
## Default keymaps
|
||||||
|
|
||||||
|
These mappings are active for the outline window.
|
||||||
|
|
||||||
|
| Key | Action |
|
||||||
|
| ---------- | -------------------------------------------------- |
|
||||||
|
| Escape | Close outline |
|
||||||
|
| ? | Show help message |
|
||||||
|
| Enter | Go to symbol location in code |
|
||||||
|
| o | Go to symbol location in code without losing focus |
|
||||||
|
| Ctrl+k | Go up and goto location |
|
||||||
|
| Ctrl+j | Go down and goto location |
|
||||||
|
| Ctrl+g | Go to code location in outline window |
|
||||||
|
| Ctrl+Space | Hover current symbol |
|
||||||
|
| K | Toggles the current symbol preview |
|
||||||
|
| r | Rename symbol |
|
||||||
|
| a | Code actions |
|
||||||
|
| h | Fold symbol or parent symbol |
|
||||||
|
| Tab | Toggle fold under cursor |
|
||||||
|
| Shift+Tab | Toggle all folds |
|
||||||
|
| l | Unfold symbol |
|
||||||
|
| W | Fold all symbols |
|
||||||
|
| E | Unfold all symbols |
|
||||||
|
| R | Reset all folding |
|
||||||
|
|
||||||
|
## Highlights
|
||||||
|
|
||||||
|
| Highlight | Purpose |
|
||||||
|
| ----------------------- | -------------------------------------- |
|
||||||
|
| FocusedSymbol | Highlight of the focused symbol |
|
||||||
|
| Pmenu | Highlight of the preview popup windows |
|
||||||
|
| SymbolsOutlineConnector | Highlight of the table connectors |
|
||||||
|
| Comment | Highlight of the info virtual text |
|
||||||
|
|
||||||
|
|
||||||
|
Note that some highlights are configurable such as the preview window border and
|
||||||
|
background. Please see [configuration options](#default-options).
|
||||||
|
|
||||||
|
## Lua API
|
||||||
|
|
||||||
|
Symbols-outline provides the following public API for use in lua.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require'symbols-outline'
|
require'symbols-outline'
|
||||||
@@ -630,40 +723,17 @@ require'symbols-outline'
|
|||||||
|
|
||||||
With `opts.focus_outline=false`, cursor focus will remain on code window.
|
With `opts.focus_outline=false`, cursor focus will remain on code window.
|
||||||
|
|
||||||
|
## Tips
|
||||||
|
|
||||||
## Default keymaps
|
- To open the outline but don't focus on it, you can use `:SymbolsOutline!` or
|
||||||
|
`:SymbolsOutlineOpen`.
|
||||||
|
|
||||||
These mappings are active for the outline window.
|
This is useful in autocmds, say you have a filetype that, whenever a buffer with
|
||||||
|
that filetype is opened you want to open the outline.
|
||||||
|
|
||||||
| Key | Action |
|
- After navigating around in the outline window, you can use `<C-g>` (default
|
||||||
| ---------- | -------------------------------------------------- |
|
mapping for `restore_location`) to go back to the corresponding outline
|
||||||
| Escape | Close outline |
|
location based on the code location.
|
||||||
| ? | Show help message |
|
|
||||||
| Enter | Go to symbol location in code |
|
|
||||||
| o | Go to symbol location in code without losing focus |
|
|
||||||
| Ctrl+k | Go up and goto location |
|
|
||||||
| Ctrl+j | Go down and goto location |
|
|
||||||
| Ctrl+g | Go to code location in outline window |
|
|
||||||
| Ctrl+Space | Hover current symbol |
|
|
||||||
| K | Toggles the current symbol preview |
|
|
||||||
| r | Rename symbol |
|
|
||||||
| a | Code actions |
|
|
||||||
| h | Fold symbol or parent symbol |
|
|
||||||
| Tab | Toggle fold under cursor |
|
|
||||||
| Shift+Tab | Toggle all folds |
|
|
||||||
| l | Unfold symbol |
|
|
||||||
| W | Fold all symbols |
|
|
||||||
| E | Unfold all symbols |
|
|
||||||
| R | Reset all folding |
|
|
||||||
|
|
||||||
## Highlights
|
|
||||||
|
|
||||||
| Highlight | Purpose |
|
|
||||||
| ----------------------- | -------------------------------------- |
|
|
||||||
| FocusedSymbol | Highlight of the focused symbol |
|
|
||||||
| Pmenu | Highlight of the preview popup windows |
|
|
||||||
| SymbolsOutlineConnector | Highlight of the table connectors |
|
|
||||||
| Comment | Highlight of the info virtual text |
|
|
||||||
|
|
||||||
|
|
||||||
## Recipes
|
## Recipes
|
||||||
@@ -671,30 +741,40 @@ These mappings are active for the outline window.
|
|||||||
Behaviour you may want to achieve and the combination of configuration options
|
Behaviour you may want to achieve and the combination of configuration options
|
||||||
to achieve it.
|
to achieve it.
|
||||||
|
|
||||||
|
Code snippets in this section are to be placed in `.setup({ <HERE> })` directly
|
||||||
|
unless specified otherwise.
|
||||||
|
|
||||||
**Unfold all others except currently hovered item**
|
**Unfold all others except currently hovered item**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
symbol_folding = {
|
||||||
autofold_depth = 1,
|
autofold_depth = 1,
|
||||||
auto_unfold_hover = true,
|
auto_unfold_hover = true,
|
||||||
|
},
|
||||||
```
|
```
|
||||||
<img width="900" alt="image" src="https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/2e0c5f91-a979-4e64-a100-256ad062dce3">
|
<img width="900" alt="image" src="https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/2e0c5f91-a979-4e64-a100-256ad062dce3">
|
||||||
|
|
||||||
|
|
||||||
Any other recipes you think others may also find useful? Feel free to open a PR.
|
|
||||||
|
|
||||||
**Use outline window as a quick-jump window**
|
**Use outline window as a quick-jump window**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
preview_window = {
|
||||||
auto_preview = true,
|
auto_preview = true,
|
||||||
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/a473d791-d1b9-48e9-917f-b816b564a645
|
https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/a473d791-d1b9-48e9-917f-b816b564a645
|
||||||
|
|
||||||
|
Note that in the recording I have `preview_window.open_hover_on_preview =
|
||||||
|
false`.
|
||||||
|
|
||||||
Alternatively, if you want to automatically navigate to the corresponding code
|
Alternatively, if you want to automatically navigate to the corresponding code
|
||||||
location and not use the preview window:
|
location directly and not use the preview window:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
outline_window = {
|
||||||
auto_goto = true,
|
auto_goto = true,
|
||||||
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
This feature was added by @stickperson in an upstream PR 🙌
|
This feature was added by @stickperson in an upstream PR 🙌
|
||||||
@@ -704,21 +784,30 @@ https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/3d06e342-97ac-40
|
|||||||
Or, you can use keys `<C-j>` and `<C-k>` to achieve the same effect, whilst not
|
Or, you can use keys `<C-j>` and `<C-k>` to achieve the same effect, whilst not
|
||||||
having `auto_goto` on by default.
|
having `auto_goto` on by default.
|
||||||
|
|
||||||
|
This feature is newly added in this fork.
|
||||||
|
|
||||||
**Hide the extra details after each symbol name**
|
**Hide the extra details after each symbol name**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
outline_items = {
|
||||||
show_symbol_details = false,
|
show_symbol_details = false,
|
||||||
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
**Show line numbers next to each symbol to jump to that symbol quickly**
|
**Show line numbers next to each symbol to jump to that symbol quickly**
|
||||||
|
|
||||||
|
This feature is newly added in this fork.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
show_symbol_lineno = true,
|
outline_items = {
|
||||||
|
show_symbol_lineno = false,
|
||||||
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
The default highlight group is `LineNr`.
|
The default highlight group for the line numbers is `LineNr`.
|
||||||
|
|
||||||
<img width="900" alt="image" src="https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/2bbb5833-f40b-4c53-8338-407252d61443">
|
<img width="900" alt="image" src="https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/2bbb5833-f40b-4c53-8338-407252d61443">
|
||||||
|
|
||||||
|
---
|
||||||
|
Any other recipes you think others may also find useful? Feel free to open a PR.
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ local vim = vim
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.defaults = {
|
M.defaults = {
|
||||||
position = 'right',
|
|
||||||
width = 25,
|
|
||||||
highlight_hovered_item = true,
|
|
||||||
guides = {
|
guides = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
markers = {
|
markers = {
|
||||||
@@ -15,24 +12,39 @@ M.defaults = {
|
|||||||
horizontal = '─',
|
horizontal = '─',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
border = 'single',
|
outline_items = {
|
||||||
|
show_symbol_details = true,
|
||||||
|
show_symbol_lineno = false,
|
||||||
|
highlight_hovered_item = true,
|
||||||
|
},
|
||||||
|
outline_window = {
|
||||||
|
position = 'right',
|
||||||
|
width = 25,
|
||||||
relative_width = true,
|
relative_width = true,
|
||||||
|
wrap = false,
|
||||||
|
focus_on_open = true,
|
||||||
auto_close = false,
|
auto_close = false,
|
||||||
auto_goto = false,
|
auto_goto = false,
|
||||||
auto_preview = false,
|
|
||||||
open_hover_on_preview = true,
|
|
||||||
show_numbers = false,
|
show_numbers = false,
|
||||||
show_relative_numbers = false,
|
show_relative_numbers = false,
|
||||||
show_cursorline = true,
|
show_cursorline = true,
|
||||||
show_symbol_details = true,
|
},
|
||||||
show_symbol_lineno = false,
|
preview_window = {
|
||||||
preview_bg_highlight = 'Pmenu',
|
auto_preview = false,
|
||||||
|
width = 50,
|
||||||
|
min_width = 100,
|
||||||
|
relative_width = true,
|
||||||
|
bg_hl = 'Pmenu',
|
||||||
|
border = 'single',
|
||||||
|
border_hl = 'Pmenu',
|
||||||
|
open_hover_on_preview = true,
|
||||||
winblend = 0,
|
winblend = 0,
|
||||||
|
},
|
||||||
|
symbol_folding = {
|
||||||
autofold_depth = nil,
|
autofold_depth = nil,
|
||||||
auto_unfold_hover = true,
|
auto_unfold_hover = true,
|
||||||
fold_markers = { '', '' },
|
markers = { '', '' },
|
||||||
wrap = false,
|
},
|
||||||
focus_on_open = true,
|
|
||||||
keymaps = {
|
keymaps = {
|
||||||
show_help = '?',
|
show_help = '?',
|
||||||
close = { '<Esc>', 'q' },
|
close = { '<Esc>', 'q' },
|
||||||
@@ -53,9 +65,14 @@ M.defaults = {
|
|||||||
down_and_goto = '<C-j>',
|
down_and_goto = '<C-j>',
|
||||||
up_and_goto = '<C-k>',
|
up_and_goto = '<C-k>',
|
||||||
},
|
},
|
||||||
lsp_blacklist = {},
|
providers = {
|
||||||
symbol_blacklist = {},
|
lsp = {
|
||||||
|
blacklist_clients = {},
|
||||||
|
},
|
||||||
|
},
|
||||||
symbols = {
|
symbols = {
|
||||||
|
blacklist = {},
|
||||||
|
icons = {
|
||||||
File = { icon = '', hl = '@text.uri' },
|
File = { icon = '', hl = '@text.uri' },
|
||||||
Module = { icon = '', hl = '@namespace' },
|
Module = { icon = '', hl = '@namespace' },
|
||||||
Namespace = { icon = '', hl = '@namespace' },
|
Namespace = { icon = '', hl = '@namespace' },
|
||||||
@@ -90,16 +107,17 @@ M.defaults = {
|
|||||||
StaticMethod = { icon = ' ', hl = '@function' },
|
StaticMethod = { icon = ' ', hl = '@function' },
|
||||||
Macro = { icon = ' ', hl = '@macro' },
|
Macro = { icon = ' ', hl = '@macro' },
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
M.options = {}
|
M.o = {}
|
||||||
|
|
||||||
function M.has_numbers()
|
function M.has_numbers()
|
||||||
return M.options.show_numbers or M.options.show_relative_numbers
|
return M.o.outline_window.show_numbers or M.o.outline_window.show_relative_numbers
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_position_navigation_direction()
|
function M.get_position_navigation_direction()
|
||||||
if M.options.position == 'left' then
|
if M.o.outline_window.position == 'left' then
|
||||||
return 'h'
|
return 'h'
|
||||||
else
|
else
|
||||||
return 'l'
|
return 'l'
|
||||||
@@ -107,15 +125,15 @@ function M.get_position_navigation_direction()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.get_window_width()
|
function M.get_window_width()
|
||||||
if M.options.relative_width then
|
if M.o.outline_window.relative_width then
|
||||||
return math.ceil(vim.o.columns * (M.options.width / 100))
|
return math.ceil(vim.o.columns * (M.o.outline_window.width / 100))
|
||||||
else
|
else
|
||||||
return M.options.width
|
return M.o.outline_window.width
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_split_command()
|
function M.get_split_command()
|
||||||
if M.options.position == 'left' then
|
if M.o.outline_window.position == 'left' then
|
||||||
return 'topleft vs'
|
return 'topleft vs'
|
||||||
else
|
else
|
||||||
return 'botright vs'
|
return 'botright vs'
|
||||||
@@ -136,7 +154,7 @@ function M.is_symbol_blacklisted(kind)
|
|||||||
if kind == nil then
|
if kind == nil then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return has_value(M.options.symbol_blacklist, kind)
|
return has_value(M.o.symbols.blacklist, kind)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.is_client_blacklisted(client_id)
|
function M.is_client_blacklisted(client_id)
|
||||||
@@ -144,17 +162,21 @@ function M.is_client_blacklisted(client_id)
|
|||||||
if not client then
|
if not client then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
return has_value(M.options.lsp_blacklist, client.name)
|
return has_value(M.o.providers.lsp.blacklist_clients, client.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.show_help()
|
function M.show_help()
|
||||||
print 'Current keymaps:'
|
print 'Current keymaps:'
|
||||||
print(vim.inspect(M.options.keymaps))
|
print(vim.inspect(M.o.keymaps))
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup(options)
|
function M.setup(options)
|
||||||
vim.g.symbols_outline_loaded = 1
|
vim.g.symbols_outline_loaded = 1
|
||||||
M.options = vim.tbl_deep_extend('force', {}, M.defaults, options or {})
|
M.o = vim.tbl_deep_extend('force', {}, M.defaults, options or {})
|
||||||
|
local guides = M.o.guides
|
||||||
|
if type(guides) == 'boolean' and guides then
|
||||||
|
M.o.guides = M.defaults.guides
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
local config = require 'symbols-outline.config'
|
local cfg = require 'symbols-outline.config'
|
||||||
|
|
||||||
M.is_foldable = function(node)
|
M.is_foldable = function(node)
|
||||||
return node.children and #node.children > 0
|
return node.children and #node.children > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local get_default_folded = function(depth)
|
local get_default_folded = function(depth)
|
||||||
local fold_past = config.options.autofold_depth
|
local fold_past = cfg.o.symbol_folding.autofold_depth
|
||||||
if not fold_past then
|
if not fold_past then
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
@@ -17,7 +17,7 @@ end
|
|||||||
M.is_folded = function(node)
|
M.is_folded = function(node)
|
||||||
if node.folded ~= nil then
|
if node.folded ~= nil then
|
||||||
return node.folded
|
return node.folded
|
||||||
elseif node.hovered and config.options.auto_unfold_hover then
|
elseif node.hovered and cfg.o.symbol_folding.auto_unfold_hover then
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
return get_default_folded(node.depth)
|
return get_default_folded(node.depth)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local so = require 'symbols-outline'
|
local so = require 'symbols-outline'
|
||||||
local soconfig = require 'symbols-outline.config'
|
local cfg = require 'symbols-outline.config'
|
||||||
local util = vim.lsp.util
|
local util = vim.lsp.util
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
@@ -40,7 +40,7 @@ function M.show_hover()
|
|||||||
end
|
end
|
||||||
-- FIXME
|
-- FIXME
|
||||||
local bufnr, winnr = util.open_floating_preview(markdown_lines, 'markdown', config)
|
local bufnr, winnr = util.open_floating_preview(markdown_lines, 'markdown', config)
|
||||||
local winhi = 'Normal:' .. soconfig.options.preview_bg_highlight
|
local winhi = 'Normal:' .. cfg.o.preview_window.bg_hl
|
||||||
vim.api.nvim_win_set_option(winnr, 'winhighlight', winhi)
|
vim.api.nvim_win_set_option(winnr, 'winhighlight', winhi)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ local parser = require 'symbols-outline.parser'
|
|||||||
local providers = require 'symbols-outline.providers.init'
|
local providers = require 'symbols-outline.providers.init'
|
||||||
local ui = require 'symbols-outline.ui'
|
local ui = require 'symbols-outline.ui'
|
||||||
local writer = require 'symbols-outline.writer'
|
local writer = require 'symbols-outline.writer'
|
||||||
local config = require 'symbols-outline.config'
|
local cfg = require 'symbols-outline.config'
|
||||||
local utils = require 'symbols-outline.utils.init'
|
local utils = require 'symbols-outline.utils.init'
|
||||||
local View = require 'symbols-outline.view'
|
local View = require 'symbols-outline.view'
|
||||||
local folding = require 'symbols-outline.folding'
|
local folding = require 'symbols-outline.folding'
|
||||||
@@ -11,7 +11,7 @@ local M = {}
|
|||||||
|
|
||||||
local function setup_global_autocmd()
|
local function setup_global_autocmd()
|
||||||
if
|
if
|
||||||
config.options.highlight_hovered_item or config.options.auto_unfold_hover
|
cfg.o.outline_items.highlight_hovered_item or cfg.o.symbol_folding.auto_unfold_hover
|
||||||
then
|
then
|
||||||
vim.api.nvim_create_autocmd('CursorHold', {
|
vim.api.nvim_create_autocmd('CursorHold', {
|
||||||
pattern = '*',
|
pattern = '*',
|
||||||
@@ -107,7 +107,7 @@ end
|
|||||||
-- Wraps __goto_location and handles auto_close
|
-- Wraps __goto_location and handles auto_close
|
||||||
function M._goto_location(change_focus)
|
function M._goto_location(change_focus)
|
||||||
M.__goto_location(change_focus)
|
M.__goto_location(change_focus)
|
||||||
if change_focus and config.options.auto_close then
|
if change_focus and cfg.o.outline_window.auto_close then
|
||||||
M.close_outline()
|
M.close_outline()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -130,7 +130,7 @@ function M._toggle_fold(move_cursor, node_index)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function setup_buffer_autocmd()
|
local function setup_buffer_autocmd()
|
||||||
if config.options.auto_preview then
|
if cfg.o.preview_window.auto_preview then
|
||||||
vim.api.nvim_create_autocmd('CursorMoved', {
|
vim.api.nvim_create_autocmd('CursorMoved', {
|
||||||
buffer = 0,
|
buffer = 0,
|
||||||
callback = require('symbols-outline.preview').show,
|
callback = require('symbols-outline.preview').show,
|
||||||
@@ -141,7 +141,7 @@ local function setup_buffer_autocmd()
|
|||||||
callback = require('symbols-outline.preview').close,
|
callback = require('symbols-outline.preview').close,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
if config.options.auto_goto then
|
if cfg.o.outline_window.auto_goto then
|
||||||
vim.api.nvim_create_autocmd('CursorMoved', {
|
vim.api.nvim_create_autocmd('CursorMoved', {
|
||||||
buffer = 0,
|
buffer = 0,
|
||||||
callback = function()
|
callback = function()
|
||||||
@@ -261,76 +261,76 @@ local function setup_keymaps(bufnr)
|
|||||||
utils.nmap(bufnr, ...)
|
utils.nmap(bufnr, ...)
|
||||||
end
|
end
|
||||||
-- goto_location of symbol and focus that window
|
-- goto_location of symbol and focus that window
|
||||||
map(config.options.keymaps.goto_location, function()
|
map(cfg.o.keymaps.goto_location, function()
|
||||||
M._goto_location(true)
|
M._goto_location(true)
|
||||||
end)
|
end)
|
||||||
-- goto_location of symbol but stay in outline
|
-- goto_location of symbol but stay in outline
|
||||||
map(config.options.keymaps.peek_location, function()
|
map(cfg.o.keymaps.peek_location, function()
|
||||||
M._goto_location(false)
|
M._goto_location(false)
|
||||||
end)
|
end)
|
||||||
-- Navigate to corresponding outline location for current code location
|
-- Navigate to corresponding outline location for current code location
|
||||||
map(config.options.keymaps.restore_location, function()
|
map(cfg.o.keymaps.restore_location, function()
|
||||||
M._map_follow_cursor()
|
M._map_follow_cursor()
|
||||||
end)
|
end)
|
||||||
-- Move down/up in outline and peek that location in code
|
-- Move down/up in outline and peek that location in code
|
||||||
map(config.options.keymaps.down_and_goto, function()
|
map(cfg.o.keymaps.down_and_goto, function()
|
||||||
M._move_and_goto('down')
|
M._move_and_goto('down')
|
||||||
end)
|
end)
|
||||||
-- Move down/up in outline and peek that location in code
|
-- Move down/up in outline and peek that location in code
|
||||||
map(config.options.keymaps.up_and_goto, function()
|
map(cfg.o.keymaps.up_and_goto, function()
|
||||||
M._move_and_goto('up')
|
M._move_and_goto('up')
|
||||||
end)
|
end)
|
||||||
-- hover symbol
|
-- hover symbol
|
||||||
map(
|
map(
|
||||||
config.options.keymaps.hover_symbol,
|
cfg.o.keymaps.hover_symbol,
|
||||||
require('symbols-outline.hover').show_hover
|
require('symbols-outline.hover').show_hover
|
||||||
)
|
)
|
||||||
-- preview symbol
|
-- preview symbol
|
||||||
map(
|
map(
|
||||||
config.options.keymaps.toggle_preview,
|
cfg.o.keymaps.toggle_preview,
|
||||||
require('symbols-outline.preview').toggle
|
require('symbols-outline.preview').toggle
|
||||||
)
|
)
|
||||||
-- rename symbol
|
-- rename symbol
|
||||||
map(
|
map(
|
||||||
config.options.keymaps.rename_symbol,
|
cfg.o.keymaps.rename_symbol,
|
||||||
require('symbols-outline.rename').rename
|
require('symbols-outline.rename').rename
|
||||||
)
|
)
|
||||||
-- code actions
|
-- code actions
|
||||||
map(
|
map(
|
||||||
config.options.keymaps.code_actions,
|
cfg.o.keymaps.code_actions,
|
||||||
require('symbols-outline.code_action').show_code_actions
|
require('symbols-outline.code_action').show_code_actions
|
||||||
)
|
)
|
||||||
-- show help
|
-- show help
|
||||||
map(
|
map(
|
||||||
config.options.keymaps.show_help,
|
cfg.o.keymaps.show_help,
|
||||||
require('symbols-outline.config').show_help
|
require('symbols-outline.config').show_help
|
||||||
)
|
)
|
||||||
-- close outline
|
-- close outline
|
||||||
map(config.options.keymaps.close, function()
|
map(cfg.o.keymaps.close, function()
|
||||||
M.view:close()
|
M.view:close()
|
||||||
end)
|
end)
|
||||||
-- toggle fold selection
|
-- toggle fold selection
|
||||||
map(config.options.keymaps.fold_toggle, M._toggle_fold)
|
map(cfg.o.keymaps.fold_toggle, M._toggle_fold)
|
||||||
-- fold selection
|
-- fold selection
|
||||||
map(config.options.keymaps.fold, function()
|
map(cfg.o.keymaps.fold, function()
|
||||||
M._set_folded(true)
|
M._set_folded(true)
|
||||||
end)
|
end)
|
||||||
-- unfold selection
|
-- unfold selection
|
||||||
map(config.options.keymaps.unfold, function()
|
map(cfg.o.keymaps.unfold, function()
|
||||||
M._set_folded(false)
|
M._set_folded(false)
|
||||||
end)
|
end)
|
||||||
-- toggle fold all
|
-- toggle fold all
|
||||||
map(config.options.keymaps.fold_toggle_all, M._toggle_all_fold)
|
map(cfg.o.keymaps.fold_toggle_all, M._toggle_all_fold)
|
||||||
-- fold all
|
-- fold all
|
||||||
map(config.options.keymaps.fold_all, function()
|
map(cfg.o.keymaps.fold_all, function()
|
||||||
M._set_all_folded(true)
|
M._set_all_folded(true)
|
||||||
end)
|
end)
|
||||||
-- unfold all
|
-- unfold all
|
||||||
map(config.options.keymaps.unfold_all, function()
|
map(cfg.o.keymaps.unfold_all, function()
|
||||||
M._set_all_folded(false)
|
M._set_all_folded(false)
|
||||||
end)
|
end)
|
||||||
-- fold reset
|
-- fold reset
|
||||||
map(config.options.keymaps.fold_reset, function()
|
map(cfg.o.keymaps.fold_reset, function()
|
||||||
M._set_all_folded(nil)
|
M._set_all_folded(nil)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -362,7 +362,7 @@ local function handler(response, opts)
|
|||||||
|
|
||||||
M._highlight_current_item(M.state.code_win)
|
M._highlight_current_item(M.state.code_win)
|
||||||
|
|
||||||
if not config.options.focus_on_open or (opts and not opts.focus_outline) then
|
if not cfg.o.outline_window.focus_on_open or (opts and not opts.focus_outline) then
|
||||||
vim.fn.win_gotoid(M.state.code_win)
|
vim.fn.win_gotoid(M.state.code_win)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -561,7 +561,7 @@ end
|
|||||||
|
|
||||||
---Set up configuration options for symbols-outline.
|
---Set up configuration options for symbols-outline.
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
config.setup(opts)
|
cfg.setup(opts)
|
||||||
ui.setup_highlights()
|
ui.setup_highlights()
|
||||||
|
|
||||||
M.view = View:new()
|
M.view = View:new()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local symbols = require 'symbols-outline.symbols'
|
local symbols = require 'symbols-outline.symbols'
|
||||||
local ui = require 'symbols-outline.ui'
|
local ui = require 'symbols-outline.ui'
|
||||||
local config = require 'symbols-outline.config'
|
local cfg = require 'symbols-outline.config'
|
||||||
local t_utils = require 'symbols-outline.utils.table'
|
local t_utils = require 'symbols-outline.utils.table'
|
||||||
local lsp_utils = require 'symbols-outline.utils.lsp_utils'
|
local lsp_utils = require 'symbols-outline.utils.lsp_utils'
|
||||||
local folding = require 'symbols-outline.folding'
|
local folding = require 'symbols-outline.folding'
|
||||||
@@ -17,7 +17,7 @@ local function parse_result(result, depth, hierarchy, parent)
|
|||||||
local ret = {}
|
local ret = {}
|
||||||
|
|
||||||
for index, value in pairs(result) do
|
for index, value in pairs(result) do
|
||||||
if not config.is_symbol_blacklisted(symbols.kinds[value.kind]) then
|
if not cfg.is_symbol_blacklisted(symbols.kinds[value.kind]) then
|
||||||
-- the hierarchy is basically a table of booleans which tells whether
|
-- the hierarchy is basically a table of booleans which tells whether
|
||||||
-- the parent was the last in its group or not
|
-- the parent was the last in its group or not
|
||||||
local hir = hierarchy or {}
|
local hir = hierarchy or {}
|
||||||
@@ -99,7 +99,7 @@ function M.get_lines(flattened_outline_items)
|
|||||||
|
|
||||||
for node_line, node in ipairs(flattened_outline_items) do
|
for node_line, node in ipairs(flattened_outline_items) do
|
||||||
local depth = node.depth
|
local depth = node.depth
|
||||||
local marker_space = (config.options.fold_markers and 1) or 0
|
local marker_space = (cfg.o.symbol_folding.markers and 1) or 0
|
||||||
|
|
||||||
local line = t_utils.str_to_table(string.rep(' ', depth + marker_space))
|
local line = t_utils.str_to_table(string.rep(' ', depth + marker_space))
|
||||||
local running_length = 1
|
local running_length = 1
|
||||||
@@ -118,15 +118,15 @@ function M.get_lines(flattened_outline_items)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for index, _ in ipairs(line) do
|
for index, _ in ipairs(line) do
|
||||||
if config.options.guides.enabled then
|
if cfg.o.guides.enabled then
|
||||||
local guide_markers = config.options.guides.markers
|
local guide_markers = cfg.o.guides.markers
|
||||||
if index == 1 then
|
if index == 1 then
|
||||||
line[index] = ''
|
line[index] = ''
|
||||||
-- if index is last, add a bottom marker if current item is last,
|
-- if index is last, add a bottom marker if current item is last,
|
||||||
-- else add a middle marker
|
-- else add a middle marker
|
||||||
elseif index == #line then
|
elseif index == #line then
|
||||||
-- add fold markers
|
-- add fold markers
|
||||||
local fold_markers = config.options.fold_markers
|
local fold_markers = cfg.o.symbol_folding.markers
|
||||||
if fold_markers and folding.is_foldable(node) then
|
if fold_markers and folding.is_foldable(node) then
|
||||||
if folding.is_folded(node) then
|
if folding.is_folded(node) then
|
||||||
line[index] = fold_markers[1]
|
line[index] = fold_markers[1]
|
||||||
@@ -184,14 +184,14 @@ function M.get_lines(flattened_outline_items)
|
|||||||
|
|
||||||
local hl_start = #string_prefix
|
local hl_start = #string_prefix
|
||||||
local hl_end = #string_prefix + #node.icon
|
local hl_end = #string_prefix + #node.icon
|
||||||
local hl_type = config.options.symbols[symbols.kinds[node.kind]].hl
|
local hl_type = cfg.o.symbols.icons[symbols.kinds[node.kind]].hl
|
||||||
table.insert(hl_info, { node_line, hl_start, hl_end, hl_type })
|
table.insert(hl_info, { node_line, hl_start, hl_end, hl_type })
|
||||||
|
|
||||||
node.prefix_length = #string_prefix + #node.icon + 1
|
node.prefix_length = #string_prefix + #node.icon + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local final_hl = {}
|
local final_hl = {}
|
||||||
if config.options.show_symbol_lineno then
|
if cfg.o.outline_items.show_symbol_lineno then
|
||||||
-- Width of the highest lineno value
|
-- Width of the highest lineno value
|
||||||
local max_width = #tostring(lineno_max)
|
local max_width = #tostring(lineno_max)
|
||||||
-- Padded prefix to the right of lineno for better readability if linenos
|
-- Padded prefix to the right of lineno for better readability if linenos
|
||||||
@@ -209,7 +209,7 @@ function M.get_lines(flattened_outline_items)
|
|||||||
})
|
})
|
||||||
node.prefix_length = node.prefix_length + total_offset
|
node.prefix_length = node.prefix_length + total_offset
|
||||||
end
|
end
|
||||||
if config.options.guides.enabled then
|
if cfg.o.guides.enabled then
|
||||||
for _, hl in ipairs(guide_hl_info) do
|
for _, hl in ipairs(guide_hl_info) do
|
||||||
table.insert(final_hl, {
|
table.insert(final_hl, {
|
||||||
hl[1],
|
hl[1],
|
||||||
@@ -222,7 +222,7 @@ function M.get_lines(flattened_outline_items)
|
|||||||
else
|
else
|
||||||
-- Merge lists hl_info and guide_hl_info
|
-- Merge lists hl_info and guide_hl_info
|
||||||
final_hl = hl_info
|
final_hl = hl_info
|
||||||
if config.options.guides.enabled then
|
if cfg.o.guides.enabled then
|
||||||
for _, hl in ipairs(guide_hl_info) do
|
for _, hl in ipairs(guide_hl_info) do
|
||||||
table.insert(final_hl, hl)
|
table.insert(final_hl, hl)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local so = require 'symbols-outline'
|
local so = require 'symbols-outline'
|
||||||
local config = require 'symbols-outline.config'
|
local cfg = require 'symbols-outline.config'
|
||||||
local hover = require 'symbols-outline.hover'
|
local hover = require 'symbols-outline.hover'
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
@@ -31,11 +31,11 @@ local function get_offset()
|
|||||||
local width = 53
|
local width = 53
|
||||||
local height = 0
|
local height = 0
|
||||||
|
|
||||||
if config.has_numbers() then
|
if cfg.has_numbers() then
|
||||||
width = width + 4
|
width = width + 4
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.options.position == 'right' then
|
if cfg.o.outline_window.position == 'right' then
|
||||||
width = 0 - width
|
width = 0 - width
|
||||||
else
|
else
|
||||||
width = vim.api.nvim_win_get_width(outline_winnr) + 1
|
width = vim.api.nvim_win_get_width(outline_winnr) + 1
|
||||||
@@ -91,10 +91,10 @@ local function setup_preview_buf()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function set_bg_hl()
|
local function set_bg_hl()
|
||||||
local winhi = 'Normal:' .. config.options.preview_bg_highlight
|
local winhi = 'Normal:' .. cfg.o.preview_window.bg_hl
|
||||||
vim.api.nvim_win_set_option(state.preview_win, 'winhighlight', winhi)
|
vim.api.nvim_win_set_option(state.preview_win, 'winhighlight', winhi)
|
||||||
-- vim.api.nvim_win_set_option(state.hover_win, 'winhighlight', winhi)
|
-- vim.api.nvim_win_set_option(state.hover_win, 'winhighlight', winhi)
|
||||||
local winblend = config.options.winblend
|
local winblend = cfg.o.preview_window.winblend
|
||||||
vim.api.nvim_win_set_option(state.preview_win, 'winblend', winblend)
|
vim.api.nvim_win_set_option(state.preview_win, 'winblend', winblend)
|
||||||
-- vim.api.nvim_win_set_option(state.hover_win, 'winblend', winblend)
|
-- vim.api.nvim_win_set_option(state.hover_win, 'winblend', winblend)
|
||||||
end
|
end
|
||||||
@@ -119,7 +119,7 @@ local function show_preview()
|
|||||||
col = offsets[2],
|
col = offsets[2],
|
||||||
-- Position preview window middle-aligned vertically
|
-- Position preview window middle-aligned vertically
|
||||||
row = math.ceil((height - winheight) / 2),
|
row = math.ceil((height - winheight) / 2),
|
||||||
border = config.options.border,
|
border = cfg.o.preview_window.border,
|
||||||
})
|
})
|
||||||
setup_preview_buf()
|
setup_preview_buf()
|
||||||
else
|
else
|
||||||
@@ -134,7 +134,7 @@ function M.show()
|
|||||||
|
|
||||||
show_preview()
|
show_preview()
|
||||||
set_bg_hl()
|
set_bg_hl()
|
||||||
if config.options.open_hover_on_preview then
|
if cfg.o.preview_window.open_hover_on_preview then
|
||||||
hover.show_hover()
|
hover.show_hover()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function M.rename()
|
|||||||
|
|
||||||
local params = get_rename_params(node, so.state.code_win)
|
local params = get_rename_params(node, so.state.code_win)
|
||||||
|
|
||||||
local new_name = vim.fn.input('New Name: ', node.name)
|
local new_name = vim.fn.input({ prompt = 'New Name: ', default = node.name })
|
||||||
if not new_name or new_name == '' or new_name == node.name then
|
if not new_name or new_name == '' or new_name == node.name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ M.kinds = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function M.icon_from_kind(kind)
|
function M.icon_from_kind(kind)
|
||||||
local symbols = config.options.symbols
|
local symbols = config.o.symbols.icons
|
||||||
|
|
||||||
if type(kind) == 'string' then
|
if type(kind) == 'string' then
|
||||||
return symbols[kind].icon
|
return symbols[kind].icon
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local config = require 'symbols-outline.config'
|
local cfg = require('symbols-outline.config')
|
||||||
|
|
||||||
local View = {}
|
local View = {}
|
||||||
|
|
||||||
@@ -14,9 +14,9 @@ function View:setup_view()
|
|||||||
-- delete buffer when window is closed / buffer is hidden
|
-- delete buffer when window is closed / buffer is hidden
|
||||||
vim.api.nvim_buf_set_option(self.bufnr, 'bufhidden', 'delete')
|
vim.api.nvim_buf_set_option(self.bufnr, 'bufhidden', 'delete')
|
||||||
-- create a split
|
-- create a split
|
||||||
vim.cmd(config.get_split_command())
|
vim.cmd(cfg.get_split_command())
|
||||||
-- resize to a % of the current window size
|
-- resize to a % of the current window size
|
||||||
vim.cmd('vertical resize ' .. config.get_window_width())
|
vim.cmd('vertical resize ' .. cfg.get_window_width())
|
||||||
|
|
||||||
-- get current (outline) window and attach our buffer to it
|
-- get current (outline) window and attach our buffer to it
|
||||||
self.winnr = vim.api.nvim_get_current_win()
|
self.winnr = vim.api.nvim_get_current_win()
|
||||||
@@ -30,7 +30,7 @@ function View:setup_view()
|
|||||||
vim.api.nvim_win_set_option(self.winnr, 'relativenumber', false)
|
vim.api.nvim_win_set_option(self.winnr, 'relativenumber', false)
|
||||||
vim.api.nvim_win_set_option(self.winnr, 'winfixwidth', true)
|
vim.api.nvim_win_set_option(self.winnr, 'winfixwidth', true)
|
||||||
vim.api.nvim_win_set_option(self.winnr, 'list', false)
|
vim.api.nvim_win_set_option(self.winnr, 'list', false)
|
||||||
vim.api.nvim_win_set_option(self.winnr, 'wrap', config.options.wrap)
|
vim.api.nvim_win_set_option(self.winnr, 'wrap', cfg.o.outline_window.wrap)
|
||||||
vim.api.nvim_win_set_option(self.winnr, 'linebreak', true) -- only has effect when wrap=true
|
vim.api.nvim_win_set_option(self.winnr, 'linebreak', true) -- only has effect when wrap=true
|
||||||
vim.api.nvim_win_set_option(self.winnr, 'breakindent', true) -- only has effect when wrap=true
|
vim.api.nvim_win_set_option(self.winnr, 'breakindent', true) -- only has effect when wrap=true
|
||||||
-- Would be nice to use guides.markers.vertical as part of showbreak to keep
|
-- Would be nice to use guides.markers.vertical as part of showbreak to keep
|
||||||
@@ -43,15 +43,15 @@ function View:setup_view()
|
|||||||
vim.api.nvim_buf_set_option(self.bufnr, 'filetype', 'Outline')
|
vim.api.nvim_buf_set_option(self.bufnr, 'filetype', 'Outline')
|
||||||
vim.api.nvim_buf_set_option(self.bufnr, 'modifiable', false)
|
vim.api.nvim_buf_set_option(self.bufnr, 'modifiable', false)
|
||||||
|
|
||||||
if config.options.show_numbers or config.options.show_relative_numbers then
|
if cfg.o.outline_window.show_numbers or cfg.o.outline_window.show_relative_numbers then
|
||||||
vim.api.nvim_win_set_option(self.winnr, 'nu', true)
|
vim.api.nvim_win_set_option(self.winnr, 'nu', true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.options.show_relative_numbers then
|
if cfg.o.outline_window.show_relative_numbers then
|
||||||
vim.api.nvim_win_set_option(self.winnr, 'rnu', true)
|
vim.api.nvim_win_set_option(self.winnr, 'rnu', true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.options.show_cursorline then
|
if cfg.o.outline_window.show_cursorline then
|
||||||
vim.api.nvim_win_set_option(self.winnr, 'cursorline', true)
|
vim.api.nvim_win_set_option(self.winnr, 'cursorline', true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local parser = require 'symbols-outline.parser'
|
local parser = require 'symbols-outline.parser'
|
||||||
local config = require 'symbols-outline.config'
|
local cfg = require('symbols-outline.config')
|
||||||
local ui = require 'symbols-outline.ui'
|
local ui = require 'symbols-outline.ui'
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
@@ -52,7 +52,7 @@ function M.write_details(bufnr, lines)
|
|||||||
if not is_buffer_outline(bufnr) then
|
if not is_buffer_outline(bufnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not config.options.show_symbol_details then
|
if not cfg.o.outline_items.show_symbol_details then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ function M.write_lineno(bufnr, lines, max)
|
|||||||
if not is_buffer_outline(bufnr) then
|
if not is_buffer_outline(bufnr) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not config.options.show_symbol_lineno then
|
if not cfg.o.outline_items.show_symbol_lineno then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local maxwidth = #tostring(max)
|
local maxwidth = #tostring(max)
|
||||||
@@ -90,7 +90,7 @@ local function clear_virt_text(bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.add_hover_highlights = function(bufnr, nodes)
|
M.add_hover_highlights = function(bufnr, nodes)
|
||||||
if not config.options.highlight_hovered_item then
|
if not cfg.o.outline_items.highlight_hovered_item then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ M.add_hover_highlights = function(bufnr, nodes)
|
|||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
local marker_fac = (config.options.fold_markers and 1) or 0
|
local marker_fac = (cfg.o.symbol_folding.markers and 1) or 0
|
||||||
if node.prefix_length then
|
if node.prefix_length then
|
||||||
ui.add_hover_highlight(
|
ui.add_hover_highlight(
|
||||||
bufnr,
|
bufnr,
|
||||||
|
|||||||
Reference in New Issue
Block a user