feat(view): indicate modified buffers (#1835)
* Outlined new options * highlight_modified is highlight_opened_files * prototype with autocmd * moved modified into glyphs * show_on_dirs and show_on_open_dirs * icon placement before & after * _get_filename_offset * fixed :wq doesn't update modified indicator * highlight_modified, signcolumn modified_placement Refactored to make everything use HighlightedString to remove all the complex `insert_highlight` calculation. Not tested. * updated doc to match the reality of no multi char for glyphs.modified * fixed git signcolumn doesn't show * fixed highlight_modified gets replaced by highlight_opened_files * fixed renderer.icons.show.modified = false crash * updated doc to reflect empty icon not breaking rendering * removed debounce_delay to implement in a later PR * doc nit: order placement * change modified dirs default to be consistent with git * illegal git & modified placement changed to default * don't assume icon exist * nit remove comment * Noted in doc that glyphs can't have more than 2 characters if in signcolumn * Don't sign_define if placement isn't signcolumn Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
parent
9ad93b6ac0
commit
dcc344cc72
@ -224,6 +224,7 @@ Subsequent calls to setup will replace the previous configuration.
|
|||||||
highlight_git = false,
|
highlight_git = false,
|
||||||
full_name = false,
|
full_name = false,
|
||||||
highlight_opened_files = "none",
|
highlight_opened_files = "none",
|
||||||
|
highlight_modified = "none",
|
||||||
root_folder_label = ":~:s?$?/..?",
|
root_folder_label = ":~:s?$?/..?",
|
||||||
indent_width = 2,
|
indent_width = 2,
|
||||||
indent_markers = {
|
indent_markers = {
|
||||||
@ -240,6 +241,7 @@ Subsequent calls to setup will replace the previous configuration.
|
|||||||
icons = {
|
icons = {
|
||||||
webdev_colors = true,
|
webdev_colors = true,
|
||||||
git_placement = "before",
|
git_placement = "before",
|
||||||
|
modified_placement = "after",
|
||||||
padding = " ",
|
padding = " ",
|
||||||
symlink_arrow = " ➛ ",
|
symlink_arrow = " ➛ ",
|
||||||
show = {
|
show = {
|
||||||
@ -247,11 +249,13 @@ Subsequent calls to setup will replace the previous configuration.
|
|||||||
folder = true,
|
folder = true,
|
||||||
folder_arrow = true,
|
folder_arrow = true,
|
||||||
git = true,
|
git = true,
|
||||||
|
modified = true,
|
||||||
},
|
},
|
||||||
glyphs = {
|
glyphs = {
|
||||||
default = "",
|
default = "",
|
||||||
symlink = "",
|
symlink = "",
|
||||||
bookmark = "",
|
bookmark = "",
|
||||||
|
modified = "●",
|
||||||
folder = {
|
folder = {
|
||||||
arrow_closed = "",
|
arrow_closed = "",
|
||||||
arrow_open = "",
|
arrow_open = "",
|
||||||
@ -326,6 +330,11 @@ Subsequent calls to setup will replace the previous configuration.
|
|||||||
show_on_open_dirs = true,
|
show_on_open_dirs = true,
|
||||||
timeout = 400,
|
timeout = 400,
|
||||||
},
|
},
|
||||||
|
modified = {
|
||||||
|
enable = false,
|
||||||
|
show_on_dirs = true,
|
||||||
|
show_on_open_dirs = true,
|
||||||
|
},
|
||||||
actions = {
|
actions = {
|
||||||
use_system_clipboard = true,
|
use_system_clipboard = true,
|
||||||
change_dir = {
|
change_dir = {
|
||||||
@ -544,6 +553,7 @@ Configuration options for the system open command.
|
|||||||
|
|
||||||
*nvim-tree.diagnostics*
|
*nvim-tree.diagnostics*
|
||||||
Show LSP and COC diagnostics in the signcolumn
|
Show LSP and COC diagnostics in the signcolumn
|
||||||
|
Note that the modified sign will take precedence over the diagnostics signs.
|
||||||
|
|
||||||
`NOTE`: it will use the default diagnostic color groups to highlight the signs.
|
`NOTE`: it will use the default diagnostic color groups to highlight the signs.
|
||||||
If you wish to customize, you can override these groups:
|
If you wish to customize, you can override these groups:
|
||||||
@ -619,6 +629,26 @@ Git integration with icons and colors.
|
|||||||
milliseconds but a few seconds), it will not render anything until the git
|
milliseconds but a few seconds), it will not render anything until the git
|
||||||
process returned the data.
|
process returned the data.
|
||||||
|
|
||||||
|
*nvim-tree.modified*
|
||||||
|
Indicate which file have unsaved modification.
|
||||||
|
|
||||||
|
*nvim-tree.modified.enable*
|
||||||
|
Enable / disable the feature.
|
||||||
|
Type: `boolean`, Default: `false`
|
||||||
|
|
||||||
|
*nvim-tree.modified.show_on_dirs*
|
||||||
|
Show modified indication on directory whose children are modified.
|
||||||
|
Type: `boolean`, Default: `true`
|
||||||
|
|
||||||
|
*nvim-tree.modified.show_on_open_dirs*
|
||||||
|
Show modified indication on open directories.
|
||||||
|
Only relevant when |modified.show_on_dirs| is `true`.
|
||||||
|
Type: `boolean`, Default: `true`
|
||||||
|
|
||||||
|
You will still need to set |renderer.icons.show.modified| `= true` or
|
||||||
|
|renderer.highlight_modified| `= true` to be able to see things in the
|
||||||
|
tree.
|
||||||
|
|
||||||
*nvim-tree.filesystem_watchers*
|
*nvim-tree.filesystem_watchers*
|
||||||
Will use file system watcher (libuv fs_event) to watch the filesystem for
|
Will use file system watcher (libuv fs_event) to watch the filesystem for
|
||||||
changes.
|
changes.
|
||||||
@ -779,6 +809,13 @@ UI rendering setup
|
|||||||
Value can be `"none"`, `"icon"`, `"name"` or `"all"`.
|
Value can be `"none"`, `"icon"`, `"name"` or `"all"`.
|
||||||
Type: `string`, Default: `"none"`
|
Type: `string`, Default: `"none"`
|
||||||
|
|
||||||
|
*nvim-tree.renderer.highlight_modified*
|
||||||
|
Highlight icons and/or names for modified files using `NvimTreeModified`
|
||||||
|
highlight groups.
|
||||||
|
Value can be `"none"`, `"icon"`, `"name"` or `"all"`
|
||||||
|
This can be used with or without the icons.
|
||||||
|
Type: `string`, Default `"none"`
|
||||||
|
|
||||||
*nvim-tree.renderer.root_folder_label* (previously `renderer.root_folder_modifier`)
|
*nvim-tree.renderer.root_folder_label* (previously `renderer.root_folder_modifier`)
|
||||||
In what format to show root folder. See `:help filename-modifiers` for
|
In what format to show root folder. See `:help filename-modifiers` for
|
||||||
available `string` options.
|
available `string` options.
|
||||||
@ -821,12 +858,17 @@ UI rendering setup
|
|||||||
Place where the git icons will be rendered.
|
Place where the git icons will be rendered.
|
||||||
Can be `"after"` or `"before"` filename (after the file/folders icons)
|
Can be `"after"` or `"before"` filename (after the file/folders icons)
|
||||||
or `"signcolumn"` (requires |nvim-tree.view.signcolumn| enabled).
|
or `"signcolumn"` (requires |nvim-tree.view.signcolumn| enabled).
|
||||||
Note that the diagnostic signs will take precedence over the git signs.
|
Note that the diagnostic signs and the modified sign will take precedence over the git signs.
|
||||||
Type: `string`, Default: `before`
|
Type: `string`, Default: `before`
|
||||||
|
|
||||||
|
*nvim-tree.renderer.icons.modified_placement*
|
||||||
|
Place where the modified icon will be rendered.
|
||||||
|
Can be `"after"` or `"before"` filename (after the file/folders icons)
|
||||||
|
or `"signcolumn"` (requires |nvim-tree.view.signcolumn| enabled).
|
||||||
|
Type: `string`, Default: `after`
|
||||||
|
|
||||||
*nvim-tree.renderer.icons.padding*
|
*nvim-tree.renderer.icons.padding*
|
||||||
Inserted between icon and filename.
|
Inserted between icon and filename.
|
||||||
Use with caution, it could break rendering if you set an empty string depending on your font.
|
|
||||||
Type: `string`, Default: `" "`
|
Type: `string`, Default: `" "`
|
||||||
|
|
||||||
*nvim-tree.renderer.icons.symlink_arrow*
|
*nvim-tree.renderer.icons.symlink_arrow*
|
||||||
@ -854,8 +896,15 @@ UI rendering setup
|
|||||||
Requires |git.enable| `= true`
|
Requires |git.enable| `= true`
|
||||||
Type: `boolean`, Default: `true`
|
Type: `boolean`, Default: `true`
|
||||||
|
|
||||||
|
*nvim-tree.renderer.icons.show.modified*
|
||||||
|
Show a modified icon, see |renderer.icons.modified_placement|
|
||||||
|
Requires |modified.enable| `= true`
|
||||||
|
Type: `boolean`, Default: `true`
|
||||||
|
|
||||||
*nvim-tree.renderer.icons.glyphs*
|
*nvim-tree.renderer.icons.glyphs*
|
||||||
Configuration options for icon glyphs.
|
Configuration options for icon glyphs.
|
||||||
|
NOTE: Do not set any glyphs to more than two characters if it's going
|
||||||
|
to appear in the signcolumn.
|
||||||
|
|
||||||
*nvim-tree.renderer.icons.glyphs.default*
|
*nvim-tree.renderer.icons.glyphs.default*
|
||||||
Glyph for files. Will be overridden by `nvim-web-devicons` if available.
|
Glyph for files. Will be overridden by `nvim-web-devicons` if available.
|
||||||
@ -865,6 +914,10 @@ UI rendering setup
|
|||||||
Glyph for symlinks to files.
|
Glyph for symlinks to files.
|
||||||
Type: `string`, Default: `""`
|
Type: `string`, Default: `""`
|
||||||
|
|
||||||
|
*nvim-tree.renderer.icons.glyphs.modified*
|
||||||
|
Icon to display for modified files.
|
||||||
|
Type: `string`, Default: `"●"`
|
||||||
|
|
||||||
*nvim-tree.renderer.icons.glyphs.folder*
|
*nvim-tree.renderer.icons.glyphs.folder*
|
||||||
Glyphs for directories.
|
Glyphs for directories.
|
||||||
Type: `table`, Default:
|
Type: `table`, Default:
|
||||||
@ -1471,6 +1524,7 @@ NvimTreeEmptyFolderName (Directory)
|
|||||||
NvimTreeOpenedFolderName (Directory)
|
NvimTreeOpenedFolderName (Directory)
|
||||||
NvimTreeExecFile
|
NvimTreeExecFile
|
||||||
NvimTreeOpenedFile
|
NvimTreeOpenedFile
|
||||||
|
NvimTreeModifiedFile
|
||||||
NvimTreeSpecialFile
|
NvimTreeSpecialFile
|
||||||
NvimTreeImageFile
|
NvimTreeImageFile
|
||||||
NvimTreeIndentMarker
|
NvimTreeIndentMarker
|
||||||
|
|||||||
@ -12,6 +12,7 @@ local copy_paste = require "nvim-tree.actions.fs.copy-paste"
|
|||||||
local collapse_all = require "nvim-tree.actions.tree-modifiers.collapse-all"
|
local collapse_all = require "nvim-tree.actions.tree-modifiers.collapse-all"
|
||||||
local git = require "nvim-tree.git"
|
local git = require "nvim-tree.git"
|
||||||
local filters = require "nvim-tree.explorer.filters"
|
local filters = require "nvim-tree.explorer.filters"
|
||||||
|
local modified = require "nvim-tree.modified"
|
||||||
|
|
||||||
local _config = {}
|
local _config = {}
|
||||||
|
|
||||||
@ -476,6 +477,15 @@ local function setup_autocommands(opts)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if opts.modified.enable then
|
||||||
|
create_nvim_tree_autocmd({ "BufModifiedSet", "BufWritePost" }, {
|
||||||
|
callback = function()
|
||||||
|
modified.reload()
|
||||||
|
reloaders.reload_explorer()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
||||||
@ -532,6 +542,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
highlight_git = false,
|
highlight_git = false,
|
||||||
full_name = false,
|
full_name = false,
|
||||||
highlight_opened_files = "none",
|
highlight_opened_files = "none",
|
||||||
|
highlight_modified = "none",
|
||||||
root_folder_label = ":~:s?$?/..?",
|
root_folder_label = ":~:s?$?/..?",
|
||||||
indent_width = 2,
|
indent_width = 2,
|
||||||
indent_markers = {
|
indent_markers = {
|
||||||
@ -548,6 +559,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
icons = {
|
icons = {
|
||||||
webdev_colors = true,
|
webdev_colors = true,
|
||||||
git_placement = "before",
|
git_placement = "before",
|
||||||
|
modified_placement = "after",
|
||||||
padding = " ",
|
padding = " ",
|
||||||
symlink_arrow = " ➛ ",
|
symlink_arrow = " ➛ ",
|
||||||
show = {
|
show = {
|
||||||
@ -555,11 +567,13 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
folder = true,
|
folder = true,
|
||||||
folder_arrow = true,
|
folder_arrow = true,
|
||||||
git = true,
|
git = true,
|
||||||
|
modified = true,
|
||||||
},
|
},
|
||||||
glyphs = {
|
glyphs = {
|
||||||
default = "",
|
default = "",
|
||||||
symlink = "",
|
symlink = "",
|
||||||
bookmark = "",
|
bookmark = "",
|
||||||
|
modified = "●",
|
||||||
folder = {
|
folder = {
|
||||||
arrow_closed = "",
|
arrow_closed = "",
|
||||||
arrow_open = "",
|
arrow_open = "",
|
||||||
@ -634,6 +648,11 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
|||||||
show_on_open_dirs = true,
|
show_on_open_dirs = true,
|
||||||
timeout = 400,
|
timeout = 400,
|
||||||
},
|
},
|
||||||
|
modified = {
|
||||||
|
enable = false,
|
||||||
|
show_on_dirs = true,
|
||||||
|
show_on_open_dirs = true,
|
||||||
|
},
|
||||||
actions = {
|
actions = {
|
||||||
use_system_clipboard = true,
|
use_system_clipboard = true,
|
||||||
change_dir = {
|
change_dir = {
|
||||||
@ -810,6 +829,7 @@ function M.setup(conf)
|
|||||||
require("nvim-tree.renderer").setup(opts)
|
require("nvim-tree.renderer").setup(opts)
|
||||||
require("nvim-tree.live-filter").setup(opts)
|
require("nvim-tree.live-filter").setup(opts)
|
||||||
require("nvim-tree.marks").setup(opts)
|
require("nvim-tree.marks").setup(opts)
|
||||||
|
require("nvim-tree.modified").setup(opts)
|
||||||
if M.config.renderer.icons.show.file and pcall(require, "nvim-web-devicons") then
|
if M.config.renderer.icons.show.file and pcall(require, "nvim-web-devicons") then
|
||||||
require("nvim-web-devicons").setup()
|
require("nvim-web-devicons").setup()
|
||||||
end
|
end
|
||||||
|
|||||||
@ -40,6 +40,7 @@ local function get_hl_groups()
|
|||||||
SpecialFile = { gui = "bold,underline", fg = colors.yellow },
|
SpecialFile = { gui = "bold,underline", fg = colors.yellow },
|
||||||
ImageFile = { gui = "bold", fg = colors.purple },
|
ImageFile = { gui = "bold", fg = colors.purple },
|
||||||
OpenedFile = { gui = "bold", fg = colors.green },
|
OpenedFile = { gui = "bold", fg = colors.green },
|
||||||
|
ModifiedFile = { fg = colors.green },
|
||||||
|
|
||||||
GitDirty = { fg = colors.dark_red },
|
GitDirty = { fg = colors.dark_red },
|
||||||
GitDeleted = { fg = colors.dark_red },
|
GitDeleted = { fg = colors.dark_red },
|
||||||
|
|||||||
34
lua/nvim-tree/modified.lua
Normal file
34
lua/nvim-tree/modified.lua
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
---@type table<string, boolean> record of which file is modified
|
||||||
|
M._record = {}
|
||||||
|
|
||||||
|
---refresh M.record
|
||||||
|
function M.reload()
|
||||||
|
M._record = {}
|
||||||
|
local bufs = vim.fn.getbufinfo { bufmodified = true, buflisted = true }
|
||||||
|
for _, buf in pairs(bufs) do
|
||||||
|
local path = buf.name
|
||||||
|
M._record[path] = true
|
||||||
|
while path ~= vim.fn.getcwd() and path ~= "/" do
|
||||||
|
path = vim.fn.fnamemodify(path, ":h")
|
||||||
|
M._record[path] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param node table
|
||||||
|
---@return boolean
|
||||||
|
function M.is_modified(node)
|
||||||
|
return M.config.enable
|
||||||
|
and M._record[node.absolute_path]
|
||||||
|
and (not node.nodes or M.config.show_on_dirs)
|
||||||
|
and (not node.open or M.config.show_on_open_dirs)
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param opts table
|
||||||
|
function M.setup(opts)
|
||||||
|
M.config = opts.modified
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@ -4,6 +4,7 @@ local core = require "nvim-tree.core"
|
|||||||
local git = require "nvim-tree.renderer.components.git"
|
local git = require "nvim-tree.renderer.components.git"
|
||||||
local pad = require "nvim-tree.renderer.components.padding"
|
local pad = require "nvim-tree.renderer.components.padding"
|
||||||
local icons = require "nvim-tree.renderer.components.icons"
|
local icons = require "nvim-tree.renderer.components.icons"
|
||||||
|
local modified = require "nvim-tree.renderer.components.modified"
|
||||||
|
|
||||||
local Builder = {}
|
local Builder = {}
|
||||||
Builder.__index = Builder
|
Builder.__index = Builder
|
||||||
@ -50,21 +51,32 @@ end
|
|||||||
|
|
||||||
function Builder:configure_opened_file_highlighting(highlight_opened_files)
|
function Builder:configure_opened_file_highlighting(highlight_opened_files)
|
||||||
self.highlight_opened_files = highlight_opened_files
|
self.highlight_opened_files = highlight_opened_files
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function Builder:configure_git_icons_padding(padding)
|
function Builder:configure_modified_highlighting(highlight_modified)
|
||||||
self.git_icon_padding = padding or " "
|
self.highlight_modified = highlight_modified
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function Builder:configure_icon_padding(padding)
|
||||||
|
self.icon_padding = padding or " "
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
function Builder:configure_git_icons_placement(where)
|
function Builder:configure_git_icons_placement(where)
|
||||||
if where == "signcolumn" then
|
if where ~= "after" and where ~= "before" and where ~= "signcolumn" then
|
||||||
vim.fn.sign_unplace(git.SIGN_GROUP)
|
where = "before" -- default before
|
||||||
self.is_git_sign = true
|
|
||||||
end
|
end
|
||||||
self.is_git_after = where == "after" and not self.is_git_sign
|
self.git_placement = where
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function Builder:configure_modified_placement(where)
|
||||||
|
if where ~= "after" and where ~= "before" and where ~= "signcolumn" then
|
||||||
|
where = "after" -- default after
|
||||||
|
end
|
||||||
|
self.modified_placement = where
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -91,46 +103,48 @@ local function get_folder_name(node)
|
|||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
|
|
||||||
function Builder:_unwrap_git_data(git_icons_and_hl_groups, offset)
|
---@class HighlightedString
|
||||||
if not git_icons_and_hl_groups then
|
---@field str string
|
||||||
|
---@field hl string|nil
|
||||||
|
|
||||||
|
---@param highlighted_strings HighlightedString[]
|
||||||
|
---@return string
|
||||||
|
function Builder:_unwrap_highlighted_strings(highlighted_strings)
|
||||||
|
if not highlighted_strings then
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
local icon = ""
|
local string = ""
|
||||||
for i, v in ipairs(git_icons_and_hl_groups) do
|
for _, v in ipairs(highlighted_strings) do
|
||||||
if #v.icon > 0 then
|
if #v.str > 0 then
|
||||||
self:_insert_highlight(v.hl, offset + #icon, offset + #icon + #v.icon)
|
if v.hl then
|
||||||
local remove_padding = self.is_git_after and i == #git_icons_and_hl_groups
|
self:_insert_highlight(v.hl, #string, #string + #v.str)
|
||||||
icon = icon .. v.icon .. (remove_padding and "" or self.git_icon_padding)
|
end
|
||||||
|
string = string .. v.str
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return icon
|
return string
|
||||||
end
|
end
|
||||||
|
|
||||||
function Builder:_build_folder(node, padding, git_hl, git_icons_tbl)
|
---@param node table
|
||||||
local offset = string.len(padding)
|
---@return HighlightedString icon, HighlightedString name
|
||||||
|
function Builder:_build_folder(node)
|
||||||
local name = get_folder_name(node)
|
|
||||||
local has_children = #node.nodes ~= 0 or node.has_children
|
local has_children = #node.nodes ~= 0 or node.has_children
|
||||||
local icon = icons.get_folder_icon(node.open, node.link_to ~= nil, has_children)
|
local icon = icons.get_folder_icon(node.open, node.link_to ~= nil, has_children)
|
||||||
|
|
||||||
local foldername = name .. self.trailing_slash
|
local foldername = get_folder_name(node) .. self.trailing_slash
|
||||||
if node.link_to and self.symlink_destination then
|
if node.link_to and self.symlink_destination then
|
||||||
local arrow = icons.i.symlink_arrow
|
local arrow = icons.i.symlink_arrow
|
||||||
local link_to = utils.path_relative(node.link_to, core.get_cwd())
|
local link_to = utils.path_relative(node.link_to, core.get_cwd())
|
||||||
foldername = foldername .. arrow .. link_to
|
foldername = foldername .. arrow .. link_to
|
||||||
end
|
end
|
||||||
|
|
||||||
local git_icons = self:_unwrap_git_data(git_icons_tbl, offset + #icon + (self.is_git_after and #foldername + 1 or 0))
|
local icon_hl
|
||||||
local fname_starts_at = offset + #icon + (self.is_git_after and 0 or #git_icons)
|
|
||||||
local line = self:_format_line(padding .. icon, foldername, git_icons)
|
|
||||||
self:_insert_line(line)
|
|
||||||
|
|
||||||
if #icon > 0 then
|
if #icon > 0 then
|
||||||
if node.open then
|
if node.open then
|
||||||
self:_insert_highlight("NvimTreeOpenedFolderIcon", offset, offset + #icon)
|
icon_hl = "NvimTreeOpenedFolderIcon"
|
||||||
else
|
else
|
||||||
self:_insert_highlight("NvimTreeClosedFolderIcon", offset, offset + #icon)
|
icon_hl = "NvimTreeClosedFolderIcon"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -143,27 +157,12 @@ function Builder:_build_folder(node, padding, git_hl, git_icons_tbl)
|
|||||||
foldername_hl = "NvimTreeEmptyFolderName"
|
foldername_hl = "NvimTreeEmptyFolderName"
|
||||||
end
|
end
|
||||||
|
|
||||||
self:_insert_highlight(foldername_hl, fname_starts_at, fname_starts_at + #foldername)
|
return { str = icon, hl = icon_hl }, { str = foldername, hl = foldername_hl }
|
||||||
|
|
||||||
if git_hl then
|
|
||||||
self:_insert_highlight(git_hl, fname_starts_at, fname_starts_at + #foldername)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Builder:_format_line(before, after, git_icons)
|
---@param node table
|
||||||
git_icons = self.is_git_after and git_icons and " " .. git_icons or git_icons
|
---@return HighlightedString icon, HighlightedString name
|
||||||
return string.format(
|
function Builder:_build_symlink(node)
|
||||||
"%s%s%s%s",
|
|
||||||
before,
|
|
||||||
self.is_git_after and "" or git_icons,
|
|
||||||
after,
|
|
||||||
self.is_git_after and git_icons or ""
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Builder:_build_symlink(node, padding, git_highlight, git_icons_tbl)
|
|
||||||
local offset = string.len(padding)
|
|
||||||
|
|
||||||
local icon = icons.i.symlink
|
local icon = icons.i.symlink
|
||||||
local arrow = icons.i.symlink_arrow
|
local arrow = icons.i.symlink_arrow
|
||||||
local symlink_formatted = node.name
|
local symlink_formatted = node.name
|
||||||
@ -172,107 +171,173 @@ function Builder:_build_symlink(node, padding, git_highlight, git_icons_tbl)
|
|||||||
symlink_formatted = symlink_formatted .. arrow .. link_to
|
symlink_formatted = symlink_formatted .. arrow .. link_to
|
||||||
end
|
end
|
||||||
|
|
||||||
local link_highlight = git_highlight or "NvimTreeSymlink"
|
local link_highlight = "NvimTreeSymlink"
|
||||||
|
|
||||||
local git_icons_starts_at = offset + #icon + (self.is_git_after and #symlink_formatted + 1 or 0)
|
return { str = icon }, { str = symlink_formatted, hl = link_highlight }
|
||||||
local git_icons = self:_unwrap_git_data(git_icons_tbl, git_icons_starts_at)
|
|
||||||
local line = self:_format_line(padding .. icon, symlink_formatted, git_icons)
|
|
||||||
|
|
||||||
self:_insert_highlight(link_highlight, offset + (self.is_git_after and 0 or #git_icons), string.len(line))
|
|
||||||
self:_insert_line(line)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Builder:_build_file_icon(node, offset)
|
---@param node table
|
||||||
|
---@return HighlightedString icon
|
||||||
|
function Builder:_build_file_icon(node)
|
||||||
local icon, hl_group = icons.get_file_icon(node.name, node.extension)
|
local icon, hl_group = icons.get_file_icon(node.name, node.extension)
|
||||||
if hl_group then
|
return { str = icon, hl = hl_group }
|
||||||
self:_insert_highlight(hl_group, offset, offset + #icon)
|
|
||||||
end
|
|
||||||
return icon, false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Builder:_highlight_opened_files(node, offset, icon_length, git_icons_length)
|
---@param node table
|
||||||
local from = offset
|
---@return HighlightedString icon, HighlightedString name
|
||||||
local to = offset
|
function Builder:_build_file(node)
|
||||||
|
local icon = self:_build_file_icon(node)
|
||||||
if self.highlight_opened_files == "icon" then
|
|
||||||
to = from + icon_length
|
|
||||||
elseif self.highlight_opened_files == "name" then
|
|
||||||
from = offset + icon_length + git_icons_length
|
|
||||||
to = from + #node.name
|
|
||||||
elseif self.highlight_opened_files == "all" then
|
|
||||||
to = from + icon_length + git_icons_length + #node.name
|
|
||||||
end
|
|
||||||
|
|
||||||
self:_insert_highlight("NvimTreeOpenedFile", from, to)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Builder:_build_file(node, padding, git_highlight, git_icons_tbl, unloaded_bufnr)
|
|
||||||
local offset = string.len(padding)
|
|
||||||
|
|
||||||
local icon = self:_build_file_icon(node, offset)
|
|
||||||
|
|
||||||
local git_icons_starts_at = offset + #icon + (self.is_git_after and #node.name + 1 or 0)
|
|
||||||
local git_icons = self:_unwrap_git_data(git_icons_tbl, git_icons_starts_at)
|
|
||||||
|
|
||||||
self:_insert_line(self:_format_line(padding .. icon, node.name, git_icons))
|
|
||||||
|
|
||||||
local git_icons_length = self.is_git_after and 0 or #git_icons
|
|
||||||
local col_start = offset + #icon + git_icons_length
|
|
||||||
local col_end = col_start + #node.name
|
|
||||||
|
|
||||||
|
local hl
|
||||||
if vim.tbl_contains(self.special_files, node.absolute_path) or vim.tbl_contains(self.special_files, node.name) then
|
if vim.tbl_contains(self.special_files, node.absolute_path) or vim.tbl_contains(self.special_files, node.name) then
|
||||||
self:_insert_highlight("NvimTreeSpecialFile", col_start, col_end)
|
hl = "NvimTreeSpecialFile"
|
||||||
elseif node.executable then
|
elseif node.executable then
|
||||||
self:_insert_highlight("NvimTreeExecFile", col_start, col_end)
|
hl = "NvimTreeExecFile"
|
||||||
elseif self.picture_map[node.extension] then
|
elseif self.picture_map[node.extension] then
|
||||||
self:_insert_highlight("NvimTreeImageFile", col_start, col_end)
|
hl = "NvimTreeImageFile"
|
||||||
end
|
end
|
||||||
|
|
||||||
local should_highlight_opened_files = self.highlight_opened_files
|
return icon, { str = node.name, hl = hl }
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param node table
|
||||||
|
---@return HighlightedString[]|nil icon
|
||||||
|
function Builder:_get_git_icons(node)
|
||||||
|
local git_icons = git.get_icons(node)
|
||||||
|
if git_icons and #git_icons > 0 and self.git_placement == "signcolumn" then
|
||||||
|
local sign = git_icons[1]
|
||||||
|
table.insert(self.signs, { sign = sign.hl, lnum = self.index + 1, priority = 1 })
|
||||||
|
git_icons = nil
|
||||||
|
end
|
||||||
|
return git_icons
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param node table
|
||||||
|
---@return HighlightedString|nil icon
|
||||||
|
function Builder:_get_modified_icon(node)
|
||||||
|
local modified_icon = modified.get_icon(node)
|
||||||
|
if modified_icon and self.modified_placement == "signcolumn" then
|
||||||
|
local sign = modified_icon
|
||||||
|
table.insert(self.signs, { sign = sign.hl, lnum = self.index + 1, priority = 3 })
|
||||||
|
modified_icon = nil
|
||||||
|
end
|
||||||
|
return modified_icon
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param node table
|
||||||
|
---@return string icon_highlight, string name_highlight
|
||||||
|
function Builder:_get_highlight_override(node, unloaded_bufnr)
|
||||||
|
-- highlights precedence:
|
||||||
|
-- original < git < opened_file < modified
|
||||||
|
local name_hl, icon_hl
|
||||||
|
|
||||||
|
-- git
|
||||||
|
local git_highlight = git.get_highlight(node)
|
||||||
|
if git_highlight then
|
||||||
|
name_hl = git_highlight
|
||||||
|
end
|
||||||
|
|
||||||
|
-- opened file
|
||||||
|
if
|
||||||
|
self.highlight_opened_files
|
||||||
and vim.fn.bufloaded(node.absolute_path) > 0
|
and vim.fn.bufloaded(node.absolute_path) > 0
|
||||||
and vim.fn.bufnr(node.absolute_path) ~= unloaded_bufnr
|
and vim.fn.bufnr(node.absolute_path) ~= unloaded_bufnr
|
||||||
if should_highlight_opened_files then
|
then
|
||||||
self:_highlight_opened_files(node, offset, #icon, git_icons_length)
|
if self.highlight_opened_files == "all" or self.highlight_opened_files == "name" then
|
||||||
end
|
name_hl = "NvimTreeOpenedFile"
|
||||||
|
end
|
||||||
if git_highlight then
|
if self.highlight_opened_files == "all" or self.highlight_opened_files == "icon" then
|
||||||
self:_insert_highlight(git_highlight, col_start, col_end)
|
icon_hl = "NvimTreeOpenedFile"
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Builder:_build_line(node, idx, num_children, unloaded_bufnr)
|
|
||||||
local padding = pad.get_padding(self.depth, idx, num_children, node, self.markers)
|
|
||||||
|
|
||||||
if string.len(padding) > 0 then
|
|
||||||
self:_insert_highlight("NvimTreeIndentMarker", 0, string.len(padding))
|
|
||||||
end
|
|
||||||
|
|
||||||
local git_highlight = git.get_highlight(node)
|
|
||||||
local git_icons_tbl = git.get_icons(node)
|
|
||||||
|
|
||||||
if git_icons_tbl and #git_icons_tbl > 0 then
|
|
||||||
if self.is_git_sign then
|
|
||||||
local git_info = git_icons_tbl[1]
|
|
||||||
table.insert(self.signs, { sign = git_info.hl, lnum = self.index + 1 })
|
|
||||||
git_icons_tbl = {}
|
|
||||||
else
|
|
||||||
-- sort icons so it looks slightly better
|
|
||||||
table.sort(git_icons_tbl, function(a, b)
|
|
||||||
return a.ord < b.ord
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- modified file
|
||||||
|
local modified_highlight = modified.get_highlight(node)
|
||||||
|
if modified_highlight then
|
||||||
|
if self.highlight_modified == "all" or self.highlight_modified == "name" then
|
||||||
|
name_hl = modified_highlight
|
||||||
|
end
|
||||||
|
if self.highlight_modified == "all" or self.highlight_modified == "icon" then
|
||||||
|
icon_hl = modified_highlight
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return icon_hl, name_hl
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param padding HighlightedString
|
||||||
|
---@param icon HighlightedString
|
||||||
|
---@param name HighlightedString
|
||||||
|
---@param git_icons HighlightedString[]|nil
|
||||||
|
---@param modified_icon HighlightedString|nil
|
||||||
|
---@return HighlightedString[]
|
||||||
|
function Builder:_format_line(padding, icon, name, git_icons, modified_icon)
|
||||||
|
local added_len = 0
|
||||||
|
local function add_to_end(t1, t2)
|
||||||
|
for _, v in ipairs(t2) do
|
||||||
|
if added_len > 0 then
|
||||||
|
table.insert(t1, { str = self.icon_padding })
|
||||||
|
end
|
||||||
|
table.insert(t1, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- first add_to_end don't need padding
|
||||||
|
-- hence added_len is calculated at the end to be used next time
|
||||||
|
added_len = 0
|
||||||
|
for _, v in ipairs(t2) do
|
||||||
|
added_len = added_len + #v.str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local line = { padding }
|
||||||
|
add_to_end(line, { icon })
|
||||||
|
if git_icons and self.git_placement == "before" then
|
||||||
|
add_to_end(line, git_icons)
|
||||||
|
end
|
||||||
|
if modified_icon and self.modified_placement == "before" then
|
||||||
|
add_to_end(line, { modified_icon })
|
||||||
|
end
|
||||||
|
add_to_end(line, { name })
|
||||||
|
if git_icons and self.git_placement == "after" then
|
||||||
|
add_to_end(line, git_icons)
|
||||||
|
end
|
||||||
|
if modified_icon and self.modified_placement == "after" then
|
||||||
|
add_to_end(line, { modified_icon })
|
||||||
|
end
|
||||||
|
|
||||||
|
return line
|
||||||
|
end
|
||||||
|
|
||||||
|
function Builder:_build_line(node, idx, num_children, unloaded_bufnr)
|
||||||
|
-- various components
|
||||||
|
local padding = pad.get_padding(self.depth, idx, num_children, node, self.markers)
|
||||||
|
local git_icons = self:_get_git_icons(node)
|
||||||
|
local modified_icon = self:_get_modified_icon(node)
|
||||||
|
|
||||||
|
-- main components
|
||||||
local is_folder = node.nodes ~= nil
|
local is_folder = node.nodes ~= nil
|
||||||
local is_symlink = node.link_to ~= nil
|
local is_symlink = node.link_to ~= nil
|
||||||
|
local icon, name
|
||||||
if is_folder then
|
if is_folder then
|
||||||
self:_build_folder(node, padding, git_highlight, git_icons_tbl)
|
icon, name = self:_build_folder(node)
|
||||||
elseif is_symlink then
|
elseif is_symlink then
|
||||||
self:_build_symlink(node, padding, git_highlight, git_icons_tbl)
|
icon, name = self:_build_symlink(node)
|
||||||
else
|
else
|
||||||
self:_build_file(node, padding, git_highlight, git_icons_tbl, unloaded_bufnr)
|
icon, name = self:_build_file(node)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- highlight override
|
||||||
|
local icon_hl, name_hl = self:_get_highlight_override(node, unloaded_bufnr)
|
||||||
|
if icon_hl then
|
||||||
|
icon.hl = icon_hl
|
||||||
|
end
|
||||||
|
if name_hl then
|
||||||
|
name.hl = name_hl
|
||||||
|
end
|
||||||
|
|
||||||
|
local line = self:_format_line(padding, icon, name, git_icons, modified_icon)
|
||||||
|
self:_insert_line(self:_unwrap_highlighted_strings(line))
|
||||||
|
|
||||||
self.index = self.index + 1
|
self.index = self.index + 1
|
||||||
|
|
||||||
if node.open then
|
if node.open then
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
local notify = require "nvim-tree.notify"
|
local notify = require "nvim-tree.notify"
|
||||||
local explorer_node = require "nvim-tree.explorer.node"
|
local explorer_node = require "nvim-tree.explorer.node"
|
||||||
|
|
||||||
local M = {
|
local M = {}
|
||||||
SIGN_GROUP = "NvimTreeGitSigns",
|
|
||||||
}
|
|
||||||
|
|
||||||
local function build_icons_table(i)
|
local function build_icons_table(i)
|
||||||
local icons = {
|
local icons = {
|
||||||
staged = { icon = i.staged, hl = "NvimTreeGitStaged", ord = 1 },
|
staged = { str = i.staged, hl = "NvimTreeGitStaged", ord = 1 },
|
||||||
unstaged = { icon = i.unstaged, hl = "NvimTreeGitDirty", ord = 2 },
|
unstaged = { str = i.unstaged, hl = "NvimTreeGitDirty", ord = 2 },
|
||||||
renamed = { icon = i.renamed, hl = "NvimTreeGitRenamed", ord = 3 },
|
renamed = { str = i.renamed, hl = "NvimTreeGitRenamed", ord = 3 },
|
||||||
deleted = { icon = i.deleted, hl = "NvimTreeGitDeleted", ord = 4 },
|
deleted = { str = i.deleted, hl = "NvimTreeGitDeleted", ord = 4 },
|
||||||
unmerged = { icon = i.unmerged, hl = "NvimTreeGitMerge", ord = 5 },
|
unmerged = { str = i.unmerged, hl = "NvimTreeGitMerge", ord = 5 },
|
||||||
untracked = { icon = i.untracked, hl = "NvimTreeGitNew", ord = 6 },
|
untracked = { str = i.untracked, hl = "NvimTreeGitNew", ord = 6 },
|
||||||
ignored = { icon = i.ignored, hl = "NvimTreeGitIgnored", ord = 7 },
|
ignored = { str = i.ignored, hl = "NvimTreeGitIgnored", ord = 7 },
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
["M "] = { icons.staged },
|
["M "] = { icons.staged },
|
||||||
@ -59,6 +57,8 @@ local function warn_status(git_status)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param node table
|
||||||
|
---@return HighlightedString[]|nil
|
||||||
local function get_icons_(node)
|
local function get_icons_(node)
|
||||||
local git_status = explorer_node.get_git_status(node)
|
local git_status = explorer_node.get_git_status(node)
|
||||||
if git_status == nil then
|
if git_status == nil then
|
||||||
@ -85,6 +85,11 @@ local function get_icons_(node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- sort icons so it looks slightly better
|
||||||
|
table.sort(iconss, function(a, b)
|
||||||
|
return a.ord < b.ord
|
||||||
|
end)
|
||||||
|
|
||||||
return iconss
|
return iconss
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -145,7 +150,9 @@ function M.setup(opts)
|
|||||||
|
|
||||||
M.git_icons = build_icons_table(opts.renderer.icons.glyphs.git)
|
M.git_icons = build_icons_table(opts.renderer.icons.glyphs.git)
|
||||||
|
|
||||||
M.setup_signs(opts.renderer.icons.glyphs.git)
|
if opts.renderer.icons.git_placement == "signcolumn" then
|
||||||
|
M.setup_signs(opts.renderer.icons.glyphs.git)
|
||||||
|
end
|
||||||
|
|
||||||
if opts.renderer.icons.show.git then
|
if opts.renderer.icons.show.git then
|
||||||
M.get_icons = get_icons_
|
M.get_icons = get_icons_
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
local M = { i = {} }
|
local M = { i = {} }
|
||||||
|
|
||||||
local function config_symlinks()
|
local function config_symlinks()
|
||||||
M.i.symlink = #M.config.glyphs.symlink > 0 and M.config.glyphs.symlink .. M.config.padding or ""
|
M.i.symlink = #M.config.glyphs.symlink > 0 and M.config.glyphs.symlink or ""
|
||||||
M.i.symlink_arrow = M.config.symlink_arrow
|
M.i.symlink_arrow = M.config.symlink_arrow
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -28,14 +28,14 @@ local function get_folder_icon(open, is_symlink, has_children)
|
|||||||
n = M.config.glyphs.folder.empty
|
n = M.config.glyphs.folder.empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return n .. M.config.padding
|
return n
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_file_icon_default()
|
local function get_file_icon_default()
|
||||||
local hl_group = "NvimTreeFileIcon"
|
local hl_group = "NvimTreeFileIcon"
|
||||||
local icon = M.config.glyphs.default
|
local icon = M.config.glyphs.default
|
||||||
if #icon > 0 then
|
if #icon > 0 then
|
||||||
return icon .. M.config.padding, hl_group
|
return icon, hl_group
|
||||||
else
|
else
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
@ -47,7 +47,7 @@ local function get_file_icon_webdev(fname, extension)
|
|||||||
hl_group = "NvimTreeFileIcon"
|
hl_group = "NvimTreeFileIcon"
|
||||||
end
|
end
|
||||||
if icon and hl_group ~= "DevIconDefault" then
|
if icon and hl_group ~= "DevIconDefault" then
|
||||||
return icon .. M.config.padding, hl_group
|
return icon, hl_group
|
||||||
elseif string.match(extension, "%.(.*)") then
|
elseif string.match(extension, "%.(.*)") then
|
||||||
-- If there are more extensions to the file, try to grab the icon for them recursively
|
-- If there are more extensions to the file, try to grab the icon for them recursively
|
||||||
return get_file_icon_webdev(fname, string.match(extension, "%.(.*)"))
|
return get_file_icon_webdev(fname, string.match(extension, "%.(.*)"))
|
||||||
|
|||||||
41
lua/nvim-tree/renderer/components/modified.lua
Normal file
41
lua/nvim-tree/renderer/components/modified.lua
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
local modified = require "nvim-tree.modified"
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local HIGHLIGHT = "NvimTreeModifiedFile"
|
||||||
|
|
||||||
|
---return modified icon if node is modified, otherwise return empty string
|
||||||
|
---@param node table
|
||||||
|
---@return HighlightedString|nil modified icon
|
||||||
|
function M.get_icon(node)
|
||||||
|
if not modified.is_modified(node) or not M.show_icon then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return { str = M.icon, hl = HIGHLIGHT }
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.setup_signs()
|
||||||
|
vim.fn.sign_define(HIGHLIGHT, { text = M.icon, texthl = HIGHLIGHT })
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param node table
|
||||||
|
---@return string|nil
|
||||||
|
function M.get_highlight(node)
|
||||||
|
if not modified.is_modified(node) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return HIGHLIGHT
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.setup(opts)
|
||||||
|
M.icon = opts.renderer.icons.glyphs.modified
|
||||||
|
M.show_icon = opts.renderer.icons.show.modified
|
||||||
|
|
||||||
|
if opts.renderer.icons.modified_placement == "signcolumn" then
|
||||||
|
M.setup_signs()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@ -68,6 +68,12 @@ local function get_padding_arrows(node, indent)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param depth integer
|
||||||
|
---@param idx integer
|
||||||
|
---@param nodes_number integer
|
||||||
|
---@param node table
|
||||||
|
---@param markers table
|
||||||
|
---@return HighlightedString
|
||||||
function M.get_padding(depth, idx, nodes_number, node, markers)
|
function M.get_padding(depth, idx, nodes_number, node, markers)
|
||||||
local padding = ""
|
local padding = ""
|
||||||
|
|
||||||
@ -86,7 +92,7 @@ function M.get_padding(depth, idx, nodes_number, node, markers)
|
|||||||
padding = padding .. get_padding_arrows(node, not show_markers)
|
padding = padding .. get_padding_arrows(node, not show_markers)
|
||||||
end
|
end
|
||||||
|
|
||||||
return padding
|
return { str = padding, hl = "NvimTreeIndentMarker" }
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ local core = require "nvim-tree.core"
|
|||||||
local diagnostics = require "nvim-tree.diagnostics"
|
local diagnostics = require "nvim-tree.diagnostics"
|
||||||
local log = require "nvim-tree.log"
|
local log = require "nvim-tree.log"
|
||||||
local view = require "nvim-tree.view"
|
local view = require "nvim-tree.view"
|
||||||
|
local modified = require "nvim-tree.renderer.components.modified"
|
||||||
|
|
||||||
local _padding = require "nvim-tree.renderer.components.padding"
|
local _padding = require "nvim-tree.renderer.components.padding"
|
||||||
local icon_component = require "nvim-tree.renderer.components.icons"
|
local icon_component = require "nvim-tree.renderer.components.icons"
|
||||||
@ -16,6 +17,8 @@ local M = {
|
|||||||
last_highlights = {},
|
last_highlights = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local SIGN_GROUP = "NvimTreeRendererSigns"
|
||||||
|
|
||||||
local namespace_id = vim.api.nvim_create_namespace "NvimTreeHighlights"
|
local namespace_id = vim.api.nvim_create_namespace "NvimTreeHighlights"
|
||||||
|
|
||||||
local function _draw(bufnr, lines, hl, signs)
|
local function _draw(bufnr, lines, hl, signs)
|
||||||
@ -23,9 +26,9 @@ local function _draw(bufnr, lines, hl, signs)
|
|||||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines)
|
||||||
M.render_hl(bufnr, hl)
|
M.render_hl(bufnr, hl)
|
||||||
vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
|
vim.api.nvim_buf_set_option(bufnr, "modifiable", false)
|
||||||
vim.fn.sign_unplace(git.SIGN_GROUP)
|
vim.fn.sign_unplace(SIGN_GROUP)
|
||||||
for _, sign in pairs(signs) do
|
for _, sign in pairs(signs) do
|
||||||
vim.fn.sign_place(0, git.SIGN_GROUP, sign.sign, bufnr, { lnum = sign.lnum, priority = 1 })
|
vim.fn.sign_place(0, SIGN_GROUP, sign.sign, bufnr, { lnum = sign.lnum, priority = sign.priority })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -68,8 +71,10 @@ function M.draw(unloaded_bufnr)
|
|||||||
:configure_special_files(M.config.special_files)
|
:configure_special_files(M.config.special_files)
|
||||||
:configure_picture_map(picture_map)
|
:configure_picture_map(picture_map)
|
||||||
:configure_opened_file_highlighting(M.config.highlight_opened_files)
|
:configure_opened_file_highlighting(M.config.highlight_opened_files)
|
||||||
:configure_git_icons_padding(M.config.icons.padding)
|
:configure_modified_highlighting(M.config.highlight_modified)
|
||||||
|
:configure_icon_padding(M.config.icons.padding)
|
||||||
:configure_git_icons_placement(M.config.icons.git_placement)
|
:configure_git_icons_placement(M.config.icons.git_placement)
|
||||||
|
:configure_modified_placement(M.config.icons.modified_placement)
|
||||||
:configure_symlink_destination(M.config.symlink_destination)
|
:configure_symlink_destination(M.config.symlink_destination)
|
||||||
:configure_filter(live_filter.filter, live_filter.prefix)
|
:configure_filter(live_filter.filter, live_filter.prefix)
|
||||||
:build_header(view.is_root_folder_visible(core.get_cwd()))
|
:build_header(view.is_root_folder_visible(core.get_cwd()))
|
||||||
@ -100,10 +105,12 @@ end
|
|||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
M.config = opts.renderer
|
M.config = opts.renderer
|
||||||
|
M.config.modified = opts.modified
|
||||||
|
|
||||||
_padding.setup(opts)
|
_padding.setup(opts)
|
||||||
full_name.setup(opts)
|
full_name.setup(opts)
|
||||||
git.setup(opts)
|
git.setup(opts)
|
||||||
|
modified.setup(opts)
|
||||||
icon_component.setup(opts)
|
icon_component.setup(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user