feat(nvim): minify copnfig
This commit is contained in:
parent
772322333c
commit
58703c4bf8
4 changed files with 79 additions and 38 deletions
|
|
@ -3,8 +3,6 @@ vim.pack.add({
|
|||
'https://github.com/monaqa/dial.nvim',
|
||||
'https://github.com/catgoose/nvim-colorizer.lua',
|
||||
'https://github.com/echasnovski/mini.pairs',
|
||||
'https://github.com/echasnovski/mini.misc',
|
||||
'https://github.com/nvim-mini/mini.bufremove',
|
||||
'https://github.com/tpope/vim-abolish',
|
||||
'https://github.com/tpope/vim-sleuth',
|
||||
'https://github.com/kylechui/nvim-surround',
|
||||
|
|
@ -202,34 +200,6 @@ return {
|
|||
end,
|
||||
event = 'BufReadPre',
|
||||
},
|
||||
{
|
||||
'echasnovski/mini.misc',
|
||||
after = function()
|
||||
require('mini.misc').setup()
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
'<c-w>m',
|
||||
"<cmd>lua MiniMisc.zoom(0, { title = '', border = 'none' })<cr>",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'nvim-mini/mini.bufremove',
|
||||
after = function()
|
||||
require('mini.bufremove').setup()
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
'<leader>bd',
|
||||
'<cmd>lua MiniBufremove.delete()<cr>',
|
||||
},
|
||||
{
|
||||
'<leader>bw',
|
||||
'<cmd>lua MiniBufremove.wipeout()<cr>',
|
||||
},
|
||||
},
|
||||
},
|
||||
{ 'tpope/vim-abolish', event = 'DeferredUIEnter' },
|
||||
{ 'tpope/vim-sleuth', event = 'BufReadPost' },
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,14 +60,6 @@
|
|||
"rev": "4b0a6207341d895b6cfe9bcb1e4d3e8607bfe4f4",
|
||||
"src": "https://github.com/echasnovski/mini.ai"
|
||||
},
|
||||
"mini.bufremove": {
|
||||
"rev": "ee69f823f84508c556127a5882760d9783692023",
|
||||
"src": "https://github.com/nvim-mini/mini.bufremove"
|
||||
},
|
||||
"mini.misc": {
|
||||
"rev": "de8947231c29012271722651aa07f6749c41d1ed",
|
||||
"src": "https://github.com/echasnovski/mini.misc"
|
||||
},
|
||||
"mini.pairs": {
|
||||
"rev": "b7fde3719340946feb75017ef9d75edebdeb0566",
|
||||
"src": "https://github.com/echasnovski/mini.pairs"
|
||||
|
|
|
|||
40
config/nvim/plugin/bufremove.lua
Normal file
40
config/nvim/plugin/bufremove.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
-- https://github.com/echasnovski/mini.bufremove/blob/main/lua/mini/bufremove.lua#L86
|
||||
|
||||
---@param wipeout? boolean
|
||||
local function bufremove(wipeout)
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
local cmd = wipeout and 'bwipeout' or 'bdelete'
|
||||
|
||||
if vim.bo[buf].modified then
|
||||
local ok = vim.fn.confirm(
|
||||
('Buffer %d has unsaved changes. Force %s?'):format(buf, cmd),
|
||||
'&No\n&Yes', 1, 'Question'
|
||||
) == 2
|
||||
if not ok then return end
|
||||
end
|
||||
|
||||
for _, win in ipairs(vim.fn.win_findbuf(buf)) do
|
||||
vim.api.nvim_win_call(win, function()
|
||||
if vim.fn.getcmdwintype() ~= '' then
|
||||
vim.cmd('close!')
|
||||
return
|
||||
end
|
||||
local alt = vim.fn.bufnr('#')
|
||||
if alt ~= buf and vim.fn.buflisted(alt) == 1 then
|
||||
vim.api.nvim_win_set_buf(win, alt)
|
||||
elseif pcall(vim.cmd, 'bprevious') and buf ~= vim.api.nvim_win_get_buf(win) then
|
||||
return
|
||||
else
|
||||
vim.api.nvim_win_set_buf(win, vim.api.nvim_create_buf(true, false))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local ok, err = pcall(vim.cmd, ('%s! %d'):format(cmd, buf))
|
||||
if not ok and not (err:find('E516%D') or err:find('E517%D') or err:find('E11%D')) then
|
||||
vim.notify(err, vim.log.levels.ERROR)
|
||||
end
|
||||
end
|
||||
|
||||
vim.keymap.set('n', '<leader>bd', function() bufremove() end)
|
||||
vim.keymap.set('n', '<leader>bw', function() bufremove(true) end)
|
||||
39
config/nvim/plugin/zoom.lua
Normal file
39
config/nvim/plugin/zoom.lua
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
-- https://github.com/echasnovski/mini.misc/blob/main/lua/mini/misc.lua#L838
|
||||
|
||||
---@type integer?
|
||||
local zoom_winid = nil
|
||||
|
||||
local function zoom()
|
||||
if zoom_winid and vim.api.nvim_win_is_valid(zoom_winid) then
|
||||
vim.api.nvim_win_close(zoom_winid, true)
|
||||
zoom_winid = nil
|
||||
return
|
||||
end
|
||||
local cfg = {
|
||||
relative = 'editor',
|
||||
row = 0,
|
||||
col = 0,
|
||||
width = vim.o.columns,
|
||||
height = vim.o.lines - vim.o.cmdheight,
|
||||
border = 'none',
|
||||
}
|
||||
zoom_winid = vim.api.nvim_open_win(0, true, cfg)
|
||||
vim.cmd.normal('zz', { bang = true })
|
||||
vim.api.nvim_create_autocmd('VimResized', {
|
||||
group = vim.api.nvim_create_augroup('Zoom', { clear = true }),
|
||||
callback = function()
|
||||
if not (zoom_winid and vim.api.nvim_win_is_valid(zoom_winid)) then
|
||||
return
|
||||
end
|
||||
vim.api.nvim_win_set_config(zoom_winid, {
|
||||
relative = 'editor',
|
||||
row = 0,
|
||||
col = 0,
|
||||
width = vim.o.columns,
|
||||
height = vim.o.lines - vim.o.cmdheight,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
vim.keymap.set('n', '<c-w>m', zoom)
|
||||
Loading…
Add table
Add a link
Reference in a new issue