nixvim/config/auto_cmds.nix
Roel de Cort 48bbb7951d
feat: autopairs, cursor restore and rename option (#15)
Add the nvim-autopairs so "'{[ characters will auto close.
Add AutoCmd to restore the cursor position when re-opening file.
Fix treesitter option name.
2024-07-25 22:57:29 +02:00

75 lines
1.5 KiB
Nix

{
autoGroups = {
highlight_yank = {};
vim_enter = {};
indentscope = {};
restore_cursor = {};
};
autoCmd = [
{
group = "highlight_yank";
event = ["TextYankPost"];
pattern = "*";
callback = {
__raw = ''
function()
vim.highlight.on_yank()
end
'';
};
}
{
group = "vim_enter";
event = ["VimEnter"];
pattern = "*";
callback = {
__raw = ''
function()
vim.cmd('Startup')
end
'';
};
}
{
group = "indentscope";
event = ["FileType"];
pattern = [
"help"
"Startup"
"startup"
"neo-tree"
"Trouble"
"trouble"
"notify"
];
callback = {
__raw = ''
function()
vim.b.miniindentscope_disable = true
end
'';
};
}
## from NVChad https://nvchad.com/docs/recipes (this autocmd will restore the cursor position when opening a file)
{
group = "restore_cursor";
event = ["BufReadPost"];
pattern = "*";
callback = {
__raw = ''
function()
if
vim.fn.line "'\"" > 1
and vim.fn.line "'\"" <= vim.fn.line "$"
and vim.bo.filetype ~= "commit"
and vim.fn.index({ "xxd", "gitrebase" }, vim.bo.filetype) == -1
then
vim.cmd "normal! g`\""
end
end
'';
};
}
];
}