My own portable configs with vendored deps, mostly usable everywhere
at main 25 lines 628 B view raw
1vim.api.nvim_create_augroup('AutoFormatting', {}) 2 3-- General case: use LSP 4vim.api.nvim_create_autocmd('BufWritePre', { 5 pattern = '*.lua', 6 group = 'AutoFormatting', 7 callback = function() 8 vim.lsp.buf.format() 9 end, 10}) 11 12-- OCaml: ocamllsp doesn't call ocamlformat (manual call) 13local opam_bin = vim.fn.trim(vim.fn.system('opam var bin')) 14local ocamlformat_bin = opam_bin .. "/ocamlformat" 15vim.api.nvim_create_autocmd( 16 "BufWritePost", 17 { 18 pattern = "*.ml,*.mli", 19 group = "AutoFormatting", 20 callback = function() 21 vim.cmd(" silent !" .. ocamlformat_bin .. " -i %") 22 vim.cmd("edit") 23 end, 24 } 25)