Skip to content

Commit 88cfc94

Browse files
committed
Add command to run Python isort
1 parent d0ddb50 commit 88cfc94

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

after/ftplugin/python.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,15 @@ if (vim.o.textwidth or 0) > 0 then
33
macchiato_line_length = vim.o.textwidth
44
end
55
vim.opt_local.formatprg = 'black-macchiato -l ' .. macchiato_line_length
6+
7+
vim.keymap.set('n', '<leader>is', function()
8+
local bufnr = vim.api.nvim_get_current_buf()
9+
local modified = vim.api.nvim_get_option_value("modified", { buf = bufnr })
10+
11+
if modified then
12+
print('*** Save your changes first!' ***)
13+
return
14+
end
15+
local file_name = vim.api.nvim_buf_get_name(0) -- Get file name of file in current buffer
16+
vim.cmd(":!isort -l 1000000 --wl 0 --sl " .. file_name)
17+
end, { desc = 'Run isort on the current buffer' })

0 commit comments

Comments
 (0)