.config/nvim/lua/config/autocmds.lua

changeset 1087
bfcf9813c223
parent 1086
82f517e1ae76
child 1088
c221227cbba5
equal deleted inserted replaced
1086:82f517e1ae76 1087:bfcf9813c223
12 autocmd(g, "FocusGained", "*", cmd.checktime) 12 autocmd(g, "FocusGained", "*", cmd.checktime)
13 13
14 -- >> autowriteall improvment 14 -- >> autowriteall improvment
15 -- Stopinsert on leave, or autowriteall doesn't work. 15 -- Stopinsert on leave, or autowriteall doesn't work.
16 autocmd(g, { "WinLeave", "FocusLost" }, "*", function() 16 autocmd(g, { "WinLeave", "FocusLost" }, "*", function()
17 if not fn.pumvisible() then 17 if fn.pumvisible() == 0 then
18 fn.stopinsert() 18 fn.stopinsert()
19 end 19 end
20 cmd.wa()
20 end) 21 end)
21
22 -- write all on leave
23 autocmd(g, "FocusLost", "*", cmd.wa)
24 22
25 -- >> auto mkpath on write 23 -- >> auto mkpath on write
26 autocmd(g, "BufWritePre", "*", { 24 autocmd(g, "BufWritePre", "*", {
27 callback = function(ctx) 25 callback = function(ctx)
28 if vim.bo[ctx.buf].buftype == "" and not string.match(ctx.file, "^[%w]+:") then 26 if vim.bo[ctx.buf].buftype == "" and not string.match(ctx.file, "^[%w]+:") then

mercurial