2022-10-01 11:46:18 +00:00
|
|
|
vim.cmd("autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif")
|
|
|
|
|
|
|
|
-- Highlight Yanked Text
|
|
|
|
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
|
|
|
|
callback = function()
|
|
|
|
vim.highlight.on_yank({ higroup = "Visual", timeout = 200 })
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
2022-10-02 15:38:01 +00:00
|
|
|
-- Set expandtab=true in several file types
|
2022-10-01 11:46:18 +00:00
|
|
|
vim.api.nvim_create_autocmd({ "FileType" }, {
|
2022-10-19 18:06:39 +00:00
|
|
|
pattern = { "go", "makefile", "lua" },
|
2022-10-01 11:46:18 +00:00
|
|
|
callback = function()
|
|
|
|
vim.opt_local.expandtab = false
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Use 'q' to quit from common plugins
|
|
|
|
vim.api.nvim_create_autocmd({ "FileType" }, {
|
2022-10-14 18:40:51 +00:00
|
|
|
pattern = { "qf", "help", "man", "lspinfo" },
|
2022-10-01 11:46:18 +00:00
|
|
|
callback = function()
|
|
|
|
vim.cmd([[
|
|
|
|
nnoremap <silent> <buffer> q :close<CR>
|
|
|
|
set nobuflisted
|
|
|
|
]])
|
|
|
|
end,
|
|
|
|
})
|
2022-11-01 17:14:36 +00:00
|
|
|
|
|
|
|
-- Disable illuminate on very large files
|
|
|
|
vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
|
|
|
|
callback = function()
|
|
|
|
local line_count = vim.api.nvim_buf_line_count(0)
|
|
|
|
if line_count >= 5000 then
|
|
|
|
vim.cmd("IlluminatePauseBuf")
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
2022-12-15 18:50:32 +00:00
|
|
|
|
|
|
|
-- Autostore session on VimExit
|
|
|
|
local session = require("projections.session")
|
|
|
|
vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
|
|
|
|
callback = function()
|
|
|
|
session.store(vim.loop.cwd())
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
-- If vim was started with arguments, do nothing
|
|
|
|
-- If in some project's root, attempt to restore that project's session
|
|
|
|
-- If not, restore last session
|
|
|
|
-- If no sessions, do nothing
|
|
|
|
vim.api.nvim_create_autocmd({ "VimEnter" }, {
|
|
|
|
callback = function()
|
|
|
|
if vim.fn.argc() ~= 0 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local session_info = session.info(vim.loop.cwd())
|
|
|
|
if session_info == nil then
|
|
|
|
session.restore_latest()
|
|
|
|
else
|
|
|
|
session.restore(vim.loop.cwd())
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
desc = "Restore last session automatically",
|
|
|
|
})
|