1
0
Fork 0

begin nvim config cleanup

This commit is contained in:
Arthur Khachaturov 2024-08-25 07:52:04 +03:00
parent d2d85c8cff
commit 4ecc5566b4
No known key found for this signature in database
GPG key ID: CAC2B7EB6DF45D55
37 changed files with 326 additions and 476 deletions

View file

@ -1,31 +1,15 @@
local M = { }
local function try_quit(command)
local success, errorMsg = pcall(vim.api.nvim_command, command)
if not success then
print("Failed to quit: " .. errorMsg)
end
end
function M.close_buffer(force)
local buf_cmd = "bd"
local quit_cmd = "qa"
if #vim.fn.filter(vim.fn.range(1, vim.fn.bufnr '$'), 'buflisted(v:val)') <= 1 then
vim.api.nvim_command("qa" .. (force and "!" or ""))
else
local tree = require("nvim-tree.api").tree
if force then
buf_cmd = "bd!"
quit_cmd = "qa!"
end
local tree = require("nvim-tree.api").tree
local buffer_count = #vim.fn.filter(vim.fn.range(1, vim.fn.bufnr '$'), 'buflisted(v:val)')
if buffer_count == 1 or buffer_count == 0 then
try_quit(quit_cmd)
else
tree.toggle({ focus = false })
try_quit(buf_cmd)
tree.toggle({ focus = false })
end
tree.toggle({ focus = false })
vim.api.nvim_command("bd" .. (force and "!" or ""))
tree.toggle({ focus = false })
end
end
return M

View file

@ -1,18 +1,18 @@
local M = { }
function M.lazy_init()
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
}
end
vim.opt.rtp:prepend(lazypath)
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable',
lazypath,
}
end
vim.opt.rtp:prepend(lazypath)
end
return M