82 lines
2.4 KiB
Lua
82 lines
2.4 KiB
Lua
-- highlight on yank
|
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
|
group = vim.api.nvim_create_augroup('highlight_yank', {}),
|
|
desc = 'Hightlight selection on yank',
|
|
pattern = '*',
|
|
callback = function()
|
|
vim.highlight.on_yank { higroup = 'IncSearch', timeout = 500 }
|
|
end,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd({ "VimEnter" }, {
|
|
callback = function()
|
|
vim.cmd("hi link illuminatedWord LspReferenceText")
|
|
end,
|
|
})
|
|
|
|
-- go to last loc when opening a buffer
|
|
vim.api.nvim_create_autocmd("BufReadPost", {
|
|
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,
|
|
})
|
|
|
|
-- close some filetypes with <q>
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = {
|
|
"qf",
|
|
"help",
|
|
"man",
|
|
"notify",
|
|
"lspinfo",
|
|
"spectre_panel",
|
|
"startuptime",
|
|
"tsplayground",
|
|
"PlenaryTestPopup",
|
|
},
|
|
callback = function(event)
|
|
vim.bo[event.buf].buflisted = false
|
|
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
|
|
end,
|
|
})
|
|
|
|
-- add spellcheck and wrapping to some file types
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = { "gitcommit", "markdown" },
|
|
callback = function()
|
|
vim.opt_local.wrap = true
|
|
vim.opt_local.spell = true
|
|
end,
|
|
})
|
|
|
|
-- Prevent auto comment on next line
|
|
vim.cmd('autocmd BufEnter * set formatoptions-=cro')
|
|
vim.cmd('autocmd BufEnter * setlocal formatoptions-=cro')
|
|
|
|
-- Set filetype to tex for .tex files?
|
|
vim.cmd([[autocmd BufRead,BufNewFile *.tex set filetype=tex]])
|
|
|
|
-- -- Trim whitespace from files on save, also have utils.trim_whitespace()
|
|
-- vim.cmd([[
|
|
-- autocmd BufWritePre * let currPos = getpos(".")
|
|
-- autocmd BufWritePre * %s/\s\+$//e
|
|
-- autocmd BufWritePre * %s/\n\+\%$//e
|
|
-- autocmd BufWritePre *.[ch] %s/\%$/\r/e
|
|
-- autocmd BufWritePre * cal cursor(currPos[1], currPos[2])
|
|
-- ]])
|
|
|
|
-- Run custom textclear command when exiting a .tex file (cleanup files)
|
|
vim.cmd([[autocmd VimLeave *.tex !texclear %]])
|
|
|
|
vim.api.nvim_create_autocmd("TermOpen", {
|
|
group = vim.api.nvim_create_augroup("custom-term-open", { clear = true }),
|
|
callback = function()
|
|
vim.opt.number = false
|
|
vim.opt.relativenumber = false
|
|
end
|
|
})
|