-
-
Notifications
You must be signed in to change notification settings - Fork 623
feat(#2948): add custom decorators, :help nvim-tree-decorators #2996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ff3dd12
feat(#2948): add UserDecorator, proof of concept
alex-courtis 4cada41
Merge branch 'master' into 2948-add-user-decorators
alex-courtis cbc34fb
Merge branch 'master' into 2948-add-user-decorators
alex-courtis 5c3bf8f
feat(#2948): add UserDecorator, proof of concept
alex-courtis 099de58
feat(#2948): add UserDecorator, proof of concept
alex-courtis 24eb27e
feat(#2948): add UserDecorator
alex-courtis f2a926d
feat(#2948): add UserDecorator
alex-courtis ad368d9
feat(#2948): add UserDecorator
alex-courtis dd6b015
feat(#2948): add Decorator node icon override
alex-courtis 1f1ad93
feat(#2948): add nvim_tree.api.* node classes
alex-courtis 45a14f6
feat(#2948): extract _meta following nvim pattern
alex-courtis 919a0a3
feat(#2948): extract _meta following nvim pattern
alex-courtis 129c349
feat(#2948): add decorator registry and order
alex-courtis 8e1e2aa
feat(#2948): add decorator registry and order
alex-courtis ff4ee07
Merge branch 'master' into 2948-add-user-decorators
alex-courtis 294a96e
feat(#2948): tidy
alex-courtis 93cf3f9
feat(#2948): document API
alex-courtis 8b5f342
feat(#2948): document API
alex-courtis 3ab3980
feat(#2948): document API
alex-courtis 6148f69
feat(#2948): pass api nodes to user decorators
alex-courtis ba296e6
feat(#2948): document API
alex-courtis cb351ae
feat(#2948): use renderer.decorators to define order and register
alex-courtis 4bf4a85
feat(#2948): tidy decorator args and complete documentation
alex-courtis 3b60fa7
feat(#2948): decorator classes specified by prefix rather than suffix
alex-courtis fd49b1f
feat(#2948): improve doc
alex-courtis dcfcecb
feat(#2948): improve doc
alex-courtis 9e30e9f
feat(#2948): improve doc
alex-courtis a063280
feat(#2948): additional user decorator safety
alex-courtis 47156b3
feat(#2948): create nvim_tree.api.decorator.UserDecorator class in AP…
alex-courtis 72ef08b
feat(#2948): improve doc
alex-courtis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
---@meta | ||
error("Cannot require a meta file") | ||
|
||
-- | ||
-- Nodes | ||
-- | ||
|
||
---Base Node, Abstract | ||
---@class (exact) nvim_tree.api.Node | ||
---@field type "file" | "directory" | "link" uv.fs_stat.result.type | ||
---@field absolute_path string | ||
---@field executable boolean | ||
---@field fs_stat uv.fs_stat.result? | ||
---@field git_status GitNodeStatus? | ||
---@field hidden boolean | ||
---@field name string | ||
---@field parent nvim_tree.api.DirectoryNode? | ||
---@field diag_severity lsp.DiagnosticSeverity? | ||
|
||
---File | ||
---@class (exact) nvim_tree.api.FileNode: nvim_tree.api.Node | ||
---@field extension string | ||
|
||
---Directory | ||
---@class (exact) nvim_tree.api.DirectoryNode: nvim_tree.api.Node | ||
---@field has_children boolean | ||
---@field nodes nvim_tree.api.Node[] | ||
---@field open boolean | ||
|
||
---Root Directory | ||
---@class (exact) nvim_tree.api.RootNode: nvim_tree.api.DirectoryNode | ||
|
||
---Link mixin | ||
---@class (exact) nvim_tree.api.LinkNode | ||
---@field link_to string | ||
---@field fs_stat_target uv.fs_stat.result | ||
|
||
---File Link | ||
---@class (exact) nvim_tree.api.FileLinkNode: nvim_tree.api.FileNode, nvim_tree.api.LinkNode | ||
|
||
---DirectoryLink | ||
---@class (exact) nvim_tree.api.DirectoryLinkNode: nvim_tree.api.DirectoryNode, nvim_tree.api.LinkNode | ||
|
||
-- | ||
-- Various Types | ||
-- | ||
|
||
---A string for rendering, with optional highlight groups to apply to it | ||
---@class (exact) nvim_tree.api.HighlightedString | ||
---@field str string | ||
---@field hl string[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
---@meta | ||
error("Cannot require a meta file") | ||
|
||
local nvim_tree = {} | ||
|
||
---Highlight group range as per nvim-tree.renderer.highlight_* | ||
---@alias nvim_tree.api.decorator.HighlightRange "none" | "icon" | "name" | "all" | ||
|
||
---Icon position as per renderer.icons.*_placement | ||
---@alias nvim_tree.api.decorator.IconPlacement "none" | "before" | "after" | "signcolumn" | "right_align" | ||
|
||
---Names of builtin decorators or your decorator classes. Builtins are ordered lowest to highest priority. | ||
---@alias nvim_tree.api.decorator.Name "Git" | "Opened" | "Hidden" | "Modified" | "Bookmarks" | "Diagnostics" | "Copied" | "Cut" | nvim_tree.api.decorator.UserDecorator | ||
|
||
---Custom decorator, see :help nvim-tree-decorators | ||
--- | ||
---@class (exact) nvim_tree.api.decorator.UserDecorator | ||
---@field protected enabled boolean | ||
---@field protected highlight_range nvim_tree.api.decorator.HighlightRange | ||
---@field protected icon_placement nvim_tree.api.decorator.IconPlacement | ||
|
||
---Abstract: no-args constructor must be implemented and will be called once per tree render. | ||
---Must set all fields. | ||
--- | ||
function nvim_tree.api.decorator.UserDecorator:new() end | ||
|
||
---Abstract: optionally implement to set the node's icon | ||
--- | ||
---@param node nvim_tree.api.Node | ||
---@return nvim_tree.api.HighlightedString? icon_node | ||
function nvim_tree.api.decorator.UserDecorator:icon_node(node) end | ||
|
||
---Abstract: optionally implement to provide icons and the highlight groups for your icon_placement. | ||
--- | ||
---@param node nvim_tree.api.Node | ||
---@return nvim_tree.api.HighlightedString[]? icons | ||
function nvim_tree.api.decorator.UserDecorator:icons(node) end | ||
|
||
---Abstract: optionally implement to provide one highlight group to apply to your highlight_range. | ||
--- | ||
---@param node nvim_tree.api.Node | ||
---@return string? highlight_group | ||
function nvim_tree.api.decorator.UserDecorator:highlight_group(node) end | ||
|
||
---Define a sign. This should be called in the constructor. | ||
--- | ||
---@protected | ||
---@param icon nvim_tree.api.HighlightedString? | ||
function nvim_tree.api.decorator.UserDecorator:define_sign(icon) end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.