Last active
April 20, 2024 15:58
-
-
Save VladislavTitov/1bf1e532c4d728bf63a9e378ee6fcfe8 to your computer and use it in GitHub Desktop.
My vim config file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
filetype off | |
syntax enable | |
set encoding=utf-8 | |
set number " show line numbers | |
set showcmd " show command in bottom bar | |
set cursorline " highlight current line | |
set signcolumn=yes " show column in front of line number column, used by linter, e.g. | |
set wrap | |
set mouse=a | |
set wildmenu " visual autocomplete for command menu | |
set wildoptions=pum " show autocomple in popup | |
:set showmatch " jump to matching bracket when insert one | |
:set matchtime=3 " speed up showmatch | |
" make showmatch scrollable | |
inoremap } }<Left><c-o>%<c-o>:sleep 500m<CR><c-o>%<c-o>a | |
inoremap ] ]<Left><c-o>%<c-o>:sleep 500m<CR><c-o>%<c-o>a | |
inoremap ) )<Left><c-o>%<c-o>:sleep 500m<CR><c-o>%<c-o>a | |
" don't forget about '%' to jump between corresponding brackets | |
" Without this line you cannot erase old symbols, any indentation and lines in | |
" Edit mode. | |
set backspace=indent,eol,start | |
" Next 3 lines makes tab = 4 spaces | |
" Nice explanation: https://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces | |
set shiftwidth=4 smarttab | |
set expandtab | |
set tabstop=8 softtabstop=0 | |
" Show color column at 80 characters width, visual reminder of keepingcode line within a popular line width. | |
set colorcolumn=80 | |
set ttyfast " fast rendering | |
set clipboard=unnamed " copy to os clipboard, not to vim clipboard" | |
let g:ale_completion_enabled = 1 | |
let g:ale_kotlin_languageserver_executable='/opt/homebrew/Cellar/kotlin-language-server/1.3.9/bin/kotlin-language-server' | |
" Auto-installing of vim-plug | |
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' | |
if empty(glob(data_dir . '/autoload/plug.vim')) | |
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' | |
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC | |
endif | |
" Plugins | |
call plug#begin('~/.vim/plugged') | |
Plug 'rust-lang/rust.vim' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'dense-analysis/ale' | |
Plug 'preservim/nerdtree'| | |
\ Plug 'Xuyuanp/nerdtree-git-plugin'| | |
\ Plug 'ryanoasis/vim-devicons' | |
Plug 'sheerun/vim-polyglot' | |
Plug 'udalov/kotlin-vim' | |
Plug 'nightsense/stellarized' | |
Plug 'ghifarit53/tokyonight-vim' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'tpope/vim-fugitive' | |
Plug 'hdiniz/vim-gradle' | |
"Plug 'davidhalter/jedi-vim' | |
call plug#end() | |
" Color theme settings | |
set background=dark | |
set termguicolors | |
colorscheme tokyonight | |
"let g:lightline = { 'colorscheme': 'stellarized_dark' } | |
" Coc config | |
inoremap <silent><expr> <TAB> | |
\ coc#pum#visible() ? coc#pum#next(1) : | |
\ CheckBackspace() ? "\<Tab>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" | |
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() | |
\: "<CR>" | |
function! CheckBackspace() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
if has('nvim') | |
inoremap <silent><expr> <c-space> coc#refresh() | |
else | |
inoremap <silent><expr> <c-@> coc#refresh() | |
endif | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
" Use K to show documentation in preview window | |
nnoremap <silent> K :call ShowDocumentation()<CR> | |
function! ShowDocumentation() | |
if CocAction('hasProvider', 'hover') | |
call CocActionAsync('doHover') | |
else | |
call feedkeys('K', 'in') | |
endif | |
endfunction | |
" Highlight the symbol and its references when holding the cursor | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Symbol renaming | |
nmap <leader>rn <Plug>(coc-rename) | |
" Formatting selected code | |
xmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(coc-format-selected) | |
" Jedi-vim config | |
let g:jedi#use_splits_not_buffers = "right" | |
let g:jedi#environment_path = "venv" | |
" NERDTree config | |
nnoremap <leader>n :NERDTreeFocus<CR> | |
nnoremap <C-n> :NERDTree<CR> | |
nnoremap <C-t> :NERDTreeToggle<CR> | |
nnoremap <C-f> :NERDTreeFind<CR> | |
let NERDTreeShowHidden=1 " Show hidden files in NerdTree | |
let NERDTreeCascadeSingleChildDir=0 " Remove one-child dirs collapsing | |
" Simple split navigation | |
nnoremap <C-J> <C-W><C-J> | |
nnoremap <C-K> <C-W><C-K> | |
nnoremap <C-L> <C-W><C-L> | |
nnoremap <C-H> <C-W><C-H> | |
" Open new vertical split to the right from current window | |
set splitright | |
" Open new horizontal split to the bottom from current window | |
set splitbelow | |
inoremap jj <esc> " fast esc on double-tap j key | |
noremap ,, :tabp<ENTER> " go to previous tab window | |
noremap .. :tabn<ENTER> " go to next tab window | |
au FocusLost User :wa " write buffer on focus lost" | |
" rustfmt settings | |
let g:rustfmt_autosave = 1 | |
let g:rustfmt_emit_files = 1 | |
let g:rustfmt_fail_silently = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment