Skip to content

Commit 142cb30

Browse files
committed
chore: resolve undefined-field
1 parent a4a6e6c commit 142cb30

File tree

8 files changed

+48
-44
lines changed

8 files changed

+48
-44
lines changed

lua/nvim-tree/actions/moves/item.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ local MAX_DEPTH = 100
1111

1212
---Return the status of the node or nil if no status, depending on the type of
1313
---status.
14-
---@param node table node to inspect
14+
---@param node Node to inspect
1515
---@param what string type of status
1616
---@param skip_gitignored boolean default false
1717
---@return boolean
1818
local function status_is_valid(node, what, skip_gitignored)
1919
if what == "git" then
20-
local git_status = node:get_git_status()
21-
return git_status ~= nil and (not skip_gitignored or git_status[1] ~= "!!")
20+
local git_xy = node:get_git_xy()
21+
return git_xy ~= nil and (not skip_gitignored or git_xy[1] ~= "!!")
2222
elseif what == "diag" then
2323
local diag_status = diagnostics.get_diag_status(node)
2424
return diag_status ~= nil and diag_status.value ~= nil

lua/nvim-tree/git/init.lua

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,29 @@ local Watcher = require("nvim-tree.watcher").Watcher
77
local Iterator = require("nvim-tree.iterators.node-iterator")
88
local DirectoryNode = require("nvim-tree.node.directory")
99

10-
---Git xy short-format statuses for a single node
11-
---@class (exact) GitNodeStatus
12-
---@field file string?
13-
---@field dir table<"direct" | "indirect", string[]>?
10+
---Git short format status xy
11+
---@alias GitXY string
1412

15-
-- Git xy short-format status
16-
---@alias GitPathXY table<string, string>
13+
-- Git short-format status
14+
---@alias GitPathXY table<string, GitXY>
1715

18-
-- Git xy short-format statuses
19-
---@alias GitPathXYs table<string, string[]>
16+
-- Git short-format statuses
17+
---@alias GitPathXYs table<string, GitXY[]>
2018

21-
---@alias GitProjectFiles GitPathXY
22-
---@alias GitProjectDirs table<"direct" | "indirect", GitPathXYs>
19+
---Git short-format statuses for a single node
20+
---@class (exact) GitNodeStatus
21+
---@field file GitXY
22+
---@field dir table<"direct" | "indirect", GitXY[]>?
2323

2424
---Git state for an entire repo
2525
---@class (exact) GitProject
2626
---@field files GitProjectFiles?
2727
---@field dirs GitProjectDirs?
2828
---@field watcher Watcher?
2929

30+
---@alias GitProjectFiles GitPathXY
31+
---@alias GitProjectDirs table<"direct" | "indirect", GitPathXYs>
32+
3033
local M = {
3134
config = {},
3235

lua/nvim-tree/node/directory-link.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function DirectoryLinkNode:destroy()
3636
DirectoryNode.destroy(self)
3737
end
3838

39-
---Update the directory GitStatus of link target and the file status of the link itself
39+
---Update the directory git_status of link target and the file status of the link itself
4040
---@param parent_ignored boolean
4141
---@param status table|nil
4242
function DirectoryLinkNode:update_git_status(parent_ignored, status)

lua/nvim-tree/node/directory.lua

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,41 +65,41 @@ function DirectoryNode:destroy()
6565
Node.destroy(self)
6666
end
6767

68-
---Update the GitStatus of the directory
68+
---Update the git_status of the directory
6969
---@param parent_ignored boolean
7070
---@param status table|nil
7171
function DirectoryNode:update_git_status(parent_ignored, status)
7272
self.git_status = git_utils.git_status_dir(parent_ignored, status, self.absolute_path, nil)
7373
end
7474

75-
---@return string[]? xy short-format statuses
76-
function DirectoryNode:get_git_status()
75+
---@return GitXY[]?
76+
function DirectoryNode:get_git_xy()
7777
if not self.git_status or not self.explorer.opts.git.show_on_dirs then
7878
return nil
7979
end
8080

81-
local status = {}
81+
local xys = {}
8282
if not self:last_group_node().open or self.explorer.opts.git.show_on_open_dirs then
8383
-- dir is closed or we should show on open_dirs
8484
if self.git_status.file ~= nil then
85-
table.insert(status, self.git_status.file)
85+
table.insert(xys, self.git_status.file)
8686
end
8787
if self.git_status.dir ~= nil then
8888
if self.git_status.dir.direct ~= nil then
8989
for _, s in pairs(self.git_status.dir.direct) do
90-
table.insert(status, s)
90+
table.insert(xys, s)
9191
end
9292
end
9393
if self.git_status.dir.indirect ~= nil then
9494
for _, s in pairs(self.git_status.dir.indirect) do
95-
table.insert(status, s)
95+
table.insert(xys, s)
9696
end
9797
end
9898
end
9999
else
100100
-- dir is open and we shouldn't show on open_dirs
101101
if self.git_status.file ~= nil then
102-
table.insert(status, self.git_status.file)
102+
table.insert(xys, self.git_status.file)
103103
end
104104
if self.git_status.dir ~= nil and self.git_status.dir.direct ~= nil then
105105
local deleted = {
@@ -110,15 +110,15 @@ function DirectoryNode:get_git_status()
110110
}
111111
for _, s in pairs(self.git_status.dir.direct) do
112112
if deleted[s] then
113-
table.insert(status, s)
113+
table.insert(xys, s)
114114
end
115115
end
116116
end
117117
end
118-
if #status == 0 then
118+
if #xys == 0 then
119119
return nil
120120
else
121-
return status
121+
return xys
122122
end
123123
end
124124

lua/nvim-tree/node/file-link.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function FileLinkNode:destroy()
3232
FileNode.destroy(self)
3333
end
3434

35-
---Update the GitStatus of the target otherwise the link itself
35+
---Update the git_status of the target otherwise the link itself
3636
---@param parent_ignored boolean
3737
---@param status table|nil
3838
function FileLinkNode:update_git_status(parent_ignored, status)

lua/nvim-tree/node/file.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function FileNode:update_git_status(parent_ignored, status)
4747
self.git_status = git_utils.git_status_file(parent_ignored, status, self.absolute_path, nil)
4848
end
4949

50-
---@return string[]? xy short-format statuses
51-
function FileNode:get_git_status()
50+
---@return GitXY[]?
51+
function FileNode:get_git_xy()
5252
if not self.git_status then
5353
return nil
5454
end

lua/nvim-tree/node/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@ local Node = Class:new()
1919
function Node:destroy()
2020
end
2121

22-
---Update the GitStatus of the node
22+
---Update the git_status of the node
2323
---Abstract
2424
---@param parent_ignored boolean
2525
---@param status table?
2626
function Node:update_git_status(parent_ignored, status)
2727
self:nop(parent_ignored, status)
2828
end
2929

30-
---@return string[]? xy short-format statuses
31-
function Node:get_git_status()
30+
---Short-format statuses
31+
---@return GitXY[]?
32+
function Node:get_git_xy()
3233
end
3334

3435
---@return boolean

lua/nvim-tree/renderer/decorator/git.lua

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ local DirectoryNode = require("nvim-tree.node.directory")
1212
---@alias GitStatusStrings "deleted" | "ignored" | "renamed" | "staged" | "unmerged" | "unstaged" | "untracked"
1313

1414
---@alias GitIconsByStatus table<GitStatusStrings, GitHighlightedString> human status
15-
---@alias GitIconsByXY table<string, GitHighlightedString[]> porcelain status
16-
---@alias GitGlyphs table<GitStatusStrings, string> from opts
15+
---@alias GitIconsByXY table<GitXY, GitHighlightedString[]> porcelain status
16+
---@alias GitGlyphsByStatus table<GitStatusStrings, string> from opts
1717

1818
---@class (exact) DecoratorGit: Decorator
19-
---@field file_hl_by_xy table<string, string>?
20-
---@field folder_hl_by_xy table<string, string>?
19+
---@field file_hl_by_xy table<GitXY, string>?
20+
---@field folder_hl_by_xy table<GitXY, string>?
2121
---@field icons_by_status GitIconsByStatus?
2222
---@field icons_by_xy GitIconsByXY?
2323
local DecoratorGit = Decorator:new()
@@ -56,7 +56,7 @@ function DecoratorGit:create(opts, explorer)
5656
return o
5757
end
5858

59-
---@param glyphs GitGlyphs
59+
---@param glyphs GitGlyphsByStatus
6060
function DecoratorGit:build_icons_by_status(glyphs)
6161
self.icons_by_status = {}
6262
self.icons_by_status.staged = { str = glyphs.staged, hl = { "NvimTreeGitStagedIcon" }, ord = 1 }
@@ -154,19 +154,19 @@ function DecoratorGit:calculate_icons(node)
154154
return nil
155155
end
156156

157-
local git_status = node:get_git_status()
158-
if git_status == nil then
157+
local git_xy = node:get_git_xy()
158+
if git_xy == nil then
159159
return nil
160160
end
161161

162162
local inserted = {}
163163
local iconss = {}
164164

165-
for _, s in pairs(git_status) do
165+
for _, s in pairs(git_xy) do
166166
local icons = self.icons_by_xy[s]
167167
if not icons then
168168
if self.hl_pos == HL_POSITION.none then
169-
notify.warn(string.format("Unrecognized git state '%s'", git_status))
169+
notify.warn(string.format("Unrecognized git state '%s'", git_xy))
170170
end
171171
return nil
172172
end
@@ -215,15 +215,15 @@ function DecoratorGit:calculate_highlight(node)
215215
return nil
216216
end
217217

218-
local git_status = node:get_git_status()
219-
if not git_status then
218+
local git_xy = node:get_git_xy()
219+
if not git_xy then
220220
return nil
221221
end
222222

223223
if node:is(DirectoryNode) then
224-
return self.folder_hl_by_xy[git_status[1]]
224+
return self.folder_hl_by_xy[git_xy[1]]
225225
else
226-
return self.file_hl_by_xy[git_status[1]]
226+
return self.file_hl_by_xy[git_xy[1]]
227227
end
228228
end
229229

0 commit comments

Comments
 (0)