aboutsummaryrefslogtreecommitdiff
path: root/lua/custom-autocmd.lua
diff options
context:
space:
mode:
authorjdhao <jdhao@hotmail.com>2022-09-10 23:55:22 +0800
committerjdhao <jdhao@hotmail.com>2022-09-10 23:55:22 +0800
commitaaeb6a813a9044892e5bb76ba4a3a61db08eae4d (patch)
tree6a1dc5a4f79f08678bdb8903a7920e8545718fa7 /lua/custom-autocmd.lua
parent9ba728e201657892681cafc2c6fe8ad997873b49 (diff)
format with stylua
Diffstat (limited to 'lua/custom-autocmd.lua')
-rw-r--r--lua/custom-autocmd.lua17
1 files changed, 8 insertions, 9 deletions
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index b9be923..9d85fda 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -3,7 +3,6 @@ local api = vim.api
local utils = require("utils")
-
-- Display a message when the current file is not in utf-8 format.
-- Note that we need to use `unsilent` command here because of this issue:
-- https://github.com/vim/vim/issues/4379
@@ -11,10 +10,10 @@ api.nvim_create_autocmd({ "BufRead" }, {
pattern = "*",
group = api.nvim_create_augroup("non_utf8_file", { clear = true }),
callback = function()
- if vim.bo.fileencoding ~= 'utf-8' then
+ if vim.bo.fileencoding ~= "utf-8" then
vim.notify("File not in UTF-8 format!", vim.log.levels.WARN, { title = "nvim-config" })
end
- end
+ end,
})
-- highlight yanked region, see `:h lua-highlight`
@@ -23,7 +22,7 @@ api.nvim_create_autocmd({ "TextYankPost" }, {
group = api.nvim_create_augroup("highlight_yank", { clear = true }),
callback = function()
vim.highlight.on_yank { higroup = "YankColor", timeout = 300 }
- end
+ end,
})
-- Auto-generate packer_compiled.lua file
@@ -34,7 +33,7 @@ api.nvim_create_autocmd({ "BufWritePost" }, {
local cmd = "source " .. ctx.file
vim.cmd(cmd)
vim.cmd("PackerCompile")
- end
+ end,
})
-- Auto-create dir when saving a file, in case some intermediate directory does not exist
@@ -44,7 +43,7 @@ api.nvim_create_autocmd({ "BufWritePre" }, {
callback = function(ctx)
local dir = fn.fnamemodify(ctx.file, ":p:h")
utils.may_create_dir(dir)
- end
+ end,
})
-- Automatically reload the file if it is changed outside of Nvim, see https://unix.stackexchange.com/a/383044/221410.
@@ -57,17 +56,17 @@ api.nvim_create_autocmd({ "FileChangedShellPost" }, {
group = "auto_read",
callback = function()
vim.notify("File changed on disk. Buffer reloaded!", vim.log.levels.WARN, { title = "nvim-config" })
- end
+ end,
})
api.nvim_create_autocmd({ "FocusGained", "CursorHold" }, {
pattern = "*",
group = "auto_read",
callback = function()
- if fn.getcmdwintype() == '' then
+ if fn.getcmdwintype() == "" then
vim.cmd("checktime")
end
- end
+ end,
})
-- Resize all windows when we resize the terminal