- local aucmd_dict = {
- FileType = {
- {
- -- Set tabstop to 2 for Dart, Vue, JavaScript, TypeScript, and JSON files
- pattern = "dart,vue,javascript,typescript,json,markdown",
- callback = function()
- vim.opt_local.tabstop = 2
- vim.opt_local.softtabstop = 2
- vim.opt_local.shiftwidth = 2
- end,
- },
- {
- pattern = 'dart',
- callback = function ()
- vim.bo.commentstring = '// %s'
- end
- },
- },
-
- BufWritePre = {
- {
- -- Remove trailing whitespace on save
- command = [[%s/\s\+$//e]],
- },
- },
-
- BufRead = {
- {
- -- Return cursor to where it was previously when re-opening a file
- callback = function()
- if vim.fn.expand('%:p') ~= '.git/COMMIT_EDITMSG' and vim.fn.line("'\"") > 1 and vim.fn.line("'\"") <= vim.fn.line("$") then
- vim.cmd("normal! g`\"")
- end
- end
- },
-
- {
- -- Set syntax for Dockerfiles
- pattern = { '*.docker' },
- callback = function()
- vim.opt_local.syntax = 'dockerfile'
- end
- },
-
- {
- pattern = { '*.blade.php' },
- command = [[set syntax=html]],
- },
- },
-
- BufNewFile = {
- {
- -- Set syntax for Dockerfiles
- pattern = { '*.docker' },
- callback = function()
- vim.opt_local.syntax = 'dockerfile'
- 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
-
|