1
2
3
4
5
6 "Software"
7
8
9
10
11
12
13
14
15 "AS IS"
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 set nocompatible
41
42
43
44
45 let mapleader = '\'
46 let maplocalleader = '\'
47
+ - 48 +-- 44 lines: System Dependencies:
48
| 49 let g:jm_vimrc = {}
| 50
| 51
| 52
| 53 let g:jm_vimrc.docs = {}
| 54
| 55
| 56
| 57 let g:jm_vimrc.docs.commands = {}
| 58
| 59
| 60
| 61 let g:jm_vimrc.docs.mappings = {}
| 62
| 63
| 64 let g:jm_vimrc.deps = #{
| 65 \ jshell: 'jshell',
| 66 \ curl: 'curl',
| 67 \ blaze: 'blaze',
| 68 \ javap: 'javap',
| 69 \ ag: 'ag',
| 70 \ fish: 'fish',
| 71 \ python: 'python3',
| 72 \ }
| 73
| 74
| 75 let g:jm_vimrc.is_mac = system('uname -s') =~# 'Darwin'
| 76
| 77
| 78 let g:jm_vimrc.has_python = has('python3')
| 79
| 80
| 81 let g:jm_vimrc.deps.JavaClassnameList = {-> systemlist('fish -c "classpath list-all-classes"')}
| 82 let g:jm_vimrc.deps.ClasspathJarList = {-> systemlist('fish -c classpath')}
| 83
| 84 let g:jm_vimrc.deps.google_java_executable = 'google-java-format'
| 85 let g:jm_vimrc.deps.ktfmt_executable = [
| 86 \ 'java',
| 87 \ '-jar',
| 88 \ '/Users/jmend/.classpath/ktfmt-0.62-with-dependencies.jar'
| 89 \ ]
| 90 let g:jm_vimrc.deps.buildozer = 'fish -c buildozer'
| 91
92
+ - 93 +-- 25 lines: Playground:
93
| 94 let s:pg_items = (g:jm_vimrc.is_mac)
| 95 \ ? #{
| 96 \ b: 'Files ~/Playground/basis',
| 97 \ co: 'Files ~/Playground',
| 98 \ cj: 'Files ~/Playground/jdk/src/java.base/share/classes',
| 99 \ cO: 'Files /opt/homebrew/lib/ocaml/',
| 100 \ pg: 'Files ~/Playground',
| 101 \ n: 'Files ~/Playground/jmendio/n',
| 102 \ v: 'edit ~/.vimrc',
| 103 \ }
| 104 \ : #{
| 105 \ b: 'Files ~/code/basis',
| 106 \ co: 'Files ~/code',
| 107 \ cg: 'Files ~/code/guava/guava/src',
| 108 \ cj: 'Files ~/code/jdk/src/java.base/share/classes',
| 109 \ cO: 'Files /usr/lib/ocaml',
| 110 \ n: 'Files ~/jmendio/n',
| 111 \ v: 'edit ~/.vimrc',
| 112 \ }
| 113 for [key, path] in items(s:pg_items)
| 114 execute printf('nnoremap <leader>e%s :%s<cr>', key, path)
| 115 let g:jm_vimrc.docs.mappings['\e' .. key] = 'Run :' .. path
| 116 endfor
| 117
118
+ - 119 +-- 88 lines: Plugins (vim-plug):
119
| 120 call plug#begin('~/.vim/bundle')
| 121
| 122
| 123 Plug 'morhetz/gruvbox'
| 124 Plug 'tpope/vim-surround'
| 125 Plug 'scrooloose/nerdtree'
| 126 Plug 'godlygeek/tabular'
| 127 if g:jm_vimrc.has_python
| 128 Plug 'SirVer/ultisnips'
| 129 Plug 'Valloric/YouCompleteMe'
| 130 endif
| 131 Plug 'honza/vim-snippets'
| 132 Plug 'junegunn/fzf', {'do': {-> fzf#install()}}
| 133 Plug 'junegunn/fzf.vim'
| 134 Plug 'junegunn/vim-easy-align'
| 135 Plug 'tpope/vim-fugitive'
| 136 Plug 'moll/vim-bbye'
| 137 Plug 'scrooloose/nerdcommenter'
| 138 Plug 'jiangmiao/auto-pairs'
| 139 Plug 'tpope/vim-repeat'
| 140 Plug 'triglav/vim-visual-increment'
| 141 Plug 'tmhedberg/SimpylFold'
| 142 Plug 'majutsushi/tagbar'
| 143 Plug 'pangloss/vim-javascript'
| 144 Plug 'justinmk/vim-syntax-extra'
| 145 Plug 'jpalardy/vim-slime'
| 146 Plug 'itchyny/lightline.vim'
| 147 Plug 'ap/vim-buftabline'
| 148 Plug 'airblade/vim-gitgutter'
| 149 Plug 'google/vim-maktaba'
| 150 Plug 'google/vim-codefmt'
| 151 Plug 'google/vim-glaive'
| 152 Plug 'frazrepo/vim-rainbow'
| 153 Plug 'AndrewRadev/splitjoin.vim'
| 154 Plug 'AndrewRadev/linediff.vim'
| 155 Plug 'shiracamus/vim-syntax-x86-objdump-d'
| 156 if isdirectory('$OCAML_OCP_INDENT')
| 157 Plug $OCAML_OCP_INDENT
| 158 endif
| 159 if exists("$BASIS")
| 160 Plug $BASIS, { 'rtp': 'vim' }
| 161 else
| 162 Plug 'jmend736/basis', { 'rtp': 'vim' }
| 163 endif
| 164
| 165
| 166
| 167
| 168
| 169
| 170
| 171
| 172
| 173
| 174
| 175
| 176
| 177
| 178
| 179
| 180
| 181
| 182
| 183
| 184
| 185
| 186
| 187
| 188
| 189
| 190 call plug#end()
| 191
| 192 if !exists('g:loaded_plug')
| 193 echoerr "ERROR: vim-plug is REQUIRED https://github.com/junegunn/vim-plug OR :InstallPlug"
| 194 command InstallPlug execute printf('term curl -fLo %s/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', $HOME)
| 195 finish
| 196 endif
| 197
| 198
| 199 call glaive#Install()
| 200
| 201 Glaive codefmt
| 202 \ google_java_executable=`g:jm_vimrc.deps.google_java_executable`
| 203 \ clang_format_style='Google'
| 204 \ ktfmt_executable=`g:jm_vimrc.deps.ktfmt_executable`
| 205
| 206
207
+ - 208 +--105 lines: General Options:
208
| 209 filetype plugin indent on
| 210
| 211 set t_Co=256
| 212 set t_ut=
| 213
| 214 set scrolloff=0
| 215
| 216 set shell=/bin/bash
| 217
| 218 set hidden
| 219
| 220 set tabstop=2
| 221 set softtabstop=2
| 222 set shiftwidth=2
| 223 set expandtab
| 224 set smarttab
| 225
| 226 set autoindent
| 227 set smartindent
| 228
| 229
| 230 set backspace=indent,eol,start
| 231
| 232 set list
| 233 set listchars=tab:\>\ ,trail:·,extends:→,precedes:←
| 234
| 235 set number
| 236 set numberwidth=4
| 237 set relativenumber
| 238 set noruler
| 239 set showcmd
| 240
| 241 set statusline=%f\ %=L:%l/%L\ %c\ (%p%%)
| 242
| 243 set wildmenu
| 244 set wildmode=longest,list,full
| 245
| 246 set hlsearch
| 247 set incsearch
| 248 set foldopen-=search
| 249
| 250 set foldlevel=999
| 251
| 252
| 253 set ignorecase
| 254 set smartcase
| 255
| 256
| 257 set fileencodings=utf-8
| 258 set tags=tags
| 259 set tags+=/usr/include/**/tags
| 260 set printoptions=number:y,duplex:long,paper:letter
| 261 if g:jm_vimrc.is_mac
| 262 set clipboard=unnamed
| 263 else
| 264 set clipboard=unnamedplus
| 265 endif
| 266 set errorbells
| 267 set laststatus=2
| 268 set cursorline
| 269 set sessionoptions=
| 270 \blank,
| 271 \curdir,
| 272 \folds,
| 273 \help,
| 274 \localoptions,
| 275 \options,
| 276 \tabpages,
| 277 \winsize,
| 278 \terminal
| 279
| 280 set directory=~/.swaps//
| 281
| 282
| 283 digraphs el 8712
| 284 digraphs in 8712
| 285 digraphs ni 8713
| 286 digraphs es 8709
| 287 digraphs ss 8834
| 288 digraphs se 8838
| 289 digraphs ns 8836
| 290 digraphs nS 8840
| 291 digraphs nn 8745 " Intersection
| 292 digraphs uu 8746
| 293 digraphs un 8746
| 294 digraphs co 8728
| 295 digraphs \|> 8614
| 296 digraphs tl 8598
| 297 digraphs tr 8599
| 298 digraphs br 8600
| 299 digraphs bl 8601
| 300 digraphs -u 8593
| 301 digraphs -d 8595
| 302 digraphs c. 183
| 303 digraphs .. 183
| 304 digraphs T- 8866
| 305 digraphs -T 8867
| 306 digraphs =v 8659
| 307
| 308
| 309 colorscheme gruvbox
| 310 syntax enable
| 311 set bg=dark
| 312
313
+ - 314 +-- 65 lines: Plugin Settings:
314
| 315
| 316 let g:lightline = {
| 317 \ 'active': {
| 318 \ 'left': [['mode', 'paste'], ['filename', 'modified']],
| 319 \ 'right': [['winlayout', 'winid_bufnr', 'lineinfo'], ['percent', 'foldlevel'], ['readonly']]
| 320 \ },
| 321 \ 'inactive': {
| 322 \ 'left': [['filename', 'modified']],
| 323 \ 'right': [['winlayout', 'winid_bufnr', 'lineinfo'], ['readonly']]
| 324 \ },
| 325 \ 'component_type': {
| 326 \ 'readonly': 'error',
| 327 \ },
| 328 \ 'component': {
| 329 \ 'winid_bufnr': '[%{winnr()}/%{win_getid()}(%{Layout()[win_getid()]})]{%{bufnr()}}',
| 330 \ 'foldlevel': '%{(&foldenable) ? &foldlevel : "-"}f',
| 331 \ },
| 332 \ }
| 333
| 334 if !g:jm_vimrc.is_mac
| 335 let $FZF_DEFAULT_COMMAND = 'ag -l'
| 336 endif
| 337
| 338 let g:html_dynamic_folds = v:true
| 339
| 340 let g:ycm_auto_trigger = 1
| 341 let g:ycm_disable_signature_help = 1
| 342 let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
| 343 let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
| 344
| 345 let g:slime_target = "tmux"
| 346
| 347
| 348 let g:bss_markdown_fix = 1
| 349
| 350 let g:bss_java_fix = 1
| 351
| 352 let g:markdown_folding = 1
| 353
| 354 let g:NERDCompactSexyComs = v:true
| 355 let g:NERDCommentEmptyLines = v:true
| 356 let g:NERDDefaultAlign = 'left'
| 357
| 358 let g:tagbar_sort = v:false
| 359
| 360
| 361 let g:buftabline_numbers = 2
| 362 let g:buftabline_indicators = v:true
| 363 let g:buftabline_separators = v:false
| 364
| 365 let g:netre_liststyle=3
| 366
| 367 let g:tex_flavor='latex'
| 368
| 369 let g:UltiSnipsExpandTrigger="<tab>"
| 370 let g:UltiSnipsJumpForwardTrigger="<c-j>"
| 371 let g:UltiSnipsJumpBackwardTrigger="<c-z>"
| 372 let g:UltiSnipsEditSplit="vertical"
| 373
| 374 let g:gitgutter_sign_added = '··'
| 375 let g:gitgutter_sign_modified = '··'
| 376 let g:gitgutter_sign_removed = '·'
| 377 let g:gitgutter_sign_modified_removed = '·'
| 378
379
+ - 380 +--153 lines: Keymappings:
380
| 381
| 382
| 383
| 384
| 385
| 386
| 387
| 388
| 389
| 390
| 391
| 392
| 393
| 394 let g:jm_vimrc.docs.mappings['<C-[hjkl]>'] =
| 395 \ 'Move between windows by holding CTRL'
| 396 noremap <C-j> <C-W>j
| 397 noremap <C-k> <C-W>k
| 398 noremap <C-h> <C-W>h
| 399 noremap <C-l> <C-W>l
| 400
| 401 let g:jm_vimrc.docs.mappings['<C-[←↑↓→]>'] =
| 402 \ 'Move visual selection'
| 403 vnoremap <C-Up> koko
| 404 vnoremap <C-Down> jojo
| 405 vnoremap <C-Left> hoho
| 406 vnoremap <C-Right> lolo
| 407
| 408 let g:jm_vimrc.docs.mappings['[['] =
| 409 \ 'Enable [[,][,]],[] to operate on non-col-1-{}'
| 410
| 411 nnoremap [[ ?{<CR>w99[{
| 412 nnoremap ][ /}<CR>b99]}
| 413 nnoremap ]] j0[[%/{<CR>
| 414 nnoremap [] k$][%?}<CR>
| 415
| 416 let g:jm_vimrc.docs.mappings['\q'] =
| 417 \ 'Delete current buffer without changing window layout'
| 418 nnoremap <leader>q :Bdelete<cr>
| 419
| 420 let g:jm_vimrc.docs.mappings["\\'"] =
| 421 \ 'Open NERDTree (file explorer)'
| 422 nnoremap <leader>' :NERDTreeToggle<cr>
| 423
| 424 let g:jm_vimrc.docs.mappings['\"'] =
| 425 \ 'Open NERDTree (file explorer) to current file'
| 426 nnoremap <leader>" :NERDTreeFind<cr>
| 427
| 428 let g:jm_vimrc.docs.mappings['\<Tab>'] =
| 429 \ 'Open Tagbar'
| 430 nnoremap <leader><tab> :TagbarToggle<cr>
| 431
| 432 let g:jm_vimrc.docs.mappings['<F10>'] =
| 433 \ 'Toggle paste'
| 434 set pastetoggle=<F10>
| 435
| 436 let g:jm_vimrc.docs.mappings['<F9>'] =
| 437 \ 'Toggle virtualedit=all'
| 438 nnoremap <F9> :let &ve = <C-r>=empty(&ve) ? '"all"' : '""'<cr><cr>
| 439
| 440 let g:jm_vimrc.docs.mappings['<C-r><C-f>'] =
| 441 \ '[modes:ic] Insert file name root'
| 442 inoremap <C-r><C-f> <C-r>=expand('%:p:t:r')<cr>
| 443 cnoremap <C-r><C-f> <C-r>=expand('%:p:t:r')<cr>
| 444
| 445 let g:jm_vimrc.docs.mappings['<C-r><C-t>'] =
| 446 \ '[modes:ic] Insert file name root'
| 447 inoremap <C-r><C-t> <C-r>=bss#blaze#BlazeTarget()<cr>
| 448 cnoremap <C-r><C-t> <C-r>=bss#blaze#BlazeTarget()<cr>
| 449
| 450 let g:jm_vimrc.docs.mappings['<C-p>'] =
| 451 \ 'Fuzzy-search PWD'
| 452 nnoremap <C-p> :Files<cr>
| 453
| 454 let g:jm_vimrc.docs.mappings['\w'] =
| 455 \ 'Clear search highlights (:nohlsearch)'
| 456 nnoremap <silent> <leader>w :nohlsearch<Bar>:echo<cr>
| 457
| 458 let g:jm_vimrc.docs.mappings['<F11>'] =
| 459 \ 'Ensure non-syntax toplevel text is spell-checked'
| 460 noremap <F11> :syntax spell toplevel<cr>
| 461 let g:jm_vimrc.docs.mappings['<F12>'] =
| 462 \ 'Toggle spell checking'
| 463 noremap <F12> :setlocal spell! spelllang=en_us<cr>
| 464
| 465 let g:jm_vimrc.docs.mappings['<Space>l'] =
| 466 \ 'Open Git ("Change [L]ist")'
| 467 nnoremap <leader>l :Git<cr>
| 468
| 469 let g:jm_vimrc.docs.mappings['<C-w><C-z>'] =
| 470 \ 'Set window height to 10 and fix the height'
| 471 nnoremap <C-w><C-z> :FixHeight 10<cr>
| 472 nnoremap <C-w>z :FixHeight 10<cr>
| 473
| 474 let g:jm_vimrc.docs.mappings['K'] =
| 475 \ 'Do grep for word under cursor'
| 476 nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
| 477
| 478 let g:jm_vimrc.docs.mappings['\\'] =
| 479 \ 'Show :tags'
| 480 nnoremap <leader><leader> :tags<cr>
| 481
| 482 let g:jm_vimrc.docs.mappings['\s'] =
| 483 \ 'Refresh UltSnips snippets'
| 484 nnoremap <leader>s :call UltiSnips#RefreshSnippets()<cr>
| 485
| 486 let g:jm_vimrc.docs.mappings['\<Space>'] =
| 487 \ 'Toggle foldcolumn'
| 488 nnoremap <leader><space> :let &l:foldcolumn = (&l:foldcolumn) ? 0 : 3<cr>
| 489
| 490 let g:jm_vimrc.docs.mappings['\a'] =
| 491 \ 'Trigger EasyAlign (See :Wtf ea)'
| 492 xmap <leader>a <Plug>(EasyAlign)
| 493 nmap <leader>a <Plug>(EasyAlign)
| 494
| 495 let g:jm_vimrc.docs.mappings['\O'] =
| 496 \ 'Run `open %`'
| 497 xmap <leader>O :<C-u>!open %<cr>
| 498 nmap <leader>O :<C-u>!open %<cr>
| 499
| 500 let g:jm_vimrc.docs.mappings["C-W !"] =
| 501 \ 'Toggle buflisted'
| 502 nnoremap <C-W>l :set buflisted!<cr>
| 503
| 504 nnoremap <space>c :YcmCompleter GetType<cr>
| 505 nnoremap <space>cq :YcmCompleter GoToDocumentOutline<cr>
| 506 nnoremap <space>cc :YcmCompleter GoToCallers<cr>
| 507 nnoremap <space>cC :YcmCompleter GoToDefinition<cr>
| 508 nnoremap <space>cf :YcmCompleter FixIt<cr>
| 509 nnoremap <space>cd :YcmCompleter GetDoc<cr>
| 510 nnoremap <space>ct :YcmCompleter GetType<cr>
| 511
| 512 let g:jm_vimrc.docs.mappings["<space>T"] =
| 513 \ 'Go to java test (and maybe make it)'
| 514 nnoremap <space>T :FindOrMakeJavaTest<cr>
| 515
| 516 let g:jm_vimrc.docs.mappings['\a[:(]'] =
| 517 \ 'Extra/overriden EasyAlign items'
| 518 let g:easy_align_delimiters = bss#extra#EasyAlignDelimiters()
| 519
| 520 let g:jm_vimrc.docs.mappings['\[0-9]'] =
| 521 \ 'Switch to buffer (from buftabline)'
| 522 nmap <leader>1 <Plug>BufTabLine.Go(1)
| 523 nmap <leader>2 <Plug>BufTabLine.Go(2)
| 524 nmap <leader>3 <Plug>BufTabLine.Go(3)
| 525 nmap <leader>4 <Plug>BufTabLine.Go(4)
| 526 nmap <leader>5 <Plug>BufTabLine.Go(5)
| 527 nmap <leader>6 <Plug>BufTabLine.Go(6)
| 528 nmap <leader>7 <Plug>BufTabLine.Go(7)
| 529 nmap <leader>8 <Plug>BufTabLine.Go(8)
| 530 nmap <leader>9 <Plug>BufTabLine.Go(9)
| 531 nmap <leader>0 <Plug>BufTabLine.Go(10)
| 532
533
+ - 534 +--226 lines: Commands:
534
| 535
| 536
| 537
| 538
| 539
| 540
| 541
| 542
| 543
| 544 if !exists('g:jm_term') || !exists('g:jm_terms')
| 545 let g:jm_term = bss#view#TermView()
| 546 let g:jm_terms = {}
| 547 endif
| 548 let g:jm_vimrc.docs.commands['Term'] =
| 549 \ 'Run a terminal command in a reused window'
| 550 command! -nargs=* -complete=shellcmd Term
| 551 \ eval g:jm_term.Run(<q-args>)
| 552
| 553 let g:jm_vimrc.docs.commands['TermSet'] =
| 554 \ 'Set an option on the term window'
| 555 command! -nargs=* -complete=option TermSet
| 556 \ eval g:jm_term.Exec(printf("setlocal %s", <q-args>))
| 557
| 558 let g:jm_vimrc.docs.commands['Terms'] =
| 559 \ 'Run a terminal command in a reused named window. Terms [name] [cmd]...'
| 560 command! -nargs=* -complete=shellcmd Terms
| 561 \ eval bss#SetDefault(g:jm_terms, [<f-args>][0], {-> bss#view#TermView()})
| 562 \ .Run([<f-args>][1:]->join(' '))
| 563
| 564 let g:jm_vimrc.docs.commands['ReplaceR'] =
| 565 \ 'Locally set \r to run :Term with the specified command'
| 566 command! -nargs=+ ReplaceR
| 567 \ nnoremap <buffer> <localleader>r :Term <args><cr>
| 568
| 569 let g:jm_vimrc.docs.commands['ReplaceRTarget'] =
| 570 \ 'Set \r to bazel target of the current file'
| 571 command! -bar ReplaceRTarget
| 572 \ execute 'ReplaceR' BlazeGuessCommand()
| 573
| 574 let g:jm_vimrc.docs.commands['StopAllJobs'] =
| 575 \ 'Stop all running jobs'
| 576 command! -bar StopAllJobs eval job_info()->map('job_stop(v:val)')
| 577
| 578 let g:jm_vimrc.docs.commands['ListAllJobs'] =
| 579 \ 'List all running jobs'
| 580 command! -bar -bang ListAllJobs
| 581 \ call bss#PP(job_info()->filter('<bang>0 || (job_status(v:val) == "run")'))
| 582
| 583 let g:jm_vimrc.docs.commands['DumpAllJobs'] =
| 584 \ 'List job_infos for all running jobs'
| 585 command! -bar -bang DumpAllJobs
| 586 \ call bss#PP(job_info()->filter('<bang>0 || (job_status(v:val) == "run")')->map('job_info(v:val)'))
| 587
| 588 let g:jm_vimrc.docs.commands['SetupClasspath'] =
| 589 \ 'Set classpath to jm_vimrc.deps.ClasspathJarList()'
| 590 command! -bar SetupClasspath
| 591 \ let $CLASSPATH = join(g:jm_vimrc.deps.ClasspathJarList(), ':')
| 592
| 593 let g:jm_vimrc.docs.commands['SetupTargetClasspath'] =
| 594 \ 'Set classpath to blaze target included jars'
| 595 command! -bar SetupTargetClasspath
| 596 \ let $CLASSPATH = s:TargetClasspath()
| 597
| 598 let g:jm_vimrc.docs.commands['SetupCV'] =
| 599 \ 'Setup $LDFLAGS, $CFLAGS and &path for OpenCV development'
| 600 command! -bar SetupCV
| 601 \ let $LDFLAGS = '-lopencv_core -lopencv_imgcodecs -lopencv_imgproc' |
| 602 \ let $CFLAGS = '-I/usr/include/opencv4' |
| 603 \ let &path ..= ',/usr/include/opencv4,/usr/include/c++/10/'
| 604
| 605 let g:jm_vimrc.docs.commands['FixHeight'] =
| 606 \ 'Resize window and fix its height'
| 607 command! -nargs=1 FixHeight
| 608 \ resize <args> | set winfixheight
| 609
| 610 let g:jm_vimrc.docs.commands['SetupTermRainbow'] =
| 611 \ 'Add Rainbow-coloring to terminals'
| 612 command! -bar SetupTermRainbow
| 613 \ autocmd TerminalOpen * RainbowLoad
| 614
| 615 let g:jm_vimrc.docs.commands['SetupAutoread'] =
| 616 \ 'Enable autoread and add checktime autocmd'
| 617 command! -bar SetupAutoread
| 618 \ set autoread | autocmd FocusGained,BufEnter * checktime
| 619
| 620 let g:jm_vimrc.docs.commands['RemoveTrailingWhitespace'] =
| 621 \ 'Removes all trailing whitespace from the selected lines'
| 622 command! -range=% RemoveTrailingWhitespace
| 623 \ <line1>,<line2>s/\s\+$//
| 624
| 625 let g:jm_vimrc.docs.commands['SetupMatchHex'] =
| 626 \ 'Match hex numbers'
| 627 command! -bar SetupMatchHex
| 628 \ match GruvboxAqua /\<0x0*\zs[1-9a-f]\x*\>/
| 629
| 630 let g:jm_vimrc.docs.commands['SetupMatchNum'] =
| 631 \ 'Match decimal numbers'
| 632 command! -bar SetupMatchNum
| 633 \ match GruvboxAqua /\<\(0x\)\?0*\zs[1-9a-f]\x*\>/
| 634
| 635 let g:jm_vimrc.docs.commands['RefreshSnippets'] =
| 636 \ 'Refresh ultisnips'
| 637 command! -bar RefreshSnippets
| 638 \ call UltiSnips#RefreshSnippets()
| 639
| 640 let g:jm_vimrc.docs.commands['Dis'] =
| 641 \ 'Setup terminal for viewing objdump output ($ objdump -d ... | vim +Dis -)'
| 642 command! -bar Dis
| 643 \ setlocal ft=dis buftype=nofile
| 644
| 645 let g:jm_vimrc.docs.commands['Center'] =
| 646 \ 'Block alignment-preserving :center'
| 647 call bss#draw#block#RegisterCommands()
| 648
| 649 let g:jm_vimrc.docs.commands['ToggleFoldOpenSearch'] =
| 650 \ 'Toggle search on foldopen option'
| 651 command! ToggleFoldOpenSearch
| 652 \ if stridx(&foldopen, "search") == -1 |
| 653 \ set foldopen+=search |
| 654 \ echo "ENABLED foldopen search" |
| 655 \ else |
| 656 \ set foldopen-=search |
| 657 \ echo "DISABLED foldopen search" |
| 658 \ endif
| 659
| 660 let g:jm_vimrc.docs.commands['SetupMath'] =
| 661 \ 'Set up abbreviations for math symbols'
| 662 command! SetupMath
| 663 \ execute 'iabbrev <buffer> nn ∩' |
| 664 \ execute 'iabbrev <buffer> uu ∪' |
| 665 \ execute 'iabbrev <buffer> in ∈' |
| 666 \ execute 'iabbrev <buffer> ni ∉' |
| 667 \ execute 'iabbrev <buffer> ss ⊂' |
| 668 \ execute 'iabbrev <buffer> se ⊆' |
| 669 \ execute 'iabbrev <buffer> ns ⊄' |
| 670 \ execute 'iabbrev <buffer> AN ∧' |
| 671 \ execute 'iabbrev <buffer> OR ∨' |
| 672 \ execute 'iabbrev <buffer> es ∅' |
| 673 \ execute 'iabbrev <buffer> => ⇒' |
| 674 \ execute 'iabbrev <buffer> == ⇔' |
| 675 \ execute 'iabbrev <buffer> != ≠' |
| 676 \ execute 'iabbrev <buffer> co ∘' |
| 677 \ execute 'iabbrev <buffer> FA ∀' |
| 678 \ execute 'iabbrev <buffer> TE ∃' |
| 679 \ execute 'iabbrev <buffer> \|> ↦'
| 680
| 681 let g:jm_vimrc.docs.commands['PyHelp'] =
| 682 \ 'Look-up help for python expression (: PyHelp <pkg> <cls>)'
| 683 command! -nargs=+ -bang PyHelp
| 684 \ call py3eval((<bang>0) ? printf('help(%s)', <q-args>) : printf('help(__import__("%s").%s)', <f-args>))
| 685
| 686 let g:jm_vimrc.docs.commands['MakeOrSetup'] =
| 687 \ 'Run blaze, make, or create a Makefile with included commands (using ; as separator)'
| 688 command! -nargs=+ MakeOrSetup call s:MakeOrSetup(<q-args>)
| 689 function! s:MakeOrSetup(cmds) abort
| 690 if filereadable('WORKSPACE')
| 691 execute 'Term blaze build' BlazeTarget()
| 692 elseif filereadable('Makefile')
| 693 Term make
| 694 else
| 695 let l:cmds = substitute(a:cmds, '%', expand('%'), 'g')
| 696 let l:lines = split(l:cmds, ';')->map('trim(v:val)')
| 697 let l:cursor = bss#cursor#SaveWithBuf()
| 698 try
| 699 redir > Makefile
| 700 silent echo '.PHONY: all'
| 701 silent echo 'all:'
| 702 for l:cmd in l:lines
| 703 silent echo ' ' .. l:cmd
| 704 endfor
| 705 redir END
| 706 silent edit Makefile
| 707 Term make
| 708 finally
| 709 call l:cursor.Restore()
| 710 endtry
| 711 endif
| 712 endfunction
| 713
| 714 let g:jm_vimrc.docs.commands['SetupYcmClasspath'] =
| 715 \ 'Create .ycm_extra_conf.py with CLASSPATH'
| 716 command! -bang SetupYcmClasspath
| 717 \ call s:SetupYcmClasspath($CLASSPATH)
| 718 function! s:SetupYcmClasspath(classpath) abort
| 719 let l:classpath = split(a:classpath, ':')
| 720 let l:lines = s:GenerateYcm(l:classpath)
| 721 if filereadable('.ycm_extra_conf.py')
| 722 throw 'ERROR(FileExists): .ycm_extra_conf.py already exists!'
| 723 else
| 724 call writefile(l:lines, '.ycm_extra_conf.py')
| 725 YcmRestartServer
| 726 endif
| 727 endfunction
| 728 function! s:GenerateYcm(classpath) abort
| 729 let l:path = a:classpath
| 730 \->map('string(v:val)')
| 731 \->join(", ")
| 732 let l:lines =<< eval trim END
| 733 def Settings(**kwargs):
| 734 if kwargs["language"] == "java":
| 735 return {{
| 736 "ls": {{
| 737 "java.project.referencedLibraries": [{l:path}]
| 738 }}
| 739 }}
| 740 END
| 741 return l:lines
| 742 endfunction
| 743
| 744 let g:jm_vimrc.docs.commands['SetupOcamlformat'] =
| 745 \ 'Create a basic .ocamlformat'
| 746 command! SetupOcamlformat call s:SetupOcamlformat()
| 747 function! s:SetupOcamlformat() abort
| 748 if !filereadable('.ocamlformat')
| 749 call writefile(['profile = default'], '.ocamlformat')
| 750 endif
| 751 endfunction
| 752
| 753
| 754 if executable('ag')
| 755
| 756 set grepprg=ag\ --nogroup\ --nocolor\ --ignore=tags\ --vimgrep
| 757 set grepformat^=%f:%l:%c:%m
| 758 endif
| 759
760
+ - 761 +--303 lines: FT-Specific Settings:
761
| 762
| 763
| 764
| 765
| 766
| 767
| 768
| 769
| 770
| 771
| 772
| 773
| 774
| 775
| 776
| 777
| 778
| 779 augroup ft_latex
| 780 autocmd!
| 781 autocmd FileType tex setlocal nocursorline
| 782 autocmd FileType tex setlocal tabstop=4 shiftwidth=4
| 783 autocmd FileType tex nnoremap <buffer> <localleader>r
| 784 \ :execute 'Term fish -c "mkt ' .. expand('%') .. '"'<cr>
| 785 augroup END
| 786
| 787 augroup ft_dot
| 788 autocmd!
| 789 autocmd FileType dot setlocal tabstop=2 shiftwidth=2
| 790 autocmd FileType dot nnoremap <buffer> <localleader>r
| 791 \ :execute 'Term dot -T svg -O' expand('%') <cr>
| 792 augroup END
| 793
| 794 augroup ft_c
| 795 autocmd!
| 796 autocmd FileType c setlocal tabstop=2 shiftwidth=2
| 797 autocmd FileType c setlocal foldmethod=syntax
| 798 autocmd FileType c nnoremap <buffer> <localleader>r
| 799 \ :Term make<CR>
| 800 autocmd FileType c nnoremap <buffer> <localleader>R
| 801 \ :MakeOrSetup gcc -Wall -O3 -o a.out %; ./a.out; rm a.out<cr>
| 802 augroup END
| 803
| 804
| 805 augroup ft_cc
| 806 autocmd!
| 807 autocmd FileType cpp setlocal tabstop=2 shiftwidth=2
| 808 autocmd FileType cpp setlocal foldmethod=syntax
| 809 autocmd FileType cpp nnoremap <buffer> <localleader>t
| 810 \ :term <C-r>=BlazeGuessCommand()<CR>
| 811 autocmd FileType cpp nnoremap <buffer> <localleader>r
| 812 \ :MakeOrSetup
| 813 \ clang++-12 -std=c++17 $(CFLAGS) -o build % $(LDFLAGS);
| 814 \ ./build<CR>
| 815 autocmd FileType cpp nnoremap <buffer> <space>f
| 816 \ :FormatCode<CR>
| 817 autocmd FileType cpp
| 818 \ if exists('g:jm_setup_cpp_cv') |
| 819 \ SetupCV |
| 820 \ endif
| 821 autocmd FileType cpp
| 822 \ if expand('%:p') =~ '/home/jmend/pg' |
| 823 \ silent ReplaceRTarget |
| 824 \ endif
| 825 augroup END
| 826
| 827 augroup ft_gdb
| 828 autocmd!
| 829 autocmd FileType gdb nnoremap <buffer> <localleader>r
| 830 \ :execute 'Term gdb -q -x' expand('%')<cr>
| 831 augroup END
| 832
| 833 augroup ft_python
| 834 autocmd!
| 835 autocmd FileType python command! RunPython
| 836 \ execute "Term" g:jm_vimrc.deps.python expand('%')
| 837 autocmd FileType python command! RunPythonTests
| 838 \ execute "Term" g:jm_vimrc.deps.python "-m pytest" expand('%')
| 839 autocmd FileType python command! RunPythonTypechecks
| 840 \ execute "Term" g:jm_vimrc.deps.python "-m mypy --ignore-missing-imports --follow-imports=skip " expand("%")
| 841 autocmd FileType python command! RunPythonMPL
| 842 \ StopAllJobs | eval timer_start(0, {-> execute('RunPython')})
| 843 autocmd FileType python command! ReplaceRMPL
| 844 \ nnoremap <buffer> <localleader>r :RunPythonMPL<cr>
| 845 autocmd FileType python nnoremap <buffer> <localleader>r
| 846 \ :RunPython<cr>
| 847 autocmd FileType python nnoremap <buffer> <localleader>R
| 848 \ :RunPythonTests<cr>
| 849 autocmd FileType python nnoremap <buffer> <localleader>t
| 850 \ :RunPythonTypechecks<cr>
| 851 autocmd FileType python nnoremap <buffer> <space>f
| 852 \ :FormatCode<CR>
| 853
| 854 autocmd BufNewFile .ycm_extra_conf.py call setline('.', [
| 855 \ 'def Settings(**kwargs):',
| 856 \ ' if kwargs["language"] == "java":',
| 857 \ ' return {',
| 858 \ ' "ls": {',
| 859 \ ' "java.project.referencedLibraries": ["~/.jars/*.jar"]',
| 860 \ ' }',
| 861 \ ' }',
| 862 \ ])
| 863
| 864
| 865 augroup END
| 866
| 867 augroup ft_scheme
| 868 autocmd!
| 869 autocmd FileType scheme setlocal colorcolumn=79
| 870 autocmd FileType scheme let g:lisp_rainbow = v:true
| 871 autocmd FileType scheme nnoremap <buffer> <localleader>r
| 872 \ :w<CR> :Term mit-scheme --load % <CR>
| 873 augroup END
| 874
| 875 augroup ft_java
| 876 autocmd!
| 877 autocmd FileType java
| 878 \ setlocal tabstop=2 softtabstop=2 tabstop=2 shiftwidth=2 smarttab
| 879 autocmd FileType java
| 880 \ setlocal foldmethod=marker foldmarker={,}
| 881 autocmd FileType java nnoremap <space>f :FormatCode<cr>
| 882 autocmd FileType java nnoremap <space>F :set bt=nowrite <bar> FormatCode<cr>
| 883 autocmd FileType java vnoremap <space>f :FormatLines<cr>
| 884 if filereadable('Makefile')
| 885 autocmd FileType java nnoremap <silent> <buffer> <localleader>r
| 886 \ :Term make<cr>
| 887 elseif filereadable('WORKSPACE')
| 888 autocmd FileType java nnoremap <silent> <buffer> <localleader>r
| 889 \ :execute "Term blaze run " .. join(<SID>BlazeTargets(expand("%")), " ")<cr>
| 890 elseif filereadable('gradlew')
| 891 autocmd FileType java nnoremap <silent> <buffer> <localleader>r
| 892 \ :Term ./gradlew test --rerun<cr>
| 893 else
| 894 autocmd FileType java nnoremap <silent> <buffer> <localleader>r
| 895 \ :MakeOrSetup java %<cr>
| 896 endif
| 897 autocmd FileType java nnoremap <silent> <buffer> <localleader>R
| 898 \ :Term ./gradlew run<cr>
| 899 autocmd FileType java let b:surround_99 = "{@code \r}"
| 900 augroup END
| 901
| 902 augroup ft_kotlin
| 903 autocmd!
| 904 autocmd FileType kotlin
| 905 \ setlocal tabstop=2 softtabstop=2 tabstop=2 shiftwidth=2 smarttab
| 906 if filereadable('Makefile')
| 907 autocmd FileType kotlin nnoremap <silent> <buffer> <localleader>r
| 908 \ :Term make<cr>
| 909 elseif filereadable('gradlew')
| 910 autocmd FileType kotlin nnoremap <silent> <buffer> <localleader>r
| 911 \ :Term ./gradlew test --rerun<cr>
| 912 else
| 913 autocmd FileType kotlin nnoremap <silent> <buffer> <localleader>r
| 914 \ :MakeOrSetup
| 915 \ kotlinc . -include-runtime -d a.jar;
| 916 \ java -jar a.jar<CR>
| 917 endif
| 918 autocmd FileType kotlin nnoremap <silent> <buffer> <localleader>R
| 919 \ :Term ./gradlew run<cr>
| 920 augroup END
| 921
| 922 augroup ft_jar
| 923 autocmd!
| 924 autocmd FileType jar
| 925 \ call zip#Browse(expand("<amatch>"))
| 926 autocmd FileType jar
| 927 \ setlocal buflisted
| 928 augroup END
| 929
| 930 augroup ft_class
| 931 autocmd!
| 932 autocmd BufReadCmd *.class
| 933 \ call bss#java#javap#Browse(expand("<amatch>"))
| 934 augroup END
| 935
| 936 augroup ft_javascript
| 937 autocmd!
| 938 autocmd FileType javascript
| 939 \ setlocal tabstop=2 softtabstop=2 tabstop=2 smarttab
| 940 autocmd FileType javascript nnoremap <buffer> <localleader>r
| 941 \ :execute "Term node " .. expand('%')<cr>
| 942 autocmd FileType javascript nnoremap <buffer> <localleader>R
| 943 \ :Term webpack<CR>
| 944 autocmd FileType javascript nnoremap <buffer> <space>f
| 945 \ :FormatCode<CR>
| 946 augroup END
| 947
| 948 augroup ft_markdown
| 949 autocmd!
| 950 autocmd FileType markdown set textwidth=72 smartindent autoindent
| 951 autocmd FileType markdown set cinwords+=:
| 952
| 953 autocmd FileType markdown nnoremap <buffer> ]h :<c-u>call search('\v^#+ ', 'Wz')<cr>
| 954 autocmd FileType markdown nnoremap <buffer> [h :<c-u>call search('\v^#+ ', 'bWz')<cr>
| 955
| 956
| 957
| 958 autocmd FileType markdown nnoremap <buffer> <space>l :<c-u>lvimgrep /\v^#+ / %<cr>
| 959
| 960 autocmd FileType markdown
| 961 \ command! GoToSection call bss#md#GoToSection()
| 962
| 963 autocmd FileType markdown nnoremap <buffer> <localleader>r
| 964 \ :GoToSection<cr>
| 965
| 966 autocmd FileType markdown nnoremap <buffer> <localleader>R
| 967 \ :call bss#md#GoToRandomSection()<cr>
| 968 \ :normal zt0<cr>
| 969
| 970 autocmd FileType markdown command! SetupRPandoc nnoremap <buffer> <localleader>r
| 971 \ :call execute(printf(
| 972 \ "Term pandoc %s -s --highlight-style kate --pdf-engine=xelatex -o %s.pdf",
| 973 \ expand('%:p'),
| 974 \ expand('%:t:r'),
| 975 \ ))<cr>
| 976
| 977 autocmd FileType markdown command! JmMdQuotesAsComments match GruvboxFg3 /^\s*>.*/
| 978
| 979 if !exists('g:bss_markdown_fix') || !g:bss_markdown_fix
| 980
| 981
| 982 autocmd FileType markdown syntax clear markdownCodeBlock
| 983 autocmd FileType markdown syntax region markdownCodeBlock matchgroup=markdownCodeDelimiter start="^\s*\z(`\{3,\}\).*$" end="^\s*\z1\ze\s*$" keepend
| 984 autocmd FileType markdown syntax region markdownCodeBlock matchgroup=markdownCodeDelimiter start="^\s*\z(\~\{3,\}\).*$" end="^\s*\z1\ze\s*$" keepend
| 985
| 986
| 987 autocmd FileType markdown highlight link markdownH1 GruvboxRedBold
| 988 autocmd FileType markdown highlight link markdownH2 GruvboxBlueBold
| 989 autocmd FileType markdown highlight link markdownH3 GruvboxGreenBold
| 990 autocmd FileType markdown highlight link markdownH4 GruvboxPurpleBold
| 991
| 992
| 993 autocmd FileType markdown highlight link markdownBold GruvboxFg4
| 994 autocmd FileType markdown highlight link markdownBoldDelimiter GruvboxFg4
| 995 autocmd FileType markdown highlight link markdownItalic GruvboxFg2
| 996 autocmd FileType markdown highlight link markdownItalicDelimiter GruvboxFg2
| 997 endif
| 998 augroup END
| 999
| 1000 augroup ft_vim
| 1001 autocmd!
| 1002 autocmd FileType vim setlocal foldmethod=marker shiftwidth=2
| 1003 autocmd FileType vim nnoremap <buffer> <localleader>r
| 1004 \ :source %<cr>
| 1005 autocmd FileType vim nnoremap K :help <C-r><C-w><CR>
| 1006 augroup END
| 1007
| 1008 augroup ft_fish
| 1009 autocmd!
| 1010 autocmd FileType fish setlocal tabstop=4 shiftwidth=4 smartindent
| 1011 autocmd FileType fish nnoremap <buffer> <space>f
| 1012 \ :0,$!fish_indent<cr>
| 1013 autocmd FileType fish setlocal omnifunc=bss#fish#Complete
| 1014 augroup END
| 1015
| 1016 augroup ft_make
| 1017 autocmd!
| 1018 autocmd FileType make nnoremap <buffer> <localleader>r
| 1019 \ :Term make<cr>
| 1020 augroup END
| 1021
| 1022 augroup ft_ocaml
| 1023 autocmd!
| 1024 autocmd FileType ocaml
| 1025 \ setlocal tabstop=2 softtabstop=2 tabstop=2 smarttab
| 1026 autocmd FileType ocaml nnoremap <space>f :FormatCode<cr>
| 1027 autocmd FileType ocaml vnoremap <space>f :FormatLines<cr>
| 1028 if filereadable('Makefile')
| 1029 autocmd FileType ocaml nnoremap <silent> <buffer> <localleader>r
| 1030 \ :Term make<cr>
| 1031 elseif filereadable('dune-project')
| 1032 autocmd FileType ocaml nnoremap <silent> <buffer> <localleader>r
| 1033 \ :Term dune build<cr>
| 1034 else
| 1035 autocmd FileType ocaml nnoremap <silent> <buffer> <localleader>r
| 1036 \ :execute 'Term ocaml' expand("%")<cr>
| 1037 endif
| 1038 if isdirectory('/usr/bin/ocaml')
| 1039 autocmd FileType ocaml set path+=/usr/lib/ocaml
| 1040 endif
| 1041 augroup END
| 1042
| 1043 augroup ft_coq
| 1044 autocmd!
| 1045 autocmd FileType coq
| 1046 \ setlocal tabstop=2 softtabstop=2 tabstop=2 smarttab smartindent
| 1047 if filereadable('Makefile')
| 1048 autocmd FileType coq nnoremap <silent> <buffer> <localleader>r
| 1049 \ :Term make<cr>
| 1050 else
| 1051 autocmd FileType coq nnoremap <silent> <buffer> <localleader>r
| 1052 \ :execute 'Term coqc' expand("%")
| 1053 \ <bar> execute 'TermSet ft=coq'<cr>
| 1054 endif
| 1055 augroup END
| 1056
| 1057
| 1058 augroup cfg_quickfix_fix
| 1059 autocmd QuickFixCmdPost [^l]* nested cwindow
| 1060 autocmd QuickFixCmdPost l* nested lwindow
| 1061 augroup end
| 1062
| 1063
1064
+ - 1065 +--559 lines: Misc:
1065
| 1066
| 1067
| 1068
| 1069
| 1070
| 1071
| 1072
| 1073
|+ |- 1074 +--- 94 lines:
1074
|| 1075 let g:jm_vimrc.docs.commands['FindImport'] =
|| 1076 \ 'Given a name, find the corresponding import and add an import statment'
|| 1077 nnoremap <space>t :call <SID>FindImport(expand('<cword>'))<CR>
|| 1078 command -nargs=1 FindImport call <SID>FindImport(<q-args>)
|| 1079 function! s:FindImport(word) abort
|| 1080
|| 1081 if &filetype ==# 'cpp'
|| 1082 let l:res = g:jm_vimrc.cc_import_cache
|| 1083 \->copy()
|| 1084 \->filter({incl, names -> index(names, a:word) != -1})
|| 1085 \->keys()
|| 1086 \->map({k, incl -> printf("#include %s", incl)})
|| 1087 if len(l:res) == 0
|| 1088 echo "FindImport: `" .. a:word .. "` not found!"
|| 1089 elseif len(l:res) > 1
|| 1090 call maktaba#ui#selector#Create(l:res)
|| 1091 \.WithMappings({'<cr>': [function("s:AddImportCpp")->get("name"), 'Close', 'Add import']})
|| 1092 \.Show()
|| 1093 else
|| 1094 call s:AddImportCpp(l:res[0])
|| 1095 endif
|| 1096 return
|| 1097 endif
|| 1098
|| 1099 if &filetype !=# 'java'
|| 1100 throw 'ERROR(InvalidFiletype)'
|| 1101 return
|| 1102 endif
|| 1103
|| 1104
|| 1105 if (has_key(g:jm_vimrc.java_import_cache, a:word))
|| 1106 call s:AddOrSelectImport(get(g:jm_vimrc.java_import_cache, a:word)->mapnew({_, w -> printf('import %s;', w)}))
|| 1107 return
|| 1108 endif
|| 1109
|| 1110
|| 1111 let l:results = printf(
|| 1112 \ '%s --nofilename --nobreak %s',
|| 1113 \ g:jm_vimrc.deps.ag,
|| 1114 \ shellescape(printf('import .+\b%s\b;', a:word)))
|| 1115 \->systemlist()
|| 1116 \->sort()
|| 1117 \->uniq()
|| 1118
|| 1119
|| 1120 if empty(l:results)
|| 1121 let l:results = g:jm_vimrc.deps.JavaClassnameList()
|| 1122 \->filter('v:val =~# a:word')
|| 1123 \->map('"import " .. v:val .. ";"')
|| 1124 endif
|| 1125
|| 1126 call s:AddOrSelectImport(l:results)
|| 1127 endfunction
|| 1128
|| 1129 function! s:AddOrSelectImport(options) abort
|| 1130 if len(a:options) == 1
|| 1131 call s:AddImport(a:options[0])
|| 1132 elseif len(a:options) > 1
|| 1133 call maktaba#ui#selector#Create(a:options)
|| 1134 \.WithMappings({'<cr>': [function("s:AddImport")->get("name"), 'Close', 'Add import']})
|| 1135 \.Show()
|| 1136 endif
|| 1137 endfunction
|| 1138
|| 1139 function! s:AddImport(import) abort
|| 1140 let l:result = search(a:import, 'nw')
|| 1141 if l:result == 0
|| 1142 let l:start = search('^import', 'nw')
|| 1143 if l:start == 0
|| 1144 let l:start = search('^package', 'nw')
|| 1145 call append(l:start, [""])
|| 1146 let l:start += 1
|| 1147 endif
|| 1148 call append(l:start, [a:import])
|| 1149
|| 1150 echom "Adding: " .. a:import
|| 1151 else
|| 1152 echom "Already Present: " .. a:import
|| 1153 endif
|| 1154 endfunction
|| 1155
|| 1156 function! s:AddImportCpp(import) abort
|| 1157 let l:result = search(a:import, 'nw')
|| 1158 if l:result == 0
|| 1159 let l:start = search('^#include', 'nw')
|| 1160 call append(l:start, [a:import])
|| 1161
|| 1162 echom "Adding: " .. a:import
|| 1163 else
|| 1164 echom "Already Present: " .. a:import
|| 1165 endif
|| 1166 endfunction
|| 1167
| 1168
| 1169
| 1170
|+ |- 1171 +--- 40 lines:
1171
|| 1172 let g:jm_vimrc.docs.commands['Javap'] =
|| 1173 \ 'Execute Javap and show output with highlighting'
|| 1174 command! -nargs=? -complete=customlist,<SID>JavapComplete -bang
|| 1175 \ Javap call <SID>Javap(<q-args>, "<bang>" ==# '!')
|| 1176 function! s:Javap(arg, search) abort
|| 1177 if empty($CLASSPATH)
|| 1178 SetupClasspath
|| 1179 endif
|| 1180
|| 1181
|| 1182 let l:cls = empty(a:arg) ? @" : a:arg
|| 1183 let l:cls = substitute(l:cls, '\(;\|<.\+>\)', '', 'ga')
|| 1184
|| 1185 if a:search
|| 1186 let l:results = s:JavapComplete(l:cls, v:none, v:none)
|| 1187 if len(l:results) == 1
|| 1188 let l:cls = l:results[0]
|| 1189 else
|| 1190 call maktaba#ui#selector#Create(l:results)
|| 1191 \.WithMappings({'<cr>': [function("s:JavapOpen")->get("name"), 'Close', 'Open window']})
|| 1192 \.Show()
|| 1193 return
|| 1194 endif
|| 1195 endif
|| 1196
|| 1197 eval g:jm_term
|| 1198 \.Run(join([g:jm_vimrc.deps.javap, l:cls], ' '))
|| 1199 \.Exec('set ft=java')
|| 1200 endfunction
|| 1201
|| 1202 function! s:JavapComplete(arg_lead, cmd_line, cursor_pos) abort
|| 1203 return g:jm_vimrc.deps.JavaClassnameList()
|| 1204 \->filter('v:val =~# a:arg_lead')
|| 1205 endfunction
|| 1206
|| 1207 function! s:JavapOpen(cls) abort
|| 1208 execute 'Javap ' .. a:cls
|| 1209 endfunction
|| 1210
| 1211
| 1212
| 1213
| 1214
|+ |- 1215 +--- 69 lines:
1215
|| 1216 let g:jm_vimrc.docs.commands['MavenSearch'] =
|| 1217 \ 'Search maven, then either add a dependecy or download the jar'
|| 1218 command! -nargs=1 MavenSearch call <SID>MavenSearch(<q-args>)
|| 1219 command! -nargs=1 M MavenSearch <args>
|| 1220 function! s:MavenSearch(query) abort
|| 1221 const l:request = {
|| 1222 \ "page": 0,
|| 1223 \ "size": 20,
|| 1224 \ "searchTerm": a:query,
|| 1225 \ "filter": []
|| 1226 \ }
|| 1227 const l:query_url =
|| 1228 \ 'https://central.sonatype.com/api/internal/browse/components'
|| 1229
|| 1230 const l:query_cmd = join([
|| 1231 \ g:jm_vimrc.deps.curl,
|| 1232 \ '-s',
|| 1233 \ l:query_url,
|| 1234 \ '--json',
|| 1235 \ shellescape(json_encode(l:request))
|| 1236 \ ])
|| 1237
|| 1238 let l:msg = system(l:query_cmd)
|| 1239 let l:resp = json_decode(l:msg)
|| 1240
|| 1241 if l:resp.totalResultCount == 0
|| 1242 echom "None found!"
|| 1243 return
|| 1244 endif
|| 1245 let l:components = l:resp.components
|| 1246 const l:mappings = {
|| 1247 \ '<cr>': [function("s:MInsert")->get("name"), 'Close', 'Insert below'],
|| 1248 \ 'D': [function("s:MDownload")->get("name"), 'Close', 'Insert below'],
|| 1249 \ }
|| 1250 call maktaba#ui#selector#Create(map(l:components, 'v:val.namespace .. ":" .. v:val.name .. ":" .. v:val.latestVersionInfo.version'))
|| 1251 \.WithMappings(l:mappings)
|| 1252 \.Show()
|| 1253 endfunction
|| 1254
|| 1255 function! s:MInsert(msg) abort
|| 1256 let l:spaces = getline('.')->matchstr('^\s*')
|| 1257 call append(line('.'), printf("%simplementation '%s'", l:spaces, a:msg))
|| 1258 endfunction
|| 1259
|| 1260 function! s:MDownload(msg) abort
|| 1261 let [l:package, l:name, l:version] = split(a:msg, ':')
|| 1262 let l:url_package = substitute(l:package, '\.', '/', 'g')
|| 1263 let l:url = printf('https://repo1.maven.org/maven2/%s/%s/%s/',
|| 1264 \ l:url_package,
|| 1265 \ l:name,
|| 1266 \ l:version)
|| 1267 let l:file = printf('%s-%s.jar', l:name, l:version)
|| 1268 let l:file_url = l:url .. l:file
|| 1269 echom l:url .. l:file
|| 1270
|| 1271 const l:cmd = join([
|| 1272 \ g:jm_vimrc.deps.curl,
|| 1273 \ '-o',
|| 1274 \ shellescape(l:file),
|| 1275 \ '-s',
|| 1276 \ shellescape(l:file_url),
|| 1277 \ ])
|| 1278 silent call system(l:cmd)
|| 1279 if v:shell_error
|| 1280 echom 'ERROR: Could not download! ' .. l:file_url
|| 1281 endif
|| 1282 endfunction
|| 1283
| 1284
| 1285
| 1286
| 1287
| 1288
| 1289
| 1290
| 1291
| 1292
| 1293
| 1294
| 1295
| 1296
| 1297
| 1298
| 1299
|+ |- 1300 +--- 69 lines:
1300
|| 1301 function! s:BlazeTargets(fname) abort
|| 1302 let l:query = printf(
|| 1303 \ 'same_pkg_direct_rdeps(%s)',
|| 1304 \ fnamemodify(a:fname, ":p:."),
|| 1305 \ )
|| 1306
|| 1307 let l:command = printf(
|| 1308 \ "%s query '%s'",
|| 1309 \ g:jm_vimrc.deps.blaze,
|| 1310 \ l:query,
|| 1311 \ )
|| 1312 return filter(systemlist(l:command), 'v:val =~# "^//"')
|| 1313 endfunction
|| 1314
|| 1315 function! BlazeGuessCommand(show = v:false) abort
|| 1316 let l:fname = expand('%:p')
|| 1317
|| 1318 let l:target = BlazeTarget()
|| 1319 if l:target ==# "???"
|| 1320 echom "Can't find blaze target!"
|| 1321 return "false"
|| 1322 endif
|| 1323
|| 1324 let l:action = 'build'
|| 1325 if l:fname =~# '\v(_test.cc|Test.java)$' || l:target =~# '\v(_test|Test)$'
|| 1326 let l:action = 'test'
|| 1327 elseif l:fname =~# '\v(main.cc|_bin.cc|Bin.java)$' || l:target =~# '\v(_bin|Bin|main|Main)$'
|| 1328 let l:action = 'run'
|| 1329 elseif l:fname =~# '\v(_bench.cc)$' || l:target =~# '\v(_bench)$'
|| 1330 let l:action = 'run -c opt'
|| 1331 endif
|| 1332
|| 1333 let l:command = printf(
|| 1334 \ "%s %s %s",
|| 1335 \ g:jm_vimrc.deps.blaze,
|| 1336 \ l:action,
|| 1337 \ l:target,
|| 1338 \ )
|| 1339 if a:show
|| 1340 echom 'Using:' l:command
|| 1341 endif
|| 1342 return l:command
|| 1343 endfunction
|| 1344
|| 1345 function! BlazeTarget() abort
|| 1346 return get(s:BlazeTargets(expand('%:p')), 0, "???")
|| 1347 endfunction
|| 1348
|| 1349 function! s:TargetClasspath() abort
|| 1350 let l:target = BlazeTarget()
|| 1351 if l:target ==# "???"
|| 1352 echom "Can't find blaze target!"
|| 1353 return ""
|| 1354 endif
|| 1355
|| 1356 let l:lines = systemlist(printf('blaze print_action "%s"', l:target))
|| 1357 let l:jars = filter(l:lines, {_, v -> v =~# '^\s\+\(outputjar\|classpath\): "[^"]*"'})
|| 1358 \->map({_, v -> matchlist(v, '"\([^"]*\)"')[1]})
|| 1359 return join(l:jars, ':')
|| 1360 endfunction
|| 1361
|| 1362 function! s:CompleteTargets(arg_lead, cmd_line, cursor_pos) abort
|| 1363 if a:arg_lead =~ '^//.*'
|| 1364 return systemlist(printf('%s query ... 2>&1', g:jm_vimrc.deps.blaze))
|| 1365 \->filter('v:val =~# "' .. a:arg_lead .. '"')
|| 1366 endif
|| 1367 endfunction
|| 1368
| 1369
| 1370
| 1371
|+ |- 1372 +--- 16 lines:
1372
|| 1373 let g:jm_vimrc.docs.commands['Touch'] =
|| 1374 \ 'Create files and directories'
|| 1375 command! -nargs=* Touch call s:Touch([<f-args>])
|| 1376 function! s:Touch(paths) abort
|| 1377 for l:path in a:paths
|| 1378 let l:dir = fnamemodify(l:path, ':h')
|| 1379 if l:dir !=# '.' && !isdirectory(l:dir)
|| 1380 call system('mkdir -p ' .. shellescape(l:dir))
|| 1381 endif
|| 1382 if !filereadable(l:path)
|| 1383 call system('touch ' .. shellescape(l:path))
|| 1384 endif
|| 1385 endfor
|| 1386 endfunction
|| 1387
| 1388
| 1389
| 1390
|+ |- 1391 +--- 8 lines:
1391
|| 1392 let g:jm_vimrc.docs.commands['CurrentHLGroup'] =
|| 1393 \ 'Echo name of the highlight group under the cursor'
|| 1394 command! CurrentHLGroup echo s:SyntaxItem()
|| 1395 function! s:SyntaxItem()
|| 1396 return synIDattr(synID(line("."), col("."), 1), "name")
|| 1397 endfunction
|| 1398
| 1399
| 1400
| 1401
| 1402
| 1403
| 1404
|+ |- 1405 +--- 9 lines:
1405
|| 1406 function! s:Async(Fn)
|| 1407 eval timer_start(0, a:Fn)
|| 1408 endfunction
|| 1409
|| 1410 function! s:AsyncExec(...)
|| 1411 eval s:Async({-> execute(join(map(a:000, function('string'))))})
|| 1412 endfunction
|| 1413
| 1414
| 1415
| 1416
|+ |- 1417 +--- 17 lines:
1417
|| 1418 let g:jm_vimrc.docs.commands['ConcealK'] =
|| 1419 \ 'Define conceal rules: eg. ConcealK lambda:λ'
|| 1420 command! -complete=expression -nargs=1 ConcealK call <SID>ConcealK(<q-args>)
|| 1421 function! s:ConcealK(repl_str) abort
|| 1422 let l:repl = {}
|| 1423 let l:i = 0
|| 1424 for [l:keyword, l:replacement] in split(a:repl_str, ' ')->map('v:val->split(":")')
|| 1425 let l:i += 1
|| 1426 execute 'syntax keyword'
|| 1427 \ printf('ConcealK%03d', l:i) l:keyword
|| 1428 \ 'conceal' printf('cchar=%s', l:replacement)
|| 1429 endfor
|| 1430 setlocal conceallevel=1
|| 1431 setlocal concealcursor=ni
|| 1432 endfunction
|| 1433
| 1434
| 1435
| 1436
|+ |- 1437 +--- 5 lines:
1437
|| 1438 let g:jm_vimrc.docs.commands['ReadExecute'] =
|| 1439 \ 'Execute then read the output of that vim command'
|| 1440 command! -nargs=* -complete=command ExecuteRead eval append(line('.'), execute(<q-args>)->split("\n"))
|| 1441
| 1442
| 1443
| 1444
|+ |- 1445 +--- 9 lines:
1445
|| 1446 let g:jm_vimrc.docs.commands['Bdz'] =
|| 1447 \ 'Run buildozer on current target (or :__pkg__ if none exists)'
|| 1448 command! -nargs=* Bdz echom
|| 1449 \ system(printf("fish -c \"buildozer '%s' %s\"",
|| 1450 \ join([<f-args>], ' '),
|| 1451 \ BlazeTarget() != '???' ? BlazeTarget() : ':__pkg__'
|| 1452 \ ))
|| 1453
| 1454
| 1455
| 1456 "format:`cmd`""format: END"
|+ |- 1457 +--- 38 lines:
1457
|| 1458 let g:jm_vimrc.docs.commands['JemFormat'] =
|| 1459 \ 'Format lines between "format:`cmd`" to "format: END"'
|| 1460 command! -nargs=* -complete=customlist,<SID>JemFormatComplete JemFormat eval s:JemFormat[<q-args>]()
|| 1461 let s:JemFormat = {
|| 1462 \ '' : {-> s:JemFormat.format()},
|| 1463 \ 'help' : {-> bss#PP(s:JemFormat, v:true)},
|| 1464 \ }
|| 1465 function! s:JemFormatComplete(arglead, cmdline, curpos) abort
|| 1466 return keys(s:JemFormat)->filter({k, v -> !stridx(v, a:arglead)})
|| 1467 endfunction
|| 1468
|| 1469 function! s:JemFormat.format() abort dict
|| 1470 let command = self.find()
|| 1471 if !empty(command)
|| 1472 silent execute command
|| 1473 endif
|| 1474 endfunction
|| 1475
|| 1476 function! s:JemFormat.find() abort dict
|| 1477 let [_, num, col; _] = getcurpos()
|| 1478 let start_pat = '\v.*for' .. 'mat: `([^`]+)`.*'
|| 1479 let end_pat = '\v.*for' .. 'mat: END.*'
|| 1480 let start_lines = matchbufline(bufnr(), start_pat, 1, num)
|| 1481 let start_line = bss#Last(start_lines)
|| 1482 let end_line = start_line
|| 1483 \->bss#Get('lnum')
|| 1484 \->bss#Apply({l -> matchbufline(bufnr(), end_pat, l, '$')})
|| 1485 \->bss#Apply('bss#Last')
|| 1486 \->bss#Or('$')
|| 1487 if start_line is v:none
|| 1488 return ''
|| 1489 endif
|| 1490 let range = [start_line.lnum + 1, end_line.lnum - 1]->join(',')
|| 1491 let command = substitute(start_line.text, start_pat, '\1', '')
|| 1492 return join([range, command], ' ')
|| 1493 endfunction
|| 1494
| 1495
| 1496
| 1497
| 1498
| 1499
| 1500
| 1501
| 1502
|+ |- 1503 +--- 50 lines:
1503
|| 1504 command! -nargs=1 -complete=file SetupAppendMarkdownBlock
|| 1505 \ nnoremap <buffer> \r :AppendMarkdownBlock <args><cr>
|| 1506 command! -nargs=1 -complete=file -range=% AppendMarkdownBlock
|| 1507 \ eval AppendMarkdownBlock(<q-args>, <line1>, <line2>)
|| 1508 command! -nargs=1 -complete=file AppendMarkdownBlockDebug
|| 1509 \ eval AppendMarkdownBlock(<q-args>, 0, '$', v:true)
|| 1510
|| 1511 function! AppendMarkdownBlock(fname, begin=0, end='$', debug=v:false) abort
|| 1512 let lines = getline(a:begin, a:end)->s:Markdown_lines2codeblock()
|| 1513 if !a:debug
|| 1514 call s:AppendMarkdownBlock_write(a:fname, lines)
|| 1515 else
|| 1516 call s:AppendMarkdownBlock_dump(a:fname, lines)
|| 1517 endif
|| 1518 endfunction
|| 1519
|| 1520
|| 1521
|| 1522
|| 1523 function! s:Markdown_lines2codeblock(lines) abort
|| 1524 let prefix = '```'
|| 1525 let suffix = prefix
|| 1526 return [prefix] + a:lines + [suffix]
|| 1527 endfunction
|| 1528
|| 1529
|| 1530
|| 1531
|| 1532
|| 1533 function! s:AppendMarkdownBlock_write(fname, lines) abort
|| 1534 let prefix = (readfile(a:fname)->bss#Last()->empty())
|| 1535 \ ? [] : [""]
|| 1536 call writefile(prefix + a:lines, a:fname, 'a')
|| 1537 echom "Wrote file" a:fname
|| 1538 endfunction
|| 1539
|| 1540
|| 1541
|| 1542
|| 1543 function! s:AppendMarkdownBlock_dump(fname, lines) abort
|| 1544
|| 1545 echo 'fname:' a:fname
|| 1546 echo 'lines:'
|| 1547 echo
|| 1548 for l in a:lines
|| 1549 echo ' ' .. l
|| 1550 endfor
|| 1551 endfunction
|| 1552
| 1553
| 1554
| 1555
|+ |- 1556 +--- 17 lines:
1556
|| 1557 command! -nargs=? -complete=customlist,s:SetupSlimeTarget_Complete SetupSlimeTarget call s:SetupSlimeTarget(<q-args>)
|| 1558 let s:SlimeTargets = [
|| 1559 \ 'tmux',
|| 1560 \ 'vimterminal',
|| 1561 \ ]
|| 1562 function! s:SetupSlimeTarget(arg) abort
|| 1563 if empty(a:arg)
|| 1564 echom printf('Current slime target: %s', g:slime_target)
|| 1565 else
|| 1566 let g:slime_target = a:arg
|| 1567 endif
|| 1568 endfunction
|| 1569 function! s:SetupSlimeTarget_Complete(arg, ...) abort
|| 1570 return s:SlimeTargets->filter('stridx(v:val, a:arg) == 0')
|| 1571 endfunction
|| 1572
| 1573
| 1574 function! Layout() abort
| 1575 let layout = winlayout()
| 1576 return s:InvertLayout(layout)
| 1577 endfunction
| 1578 function! s:InvertLayout(l, path=[]) abort
| 1579 if len(a:l) != 2
| 1580 throw "ERROR(InvalidArguments): s:InvertLayout expects only 2-element lists"
| 1581 endif
| 1582 let [kind, val] = a:l
| 1583 if kind ==# 'leaf'
| 1584 return {val: join(a:path, '')}
| 1585 elseif kind ==# 'col'
| 1586 return val
| 1587 \->map('s:InvertLayout(v:val, a:path + ["|"])')
| 1588 \->reduce({a, b -> extend(a, b)})
| 1589 elseif kind ==# 'row'
| 1590 return val
| 1591 \->map('s:InvertLayout(v:val, a:path + ["-"])')
| 1592 \->reduce({a, b -> extend(a, b)})
| 1593 endif
| 1594 endfunction
| 1595
| 1596
| 1597
| 1598
| 1599
|+ |- 1600 +--- 22 lines:
1600
|| 1601 command! FindOrMakeJavaTest call s:FindOrMakeJavaTest()
|| 1602 function! s:FindOrMakeJavaTest() abort
|| 1603 let l:path = expand('%:p:h')
|| 1604 let l:name = expand('%:t:r')
|| 1605 let l:extn = expand('%:t:e')
|| 1606 if l:path =~# ".*/src/main/java/.*"
|| 1607 let l:path = substitute(l:path, "src/main/java", "src/test/java", "")
|| 1608 let l:name .= 'Test'
|| 1609 elseif l:path =~# ".*/src/test/java/.*" && l:name =~# ".*Test$"
|| 1610 let l:path = substitute(l:path, "src/test/java", "src/main/java", "")
|| 1611 let l:name = l:name[:-5]
|| 1612 elseif l:path =~# ".*/java/.*"
|| 1613 let l:path = substitute(l:path, "/java/", "/javatests/", "")
|| 1614 let l:name .= 'Test'
|| 1615 elseif l:path =~# ".*/javatests/.*" && l:name =~# ".*Test$"
|| 1616 let l:path = substitute(l:path, "/javatests/", "/java/", "")
|| 1617 let l:name = l:name[:-5]
|| 1618 endif
|| 1619 execute 'edit' $"{l:path}/{l:name}.{l:extn}"
|| 1620 endfunction
|| 1621
| 1622
| 1623
1624
+ - 1625 +-- 5 lines: Notes
1625
| 1626 let s:Wtf = bss#wtf#Initialize()
| 1627 call bss#wtf#AddDict(['mappings', 'm'], g:jm_vimrc.docs.mappings)
| 1628 call bss#wtf#AddDict(['commands', 'c'], g:jm_vimrc.docs.commands)
| 1629
1630
1631
1632
1633
1634 TODO
+ - 1635 +--271 lines: Java Import Cache:
1635
| 1636 let g:jm_vimrc.java_import_list =<< JAVA_IMPORT_LIST_END
| 1637 com.google.auto.common.AnnotationMirrors
| 1638 com.google.auto.common.AnnotationValues
| 1639 com.google.auto.common.BasicAnnotationProcessor
| 1640 com.google.auto.common.MoreElements
| 1641 com.google.auto.common.MoreTypes
| 1642 com.google.common.base.Stopwatch
| 1643 com.google.common.collect.ImmutableList
| 1644 com.google.common.collect.ImmutableMap
| 1645 com.google.common.collect.ImmutableSet
| 1646 com.google.common.collect.ImmutableTable
| 1647 com.google.common.collect.Lists
| 1648 com.google.common.collect.Streams
| 1649 com.google.common.collect.Table
| 1650 com.google.common.collect.Tables
| 1651 com.google.common.math.Stats
| 1652 com.google.common.math.StatsAccumulator
| 1653 com.google.common.util.concurrent.AbstractExecutionThreadService
| 1654 com.google.common.util.concurrent.AbstractFuture
| 1655 com.google.common.util.concurrent.AbstractScheduledService
| 1656 com.google.common.util.concurrent.AbstractTransformFuture
| 1657 com.google.common.util.concurrent.FutureCallback
| 1658 com.google.common.util.concurrent.Futures
| 1659 com.google.common.util.concurrent.ListenableFuture
| 1660 com.google.common.util.concurrent.ListenableFutureTask
| 1661 com.google.common.util.concurrent.ListenableScheduledFuture
| 1662 com.google.common.util.concurrent.ListenerCallQueue
| 1663 com.google.common.util.concurrent.ListeningExecutorService
| 1664 com.google.common.util.concurrent.ListeningScheduledExecutorService
| 1665 com.google.common.util.concurrent.MoreExecutors
| 1666 com.google.common.util.concurrent.SettableFuture
| 1667 com.google.common.util.concurrent.Uninterruptibles
| 1668 com.squareup.javapoet.ClassName
| 1669 com.squareup.javapoet.CodeBlock
| 1670 com.squareup.javapoet.FieldSpec
| 1671 com.squareup.javapoet.JavaFile
| 1672 com.squareup.javapoet.MethodSpec
| 1673 com.squareup.javapoet.ParameterSpec
| 1674 com.squareup.javapoet.ParameterizedTypeName
| 1675 com.squareup.javapoet.TypeName
| 1676 com.squareup.javapoet.TypeSpec
| 1677 dagger.Binds
| 1678 dagger.BindsInstance
| 1679 dagger.Component
| 1680 dagger.MapKey
| 1681 dagger.Module
| 1682 dagger.Provides
| 1683 dagger.multibindings.ClassKey
| 1684 dagger.multibindings.ElementsIntoSet
| 1685 dagger.multibindings.IntKey
| 1686 dagger.multibindings.IntoMap
| 1687 dagger.multibindings.IntoSet
| 1688 dagger.multibindings.LongKey
| 1689 dagger.multibindings.Multibinds
| 1690 dagger.multibindings.StringKey
| 1691 dagger.producers.Produced
| 1692 dagger.producers.Producer
| 1693 dagger.producers.ProducerModule
| 1694 dagger.producers.Producers
| 1695 dagger.producers.Produces
| 1696 dagger.producers.Production
| 1697 dagger.producers.ProductionComponent
| 1698 dagger.producers.ProductionScope
| 1699 dagger.producers.ProductionSubcomponent
| 1700 dagger.producers.monitoring.ProducerMonitor
| 1701 dagger.producers.monitoring.ProducerToken
| 1702 dagger.producers.monitoring.ProductionComponentMonitor
| 1703 java.io.IOException
| 1704 java.lang.reflect.AnnotatedElement
| 1705 java.lang.reflect.Executable
| 1706 java.lang.reflect.Field
| 1707 java.lang.reflect.GenericDeclaration
| 1708 java.lang.reflect.Method
| 1709 java.lang.reflect.Modifier
| 1710 java.lang.reflect.Type
| 1711 java.nio.file.Files
| 1712 java.nio.file.Path
| 1713 java.util.ArrayList
| 1714 java.util.Arrays
| 1715 java.util.Collection
| 1716 java.util.HashMap
| 1717 java.util.HashSet
| 1718 java.util.Iterator
| 1719 java.util.LinkedList
| 1720 java.util.List
| 1721 java.util.Map
| 1722 java.util.NavigableMap
| 1723 java.util.Optional
| 1724 java.util.OrderedMap
| 1725 java.util.Set
| 1726 java.util.TreeMap
| 1727 java.util.TreeSet
| 1728 java.util.concurrent.ConcurrentHashMap
| 1729 java.util.concurrent.CopyOnWriteArrayList
| 1730 java.util.concurrent.ExecutionException
| 1731 java.util.concurrent.Executor
| 1732 java.util.concurrent.ExecutorService
| 1733 java.util.concurrent.Executors
| 1734 java.util.concurrent.Future
| 1735 java.util.concurrent.ThreadPoolExecutor
| 1736 java.util.concurrent.TimeUnit
| 1737 java.util.concurrent.atomic.AtomicInteger
| 1738 java.util.concurrent.atomic.AtomicLong
| 1739 java.util.concurrent.atomic.LongAdder
| 1740 java.util.function.Consumer
| 1741 java.util.function.Function
| 1742 java.util.function.Predicate
| 1743 java.util.function.Supplier
| 1744 java.util.stream.Collector
| 1745 java.util.stream.Collectors
| 1746 java.util.stream.Stream
| 1747 javax.annotation.processing.AbstractProcessor
| 1748 javax.annotation.processing.Completion
| 1749 javax.annotation.processing.Completions
| 1750 javax.annotation.processing.Filer
| 1751 javax.annotation.processing.FilerException
| 1752 javax.annotation.processing.Generated
| 1753 javax.annotation.processing.Messager
| 1754 javax.annotation.processing.ProcessingEnvironment
| 1755 javax.annotation.processing.Processor
| 1756 javax.annotation.processing.RoundEnvironment
| 1757 javax.annotation.processing.SupportedAnnotationTypes
| 1758 javax.annotation.processing.SupportedOptions
| 1759 javax.annotation.processing.SupportedSourceVersion
| 1760 javax.inject.Inject
| 1761 javax.inject.Named
| 1762 javax.inject.Provider
| 1763 javax.inject.Qualifier
| 1764 javax.inject.Singleton
| 1765 javax.lang.model.element.Element
| 1766 javax.lang.model.element.ElementVisitor
| 1767 javax.lang.model.element.ExecutableElement
| 1768 javax.lang.model.element.Modifier
| 1769 javax.lang.model.element.TypeElement
| 1770 javax.lang.model.type.TypeMirror
| 1771 org.apache.commons.lang3.builder.ReflectionToStringBuilder
| 1772 org.apache.commons.lang3.builder.ToStringStyle
| 1773 org.objectweb.asm.ClassReader
| 1774 org.objectweb.asm.ClassVisitor
| 1775 org.objectweb.asm.ClassWriter
| 1776 org.objectweb.asm.FieldVisitor
| 1777 org.objectweb.asm.MethodVisitor
| 1778 org.objectweb.asm.Opcodes
| 1779 org.objectweb.asm.TypePath
| 1780 org.openjdk.jmh.annotations.AuxCounters
| 1781 org.openjdk.jmh.annotations.Benchmark
| 1782 org.openjdk.jmh.annotations.BenchmarkMode
| 1783 org.openjdk.jmh.annotations.CompilerControl
| 1784 org.openjdk.jmh.annotations.Fork
| 1785 org.openjdk.jmh.annotations.Group
| 1786 org.openjdk.jmh.annotations.GroupThreads
| 1787 org.openjdk.jmh.annotations.Level
| 1788 org.openjdk.jmh.annotations.Measurement
| 1789 org.openjdk.jmh.annotations.Mode
| 1790 org.openjdk.jmh.annotations.OperationsPerInvocation
| 1791 org.openjdk.jmh.annotations.OutputTimeUnit
| 1792 org.openjdk.jmh.annotations.Param
| 1793 org.openjdk.jmh.annotations.Scope
| 1794 org.openjdk.jmh.annotations.Setup
| 1795 org.openjdk.jmh.annotations.State
| 1796 org.openjdk.jmh.annotations.TearDown
| 1797 org.openjdk.jmh.annotations.Threads
| 1798 org.openjdk.jmh.annotations.Timeout
| 1799 org.openjdk.jmh.annotations.Warmup
| 1800 org.openjdk.jmh.infra.BenchmarkParams
| 1801 org.openjdk.jmh.infra.Blackhole
| 1802 org.openjdk.jmh.infra.Control
| 1803 org.openjdk.jmh.infra.IterationParams
| 1804 org.openjdk.jmh.infra.ThreadParams
| 1805 org.openjdk.jmh.results.RunResult
| 1806 org.openjdk.jmh.results.format.ResultFormatType
| 1807 org.openjdk.jmh.runner.Runner
| 1808 org.openjdk.jmh.runner.RunnerException
| 1809 org.openjdk.jmh.runner.options.CommandLineOptionException
| 1810 org.openjdk.jmh.runner.options.CommandLineOptions
| 1811 org.openjdk.jmh.runner.options.Options
| 1812 org.openjdk.jmh.runner.options.OptionsBuilder
| 1813 static com.google.common.collect.ImmutableList.toImmutableList
| 1814 static com.google.common.collect.ImmutableSet.toImmutableSet
| 1815 static com.google.common.truth.Truth.assertThat
| 1816 static com.google.common.truth.Truth.assertWithMessage
| 1817 static com.google.common.util.concurrent.MoreExecutors.directExecutor
| 1818 static java.util.concurrent.TimeUnit.DAYS
| 1819 static java.util.concurrent.TimeUnit.HOURS
| 1820 static java.util.concurrent.TimeUnit.MICROSECONDS
| 1821 static java.util.concurrent.TimeUnit.MILLISECONDS
| 1822 static java.util.concurrent.TimeUnit.MINUTES
| 1823 static java.util.concurrent.TimeUnit.NANOSECONDS
| 1824 static java.util.concurrent.TimeUnit.SECONDS
| 1825 static java.util.stream.Collectors.averagingDouble
| 1826 static java.util.stream.Collectors.averagingInt
| 1827 static java.util.stream.Collectors.averagingLong
| 1828 static java.util.stream.Collectors.collectingAndThen
| 1829 static java.util.stream.Collectors.counting
| 1830 static java.util.stream.Collectors.filtering
| 1831 static java.util.stream.Collectors.flatMapping
| 1832 static java.util.stream.Collectors.groupingBy
| 1833 static java.util.stream.Collectors.joining
| 1834 static java.util.stream.Collectors.mapping
| 1835 static java.util.stream.Collectors.maxBy
| 1836 static java.util.stream.Collectors.minBy
| 1837 static java.util.stream.Collectors.partitioningBy
| 1838 static java.util.stream.Collectors.reducing
| 1839 static java.util.stream.Collectors.summarizingDouble
| 1840 static java.util.stream.Collectors.summarizingInt
| 1841 static java.util.stream.Collectors.summarizingLong
| 1842 static java.util.stream.Collectors.summingDouble
| 1843 static java.util.stream.Collectors.summingInt
| 1844 static java.util.stream.Collectors.summingLong
| 1845 static java.util.stream.Collectors.toCollection
| 1846 static java.util.stream.Collectors.toConcurrentMap
| 1847 static java.util.stream.Collectors.toList
| 1848 static java.util.stream.Collectors.toMap
| 1849 static java.util.stream.Collectors.toSet
| 1850 static java.util.stream.Collectors.toUnmodifiableList
| 1851 static java.util.stream.Collectors.toUnmodifiableMap
| 1852 static java.util.stream.Collectors.toUnmodifiableSet
| 1853 java.net.ServerSocket
| 1854 java.net.Socket
| 1855 java.io.OutputStream
| 1856 com.google.common.flogger.FluentLogger
| 1857 static com.google.common.util.concurrent.Futures.immediateFuture
| 1858 java.util.concurrent.atomic.AtomicReference
| 1859 static com.google.common.util.concurrent.Futures.immediateVoidFuture
| 1860 java.util.concurrent.atomic.AtomicMarkableReference
| 1861 java.util.Random
| 1862 java.time.Instant
| 1863 static com.google.common.base.Preconditions.checkArgument
| 1864 static com.google.common.base.Preconditions.checkNotNull
| 1865 static org.mockito.Mockito.mock
| 1866 static org.mockito.Mockito.verify
| 1867 static org.mockito.ArgumentMatchers.any
| 1868 static org.mockito.Mockito.times
| 1869 static org.mockito.AdditionalMatchers.and
| 1870 static org.mockito.ArgumentMatchers.assertArg
| 1871 JAVA_IMPORT_LIST_END
| 1872
| 1873 command! AddJavaImport call AddJavaImport(getline('.'))
| 1874 function! AddJavaImport(content) abort
| 1875 let content = a:content
| 1876 \->substitute('^import ', '', '')
| 1877 \->substitute(';$', '', '')
| 1878 if index(g:jm_vimrc.java_import_list, content) != -1
| 1879 echom "Already present:" content
| 1880 return
| 1881 endif
| 1882 let lines = readfile($MYVIMRC)
| 1883 let index = match(lines, '^JAVA_IMPORT_LIST_END$')
| 1884 call insert(lines, content, index)
| 1885 call writefile(lines, $MYVIMRC)
| 1886 echom "Added:" content
| 1887 endfunction
| 1888
| 1889 function! s:ProcessJavaImportList(import_list) abort
| 1890 let cache = {}
| 1891 for elem in a:import_list
| 1892 let name = slice(elem, strridx(elem, '.') + 1)
| 1893 if has_key(cache, name)
| 1894 call add(cache[name], elem)
| 1895 else
| 1896 let cache[name] = [elem]
| 1897 endif
| 1898 endfor
| 1899 return cache
| 1900 endfunction
| 1901
| 1902 let g:jm_vimrc.java_import_cache =
| 1903 \ s:ProcessJavaImportList(g:jm_vimrc.java_import_list)
| 1904
| 1905
1906
1907
+ - 1908 +--193 lines: C++ Import Cache:
1908
| 1909 let g:jm_vimrc.cc_import_cache = {
| 1910 \ '"absl/flags/flag.h"': ['ABSL_FLAG', 'GetFlag'],
| 1911 \ '"absl/flags/declare.h"': ['ABSL_DECLARE_FLAG'],
| 1912 \ '"absl/flags/parse.h"': ['ParseCommandLine'],
| 1913 \ '"absl/flags/usage.h"': ['ProgramUsageMessage', 'SetProgramUsageMessage'],
| 1914 \ '"absl/strings/str_join.h"': ['StrJoin'],
| 1915 \ '"absl/strings/str_cat.h"': ['StrCat'],
| 1916 \ '"absl/strings/str_replace.h"': ['StrReplaceAll'],
| 1917 \ '"absl/strings/str_split.h"': ['StrSplit'],
| 1918 \ '"absl/status/status.h"': ['Status'],
| 1919 \ '"absl/status/statusor.h"': ['StatusOr'],
| 1920 \ '<opencv2/core.hpp>': [
| 1921 \ 'Mat',
| 1922 \ 'Mat_',
| 1923 \ 'Mat1b', 'Mat2b', 'Mat3b', 'Mat4b',
| 1924 \ 'Mat1i', 'Mat2i', 'Mat3i', 'Mat4i',
| 1925 \ 'Mat1f', 'Mat2f', 'Mat3f', 'Mat4f',
| 1926 \ 'Mat1d', 'Mat2d', 'Mat3d', 'Mat4d',
| 1927 \ 'Matx',
| 1928 \ 'Matx22f', 'Matx33f', 'Matx44f',
| 1929 \ 'Matx21f', 'Matx31f', 'Matx41f',
| 1930 \ 'Matx22d', 'Matx33d', 'Matx44d',
| 1931 \ 'Matx21d', 'Matx31d', 'Matx41d',
| 1932 \ 'Vec',
| 1933 \ 'Vec1b', 'Vec2b', 'Vec3b', 'Vec4b', 'Vec6b',
| 1934 \ 'Vec1i', 'Vec2i', 'Vec3i', 'Vec4i', 'Vec6i',
| 1935 \ 'Vec1f', 'Vec2f', 'Vec3f', 'Vec4f', 'Vec6f',
| 1936 \ 'Vec1d', 'Vec2d', 'Vec3d', 'Vec4d', 'Vec6d',
| 1937 \ 'Scalar_', 'Scalar',
| 1938 \ 'Point_', 'Point2i', 'Point2l', 'Point2f', 'Point2d',
| 1939 \ 'Point3_', 'Point3i', 'Point3l', 'Point3f', 'Point3d',
| 1940 \ 'abs',
| 1941 \ 'exp', 'log',
| 1942 \ 'pow', 'sqrt',
| 1943 \ ],
| 1944 \ '<opencv2/imgcodecs.hpp>': ['imread', 'imwrite'],
| 1945 \ '<opencv2/imgproc.hpp>': ['circle'],
| 1946 \ '<utility>': [
| 1947 \ 'forward', 'declval',
| 1948 \ 'move', 'swap', 'exchange',
| 1949 \ 'integer_sequence', 'make_integer_sequence',
| 1950 \ 'index_sequence', 'make_index_sequence',
| 1951 \ 'pair', 'make_pair',
| 1952 \ ],
| 1953 \ '<memory>': ['unique_ptr', 'make_unique'],
| 1954 \ '<vector>': ['vector'],
| 1955 \ '<tuple>': [
| 1956 \ 'tuple',
| 1957 \ 'tuple_size',
| 1958 \ 'tuple_element',
| 1959 \ 'get',
| 1960 \ ],
| 1961 \ '<type_traits>': [
| 1962 \ 'enable_if', 'conditional',
| 1963 \ 'enable_if_t', 'conditional_t',
| 1964 \ 'integral_constant', 'bool_constant',
| 1965 \ 'true_type', 'false_type',
| 1966 \ 'conjunction', 'disjunction', 'negation',
| 1967 \ 'conjunction_v', 'disjunction_v', 'negation_v',
| 1968 \ 'is_same', 'is_base_of', 'is_convertible',
| 1969 \ 'is_same_v', 'is_base_of_v', 'is_convertible_v',
| 1970 \ ],
| 1971 \ '<array>': ['array'],
| 1972 \ '<valarray>': ['valarray'],
| 1973 \ '<cstddef>': [
| 1974 \ 'size_t', 'ptrdiff_t', 'nullptr_t',
| 1975 \ ],
| 1976 \ '<future>': [
| 1977 \ 'future', 'promise', 'async', 'launch',
| 1978 \ ],
| 1979 \ '<thread>': [
| 1980 \ 'thread', 'this_thread', 'yield', 'get_id', 'sleep_for',
| 1981 \ ],
| 1982 \ '<cstdint>': [
| 1983 \ 'int8_t', 'int16_t', 'int32_t', 'int64_t',
| 1984 \ 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t',
| 1985 \ ],
| 1986 \ '<cmath>': [
| 1987 \ 'abs',
| 1988 \ 'exp', 'log', 'log2', 'log10',
| 1989 \ 'pow', 'sqrt', 'hypot',
| 1990 \ 'sin', 'cos', 'tan',
| 1991 \ 'asin', 'acos', 'atan',
| 1992 \ 'sinh', 'cosh', 'tanh',
| 1993 \ 'asinh', 'acosh', 'atanh',
| 1994 \ 'ceil', 'floor', 'trunc', 'round',
| 1995 \ ],
| 1996 \ '<string>': [
| 1997 \ 'string',
| 1998 \ 'to_string',
| 1999 \ 'stoi', 'stol', 'stoul', 'stoll', 'stoull',
| 2000 \ 'stof', 'stod', 'stold',
| 2001 \ ],
| 2002 \ '<map>': ['map'],
| 2003 \ '<unordered_map>': ['unordered_map'],
| 2004 \ '<set>': ['set'],
| 2005 \ '<iostream>': [
| 2006 \ 'cout', 'cin', 'cerr',
| 2007 \ 'endl',
| 2008 \ ],
| 2009 \ '<ios>': [
| 2010 \ 'internal', 'left', 'right',
| 2011 \ 'boolalpha', 'showbase', 'showpos',
| 2012 \ 'dec', 'hex', 'oct',
| 2013 \ 'fixed', 'scientific', 'default',
| 2014 \ ],
| 2015 \ '<format>': ['format'],
| 2016 \ '<iomanip>': [
| 2017 \ 'setw',
| 2018 \ 'quoted',
| 2019 \ ],
| 2020 \ '<unordered_set>': ['unordered_set'],
| 2021 \ '<optional>': ['optional'],
| 2022 \ '<complex>': ['complex'],
| 2023 \ '<initializer_list>': ['initializer_list'],
| 2024 \ '<numeric>': [
| 2025 \ 'iota',
| 2026 \ 'accumulate',
| 2027 \ 'reduce',
| 2028 \ 'inner_product',
| 2029 \ 'adjacent_difference',
| 2030 \ 'partial_sum',
| 2031 \ ],
| 2032 \ '<cstdlib>': [
| 2033 \ 'system',
| 2034 \ 'exit',
| 2035 \ 'getenv',
| 2036 \ 'malloc',
| 2037 \ 'free',
| 2038 \ 'aligned_malloc',
| 2039 \ ],
| 2040 \ '<random>': [
| 2041 \ 'random_device',
| 2042 \ 'mt19937',
| 2043 \ 'mt19937_64',
| 2044 \ 'uniform_real_distribution',
| 2045 \ 'uniform_int_distribution',
| 2046 \ 'normal_distribution',
| 2047 \ ],
| 2048 \ '<functional>': [
| 2049 \ 'function',
| 2050 \ 'plus', 'minus', 'multiplies', 'divides',
| 2051 \ 'equal_to', 'not_equal_to',
| 2052 \ 'greater', 'less', 'greater_equal', 'less_equal',
| 2053 \ 'logical_and', 'logical_or', 'logical_not',
| 2054 \ 'bit_end', 'bit_or', 'bit_xor', 'bit_not',
| 2055 \ ],
| 2056 \ '<algorithm>': [
| 2057 \
| 2058 \ 'all_of', 'any_of', 'none_of',
| 2059 \ 'for_each', 'for_each_n',
| 2060 \ 'count', 'count_if',
| 2061 \ 'mismatch',
| 2062 \ 'find', 'find_if', 'find_if_not',
| 2063 \ 'find_end', 'find_first_of', 'adjacent_find',
| 2064 \ 'search', 'search_n',
| 2065 \
| 2066 \ 'copy', 'copy_backward', 'move', 'move_backward', 'copy_n',
| 2067 \ 'fill', 'fill_n', 'transform', 'generate', 'generate_n',
| 2068 \ 'remove', 'remove_if', 'remove_copy', 'remove_copy_if',
| 2069 \ 'replace', 'replace_if', 'replace_copy', 'replace_copy_if',
| 2070 \ 'swap', 'swap_ranges', 'swap_iter',
| 2071 \ 'reverse', 'reverse_copy', 'rotate',
| 2072 \ 'rotate_copy',
| 2073 \ 'shuffle',
| 2074 \ 'max', 'min', 'max_element', 'min_element', 'minmax',
| 2075 \ ],
| 2076 \ '"absl/algorithm/container.h"': [
| 2077 \
| 2078 \ 'c_all_of', 'c_any_of', 'c_none_of',
| 2079 \ 'c_for_each', 'c_for_each_n',
| 2080 \ 'c_count', 'c_count_if',
| 2081 \ 'c_mismatch',
| 2082 \ 'c_find', 'c_find_if', 'c_find_if_not',
| 2083 \ 'c_find_end', 'c_find_first_of', 'c_adjacent_find',
| 2084 \ 'c_search', 'c_search_n',
| 2085 \
| 2086 \ 'c_copy', 'c_copy_backward', 'c_move', 'c_move_backward', 'c_copy_n',
| 2087 \ 'c_fill', 'c_fill_n', 'c_transform', 'c_generate', 'c_generate_n',
| 2088 \ 'c_remove', 'c_remove_if', 'c_remove_copy', 'c_remove_copy_if',
| 2089 \ 'c_replace', 'c_replace_if', 'c_replace_copy', 'c_replace_copy_if',
| 2090 \ 'c_swap', 'c_swap_ranges', 'c_swap_iter',
| 2091 \ 'c_reverse', 'c_reverse_copy', 'c_rotate',
| 2092 \ 'c_rotate_copy',
| 2093 \ 'c_shuffle',
| 2094 \ ],
| 2095 \ '<iterator>': [
| 2096 \ 'istream_iterator',
| 2097 \ 'ostream_iterator',
| 2098 \ ],
| 2099 \ }
| 2100