nvim/lua/config/isort.lua

13 lines
459 B
Lua
Raw Normal View History

2024-06-08 01:17:42 +02:00
vim.api.nvim_create_autocmd( { "BufWritePre" }, {
2024-05-23 08:33:22 +02:00
pattern = { "*.py", "*.pyi" },
2024-06-08 22:26:33 +02:00
callback = function(ev)
2024-06-13 10:52:43 +02:00
local old_cursor = vim.api.nvim_win_get_cursor(0)
2024-06-08 22:26:33 +02:00
vim.api.nvim_command([[ :silent! %!/usr/bin/env isort -q - ]])
2024-06-13 10:52:43 +02:00
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
2024-06-08 22:26:33 +02:00
end
2024-05-23 08:33:22 +02:00
})