diff options
author | Oxbian <got.dacs@slmail.me> | 2023-07-25 00:02:49 +0200 |
---|---|---|
committer | Oxbian <got.dacs@slmail.me> | 2023-07-25 00:02:49 +0200 |
commit | 32de71752457551f96433f9aff5fba81950d8245 (patch) | |
tree | e1a8c5b85dd7e2548baaaa526d8186abd6c55b10 /.vim/after/ftplugin | |
parent | 15aa4257ee97af243573c43644b35cf6ddbc0b25 (diff) | |
download | vimrc-32de71752457551f96433f9aff5fba81950d8245.tar.gz vimrc-32de71752457551f96433f9aff5fba81950d8245.zip |
Setting up formatting for python
Diffstat (limited to '.vim/after/ftplugin')
-rw-r--r-- | .vim/after/ftplugin/python.vim | 12 |
1 files changed, 11 insertions, 1 deletions
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 <leader>ldf +nnoremap <leader>ldf :call FormatPythonFile()<CR> + |