This commit is contained in:
2022-02-11 15:40:28 +01:00
parent b7e82d3ce9
commit f2a0c97a98

43
vimrc
View File

@@ -26,11 +26,12 @@ set undodir=$HOME/.vim/undo
" italicize comments
highlight Comment cterm=italic gui=italic
set relativenumber
set number relativenumber
" four-space tabs
filetype indent plugin on
set smartindent
set autoindent
autocmd FileType javascript set shiftwidth=2
set title " set the terminal title
set ruler "show status line
@@ -38,7 +39,6 @@ set rulerformat=%10(%l,%c%V%)
set laststatus=2 "always show status line
set cursorline "highlight current line
set ignorecase "case-insensitive search
set smartcase "unless there's an uppercase letter in the keyword
setlocal shiftwidth=2 softtabstop=2 expandtab
@@ -47,9 +47,13 @@ au FileType python setl softtabstop=4 shiftwidth=4 tabstop=4
" toggle paste mode
map <Leader>p :set invpaste<CR>
" keep visual selection after indenting
vnoremap < <gv
vnoremap > >gv
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gr <Plug>(coc-references)
" easier completion mode
imap <c-k> <c-x>
@@ -73,14 +77,8 @@ nnoremap <c-/> gc
" save all and quit
nnoremap <leader>q :wa<cr>ZQ
function! RunBlackIfInPythonFile()
if &filetype ==# 'python'
:call Black()
endif
endfunction
" save
nnoremap <c-s> :call RunBlackIfInPythonFile()<cr>:w<cr>
nnoremap <c-s> :w<cr>
" save and close buffer
nnoremap <leader>w :w<cr>:bw<cr>
nnoremap <c-h> :bp<cr>
@@ -89,13 +87,12 @@ nnoremap <c-l> :bn<cr>
nnoremap <c-e> :noh<cr>
nnoremap <leader>p :PlugInstall<cr>
nnoremap <leader>b :call RunBlackIfInPythonFile()<cr>
nnoremap <leader>s :source ~/.config/nvim/init.vim<cr>
nnoremap <leader>v :e ~/.config/nvim/init.vim<cr>
" show number of lines in buffer
nnoremap <leader>l :echo line("$")<cr>
nnoremap <leader>f :Files<cr>
" quickly source vimrc with <space> + s
nnoremap <leader>s :source ~/.vimrc<cr>
nmap <leader>l :call CocAction('diagnosticNext')<cr>
" move selection
nnoremap <C-j> :m .+1<CR>==
@@ -110,11 +107,29 @@ let g:black#settings = {
\ 'fast': 1,
\ 'line_length': 100
\}
let g:python3_host_prog = $HOME . '/.local/venv/nvim/bin/python'
call plug#begin('~/.vim/plugged')
Plug 'folke/tokyonight.nvim', { 'branch': 'main' }
Plug 'averms/black-nvim', {'do': ':UpdateRemotePlugins'}
Plug 'tpope/vim-commentary'
Plug 'sheerun/vim-polyglot'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'tpope/vim-fugitive'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
call plug#end()
colorscheme tokyonight
command! UnMinify call UnMinify()
function! UnMinify()
%s/{\ze[^\r\n]/{\r/g
%s/){/) {/g
%s/};\?\ze[^\r\n]/\0\r/g
%s/;\ze[^\r\n]/;\r/g
%s/[^\s]\zs[=&|]\+\ze[^\s]/ \0 /g
normal ggVG=
endfunction