chore: add type annotations to (almost) all functions

This commit is contained in:
Akmadan23
2023-11-24 12:01:24 +01:00
parent 46e1f776f0
commit fabea3376e
48 changed files with 438 additions and 83 deletions

View File

@@ -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

View File

@@ -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 = ""

View File

@@ -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>")

View File

@@ -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."