Skip to content

Commit

Permalink
Fix: bookmark columns.
Browse files Browse the repository at this point in the history
  • Loading branch information
obaland committed Feb 21, 2022
1 parent a6efe25 commit 80eb2bb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
14 changes: 10 additions & 4 deletions lua/vfiler/extensions/bookmark/columns/icon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ IconColumn.configs = {
directory = ' ',
closed = '+',
opened = '-',
unknown = '?',
}

function IconColumn.setup(configs)
Expand All @@ -33,6 +34,11 @@ function IconColumn.new()
start_mark = 'i@c\\',
highlight = 'vfilerBookmarkCategory',
},
unknown = {
group = 'vfilerBookmarkIcon_Unknown',
start_mark = 'i@u\\',
highlight = 'vfilerBookmarkUnknown',
},
},
end_mark = '\\i@',
})
Expand All @@ -49,13 +55,13 @@ function IconColumn:get_width(items)
end

function IconColumn:_get_text(item, width)
local iname
local key
if item.type == 'category' then
iname = item.opened and 'opened' or 'closed'
key = item.opened and 'opened' or 'closed'
else
iname = item.type
key = item.type
end
local icon = self.configs[iname]
local icon = self.configs[key]
return icon .. (' '):rep(self.icon_width - vim.fn.strwidth(icon))
end

Expand Down
5 changes: 5 additions & 0 deletions lua/vfiler/extensions/bookmark/columns/name.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ function NameColumn.new()
start_mark = 'n@l\\',
highlight = 'vfilerBookmarkLink',
},
unknown = {
group = 'vfilerBookmarkName_Unknown',
start_mark = 'n@u\\',
highlight = 'vfilerBookmarkUnknown',
},
},
end_mark = '\\n@',
})
Expand Down
4 changes: 2 additions & 2 deletions lua/vfiler/extensions/bookmark/items/item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ function Item.new(name, path)
level = 2,
parent = nil,
path = path,
link = fstat.link,
type = fstat.type,
link = fstat and fstat.link or false,
type = fstat and fstat.type or 'unknown',
}, Item)
end

Expand Down
3 changes: 3 additions & 0 deletions lua/vfiler/libs/filesystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ if core.is_nvim then

function M.stat(path)
local stat = uv.fs_lstat(path)
if not stat then
return nil
end
local link = stat.type == 'link'
if link then
stat = uv.fs_stat(path)
Expand Down
1 change: 1 addition & 0 deletions plugin/vfiler.vim
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ highlight default link vfilerBookmarkCategory Title
highlight default link vfilerBookmarkDirectory Directory
highlight default link vfilerBookmarkFile None
highlight default link vfilerBookmarkLink Constant
highlight default link vfilerBookmarkUnknown Comment
highlight default link vfilerBookmarkPath Comment
highlight default link vfilerBookmarkWarning WarningMsg

Expand Down

0 comments on commit 80eb2bb

Please sign in to comment.