Created
May 7, 2024 04:32
-
-
Save slonoed/79082b1522bdf9b1910abc2a8c455acc to your computer and use it in GitHub Desktop.
vc
This file contains hidden or 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
" VIM | |
set nocompatible | |
filetype off | |
" vim-plug | |
call plug#begin() | |
" Colors {{{ | |
syntax enable | |
set runtimepath^=/Users/slonoed/_repos/vim-popup | |
set background=dark | |
"let base16colorspace=256 | |
let &t_AB="\e[48;5;%dm" | |
let &t_AF="\e[38;5;%dm" | |
highlight LineNr ctermfg=DarkGray ctermbg=black | |
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red | |
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red | |
highlight DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red | |
highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red | |
" }}} | |
"set pythonthreedll=/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib | |
"set pythonthreehome=/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11 | |
" Misc {{{ | |
set vb | |
"set autoread | |
set backspace=indent,eol,start | |
" don't give |ins-completion-menu| messages. | |
set shortmess+=c | |
set hidden | |
" always show signcolumns | |
set signcolumn=yes | |
set noshowmode | |
set wildmenu | |
set cmdheight=1 | |
set laststatus=2 " allways show statusline | |
set statusline= | |
set statusline+=%#PmenuSel# | |
set statusline+=%#LineNr# | |
set statusline+=\ %f | |
set statusline+=%m\ | |
set statusline+=%= | |
set statusline+=%#CursorColumn# | |
"set statusline+=\ %Y | |
set statusline+=\ %3.l:%-3.c | |
set statusline+=\ %2.p%%\ (%L) | |
set statusline+=\ " | |
function! LinterStatusOk() abort | |
let l:counts = ale#statusline#Count(bufnr('')) | |
let l:all_errors = l:counts.error + l:counts.style_error | |
let l:all_non_errors = l:counts.total - l:all_errors | |
return l:counts.total == 0 ? 'Ok' : '' | |
endfunction | |
set statusline+=%{LinterStatusOk()} | |
set statusline+=%#warningmsg# | |
function! LinterStatusError() abort | |
let l:counts = ale#statusline#Count(bufnr('')) | |
let l:all_errors = l:counts.error + l:counts.style_error | |
let l:all_non_errors = l:counts.total - l:all_errors | |
return l:counts.total == 0 ? '' : printf( | |
\ '%dW %dE', | |
\ all_non_errors, | |
\ all_errors | |
\) | |
endfunction | |
set statusline+=%{LinterStatusError()} | |
set statusline+=%* | |
set incsearch " Jump when search | |
set number " Toggle numbers | |
set rnu " relative numbers | |
set scrolloff=4 | |
set mouse=a | |
set nobackup | |
set nowritebackup | |
set updatetime=300 | |
set noswapfile | |
set ignorecase | |
set smartcase | |
set virtualedit=block | |
" remove preview window when completion popup | |
set completeopt-=preview | |
" Persistent undo | |
set undofile | |
set undodir=$HOME/.config/nvim/undo | |
set undolevels=1000 | |
set undoreload=10000 | |
" Indents | |
set smartindent | |
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
" Open new split panes to right and bottom | |
set splitbelow | |
set splitright | |
"set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline) | |
" spellcheck | |
set spell spelllang=ru,en | |
" russian map | |
" set langmap=ёйцукенгшщзхъфывапролджэячсмитьбюЁЙЦУКЕHГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ;`qwertyuiop[]asdfghjkl\\;'zxcvbnm\\,.~QWERTYUIOP{}ASDFGHJKL:\\"ZXCVBNM<> | |
" }}} | |
set selection=old | |
" Plugins {{{ | |
"Plug 'CoderCookE/vim-chatgpt', {'branch': 'main'} | |
"let g:openai_api_key='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' | |
"let g:chat_gpt_split_direction = 'vertical' | |
"let g:chat_gpt_session_mode = 1 | |
Plug 'jparise/vim-graphql' | |
Plug 'ledger/vim-ledger' | |
Plug 'diepm/vim-rest-console' | |
Plug 'aquach/vim-http-client' | |
Plug 'danielwe/base16-vim' | |
Plug 'github/copilot.vim' | |
Plug 'simnalamburt/vim-mundo' | |
" Duo tome colors | |
Plug 'altercation/vim-colors-solarized' | |
" vimdiff | |
Plug 'sjl/threesome.vim' | |
Plug 'tpope/vim-repeat' | |
Plug 'ntpeters/vim-better-whitespace' | |
Plug 'vim-scripts/surround.vim' | |
Plug 'tpope/vim-vinegar' | |
let g:netrw_liststyle = 'tree' | |
Plug 'tomtom/tcomment_vim' | |
Plug 'Raimondi/delimitMate' | |
Plug 'gorodinskiy/vim-coloresque' | |
Plug 'kien/ctrlp.vim' | |
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|dist-client\|dist-server\|dist-test' | |
let g:ctrlp_switch_buffer = 'Et' | |
let g:ctrlp_mruf_exclude = '/tmp/.*\|/temp/.*' | |
let g:ctrlp_root_markers = ['package.json'] | |
" Ack replacement | |
Plug 'dyng/ctrlsf.vim' | |
" Git | |
Plug 'tpope/vim-fugitive' | |
Plug 'sodapopcan/vim-twiggy' | |
Plug 'junegunn/gv.vim' | |
" Lang plugins {{{ | |
Plug 'pangloss/vim-javascript', { 'for': ['typescript', 'javascript'] } | |
let g:javascript_plugin_flow = 1 | |
Plug 'maxmellon/vim-jsx-pretty' | |
Plug 'elzr/vim-json' | |
let g:vim_json_syntax_conceal = 0 | |
Plug 'tpope/vim-jdaddy' | |
Plug 'dense-analysis/ale' | |
let g:ale_linters = { | |
\'javascript': ['flow', 'eslint'], | |
\} | |
let g:ale_fixers = { | |
\'javascript': ['eslint', 'prettier'], | |
\} | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'mxw/vim-jsx' | |
" use <tab> for trigger completion and navigate to the next complete item | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
inoremap <silent><expr> <Tab> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<Tab>" : | |
\ coc#refresh() | |
" Use tab for trigger completion with characters ahead and navigate. | |
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin. | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
" Use <c-space> to trigger completion. | |
inoremap <silent><expr> <c-space> coc#refresh() | |
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position. | |
" Coc only does snippet and additional edit on confirm. | |
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Use `[c` and `]c` to navigate diagnostics | |
nmap <silent> [c <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]c <Plug>(coc-diagnostic-next) | |
nmap <silent>ga <Plug>(coc-codeaction-cursor) | |
" Remap keys for gotos | |
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 <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" Applying code actions to the selected code block | |
" Example: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap keys for applying code actions at the cursor position | |
nmap <leader>ac <Plug>(coc-codeaction-cursor) | |
" Remap keys for apply code actions affect whole buffer | |
nmap <leader>as <Plug>(coc-codeaction-source) | |
" Apply the most preferred quickfix action to fix diagnostic on the current line | |
nmap <leader>qf <Plug>(coc-fix-current) | |
Plug 'janko-m/vim-test' | |
let test#strategy = "iterm" | |
let g:test#javascript#jest#file_pattern = '\vtest\.(browser|node)\.js$' | |
let test#vim#term_position = "vertical" | |
Plug 'SirVer/ultisnips' | |
Plug 'honza/vim-snippets' | |
let g:UltiSnipsExpandTrigger="<c-e>" | |
let g:UltiSnipsJumpForwardTrigger="<c-b>" | |
let g:UltiSnipsJumpBackwardTrigger="<c-z>" | |
let g:UltiSnipsEditSplit="context" | |
"let g:UltiSnipsSnippetsDir="~/dotfiles/ultisnips" | |
let g:UltiSnipsSnippetDirectories = ['~/.vim/UltiSnips', 'UltiSnips', '/Users/slonoed/Uber/snippets'] | |
Plug 'tpope/vim-projectionist' | |
let g:projectionist_heuristics = { | |
\ "*/src/components": { | |
\ "*.js": { "alternate": "{}.test.browser.js" }, | |
\ "*.test.browser.js": { "alternate": "{}.js" } | |
\ }, | |
\ "*/src/graphql": { | |
\ "*.js": { "alternate": "{}.test.node.js" }, | |
\ "*.test.node.js": { "alternate": "{}.js" } | |
\ } | |
\ } | |
Plug 'tpope/vim-obsession' | |
Plug 'dhruvasagar/vim-prosession' | |
" Leader Map {{{ | |
:let mapleader = "\<Space>" | |
" r - runs | |
nnoremap <LEADER>r <Nop> | |
" run nearest test | |
nnoremap <LEADER>rn :TestNearest<CR> | |
" run tests for file | |
nnoremap <LEADER>rf :TestFile<CR> | |
" run tests for file in watch mode | |
nnoremap <LEADER>rw :TestFile --watch<CR> | |
" run last test | |
nnoremap <LEADER>rl :TestLast<CR> | |
nmap <leader>rr <Plug>(coc-rename) | |
" i - info | |
" translate to en | |
vnoremap <silent> <leader>ie :TranslateVisual -e google ru:en<CR> | |
" translate to ru | |
vnoremap <silent> <leader>ir :TranslateVisual -e google en:ru<CR> | |
" c - comments | |
nnoremap <LEADER>c <Nop> | |
nnoremap <LEADER>cc :TComment<CR> | |
vnoremap <LEADER>cc :TComment<CR> | |
" s - splits | |
nnoremap <LEADER>s <Nop> | |
nnoremap <LEADER>sl :vsplit<CR> | |
nnoremap <LEADER>sj :split<CR> | |
nnoremap <LEADER>st :AV<CR> | |
" t - toggles | |
nnoremap <LEADER>t <Nop> | |
nnoremap <LEADER>tp :set invpaste paste?<CR> | |
nnoremap <LEADER>th :CocCommand rest-client.request <cr> | |
nnoremap <LEADER>tn :set invnumber number?<CR> | |
nnoremap <LEADER>tl :set invcursorline cursorline?<CR> | |
nnoremap <LEADER>tb :TagbarToggle<CR> | |
" w - file ops | |
nnoremap <LEADER>w <Nop> | |
nnoremap <LEADER>ww :w<CR> | |
nnoremap <LEADER>wq :wq<CR> | |
nnoremap <LEADER>wa :qa<CR> | |
nnoremap <LEADER>wd :q!<CR> | |
nnoremap <LEADER>wr :source ~/.vimrc<CR> | |
" f - buffers and files | |
nnoremap <LEADER>f <Nop> | |
nmap <LEADER>fs <Plug>CtrlSFPrompt | |
" nnoremap <LEADER>ft :NERDTreeToggle<CR> | |
" nnoremap <LEADER>ff :NERDTreeFind<CR> | |
nnoremap <LEADER>fb :CtrlPMRUFiles<CR> | |
nnoremap <LEADER>fp :CtrlP<CR> | |
nmap <LEADER>fw <Plug>CtrlSFCwordPath | |
" u - gundo | |
nnoremap <LEADER>u <Nop> | |
nnoremap <LEADER>ut :MundoToggle<CR> | |
" b - brackets | |
nmap <leader>b) ys%) | |
nmap <leader>b] ys%] | |
nmap <leader>b} ys%} | |
" g - git | |
nnoremap <LEADER>g <Nop> | |
nnoremap <LEADER>gb :Gblame<CR> | |
nnoremap <LEADER>gs :Gstatus<CR> | |
nnoremap <LEADER>go :call system('open https://sourcegraph.uberinternal.com/code.uber.internal/web-code/-/blob/' . expand('%') . '#L' . line('.'))<CR> | |
" e - edit code (refactoring) | |
nnoremap <LEADER>e <Nop> | |
nnoremap <LEADER>er :LSClientFindCodeActions 'return'<CR> | |
nnoremap <LEADER>eo :LSClientFindCodeActions 'only'<CR> | |
" }}} | |
function! Z() | |
let a = "Use implicit return" | |
echom a =~ 'Use \(implicit\|explicit\) return' | |
endfunction | |
"call Z() | |
" Local leader map {{{ | |
:let maplocalleader = "\\" | |
" }}} | |
" Visual map {{{ | |
vmap <C-f> <Plug>CtrlSFVwordPath | |
" Find and replace selected text | |
vnoremap <C-r> "hy:%sno/<C-r>h//gc<left><left><left> | |
vnoremap <silent> ga :call lsc#edit#findCodeActions(lsc#edit#filterActions(), 0, 0)<CR> | |
" }}} | |
" Moving | |
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> | |
tnoremap <C-J> <C-W><C-J> | |
tnoremap <C-K> <C-W><C-K> | |
tnoremap <C-L> <C-W><C-L> | |
tnoremap <C-H> <C-W><C-H> | |
if has("gui_macvim") | |
" Switch to specific tab numbers with Command-number | |
noremap <D-1> :tabn 1<CR> | |
noremap <D-2> :tabn 2<CR> | |
noremap <D-3> :tabn 3<CR> | |
noremap <D-4> :tabn 4<CR> | |
noremap <D-5> :tabn 5<CR> | |
noremap <D-6> :tabn 6<CR> | |
noremap <D-7> :tabn 7<CR> | |
noremap <D-8> :tabn 8<CR> | |
noremap <D-9> :tabn 9<CR> | |
" Command-0 goes to the last tab | |
noremap <D-0> :tablast<CR> | |
endif | |
" Using CocList | |
" Show all diagnostics | |
"nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr> | |
"" Manage extensions | |
"nnoremap <silent> <space>e :<C-u>CocList extensions<cr> | |
"" Show commands | |
"nnoremap <silent> <space>c :<C-u>CocList commands<cr> | |
"" Find symbol of current document | |
"nnoremap <silent> <space>o :<C-u>CocList outline<cr> | |
"" Search workspace symbols | |
"nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr> | |
"" Do default action for next item. | |
"nnoremap <silent> <space>j :<C-u>CocNext<CR> | |
"" Do default action for previous item. | |
"nnoremap <silent> <space>k :<C-u>CocPrev<CR> | |
"" Resume latest coc list | |
"nnoremap <silent> <space>p :<C-u>CocListResume<CR> | |
" All oa your Plugs must be added before the following line | |
call plug#end() | |
filetype on | |
filetype plugin indent on " required | |
filetype plugin on | |
fun! <SID>StripTrailingWhitespaces() | |
let l = line(".") | |
let c = col(".") | |
%s/\s\+$//e | |
call cursor(l, c) | |
endfun | |
set omnifunc=syntaxcomplete#Complete | |
colorscheme base16-twilight | |
hi clear SpellBad | |
hi SpellBad cterm=underline ctermfg=red | |
" Autocmd {{{ | |
autocmd FileType c,cpp,java,php,ruby,python,js,clj,cljs autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces() | |
autocmd BufWritePre * %s/\s\+$//e | |
au BufNewFile,BufRead *.js set filetype=javascript | |
au BufRead,BufNewFile,BufReadPost *.json set syntax=json | |
au BufRead,BufNewFile,BufReadPost *.graphql set syntax=graphql | |
" Highlight symbol under cursor on CursorHold | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" }}} | |
" | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment