chore: add type annotations and resolve LSP warnings (#2555)
* chore: add type annotations to (almost) all functions
* stylua
* Add classes for symlink nodes
* Replace deprecated `@vararg`
* Move node classes to `node` module
* Fix `Symlink*` classes
* add vim and libuv runtime for luals, qualify libuv types
* add scripts/luals-check, not quite ready for CI
* additional nil checks for git/init.lua and git/runner.lua
* additional nil checks for nvim-tree.lua
* wrap vim.cmd-as-a-function calls inside functions
* vim.tbl_filter predicate returns booleans
* Revert "add scripts/luals-check, not quite ready for CI"
This reverts commit c70229cad9.
* Add `MinimalNode` class in `marks` module
* Fix various LSP warnings
* stylua
* Fix `Explorer` class, update related annotations and add necessary checks
* Add missing annotations to `live-filter`
* Add temporary aliases for `uv.*` types
* Resolve remaining LSP warnings
* Revert changes not related to internal types
* Minor adjustments
* Update doc comments style
* Minor adjustments (pt. 2)
---------
Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
@@ -2,6 +2,8 @@ local utils = require "nvim-tree.utils"
|
||||
|
||||
local M = {}
|
||||
|
||||
---@param node Node
|
||||
---@return table
|
||||
local function get_formatted_lines(node)
|
||||
local stats = node.fs_stat
|
||||
local fpath = " fullpath: " .. node.absolute_path
|
||||
@@ -21,6 +23,7 @@ end
|
||||
|
||||
local current_popup = nil
|
||||
|
||||
---@param node Node
|
||||
local function setup_window(node)
|
||||
local lines = get_formatted_lines(node)
|
||||
|
||||
@@ -52,6 +55,7 @@ function M.close_popup()
|
||||
end
|
||||
end
|
||||
|
||||
---@param node Node
|
||||
function M.toggle_file_info(node)
|
||||
if node.name == ".." then
|
||||
return
|
||||
|
||||
@@ -6,6 +6,8 @@ local view = require "nvim-tree.view"
|
||||
|
||||
local M = {}
|
||||
|
||||
---Get single char from user input
|
||||
---@return string
|
||||
local function get_user_input_char()
|
||||
local c = vim.fn.getchar()
|
||||
while type(c) ~= "number" do
|
||||
@@ -302,6 +304,8 @@ local function edit_in_current_buf(filename)
|
||||
vim.cmd("keepalt keepjumps edit " .. vim.fn.fnameescape(filename))
|
||||
end
|
||||
|
||||
---@param mode string
|
||||
---@param filename string
|
||||
function M.fn(mode, filename)
|
||||
if type(mode) ~= "string" then
|
||||
mode = ""
|
||||
|
||||
@@ -6,14 +6,18 @@ local M = {}
|
||||
---Retrieves the absolute path to the node.
|
||||
---Safely handles the node representing the current directory
|
||||
---(the topmost node in the nvim-tree window)
|
||||
---@param node Node
|
||||
---@return string
|
||||
local function get_node_path(node)
|
||||
if node.name == ".." then
|
||||
return utils.path_remove_trailing(core.get_cwd())
|
||||
local cwd = core.get_cwd()
|
||||
if node.name == ".." and cwd then
|
||||
return utils.path_remove_trailing(cwd)
|
||||
else
|
||||
return node.absolute_path
|
||||
end
|
||||
end
|
||||
|
||||
---@param node Node
|
||||
function M.run_file_command(node)
|
||||
local node_path = get_node_path(node)
|
||||
vim.api.nvim_input(": " .. node_path .. "<Home>")
|
||||
|
||||
@@ -3,6 +3,7 @@ local utils = require "nvim-tree.utils"
|
||||
|
||||
local M = {}
|
||||
|
||||
---@param node Node
|
||||
function M.fn(node)
|
||||
if #M.config.system_open.cmd == 0 then
|
||||
require("nvim-tree.utils").notify.warn "Cannot open file with system application. Unrecognized platform."
|
||||
|
||||
Reference in New Issue
Block a user