2025-02-14 01:48:45 -08:00
|
|
|
local augroup = vim.api.nvim_create_augroup
|
|
|
|
local autocmd = vim.api.nvim_create_autocmd
|
|
|
|
|
|
|
|
-- Restore cursor position
|
2025-02-14 17:34:12 -08:00
|
|
|
local restore_cursor = augroup("RestoreCursor", { clear = true })
|
|
|
|
autocmd("BufReadPost", {
|
|
|
|
group = restore_cursor,
|
|
|
|
callback = function()
|
|
|
|
local mark = vim.api.nvim_buf_get_mark(0, '"')
|
|
|
|
local lcount = vim.api.nvim_buf_line_count(0)
|
|
|
|
if mark[1] > 0 and mark[1] <= lcount then
|
|
|
|
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
|
|
|
end
|
|
|
|
end,
|
2025-02-14 01:48:45 -08:00
|
|
|
})
|
|
|
|
|
|
|
|
-- Help and man pages in vertical split
|
2025-02-14 17:34:12 -08:00
|
|
|
local help_config = augroup("HelpConfig", { clear = true })
|
|
|
|
autocmd("FileType", {
|
|
|
|
group = help_config,
|
|
|
|
pattern = { "help", "man" },
|
|
|
|
command = "wincmd L",
|
2025-02-14 01:48:45 -08:00
|
|
|
})
|
|
|
|
|
|
|
|
-- Terminal settings
|
2025-02-14 17:34:12 -08:00
|
|
|
local term_config = augroup("TermConfig", { clear = true })
|
|
|
|
autocmd("TermOpen", {
|
|
|
|
group = term_config,
|
|
|
|
pattern = "*",
|
|
|
|
command = "setlocal nonumber norelativenumber",
|
2025-02-14 01:48:45 -08:00
|
|
|
})
|
|
|
|
|
2025-02-14 17:34:12 -08:00
|
|
|
local highlight_yank = augroup("HighlightYank", { clear = true })
|
|
|
|
autocmd("TextYankPost", {
|
|
|
|
group = highlight_yank,
|
|
|
|
pattern = "*",
|
|
|
|
callback = function()
|
|
|
|
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 420 })
|
|
|
|
end,
|
2025-02-14 01:48:45 -08:00
|
|
|
})
|
|
|
|
|
2025-02-14 17:34:12 -08:00
|
|
|
function disable_for_dashboard()
|
|
|
|
local buftype = vim.api.nvim_buf_get_option(0, "buftype")
|
|
|
|
local filetype = vim.api.nvim_buf_get_option(0, "filetype")
|
|
|
|
if buftype == "nofile" and filetype == "dashboard" then
|
|
|
|
vim.b.indent_blankline_enabled = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
vim.cmd([[
|
|
|
|
augroup IndentBlankline
|
|
|
|
autocmd!
|
|
|
|
autocmd FileType dashboard lua disable_for_dashboard()
|
|
|
|
augroup END
|
|
|
|
]])
|
|
|
|
|
2025-02-14 01:48:45 -08:00
|
|
|
-- Code actions on cursor hold
|
|
|
|
-- local code_action = augroup('CodeAction', { clear = true })
|
|
|
|
-- autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
|
|
|
-- group = code_action,
|
|
|
|
-- callback = function()
|
|
|
|
-- if vim.tbl_isempty(vim.lsp.buf_get_clients()) then
|
|
|
|
-- require('code_action_utils').code_action_listener()
|
|
|
|
-- end
|
|
|
|
-- end
|
2025-02-14 13:46:24 -08:00
|
|
|
-- })
|