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