diff --git a/README.md b/README.md
index 6fb6f93..e69a426 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,7 @@ Table of contents
* [Line numbers](#line-numbers)
* [Blend cursor with cursorline](#blend-cursor-with-cursorline)
* [Custom icons](#custom-icons)
+ * [Disable icons](#disable-icons)
* [TODO](#todo)
* [Related plugins](#related-plugins)
@@ -373,8 +374,7 @@ The order in which the sources for icons are checked is:
2. Icon source (only `lspkind` is supported for this option as of now)
3. Icons table
-A fallback is always used if the previous candidate returned either an empty
-string or a falsey value.
+A fallback is always used if the previous candidate returned a falsey value.
## Commands
@@ -572,8 +572,24 @@ require'outline'
2. Icon source
3. Icons table
- A fallback is always used if the previous candidate returned either an empty
- string or a falsey value.
+ A fallback is always used if the previous candidate returned falsey value.
+
+ You can hide an icon for a specific type by returning `""`.
+
+ Below is an example where icons are disabled for kind 'Package', and for other
+ icons use lspkind.
+
+```lua
+symbols = {
+ icon_fetcher = function(k)
+ if k == 'Package' then
+ return ""
+ end
+ return false
+ end,
+ icon_source = 'lspkind',
+}
+```
- You can customize the split command used for creating the outline window split
using `outline_window.split_command`, such as `"topleft vsp"`. See `:h windows`
@@ -601,7 +617,7 @@ symbol_folding = {
auto_unfold_hover = true,
},
```
-
+

### Auto-jump
@@ -658,7 +674,7 @@ 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).
-
+
### Blend cursor with cursorline
@@ -674,7 +690,7 @@ outline_window = {
This will be how the outline window looks like when focused:
-
+
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.
@@ -696,8 +712,33 @@ symbols = {
The fetcher function, if provided, is checked first before using `icon_source`
and `icons` as fallback.
-
+
+### Disable icons
+
+Disable all icons:
+
+```lua
+symbols = {
+ icon_fetcher = function(_) return "" end,
+}
+```
+
+Disable icons for specific kinds, and for others use lspkind:
+
+```lua
+symbols = {
+ icon_fetcher = function(k)
+ if k == 'String' then
+ return ""
+ end
+ return false
+ end,
+ icon_source = 'lspkind',
+}
+```
+
+
diff --git a/lua/outline/init.lua b/lua/outline/init.lua
index ab94d1e..78d0e67 100644
--- a/lua/outline/init.lua
+++ b/lua/outline/init.lua
@@ -299,7 +299,7 @@ function M._highlight_current_item(winnr)
if
value.line == hovered_line
- or (hovered_line > value.range_start and hovered_line < value.range_end)
+ or (hovered_line >= value.range_start and hovered_line <= value.range_end)
then
value.hovered = true
table.insert(parent_nodes, value)
diff --git a/lua/outline/symbols.lua b/lua/outline/symbols.lua
index 2b820b2..4032c58 100644
--- a/lua/outline/symbols.lua
+++ b/lua/outline/symbols.lua
@@ -51,7 +51,8 @@ function M.icon_from_kind(kind)
if type(cfg.o.symbols.icon_fetcher) == 'function' then
local icon = cfg.o.symbols.icon_fetcher(kindstr)
- if icon and icon ~= "" then
+ -- Allow returning empty string
+ if icon then
return icon
end
end
diff --git a/lua/outline/writer.lua b/lua/outline/writer.lua
index 310cec8..a753bb4 100644
--- a/lua/outline/writer.lua
+++ b/lua/outline/writer.lua
@@ -220,11 +220,18 @@ function M.make_outline(bufnr, items, codewin)
add_fold_hl(total_pref_len - fold_marker_width, total_pref_len + 1)
end
- local line = lineno_prefix..pref_str..' '..node.icon..' '..node.name
+ local line = lineno_prefix..pref_str
+ local icon_pref = 0
+ if node.icon ~= "" then
+ line = line..' '..node.icon
+ icon_pref = 1
+ end
+ line = line..' '..node.name
-- Highlight for the icon ✨
- local hl_start = #pref_str + #lineno_prefix + 1 -- Start from icon col
- local hl_end = hl_start + #node.icon -- until after icon
+ -- Start from icon col
+ local hl_start = #pref_str + #lineno_prefix + icon_pref
+ local hl_end = hl_start + #node.icon -- until after icon
local hl_type = cfg.o.symbols.icons[symbols.kinds[node.kind]].hl
table.insert(hl, { #flattened, hl_start, hl_end, hl_type })