mirror of
https://github.com/iofq/nvim.nix.git
synced 2026-01-23 08:55:16 -06:00
custom dart tabline
This commit is contained in:
parent
d7ae87e671
commit
9457c7436e
12 changed files with 424 additions and 51 deletions
|
|
@ -426,8 +426,8 @@ hi(0, 'MiniMapSymbolCount', { link = 'Special' })
|
|||
hi(0, 'MiniMapSymbolLine', { link = 'Title' })
|
||||
hi(0, 'MiniMapSymbolView', { link = 'Delimiter' })
|
||||
hi(0, 'MiniNotifyBorder', { link = 'FloatBorder' })
|
||||
hi(0, 'MiniNotifyNormal', { link = 'NormalFloat' })
|
||||
hi(0, 'MiniNotifyTitle', { link = 'FloatTitle' })
|
||||
hi(0, 'MiniNotifyNormal', { link = 'Normal' })
|
||||
hi(0, 'MiniNotifyTitle', { link = 'Title' })
|
||||
hi(0, 'MiniOperatorsExchangeFrom', { link = 'IncSearch' })
|
||||
hi(0, 'MiniPickBorder', { link = 'FloatBorder' })
|
||||
hi(0, 'MiniPickBorderBusy', { link = 'DiagnosticFloatingWarn' })
|
||||
|
|
@ -463,13 +463,13 @@ hi(0, 'MiniStatuslineModeReplace', { bg = '#e85c51', bold = true, fg = '#0f1c1e'
|
|||
hi(0, 'MiniStatuslineModeVisual', { bg = '#ad5c7c', bold = true, fg = '#0f1c1e' })
|
||||
hi(0, 'MiniSurround', { link = 'IncSearch' })
|
||||
hi(0, 'MiniTablineCurrent', { bg = '#2d4f56', bold = true, fg = '#cbd9d8' })
|
||||
hi(0, 'MiniTablineFill', { link = 'TabLineFill' })
|
||||
hi(0, 'MiniTablineHidden', { bg = '#1d3337', fg = '#587b7b' })
|
||||
hi(0, 'MiniTablineModifiedCurrent', { bg = '#cbd9d8', bold = true, fg = '#2d4f56' })
|
||||
hi(0, 'MiniTablineModifiedHidden', { bg = '#587b7b', fg = '#1d3337' })
|
||||
hi(0, 'MiniTablineModifiedVisible', { bg = '#cbd9d8', fg = '#1d3337' })
|
||||
hi(0, 'MiniTablineTabpagesection', { bg = '#152528', bold = true, fg = '#e6eaea' })
|
||||
hi(0, 'MiniTablineModifiedCurrent', { bg = '#688888', bold = true, fg = '#1d3337' })
|
||||
hi(0, 'MiniTablineVisible', { bg = '#1d3337', fg = '#cbd9d8' })
|
||||
hi(0, 'MiniTablineModifiedVisible', { bg = '#587b7b', fg = '#1d3337' })
|
||||
hi(0, 'MiniTablineTabpagesection', { bg = '#152528', bold = true, fg = '#e6eaea' })
|
||||
hi(0, 'MiniTablineFill', { link = 'TabLineFill' })
|
||||
-- hi(0, 'MiniTablineHidden', { bg = '#1d3337', fg = '#587b7b' })
|
||||
-- hi(0, 'MiniTablineModifiedHidden', { bg = '#587b7b', fg = '#1d3337' })
|
||||
hi(0, 'MiniTestEmphasis', { bold = true })
|
||||
hi(0, 'MiniTestFail', { bold = true, fg = '#e85c51' })
|
||||
hi(0, 'MiniTestPass', { bold = true, fg = '#7aa4a1' })
|
||||
|
|
|
|||
|
|
@ -1,27 +1,28 @@
|
|||
vim.opt.autowrite = true
|
||||
|
||||
vim.opt.backspace = 'indent,eol,start'
|
||||
vim.opt.confirm = true
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
vim.opt.cmdheight = 1
|
||||
vim.opt.diffopt = 'internal,filler,closeoff,inline:char'
|
||||
vim.opt.expandtab = true -- insert tabs as spaces
|
||||
vim.opt.expandtab = true -- insert tabs as spaces
|
||||
vim.o.foldenable = true
|
||||
vim.o.foldmethod = 'expr' -- use tree-sitter for folding method
|
||||
vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
|
||||
vim.o.foldlevelstart = 99
|
||||
vim.opt.inccommand = 'split' -- incremental live completion
|
||||
vim.opt.inccommand = 'split' -- incremental live completion
|
||||
vim.opt.list = true
|
||||
vim.opt.nrformats:append('alpha') -- let Ctrl-a do letters as well
|
||||
vim.opt.path:append('**') -- enable fuzzy :find ing
|
||||
vim.opt.path:append('**') -- enable fuzzy :find ing
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.shadafile = 'NONE' -- disable shada
|
||||
vim.opt.shiftwidth = 0 -- >> shifts by tabstop
|
||||
vim.opt.showmatch = true -- highlight matching brackets
|
||||
vim.opt.shadafile = 'NONE' -- disable shada
|
||||
vim.opt.shiftwidth = 0 -- >> shifts by tabstop
|
||||
vim.opt.showmatch = true -- highlight matching brackets
|
||||
vim.opt.signcolumn = 'no'
|
||||
vim.opt.softtabstop = -1 -- backspace removes tabstop
|
||||
vim.opt.softtabstop = -1 -- backspace removes tabstop
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.tabstop = 2 -- 2 space tabs are based
|
||||
vim.opt.updatetime = 250 -- decrease update time
|
||||
vim.opt.tabstop = 2 -- 2 space tabs are based
|
||||
vim.opt.updatetime = 250 -- decrease update time
|
||||
vim.opt.virtualedit = 'onemore'
|
||||
vim.opt.winborder = 'single'
|
||||
vim.cmd('colorscheme iofq')
|
||||
|
|
@ -83,18 +84,24 @@ vim.api.nvim_create_autocmd({ 'FileType' }, {
|
|||
|
||||
-- random keymaps
|
||||
vim.keymap.set({ 'v', 'i' }, 'wq', '<esc>l', { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '<S-l>', vim.cmd.bnext, { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '<S-h>', vim.cmd.bprev, { noremap = true, silent = true })
|
||||
vim.keymap.set({ 'v', 'n' }, 'q:', '<nop>')
|
||||
vim.keymap.set('v', '<', '<gv')
|
||||
vim.keymap.set('v', '>', '>gv')
|
||||
vim.keymap.set('n', 'n', 'nzz', { noremap = true })
|
||||
vim.keymap.set('n', 'N', 'Nzz', { noremap = true })
|
||||
vim.keymap.set('n', '<C-u>', '<C-u>zz', { noremap = true })
|
||||
vim.keymap.set('n', '<C-d>', '<C-d>zz', { noremap = true })
|
||||
vim.keymap.set('v', '<A-j>', ":m '>+1<CR>gv=gv", { desc = 'move selection down' })
|
||||
vim.keymap.set('v', '<A-k>', ":m '<-2<CR>gv=gv", { desc = 'move selection up' })
|
||||
vim.keymap.set({ 'v', 'n' }, 'q:', '<nop>')
|
||||
vim.keymap.set('n', 'gq', vim.cmd.bdelete, { noremap = true, silent = true, desc = 'close buffer' })
|
||||
vim.keymap.set('n', 'gQ', function()
|
||||
vim.cmd('bufdo bdelete')
|
||||
end, { noremap = true, silent = true, desc = 'close all buffers' })
|
||||
|
||||
-- custom tabline
|
||||
local dart = require('plugins.lib.dart')
|
||||
dart.setup()
|
||||
|
||||
-- resize splits if window got resized
|
||||
vim.api.nvim_create_autocmd({ 'VimResized' }, {
|
||||
group = vim.api.nvim_create_augroup('resize_splits', { clear = true }),
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ return {
|
|||
draw = {
|
||||
treesitter = { 'lsp' },
|
||||
columns = {
|
||||
{ 'label', 'label_description', gap = 1 },
|
||||
{ 'source_name', 'kind', gap = 1 },
|
||||
{ 'label', 'label_description', gap = 1 },
|
||||
{ 'source_name', 'kind', gap = 1 },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -79,5 +79,9 @@ return {
|
|||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require('blink.cmp').setup(opts)
|
||||
vim.treesitter.language.register('markdown', 'blink-cmp-documentation')
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
361
nvim/lua/plugins/lib/dart.lua
Normal file
361
nvim/lua/plugins/lib/dart.lua
Normal file
|
|
@ -0,0 +1,361 @@
|
|||
local Dart = {}
|
||||
local M = {}
|
||||
|
||||
-- table of {bufnr = int, mark = string}
|
||||
M.state = {}
|
||||
|
||||
Dart.setup = function(config)
|
||||
config = M.setup_config(config)
|
||||
M.apply_config(config)
|
||||
M.create_autocommands()
|
||||
M.create_default_hl()
|
||||
|
||||
_G.Dart = Dart
|
||||
end
|
||||
|
||||
M.config = {
|
||||
-- list of characters to use to mark 'pinned' buffers
|
||||
-- the characters will be chosen for new pins in order
|
||||
marklist = { 'a', 's', 'd', 'f', 'q', 'w', 'e', 'r' },
|
||||
-- list of characters to use to mark recent buffers
|
||||
-- we track the last #buflist opened buffers to display on the left side of the tabline
|
||||
buflist = { 'z', 'x', 'c' },
|
||||
|
||||
mappings = {
|
||||
mark = '<leader>mm',
|
||||
jump = '<leader>m',
|
||||
pick = '<leader>mp',
|
||||
next = '<S-l>',
|
||||
prev = '<S-h>',
|
||||
},
|
||||
}
|
||||
|
||||
M.setup_config = function(config)
|
||||
M.config = vim.tbl_deep_extend('force', M.config, config or {})
|
||||
return M.config
|
||||
end
|
||||
|
||||
M.apply_config = function(config)
|
||||
-- built list of all marks (buf + pin) to sort tabline by
|
||||
M.order = {}
|
||||
for i, key in ipairs(vim.list_extend(vim.deepcopy(config.buflist), config.marklist)) do
|
||||
M.order[key] = i
|
||||
end
|
||||
|
||||
vim.opt.showtabline = 2
|
||||
vim.opt.tabline = '%!v:lua.Dart.gen_tabline()'
|
||||
|
||||
-- setup keymaps
|
||||
local function map(mode, lhs, rhs, opts)
|
||||
if lhs == '' then
|
||||
return
|
||||
end
|
||||
opts = vim.tbl_deep_extend('force', { silent = true }, opts or {})
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
end
|
||||
|
||||
map('n', config.mappings.mark, Dart.mark, { desc = 'Dart: mark current buffer' })
|
||||
map('n', config.mappings.jump, function()
|
||||
Dart.jump(vim.fn.getcharstr())
|
||||
end, { desc = 'Dart: jump to buffer' })
|
||||
map('n', config.mappings.pick, Dart.pick, { desc = 'Dart: pick buffer' })
|
||||
map('n', config.mappings.next, Dart.next, { desc = 'Dart: next buffer' })
|
||||
map('n', config.mappings.prev, Dart.prev, { desc = 'Dart: prev buffer' })
|
||||
end
|
||||
|
||||
M.create_autocommands = function()
|
||||
local group = vim.api.nvim_create_augroup('Dart', {})
|
||||
|
||||
-- cleanup deleted buffers
|
||||
vim.api.nvim_create_autocmd('BufDelete', {
|
||||
group = group,
|
||||
callback = function(args)
|
||||
M.del_by_bufnr(args.buf)
|
||||
end,
|
||||
})
|
||||
|
||||
-- track last n opened buffers
|
||||
vim.api.nvim_create_autocmd({ 'BufWinEnter', 'BufAdd' }, {
|
||||
group = group,
|
||||
callback = function(args)
|
||||
M.shift_buflist(args.buf)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Clickable tabs
|
||||
vim.api.nvim_exec2(
|
||||
[[function! SwitchBuffer(buf_id, clicks, button, mod)
|
||||
execute 'buffer' a:buf_id
|
||||
endfunction]],
|
||||
{}
|
||||
)
|
||||
end
|
||||
|
||||
-- Use Mini Tabline for default highlights, since it's well supported by many colorschemes
|
||||
-- override the foreground for labels to be more visible
|
||||
M.create_default_hl = function()
|
||||
local set_default_hl = function(name, opts)
|
||||
opts.default = true
|
||||
vim.api.nvim_set_hl(0, name, opts)
|
||||
end
|
||||
|
||||
local override_label = function(hl, link)
|
||||
local prev = vim.api.nvim_get_hl(0, { name = link })
|
||||
vim.api.nvim_set_hl(0, hl, { bg = prev.bg, fg = 'orange', bold = true })
|
||||
end
|
||||
|
||||
-- Current selection
|
||||
set_default_hl('DartCurrent', { link = 'MiniTablineCurrent' })
|
||||
override_label('DartCurrentLabel', 'MiniTablineCurrent')
|
||||
|
||||
-- Current selection if modified
|
||||
set_default_hl('DartCurrentModified', { link = 'MiniTablineModifiedCurrent' })
|
||||
override_label('DartCurrentLabelModified', 'MiniTablineModifiedCurrent')
|
||||
|
||||
-- Visible but not selected
|
||||
set_default_hl('DartVisible', { link = 'MiniTablineVisible' })
|
||||
override_label('DartVisibleLabel', 'MiniTablineVisible')
|
||||
|
||||
-- Visible and modified but not selected
|
||||
set_default_hl('DartVisibleModified', { link = 'MiniTablineModifiedVisible' })
|
||||
override_label('DartVisibleLabelModified', 'MiniTablineModifiedVisible')
|
||||
|
||||
-- Fill
|
||||
set_default_hl('DartFill', { link = 'MiniTablineFill' })
|
||||
end
|
||||
|
||||
M.get_state_by_field = function(field, value)
|
||||
for _, m in ipairs(M.state) do
|
||||
if m[field] == value then
|
||||
return m
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.state_from_bufnr = function(bufnr)
|
||||
return M.get_state_by_field('bufnr', bufnr)
|
||||
end
|
||||
|
||||
M.state_from_mark = function(mark)
|
||||
return M.get_state_by_field('mark', mark)
|
||||
end
|
||||
|
||||
M.del_by_bufnr = function(bufnr)
|
||||
for i, m in ipairs(M.state) do
|
||||
if m.bufnr == bufnr then
|
||||
table.remove(M.state, i)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.should_show = function(bufnr)
|
||||
return vim.api.nvim_buf_is_valid(bufnr) -- buffer exists and is loaded
|
||||
and vim.api.nvim_buf_is_loaded(bufnr)
|
||||
and vim.bo[bufnr].buflisted -- don't show hidden buffers
|
||||
and vim.bo[bufnr].buftype == '' -- don't show pickers, prompts, etc.
|
||||
and vim.api.nvim_buf_get_name(bufnr) ~= '' -- don't show unnamed files
|
||||
end
|
||||
|
||||
M.next_unused_mark = function()
|
||||
for _, m in ipairs(M.config.marklist) do
|
||||
if not M.state_from_mark(m) then
|
||||
return m
|
||||
end
|
||||
end
|
||||
return 'Z'
|
||||
end
|
||||
|
||||
M.shift_buflist = function(bufnr)
|
||||
if M.state_from_bufnr(bufnr) or not M.should_show(bufnr) then
|
||||
return
|
||||
end
|
||||
|
||||
local buflist = M.config.buflist
|
||||
|
||||
-- if there's a free buflist mark, set it
|
||||
for _, mark in ipairs(buflist) do
|
||||
if not M.state_from_mark(mark) then
|
||||
M.mark(bufnr, mark)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- if not, shift buflist right and set new buffer to element 1
|
||||
for i = #buflist, 2, -1 do
|
||||
local mark = M.state_from_mark(buflist[i])
|
||||
local next = M.state_from_mark(buflist[i - 1])
|
||||
mark.bufnr = next.bufnr
|
||||
end
|
||||
M.state_from_mark(buflist[1]).bufnr = bufnr
|
||||
end
|
||||
|
||||
-- param direction -1 for prev, 1 for next
|
||||
M.cycle_tabline = function(direction)
|
||||
local cur = vim.api.nvim_get_current_buf()
|
||||
for i, m in ipairs(M.state) do
|
||||
if cur == m.bufnr then
|
||||
local next = ((i + direction - 1) % #M.state) + 1 -- wrap around list
|
||||
if M.state[next] then
|
||||
vim.api.nvim_set_current_buf(M.state[next].bufnr)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.gen_tabpage = function()
|
||||
local n_tabpages = vim.fn.tabpagenr('$')
|
||||
if n_tabpages == 1 then
|
||||
return ''
|
||||
end
|
||||
return string.format('%%= Tab %d/%d ', vim.fn.tabpagenr(), n_tabpages)
|
||||
end
|
||||
|
||||
M.gen_tabline_item = function(item)
|
||||
local bufnr = item.bufnr
|
||||
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ':t')
|
||||
local is_current = bufnr == vim.api.nvim_get_current_buf()
|
||||
local modified = vim.bo[bufnr].modified and 'Modified' or ''
|
||||
|
||||
local hl_label = is_current and 'DartCurrentLabel' or 'DartVisibleLabel'
|
||||
local label = item.mark ~= '' and item.mark .. ' ' or ''
|
||||
local hl = is_current and 'DartCurrent' or 'DartVisible'
|
||||
local content = filename ~= '' and filename or '*'
|
||||
|
||||
return {
|
||||
bufnr = bufnr,
|
||||
hl_label = hl_label .. modified,
|
||||
label = label,
|
||||
hl = hl .. modified,
|
||||
content = content,
|
||||
}
|
||||
end
|
||||
|
||||
M.format_tabline_item = function(item)
|
||||
local click = string.format('%%%s@SwitchBuffer@', item.bufnr)
|
||||
return string.format('%%#%s#%s %s%%#%s#%s %%X', item.hl_label, click, item.label, item.hl, item.content)
|
||||
end
|
||||
|
||||
M.mark = function(bufnr, mark)
|
||||
if not bufnr then
|
||||
bufnr = vim.api.nvim_get_current_buf()
|
||||
end
|
||||
if not M.should_show(bufnr) then
|
||||
return
|
||||
end
|
||||
if not mark then
|
||||
mark = M.next_unused_mark()
|
||||
end
|
||||
|
||||
local exists = M.state_from_bufnr(bufnr)
|
||||
if not exists then
|
||||
table.insert(M.state, { bufnr = bufnr, mark = mark })
|
||||
elseif vim.tbl_contains(M.config.buflist, exists.mark) then
|
||||
exists.mark = mark -- allow for re-marking buffers in the buflist
|
||||
else
|
||||
return -- skip sort if no change
|
||||
end
|
||||
table.sort(M.state, function(a, b)
|
||||
return (M.order[a.mark] or 998) < (M.order[b.mark] or 999)
|
||||
end)
|
||||
vim.cmd.redrawtabline()
|
||||
end
|
||||
|
||||
Dart.state = M.state
|
||||
Dart.mark = M.mark
|
||||
|
||||
Dart.jump = function(mark)
|
||||
local m = M.state_from_mark(mark)
|
||||
if m and m.bufnr then
|
||||
vim.api.nvim_set_current_buf(m.bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
Dart.pick = function()
|
||||
local prompt = { 'Jump to buffer:' }
|
||||
for _, mark in ipairs(M.state) do
|
||||
local name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(mark.bufnr), ':t')
|
||||
table.insert(prompt, string.format(' %s → %s', mark.mark, name))
|
||||
end
|
||||
|
||||
local selected = vim.fn.input(table.concat(prompt, '\n') .. '\n> ')
|
||||
Dart.jump(selected)
|
||||
end
|
||||
|
||||
Dart.next = function()
|
||||
M.cycle_tabline(1)
|
||||
end
|
||||
|
||||
Dart.prev = function()
|
||||
M.cycle_tabline(-1)
|
||||
end
|
||||
|
||||
Dart.gen_tabline = function()
|
||||
local items = {}
|
||||
local center = 1
|
||||
local cur = vim.api.nvim_get_current_buf()
|
||||
local columns = vim.o.columns
|
||||
|
||||
for i, m in ipairs(M.state) do
|
||||
if M.should_show(m.bufnr) then
|
||||
table.insert(items, M.gen_tabline_item(m))
|
||||
if m.bufnr == cur then
|
||||
center = i
|
||||
end
|
||||
else
|
||||
M.del_by_bufnr(m.bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
local function width(tabline)
|
||||
return vim.api.nvim_strwidth(table.concat(
|
||||
vim.tbl_map(function(m)
|
||||
return string.format(' %s %s ', m.label, m.content)
|
||||
end, tabline),
|
||||
''
|
||||
)) + 3 -- save room for trunc
|
||||
end
|
||||
|
||||
local result = { items[center] }
|
||||
local left = center - 1
|
||||
local right = center + 1
|
||||
local trunc_left = false
|
||||
local trunc_right = false
|
||||
|
||||
while left >= 1 or right <= #items do
|
||||
local added = false
|
||||
|
||||
if left >= 1 then
|
||||
table.insert(result, 1, items[left])
|
||||
if width(result) >= columns then
|
||||
table.remove(result, 1)
|
||||
trunc_left = true
|
||||
else
|
||||
left = left - 1
|
||||
added = true
|
||||
end
|
||||
end
|
||||
if right <= #items then
|
||||
table.insert(result, items[right])
|
||||
if width(result) >= columns then
|
||||
table.remove(result)
|
||||
trunc_right = true
|
||||
else
|
||||
right = right + 1
|
||||
added = true
|
||||
end
|
||||
end
|
||||
if not added then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return (trunc_left and '%#DartVisibleLabel# < ' or '')
|
||||
.. table.concat(vim.tbl_map(M.format_tabline_item, result), '')
|
||||
.. (trunc_right and '%#DartVisibleLabel# > ' or '')
|
||||
.. '%X%#DartFill#'
|
||||
.. M.gen_tabpage()
|
||||
end
|
||||
|
||||
return Dart
|
||||
|
|
@ -50,7 +50,7 @@ M.load = function()
|
|||
-- load session (buffers, etc) as well as shada (marks)
|
||||
sessions.read(id)
|
||||
vim.cmd('rshada')
|
||||
Snacks.notify('loaded jj session: ' .. id)
|
||||
vim.notify('loaded jj session: ' .. id)
|
||||
end
|
||||
end)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ M.marks = function()
|
|||
['local'] = false,
|
||||
on_show = function()
|
||||
vim.cmd.delmarks { args = { '0-9' } }
|
||||
vim.cmd.delmarks { args = { '"' } }
|
||||
end,
|
||||
actions = {
|
||||
markdel = function(picker)
|
||||
for _, item in ipairs(picker:selected()) do
|
||||
for _, item in ipairs(picker:selected { fallback = true }) do
|
||||
vim.cmd.delmarks { args = { item.label } }
|
||||
end
|
||||
vim.cmd('wshada')
|
||||
|
|
@ -18,7 +19,7 @@ M.marks = function()
|
|||
},
|
||||
win = {
|
||||
input = {
|
||||
keys = { ['<c-x>'] = 'markdel' },
|
||||
keys = { ['<c-x>'] = { 'markdel', mode = { 'n', 'i' } } },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ function M.revs()
|
|||
picker:close()
|
||||
if item then
|
||||
if not item.rev then
|
||||
Snacks.notify.warn('No branch or commit found', { title = 'Snacks Picker' })
|
||||
vim.notify.warn('No branch or commit found', { title = 'Snacks Picker' })
|
||||
return
|
||||
end
|
||||
local cmd = { 'jj', 'new', '-r', item.rev }
|
||||
Snacks.picker.util.cmd(cmd, function()
|
||||
Snacks.notify('Checking out revision: ' .. item.rev, { title = 'Snacks Picker' })
|
||||
vim.notify('Checking out revision: ' .. item.rev, { title = 'Snacks Picker' })
|
||||
vim.cmd.checktime()
|
||||
require('plugins.lib.session_jj').load()
|
||||
end, { cwd = item.cwd })
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ return {
|
|||
'\\f',
|
||||
function()
|
||||
vim.b.disable_autoformat = not vim.b.disable_autoformat
|
||||
Snacks.notify(string.format('Buffer formatting disabled: %s', vim.b.disable_autoformat))
|
||||
vim.notify(string.format('Buffer formatting disabled: %s', vim.b.disable_autoformat))
|
||||
end,
|
||||
mode = { 'n', 'x' },
|
||||
desc = 'toggle buffer formatting',
|
||||
|
|
@ -102,7 +102,7 @@ return {
|
|||
'\\F',
|
||||
function()
|
||||
vim.g.disable_autoformat = not vim.g.disable_autoformat
|
||||
Snacks.notify(string.format('Global formatting disabled: %s', vim.g.disable_autoformat))
|
||||
vim.notify(string.format('Global formatting disabled: %s', vim.g.disable_autoformat))
|
||||
end,
|
||||
mode = { 'n', 'x' },
|
||||
desc = 'toggle global formatting',
|
||||
|
|
|
|||
|
|
@ -47,21 +47,6 @@ return {
|
|||
},
|
||||
config = function()
|
||||
require('mini.basics').setup { mappings = { windows = true } }
|
||||
require('mini.tabline').setup {
|
||||
tabpage_section = 'right',
|
||||
show_icons = false,
|
||||
format = function(buf_id, label) -- show global marks in tab
|
||||
local default = MiniTabline.default_format(buf_id, label)
|
||||
for _, mark in ipairs(vim.fn.getmarklist()) do
|
||||
if mark.pos[1] == buf_id then
|
||||
if mark.mark:match("^'[A-Z]$") then
|
||||
return ' [' .. mark.mark:sub(2) .. ']' .. default
|
||||
end
|
||||
end
|
||||
end
|
||||
return default
|
||||
end,
|
||||
}
|
||||
require('mini.statusline').setup {
|
||||
content = {
|
||||
active = function()
|
||||
|
|
@ -73,11 +58,11 @@ return {
|
|||
|
||||
return MiniStatusline.combine_groups {
|
||||
'%<', -- Mark general truncate point
|
||||
-- { hl = 'MiniStatuslineFilename', strings = { filename } },
|
||||
'%=', -- End left alignment
|
||||
-- { hl = 'MiniStatuslineDevinfo', strings = { filename } },
|
||||
{ hl = 'MiniStatuslineDevinfo', strings = { diagnostics, lsp } },
|
||||
{ hl = 'MiniStatuslineDevinfo', strings = { search } },
|
||||
{ hl = mode_hl, strings = { mode } },
|
||||
{ hl = mode_hl, strings = { mode } },
|
||||
}
|
||||
end,
|
||||
inactive = function()
|
||||
|
|
@ -124,7 +109,7 @@ return {
|
|||
local jj_sesh = require('plugins.lib.session_jj')
|
||||
local jj_id = jj_sesh.get_id()
|
||||
if jj_sesh.check_exists(jj_id) then
|
||||
Snacks.notify('Existing session for ' .. jj_id)
|
||||
vim.notify('Existing session for ' .. jj_id)
|
||||
end
|
||||
|
||||
local jump = require('mini.jump2d')
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@ return {
|
|||
{
|
||||
'MeanderingProgrammer/render-markdown.nvim',
|
||||
event = 'VeryLazy',
|
||||
config = true,
|
||||
opts = {
|
||||
completions = {
|
||||
blink = { enabled = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'sindrets/diffview.nvim',
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ return {
|
|||
quickfile = { enabled = true },
|
||||
notifier = {
|
||||
enabled = true,
|
||||
timeout = 5000,
|
||||
timeout = 4000,
|
||||
},
|
||||
styles = {
|
||||
notification = {
|
||||
|
|
@ -21,6 +21,9 @@ return {
|
|||
words = { enabled = true },
|
||||
picker = {
|
||||
enabled = true,
|
||||
jump = {
|
||||
reuse_win = true,
|
||||
},
|
||||
matcher = {
|
||||
frecency = true,
|
||||
history_bonus = true,
|
||||
|
|
@ -38,9 +41,9 @@ return {
|
|||
smart = {
|
||||
multi = {
|
||||
'marks',
|
||||
{ source = 'buffers', current = false },
|
||||
{ source = 'buffers', current = false },
|
||||
'recent',
|
||||
{ source = 'files', hidden = true },
|
||||
{ source = 'files', hidden = true },
|
||||
{ source = 'git_files', untracked = true },
|
||||
},
|
||||
},
|
||||
|
|
@ -94,6 +97,7 @@ return {
|
|||
'<leader><leader>',
|
||||
function()
|
||||
vim.cmd.delmarks { args = { '0-9' } }
|
||||
vim.cmd.delmarks { args = { '"' } }
|
||||
Snacks.picker.smart()
|
||||
end,
|
||||
desc = 'Fuzzy find smart',
|
||||
|
|
@ -175,6 +179,13 @@ return {
|
|||
end,
|
||||
desc = 'pick notifications',
|
||||
},
|
||||
{
|
||||
'gO',
|
||||
function()
|
||||
Snacks.picker.treesitter()
|
||||
end,
|
||||
desc = 'pick treesitter nodes',
|
||||
},
|
||||
{
|
||||
'<leader>fm',
|
||||
function()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue