chore: migrate to classic (#2991)
* add classic, migrating nodes classes
* add mixins to classic
* typechecked optargs constructors for nodes
* typechecked optargs constructors for watcher and event
* luacheck
* typechecked optargs constructors for GitRunner
* typechecked optargs constructors for Sorter
* typechecked optargs constructors for decorators, WIP
* typechecked optargs constructors for decorators, WIP
* typechecked optargs constructors for decorators
* remove class
* replace enums with named maps
* Renderer and Builder use classic, tidy opts
* LiveFilter uses classic, tidy opts
* Filter uses classic, tidy opts
* add FilterTypes named map
* move toggles into filters
* Marks uses classic, tidy opts
* Sorter uses classic, tidy opts
* Clipboard uses classic, tidy opts
* use supers for node methods
* HighlightDisplay uses classic
* protected :new
* Watcher tidy
* Revert "use supers for node methods"
This reverts commit 9fc7a866ec.
* Watcher tidy
* format
* format
* Filters private methods
* format
* Sorter type safety
* Sorter type safety
* Sorter type safety
* Sorter type safety
* Sorter type safety
* Sorter type safety
* tidy Runner
* tidy hi-test name
This commit is contained in:
committed by
GitHub
parent
610a1c189b
commit
3fc8de198c
@@ -7,6 +7,7 @@ local notify = require("nvim-tree.notify")
|
||||
|
||||
local find_file = require("nvim-tree.actions.finders.find-file").fn
|
||||
|
||||
local Class = require("nvim-tree.classic")
|
||||
local DirectoryNode = require("nvim-tree.node.directory")
|
||||
|
||||
---@alias ClipboardAction "copy" | "cut"
|
||||
@@ -14,35 +15,31 @@ local DirectoryNode = require("nvim-tree.node.directory")
|
||||
|
||||
---@alias ClipboardActionFn fun(source: string, dest: string): boolean, string?
|
||||
|
||||
---@class Clipboard to handle all actions.fs clipboard API
|
||||
---@field config table hydrated user opts.filters
|
||||
---@class (exact) Clipboard: Class
|
||||
---@field private explorer Explorer
|
||||
---@field private data ClipboardData
|
||||
---@field private clipboard_name string
|
||||
---@field private reg string
|
||||
local Clipboard = {}
|
||||
local Clipboard = Class:extend()
|
||||
|
||||
---@param opts table user options
|
||||
---@param explorer Explorer
|
||||
---@return Clipboard
|
||||
function Clipboard:new(opts, explorer)
|
||||
---@type Clipboard
|
||||
local o = {
|
||||
explorer = explorer,
|
||||
data = {
|
||||
copy = {},
|
||||
cut = {},
|
||||
},
|
||||
clipboard_name = opts.actions.use_system_clipboard and "system" or "neovim",
|
||||
reg = opts.actions.use_system_clipboard and "+" or "1",
|
||||
config = {
|
||||
filesystem_watchers = opts.filesystem_watchers,
|
||||
},
|
||||
---@class Clipboard
|
||||
---@overload fun(args: ClipboardArgs): Clipboard
|
||||
|
||||
---@class (exact) ClipboardArgs
|
||||
---@field explorer Explorer
|
||||
|
||||
---@protected
|
||||
---@param args ClipboardArgs
|
||||
function Clipboard:new(args)
|
||||
self.explorer = args.explorer
|
||||
|
||||
self.data = {
|
||||
copy = {},
|
||||
cut = {},
|
||||
}
|
||||
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
return o
|
||||
self.clipboard_name = self.explorer.opts.actions.use_system_clipboard and "system" or "neovim"
|
||||
self.reg = self.explorer.opts.actions.use_system_clipboard and "+" or "1"
|
||||
end
|
||||
|
||||
---@param source string
|
||||
@@ -252,7 +249,7 @@ function Clipboard:do_paste(node, action, action_fn)
|
||||
end
|
||||
|
||||
self.data[action] = {}
|
||||
if not self.config.filesystem_watchers.enable then
|
||||
if not self.explorer.opts.filesystem_watchers.enable then
|
||||
self.explorer:reload_explorer()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,6 @@ local M = {}
|
||||
|
||||
M.collapse_all = require("nvim-tree.actions.tree.modifiers.collapse-all")
|
||||
M.expand_all = require("nvim-tree.actions.tree.modifiers.expand-all")
|
||||
M.toggles = require("nvim-tree.actions.tree.modifiers.toggles")
|
||||
|
||||
function M.setup(opts)
|
||||
M.expand_all.setup(opts)
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
local utils = require("nvim-tree.utils")
|
||||
local core = require("nvim-tree.core")
|
||||
local M = {}
|
||||
|
||||
---@param explorer Explorer
|
||||
local function reload(explorer)
|
||||
local node = explorer:get_node_at_cursor()
|
||||
explorer:reload_explorer()
|
||||
if node then
|
||||
utils.focus_node_or_parent(node)
|
||||
end
|
||||
end
|
||||
|
||||
local function wrap_explorer(fn)
|
||||
return function(...)
|
||||
local explorer = core.get_explorer()
|
||||
if explorer then
|
||||
return fn(explorer, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param explorer Explorer
|
||||
local function custom(explorer)
|
||||
explorer.filters.config.filter_custom = not explorer.filters.config.filter_custom
|
||||
reload(explorer)
|
||||
end
|
||||
|
||||
---@param explorer Explorer
|
||||
local function git_ignored(explorer)
|
||||
explorer.filters.config.filter_git_ignored = not explorer.filters.config.filter_git_ignored
|
||||
reload(explorer)
|
||||
end
|
||||
|
||||
---@param explorer Explorer
|
||||
local function git_clean(explorer)
|
||||
explorer.filters.config.filter_git_clean = not explorer.filters.config.filter_git_clean
|
||||
reload(explorer)
|
||||
end
|
||||
|
||||
---@param explorer Explorer
|
||||
local function no_buffer(explorer)
|
||||
explorer.filters.config.filter_no_buffer = not explorer.filters.config.filter_no_buffer
|
||||
reload(explorer)
|
||||
end
|
||||
|
||||
---@param explorer Explorer
|
||||
local function no_bookmark(explorer)
|
||||
explorer.filters.config.filter_no_bookmark = not explorer.filters.config.filter_no_bookmark
|
||||
reload(explorer)
|
||||
end
|
||||
|
||||
---@param explorer Explorer
|
||||
local function dotfiles(explorer)
|
||||
explorer.filters.config.filter_dotfiles = not explorer.filters.config.filter_dotfiles
|
||||
reload(explorer)
|
||||
end
|
||||
|
||||
---@param explorer Explorer
|
||||
local function enable(explorer)
|
||||
explorer.filters.config.enable = not explorer.filters.config.enable
|
||||
reload(explorer)
|
||||
end
|
||||
|
||||
M.custom = wrap_explorer(custom)
|
||||
M.git_ignored = wrap_explorer(git_ignored)
|
||||
M.git_clean = wrap_explorer(git_clean)
|
||||
M.no_buffer = wrap_explorer(no_buffer)
|
||||
M.no_bookmark = wrap_explorer(no_bookmark)
|
||||
M.dotfiles = wrap_explorer(dotfiles)
|
||||
M.enable = wrap_explorer(enable)
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user