Skip to content

Commit

Permalink
Show relative paths when CWD only is enabled for recent files (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-algms authored Feb 2, 2024
1 parent 63df284 commit f6e8b07
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lua/dashboard/theme/hyper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,10 @@ local function mru_list(config)
local filename = vim.fn.fnamemodify(file, ':t')
local icon, group = utils.get_icon(filename)
icon = icon or ''
if not utils.is_win then
file = file:gsub(vim.env.HOME, '~')
if config.mru.cwd_only then
file = vim.fn.fnamemodify(file, ':.')
elseif not utils.is_win then
file = vim.fn.fnamemodify(file, ':~')
end
file = icon .. ' ' .. file
table.insert(groups, { #icon, group })
Expand Down Expand Up @@ -279,8 +281,15 @@ end
local function map_key(config, key, content)
keymap.set('n', key, function()
local text = content or api.nvim_get_current_line()
local scol = utils.is_win and text:find('%w') or text:find('%p')
text = text:sub(scol)

if config.mru.cwd_only then
local scol = text:find(' %w')
text = text:sub(scol)
else
local scol = utils.is_win and text:find('%w') or text:find('%p')
text = text:sub(scol)
end

local path = text:sub(1, text:find('%w(%s+)$'))
path = vim.fs.normalize(path)
if vim.fn.isdirectory(path) == 1 then
Expand Down

0 comments on commit f6e8b07

Please sign in to comment.