nvim: black-format python files on write
This commit is contained in:
parent
01d5bc029f
commit
fb441bc3df
@ -4,6 +4,28 @@ confutil = require("confutil")
|
|||||||
keymap = confutil.keymap
|
keymap = confutil.keymap
|
||||||
|
|
||||||
|
|
||||||
|
------
|
||||||
|
-- python format-on-save
|
||||||
|
-- https://stackoverflow.com/a/77467553
|
||||||
|
------
|
||||||
|
|
||||||
|
-- to turn this off for a session (permanently), run
|
||||||
|
-- :autocmd! AutoFormat
|
||||||
|
-- https://superuser.com/a/1415274
|
||||||
|
vim.api.nvim_create_augroup("AutoFormat", {})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd(
|
||||||
|
"BufWritePost",
|
||||||
|
{
|
||||||
|
pattern = "*.py",
|
||||||
|
group = "AutoFormat",
|
||||||
|
callback = function()
|
||||||
|
vim.cmd("silent !black --quiet %")
|
||||||
|
vim.cmd("edit")
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
------
|
------
|
||||||
-- syntax highlighting
|
-- syntax highlighting
|
||||||
|
Loading…
Reference in New Issue
Block a user