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:
@@ -2,6 +2,7 @@ local core = require "nvim-tree.core"
|
||||
local diagnostics = require "nvim-tree.diagnostics"
|
||||
local log = require "nvim-tree.log"
|
||||
local view = require "nvim-tree.view"
|
||||
local modified = require "nvim-tree.renderer.components.modified"
|
||||
|
||||
local _padding = require "nvim-tree.renderer.components.padding"
|
||||
local icon_component = require "nvim-tree.renderer.components.icons"
|
||||
@@ -16,6 +17,8 @@ local M = {
|
||||
last_highlights = {},
|
||||
}
|
||||
|
||||
local SIGN_GROUP = "NvimTreeRendererSigns"
|
||||
|
||||
local namespace_id = vim.api.nvim_create_namespace "NvimTreeHighlights"
|
||||
|
||||
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)
|
||||
M.render_hl(bufnr, hl)
|
||||
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
|
||||
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
|
||||
|
||||
@@ -68,8 +71,10 @@ function M.draw(unloaded_bufnr)
|
||||
:configure_special_files(M.config.special_files)
|
||||
:configure_picture_map(picture_map)
|
||||
: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_modified_placement(M.config.icons.modified_placement)
|
||||
:configure_symlink_destination(M.config.symlink_destination)
|
||||
:configure_filter(live_filter.filter, live_filter.prefix)
|
||||
:build_header(view.is_root_folder_visible(core.get_cwd()))
|
||||
@@ -100,10 +105,12 @@ end
|
||||
|
||||
function M.setup(opts)
|
||||
M.config = opts.renderer
|
||||
M.config.modified = opts.modified
|
||||
|
||||
_padding.setup(opts)
|
||||
full_name.setup(opts)
|
||||
git.setup(opts)
|
||||
modified.setup(opts)
|
||||
icon_component.setup(opts)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user