summaryrefslogtreecommitdiff
path: root/lua/talha/autocmds.lua
diff options
context:
space:
mode:
authortalha <talha@talhaamir.xyz>2024-01-03 00:46:34 +0500
committertalha <talha@talhaamir.xyz>2024-01-03 00:46:34 +0500
commite101b978d77ddbce2060c1a8ba898b873a8ed535 (patch)
tree4d0de4ba124be440471a68a0694d3a805c6c017f /lua/talha/autocmds.lua
parent7e1c16b7aefbb253e391dc5b8361621142772e3d (diff)
parentdb929434fa2f29e5674a5f24d71901b4fa458363 (diff)
Merge branch 'main' of ta_git:/var/www/git/nvim
Diffstat (limited to 'lua/talha/autocmds.lua')
-rw-r--r--lua/talha/autocmds.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/lua/talha/autocmds.lua b/lua/talha/autocmds.lua
new file mode 100644
index 0000000..a892fa2
--- /dev/null
+++ b/lua/talha/autocmds.lua
@@ -0,0 +1,19 @@
+local autocmd_group = vim.api.nvim_create_augroup("Custom auto-commands", { clear = true })
+
+vim.api.nvim_create_autocmd({ "BufWritePost" }, {
+ pattern = { "*.py" },
+ desc = "Auto-format python files after saving",
+ callback = function()
+ local filename = vim.api.nvim_buf_get_name(0)
+ vim.cmd(":silent !autopep8 -i " .. filename)
+ vim.cmd(":silent !isort " .. filename)
+ end,
+ group = autocmd_group,
+})
+
+vim.api.nvim_create_autocmd({ "CursorHold" }, {
+ desc = "reload the file on changes",
+ command = "checktime",
+ group = autocmd_group,
+})
+