Skip to content

Commit

Permalink
feat(hyper): add mru.enable option (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmckendry authored Nov 2, 2024
1 parent d2c5a4d commit 5f29798
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ config = {
-- action can be a functino type, e.g.
-- action = func(path) vim.cmd('Telescope find_files cwd=' .. path) end
project = { enable = true, limit = 8, icon = 'your icon', label = '', action = 'Telescope find_files cwd=' },
mru = { limit = 10, icon = 'your icon', label = '', cwd_only = false },
mru = { enable = true, limit = 10, icon = 'your icon', label = '', cwd_only = false },
footer = {}, -- footer
}
```
Expand Down
15 changes: 14 additions & 1 deletion lua/dashboard/theme/hyper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,13 @@ local function mru_list(config)
icon_hl = 'DashboardMruIcon',
label = ' Most Recent Files:',
cwd_only = false,
enable = true,
}, config.mru or {})

if not config.mru.enable then
return {}, {}
end

local list = {
config.mru.icon .. config.mru.label,
}
Expand Down Expand Up @@ -352,12 +357,20 @@ local function gen_center(plist, config)
local first_line = api.nvim_buf_line_count(config.bufnr)
api.nvim_buf_set_lines(config.bufnr, first_line, -1, false, plist)

local start_col = plist[plist_len + 2]:find('[^%s]') - 1
if not config.project.enable and not config.mru.enable then
return
end

local _, scol = plist[2]:find('%S')
if scol == nil then
scol = 0
end

local start_col = scol
if config.mru.enable then
start_col = plist[plist_len + 2]:find('[^%s]') - 1
end

local hotkey = gen_hotkey(config)

api.nvim_buf_add_highlight(config.bufnr, 0, 'DashboardProjectTitle', first_line + 1, 0, -1)
Expand Down

0 comments on commit 5f29798

Please sign in to comment.