diff --git a/after/ftplugin/python.lua b/after/ftplugin/python.lua new file mode 100644 index 0000000..b64b458 --- /dev/null +++ b/after/ftplugin/python.lua @@ -0,0 +1,25 @@ +-- Deactivate fold for python files + +vim.opt.foldlevel = 99 + +-- Ruff import sorting and formatting + +vim.api.nvim_create_autocmd("BufWritePre", { + buffer = 0, + callback = function() + -- Tri des imports via code action Ruff + local clients = vim.lsp.get_clients({ bufnr = 0 }) + for _, c in ipairs(clients) do + if c.name == "ruff" then + vim.lsp.buf.code_action({ + context = { only = { "source.organizeImports.ruff" } }, + apply = true, + }) + break + end + end + -- Formatage du code + vim.lsp.buf.format({ async = false }) + end, +}) +