filetypes: set rules for python filetype
- Disables forlding. - Lets Ruff sort imports and format file content on save. Co-Authored-by: iGor milhit <igor@milhit.ch>main
parent
ccecc89a42
commit
a111e23eec
|
|
@ -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,
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue