Last active
May 3, 2022 15:27
-
-
Save medwards/2195f922ee8928574831036bd922e032 to your computer and use it in GitHub Desktop.
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 noswapfile | |
syntax enable | |
filetype plugin indent on | |
" rust.vim | |
" git clone https://github.com/rust-lang/rust.vim ~/.vim/pack/plugins/start/rust.vim | |
let g:rustfmt_autosave = 1 | |
" kotlin-vim | |
" git clone https://github.com/udalov/kotlin-vim.git ~/.vim/pack/plugins/start/kotlin-vim | |
" coc.nvim | |
" curl -sL install-node.now.sh/lts | bash <--- UNTRUSTED SOURCE?? | |
" https://nodejs.org/en/download/ into ~/.local and symlink to ~/.local/bin | |
" https://github.com/neoclide/coc.nvim/wiki/Install-coc.nvim#using-vim8s-native-package-manager | |
" mkdir -p ~/.vim/pack/coc/start | |
" cd ~/.vim/pack/coc/start | |
" curl --fail -L https://github.com/neoclide/coc.nvim/archive/release.tar.gz|tar xzfv - | |
" :CocInstall coc-rust-analyzer | |
" :CocInstall coc-lists | |
" :CocConfig | |
" /w (without escaping) | |
" { | |
" \"coc.preferences.jumpCommand\": \"tab drop\" | |
" } | |
" https://github.com/fwcd/kotlin-language-server/blob/master/EDITORS.md | |
" :helptags /home/medwards/.vim/pack/coc/start/coc.nvim-release/doc | |
" =================== | |
" Temporary | |
" ==================== | |
" Keyboard shortcuts | |
" Go to next diagnostic (generally an error) | |
nmap <silent> <F8> <Plug>(coc-diagnostic-next) | |
" Go to previous diagnostic (generally an error) | |
nmap <silent> <S-F8> <Plug>(coc-diagnostic-prev) | |
" Go to definition of symbol under cursor | |
nmap <silent> <F12> <Plug>(coc-definition) | |
" Go to type definition of symbol under cursor | |
nmap <silent> <C-K> <Plug>(coc-type-definition) | |
" Go to references of symbol under cursor | |
nmap <silent> <S-F12> <Plug>(coc-references) | |
" Rename symbol under cursor and all references | |
nmap <silent> <F2> <Plug>(coc-rename) | |
" Search all symbols | |
nmap <silent> <C-T> :CocList<SPACE>symbols<CR> | |
" Search all files | |
nmap <silent> <C-P> :CocList<SPACE>files<CR> | |
" Search all text | |
nmap <silent> <C-F> :CocList<SPACE>grep<CR> | |
" trigger autocomplete | |
if has('nvim') | |
inoremap <silent><expr> <c-space> coc#refresh() | |
else | |
inoremap <silent><expr> <c-@> coc#refresh() | |
endif | |
" Browse problems | |
nmap <silent> <F8> <Plug>(coc-diagnostic-next) | |
nmap <silent> <S-F8> <Plug>(coc-diagnostic-prev) | |
" trigger codeactions | |
nmap <silent> <C-L> <Plug>(coc-codeaction-cursor) | |
xmap <silent> <C-L> <Plug>(coc-codeaction-selected) | |
" Use K to show documentation in preview window. | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
" Open docs in another window (VSCode "Open definition to the side") | |
nmap <silent> <C-K><F12> :CocCommand<SPACE>rust-analyzer.openDocs<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" Use tab for trigger completion with characters ahead and navigate. | |
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by | |
" other plugin before putting this into your config. | |
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 | |
function! StatusDiagnostic() abort | |
let info = get(b:, 'coc_diagnostic_info', {}) | |
if empty(info) | return '' | endif | |
let msgs = [] | |
if get(info, 'error', 0) | |
call add(msgs, 'E' . info['error']) | |
endif | |
if get(info, 'warning', 0) | |
call add(msgs, 'W' . info['warning']) | |
endif | |
return ' - ' . join(msgs, ' ') | |
endfunction | |
function! StatusCoc() abort | |
return get(g:, 'coc_status', '') | |
endfunction | |
set laststatus=2 | |
autocmd User CocStatusChange redraws | |
"set statusline=%{coc#status()} | |
set statusline=%f | |
set statusline+=: | |
set statusline+=%l | |
set statusline+=%{StatusDiagnostic()} | |
set statusline+=%= | |
set statusline+=%{StatusCoc()} | |
" fugitive.vim - https://github.com/tpope/vim-fugitive | |
" mkdir -p ~/.vim/pack/tpope/start | |
" cd ~/.vim/pack/tpope/start | |
" git clone https://tpope.io/vim/fugitive.git | |
" vim -u NONE -c \"helptags fugitive/doc\" -c q # /wo escaping | |
" git blame -- ALT+B (gq to quit) | |
nmap <silent> b :Git<SPACE>blame<CR> | |
" On blame: - reblame at commit (see g?) | |
" vim-rhubarb - https://github.com/tpope/vim-rhubarb | |
" mkdir -p ~/.vim/pack/tpope/start | |
" cd ~/.vim/pack/tpope/start | |
" git clone https://github.com/tpope/vim-rhubarb.git | |
" vim -u NONE -c \"helptags vim-rhubarb/doc\" -c q | |
" :GBrowse | |
" vim-toml - https://github.com/cespare/vim-toml | |
" git clone https://github.com/cespare/vim-toml ~/.vim/pack/plugins/start/vim-toml | |
" :Termdebug | |
packadd termdebug | |
let g:termdebug_wide = 1 | |
au BufEnter *.c let termdebugger="gdb" | |
au BufEnter *.cpp let termdebugger="gdb" | |
au BufEnter *.rs let termdebugger="rust-gdb" | |
au BufEnter *.java let termdebugger="jdb" | |
au BufEnter *.kt let termdebugger="jdb" | |
" TODO: check termdebug state to determine if F5 is :Run or :Continue | |
nmap <silent> <F5> :Continue<CR> | |
nmap <silent> <F9> :Break<CR> | |
nmap <silent> <F10> :Over<CR> | |
" add line numbers TODO: only for code | |
set number | |
highlight CocFloating ctermbg=0 | |
highlight Pmenu ctermbg=0 ctermfg=13 | |
highlight PmenuSel ctermbg=0 ctermfg=NONE | |
set backspace=indent,eol,start | |
" tabs to spaces is pretty much universal now | |
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment