Update generated neovim config
This commit is contained in:
@ -704,7 +704,7 @@ MiniAi.gen_spec = {}
|
||||
--- Default: `{ '%b""', "%b''", '%b()', '%b[]', '%b{}' }` (separators
|
||||
--- inside balanced quotes or brackets are ignored).
|
||||
MiniAi.gen_spec.argument = function(opts)
|
||||
opts = vim.tbl_deep_extend('force', {
|
||||
opts = vim.tbl_extend('force', {
|
||||
brackets = { '%b()', '%b[]', '%b{}' },
|
||||
separator = ',',
|
||||
exclude_regions = { '%b""', "%b''", '%b()', '%b[]', '%b{}' },
|
||||
@ -1425,7 +1425,7 @@ H.find_textobject_region = function(tobj_spec, ai_type, opts)
|
||||
end
|
||||
|
||||
-- Convert to region
|
||||
return neigh.span_to_region(final_span)
|
||||
return neigh.span_to_region(final_span, find_res.vis_mode)
|
||||
end
|
||||
|
||||
H.get_default_opts = function()
|
||||
@ -1540,11 +1540,10 @@ end
|
||||
---@param opts table Fields: <search_method>.
|
||||
---@private
|
||||
H.find_best_match = function(neighborhood, tobj_spec, reference_span, opts)
|
||||
local best_span, best_nested_pattern, current_nested_pattern
|
||||
local f = function(span)
|
||||
local best_span, best_nested_pattern, best_vis_mode, current_nested_pattern
|
||||
local f = function(span, vis_mode)
|
||||
if H.is_better_span(span, best_span, reference_span, opts) then
|
||||
best_span = span
|
||||
best_nested_pattern = current_nested_pattern
|
||||
best_span, best_nested_pattern, best_vis_mode = span, current_nested_pattern, vis_mode
|
||||
end
|
||||
end
|
||||
|
||||
@ -1552,7 +1551,7 @@ H.find_best_match = function(neighborhood, tobj_spec, reference_span, opts)
|
||||
-- Iterate over all spans representing regions in array
|
||||
for _, region in ipairs(tobj_spec) do
|
||||
-- Consider region only if it is completely within neighborhood
|
||||
if neighborhood.is_region_inside(region) then f(neighborhood.region_to_span(region)) end
|
||||
if neighborhood.is_region_inside(region) then f(neighborhood.region_to_span(region), region.vis_mode) end
|
||||
end
|
||||
else
|
||||
-- Iterate over all matched spans
|
||||
@ -1564,7 +1563,7 @@ H.find_best_match = function(neighborhood, tobj_spec, reference_span, opts)
|
||||
|
||||
local extract_pattern
|
||||
if best_nested_pattern ~= nil then extract_pattern = best_nested_pattern[#best_nested_pattern] end
|
||||
return { span = best_span, extract_pattern = extract_pattern }
|
||||
return { span = best_span, vis_mode = best_vis_mode, extract_pattern = extract_pattern }
|
||||
end
|
||||
|
||||
H.iterate_matched_spans = function(line, nested_pattern, f)
|
||||
@ -1842,12 +1841,12 @@ H.get_neighborhood = function(reference_region, n_neighbors)
|
||||
end
|
||||
|
||||
-- Convert 1d span to 2d region
|
||||
local span_to_region = function(span)
|
||||
local span_to_region = function(span, vis_mode)
|
||||
if span == nil then return nil end
|
||||
-- NOTE: this might lead to outside of line positions due to added `\n` at
|
||||
-- the end of lines in 1d-neighborhood. However, this is crucial for
|
||||
-- allowing `i` textobjects to collapse multiline selections.
|
||||
local res = { from = offset_to_pos(span.from) }
|
||||
local res = { from = offset_to_pos(span.from), vis_mode = vis_mode }
|
||||
|
||||
-- Convert empty span to empty region
|
||||
if span.from < span.to then res.to = offset_to_pos(span.to - 1) end
|
||||
|
||||
@ -1330,8 +1330,10 @@ end
|
||||
|
||||
H.is_disabled = function() return vim.g.minialign_disable == true or vim.b.minialign_disable == true end
|
||||
|
||||
H.get_config = function(config)
|
||||
return vim.tbl_deep_extend('force', MiniAlign.config, vim.b.minialign_config or {}, config or {})
|
||||
H.get_config = function()
|
||||
-- Using `tbl_deep_extend()` works even in presense of `steps.pre_*` arrays
|
||||
-- because default ones are empty.
|
||||
return vim.tbl_deep_extend('force', MiniAlign.config, vim.b.minialign_config or {})
|
||||
end
|
||||
|
||||
-- Mappings -------------------------------------------------------------------
|
||||
@ -1396,7 +1398,8 @@ end
|
||||
|
||||
H.normalize_steps = function(steps, steps_name)
|
||||
-- Infer all defaults from module config
|
||||
local res = vim.tbl_deep_extend('force', H.get_config().steps, steps or {})
|
||||
-- NOTE: Don't use `tbl_deep_extend` to prefer full input arrays (if present)
|
||||
local res = vim.tbl_extend('force', H.get_config().steps, steps or {})
|
||||
|
||||
H.validate_steps(res, steps_name)
|
||||
|
||||
|
||||
@ -1211,10 +1211,10 @@ end
|
||||
H.apply_config = function(config) MiniAnimate.config = config end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniAnimate', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniAnimate', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au('CursorMoved', '*', H.auto_cursor, 'Animate cursor')
|
||||
@ -1246,7 +1246,7 @@ H.create_autocommands = function()
|
||||
|
||||
au('WinClosed', '*', function() H.auto_openclose('close') end, 'Animate window close')
|
||||
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure proper colors')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
H.create_default_hl = function()
|
||||
@ -1783,8 +1783,7 @@ H.make_openclose_step = function(action_type, win_id, config)
|
||||
vim.api.nvim_win_set_config(float_win_id, float_config)
|
||||
end
|
||||
|
||||
local new_winblend = H.round(winblend(step, n_steps))
|
||||
vim.api.nvim_win_set_option(float_win_id, 'winblend', new_winblend)
|
||||
vim.wo[float_win_id].winblend = H.round(winblend(step, n_steps))
|
||||
|
||||
return true
|
||||
end,
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
--- - 'HiPhish/rainbow-delimiters.nvim'
|
||||
--- - 'hrsh7th/nvim-cmp'
|
||||
--- - 'justinmk/vim-sneak'
|
||||
--- - 'kevinhwang91/nvim-bqf'
|
||||
--- - 'kevinhwang91/nvim-ufo'
|
||||
--- - 'lewis6991/gitsigns.nvim'
|
||||
--- - 'lukas-reineke/indent-blankline.nvim'
|
||||
@ -468,73 +469,79 @@ H.apply_palette = function(palette, use_cterm)
|
||||
-- stylua: ignore start
|
||||
-- Builtin highlighting groups. Some groups which are missing in 'base16-vim'
|
||||
-- are added based on groups to which they are linked.
|
||||
hi('ColorColumn', {fg=nil, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('Conceal', {fg=p.base0D, bg=nil, attr=nil, sp=nil})
|
||||
hi('CurSearch', {fg=p.base01, bg=p.base09, attr=nil, sp=nil})
|
||||
hi('Cursor', {fg=p.base00, bg=p.base05, attr=nil, sp=nil})
|
||||
hi('CursorColumn', {fg=nil, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('CursorIM', {fg=p.base00, bg=p.base05, attr=nil, sp=nil})
|
||||
hi('CursorLine', {fg=nil, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('CursorLineFold', {fg=p.base0C, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('CursorLineNr', {fg=p.base04, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('CursorLineSign', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('DiffAdd', {fg=p.base0B, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('ColorColumn', {fg=nil, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('Conceal', {fg=p.base0D, bg=nil, attr=nil, sp=nil})
|
||||
hi('CurSearch', {fg=p.base01, bg=p.base09, attr=nil, sp=nil})
|
||||
hi('Cursor', {fg=p.base00, bg=p.base05, attr=nil, sp=nil})
|
||||
hi('CursorColumn', {fg=nil, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('CursorIM', {fg=p.base00, bg=p.base05, attr=nil, sp=nil})
|
||||
hi('CursorLine', {fg=nil, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('CursorLineFold', {fg=p.base0C, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('CursorLineNr', {fg=p.base04, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('CursorLineSign', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('DiffAdd', {fg=p.base0B, bg=p.base01, attr=nil, sp=nil})
|
||||
-- Differs from base16-vim, but according to general style guide
|
||||
hi('DiffChange', {fg=p.base0E, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('DiffDelete', {fg=p.base08, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('DiffText', {fg=p.base0D, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('Directory', {fg=p.base0D, bg=nil, attr=nil, sp=nil})
|
||||
hi('EndOfBuffer', {fg=p.base03, bg=nil, attr=nil, sp=nil})
|
||||
hi('ErrorMsg', {fg=p.base08, bg=p.base00, attr=nil, sp=nil})
|
||||
hi('FoldColumn', {fg=p.base0C, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('Folded', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('IncSearch', {fg=p.base01, bg=p.base09, attr=nil, sp=nil})
|
||||
hi('lCursor', {fg=p.base00, bg=p.base05, attr=nil, sp=nil})
|
||||
hi('LineNr', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('LineNrAbove', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('LineNrBelow', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('DiffChange', {fg=p.base0E, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('DiffDelete', {fg=p.base08, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('DiffText', {fg=p.base0D, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('Directory', {fg=p.base0D, bg=nil, attr=nil, sp=nil})
|
||||
hi('EndOfBuffer', {fg=p.base03, bg=nil, attr=nil, sp=nil})
|
||||
hi('ErrorMsg', {fg=p.base08, bg=p.base00, attr=nil, sp=nil})
|
||||
hi('FoldColumn', {fg=p.base0C, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('Folded', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('IncSearch', {fg=p.base01, bg=p.base09, attr=nil, sp=nil})
|
||||
hi('lCursor', {fg=p.base00, bg=p.base05, attr=nil, sp=nil})
|
||||
hi('LineNr', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('LineNrAbove', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('LineNrBelow', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
-- Slight difference from base16, where `bg=base03` is used. This makes
|
||||
-- it possible to comfortably see this highlighting in comments.
|
||||
hi('MatchParen', {fg=nil, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('ModeMsg', {fg=p.base0B, bg=nil, attr=nil, sp=nil})
|
||||
hi('MoreMsg', {fg=p.base0B, bg=nil, attr=nil, sp=nil})
|
||||
hi('MsgArea', {fg=p.base05, bg=p.base00, attr=nil, sp=nil})
|
||||
hi('MsgSeparator', {fg=p.base04, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('NonText', {fg=p.base03, bg=nil, attr=nil, sp=nil})
|
||||
hi('Normal', {fg=p.base05, bg=p.base00, attr=nil, sp=nil})
|
||||
hi('NormalFloat', {fg=p.base05, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('NormalNC', {fg=p.base05, bg=p.base00, attr=nil, sp=nil})
|
||||
hi('PMenu', {fg=p.base05, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('PMenuSbar', {fg=nil, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('PMenuSel', {fg=p.base01, bg=p.base05, attr=nil, sp=nil})
|
||||
hi('PMenuThumb', {fg=nil, bg=p.base07, attr=nil, sp=nil})
|
||||
hi('Question', {fg=p.base0D, bg=nil, attr=nil, sp=nil})
|
||||
hi('QuickFixLine', {fg=nil, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('Search', {fg=p.base01, bg=p.base0A, attr=nil, sp=nil})
|
||||
hi('SignColumn', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('SpecialKey', {fg=p.base03, bg=nil, attr=nil, sp=nil})
|
||||
hi('SpellBad', {fg=nil, bg=nil, attr='undercurl', sp=p.base08})
|
||||
hi('SpellCap', {fg=nil, bg=nil, attr='undercurl', sp=p.base0D})
|
||||
hi('SpellLocal', {fg=nil, bg=nil, attr='undercurl', sp=p.base0C})
|
||||
hi('SpellRare', {fg=nil, bg=nil, attr='undercurl', sp=p.base0E})
|
||||
hi('StatusLine', {fg=p.base04, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('StatusLineNC', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('Substitute', {fg=p.base01, bg=p.base0A, attr=nil, sp=nil})
|
||||
hi('TabLine', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('TabLineFill', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('TabLineSel', {fg=p.base0B, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('TermCursor', {fg=nil, bg=nil, attr='reverse', sp=nil})
|
||||
hi('TermCursorNC', {fg=nil, bg=nil, attr='reverse', sp=nil})
|
||||
hi('Title', {fg=p.base0D, bg=nil, attr=nil, sp=nil})
|
||||
hi('VertSplit', {fg=p.base02, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('Visual', {fg=nil, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('VisualNOS', {fg=p.base08, bg=nil, attr=nil, sp=nil})
|
||||
hi('WarningMsg', {fg=p.base08, bg=nil, attr=nil, sp=nil})
|
||||
hi('Whitespace', {fg=p.base03, bg=nil, attr=nil, sp=nil})
|
||||
hi('WildMenu', {fg=p.base08, bg=p.base0A, attr=nil, sp=nil})
|
||||
hi('WinBar', {fg=p.base04, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('WinBarNC', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('WinSeparator', {fg=p.base02, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('MatchParen', {fg=nil, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('ModeMsg', {fg=p.base0B, bg=nil, attr=nil, sp=nil})
|
||||
hi('MoreMsg', {fg=p.base0B, bg=nil, attr=nil, sp=nil})
|
||||
hi('MsgArea', {fg=p.base05, bg=p.base00, attr=nil, sp=nil})
|
||||
hi('MsgSeparator', {fg=p.base04, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('NonText', {fg=p.base03, bg=nil, attr=nil, sp=nil})
|
||||
hi('Normal', {fg=p.base05, bg=p.base00, attr=nil, sp=nil})
|
||||
hi('NormalFloat', {fg=p.base05, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('NormalNC', {fg=p.base05, bg=p.base00, attr=nil, sp=nil})
|
||||
hi('Pmenu', {fg=p.base05, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('PmenuExtra', {fg=p.base05, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('PmenuExtraSel', {fg=p.base05, bg=p.base01, attr='reverse', sp=nil})
|
||||
hi('PmenuKind', {fg=p.base05, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('PmenuKindSel', {fg=p.base05, bg=p.base01, attr='reverse', sp=nil})
|
||||
hi('PmenuMatch', {fg=p.base05, bg=p.base01, attr='bold', sp=nil})
|
||||
hi('PmenuMatchSel', {fg=p.base05, bg=p.base01, attr='bold,reverse', sp=nil})
|
||||
hi('PmenuSbar', {fg=nil, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('PmenuSel', {fg=p.base05, bg=p.base01, attr='reverse', sp=nil})
|
||||
hi('PmenuThumb', {fg=nil, bg=p.base07, attr=nil, sp=nil})
|
||||
hi('Question', {fg=p.base0D, bg=nil, attr=nil, sp=nil})
|
||||
hi('QuickFixLine', {fg=nil, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('Search', {fg=p.base01, bg=p.base0A, attr=nil, sp=nil})
|
||||
hi('SignColumn', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('SpecialKey', {fg=p.base03, bg=nil, attr=nil, sp=nil})
|
||||
hi('SpellBad', {fg=nil, bg=nil, attr='undercurl', sp=p.base08})
|
||||
hi('SpellCap', {fg=nil, bg=nil, attr='undercurl', sp=p.base0D})
|
||||
hi('SpellLocal', {fg=nil, bg=nil, attr='undercurl', sp=p.base0C})
|
||||
hi('SpellRare', {fg=nil, bg=nil, attr='undercurl', sp=p.base0E})
|
||||
hi('StatusLine', {fg=p.base04, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('StatusLineNC', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('Substitute', {fg=p.base01, bg=p.base0A, attr=nil, sp=nil})
|
||||
hi('TabLine', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('TabLineFill', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('TabLineSel', {fg=p.base0B, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('TermCursor', {fg=nil, bg=nil, attr='reverse', sp=nil})
|
||||
hi('TermCursorNC', {fg=nil, bg=nil, attr='reverse', sp=nil})
|
||||
hi('Title', {fg=p.base0D, bg=nil, attr=nil, sp=nil})
|
||||
hi('VertSplit', {fg=p.base02, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('Visual', {fg=nil, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('VisualNOS', {fg=p.base08, bg=nil, attr=nil, sp=nil})
|
||||
hi('WarningMsg', {fg=p.base08, bg=nil, attr=nil, sp=nil})
|
||||
hi('Whitespace', {fg=p.base03, bg=nil, attr=nil, sp=nil})
|
||||
hi('WildMenu', {fg=p.base08, bg=p.base0A, attr=nil, sp=nil})
|
||||
hi('WinBar', {fg=p.base04, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('WinBarNC', {fg=p.base03, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('WinSeparator', {fg=p.base02, bg=p.base02, attr=nil, sp=nil})
|
||||
|
||||
-- Standard syntax (affects treesitter)
|
||||
hi('Boolean', {fg=p.base09, bg=nil, attr=nil, sp=nil})
|
||||
@ -649,9 +656,10 @@ H.apply_palette = function(palette, use_cterm)
|
||||
hi('@symbol', {fg=p.base0E, bg=nil, attr=nil, sp=nil})
|
||||
hi('@variable', {fg=p.base05, bg=nil, attr=nil, sp=nil})
|
||||
|
||||
hi('@text.strong', {fg=nil, bg=nil, attr='bold', sp=nil})
|
||||
hi('@text.emphasis', {fg=nil, bg=nil, attr='italic', sp=nil})
|
||||
hi('@text.strike', {fg=nil, bg=nil, attr='strikethrough', sp=nil})
|
||||
hi('@text.strong', {fg=nil, bg=nil, attr='bold', sp=nil})
|
||||
hi('@text.emphasis', {fg=nil, bg=nil, attr='italic', sp=nil})
|
||||
hi('@text.strike', {fg=nil, bg=nil, attr='strikethrough', sp=nil})
|
||||
hi('@text.underline', {link='Underlined'})
|
||||
|
||||
-- Semantic tokens
|
||||
if vim.fn.has('nvim-0.9') == 1 then
|
||||
@ -669,8 +677,11 @@ H.apply_palette = function(palette, use_cterm)
|
||||
-- Included only those differing from default links
|
||||
hi('@markup.strong', {link='@text.strong'})
|
||||
hi('@markup.italic', {link='@text.emphasis'})
|
||||
hi('@markup.strikethrough', {link='@text.strikethrough'})
|
||||
hi('@markup.strikethrough', {link='@text.strike'})
|
||||
hi('@markup.underline', {link='@text.underline'})
|
||||
|
||||
hi('@string.special.vimdoc', {link='SpecialChar'})
|
||||
hi('@variable.parameter.vimdoc', {fg=p.base09, bg=nil, attr=nil, sp=nil})
|
||||
end
|
||||
|
||||
-- Plugins
|
||||
@ -757,18 +768,19 @@ H.apply_palette = function(palette, use_cterm)
|
||||
hi('MiniOperatorsExchangeFrom', {link='IncSearch'})
|
||||
|
||||
hi('MiniPickBorder', {link='NormalFloat'})
|
||||
hi('MiniPickBorderBusy', {fg=p.base0E, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('MiniPickBorderText', {fg=p.base0D, bg=p.base01, attr='bold', sp=nil})
|
||||
hi('MiniPickBorderBusy', {fg=p.base0E, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('MiniPickBorderText', {fg=p.base0D, bg=p.base01, attr='bold', sp=nil})
|
||||
hi('MiniPickCursor', {fg=nil, bg=nil, attr='nocombine', sp=nil, blend=100})
|
||||
hi('MiniPickIconDirectory', {link='Directory'})
|
||||
hi('MiniPickIconFile', {fg=p.base05, bg=nil, attr=nil, sp=nil})
|
||||
hi('MiniPickIconFile', {fg=p.base05, bg=nil, attr=nil, sp=nil})
|
||||
hi('MiniPickHeader', {link='DiagnosticFloatingHint'})
|
||||
hi('MiniPickMatchCurrent', {fg=nil, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('MiniPickMatchMarked', {fg=nil, bg=p.base03, attr=nil, sp=nil})
|
||||
hi('MiniPickMatchCurrent', {fg=nil, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('MiniPickMatchMarked', {fg=nil, bg=p.base03, attr=nil, sp=nil})
|
||||
hi('MiniPickMatchRanges', {link='DiagnosticFloatingHint'})
|
||||
hi('MiniPickNormal', {link='NormalFloat'})
|
||||
hi('MiniPickPreviewLine', {fg=nil, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('MiniPickPreviewLine', {fg=nil, bg=p.base02, attr=nil, sp=nil})
|
||||
hi('MiniPickPreviewRegion', {link='IncSearch'})
|
||||
hi('MiniPickPrompt', {fg=p.base0B, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('MiniPickPrompt', {fg=p.base0B, bg=p.base01, attr=nil, sp=nil})
|
||||
|
||||
hi('MiniStarterCurrent', {fg=nil, bg=nil, attr=nil, sp=nil})
|
||||
hi('MiniStarterFooter', {fg=p.base0D, bg=nil, attr=nil, sp=nil})
|
||||
@ -995,6 +1007,13 @@ H.apply_palette = function(palette, use_cterm)
|
||||
hi('SneakLabel', {fg=p.base00, bg=p.base0E, attr='bold', sp=nil})
|
||||
end
|
||||
|
||||
-- 'kevinhwang91/nvim-bqf'
|
||||
if H.has_integration('kevinhwang91/nvim-bqf') then
|
||||
hi('BqfPreviewFloat', {link='NormalFloat'})
|
||||
hi('BqfPreviewTitle', {fg=p.base0D, bg=p.base01, attr=nil, sp=nil})
|
||||
hi('BqfSign', {fg=p.base0C, bg=p.base01, attr=nil, sp=nil})
|
||||
end
|
||||
|
||||
-- 'kevinhwang91/nvim-ufo'
|
||||
-- Everything works correctly out of the box
|
||||
|
||||
@ -1238,12 +1257,13 @@ H.highlight_gui = function(group, args)
|
||||
command = string.format('highlight! link %s %s', group, args.link)
|
||||
else
|
||||
command = string.format(
|
||||
'highlight %s guifg=%s guibg=%s gui=%s guisp=%s',
|
||||
'highlight %s guifg=%s guibg=%s gui=%s guisp=%s blend=%s',
|
||||
group,
|
||||
args.fg or 'NONE',
|
||||
args.bg or 'NONE',
|
||||
args.attr or 'NONE',
|
||||
args.sp or 'NONE'
|
||||
args.sp or 'NONE',
|
||||
args.blend or 'NONE'
|
||||
)
|
||||
end
|
||||
vim.cmd(command)
|
||||
@ -1255,7 +1275,7 @@ H.highlight_both = function(group, args)
|
||||
command = string.format('highlight! link %s %s', group, args.link)
|
||||
else
|
||||
command = string.format(
|
||||
'highlight %s guifg=%s ctermfg=%s guibg=%s ctermbg=%s gui=%s cterm=%s guisp=%s',
|
||||
'highlight %s guifg=%s ctermfg=%s guibg=%s ctermbg=%s gui=%s cterm=%s guisp=%s blend=%s',
|
||||
group,
|
||||
args.fg and args.fg.gui or 'NONE',
|
||||
args.fg and args.fg.cterm or 'NONE',
|
||||
@ -1263,7 +1283,8 @@ H.highlight_both = function(group, args)
|
||||
args.bg and args.bg.cterm or 'NONE',
|
||||
args.attr or 'NONE',
|
||||
args.attr or 'NONE',
|
||||
args.sp and args.sp.gui or 'NONE'
|
||||
args.sp and args.sp.gui or 'NONE',
|
||||
args.blend or 'NONE'
|
||||
)
|
||||
end
|
||||
vim.cmd(command)
|
||||
|
||||
@ -708,10 +708,10 @@ end
|
||||
|
||||
-- Autocommands ---------------------------------------------------------------
|
||||
H.apply_autocommands = function(config)
|
||||
local augroup = vim.api.nvim_create_augroup('MiniBasicsAutocommands', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniBasicsAutocommands', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
if config.autocommands.basic then
|
||||
|
||||
@ -342,7 +342,7 @@ MiniBracketed.comment = function(direction, opts)
|
||||
if opts.add_to_jumplist then H.add_to_jumplist() end
|
||||
|
||||
-- Apply. Open just enough folds and put cursor on first non-blank.
|
||||
vim.api.nvim_win_set_cursor(0, { res_line_num, 0 })
|
||||
H.set_cursor(res_line_num, 0)
|
||||
vim.cmd('normal! zv^')
|
||||
end
|
||||
|
||||
@ -404,7 +404,7 @@ MiniBracketed.conflict = function(direction, opts)
|
||||
if opts.add_to_jumplist then H.add_to_jumplist() end
|
||||
|
||||
-- Apply. Open just enough folds and put cursor on first non-blank.
|
||||
vim.api.nvim_win_set_cursor(0, { res_line_num, 0 })
|
||||
H.set_cursor(res_line_num, 0)
|
||||
vim.cmd('normal! zv^')
|
||||
end
|
||||
|
||||
@ -643,7 +643,7 @@ MiniBracketed.indent = function(direction, opts)
|
||||
if opts.add_to_jumplist then H.add_to_jumplist() end
|
||||
|
||||
-- Apply. Open just enough folds and put cursor on first non-blank.
|
||||
vim.api.nvim_win_set_cursor(0, { res_line_num, 0 })
|
||||
H.set_cursor(res_line_num, 0)
|
||||
vim.cmd('normal! zv^')
|
||||
end
|
||||
|
||||
@ -919,8 +919,7 @@ MiniBracketed.treesitter = function(direction, opts)
|
||||
if opts.add_to_jumplist then H.add_to_jumplist() end
|
||||
|
||||
-- Apply
|
||||
local row, col = res_node_pos.pos[1], res_node_pos.pos[2]
|
||||
vim.api.nvim_win_set_cursor(0, { row + 1, col })
|
||||
H.set_cursor(res_node_pos.pos[1] + 1, res_node_pos.pos[2])
|
||||
end
|
||||
|
||||
--- Undo along a tracked linear history
|
||||
@ -1136,12 +1135,9 @@ MiniBracketed.yank = function(direction, opts)
|
||||
if H.is_disabled() then return end
|
||||
|
||||
H.validate_direction(direction, { 'first', 'backward', 'forward', 'last' }, 'yank')
|
||||
opts = vim.tbl_deep_extend(
|
||||
'force',
|
||||
{ n_times = vim.v.count1, operators = { 'c', 'd', 'y' }, wrap = true },
|
||||
H.get_config().yank.options,
|
||||
opts or {}
|
||||
)
|
||||
-- NOTE: Don't use `tbl_deep_extend` to prefer full input `operators` array
|
||||
local default_opts = { n_times = vim.v.count1, operators = { 'c', 'd', 'y' }, wrap = true }
|
||||
opts = vim.tbl_extend('force', default_opts, H.get_config().yank.options, opts or {})
|
||||
|
||||
-- Update yank history data
|
||||
local cache_yank, history = H.cache.yank, H.cache.yank.history
|
||||
@ -1600,10 +1596,10 @@ end
|
||||
H.get_suffix_variants = function(char) return char:lower(), char:upper() end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniBracketed', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniBracketed', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au('BufEnter', '*', H.track_oldfile, 'Track oldfile')
|
||||
@ -1975,7 +1971,7 @@ end
|
||||
|
||||
H.region_delete = function(region, normal_fun)
|
||||
-- Start with `to` to have cursor positioned on region start after deletion
|
||||
vim.api.nvim_win_set_cursor(0, { region.to.line, region.to.col - 1 })
|
||||
H.set_cursor(region.to.line, region.to.col - 1)
|
||||
|
||||
-- Do nothing more if region is empty (or leads to unnecessary line deletion)
|
||||
local is_empty = region.from.line == region.to.line
|
||||
@ -1986,7 +1982,7 @@ H.region_delete = function(region, normal_fun)
|
||||
|
||||
-- Select region in correct Visual mode
|
||||
normal_fun(region.mode)
|
||||
vim.api.nvim_win_set_cursor(0, { region.from.line, region.from.col - 1 })
|
||||
H.set_cursor(region.from.line, region.from.col - 1)
|
||||
|
||||
-- Delete region in "black hole" register
|
||||
-- - NOTE: it doesn't affect history as `"_` doesn't trigger `TextYankPost`
|
||||
@ -2017,4 +2013,12 @@ end
|
||||
|
||||
H.add_to_jumplist = function() vim.cmd([[normal! m']]) end
|
||||
|
||||
H.set_cursor = function(row, col)
|
||||
if row <= 0 then return vim.api.nvim_win_set_cursor(0, { 1, 0 }) end
|
||||
local n_lines = vim.api.nvim_buf_line_count(0)
|
||||
if n_lines < row then return vim.api.nvim_win_set_cursor(0, { n_lines, vim.fn.getline(n_lines):len() - 1 }) end
|
||||
col = math.min(math.max(col, 0), vim.fn.getline(row):len())
|
||||
return vim.api.nvim_win_set_cursor(0, { row, col })
|
||||
end
|
||||
|
||||
return MiniBracketed
|
||||
|
||||
@ -492,7 +492,7 @@ MiniClue.setup = function(config)
|
||||
H.apply_config(config)
|
||||
|
||||
-- Define behavior
|
||||
H.create_autocommands(config)
|
||||
H.create_autocommands()
|
||||
|
||||
-- Create default highlighting
|
||||
H.create_default_hl()
|
||||
@ -1171,11 +1171,11 @@ H.is_disabled = function(buf_id)
|
||||
return vim.g.miniclue_disable == true or buf_disable == true
|
||||
end
|
||||
|
||||
H.create_autocommands = function(config)
|
||||
local augroup = vim.api.nvim_create_augroup('MiniClue', {})
|
||||
H.create_autocommands = function()
|
||||
local gr = vim.api.nvim_create_augroup('MiniClue', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
-- Ensure buffer-local mappings for triggers are the latest ones to fully
|
||||
@ -1195,6 +1195,7 @@ H.create_autocommands = function(config)
|
||||
au('RecordingLeave', '*', MiniClue.enable_all_triggers, 'Enable all triggers')
|
||||
|
||||
au('VimResized', '*', H.window_update, 'Update window on resize')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
@ -1557,6 +1558,7 @@ H.window_open = function(config)
|
||||
local win_id = vim.api.nvim_open_win(H.state.buf_id, false, config)
|
||||
|
||||
vim.wo[win_id].foldenable = false
|
||||
vim.wo[win_id].foldmethod = 'manual'
|
||||
vim.wo[win_id].wrap = false
|
||||
vim.wo[win_id].list = true
|
||||
vim.wo[win_id].listchars = 'extends:…'
|
||||
|
||||
@ -45,12 +45,25 @@
|
||||
--- `<C-Space>`) or fallback completion via
|
||||
--- |MiniCompletion.complete_fallback()| (mapped to `<M-Space>`).
|
||||
---
|
||||
--- - LSP kind highlighting ("Function", "Keyword", etc.). Requires Neovim>=0.11.
|
||||
--- By default uses "lsp" category of |MiniIcons| (if enabled). Can be customized
|
||||
--- via `config.lsp_completion.process_items` by adding field <kind_hlgroup>
|
||||
--- (same meaning as in |complete-items|) to items.
|
||||
---
|
||||
--- What it doesn't do:
|
||||
--- - Snippet expansion.
|
||||
--- - Many configurable sources.
|
||||
--- - Automatic mapping of `<CR>`, `<Tab>`, etc., as those tend to have highly
|
||||
--- variable user expectations. See 'Helpful key mappings' for suggestions.
|
||||
---
|
||||
--- # Dependencies ~
|
||||
---
|
||||
--- Suggested dependencies (provide extra functionality, will work without them):
|
||||
---
|
||||
--- - Enabled |MiniIcons| module to highlight LSP kind (requires Neovim>=0.11).
|
||||
--- Otherwise |MiniCompletion.default_process_items()| does not add highlighting.
|
||||
--- Also take a look at |MiniIcons.tweak_lsp_kind()|.
|
||||
---
|
||||
--- # Setup ~
|
||||
---
|
||||
--- This module needs a setup with `require('mini.completion').setup({})`
|
||||
@ -252,12 +265,10 @@ MiniCompletion.config = {
|
||||
-- on every `BufEnter` event.
|
||||
auto_setup = true,
|
||||
|
||||
-- `process_items` should be a function which takes LSP
|
||||
-- 'textDocument/completion' response items and word to complete. Its
|
||||
-- output should be a table of the same nature as input items. The most
|
||||
-- common use-cases are custom filtering and sorting. You can use
|
||||
-- default `process_items` as `MiniCompletion.default_process_items()`.
|
||||
--minidoc_replace_start process_items = --<function: filters out snippets; sorts by LSP specs>,
|
||||
-- A function which takes LSP 'textDocument/completion' response items
|
||||
-- and word to complete. Output should be a table of the same nature as
|
||||
-- input items. Common use case is custom filter/sort.
|
||||
--minidoc_replace_start process_items = --<function: MiniCompletion.default_process_items>,
|
||||
process_items = function(items, base)
|
||||
local res = vim.tbl_filter(function(item)
|
||||
-- Keep items which match the base and are not snippets
|
||||
@ -265,8 +276,17 @@ MiniCompletion.config = {
|
||||
return vim.startswith(text, base) and item.kind ~= 15
|
||||
end, items)
|
||||
|
||||
res = vim.deepcopy(res)
|
||||
table.sort(res, function(a, b) return (a.sortText or a.label) < (b.sortText or b.label) end)
|
||||
|
||||
-- Possibly add "kind" highlighting
|
||||
if _G.MiniIcons ~= nil then
|
||||
local add_kind_hlgroup = H.make_add_kind_hlgroup()
|
||||
for _, item in ipairs(res) do
|
||||
add_kind_hlgroup(item)
|
||||
end
|
||||
end
|
||||
|
||||
return res
|
||||
end,
|
||||
--minidoc_replace_end
|
||||
@ -410,6 +430,11 @@ MiniCompletion.completefunc_lsp = function(findstart, base)
|
||||
end
|
||||
|
||||
--- Default `MiniCompletion.config.lsp_completion.process_items`
|
||||
---
|
||||
--- Steps:
|
||||
--- - Filter out items not matching `base` and snippet items.
|
||||
--- - Sort by LSP specification.
|
||||
--- - If |MiniIcons| is enabled, add <kind_hlgroup> based on the "lsp" category.
|
||||
MiniCompletion.default_process_items = function(items, base)
|
||||
return H.default_config.lsp_completion.process_items(items, base)
|
||||
end
|
||||
@ -550,10 +575,10 @@ H.apply_config = function(config)
|
||||
end
|
||||
|
||||
H.create_autocommands = function(config)
|
||||
local augroup = vim.api.nvim_create_augroup('MiniCompletion', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniCompletion', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au('InsertCharPre', '*', H.auto_completion, 'Auto show completion')
|
||||
@ -570,7 +595,7 @@ H.create_autocommands = function(config)
|
||||
au('BufEnter', '*', callback, 'Set completion function')
|
||||
end
|
||||
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure proper colors')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
au('FileType', 'TelescopePrompt', function() vim.b.minicompletion_disable = true end, 'Disable locally')
|
||||
end
|
||||
|
||||
@ -850,19 +875,19 @@ H.is_lsp_current = function(cache, id) return cache.lsp.id == id and cache.lsp.s
|
||||
H.lsp_completion_response_items_to_complete_items = function(items, client_id)
|
||||
if vim.tbl_count(items) == 0 then return {} end
|
||||
|
||||
local res = {}
|
||||
local docs, info
|
||||
local res, item_kinds = {}, vim.lsp.protocol.CompletionItemKind
|
||||
for _, item in pairs(items) do
|
||||
-- Documentation info
|
||||
docs = item.documentation
|
||||
info = H.table_get(docs, { 'value' })
|
||||
local docs = item.documentation
|
||||
local info = H.table_get(docs, { 'value' })
|
||||
if not info and type(docs) == 'string' then info = docs end
|
||||
info = info or ''
|
||||
|
||||
table.insert(res, {
|
||||
word = H.get_completion_word(item),
|
||||
abbr = item.label,
|
||||
kind = vim.lsp.protocol.CompletionItemKind[item.kind] or 'Unknown',
|
||||
kind = item_kinds[item.kind] or 'Unknown',
|
||||
kind_hlgroup = item.kind_hlgroup,
|
||||
menu = item.detail or '',
|
||||
info = info,
|
||||
icase = 1,
|
||||
@ -874,6 +899,25 @@ H.lsp_completion_response_items_to_complete_items = function(items, client_id)
|
||||
return res
|
||||
end
|
||||
|
||||
H.make_add_kind_hlgroup = function()
|
||||
-- Account for possible effect of `MiniIcons.tweak_lsp_kind()` which modifies
|
||||
-- only array part of `CompletionItemKind` but not "map" part
|
||||
if H.kind_map == nil then
|
||||
-- Cache kind map so as to not recompute it each time (as it will be called
|
||||
-- in performance sensitive context). Assumes `tweak_lsp_kind()` is called
|
||||
-- right after `require('mini.icons').setup()`.
|
||||
H.kind_map = {}
|
||||
for k, v in pairs(vim.lsp.protocol.CompletionItemKind) do
|
||||
if type(k) == 'string' and type(v) == 'number' then H.kind_map[v] = k end
|
||||
end
|
||||
end
|
||||
|
||||
return function(item)
|
||||
local _, hl, is_default = _G.MiniIcons.get('lsp', H.kind_map[item.kind] or 'Unknown')
|
||||
item.kind_hlgroup = not is_default and hl or nil
|
||||
end
|
||||
end
|
||||
|
||||
H.get_completion_word = function(item)
|
||||
-- Completion word (textEdit.newText > insertText > label). This doesn't
|
||||
-- support snippet expansion.
|
||||
@ -1280,10 +1324,13 @@ H.floating_dimensions = function(lines, max_height, max_width)
|
||||
end
|
||||
|
||||
H.open_action_window = function(cache, opts)
|
||||
cache.win_id = vim.api.nvim_open_win(cache.bufnr, false, opts)
|
||||
vim.api.nvim_win_set_option(cache.win_id, 'wrap', true)
|
||||
vim.api.nvim_win_set_option(cache.win_id, 'linebreak', true)
|
||||
vim.api.nvim_win_set_option(cache.win_id, 'breakindent', false)
|
||||
local win_id = vim.api.nvim_open_win(cache.bufnr, false, opts)
|
||||
vim.wo[win_id].breakindent = false
|
||||
vim.wo[win_id].foldenable = false
|
||||
vim.wo[win_id].foldmethod = 'manual'
|
||||
vim.wo[win_id].linebreak = true
|
||||
vim.wo[win_id].wrap = true
|
||||
cache.win_id = win_id
|
||||
end
|
||||
|
||||
H.close_action_window = function(cache, keep_timer)
|
||||
|
||||
@ -157,17 +157,17 @@ H.apply_config = function(config)
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniCursorword', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniCursorword', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au('CursorMoved', '*', H.auto_highlight, 'Auto highlight cursorword')
|
||||
au({ 'InsertEnter', 'TermEnter', 'QuitPre' }, '*', H.auto_unhighlight, 'Auto unhighlight cursorword')
|
||||
au('ModeChanged', '*:[^i]', H.auto_highlight, 'Auto highlight cursorword')
|
||||
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure proper colors')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
au('FileType', 'TelescopePrompt', function() vim.b.minicursorword_disable = true end, 'Disable locally')
|
||||
end
|
||||
|
||||
|
||||
@ -366,6 +366,9 @@ MiniDeps.setup = function(config)
|
||||
-- Apply config
|
||||
H.apply_config(config)
|
||||
|
||||
-- Define behavior
|
||||
H.create_autocommands()
|
||||
|
||||
-- Create default highlighting
|
||||
H.create_default_hl()
|
||||
|
||||
@ -710,9 +713,11 @@ MiniDeps.get_session = function()
|
||||
-- Add 'start/' plugins that are in 'rtp'. NOTE: not whole session concept is
|
||||
-- built around presence in 'rtp' to 100% ensure to preserve the order in
|
||||
-- which user called `add()`.
|
||||
local start_path = H.get_package_path() .. '/pack/deps/start'
|
||||
local start_path = H.full_path(H.get_package_path() .. '/pack/deps/start')
|
||||
local pattern = string.format('^%s/([^/]+)$', vim.pesc(start_path))
|
||||
for _, path in ipairs(vim.api.nvim_list_runtime_paths()) do
|
||||
for _, runtime_path in ipairs(vim.api.nvim_list_runtime_paths()) do
|
||||
-- Make sure plugin path is normalized (matters on Windows)
|
||||
local path = H.full_path(runtime_path)
|
||||
local name = string.match(path, pattern)
|
||||
if name ~= nil then add_spec({ path = path, name = name, hooks = {}, depends = {} }) end
|
||||
end
|
||||
@ -818,6 +823,11 @@ H.get_config = function(config)
|
||||
return vim.tbl_deep_extend('force', MiniDeps.config, vim.b.minideps_config or {}, config or {})
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local gr = vim.api.nvim_create_augroup('MiniDeps', {})
|
||||
vim.api.nvim_create_autocmd('ColorScheme', { group = gr, callback = H.create_default_hl, desc = 'Ensure colors' })
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
H.create_default_hl = function()
|
||||
local hi = function(name, opts)
|
||||
|
||||
@ -981,16 +981,17 @@ H.apply_config = function(config)
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniDiff', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniDiff', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
-- NOTE: Try auto enabling buffer on every `BufEnter` to not have `:edit`
|
||||
-- disabling buffer, as it calls `on_detach()` from buffer watcher
|
||||
au('BufEnter', '*', H.auto_enable, 'Enable diff')
|
||||
au('VimResized', '*', H.on_resize, 'Track Neovim resizing')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
|
||||
@ -808,11 +808,11 @@ end
|
||||
|
||||
-- Default documentation targets ----------------------------------------------
|
||||
H.default_input = function()
|
||||
-- Search in current and recursively in other directories for files with
|
||||
-- 'lua' extension
|
||||
-- Search in current and recursively in other directories for Lua files
|
||||
local res = {}
|
||||
for _, dir_glob in ipairs({ '.', 'lua/**', 'after/**', 'colors/**' }) do
|
||||
local files = vim.fn.globpath(dir_glob, '*.lua', false, true)
|
||||
for _, dir in ipairs({ '.', 'lua', 'after', 'colors' }) do
|
||||
local glob = (dir == '.' and '' or '**/') .. '*.lua'
|
||||
local files = vim.fn.globpath(dir, glob, false, true)
|
||||
|
||||
-- Use full paths
|
||||
files = vim.tbl_map(function(x) return vim.fn.fnamemodify(x, ':p') end, files)
|
||||
|
||||
@ -64,6 +64,8 @@
|
||||
--- - Requires target path to be part of git repository.
|
||||
--- - Present for exploration and navigation purposes. Doing any Git operations
|
||||
--- is suggested to be done in a dedicated Git client and is not planned.
|
||||
---@alias __extra_pickers_preserve_order - <preserve_order> `(boolean)` - whether to preserve original order
|
||||
--- during query. Default: `false`.
|
||||
---@alias __extra_pickers_git_path - <path> `(string|nil)` - target path for Git operation (if required). Also
|
||||
--- used to find Git repository inside which to construct items.
|
||||
--- Default: `nil` for root of Git repository containing |current-directory|.
|
||||
@ -324,12 +326,13 @@ MiniExtra.pickers = {}
|
||||
--- Possible fields:
|
||||
--- - <scope> `(string)` - one of "all" (normal listed buffers) or "current".
|
||||
--- Default: "all".
|
||||
--- __extra_pickers_preserve_order
|
||||
---@param opts __extra_pickers_opts
|
||||
---
|
||||
---@return __extra_pickers_return
|
||||
MiniExtra.pickers.buf_lines = function(local_opts, opts)
|
||||
local pick = H.validate_pick('buf_lines')
|
||||
local_opts = vim.tbl_deep_extend('force', { scope = 'all' }, local_opts or {})
|
||||
local_opts = vim.tbl_deep_extend('force', { scope = 'all', preserve_order = false }, local_opts or {})
|
||||
|
||||
local scope = H.pick_validate_scope(local_opts, { 'all', 'current' }, 'buf_lines')
|
||||
local is_scope_all = scope == 'all'
|
||||
@ -352,9 +355,11 @@ MiniExtra.pickers.buf_lines = function(local_opts, opts)
|
||||
if not poke_picker() then return end
|
||||
H.buf_ensure_loaded(buf_id)
|
||||
local buf_name = H.buf_get_name(buf_id) or ''
|
||||
local n_digits = math.floor(math.log10(vim.api.nvim_buf_line_count(buf_id))) + 1
|
||||
local format_pattern = '%s%' .. n_digits .. 'd\0%s'
|
||||
for lnum, l in ipairs(vim.api.nvim_buf_get_lines(buf_id, 0, -1, false)) do
|
||||
local prefix = is_scope_all and string.format('%s\0', buf_name) or ''
|
||||
table.insert(items, { text = string.format('%s%s\0%s', prefix, lnum, l), bufnr = buf_id, lnum = lnum })
|
||||
local prefix = is_scope_all and (buf_name .. '\0') or ''
|
||||
table.insert(items, { text = format_pattern:format(prefix, lnum, l), bufnr = buf_id, lnum = lnum })
|
||||
end
|
||||
end
|
||||
pick.set_picker_items(items)
|
||||
@ -363,7 +368,10 @@ MiniExtra.pickers.buf_lines = function(local_opts, opts)
|
||||
|
||||
local show = H.pick_get_config().source.show
|
||||
if is_scope_all and show == nil then show = H.show_with_icons end
|
||||
return H.pick_start(items, { source = { name = string.format('Buffer lines (%s)', scope), show = show } }, opts)
|
||||
local match_opts = { preserve_order = local_opts.preserve_order }
|
||||
local match = function(stritems, inds, query) pick.default_match(stritems, inds, query, match_opts) end
|
||||
local default_source = { name = string.format('Buffer lines (%s)', scope), show = show, match = match }
|
||||
return H.pick_start(items, { source = default_source }, opts)
|
||||
end
|
||||
|
||||
--- Neovim commands picker
|
||||
@ -1089,7 +1097,7 @@ end
|
||||
--- under cursor.
|
||||
--- - `:Pick lsp scope='document_symbol'` - symbols in current file.
|
||||
---
|
||||
---@param local_opts table Options defining behavior of this particular picker.
|
||||
---@param local_opts __extra_pickers_local_opts
|
||||
--- Possible fields:
|
||||
--- - <scope> `(string)` - LSP method to use. One of the supported ones (see
|
||||
--- list above). Default: `nil` which means explicit scope is needed.
|
||||
@ -1164,20 +1172,22 @@ end
|
||||
--- Possible fields:
|
||||
--- - <current_dir> `(boolean)` - whether to return files only from current
|
||||
--- working directory and its subdirectories. Default: `false`.
|
||||
--- __extra_pickers_preserve_order
|
||||
---@param opts __extra_pickers_opts
|
||||
---
|
||||
---@return __extra_pickers_return
|
||||
MiniExtra.pickers.oldfiles = function(local_opts, opts)
|
||||
local pick = H.validate_pick('oldfiles')
|
||||
local_opts = vim.tbl_deep_extend('force', { current_dir = false }, local_opts or {})
|
||||
local_opts = vim.tbl_deep_extend('force', { current_dir = false, preserve_order = false }, local_opts or {})
|
||||
local oldfiles = vim.v.oldfiles
|
||||
if not H.islist(oldfiles) then H.error('`pickers.oldfiles` picker needs valid `v:oldfiles`.') end
|
||||
|
||||
local show_all = not local_opts.current_dir
|
||||
local items = vim.schedule_wrap(function()
|
||||
local cwd = pick.get_picker_opts().source.cwd .. '/'
|
||||
local cwd = H.normalize_path(pick.get_picker_opts().source.cwd) .. '/'
|
||||
local res = {}
|
||||
for _, path in ipairs(oldfiles) do
|
||||
path = H.normalize_path(path)
|
||||
if vim.fn.filereadable(path) == 1 and (show_all or vim.startswith(path, cwd)) then
|
||||
table.insert(res, H.short_path(path, cwd))
|
||||
end
|
||||
@ -1186,7 +1196,9 @@ MiniExtra.pickers.oldfiles = function(local_opts, opts)
|
||||
end)
|
||||
|
||||
local show = H.pick_get_config().source.show or H.show_with_icons
|
||||
return H.pick_start(items, { source = { name = 'Old files', show = show } }, opts)
|
||||
local match_opts = { preserve_order = local_opts.preserve_order }
|
||||
local match = function(stritems, inds, query) pick.default_match(stritems, inds, query, match_opts) end
|
||||
return H.pick_start(items, { source = { name = 'Old files', show = show, match = match } }, opts)
|
||||
end
|
||||
|
||||
--- Neovim options picker
|
||||
@ -1398,8 +1410,7 @@ end
|
||||
--- Default: `nil` to get paths registered for |current-directory|.
|
||||
--- - <filter> `(function|string)` - forwarded to |MiniVisits.list_paths()|.
|
||||
--- Default: `nil` to use all paths.
|
||||
--- - <preserve_order> `(boolean)` - whether to preserve original order
|
||||
--- during query. Default: `false`.
|
||||
--- __extra_pickers_preserve_order
|
||||
--- - <recency_weight> `(number)` - forwarded to |MiniVisits.gen_sort.default()|.
|
||||
--- Default: 0.5 to use "robust frecency" sorting.
|
||||
--- - <sort> `(function)` - forwarded to |MiniVisits.list_paths()|.
|
||||
@ -1419,28 +1430,20 @@ MiniExtra.pickers.visit_paths = function(local_opts, opts)
|
||||
local cwd = local_opts.cwd or vim.fn.getcwd()
|
||||
-- NOTE: Use separate cwd to allow `cwd = ''` to not mean "current directory"
|
||||
local is_for_cwd = cwd ~= ''
|
||||
local picker_cwd = cwd == '' and vim.fn.getcwd() or H.full_path(cwd)
|
||||
local picker_cwd = H.normalize_path(cwd == '' and vim.fn.getcwd() or H.full_path(cwd))
|
||||
|
||||
-- Define source
|
||||
local filter = local_opts.filter or visits.gen_filter.default()
|
||||
local sort = local_opts.sort or visits.gen_sort.default({ recency_weight = local_opts.recency_weight })
|
||||
local items = vim.schedule_wrap(function()
|
||||
local paths = visits.list_paths(cwd, { filter = filter, sort = sort })
|
||||
paths = vim.tbl_map(function(x) return H.short_path(x, picker_cwd) end, paths)
|
||||
paths = vim.tbl_map(function(x) return H.normalize_path(H.short_path(x, picker_cwd)) end, paths)
|
||||
pick.set_picker_items(paths)
|
||||
end)
|
||||
|
||||
local show = H.pick_get_config().source.show or H.show_with_icons
|
||||
|
||||
local match
|
||||
if local_opts.preserve_order then
|
||||
match = function(stritems, inds, query)
|
||||
-- Return makes call synchronous, but it shouldn't be too big problem
|
||||
local res = pick.default_match(stritems, inds, query, true) or {}
|
||||
table.sort(res)
|
||||
return res
|
||||
end
|
||||
end
|
||||
local match_opts = { preserve_order = local_opts.preserve_order }
|
||||
local match = function(stritems, inds, query) pick.default_match(stritems, inds, query, match_opts) end
|
||||
|
||||
local name = string.format('Visit paths (%s)', is_for_cwd and 'cwd' or 'all')
|
||||
local default_source = { name = name, cwd = picker_cwd, match = match, show = show }
|
||||
@ -1488,7 +1491,7 @@ MiniExtra.pickers.visit_labels = function(local_opts, opts)
|
||||
local cwd = local_opts.cwd or vim.fn.getcwd()
|
||||
-- NOTE: Use separate cwd to allow `cwd = ''` to not mean "current directory"
|
||||
local is_for_cwd = cwd ~= ''
|
||||
local picker_cwd = cwd == '' and vim.fn.getcwd() or H.full_path(cwd)
|
||||
local picker_cwd = H.normalize_path(cwd == '' and vim.fn.getcwd() or H.full_path(cwd))
|
||||
|
||||
local filter = local_opts.filter or visits.gen_filter.default()
|
||||
local items = visits.list_labels(local_opts.path, local_opts.cwd, { filter = filter })
|
||||
@ -1499,7 +1502,7 @@ MiniExtra.pickers.visit_labels = function(local_opts, opts)
|
||||
return filter(path_data) and type(path_data.labels) == 'table' and path_data.labels[label]
|
||||
end
|
||||
local all_paths = visits.list_paths(local_opts.cwd, { filter = new_filter, sort = local_opts.sort })
|
||||
return vim.tbl_map(function(path) return H.short_path(path, picker_cwd) end, all_paths)
|
||||
return vim.tbl_map(function(x) return H.normalize_path(H.short_path(x, picker_cwd)) end, all_paths)
|
||||
end
|
||||
|
||||
local preview = function(buf_id, label) vim.api.nvim_buf_set_lines(buf_id, 0, -1, false, list_label_paths(label)) end
|
||||
@ -1539,6 +1542,9 @@ H.ns_id = {
|
||||
-- Various cache
|
||||
H.cache = {}
|
||||
|
||||
-- File system information
|
||||
H.is_windows = vim.loop.os_uname().sysname == 'Windows_NT'
|
||||
|
||||
-- Helper functionality =======================================================
|
||||
-- Settings -------------------------------------------------------------------
|
||||
H.setup_config = function(config) end
|
||||
@ -1836,13 +1842,22 @@ H.lsp_make_on_list = function(source, opts)
|
||||
add_decor_data = function(item)
|
||||
if type(item.kind) ~= 'string' then return end
|
||||
local icon, hl = MiniIcons.get('lsp', item.kind)
|
||||
item.text, item.hl = icon .. ' ' .. item.text, hl
|
||||
-- If kind is not original, assume it already contains an icon
|
||||
local icon_prefix = item.kind_orig == item.kind and (icon .. ' ') or ''
|
||||
item.text, item.hl = icon_prefix .. item.text, hl
|
||||
end
|
||||
end
|
||||
|
||||
local process = function(items)
|
||||
if source ~= 'document_symbol' then items = vim.tbl_map(H.pick_prepend_position, items) end
|
||||
vim.tbl_map(add_decor_data, items)
|
||||
-- Input `item.kind` is a string (resolved before `on_list`). Account for
|
||||
-- possibly tweaked symbol map (like after `MiniIcons.tweak_lsp_kind`).
|
||||
local kind_map = H.get_symbol_kind_map()
|
||||
for _, item in ipairs(items) do
|
||||
item.kind_orig, item.kind = item.kind, kind_map[item.kind]
|
||||
add_decor_data(item)
|
||||
item.kind_orig = nil
|
||||
end
|
||||
table.sort(items, H.lsp_items_compare)
|
||||
return items
|
||||
end
|
||||
@ -1875,6 +1890,17 @@ H.lsp_make_on_list = function(source, opts)
|
||||
end
|
||||
end
|
||||
|
||||
H.get_symbol_kind_map = function()
|
||||
-- Compute symbol kind map from "resolved" string kind to its "original" (as in
|
||||
-- LSP protocol). Those can be different after `MiniIcons.tweak_lsp_kind()`.
|
||||
local res = {}
|
||||
local double_map = vim.lsp.protocol.SymbolKind
|
||||
for k, v in pairs(double_map) do
|
||||
if type(k) == 'string' and type(v) == 'number' then res[double_map[v]] = k end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
H.lsp_items_compare = function(a, b)
|
||||
local a_path, b_path = a.path or '', b.path or ''
|
||||
if a_path < b_path then return true end
|
||||
@ -2040,13 +2066,17 @@ H.ensure_text_width = function(text, width)
|
||||
end
|
||||
|
||||
H.full_path = function(path) return (vim.fn.fnamemodify(path, ':p'):gsub('(.)/$', '%1')) end
|
||||
H.normalize_path = function(path) return path end
|
||||
if H.is_windows then
|
||||
H.full_path = function(path) return (vim.fn.fnamemodify(path, ':p'):gsub('(.)[\\/]$', '%1')) end
|
||||
H.normalize_path = function(path) return path:gsub('\\', '/') end
|
||||
end
|
||||
|
||||
H.short_path = function(path, cwd)
|
||||
cwd = cwd or vim.fn.getcwd()
|
||||
-- Ensure `cwd` is treated as directory path (to not match similar prefix)
|
||||
cwd = cwd:sub(-1) == '/' and cwd or (cwd .. '/')
|
||||
if not vim.startswith(path, cwd) then return vim.fn.fnamemodify(path, ':~') end
|
||||
local res = path:sub(cwd:len() + 1):gsub('^/+', ''):gsub('/+$', '')
|
||||
return res
|
||||
return vim.startswith(path, cwd) and path:sub(cwd:len() + 1) or vim.fn.fnamemodify(path, ':~')
|
||||
end
|
||||
|
||||
-- TODO: Remove after compatibility with Neovim=0.9 is dropped
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -300,7 +300,8 @@ MiniGit.config = {
|
||||
|
||||
--- Show Git related data at cursor
|
||||
---
|
||||
--- - If there is a commit-like |<cword>|, show it in split with `git show`.
|
||||
--- - If inside |mini.deps| confirmation buffer, show in split relevant commit data.
|
||||
--- - If there is a commit-like |<cword>|, show it in split.
|
||||
--- - If possible, show diff source via |MiniGit.show_diff_source()|.
|
||||
--- - If possible, show range history via |MiniGit.show_range_history()|.
|
||||
--- - Otherwise throw an error.
|
||||
@ -309,17 +310,22 @@ MiniGit.config = {
|
||||
--- - __git_split_field
|
||||
--- - Fields appropriate for forwarding to other functions.
|
||||
MiniGit.show_at_cursor = function(opts)
|
||||
local exec = MiniGit.config.job.git_executable
|
||||
local cwd = H.get_git_cwd()
|
||||
-- Try showing commit data at cursor
|
||||
local commit, cwd
|
||||
if vim.bo.filetype == 'minideps-confirm' then
|
||||
commit, cwd = H.deps_pos_to_source()
|
||||
else
|
||||
local cword = vim.fn.expand('<cword>')
|
||||
local is_commit = string.find(cword, '^%x%x%x%x%x%x%x+$') ~= nil and string.lower(cword) == cword
|
||||
commit = is_commit and cword or nil
|
||||
cwd = is_commit and H.get_git_cwd() or nil
|
||||
end
|
||||
|
||||
-- Try showing commit at cursor
|
||||
local cword = vim.fn.expand('<cword>')
|
||||
local is_commit = string.find(cword, '^%x%x%x%x%x%x%x+$') ~= nil and string.lower(cword) == cword
|
||||
if is_commit then
|
||||
if commit ~= nil and cwd ~= nil then
|
||||
local split = H.normalize_split_opt((opts or {}).split or 'auto', 'opts.split')
|
||||
local args = { 'show', cword }
|
||||
local args = { 'show', '--stat', '--patch', commit }
|
||||
local lines = H.git_cli_output(args, cwd)
|
||||
if #lines == 0 then return H.notify('Can not show commit ' .. cword, 'WARN') end
|
||||
if #lines == 0 then return H.notify('Can not show commit ' .. commit .. ' in repo ' .. cwd, 'WARN') end
|
||||
H.show_in_split(split, lines, 'show', table.concat(args, ' '))
|
||||
vim.bo.filetype = 'git'
|
||||
return
|
||||
@ -432,11 +438,12 @@ MiniGit.show_range_history = function(opts)
|
||||
|
||||
-- Construct `:Git log` command that works both with regular files and
|
||||
-- buffers from `show_diff_source()`
|
||||
local buf_name = vim.api.nvim_buf_get_name(0)
|
||||
local cwd = H.get_git_cwd()
|
||||
local buf_name, cwd = vim.api.nvim_buf_get_name(0), H.get_git_cwd()
|
||||
local commit, rel_path = H.parse_diff_source_buf_name(buf_name)
|
||||
if commit == nil then
|
||||
commit, rel_path = 'HEAD', buf_name:gsub(vim.pesc(cwd) .. '/', '')
|
||||
commit = 'HEAD'
|
||||
local cwd_pattern = '^' .. vim.pesc(cwd:gsub('\\', '/')) .. '/'
|
||||
rel_path = buf_name:gsub('\\', '/'):gsub(cwd_pattern, '')
|
||||
end
|
||||
|
||||
-- Ensure no uncommitted changes as they might result into improper `-L` arg
|
||||
@ -642,10 +649,10 @@ end
|
||||
H.apply_config = function(config) MiniGit.config = config end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniGit', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniGit', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
-- NOTE: Try auto enabling buffer on every `BufEnter` to not have `:edit`
|
||||
@ -1566,6 +1573,29 @@ end
|
||||
|
||||
H.parse_diff_source_buf_name = function(buf_name) return string.match(buf_name, '^minigit://%d+/.*show (%x+~?):(.*)$') end
|
||||
|
||||
H.deps_pos_to_source = function()
|
||||
local lines = vim.api.nvim_buf_get_lines(0, 0, vim.fn.line('.'), false)
|
||||
-- Do nothing if on the title (otherwise it operates on previous plugin info)
|
||||
if lines[#lines]:find('^[%+%-!]') ~= nil then return end
|
||||
|
||||
-- Locate lines with commit and repo path data
|
||||
local commit, commit_lnum = nil, #lines
|
||||
while commit == nil and commit_lnum >= 1 do
|
||||
local l = lines[commit_lnum]
|
||||
commit = l:match('^[><] (%x%x%x%x%x%x%x%x*) |') or l:match('^State[^:]*: %s*(%x+)')
|
||||
commit_lnum = commit_lnum - 1
|
||||
end
|
||||
|
||||
local cwd, cwd_lnum = nil, #lines
|
||||
while cwd == nil and cwd_lnum >= 1 do
|
||||
cwd, cwd_lnum = lines[cwd_lnum]:match('^Path: %s*(%S+)$'), cwd_lnum - 1
|
||||
end
|
||||
|
||||
-- Do nothing if something is not found or path corresponds to next repo
|
||||
if commit == nil or cwd == nil or commit_lnum <= cwd_lnum then return end
|
||||
return commit, cwd
|
||||
end
|
||||
|
||||
-- Folding --------------------------------------------------------------------
|
||||
H.is_hunk_header = function(lnum) return vim.fn.getline(lnum):find('^@@.*@@') ~= nil end
|
||||
|
||||
|
||||
@ -699,13 +699,14 @@ end
|
||||
H.apply_config = function(config) MiniHipatterns.config = config end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniHipatterns', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniHipatterns', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au('BufEnter', '*', H.auto_enable, 'Enable highlighting')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
au('ColorScheme', '*', H.on_colorscheme, 'Reload all enabled pattern highlighters')
|
||||
end
|
||||
|
||||
|
||||
@ -49,6 +49,7 @@
|
||||
--- - 'HiPhish/rainbow-delimiters.nvim'
|
||||
--- - 'hrsh7th/nvim-cmp'
|
||||
--- - 'justinmk/vim-sneak'
|
||||
--- - 'kevinhwang91/nvim-bqf'
|
||||
--- - 'kevinhwang91/nvim-ufo'
|
||||
--- - 'lewis6991/gitsigns.nvim'
|
||||
--- - 'lukas-reineke/indent-blankline.nvim'
|
||||
@ -477,14 +478,16 @@ MiniHues.apply_palette = function(palette, plugins)
|
||||
hi('Normal', { fg=p.fg, bg=p.bg })
|
||||
hi('NormalFloat', { fg=p.fg, bg=p.bg_edge })
|
||||
hi('NormalNC', { link='Normal' })
|
||||
hi('PMenu', { fg=p.fg, bg=p.bg_mid })
|
||||
hi('PMenuExtra', { link='PMenu' })
|
||||
hi('PMenuExtraSel', { link='PMenuSel' })
|
||||
hi('PMenuKind', { link='PMenu' })
|
||||
hi('PMenuKindSel', { link='PMenuSel' })
|
||||
hi('PMenuSbar', { link='PMenu' })
|
||||
hi('PMenuSel', { fg=p.bg, bg=p.fg, blend=0 })
|
||||
hi('PMenuThumb', { fg=nil, bg=p.bg_mid2 })
|
||||
hi('Pmenu', { fg=p.fg, bg=p.bg_mid })
|
||||
hi('PmenuExtra', { link='Pmenu' })
|
||||
hi('PmenuExtraSel', { link='PmenuSel' })
|
||||
hi('PmenuKind', { link='Pmenu' })
|
||||
hi('PmenuKindSel', { link='PmenuSel' })
|
||||
hi('PmenuMatch', { fg=p.fg, bg=p.bg_mid, bold=true })
|
||||
hi('PmenuMatchSel', { fg=nil, bg=nil, bold=true, blend=0, reverse=true })
|
||||
hi('PmenuSbar', { link='Pmenu' })
|
||||
hi('PmenuSel', { fg=nil, bg=nil, blend=0, reverse=true })
|
||||
hi('PmenuThumb', { fg=nil, bg=p.bg_mid2 })
|
||||
hi('Question', { fg=p.azure, bg=nil })
|
||||
hi('QuickFixLine', { fg=nil, bg=nil, bold=true })
|
||||
hi('Search', { fg=p.bg, bg=p.accent })
|
||||
@ -508,7 +511,7 @@ MiniHues.apply_palette = function(palette, plugins)
|
||||
hi('VisualNOS', { fg=nil, bg=p.bg_mid })
|
||||
hi('WarningMsg', { fg=p.yellow, bg=nil })
|
||||
hi('Whitespace', { fg=p.bg_mid2, bg=nil })
|
||||
hi('WildMenu', { link='PMenuSel' })
|
||||
hi('WildMenu', { link='PmenuSel' })
|
||||
hi('WinBar', { link='StatusLine' })
|
||||
hi('WinBarNC', { link='StatusLineNC' })
|
||||
hi('WinSeparator', { fg=p.accent, bg=nil })
|
||||
@ -749,6 +752,7 @@ MiniHues.apply_palette = function(palette, plugins)
|
||||
hi('@string.special.symbol', { link='@constant' })
|
||||
hi('@string.special.path', { link='Directory' })
|
||||
hi('@string.special.url', { link='@markup.link.url' })
|
||||
hi('@string.special.vimdoc', { link='@constant' })
|
||||
|
||||
-- @character
|
||||
-- @character.special
|
||||
@ -807,7 +811,7 @@ MiniHues.apply_palette = function(palette, plugins)
|
||||
|
||||
hi('@markup.strong', { link='@text.strong' })
|
||||
hi('@markup.italic', { link='@text.emphasis' })
|
||||
hi('@markup.strikethrough', { link='@text.strikethrough' })
|
||||
hi('@markup.strikethrough', { link='@text.strike' })
|
||||
hi('@markup.underline', { link='@text.underline' })
|
||||
|
||||
hi('@markup.heading', { link='@text.title' })
|
||||
@ -922,6 +926,7 @@ MiniHues.apply_palette = function(palette, plugins)
|
||||
hi('MiniPickBorder', { link='FloatBorder' })
|
||||
hi('MiniPickBorderBusy', { link='DiagnosticFloatingWarn' })
|
||||
hi('MiniPickBorderText', { link='FloatTitle' })
|
||||
hi('MiniPickCursor', { blend=100, nocombine=true })
|
||||
hi('MiniPickIconDirectory', { link='Directory' })
|
||||
hi('MiniPickIconFile', { link='MiniPickNormal' })
|
||||
hi('MiniPickHeader', { link='DiagnosticFloatingHint' })
|
||||
@ -1146,6 +1151,13 @@ MiniHues.apply_palette = function(palette, plugins)
|
||||
hi('SneakLabel', { fg=p.bg, bg=p.orange, bold=true })
|
||||
end
|
||||
|
||||
-- 'kevinhwang91/nvim-bqf'
|
||||
if has_integration('kevinhwang91/nvim-bqf') then
|
||||
hi('BqfPreviewFloat', { link='NormalFloat' })
|
||||
hi('BqfPreviewTitle', { link='FloatTitle' })
|
||||
hi('BqfSign', { fg=p.cyan })
|
||||
end
|
||||
|
||||
-- 'kevinhwang91/nvim-ufo'
|
||||
-- Everything works correctly out of the box
|
||||
|
||||
|
||||
@ -194,6 +194,9 @@ MiniIcons.setup = function(config)
|
||||
-- Apply config
|
||||
H.apply_config(config)
|
||||
|
||||
-- Define behavior
|
||||
H.create_autocommands()
|
||||
|
||||
-- Create default highlighting
|
||||
H.create_default_hl()
|
||||
end
|
||||
@ -1937,6 +1940,11 @@ H.apply_config = function(config)
|
||||
H.init_cache(config)
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local gr = vim.api.nvim_create_augroup('MiniIcons', {})
|
||||
vim.api.nvim_create_autocmd('ColorScheme', { group = gr, callback = H.create_default_hl, desc = 'Ensure colors' })
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
H.create_default_hl = function()
|
||||
local hi = function(name, opts)
|
||||
@ -2035,7 +2043,7 @@ H.get_impl = {
|
||||
-- Built-in extensions
|
||||
local icon_data = H.extension_icons[name]
|
||||
if type(icon_data) == 'string' then return MiniIcons.get('filetype', icon_data) end
|
||||
if icon_data ~= nil then return icon_data, icon_data.hl end
|
||||
if icon_data ~= nil then return icon_data end
|
||||
|
||||
-- Parts of complex extension (if can be recognized)
|
||||
local dot = string.find(name, '%..')
|
||||
@ -2058,7 +2066,8 @@ H.get_impl = {
|
||||
-- Built-in file names
|
||||
local icon_data = H.file_icons[basename]
|
||||
if type(icon_data) == 'string' then return MiniIcons.get('filetype', icon_data) end
|
||||
if icon_data ~= nil then return icon_data end
|
||||
-- - Style icon based on the basename and not full name
|
||||
if icon_data ~= nil then return H.style_icon(icon_data.glyph, basename), icon_data.hl end
|
||||
|
||||
-- Basename extensions. Prefer this before `vim.filetype.match()` for speed
|
||||
-- (as the latter is slow-ish; like 0.1 ms in Neovim<0.11)
|
||||
|
||||
@ -660,24 +660,18 @@ H.apply_config = function(config)
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniIndentscope', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniIndentscope', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au(
|
||||
{ 'CursorMoved', 'CursorMovedI', 'ModeChanged' },
|
||||
'*',
|
||||
function() H.auto_draw({ lazy = true }) end,
|
||||
'Auto draw indentscope lazily'
|
||||
)
|
||||
au(
|
||||
{ 'TextChanged', 'TextChangedI', 'TextChangedP', 'WinScrolled' },
|
||||
'*',
|
||||
function() H.auto_draw() end,
|
||||
'Auto draw indentscope'
|
||||
)
|
||||
local lazy_events = { 'CursorMoved', 'CursorMovedI', 'ModeChanged' }
|
||||
au(lazy_events, '*', function() H.auto_draw({ lazy = true }) end, 'Auto draw indentscope lazily')
|
||||
local now_events = { 'TextChanged', 'TextChangedI', 'TextChangedP', 'WinScrolled' }
|
||||
au(now_events, '*', function() H.auto_draw() end, 'Auto draw indentscope')
|
||||
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
@ -947,7 +941,9 @@ H.make_draw_function = function(indicator, opts)
|
||||
virt_text_pos = 'overlay',
|
||||
}
|
||||
|
||||
if H.has_wrapped_virt_text and vim.wo.breakindent then extmark_opts.virt_text_repeat_linebreak = true end
|
||||
if H.has_wrapped_virt_text and vim.wo.breakindent and vim.wo.showbreak == '' then
|
||||
extmark_opts.virt_text_repeat_linebreak = true
|
||||
end
|
||||
|
||||
local current_event_id = opts.event_id
|
||||
|
||||
|
||||
@ -337,14 +337,15 @@ H.apply_config = function(config)
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniJump', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniJump', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au('CursorMoved', '*', H.on_cursormoved, 'On CursorMoved')
|
||||
au({ 'BufLeave', 'InsertEnter' }, '*', MiniJump.stop_jumping, 'Stop jumping')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
H.create_default_hl = function() vim.api.nvim_set_hl(0, 'MiniJump', { default = true, link = 'SpellRare' }) end
|
||||
|
||||
@ -721,10 +721,10 @@ H.apply_config = function(config)
|
||||
end
|
||||
|
||||
H.create_autocommands = function(config)
|
||||
local augroup = vim.api.nvim_create_augroup('MiniJump2d', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniJump2d', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { pattern = pattern, group = augroup, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { pattern = pattern, group = gr, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
-- Corrections for default `<CR>` mapping to not interfere with popular usages
|
||||
@ -734,8 +734,7 @@ H.create_autocommands = function(config)
|
||||
au('CmdwinEnter', '*', revert_cr, 'Revert <CR>')
|
||||
end
|
||||
|
||||
-- Ensure proper colors
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure proper colors')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
|
||||
@ -1034,10 +1034,10 @@ end
|
||||
H.apply_config = function(config) MiniMap.config = config end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniMap', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniMap', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au({ 'BufEnter', 'BufWritePost', 'TextChanged', 'VimResized' }, '*', H.on_content_change, 'On content change')
|
||||
@ -1045,6 +1045,7 @@ H.create_autocommands = function()
|
||||
au('WinLeave', '*', H.on_winleave, 'On WinLeave')
|
||||
au('WinClosed', '*', H.on_winclosed, 'On WinClosed')
|
||||
au('ModeChanged', '*:n', H.on_content_change, 'On return to Normal mode')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
@ -1395,7 +1396,7 @@ H.create_map_buffer = function()
|
||||
local buf_id = vim.api.nvim_create_buf(false, true)
|
||||
|
||||
-- Set buffer local options (which don't involve `noautocmd`)
|
||||
vim.api.nvim_buf_set_option(buf_id, 'filetype', 'minimap')
|
||||
vim.bo[buf_id].filetype = 'minimap'
|
||||
|
||||
-- Make buffer local mappings
|
||||
vim.keymap.set('n', '<CR>', '<Cmd>lua MiniMap.toggle_focus(false)<CR>', { buffer = buf_id })
|
||||
|
||||
@ -272,7 +272,7 @@ MiniMisc.find_root = function(buf_id, names, fallback)
|
||||
|
||||
-- Use absolute path to an existing directory
|
||||
if type(res) ~= 'string' then return end
|
||||
res = vim.fn.fnamemodify(res, ':p')
|
||||
res = H.fs_normalize(vim.fn.fnamemodify(res, ':p'))
|
||||
if vim.fn.isdirectory(res) == 0 then return end
|
||||
|
||||
-- Cache result per directory path
|
||||
@ -286,19 +286,34 @@ H.root_cache = {}
|
||||
--- Set up terminal background synchronization
|
||||
---
|
||||
--- What it does:
|
||||
--- - Checks if terminal emulator supports OSC 11 control sequence. Stops if not.
|
||||
--- - Creates |UIEnter| and |ColorScheme| autocommands which change terminal
|
||||
--- background to have same color as |guibg| of |hl-Normal|.
|
||||
--- - Creates |UILeave| autocommand which sets terminal background back to the
|
||||
--- color at the time this function was called first time in current session.
|
||||
--- - Checks if terminal emulator supports OSC 11 control sequence through
|
||||
--- appropriate `stdout`. Stops if not.
|
||||
--- - Creates autocommands for |ColorScheme| and |VimResume| events, which
|
||||
--- change terminal background to have same color as |guibg| of |hl-Normal|.
|
||||
--- - Creates autocommands for |VimLeavePre| and |VimSuspend| events which set
|
||||
--- terminal background back to the color at the time this function was
|
||||
--- called first time in current session.
|
||||
--- - Synchronizes background immediately to allow not depend on loading order.
|
||||
---
|
||||
--- Primary use case is to remove possible "frame" around current Neovim instance
|
||||
--- which appears if Neovim's |hl-Normal| background color differs from what is
|
||||
--- used by terminal emulator itself.
|
||||
---
|
||||
--- Make sure to call it only during interactive session in terminal emulator.
|
||||
--- Works only on Neovim>=0.10.
|
||||
MiniMisc.setup_termbg_sync = function()
|
||||
if vim.fn.has('nvim-0.10') == 0 then
|
||||
-- Handling `'\027]11;?\007'` response was added in Neovim 0.10
|
||||
H.notify('`setup_termbg_sync()` requires Neovim>=0.10', 'WARN')
|
||||
return
|
||||
end
|
||||
|
||||
-- Proceed only if there is a valid stdout to use
|
||||
local has_stdout_tty = false
|
||||
for _, ui in ipairs(vim.api.nvim_list_uis()) do
|
||||
has_stdout_tty = has_stdout_tty or ui.stdout_tty
|
||||
end
|
||||
if not has_stdout_tty then return end
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup('MiniMiscTermbgSync', { clear = true })
|
||||
local f = function(args)
|
||||
local ok, bg_init = pcall(H.parse_osc11, args.data)
|
||||
@ -311,14 +326,16 @@ MiniMisc.setup_termbg_sync = function()
|
||||
local sync = function()
|
||||
local normal = vim.api.nvim_get_hl_by_name('Normal', true)
|
||||
if normal.background == nil then return end
|
||||
io.write(string.format('\027]11;#%06x\007', normal.background))
|
||||
-- NOTE: use `io.stdout` instead of `io.write` to ensure correct target
|
||||
-- Otherwise after `io.output(file); file:close()` there is an error
|
||||
io.stdout:write(string.format('\027]11;#%06x\007', normal.background))
|
||||
end
|
||||
vim.api.nvim_create_autocmd({ 'UIEnter', 'ColorScheme' }, { group = augroup, callback = sync })
|
||||
vim.api.nvim_create_autocmd({ 'VimResume', 'ColorScheme' }, { group = augroup, callback = sync })
|
||||
|
||||
-- Set up reset to the color returned from the very first call
|
||||
H.termbg_init = H.termbg_init or bg_init
|
||||
local reset = function() io.write('\027]11;' .. H.termbg_init .. '\007') end
|
||||
vim.api.nvim_create_autocmd({ 'UILeave' }, { group = augroup, callback = reset })
|
||||
local reset = function() io.stdout:write('\027]11;' .. H.termbg_init .. '\007') end
|
||||
vim.api.nvim_create_autocmd({ 'VimLeavePre', 'VimSuspend' }, { group = augroup, callback = reset })
|
||||
|
||||
-- Sync immediately
|
||||
sync()
|
||||
@ -326,7 +343,7 @@ MiniMisc.setup_termbg_sync = function()
|
||||
|
||||
-- Ask about current background color and process the response
|
||||
local id = vim.api.nvim_create_autocmd('TermResponse', { group = augroup, callback = f, once = true, nested = true })
|
||||
io.write('\027]11;?\007')
|
||||
io.stdout:write('\027]11;?\007')
|
||||
vim.defer_fn(function()
|
||||
local ok = pcall(vim.api.nvim_del_autocmd, id)
|
||||
if ok then H.notify('`setup_termbg_sync()` did not get response from terminal emulator', 'WARN') end
|
||||
@ -553,8 +570,7 @@ MiniMisc.use_nested_comments = function(buf_id)
|
||||
local leader = vim.trim(comment_parts[1])
|
||||
|
||||
local comments = vim.bo[buf_id].comments
|
||||
local new_comments = string.format('n:%s,%s', leader, comments)
|
||||
vim.api.nvim_buf_set_option(buf_id, 'comments', new_comments)
|
||||
vim.bo[buf_id].comments = string.format('n:%s,%s', leader, comments)
|
||||
end
|
||||
|
||||
--- Zoom in and out of a buffer, making it full screen in a floating window
|
||||
@ -594,7 +610,9 @@ H.setup_config = function(config)
|
||||
-- General idea: if some table elements are not present in user-supplied
|
||||
-- `config`, take them from default config
|
||||
vim.validate({ config = { config, 'table', true } })
|
||||
config = vim.tbl_deep_extend('force', vim.deepcopy(H.default_config), config or {})
|
||||
-- NOTE: Don't use `tbl_deep_extend` to prefer full input `make_global` array
|
||||
-- Needs adjusting if there is a new setting with nested tables
|
||||
config = vim.tbl_extend('force', vim.deepcopy(H.default_config), config or {})
|
||||
|
||||
vim.validate({
|
||||
make_global = {
|
||||
@ -639,6 +657,11 @@ H.is_number = function(x) return type(x) == 'number' end
|
||||
|
||||
H.is_string = function(x) return type(x) == 'string' end
|
||||
|
||||
H.fs_normalize = vim.fs.normalize
|
||||
if vim.fn.has('nvim-0.9') == 0 then
|
||||
H.fs_normalize = function(...) return vim.fs.normalize(...):gsub('(.)/+$', '%1') end
|
||||
end
|
||||
|
||||
-- TODO: Remove after compatibility with Neovim=0.9 is dropped
|
||||
H.islist = vim.fn.has('nvim-0.10') == 1 and vim.islist or vim.tbl_islist
|
||||
|
||||
|
||||
@ -189,6 +189,12 @@ MiniMove.move_selection = function(direction, opts)
|
||||
local dir_type = (direction == 'up' or direction == 'down') and 'vert' or 'hori'
|
||||
local is_linewise = cur_mode == 'V'
|
||||
|
||||
-- Make early return in small buffer
|
||||
if vim.api.nvim_buf_line_count(0) == 1 then
|
||||
if is_linewise and dir_type == 'vert' then return end
|
||||
if not is_linewise and vim.fn.getline(1):len() == 0 then return end
|
||||
end
|
||||
|
||||
-- Cache useful data because it will be reset when executing commands
|
||||
local n_times = opts.n_times or vim.v.count1
|
||||
local ref_curpos, ref_last_col = vim.fn.getcurpos(), vim.fn.col('$')
|
||||
@ -222,8 +228,9 @@ MiniMove.move_selection = function(direction, opts)
|
||||
if not cache_virtualedit:find('all') then vim.o.virtualedit = 'onemore' end
|
||||
|
||||
-- Cut selection while saving caching register
|
||||
local cache_z_reg = vim.fn.getreg('z')
|
||||
cmd('"zx')
|
||||
local cache_z_reg = vim.fn.getreginfo('z')
|
||||
-- - Don't use `"zx` directly to not affect registers 1-9
|
||||
cmd('"zygv"_x')
|
||||
|
||||
-- Detect edge selection: last line(s) for vertical and last character(s)
|
||||
-- for horizontal. At this point (after cutting selection) cursor is on the
|
||||
@ -310,6 +317,7 @@ end
|
||||
---@param opts __move_opts
|
||||
MiniMove.move_line = function(direction, opts)
|
||||
if H.is_disabled() or not vim.o.modifiable then return end
|
||||
if vim.api.nvim_buf_line_count(0) == 1 and (direction == 'down' or direction == 'up') then return end
|
||||
|
||||
opts = vim.tbl_deep_extend('force', H.get_config().options, opts or {})
|
||||
|
||||
@ -340,9 +348,10 @@ MiniMove.move_line = function(direction, opts)
|
||||
return
|
||||
end
|
||||
|
||||
-- Cut curre lint while saving caching register
|
||||
local cache_z_reg = vim.fn.getreg('z')
|
||||
cmd('"zdd')
|
||||
-- Cut current line while saving caching register
|
||||
local cache_z_reg = vim.fn.getreginfo('z')
|
||||
-- - Don't use `"zdd` directly to not affect registers 1-9
|
||||
cmd('"zyy"_dd')
|
||||
|
||||
-- Move cursor
|
||||
local paste_key = direction == 'up' and 'P' or 'p'
|
||||
@ -457,7 +466,7 @@ H.make_cmd_normal = function(include_undojoin)
|
||||
|
||||
-- Disable 'mini.bracketed' to avoid unwanted entries to its yank history
|
||||
local cache_minibracketed_disable = vim.b.minibracketed_disable
|
||||
local cache_unnamed_register = vim.fn.getreg('"')
|
||||
local cache_unnamed_register = { points_to = vim.fn.getreginfo('"').points_to }
|
||||
|
||||
-- Don't track possible put commands into yank history
|
||||
vim.b.minibracketed_disable = true
|
||||
|
||||
@ -105,7 +105,7 @@ MiniNotify.setup = function(config)
|
||||
H.apply_config(config)
|
||||
|
||||
-- Define behavior
|
||||
H.create_autocommands(config)
|
||||
H.create_autocommands()
|
||||
|
||||
-- Create default highlighting
|
||||
H.create_default_hl()
|
||||
@ -596,14 +596,15 @@ H.apply_config = function(config)
|
||||
end
|
||||
end
|
||||
|
||||
H.create_autocommands = function(config)
|
||||
local augroup = vim.api.nvim_create_augroup('MiniNotify', {})
|
||||
H.create_autocommands = function()
|
||||
local gr = vim.api.nvim_create_augroup('MiniNotify', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au({ 'TabEnter', 'VimResized' }, '*', function() MiniNotify.refresh() end, 'Refresh notifications')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
@ -741,9 +742,10 @@ H.window_open = function(buf_id)
|
||||
local win_id = vim.api.nvim_open_win(buf_id, false, config)
|
||||
|
||||
vim.wo[win_id].foldenable = false
|
||||
vim.wo[win_id].wrap = true
|
||||
vim.wo[win_id].foldmethod = 'manual'
|
||||
vim.wo[win_id].winblend = H.get_config().window.winblend
|
||||
vim.wo[win_id].winhighlight = 'NormalFloat:MiniNotifyNormal,FloatBorder:MiniNotifyBorder,FloatTitle:MiniNotifyTitle'
|
||||
vim.wo[win_id].wrap = true
|
||||
|
||||
return win_id
|
||||
end
|
||||
|
||||
@ -182,6 +182,9 @@ MiniOperators.setup = function(config)
|
||||
-- Apply config
|
||||
H.apply_config(config)
|
||||
|
||||
-- Define behavior
|
||||
H.create_autocommands()
|
||||
|
||||
-- Create default highlighting
|
||||
H.create_default_hl()
|
||||
end
|
||||
@ -742,6 +745,11 @@ H.get_config = function(config)
|
||||
return vim.tbl_deep_extend('force', MiniOperators.config, vim.b.minioperators_config or {}, config or {})
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local gr = vim.api.nvim_create_augroup('MiniOperators', {})
|
||||
vim.api.nvim_create_autocmd('ColorScheme', { group = gr, callback = H.create_default_hl, desc = 'Ensure colors' })
|
||||
end
|
||||
|
||||
H.create_default_hl = function()
|
||||
vim.api.nvim_set_hl(0, 'MiniOperatorsExchangeFrom', { default = true, link = 'IncSearch' })
|
||||
end
|
||||
@ -997,7 +1005,7 @@ H.replace_do = function(data)
|
||||
local edge_to_col = vim.fn.col({ to_line, '$' }) - 1 - (vim.o.selection == 'exclusive' and 0 or 1)
|
||||
|
||||
local is_edge_line = submode == 'V' and to_line == vim.fn.line('$')
|
||||
local is_edge_col = submode ~= 'V' and to_col == edge_to_col
|
||||
local is_edge_col = submode ~= 'V' and to_col == edge_to_col and vim.o.virtualedit ~= 'all'
|
||||
local is_edge = is_edge_line or is_edge_col
|
||||
|
||||
local covers_linewise_all_buffer = is_edge_line and from_line == 1
|
||||
|
||||
@ -494,10 +494,10 @@ H.apply_config = function(config)
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniPairs', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniPairs', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au('FileType', { 'TelescopePrompt', 'fzf' }, function() vim.b.minipairs_disable = true end, 'Disable locally')
|
||||
|
||||
@ -117,6 +117,7 @@
|
||||
--- * `MiniPickBorder` - window border.
|
||||
--- * `MiniPickBorderBusy` - window border while picker is busy processing.
|
||||
--- * `MiniPickBorderText` - non-prompt on border.
|
||||
--- * `MiniPickCursor` - cursor during active picker (hidden by default).
|
||||
--- * `MiniPickIconDirectory` - default icon for directory.
|
||||
--- * `MiniPickIconFile` - default icon for file.
|
||||
--- * `MiniPickHeader` - headers in info buffer and previews.
|
||||
@ -692,7 +693,7 @@ MiniPick.setup = function(config)
|
||||
H.apply_config(config)
|
||||
|
||||
-- Define behavior
|
||||
H.create_autocommands(config)
|
||||
H.create_autocommands()
|
||||
|
||||
-- Create default highlighting
|
||||
H.create_default_hl()
|
||||
@ -704,7 +705,7 @@ MiniPick.setup = function(config)
|
||||
local paste_orig = vim.paste
|
||||
vim.paste = function(...)
|
||||
if not MiniPick.is_picker_active() then return paste_orig(...) end
|
||||
vim.notify('(mini.pick) Use `mappings.paste` (`<C-r>` by default) with "*" or "+" register.', vim.log.levels.HINT)
|
||||
H.notify('Use `mappings.paste` (`<C-r>` by default) with "*" or "+" register.', 'HINT')
|
||||
end
|
||||
end
|
||||
|
||||
@ -975,20 +976,35 @@ end
|
||||
---@param inds table Array of `stritems` indexes to match. All of them should point
|
||||
--- at string elements of `stritems`. No check is done for performance reasons.
|
||||
---@param query table Array of strings.
|
||||
---@param do_sync boolean|nil Whether to match synchronously. Default: `nil`.
|
||||
---@param opts table|nil Options. Possible fields:
|
||||
--- - <sync> `(boolean)` - Whether to match synchronously. Default: `false`.
|
||||
--- - <preserve_order> `(boolean)` - Whether to skip sort step. Default: `false`.
|
||||
---
|
||||
---@return table|nil Depending on whether computation is synchronous (either `do_sync`
|
||||
--- is truthy or there is an active picker):
|
||||
---@return table|nil Depending on whether computation is synchronous (either `opts.sync`
|
||||
--- is `true` or there is an active picker):
|
||||
--- - If yes, array of `stritems` indexes matching the `query` (from best to worst).
|
||||
--- - If no, `nil` is returned with |MiniPick.set_picker_match_inds()| used later.
|
||||
MiniPick.default_match = function(stritems, inds, query, do_sync)
|
||||
local is_sync = do_sync or not MiniPick.is_picker_active()
|
||||
MiniPick.default_match = function(stritems, inds, query, opts)
|
||||
-- TODO: Remove after mini.nvim 0.14 release
|
||||
if opts and type(opts) ~= 'table' then
|
||||
if not H.notified_match_opts then
|
||||
local msg = 'Use `{ sync = true }` as fourth argument to `default_match`.'
|
||||
.. " Current code will not work after the next 'mini.nvim' release."
|
||||
H.notify(msg, 'WARN')
|
||||
H.notified_match_opts = true
|
||||
end
|
||||
opts = { sync = true }
|
||||
end
|
||||
|
||||
opts = opts or {}
|
||||
local is_sync = opts.sync or not MiniPick.is_picker_active()
|
||||
local set_match_inds = is_sync and function(x) return x end or MiniPick.set_picker_match_inds
|
||||
local f = function()
|
||||
if #query == 0 then return set_match_inds(H.seq_along(stritems)) end
|
||||
local match_data, match_type = H.match_filter(inds, stritems, query)
|
||||
if match_data == nil then return end
|
||||
if match_type == 'nosort' then return set_match_inds(H.seq_along(stritems)) end
|
||||
if match_type == 'useall' then return set_match_inds(H.seq_along(stritems)) end
|
||||
if opts.preserve_order then return set_match_inds(H.match_no_sort(match_data)) end
|
||||
local match_inds = H.match_sort(match_data)
|
||||
if match_inds == nil then return end
|
||||
return set_match_inds(match_inds)
|
||||
@ -1163,8 +1179,7 @@ MiniPick.default_choose_marked = function(items, opts)
|
||||
for _, item in ipairs(items) do
|
||||
local item_data = H.parse_item(item)
|
||||
if item_data.type == 'file' or item_data.type == 'buffer' or item_data.type == 'uri' then
|
||||
local is_uri, uri_path = pcall(vim.uri_to_fname, item_data.path)
|
||||
local entry = { bufnr = item_data.buf_id, filename = is_uri and uri_path or item_data.path }
|
||||
local entry = { bufnr = item_data.buf_id, filename = H.parse_uri(item_data.path) or item_data.path }
|
||||
entry.lnum, entry.col, entry.text = item_data.lnum or 1, item_data.col or 1, item_data.text or ''
|
||||
entry.end_lnum, entry.end_col = item_data.end_lnum, item_data.end_col
|
||||
table.insert(list, entry)
|
||||
@ -1655,7 +1670,13 @@ MiniPick.set_picker_items_from_cli = function(command, opts)
|
||||
local process, pid, stdout = nil, nil, vim.loop.new_pipe()
|
||||
local spawn_opts = vim.tbl_deep_extend('force', opts.spawn_opts, { args = args, stdio = { nil, stdout, nil } })
|
||||
if type(spawn_opts.cwd) == 'string' then spawn_opts.cwd = H.full_path(spawn_opts.cwd) end
|
||||
process, pid = vim.loop.spawn(executable, spawn_opts, function() process:close() end)
|
||||
process, pid = vim.loop.spawn(executable, spawn_opts, function()
|
||||
if process:is_active() then process:close() end
|
||||
end)
|
||||
|
||||
-- Make sure to stop the process if picker is stopped
|
||||
local kill_process = function() pcall(vim.loop.process_kill, process) end
|
||||
vim.api.nvim_create_autocmd('User', { pattern = 'MiniPickStop', once = true, callback = kill_process })
|
||||
|
||||
local data_feed = {}
|
||||
stdout:read_start(function(err, data)
|
||||
@ -1809,6 +1830,9 @@ H.querytick = 0
|
||||
-- General purpose cache
|
||||
H.cache = {}
|
||||
|
||||
-- File system information
|
||||
H.is_windows = vim.loop.os_uname().sysname == 'Windows_NT'
|
||||
|
||||
-- Helper functionality =======================================================
|
||||
-- Settings -------------------------------------------------------------------
|
||||
H.setup_config = function(config)
|
||||
@ -1883,14 +1907,15 @@ H.get_config = function(config)
|
||||
return vim.tbl_deep_extend('force', MiniPick.config, vim.b.minipick_config or {}, config or {})
|
||||
end
|
||||
|
||||
H.create_autocommands = function(config)
|
||||
local augroup = vim.api.nvim_create_augroup('MiniPick', {})
|
||||
H.create_autocommands = function()
|
||||
local gr = vim.api.nvim_create_augroup('MiniPick', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au('VimResized', '*', MiniPick.refresh, 'Refresh on resize')
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
@ -1903,6 +1928,7 @@ H.create_default_hl = function()
|
||||
hi('MiniPickBorder', { link = 'FloatBorder' })
|
||||
hi('MiniPickBorderBusy', { link = 'DiagnosticFloatingWarn' })
|
||||
hi('MiniPickBorderText', { link = 'FloatTitle' })
|
||||
hi('MiniPickCursor', { blend = 100, nocombine = true })
|
||||
hi('MiniPickIconDirectory', { link = 'Directory' })
|
||||
hi('MiniPickIconFile', { link = 'MiniPickNormal' })
|
||||
hi('MiniPickHeader', { link = 'DiagnosticFloatingHint' })
|
||||
@ -2126,17 +2152,17 @@ H.picker_new_buf = function()
|
||||
end
|
||||
|
||||
H.picker_new_win = function(buf_id, win_config)
|
||||
-- Focus cursor on Command line to not see it
|
||||
if vim.fn.mode() == 'n' then
|
||||
H.cache.cmdheight = vim.o.cmdheight
|
||||
vim.o.cmdheight = 1
|
||||
vim.cmd('noautocmd normal! :')
|
||||
end
|
||||
-- Hide cursor while picker is active (to not be visible in the window)
|
||||
-- This mostly follows a hack from 'folke/noice.nvim'
|
||||
H.cache.guicursor = vim.o.guicursor
|
||||
vim.o.guicursor = 'a:MiniPickCursor'
|
||||
|
||||
-- Create window and focus on it
|
||||
local win_id = vim.api.nvim_open_win(buf_id, true, H.picker_compute_win_config(win_config, true))
|
||||
|
||||
-- Set window-local data
|
||||
vim.wo[win_id].foldenable = false
|
||||
vim.wo[win_id].foldmethod = 'manual'
|
||||
vim.wo[win_id].list = true
|
||||
vim.wo[win_id].listchars = 'extends:…'
|
||||
vim.wo[win_id].scrolloff = 0
|
||||
@ -2438,7 +2464,10 @@ end
|
||||
|
||||
H.picker_stop = function(picker, abort)
|
||||
vim.tbl_map(function(timer) pcall(vim.loop.timer_stop, timer) end, H.timers)
|
||||
pcall(function() vim.o.cmdheight = H.cache.cmdheight end)
|
||||
|
||||
-- Show cursor (work around `guicursor=''` actually leaving cursor hidden)
|
||||
if H.cache.guicursor == '' then vim.cmd('set guicursor=a: | redraw') end
|
||||
pcall(function() vim.o.guicursor = H.cache.guicursor end)
|
||||
|
||||
if picker == nil then return end
|
||||
|
||||
@ -2759,7 +2788,7 @@ H.match_filter = function(inds, stritems, query)
|
||||
query = grouped_parts
|
||||
end
|
||||
|
||||
if #query == 0 then return {}, 'nosort', query end
|
||||
if #query == 0 then return {}, 'useall', query end
|
||||
|
||||
local is_fuzzy_plain = not (is_exact_plain or is_exact_start or is_exact_end) and #query > 1
|
||||
if is_fuzzy_forced or is_fuzzy_plain then return H.match_filter_fuzzy(inds, stritems, query), 'fuzzy', query end
|
||||
@ -2927,6 +2956,10 @@ H.match_sort = function(match_data)
|
||||
return res
|
||||
end
|
||||
|
||||
H.match_no_sort = function(match_data)
|
||||
return vim.tbl_map(function(x) return x[3] end, match_data)
|
||||
end
|
||||
|
||||
-- Default show ---------------------------------------------------------------
|
||||
H.get_icon = function(x, icons)
|
||||
local item_data = H.parse_item(x)
|
||||
@ -3031,14 +3064,15 @@ H.get_fs_type = function(path)
|
||||
if path == '' then return 'none' end
|
||||
if vim.fn.filereadable(path) == 1 then return 'file' end
|
||||
if vim.fn.isdirectory(path) == 1 then return 'directory' end
|
||||
if pcall(vim.uri_to_fname, path) then return 'uri' end
|
||||
if H.parse_uri(path) ~= nil then return 'uri' end
|
||||
return 'none'
|
||||
end
|
||||
|
||||
-- Default preview ------------------------------------------------------------
|
||||
H.preview_file = function(buf_id, item_data, opts)
|
||||
-- Fully preview only text files
|
||||
if not H.is_file_text(item_data.path) then return H.set_buflines(buf_id, { '-Non-text-file-' }) end
|
||||
-- Fully preview only accessible text files
|
||||
local is_text = H.is_file_text(item_data.path)
|
||||
if not is_text then return H.set_buflines(buf_id, { is_text == nil and '-No-access-' or '-Non-text-file-' }) end
|
||||
|
||||
-- Compute lines. Limit number of read lines to work better on large files.
|
||||
local has_lines, lines = pcall(vim.fn.readfile, item_data.path, '', (item_data.lnum or 1) + opts.n_context_lines)
|
||||
@ -3131,9 +3165,7 @@ end
|
||||
H.choose_path = function(win_target, item_data)
|
||||
-- Try to use already created buffer, if present. This avoids not needed
|
||||
-- `:edit` call and avoids some problems with auto-root from 'mini.misc'.
|
||||
local path, path_buf_id = item_data.path, nil
|
||||
local is_uri, uri_path = pcall(vim.uri_to_fname, path)
|
||||
path = is_uri and uri_path or path
|
||||
local path, path_buf_id = H.parse_uri(item_data.path) or item_data.path, nil
|
||||
for _, buf_id in ipairs(vim.api.nvim_list_bufs()) do
|
||||
local is_target = H.is_valid_buf(buf_id) and vim.bo[buf_id].buflisted and vim.api.nvim_buf_get_name(buf_id) == path
|
||||
if is_target then path_buf_id = buf_id end
|
||||
@ -3284,6 +3316,8 @@ end
|
||||
-- Utilities ------------------------------------------------------------------
|
||||
H.error = function(msg) error(string.format('(mini.pick) %s', msg), 0) end
|
||||
|
||||
H.notify = function(msg, level_name) vim.notify('(mini.pick) ' .. msg, vim.log.levels[level_name]) end
|
||||
|
||||
H.is_valid_buf = function(buf_id) return type(buf_id) == 'number' and vim.api.nvim_buf_is_valid(buf_id) end
|
||||
|
||||
H.is_valid_win = function(win_id) return type(win_id) == 'number' and vim.api.nvim_win_is_valid(win_id) end
|
||||
@ -3414,12 +3448,24 @@ end
|
||||
|
||||
H.is_file_text = function(path)
|
||||
local fd = vim.loop.fs_open(path, 'r', 1)
|
||||
if fd == nil then return nil end
|
||||
local is_text = vim.loop.fs_read(fd, 1024):find('\0') == nil
|
||||
vim.loop.fs_close(fd)
|
||||
return is_text
|
||||
end
|
||||
|
||||
H.full_path = function(path) return (vim.fn.fnamemodify(path, ':p'):gsub('(.)/$', '%1')) end
|
||||
if H.is_windows then
|
||||
H.full_path = function(path) return (vim.fn.fnamemodify(path, ':p'):gsub('(.)[\\/]$', '%1')) end
|
||||
end
|
||||
|
||||
H.parse_uri = function(x)
|
||||
local ok, path = pcall(vim.uri_to_fname, x)
|
||||
if not ok then return nil end
|
||||
-- Don't accept Windows paths with volume letter as URI
|
||||
if H.is_windows and x:find('^%a:') ~= nil and path:find('^%a:') ~= nil then return nil end
|
||||
return path
|
||||
end
|
||||
|
||||
-- TODO: Remove after compatibility with Neovim=0.9 is dropped
|
||||
H.islist = vim.fn.has('nvim-0.10') == 1 and vim.islist or vim.tbl_islist
|
||||
|
||||
@ -185,7 +185,7 @@ MiniSessions.read = function(session_name, opts)
|
||||
end
|
||||
|
||||
-- Write current session to allow proper switching between sessions
|
||||
if vim.v.this_session ~= '' then MiniSessions.write(nil, { force = true, verbose = false }) end
|
||||
if H.get_this_session() ~= '' then MiniSessions.write(nil, { force = true, verbose = false }) end
|
||||
|
||||
-- Execute 'pre' hook
|
||||
H.possibly_execute(opts.hooks.pre, data)
|
||||
@ -248,13 +248,16 @@ MiniSessions.write = function(session_name, opts)
|
||||
H.possibly_execute(opts.hooks.pre, data)
|
||||
|
||||
-- Make session file
|
||||
local cmd = ('mksession%s'):format(opts.force and '!' or '')
|
||||
vim.cmd(('%s %s'):format(cmd, vim.fn.fnameescape(session_path)))
|
||||
local command = string.format('mksession%s %s', opts.force and '!' or '', vim.fn.fnameescape(session_path))
|
||||
vim.cmd(command)
|
||||
data.modify_time = vim.fn.getftime(session_path)
|
||||
|
||||
-- Update detected sessions
|
||||
MiniSessions.detected[data.name] = data
|
||||
|
||||
-- Update current session
|
||||
vim.v.this_session = session_path
|
||||
|
||||
-- Possibly notify
|
||||
if opts.verbose then H.message(('Written session %s'):format(session_path)) end
|
||||
|
||||
@ -299,7 +302,7 @@ MiniSessions.delete = function(session_name, opts)
|
||||
if not H.validate_detected(session_name) then return end
|
||||
session_path = MiniSessions.detected[session_name].path
|
||||
|
||||
local is_current_session = session_path == vim.v.this_session
|
||||
local is_current_session = session_path == H.get_this_session()
|
||||
if not opts.force and is_current_session then
|
||||
H.error([[Can't delete current session when `opts.force` is not `true`.]])
|
||||
end
|
||||
@ -441,24 +444,22 @@ H.apply_config = function(config)
|
||||
end
|
||||
|
||||
H.create_autocommands = function(config)
|
||||
local augroup = vim.api.nvim_create_augroup('MiniSessions', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniSessions', {})
|
||||
|
||||
if config.autoread then
|
||||
local autoread = function()
|
||||
if not H.is_something_shown() then MiniSessions.read() end
|
||||
end
|
||||
local opts = { group = augroup, nested = true, once = true, callback = autoread, desc = 'Autoread latest session' }
|
||||
local opts = { group = gr, nested = true, once = true, callback = autoread, desc = 'Autoread latest session' }
|
||||
vim.api.nvim_create_autocmd('VimEnter', opts)
|
||||
end
|
||||
|
||||
if config.autowrite then
|
||||
local autowrite = function()
|
||||
if vim.v.this_session ~= '' then MiniSessions.write(nil, { force = true }) end
|
||||
if H.get_this_session() ~= '' then MiniSessions.write(nil, { force = true }) end
|
||||
end
|
||||
vim.api.nvim_create_autocmd(
|
||||
'VimLeavePre',
|
||||
{ group = augroup, callback = autowrite, desc = 'Autowrite current session' }
|
||||
)
|
||||
local opts = { group = gr, callback = autowrite, desc = 'Autowrite current session' }
|
||||
vim.api.nvim_create_autocmd('VimLeavePre', opts)
|
||||
end
|
||||
end
|
||||
|
||||
@ -506,14 +507,11 @@ H.detect_sessions_global = function(global_dir)
|
||||
end
|
||||
|
||||
H.detect_sessions_local = function(local_file)
|
||||
local f = H.join_path(vim.fn.getcwd(), local_file)
|
||||
|
||||
local f = vim.fn.getcwd() .. '/' .. local_file
|
||||
if not H.is_readable_file(f) then return {} end
|
||||
|
||||
local res = {}
|
||||
local s = H.new_session(f, 'local')
|
||||
res[s.name] = s
|
||||
return res
|
||||
return { [s.name] = s }
|
||||
end
|
||||
|
||||
H.new_session = function(session_path, session_type)
|
||||
@ -547,20 +545,20 @@ H.get_unsaved_listed_buffers = function()
|
||||
)
|
||||
end
|
||||
|
||||
H.get_current_session_name = function() return vim.fn.fnamemodify(vim.v.this_session, ':t') end
|
||||
H.get_this_session = function() return H.fs_normalize(vim.v.this_session) end
|
||||
|
||||
H.name_to_path = function(session_name)
|
||||
if session_name == nil then
|
||||
if vim.v.this_session == '' then H.error('There is no active session. Supply non-nil session name.') end
|
||||
return vim.v.this_session
|
||||
local this_session = H.get_this_session()
|
||||
if this_session == '' then H.error('There is no active session. Supply non-nil session name.') end
|
||||
return this_session
|
||||
end
|
||||
|
||||
session_name = tostring(session_name)
|
||||
if session_name == '' then H.error('Supply non-empty session name.') end
|
||||
|
||||
local session_dir = (session_name == MiniSessions.config.file) and vim.fn.getcwd() or MiniSessions.config.directory
|
||||
local path = H.join_path(session_dir, session_name)
|
||||
return H.full_path(path)
|
||||
return H.full_path(session_dir .. '/' .. session_name)
|
||||
end
|
||||
|
||||
-- Utilities ------------------------------------------------------------------
|
||||
@ -599,11 +597,12 @@ end
|
||||
|
||||
H.is_readable_file = function(path) return vim.fn.isdirectory(path) ~= 1 and vim.fn.getfperm(path):sub(1, 1) == 'r' end
|
||||
|
||||
H.join_path = function(directory, filename)
|
||||
return (string.format('%s/%s', directory, filename):gsub('\\', '/'):gsub('/+', '/'))
|
||||
H.fs_normalize = vim.fs.normalize
|
||||
if vim.fn.has('nvim-0.9') == 0 then
|
||||
H.fs_normalize = function(...) return vim.fs.normalize(...):gsub('(.)/+$', '%1') end
|
||||
end
|
||||
|
||||
H.full_path = function(path) return vim.fn.resolve(vim.fn.fnamemodify(path, ':p')) end
|
||||
H.full_path = function(path) return H.fs_normalize(vim.fn.resolve(vim.fn.fnamemodify(path, ':p'))) end
|
||||
|
||||
H.is_something_shown = function()
|
||||
-- Don't autoread session if Neovim is opened to show something. That is
|
||||
|
||||
@ -385,9 +385,9 @@ MiniStarter.refresh = function(buf_id)
|
||||
if not vim.deep_equal(data.items, old_items) then data.current_item_id = 1 end
|
||||
|
||||
-- Add content
|
||||
vim.api.nvim_buf_set_option(buf_id, 'modifiable', true)
|
||||
vim.bo[buf_id].modifiable = true
|
||||
vim.api.nvim_buf_set_lines(buf_id, 0, -1, false, MiniStarter.content_to_lines(content))
|
||||
vim.api.nvim_buf_set_option(buf_id, 'modifiable', false)
|
||||
vim.bo[buf_id].modifiable = false
|
||||
|
||||
-- Add highlighting
|
||||
H.content_highlight(buf_id)
|
||||
@ -1053,7 +1053,7 @@ end
|
||||
H.apply_config = function(config) MiniStarter.config = config end
|
||||
|
||||
H.create_autocommands = function(config)
|
||||
local augroup = vim.api.nvim_create_augroup('MiniStarter', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniStarter', {})
|
||||
|
||||
if config.autoopen then
|
||||
local on_vimenter = function()
|
||||
@ -1065,11 +1065,11 @@ H.create_autocommands = function(config)
|
||||
vim.cmd('noautocmd lua MiniStarter.open()')
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd(
|
||||
'VimEnter',
|
||||
{ group = augroup, nested = true, once = true, callback = on_vimenter, desc = 'Open on VimEnter' }
|
||||
)
|
||||
local au_opts = { group = gr, nested = true, once = true, callback = on_vimenter, desc = 'Open on VimEnter' }
|
||||
vim.api.nvim_create_autocmd('VimEnter', au_opts)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('ColorScheme', { group = gr, callback = H.create_default_hl, desc = 'Ensure colors' })
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
|
||||
@ -168,9 +168,7 @@ MiniStatusline.config = {
|
||||
-- Whether to use icons by default
|
||||
use_icons = true,
|
||||
|
||||
-- Whether to set Vim's settings for statusline (make it always shown with
|
||||
-- 'laststatus' set to 2).
|
||||
-- To use global statusline, set this to `false` and 'laststatus' to 3.
|
||||
-- Whether to set Vim's settings for statusline (make it always shown)
|
||||
set_vim_settings = true,
|
||||
}
|
||||
--minidoc_afterlines_end
|
||||
@ -510,7 +508,7 @@ H.apply_config = function(config)
|
||||
MiniStatusline.config = config
|
||||
|
||||
-- Set settings to ensure statusline is displayed properly
|
||||
if config.set_vim_settings then vim.o.laststatus = 2 end
|
||||
if config.set_vim_settings and (vim.o.laststatus == 0 or vim.o.laststatus == 1) then vim.o.laststatus = 2 end
|
||||
|
||||
-- Ensure proper 'statusline' values (to not rely on autocommands trigger)
|
||||
H.ensure_content()
|
||||
@ -521,10 +519,10 @@ H.apply_config = function(config)
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniStatusline', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniStatusline', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
au({ 'WinEnter', 'BufWinEnter' }, '*', H.ensure_content, 'Ensure statusline content')
|
||||
@ -535,6 +533,8 @@ H.create_autocommands = function()
|
||||
vim.cmd('redrawstatus')
|
||||
end)
|
||||
au({ 'LspAttach', 'LspDetach' }, '*', track_lsp, 'Track LSP clients')
|
||||
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
|
||||
@ -487,6 +487,9 @@ MiniSurround.setup = function(config)
|
||||
-- Apply config
|
||||
H.apply_config(config)
|
||||
|
||||
-- Define behavior
|
||||
H.create_autocommands()
|
||||
|
||||
-- Create default highlighting
|
||||
H.create_default_hl()
|
||||
end
|
||||
@ -1221,6 +1224,11 @@ H.apply_config = function(config)
|
||||
--stylua: ignore end
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local gr = vim.api.nvim_create_augroup('MiniSurround', {})
|
||||
vim.api.nvim_create_autocmd('ColorScheme', { group = gr, callback = H.create_default_hl, desc = 'Ensure colors' })
|
||||
end
|
||||
|
||||
H.create_default_hl = function() vim.api.nvim_set_hl(0, 'MiniSurround', { default = true, link = 'IncSearch' }) end
|
||||
|
||||
H.is_disabled = function() return vim.g.minisurround_disable == true or vim.b.minisurround_disable == true end
|
||||
@ -1309,20 +1317,20 @@ end
|
||||
|
||||
H.make_surrounding_table = function()
|
||||
-- Extend builtins with data from `config`
|
||||
local surroundings = vim.tbl_deep_extend('force', H.builtin_surroundings, H.get_config().custom_surroundings or {})
|
||||
|
||||
-- Add possibly missing information from default surrounding info
|
||||
for char, info in pairs(surroundings) do
|
||||
local surroundings = vim.deepcopy(H.builtin_surroundings)
|
||||
for char, spec in pairs(H.get_config().custom_surroundings or {}) do
|
||||
local cur_spec = surroundings[char] or {}
|
||||
local default = H.get_default_surrounding_info(char)
|
||||
surroundings[char] = vim.tbl_deep_extend('force', default, info)
|
||||
-- NOTE: Don't use `tbl_deep_extend` to prefer full `input` arrays
|
||||
cur_spec.input = spec.input or cur_spec.input or default.input
|
||||
cur_spec.output = spec.output or cur_spec.output or default.output
|
||||
surroundings[char] = cur_spec
|
||||
end
|
||||
|
||||
-- Use default surrounding info for not supplied single character identifier
|
||||
--stylua: ignore start
|
||||
return setmetatable(surroundings, {
|
||||
__index = function(_, key) return H.get_default_surrounding_info(key) end,
|
||||
})
|
||||
--stylua: ignore end
|
||||
end
|
||||
|
||||
H.get_default_surrounding_info = function(char)
|
||||
@ -1373,7 +1381,7 @@ end
|
||||
|
||||
-- Work with finding surrounding ----------------------------------------------
|
||||
---@param surr_spec table Composed pattern. Last item(s) - extraction template.
|
||||
---@param opts table Options.
|
||||
---@param opts table|nil Options.
|
||||
---@private
|
||||
H.find_surrounding = function(surr_spec, opts)
|
||||
if surr_spec == nil then return end
|
||||
|
||||
@ -89,6 +89,12 @@ MiniTabline.setup = function(config)
|
||||
-- Apply config
|
||||
H.apply_config(config)
|
||||
|
||||
-- Define behavior
|
||||
H.create_autocommands()
|
||||
|
||||
-- Create default highlighting
|
||||
H.create_default_hl()
|
||||
|
||||
-- Function to make tabs clickable
|
||||
vim.api.nvim_exec(
|
||||
[[function! MiniTablineSwitchBuffer(buf_id, clicks, button, mod)
|
||||
@ -96,9 +102,6 @@ MiniTabline.setup = function(config)
|
||||
endfunction]],
|
||||
false
|
||||
)
|
||||
|
||||
-- Create default highlighting
|
||||
H.create_default_hl()
|
||||
end
|
||||
|
||||
--- Module config
|
||||
@ -219,6 +222,11 @@ H.apply_config = function(config)
|
||||
vim.o.tabline = '%!v:lua.MiniTabline.make_tabline_string()'
|
||||
end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local gr = vim.api.nvim_create_augroup('MiniTabline', {})
|
||||
vim.api.nvim_create_autocmd('ColorScheme', { group = gr, callback = H.create_default_hl, desc = 'Ensure colors' })
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
H.create_default_hl = function()
|
||||
local set_default_hl = function(name, data)
|
||||
|
||||
@ -32,6 +32,8 @@
|
||||
---
|
||||
--- - Customizable project specific testing script.
|
||||
---
|
||||
--- - Works on Unix (Linux, MacOS, etc.) and Windows.
|
||||
---
|
||||
--- What it doesn't support:
|
||||
--- - Parallel execution. Due to idea of limiting implementation complexity.
|
||||
---
|
||||
@ -1089,6 +1091,12 @@ MiniTest.new_child_neovim = function()
|
||||
-- Make unique name for `--listen` pipe
|
||||
local job = { address = vim.fn.tempname() }
|
||||
|
||||
if vim.fn.has('win32') == 1 then
|
||||
-- Use special local pipe prefix on Windows with (hopefully) unique name
|
||||
-- Source: https://learn.microsoft.com/en-us/windows/win32/ipc/pipe-names
|
||||
job.address = [[\\.\pipe\mininvim]] .. vim.fn.fnamemodify(job.address, ':t')
|
||||
end
|
||||
|
||||
--stylua: ignore
|
||||
local full_args = {
|
||||
opts.nvim_executable, '--clean', '-n', '--listen', job.address,
|
||||
@ -1625,11 +1633,8 @@ end
|
||||
H.apply_config = function(config) MiniTest.config = config end
|
||||
|
||||
H.create_autocommands = function()
|
||||
local augroup = vim.api.nvim_create_augroup('MiniTest', {})
|
||||
vim.api.nvim_create_autocmd(
|
||||
'ColorScheme',
|
||||
{ group = augroup, callback = H.create_default_hl, desc = 'Ensure proper colors' }
|
||||
)
|
||||
local gr = vim.api.nvim_create_augroup('MiniTest', {})
|
||||
vim.api.nvim_create_autocmd('ColorScheme', { group = gr, callback = H.create_default_hl, desc = 'Ensure colors' })
|
||||
end
|
||||
|
||||
H.create_default_hl = function()
|
||||
|
||||
@ -147,10 +147,10 @@ end
|
||||
H.apply_config = function(config) MiniTrailspace.config = config end
|
||||
|
||||
H.create_autocommands = function(config)
|
||||
local augroup = vim.api.nvim_create_augroup('MiniTrailspace', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniTrailspace', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
-- NOTE: Respecting both `WinEnter` and `BufEnter` seems to be useful to
|
||||
@ -165,6 +165,8 @@ H.create_autocommands = function(config)
|
||||
-- disappears if buffer is reentered.
|
||||
au('OptionSet', 'buftype', H.track_normal_buffer, 'Track normal buffer')
|
||||
end
|
||||
|
||||
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
||||
end
|
||||
|
||||
H.create_default_hl = function() vim.api.nvim_set_hl(0, 'MiniTrailspace', { default = true, link = 'Error' }) end
|
||||
|
||||
@ -1191,6 +1191,9 @@ H.cache = {
|
||||
session_start_time = os.time(),
|
||||
}
|
||||
|
||||
-- File system information
|
||||
H.is_windows = vim.loop.os_uname().sysname == 'Windows_NT'
|
||||
|
||||
-- Helper functionality =======================================================
|
||||
-- Settings -------------------------------------------------------------------
|
||||
H.setup_config = function(config)
|
||||
@ -1224,10 +1227,10 @@ end
|
||||
H.apply_config = function(config) MiniVisits.config = config end
|
||||
|
||||
H.create_autocommands = function(config)
|
||||
local augroup = vim.api.nvim_create_augroup('MiniVisits', {})
|
||||
local gr = vim.api.nvim_create_augroup('MiniVisits', {})
|
||||
|
||||
local au = function(event, pattern, callback, desc)
|
||||
vim.api.nvim_create_autocmd(event, { group = augroup, pattern = pattern, callback = callback, desc = desc })
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
||||
end
|
||||
|
||||
if config.track.event ~= '' then au(config.track.event, '*', H.autoregister_visit, 'Auto register visit') end
|
||||
@ -1500,9 +1503,9 @@ H.error = function(msg) error(string.format('(mini.visits) %s', msg), 0) end
|
||||
H.is_valid_buf = function(buf_id) return type(buf_id) == 'number' and vim.api.nvim_buf_is_valid(buf_id) end
|
||||
|
||||
H.buf_get_path = function(buf_id)
|
||||
-- Get Path only for valid normal buffers
|
||||
-- Get path only for valid normal buffers
|
||||
if not H.is_valid_buf(buf_id) or vim.bo[buf_id].buftype ~= '' then return nil end
|
||||
local res = vim.api.nvim_buf_get_name(buf_id)
|
||||
local res = H.full_path(vim.api.nvim_buf_get_name(buf_id))
|
||||
if res == '' then return end
|
||||
return res
|
||||
end
|
||||
@ -1549,12 +1552,20 @@ H.edit_path = function(path)
|
||||
end
|
||||
end
|
||||
|
||||
H.full_path = function(path) return (vim.fn.fnamemodify(path, ':p'):gsub('\\', '/'):gsub('/+', '/'):gsub('(.)/$', '%1')) end
|
||||
H.full_path = function(path) return (vim.fn.fnamemodify(path, ':p'):gsub('/+', '/'):gsub('(.)/$', '%1')) end
|
||||
if H.is_windows then
|
||||
H.full_path = function(path)
|
||||
return (vim.fn.fnamemodify(path, ':p'):gsub('\\', '/'):gsub('/+', '/'):gsub('(.)/$', '%1'))
|
||||
end
|
||||
end
|
||||
|
||||
H.short_path = function(path, cwd)
|
||||
cwd = cwd or vim.fn.getcwd()
|
||||
if not vim.startswith(path, cwd) then return vim.fn.fnamemodify(path, ':~') end
|
||||
local res = path:sub(cwd:len() + 1):gsub('^/+', ''):gsub('/+$', '')
|
||||
-- Ensure `cwd` is treated as directory path (to not match similar prefix)
|
||||
cwd = cwd:sub(-1) == '/' and cwd or (cwd .. '/')
|
||||
if vim.startswith(path, cwd) then return path:sub(cwd:len() + 1) end
|
||||
local res = vim.fn.fnamemodify(path, ':~')
|
||||
if H.is_windows then res = res:gsub('\\', '/') end
|
||||
return res
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user