From 32de71752457551f96433f9aff5fba81950d8245 Mon Sep 17 00:00:00 2001 From: Oxbian Date: Tue, 25 Jul 2023 00:02:49 +0200 Subject: Setting up formatting for python --- .vim/after/ftplugin/python.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to '.vim/after') diff --git a/.vim/after/ftplugin/python.vim b/.vim/after/ftplugin/python.vim index bd158fa..41b1d88 100644 --- a/.vim/after/ftplugin/python.vim +++ b/.vim/after/ftplugin/python.vim @@ -1,5 +1,4 @@ " Python - let g:lsp_settings = {} let g:lsp_settings['pylsp-all'] = \ { @@ -18,3 +17,14 @@ let g:lsp_settings['pylsp-all'] = \ } \ }} \ } + +" Define a custom function that executes :LspDocumentFormat and :!isort +if !exists('*FormatPythonFile') + function! FormatPythonFile() + silent execute '!black %' + silent execute '!isort %' + endfunction +endif +" Remap the custom function to ldf +nnoremap ldf :call FormatPythonFile() + -- cgit v1.2.3