chore: add type annotations to (almost) all functions
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
|
||||
|
||||
@@ -14,7 +14,7 @@ local function get_user_input_char()
|
||||
return vim.fn.nr2char(c)
|
||||
end
|
||||
|
||||
---Get all windows in the current tabpage that aren't NvimTree.
|
||||
--- Get all windows in the current tabpage that aren't NvimTree.
|
||||
---@return table with valid win_ids
|
||||
local function usable_win_ids()
|
||||
local tabpage = vim.api.nvim_get_current_tabpage()
|
||||
@@ -302,6 +302,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,6 +6,8 @@ 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())
|
||||
@@ -14,6 +16,7 @@ local function get_node_path(node)
|
||||
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