1

Refresh generated neovim config

This commit is contained in:
2024-08-15 13:01:03 +02:00
parent 64b51cf53a
commit f5af8e2b28
1836 changed files with 38979 additions and 31094 deletions

View File

@ -36,6 +36,7 @@ local function default_options()
theme = 'hyper',
disable_move = false,
shortcut_type = 'letter',
shuffle_letter = false,
buffer_name = 'Dashboard',
change_to_vcs_root = false,
config = {
@ -76,7 +77,6 @@ local function buf_local()
['filetype'] = 'dashboard',
['wrap'] = false,
['signcolumn'] = 'no',
['winbar'] = '',
}
for opt, val in pairs(opts) do
vim.opt_local[opt] = val
@ -94,6 +94,7 @@ function db:save_user_options()
self.user_cursor_line = vim.opt.cursorline:get()
self.user_laststatus_value = vim.opt.laststatus:get()
self.user_tabline_value = vim.opt.showtabline:get()
self.user_winbar_value = vim.opt.winbar:get()
end
function db:set_ui_options(opts)
@ -103,6 +104,9 @@ function db:set_ui_options(opts)
if opts.hide.tabline then
vim.opt.showtabline = 0
end
if opts.hide.winbar then
vim.opt.winbar = ''
end
end
function db:restore_user_options(opts)
@ -117,6 +121,10 @@ function db:restore_user_options(opts)
if opts.hide.tabline and self.user_tabline_value then
vim.opt.showtabline = tonumber(self.user_tabline_value)
end
if opts.hide.winbar and self.user_winbar_value then
vim.opt.winbar = self.user_winbar_value
end
end
function db:cache_opts()
@ -190,6 +198,7 @@ function db:load_theme(opts)
winid = self.winid,
confirm_key = opts.confirm_key or nil,
shortcut_type = opts.shortcut_type,
shuffle_letter = opts.shuffle_letter,
change_to_vcs_root = opts.change_to_vcs_root,
})

View File

@ -135,11 +135,12 @@ local function generate_center(config)
-- FIX: #422: In Lua the length of a string is the number of bytes not
-- the number of characters.
local curline_str = api.nvim_buf_get_lines(config.bufnr, curline - 1, curline, false)[1]
local offset = col_width - api.nvim_strwidth(curline_str:sub(1, col + 1))
if offset < 0 then
offset = 0
local strwidth = api.nvim_strwidth(curline_str:sub(1, col + 1))
local col_with_offset = col + col_width - strwidth
if col_with_offset < 0 then
col_with_offset = 0
end
api.nvim_win_set_cursor(config.winid, { curline, col + offset })
api.nvim_win_set_cursor(config.winid, { curline, col_with_offset })
end,
})
end, 0)

View File

@ -175,11 +175,12 @@ local function mru_list(config)
if config.mru.cwd_only then
local cwd = uv.cwd()
local sep = utils.is_win and '\\' or '/'
local cwd_with_sep = cwd .. sep
-- get separator from the first file
local sep = mlist[1]:match('[\\/]')
local cwd_with_sep = cwd:gsub('[\\/]', sep) .. sep
mlist = vim.tbl_filter(function(file)
local file_dir = vim.fn.fnamemodify(file, ':p:h') .. sep
if file_dir and cwd then
local file_dir = vim.fn.fnamemodify(file, ':p:h')
if file_dir and cwd_with_sep then
return file_dir:sub(1, #cwd_with_sep) == cwd_with_sep
end
end, mlist)
@ -188,7 +189,7 @@ local function mru_list(config)
for _, file in pairs(vim.list_slice(mlist, 1, config.mru.limit)) do
local filename = vim.fn.fnamemodify(file, ':t')
local icon, group = utils.get_icon(filename)
icon = icon or ''
icon = icon or ''
if config.mru.cwd_only then
file = vim.fn.fnamemodify(file, ':.')
elseif not utils.is_win then
@ -215,6 +216,7 @@ end
local function letter_hotkey(config)
-- Reserve j, k keys to move up and down.
local list = { 106, 107 }
local shuffle = config.shuffle_letter
for _, item in pairs(config.shortcut or {}) do
if item.key then
@ -233,7 +235,9 @@ local function letter_hotkey(config)
end
end
shuffle_table(unused_keys)
if shuffle then
shuffle_table(unused_keys)
end
local unused_uppercase_keys = {}
-- A - Z
@ -243,7 +247,9 @@ local function letter_hotkey(config)
end
end
shuffle_table(unused_uppercase_keys)
if shuffle then
shuffle_table(unused_uppercase_keys)
end
-- Push shuffled uppercase keys after the lowercase ones
for _, key in pairs(unused_uppercase_keys) do
@ -404,14 +410,16 @@ local function gen_center(plist, config)
for i, data in pairs(mgroups) do
local len, group = unpack(data)
api.nvim_buf_add_highlight(
config.bufnr,
0,
group,
first_line + i + plist_len,
start_col,
start_col + len
)
if group then
api.nvim_buf_add_highlight(
config.bufnr,
0,
group,
first_line + i + plist_len,
start_col,
start_col + len
)
end
api.nvim_buf_add_highlight(
config.bufnr,
0,

View File

@ -64,7 +64,6 @@ end
function utils.get_icon(filename)
local ok, devicons = pcall(require, 'nvim-web-devicons')
if not ok then
vim.notify('[dashboard.nvim] not found nvim-web-devicons')
return nil
end
return devicons.get_icon(filename, nil, { default = true })