From 22850e4c2cee741b9e46717e53b8baa6c4a972bb Mon Sep 17 00:00:00 2001 From: Michaƫl Ball Date: Wed, 26 Feb 2025 12:25:19 +0000 Subject: Autoformat python on save --- neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'neovim/.config/nvim/lua') diff --git a/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua b/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua index fbae976..19e2eb4 100644 --- a/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua +++ b/neovim/.config/nvim/lua/plugins/nvim_lspconfig.lua @@ -145,6 +145,19 @@ return { vim.diagnostic.enable(false, { bufnr = args.buf }) end, }) + + vim.api.nvim_create_autocmd({ "BufWritePost" }, { + pattern = '*.py', + callback = function() + vim.lsp.buf.code_action { + context = { + only = { 'source.fixAll.ruff' }, + }, + apply = true, + } + vim.lsp.buf.format { async = true } + end + }) end, }, } -- cgit v1.2.3