add autoformatting with Python
This commit is contained in:
parent
25a94d9353
commit
743c03a1b6
3 changed files with 29 additions and 1 deletions
10
lua/autocmds.lua
Normal file
10
lua/autocmds.lua
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
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 !black --preview -q " .. fileName)
|
||||
vim.cmd(":silent !isort --profile black --float-to-top -q " .. fileName)
|
||||
end,
|
||||
group = autocmd_group,
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue