diff --git a/README.md b/README.md
index a152da9..52620db 100644
--- a/README.md
+++ b/README.md
@@ -163,7 +163,9 @@ Features/Changes:
lineno are now fully customizable using `outline_window.winhl`. See
[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
@@ -272,18 +274,23 @@ Key:
Key:
```
+- : Idea
- [ ] : Planned
- [/] : WIP
-- : Idea
+- ❌ : Was idea, found usable workaround
+- ✅ : Implemented
```
- Folds
- `[ ]` Org-like shift+tab behavior: Open folds level-by-level
- `[ ]` Optionally not opening all child nodes when opening parent node
- Fold siblings and siblings of parent on startup
+
- Navigation
- - Go to parent
- - Cycle siblings
+ - ❌ Go to parent (as of now you can press `hl` to achieve the same
+ 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
buffer is closed.
@@ -299,7 +306,7 @@ Key:
- View
- ✅ Outline window customizations (simrat39/symbols-outline.nvim#137)
- ✅ 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
@@ -326,24 +333,24 @@ Supports all your favourite languages.**
Table of contents
-
+
* [Prerequisites](#prerequisites)
* [Installation](#installation)
* [Setup](#setup)
* [Configuration](#configuration)
- * [Terminology](#terminology)
- * [Default options](#default-options)
+ * [Terminology](#terminology)
+ * [Default options](#default-options)
* [Commands](#commands)
* [Default keymaps](#default-keymaps)
* [Highlights](#highlights)
- * [Outline window](#outline-window)
- * [Preview window](#preview-window)
+ * [Outline window](#outline-window)
+ * [Preview window](#preview-window)
* [Lua API](#lua-api)
* [Tips](#tips)
* [Recipes](#recipes)
-
+
## Prerequisites
@@ -454,7 +461,18 @@ Default values are shown:
-- Vim options for the outline window
show_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
wrap = false,
@@ -816,7 +834,7 @@ symbol_folding = {
auto_unfold_hover = true,
},
```
-
+
- **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
it using `outline_window.winhl`: please see [highlights](#outline-window).
-
+
+- **Single cursorline**
+
+```lua
+outline_window = {
+ show_cursorline = true,
+ hide_cursor = true,
+}
+```
+
+This will be how the outline window look like when focused.
+
+
+
+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.
diff --git a/lua/symbols-outline/config.lua b/lua/symbols-outline/config.lua
index d03538b..6c5417d 100644
--- a/lua/symbols-outline/config.lua
+++ b/lua/symbols-outline/config.lua
@@ -28,6 +28,7 @@ M.defaults = {
show_numbers = false,
show_relative_numbers = false,
show_cursorline = true,
+ hide_cursor = false,
winhl = "SymbolsOutlineDetails:Comment,SymbolsOutlineLineno:LineNr",
},
preview_window = {
@@ -107,7 +108,7 @@ M.defaults = {
StaticMethod = { icon = ' ', hl = '@function' },
Macro = { icon = ' ', hl = '@macro' },
},
- },
+ },
}
M.o = {}
@@ -184,6 +185,12 @@ function M.show_help()
print(vim.inspect(M.o.keymaps))
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)
vim.g.symbols_outline_loaded = 1
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
M.o.guides = M.defaults.guides
end
+ M.check_config()
end
return M
diff --git a/lua/symbols-outline/init.lua b/lua/symbols-outline/init.lua
index d66af9d..ae87260 100644
--- a/lua/symbols-outline/init.lua
+++ b/lua/symbols-outline/init.lua
@@ -46,6 +46,9 @@ M.state = {
outline_items = {},
flattened_outline_items = {},
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()
@@ -129,6 +132,19 @@ function M._toggle_fold(move_cursor, node_index)
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()
if cfg.o.preview_window.auto_preview then
vim.api.nvim_create_autocmd('CursorMoved', {
@@ -150,6 +166,19 @@ local function setup_buffer_autocmd()
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
function M._set_folded(folded, move_cursor, node_index)