Merge branch 'master' into 2826-remove-view-globals
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -49,7 +49,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
nvim_version: [ stable, nightly ]
|
nvim_version: [ stable, nightly ]
|
||||||
luals_version: [ 3.13.9 ]
|
luals_version: [ 3.15.0 ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
VIMRUNTIME: /home/runner/nvim-${{ matrix.nvim_version }}/share/nvim/runtime
|
VIMRUNTIME: /home/runner/nvim-${{ matrix.nvim_version }}/share/nvim/runtime
|
||||||
|
|||||||
@@ -2929,43 +2929,71 @@ Decorators may:
|
|||||||
- Set highlight group for the name or icons
|
- Set highlight group for the name or icons
|
||||||
- Override node icon
|
- Override node icon
|
||||||
|
|
||||||
Specify decorators and their precedence via |nvim-tree.renderer.decorators|
|
Create a `nvim_tree.api.decorator.UserDecorator` class and register it with
|
||||||
e.g. defaults with a user decorator class being overridden only by Cut: >lua
|
precedence via |nvim-tree.renderer.decorators|
|
||||||
{
|
|
||||||
"Git",
|
See |nvim-tree-decorator-example|
|
||||||
"Open",
|
|
||||||
"Hidden",
|
See `nvim-tree/_meta/api_decorator.lua` for full class documentation.
|
||||||
"Modified",
|
|
||||||
"Bookmark",
|
|
||||||
"Diagnostics",
|
|
||||||
"Copied",
|
|
||||||
MyDecorator,
|
|
||||||
"Cut",
|
|
||||||
}
|
|
||||||
|
|
||||||
See `nvim-tree/_meta/api_decorator.lua` for full
|
|
||||||
`nvim_tree.api.decorator.UserDecorator` class documentation.
|
|
||||||
<
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
11.1. DECORATOR EXAMPLE *nvim-tree-decorator-example*
|
11.1. DECORATOR EXAMPLE *nvim-tree-decorator-example*
|
||||||
|
|
||||||
|
A decorator class for nodes named "example", overridind all builtin decorators
|
||||||
|
except for Cut.
|
||||||
|
|
||||||
|
- Highlights node name with `IncSearch`
|
||||||
|
- Creates two icons `"1"` and `"2"` placed after the node name, highlighted with
|
||||||
|
`DiffAdd` and `DiffText`
|
||||||
|
- Replaces the node icon with `"N"`, highlighted with `Error `
|
||||||
|
|
||||||
|
Create a class file `~/.config/nvim/lua/my-decorator.lua`
|
||||||
|
|
||||||
|
Require and register it during |nvim-tree-setup|:
|
||||||
|
>lua
|
||||||
|
local MyDecorator = require("my-decorator")
|
||||||
|
|
||||||
|
require("nvim-tree").setup({
|
||||||
|
renderer = {
|
||||||
|
decorators = {
|
||||||
|
"Git",
|
||||||
|
"Open",
|
||||||
|
"Hidden",
|
||||||
|
"Modified",
|
||||||
|
"Bookmark",
|
||||||
|
"Diagnostics",
|
||||||
|
"Copied",
|
||||||
|
MyDecorator,
|
||||||
|
"Cut",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
<
|
||||||
|
Contents of `my-decorator.lua`:
|
||||||
>lua
|
>lua
|
||||||
---Create your decorator class
|
|
||||||
---@class (exact) MyDecorator: nvim_tree.api.decorator.UserDecorator
|
---@class (exact) MyDecorator: nvim_tree.api.decorator.UserDecorator
|
||||||
---@field private my_icon nvim_tree.api.HighlightedString
|
---@field private my_icon1 nvim_tree.api.HighlightedString
|
||||||
|
---@field private my_icon2 nvim_tree.api.HighlightedString
|
||||||
|
---@field private my_icon_node nvim_tree.api.HighlightedString
|
||||||
|
---@field private my_highlight_group string
|
||||||
local MyDecorator = require("nvim-tree.api").decorator.UserDecorator:extend()
|
local MyDecorator = require("nvim-tree.api").decorator.UserDecorator:extend()
|
||||||
|
|
||||||
---Mandatory constructor :new() will be called once per tree render, with no arguments.
|
---Mandatory constructor :new() will be called once per tree render, with no arguments.
|
||||||
function MyDecorator:new()
|
function MyDecorator:new()
|
||||||
self.enabled = true
|
self.enabled = true
|
||||||
self.highlight_range = "all"
|
self.highlight_range = "name"
|
||||||
self.icon_placement = "signcolumn"
|
self.icon_placement = "after"
|
||||||
|
|
||||||
-- create your icon once, for convenience
|
-- create your icons and highlights once, applied to every node
|
||||||
self.my_icon = { str = "I", hl = { "MyIcon" } }
|
self.my_icon1 = { str = "1", hl = { "DiffAdd" } }
|
||||||
|
self.my_icon2 = { str = "2", hl = { "DiffText" } }
|
||||||
|
self.my_icon_node = { str = "N", hl = { "Error" } }
|
||||||
|
self.my_highlight_group = "IncSearch"
|
||||||
|
|
||||||
-- Define the icon sign only once
|
-- Define the icon signs only once
|
||||||
-- Only needed if you are using icon_placement = "signcolumn"
|
-- Only needed if you are using icon_placement = "signcolumn"
|
||||||
self:define_sign(self.my_icon)
|
-- self:define_sign(self.my_icon1)
|
||||||
|
-- self:define_sign(self.my_icon2)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Override node icon
|
---Override node icon
|
||||||
@@ -2973,33 +3001,35 @@ See `nvim-tree/_meta/api_decorator.lua` for full
|
|||||||
---@return nvim_tree.api.HighlightedString? icon_node
|
---@return nvim_tree.api.HighlightedString? icon_node
|
||||||
function MyDecorator:icon_node(node)
|
function MyDecorator:icon_node(node)
|
||||||
if node.name == "example" then
|
if node.name == "example" then
|
||||||
return self.my_icon
|
return self.my_icon_node
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Return one icon for DecoratorIconPlacement
|
---Return two icons for DecoratorIconPlacement "after"
|
||||||
---@param node nvim_tree.api.Node
|
---@param node nvim_tree.api.Node
|
||||||
---@return nvim_tree.api.HighlightedString[]? icons
|
---@return nvim_tree.api.HighlightedString[]? icons
|
||||||
function MyDecorator:icons(node)
|
function MyDecorator:icons(node)
|
||||||
if node.name == "example" then
|
if node.name == "example" then
|
||||||
return { self.my_icon }
|
return { self.my_icon1, self.my_icon2, }
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Exactly one highlight group for DecoratorHighlightRange
|
---Exactly one highlight group for DecoratorHighlightRange "name"
|
||||||
---@param node nvim_tree.api.Node
|
---@param node nvim_tree.api.Node
|
||||||
---@return string? highlight_group
|
---@return string? highlight_group
|
||||||
function MyDecorator:highlight_group(node)
|
function MyDecorator:highlight_group(node)
|
||||||
if node.name == "example" then
|
if node.name == "example" then
|
||||||
return "MyHighlight"
|
return self.my_highlight_group
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return MyDecorator
|
||||||
<
|
<
|
||||||
==============================================================================
|
==============================================================================
|
||||||
12. OS SPECIFIC RESTRICTIONS *nvim-tree-os-specific*
|
12. OS SPECIFIC RESTRICTIONS *nvim-tree-os-specific*
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local lib = require("nvim-tree.lib")
|
|||||||
local notify = require("nvim-tree.notify")
|
local notify = require("nvim-tree.notify")
|
||||||
local utils = require("nvim-tree.utils")
|
local utils = require("nvim-tree.utils")
|
||||||
local core = require("nvim-tree.core")
|
local core = require("nvim-tree.core")
|
||||||
|
local full_name = require("nvim-tree.renderer.components.full-name")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@@ -40,7 +41,12 @@ local function usable_win_ids()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local win_config = vim.api.nvim_win_get_config(id)
|
local win_config = vim.api.nvim_win_get_config(id)
|
||||||
return id ~= tree_winid and win_config.focusable and not win_config.hide and not win_config.external or false
|
return id ~= tree_winid
|
||||||
|
and id ~= full_name.popup_win
|
||||||
|
and win_config.focusable
|
||||||
|
and not win_config.hide
|
||||||
|
and not win_config.external
|
||||||
|
or false
|
||||||
end, win_ids)
|
end, win_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user