41 lines
852 B
Lua
41 lines
852 B
Lua
-- Terminals should open with insert mode
|
|
vim.api.nvim_create_autocmd({ "BufEnter", "TermEnter", "WinEnter" }, {
|
|
pattern = "term://*",
|
|
callback = function()
|
|
if vim.bo.buftype == "terminal" then
|
|
vim.schedule(function()
|
|
vim.cmd("startinsert")
|
|
end)
|
|
end
|
|
end
|
|
})
|
|
|
|
-- Start treesitter
|
|
vim.api.nvim_create_autocmd('FileType', {
|
|
pattern = '*',
|
|
callback = function(ev)
|
|
if ev.match ~= "odin" then
|
|
pcall(vim.treesitter.start)
|
|
end
|
|
end,
|
|
})
|
|
|
|
-- highlights yanked text
|
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
|
callback = function()
|
|
vim.highlight.on_yank({
|
|
higroup = "IncSearch",
|
|
timeout = 200,
|
|
})
|
|
end,
|
|
})
|
|
|
|
-- removes trailing whitespace on save
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
callback = function()
|
|
local save_cursor = vim.fn.getpos(".")
|
|
vim.cmd([[%s/\s\+$//e]])
|
|
vim.fn.setpos(".", save_cursor)
|
|
end,
|
|
})
|