You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

83 lines
2.0 KiB

local aucmd_dict = {
FileType = {
{
-- Set tabstop to 2 for Dart, Vue, JavaScript, TypeScript, and JSON files
pattern = "dart,vue,javascript,typescript,json",
callback = function()
vim.opt_local.tabstop = 2
vim.opt_local.softtabstop = 2
vim.opt_local.shiftwidth = 2
end,
},
},
BufWritePre = {
{
-- Remove trailing whitespace on save
command = [[%s/\s\+$//e]],
},
{
-- Run goimports on save
pattern = "*.go",
callback = function()
require('go.format').goimport()
end,
},
},
BufRead = {
{
-- Return cursor to where it was previously when re-opening a file
command = [[if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif]]
},
{
-- Set syntax for Dockerfiles
pattern = { '*.docker' },
callback = function()
vim.opt_local.syntax = 'dockerfile'
end
},
{
pattern = { '*.blade.php' },
callback = function()
vim.opt_local.syntax = 'html'
end
},
},
BufNewFile = {
{
-- Set syntax for Dockerfiles
pattern = { '*.docker' },
callback = function()
vim.opt_local.syntax = 'dockerfile'
end
},
{
pattern = { '*.blade.php' },
callback = function()
vim.opt_local.syntax = 'html'
end
},
},
VimLeave = {
{
-- Save session on exit
callback = function()
require('retrospect').SaveSession()
end,
},
},
}
for event, opt_tbls in pairs(aucmd_dict) do
for _, opt_tbl in pairs(opt_tbls) do
vim.api.nvim_create_autocmd(event, opt_tbl)
end
end