aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxbian <got.dacs@slmail.me>2023-07-25 00:02:49 +0200
committerOxbian <got.dacs@slmail.me>2023-07-25 00:02:49 +0200
commit32de71752457551f96433f9aff5fba81950d8245 (patch)
treee1a8c5b85dd7e2548baaaa526d8186abd6c55b10
parent15aa4257ee97af243573c43644b35cf6ddbc0b25 (diff)
downloadvimrc-32de71752457551f96433f9aff5fba81950d8245.tar.gz
vimrc-32de71752457551f96433f9aff5fba81950d8245.zip
Setting up formatting for python
-rw-r--r--.vim/after/ftplugin/python.vim12
-rw-r--r--.vim/keymaps.vim41
-rw-r--r--.vim/plugins.vim18
3 files changed, 39 insertions, 32 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>
+
diff --git a/.vim/keymaps.vim b/.vim/keymaps.vim
index 57f9e8d..5827003 100644
--- a/.vim/keymaps.vim
+++ b/.vim/keymaps.vim
@@ -38,47 +38,47 @@ nnoremap <C-s> :w!<CR>
"""""""""""""""""""""""""
" Close the current buffer
-map <leader>bd :Bclose<cr>:tabclose<cr>gT
+noremap <leader>bd :Bclose<cr>:tabclose<cr>gT
" Close all the buffers
-map <leader>ba :bufdo bd<cr>
+noremap <leader>ba :bufdo bd<cr>
" Go to the next buffer
-map <leader>bn :bnext<cr>
+noremap <leader>bn :bnext<cr>
" Go to the previous buffer
-map <leader>bp :bprevious<cr>
+noremap <leader>bp :bprevious<cr>
""""""""""""""""""""""""""""
" Tabs
"""""""""""""""""""""""""""
" Open a new tab
-map <leader>tn :tabnew<cr>
+noremap <leader>tn :tabnew<cr>
" Close all others tab
-map <leader>to :tabonly<cr>
+noremap <leader>to :tabonly<cr>
" Close current tab page
-map <leader>tc :tabclose<cr>
+noremap <leader>tc :tabclose<cr>
" Move tabs after another
-map <leader>tm :tabmove
+noremap <leader>tm :tabmove
" Go to the next tab
-map <leader>t<leader> :tabnext<cr>
+noremap <leader>t<leader> :tabnext<cr>
" Let 'tl' toggle between this and the last accessed tab
let g:lasttab = 1
-nmap <leader>tl :exe "tabn ".g:lasttab<CR>
+nnoremap <leader>tl :exe "tabn ".g:lasttab<CR>
au TabLeave * let g:lasttab = tabpagenr()
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
-map <leader>te :tabedit <C-r>=escape(expand("%:p:h"), " ")<cr>/
+noremap <leader>te :tabedit <C-r>=escape(expand("%:p:h"), " ")<cr>/
" Switch CWD to the directory of the open buffer
-map <leader>cd :cd %:p:h<cr>:pwd<cr>
+noremap <leader>cd :cd %:p:h<cr>:pwd<cr>
" Specify the behavior when switching between buffers
try
@@ -91,10 +91,10 @@ endtry
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
""""""""""""""""""""""""
-" NerdTree
+" Fern
"""""""""""""""""""""""
-" Toggle nerdtree
+" Toggle fern tree view
nnoremap <C-f> :Fern .<CR>
""""""""""""""""""""
@@ -129,19 +129,19 @@ set laststatus=2
"""""""""""""""""""""
" Toggle and untoggle spell checking
-map <leader>ss :setlocal spell!<cr>
+noremap <leader>ss :setlocal spell!<cr>
" Next word to spellcheck
-map <leader>sn ]s
+noremap <leader>sn ]s
" Previous word to spellcheck
-map <leader>sp [s
+noremap <leader>sp [s
" Add word into the spellcheck dictionnary
-map <leader>sa zg
+noremap <leader>sa zg
" show the list of alternatives for the word
-map <leader>s? z=
+noremap <leader>s? z=
"""""""""""""""""""
" LSP
@@ -177,6 +177,3 @@ nnoremap <leader>la :LspCodeAction<cr>
" Hover information
nnoremap <leader>lh :LspHover<cr>
-" Format document
-nnoremap <leader>ldf :LspDocumentFormat<cr>
-
diff --git a/.vim/plugins.vim b/.vim/plugins.vim
index 5d17b17..add6b38 100644
--- a/.vim/plugins.vim
+++ b/.vim/plugins.vim
@@ -79,15 +79,15 @@ let g:fern_renderer_devicons_disable_warning = 1
" Multi window select in which you open the file
function! s:init_fern() abort
" Use 'select' instead of 'edit' for default 'open' action
- nmap <buffer> <Plug>(fern-action-open) <Plug>(fern-action-open:select)
-
- nmap <buffer> a <Plug>(fern-action-new-path)
- nmap <buffer> d <Plug>(fern-action-remove)
- nmap <buffer> m <Plug>(fern-action-move)
- nmap <buffer> r <Plug>(fern-action-rename)
- nmap <buffer> v <Plug>(fern-action-open:vsplit)
- nmap <buffer> ga <Plug>(fern-action-git-stage)
- nmap <buffer> gd <Plug>(fern-action-git-unstage)
+ nnoremap <buffer> <Plug>(fern-action-open) <Plug>(fern-action-open:select)
+
+ nnoremap <buffer> a <Plug>(fern-action-new-path)
+ nnoremap <buffer> d <Plug>(fern-action-remove)
+ nnoremap < <buffer> m <Plug>(fern-action-move)
+ nnoremap <buffer> r <Plug>(fern-action-rename)
+ nnoremap <buffer> v <Plug>(fern-action-open:vsplit)
+ nnoremap <buffer> ga <Plug>(fern-action-git-stage)
+ nnoremap <buffer> gd <Plug>(fern-action-git-unstage)
endfunction
augroup my-fern-hijack
ArKa projects. All rights to me, and your next child right arm.