summaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorFasamii <fasami0512@gmail.com>2026-02-09 00:30:06 +0100
committerFasamii <fasami0512@gmail.com>2026-02-09 00:30:06 +0100
commitb72d585866564779e93bff98dcc5b389ae88653c (patch)
treefd51d7cbf07c922728e6716c8426380fb7272cf1 /lua
parentaa0d6ed0a4c22a773f5db25647004424fb946bf6 (diff)
downloadnetrw-icons.nvim-b72d585866564779e93bff98dcc5b389ae88653c.tar.gz
netrw-icons.nvim-b72d585866564779e93bff98dcc5b389ae88653c.tar.bz2
netrw-icons.nvim-b72d585866564779e93bff98dcc5b389ae88653c.tar.xz
netrw-icons.nvim-b72d585866564779e93bff98dcc5b389ae88653c.tar.zst
parse_liststyle_0 early returns
Diffstat (limited to 'lua')
-rw-r--r--lua/netrw-icons/parse.lua29
1 files changed, 14 insertions, 15 deletions
diff --git a/lua/netrw-icons/parse.lua b/lua/netrw-icons/parse.lua
index d2692af..4b5d121 100644
--- a/lua/netrw-icons/parse.lua
+++ b/lua/netrw-icons/parse.lua
@@ -13,37 +13,36 @@ M.TYPE_FILE = 1
M.TYPE_EXE = 2
M.TYPE_SYMLINK = 3
----@alias rwNode{name:string, icon:number, type:number}
+---@alias reNode{name:string, icon:number, type:number}
---@param line string
----@param curdir string
---@return rwNode|nil
local parse_liststyle_0 = function(line)
- local current_dir = vim.b.netrw_curdir;
- local type = M.TYPE_FILE;
+ local node = {};
+ node.type = M.TYPE_FILE;
+ node.icon = 0;
- local name = line;
+ node.name = line;
- if name:sub(-1) == "*" then
- type = M.TYPE_EXE;
+ if node.name:sub(-1) == "*" then
+ node.type = M.TYPE_EXE;
+ return node;
end
local _, _, link, link_target = string.find(line, "^(.+)@\t%s*%-%->%s*(.+)")
if link then
- type = M.TYPE_SYMLINK;
- name = link_target;
+ node.type = M.TYPE_SYMLINK;
+ node.name = link_target;
+ return node;
end
local _, _, dir = string.find(line, "^(.*)/")
if dir then
- type = M.TYPE_DIR;
+ node.type = M.TYPE_DIR;
+ return node;
end
- return {
- name = name,
- icon = 0,
- type = type,
- }
+ return node;
end
---@param line string