12 lines
478 B
Lua
12 lines
478 B
Lua
vim.api.nvim_create_autocmd( { "BufWritePre" }, {
|
|
pattern = { "*.py", "*.pyi" },
|
|
callback = function(ev)
|
|
local old_cursor = vim.api.nvim_win_get_cursor(0)
|
|
vim.api.nvim_command([[ :silent! %!/usr/bin/env black -q --stdin-filename % - ]])
|
|
local new_cursor = vim.api.nvim_win_get_cursor(0)
|
|
|
|
if old_cursor[1] ~= new_cursor[1] or old_cursor[2] ~= new_cursor[2] then
|
|
vim.cmd.normal(vim.api.nvim_replace_termcodes('<C-o>', true, true, true))
|
|
end
|
|
end
|
|
})
|