feat: Blend cursor color with cursorline
This commit is contained in:
63
README.md
63
README.md
@@ -163,7 +163,9 @@ Features/Changes:
|
|||||||
lineno are now fully customizable using `outline_window.winhl`. See
|
lineno are now fully customizable using `outline_window.winhl`. See
|
||||||
[highlights](#outline-window).
|
[highlights](#outline-window).
|
||||||
|
|
||||||
Screen recordings of some of the features is shown at the [bottom of the readme](#recipes).
|
- Option to blend cursor with cursorline (`outline_window.hide_cursor`)
|
||||||
|
|
||||||
|
Screen recordings/shots of some of the features is shown at the [bottom of the readme](#recipes).
|
||||||
|
|
||||||
|
|
||||||
## PRs
|
## PRs
|
||||||
@@ -272,18 +274,23 @@ Key:
|
|||||||
|
|
||||||
Key:
|
Key:
|
||||||
```
|
```
|
||||||
|
- : Idea
|
||||||
- [ ] : Planned
|
- [ ] : Planned
|
||||||
- [/] : WIP
|
- [/] : WIP
|
||||||
- : Idea
|
- ❌ : Was idea, found usable workaround
|
||||||
|
- ✅ : Implemented
|
||||||
```
|
```
|
||||||
|
|
||||||
- Folds
|
- Folds
|
||||||
- `[ ]` Org-like <kbd>shift+tab</kbd> behavior: Open folds level-by-level
|
- `[ ]` Org-like <kbd>shift+tab</kbd> behavior: Open folds level-by-level
|
||||||
- `[ ]` Optionally not opening all child nodes when opening parent node
|
- `[ ]` Optionally not opening all child nodes when opening parent node
|
||||||
- Fold siblings and siblings of parent on startup
|
- Fold siblings and siblings of parent on startup
|
||||||
|
|
||||||
- Navigation
|
- Navigation
|
||||||
- Go to parent
|
- ❌ Go to parent (as of now you can press `hl` to achieve the same
|
||||||
- Cycle siblings
|
effect)
|
||||||
|
- ❌ Cycle siblings (as of now when reached the last sibling, you can use `hlj`
|
||||||
|
to go back to first sibling)
|
||||||
|
|
||||||
- `[ ]` simrat39/symbols-outline.nvim#75: Handling of the outline window when attached
|
- `[ ]` simrat39/symbols-outline.nvim#75: Handling of the outline window when attached
|
||||||
buffer is closed.
|
buffer is closed.
|
||||||
@@ -299,7 +306,7 @@ Key:
|
|||||||
- View
|
- View
|
||||||
- ✅ Outline window customizations (simrat39/symbols-outline.nvim#137)
|
- ✅ Outline window customizations (simrat39/symbols-outline.nvim#137)
|
||||||
- ✅ Option to show line number next to symbols (simrat39/symbols-outline.nvim#212)
|
- ✅ Option to show line number next to symbols (simrat39/symbols-outline.nvim#212)
|
||||||
- `[/]` Option to hide cursor in outline window if cursorline enabled
|
- ✅ Option to hide cursor in outline window if cursorline enabled
|
||||||
|
|
||||||
|
|
||||||
## Related plugins
|
## Related plugins
|
||||||
@@ -326,24 +333,24 @@ Supports all your favourite languages.**
|
|||||||
<!-- panvimdoc-ignore-start -->
|
<!-- panvimdoc-ignore-start -->
|
||||||
Table of contents
|
Table of contents
|
||||||
|
|
||||||
<!-- mtoc start -->
|
<!-- mtoc-start -->
|
||||||
|
|
||||||
* [Prerequisites](#prerequisites)
|
* [Prerequisites](#prerequisites)
|
||||||
* [Installation](#installation)
|
* [Installation](#installation)
|
||||||
* [Setup](#setup)
|
* [Setup](#setup)
|
||||||
* [Configuration](#configuration)
|
* [Configuration](#configuration)
|
||||||
* [Terminology](#terminology)
|
* [Terminology](#terminology)
|
||||||
* [Default options](#default-options)
|
* [Default options](#default-options)
|
||||||
* [Commands](#commands)
|
* [Commands](#commands)
|
||||||
* [Default keymaps](#default-keymaps)
|
* [Default keymaps](#default-keymaps)
|
||||||
* [Highlights](#highlights)
|
* [Highlights](#highlights)
|
||||||
* [Outline window](#outline-window)
|
* [Outline window](#outline-window)
|
||||||
* [Preview window](#preview-window)
|
* [Preview window](#preview-window)
|
||||||
* [Lua API](#lua-api)
|
* [Lua API](#lua-api)
|
||||||
* [Tips](#tips)
|
* [Tips](#tips)
|
||||||
* [Recipes](#recipes)
|
* [Recipes](#recipes)
|
||||||
|
|
||||||
<!-- mtoc end -->
|
<!-- mtoc-end -->
|
||||||
<!-- panvimdoc-ignore-end -->
|
<!-- panvimdoc-ignore-end -->
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
@@ -454,7 +461,18 @@ Default values are shown:
|
|||||||
-- Vim options for the outline window
|
-- Vim options for the outline window
|
||||||
show_numbers = false,
|
show_numbers = false,
|
||||||
show_relative_numbers = false,
|
show_relative_numbers = false,
|
||||||
show_cursorline = true, -- Only in this fork
|
|
||||||
|
-- Only in this fork (this and the one below)
|
||||||
|
show_cursorline = true,
|
||||||
|
-- Enable this when you enabled cursorline so your cursor color can
|
||||||
|
-- blend with the cursorline, in effect, as if your cursor is hidden
|
||||||
|
-- in the outline window.
|
||||||
|
-- This is useful because with cursorline, there isn't really a need
|
||||||
|
-- to know the vertical column position of the cursor and it may even
|
||||||
|
-- be distracting, rendering lineno/guides/icons unreadable.
|
||||||
|
-- This makes your line of cursor look the same as if the cursor wasn't
|
||||||
|
-- focused on the outline window.
|
||||||
|
hide_cursor = false,
|
||||||
|
|
||||||
-- Whether to wrap long lines, or let them flow off the window
|
-- Whether to wrap long lines, or let them flow off the window
|
||||||
wrap = false,
|
wrap = false,
|
||||||
@@ -816,7 +834,7 @@ symbol_folding = {
|
|||||||
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="outline window showing auto fold depth" src="https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/2e0c5f91-a979-4e64-a100-256ad062dce3">
|
||||||
|
|
||||||
|
|
||||||
- **Use outline window as a quick-jump window**
|
- **Use outline window as a quick-jump window**
|
||||||
@@ -871,8 +889,25 @@ outline_items = {
|
|||||||
The default highlight group for the line numbers is `LineNr`, you can customize
|
The default highlight group for the line numbers is `LineNr`, you can customize
|
||||||
it using `outline_window.winhl`: please see [highlights](#outline-window).
|
it using `outline_window.winhl`: please see [highlights](#outline-window).
|
||||||
|
|
||||||
<img width="900" alt="image" src="https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/2bbb5833-f40b-4c53-8338-407252d61443">
|
<img width="900" alt="outline window showing lineno" src="https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/2bbb5833-f40b-4c53-8338-407252d61443">
|
||||||
|
|
||||||
|
- **Single cursorline**
|
||||||
|
|
||||||
|
```lua
|
||||||
|
outline_window = {
|
||||||
|
show_cursorline = true,
|
||||||
|
hide_cursor = true,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This will be how the outline window look like when focused.
|
||||||
|
|
||||||
|
<img width="300" alt="outline window showing hide_cursor" src="https://github.com/hedyhli/symbols-outline.nvim/assets/50042066/1e13c4db-ae51-4e1f-a388-2758871df36a">
|
||||||
|
|
||||||
|
Note that in the screenshot, `outline_items.show_symbol_lineno` is also enabled.
|
||||||
|
|
||||||
|
Some may find this unhelpful, but one may argue that elements in each row of the
|
||||||
|
outline becomes more readable this way, hence this is an option.
|
||||||
|
|
||||||
<!-- panvimdoc-ignore-start -->
|
<!-- panvimdoc-ignore-start -->
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ M.defaults = {
|
|||||||
show_numbers = false,
|
show_numbers = false,
|
||||||
show_relative_numbers = false,
|
show_relative_numbers = false,
|
||||||
show_cursorline = true,
|
show_cursorline = true,
|
||||||
|
hide_cursor = false,
|
||||||
winhl = "SymbolsOutlineDetails:Comment,SymbolsOutlineLineno:LineNr",
|
winhl = "SymbolsOutlineDetails:Comment,SymbolsOutlineLineno:LineNr",
|
||||||
},
|
},
|
||||||
preview_window = {
|
preview_window = {
|
||||||
@@ -107,7 +108,7 @@ M.defaults = {
|
|||||||
StaticMethod = { icon = ' ', hl = '@function' },
|
StaticMethod = { icon = ' ', hl = '@function' },
|
||||||
Macro = { icon = ' ', hl = '@macro' },
|
Macro = { icon = ' ', hl = '@macro' },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
M.o = {}
|
M.o = {}
|
||||||
@@ -184,6 +185,12 @@ function M.show_help()
|
|||||||
print(vim.inspect(M.o.keymaps))
|
print(vim.inspect(M.o.keymaps))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.check_config()
|
||||||
|
if M.o.outline_window.hide_cursor and not M.o.outline_window.show_cursorline then
|
||||||
|
vim.notify("[symbols-outline.config]: hide_cursor enabled WITHOUT cursorline enabled!", vim.log.levels.ERROR)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function M.setup(options)
|
function M.setup(options)
|
||||||
vim.g.symbols_outline_loaded = 1
|
vim.g.symbols_outline_loaded = 1
|
||||||
M.o = vim.tbl_deep_extend('force', {}, M.defaults, options or {})
|
M.o = vim.tbl_deep_extend('force', {}, M.defaults, options or {})
|
||||||
@@ -191,6 +198,7 @@ function M.setup(options)
|
|||||||
if type(guides) == 'boolean' and guides then
|
if type(guides) == 'boolean' and guides then
|
||||||
M.o.guides = M.defaults.guides
|
M.o.guides = M.defaults.guides
|
||||||
end
|
end
|
||||||
|
M.check_config()
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ M.state = {
|
|||||||
outline_items = {},
|
outline_items = {},
|
||||||
flattened_outline_items = {},
|
flattened_outline_items = {},
|
||||||
code_win = 0,
|
code_win = 0,
|
||||||
|
-- In case unhide_cursor was called before hide_cursor for _some_ reason,
|
||||||
|
-- this can still be used as a fallback
|
||||||
|
original_cursor = vim.o.guicursor,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function wipe_state()
|
local function wipe_state()
|
||||||
@@ -129,6 +132,19 @@ function M._toggle_fold(move_cursor, node_index)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function hide_cursor()
|
||||||
|
-- Set cursor color to CursorLine in normal mode
|
||||||
|
M.state.original_cursor = vim.o.guicursor
|
||||||
|
local cur = vim.o.guicursor:match("n.-:(.-)[-,]")
|
||||||
|
vim.opt.guicursor:append("n:"..cur.."-Cursorline")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function unhide_cursor()
|
||||||
|
-- vim.opt doesn't seem to provide a way to remove last item, like a pop()
|
||||||
|
-- vim.o.guicursor = vim.o.guicursor:gsub(",n.-:.-$", "")
|
||||||
|
vim.o.guicursor = M.state.original_cursor
|
||||||
|
end
|
||||||
|
|
||||||
local function setup_buffer_autocmd()
|
local function setup_buffer_autocmd()
|
||||||
if cfg.o.preview_window.auto_preview then
|
if cfg.o.preview_window.auto_preview then
|
||||||
vim.api.nvim_create_autocmd('CursorMoved', {
|
vim.api.nvim_create_autocmd('CursorMoved', {
|
||||||
@@ -150,6 +166,19 @@ local function setup_buffer_autocmd()
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
if cfg.o.outline_window.hide_cursor then
|
||||||
|
-- Unfortunately guicursor is a global option, so we have to make sure to
|
||||||
|
-- set and unset when cursor leaves the outline window.
|
||||||
|
hide_cursor()
|
||||||
|
vim.api.nvim_create_autocmd('BufEnter', {
|
||||||
|
buffer = 0,
|
||||||
|
callback = hide_cursor
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd('BufLeave', {
|
||||||
|
buffer = 0,
|
||||||
|
callback = unhide_cursor
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M._set_folded(folded, move_cursor, node_index)
|
function M._set_folded(folded, move_cursor, node_index)
|
||||||
|
|||||||
Reference in New Issue
Block a user