local augroup = vim.api.nvim_create_augroup local autocmd = vim.api.nvim_create_autocmd -- Restore cursor position 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, }) -- Help and man pages in vertical split local help_config = augroup("HelpConfig", { clear = true }) autocmd("FileType", { group = help_config, pattern = { "help", "man" }, command = "wincmd L", }) -- Terminal settings local term_config = augroup("TermConfig", { clear = true }) autocmd("TermOpen", { group = term_config, pattern = "*", command = "setlocal nonumber norelativenumber", }) local highlight_yank = augroup("HighlightYank", { clear = true }) autocmd("TextYankPost", { group = highlight_yank, pattern = "*", callback = function() vim.highlight.on_yank({ higroup = "IncSearch", timeout = 420 }) end, }) 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 ]]) -- 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 -- })