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