local function augroup(name)
return vim.api.nvim_create_augroup(name, { clear = true })
end
vim.api.nvim_create_autocmd("FileType", {
group = augroup("close_with_q"),
pattern = {
-- "help",
"PlenaryTestPopup",
"checkhealth",
"dbout",
"gitsigns-blame",
"grug-far",
"help",
"neotest-output",
"neotest-output-panel",
"neotest-summary",
"notify",
"snacks_win",
"spectre_panel",
"startuptime",
"tsplayground",
"lspinfo",
"man",
"notify",
"qf",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})
vim.api.nvim_create_autocmd("TextYankPost", {
group = augroup("highlight_yank"),
callback = function()
vim.highlight.on_yank()
end,
})
--[[
vim.api.nvim_create_autocmd({ "VimResized" }, {
group = augroup("resize_splits"),
callback = function()
vim.cmd("tabdo wincmd =")
end,
})
]]
-- Auto create dir when saving a file, in case some intermediate directory does not exist
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
group = augroup("auto_create_dir"),
callback = function(event)
if event.match:match("^%w%w+://") then
return
end
local file = vim.loop.fs_realpath(event.match) or event.match
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end,
})
-- Automatically save session to Neovim's state directory
vim.api.nvim_create_autocmd("VimLeavePre", {
callback = function()
--[[ if vim.fn.exists(":Neotree") == 2 then
vim.cmd("Neotree close")
end ]]
if vim.v.this_session == "" then
local session_path = vim.fn.stdpath("state") .. "/sessions/tmp"
vim.cmd("mksession! " .. session_path)
end
end,
desc = "Save session to 'stdpath(state)/session' when no active session exists",
})
-- go to last loc when opening a buffer
vim.api.nvim_create_autocmd("BufReadPost", {
group = augroup("last_loc"),
callback = function()
local exclude = { "gitcommit" }
local buf = vim.api.nvim_get_current_buf()
if vim.tbl_contains(exclude, vim.bo[buf].filetype) then
return
end
local mark = vim.api.nvim_buf_get_mark(buf, '"')
local lcount = vim.api.nvim_buf_line_count(buf)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
--[[ vim.api.nvim_create_autocmd("LspProgress", {
callback = function(ev)
local spinner = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }
vim.notify(vim.lsp.status(), "info", {
id = "lsp_progress",
title = "LSP Progress",
opts = function(notif)
notif.icon = ev.data.params.value.kind == "end" and " "
or spinner[math.floor(vim.uv.hrtime() / (1e6 * 80)) % #spinner + 1]
end,
})
end,
}) ]]
- init
- readme
- LuaSnip
- ftpugin
- lsp
-
lua
-
└──
core
- └── init
- └── keymaps
- └── lazy-bootstrap
- └── options
-
└──
lazy-plugins
- └── ai
- └── cmp
- └── colorscheme
- └── edit
- └── external
- └── filemanager
- └── format
- └── fun
- └── git
- └── lines
- └── lsp
- └── md
- └── nav
- └── snack
- └── start
- └── tex
- └── treesitter
- └── typst
- └── ui
- └── utils
-
└──
util
- └── latex
-
└──
core
-
plugin
- └── autocmds
- └── commands
- └── fold
- └── highlight
- └── lsp
-
snipmate
-
└──
lua
- └── nvim
- └── markdown
-
└──
tex
- └── abbre
- └── templates
-
└──
lua