changeset 504:015e94f44cc0

Merged changes.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 30 Sep 2020 21:17:47 -0700
parents 35094cf31de4 (current diff) 823b7336639a (diff)
children c19fd52542ba
files .hgignore
diffstat 11 files changed, 226 insertions(+), 130 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Apr 20 16:24:08 2020 -0700
+++ b/.hgignore	Wed Sep 30 21:17:47 2020 -0700
@@ -13,6 +13,7 @@
 vim/vimrc-local
 vim/vimrc-local-pre
 vim/bundle/
+vim/fzf-history/
 vim/local/
 vim/fzf-history/
 weechat/logs
--- a/hgrc/hgrc	Mon Apr 20 16:24:08 2020 -0700
+++ b/hgrc/hgrc	Wed Sep 30 21:17:47 2020 -0700
@@ -33,8 +33,6 @@
 delay = 1
 
 [schemes]
-bb+ssh = ssh://hg@bitbucket.org/
-bb+me = ssh://hg@bitbucket.org/ludovicchabant/
 gh+ssh = git+ssh://git@github.com:{1}/{2}.git
 gh+me = git+ssh://git@github.com:ludovicchabant/{1}.git
 srht+ssh = ssh://hg@hg.sr.ht/
--- a/hgrc/hgrc-Windows_NT	Mon Apr 20 16:24:08 2020 -0700
+++ b/hgrc/hgrc-Windows_NT	Wed Sep 30 21:17:47 2020 -0700
@@ -1,12 +1,12 @@
-[ui]
-ssh = "%USERPROFILE%\scoop\shims\plink.exe" -ssh -2 -batch -C
-editor = "C:\Program Files (x86)\Vim\vim80\vim.exe"
-
-[extdiff]
-cmds.wdiff = "C:\Program Files (x86)\WinMerge\WinMergeU.exe"
-
-[tortoisehg]
-editor = "C:\Program Files (x86)\Notepad++\notepad++.exe"
-vdiff = "C:\Program Files (x86)\WinMerge\WinMergeU.exe"
-
-# vim: ft=cfg
+[ui]
+ssh = "%USERPROFILE%\scoop\shims\plink.exe" -ssh -2 -batch -C
+editor = "%USERPROFILE%\scoop\shims\vim.exe"
+
+[extdiff]
+cmds.wdiff = "C:\Program Files (x86)\WinMerge\WinMergeU.exe"
+
+[tortoisehg]
+editor = "C:\Program Files (x86)\Notepad++\notepad++.exe"
+vdiff = "C:\Program Files (x86)\WinMerge\WinMergeU.exe"
+
+# vim: ft=cfg
--- a/install.cfg	Mon Apr 20 16:24:08 2020 -0700
+++ b/install.cfg	Wed Sep 30 21:17:47 2020 -0700
@@ -3,15 +3,14 @@
 
 lib/fzf = [git]https://github.com/junegunn/fzf.git
 
-lib/hg/allpaths = https://bitbucket.org/ludovicchabant/allpaths
-lib/hg/fast-hg-prompt = https://bitbucket.org/ludovicchabant/fast-hg-prompt
-lib/hg/hg-git = https://bitbucket.org/durin42/hg-git
-lib/hg/hg-git-sync = https://bitbucket.org/ludovicchabant/hg-git-sync
-lib/hg/hg-prompt = https://bitbucket.org/sjl/hg-prompt
-lib/hg/mercurial-cli-templates = https://bitbucket.org/sjl/mercurial-cli-templates
+lib/hg/allpaths = https://hg.sr.ht/~ludovicchabant/allpaths
+lib/hg/fast-hg-prompt = https://hg.sr.ht/~ludovicchabant/fast-hg-prompt
+lib/hg/hg-git = https://foss.heptapod.net/mercurial/hg-git
+lib/hg/hg-git-sync = https://hg.sr.ht/~ludovicchabant/hg-git-sync
+lib/hg/hg-prompt = https://hg.stevelosh.com/hg-prompt
+lib/hg/mercurial-cli-templates = https://hg.stevelosh.com/mercurial-cli-templates
 lib/hg/evolve = https://www.mercurial-scm.org/repo/evolve
-lib/hg/onsub = https://bitbucket.org/ludovicchabant/onsub
-lib/hg/path-pattern = https://bitbucket.org/Mekk/mercurial-path_pattern
+lib/hg/onsub = https://hg.sr.ht/~ludovicchabant/onsub
 
 lib/iterm2/color-schemes = [git]https://github.com/mbadolato/iTerm2-Color-Schemes.git
 
@@ -20,7 +19,7 @@
 
 [vimbundles]
 ack = [git]https://github.com/mileszs/ack.vim.git
-badwolf = https://bitbucket.org/sjl/badwolf
+badwolf = https://hg.stevelosh.com/badwolf
 colorschemes = [git]https://github.com/ludovicchabant/vim-colorschemes.git
 commentary = [git]https://github.com/tpope/vim-commentary.git
 easymotion = [git]https://github.com/Lokaltog/vim-easymotion.git
@@ -28,18 +27,18 @@
 fugitive = [git]https://github.com/tpope/vim-fugitive.git
 fzf = [git]https://github.com/junegunn/fzf.vim.git
 goyo = [git]https://github.com/junegunn/goyo.vim.git
-gundo = https://bitbucket.org/sjl/gundo.vim
-gutentags = https://bitbucket.org/ludovicchabant/vim-gutentags
+gundo = https://hg.stevelosh.com/gundo.vim
+gutentags = https://hg.sr.ht/~ludovicchabant/vim-gutentags
 interestingwords = [git]https://github.com/vasconcelloslf/vim-interestingwords.git
 jinja = [git]https://github.com/mitsuhiko/vim-jinja.git
-lawrencium = https://bitbucket.org/ludovicchabant/vim-lawrencium
+lawrencium = https://hg.sr.ht/~ludovicchabant/vim-lawrencium
 less = [git]https://github.com/groenewege/vim-less.git
 lightline = [git]https://github.com/itchyny/lightline.vim.git
 linediff = [git]https://github.com/AndrewRadev/linediff.vim.git
 markdown = [git]https://github.com/tpope/vim-markdown.git
 nerdtree = [git]https://github.com/scrooloose/nerdtree.git
 pathogen = [git]https://github.com/tpope/vim-pathogen.git
-piecrust = https://bitbucket.org/ludovicchabant/vim-piecrust
+piecrust = https://hg.sr.ht/~ludovicchabant/vim-piecrust
 projectroot = [git]https://github.com/dbakker/vim-projectroot.git
 python-pep8-indent = [git]https://github.com/hynek/vim-python-pep8-indent.git
 pythonmode = [git]https://github.com/klen/python-mode.git
--- a/install.py	Mon Apr 20 16:24:08 2020 -0700
+++ b/install.py	Wed Sep 30 21:17:47 2020 -0700
@@ -5,6 +5,7 @@
 import shutil
 import argparse
 import functools
+import traceback
 import subprocess
 import configparser
 
@@ -149,6 +150,36 @@
                ['source %s' % _p('fish', 'config.fish')])
 
 
+def _install_vim_bundle(cfg, cfg_section_name, bundle_dir, force=False):
+    if not cfg.has_section(cfg_section_name):
+        return
+
+    os.makedirs(bundle_dir, exist_ok=True)
+
+    # Keep track of lowercase directory names because the cfg parser stores
+    # config section names in lowercase.
+    existing_plugins = dict([(d.lower(), d) for d in os.listdir(bundle_dir)])
+
+    for name, url in cfg.items(cfg_section_name):
+        path = os.path.join(bundle_dir, name)
+        if url.startswith('[local]'):
+            pass
+        elif url.startswith('[git]'):
+            clone_git(url[len('[git]'):], path, force=force)
+        else:
+            clone_hg(url, path, force=force)
+        print()
+
+        existing_plugins.pop(name, None)
+
+    for k, name in existing_plugins.items():
+        print("Removing plugin %s" % name)
+        ok = input("OK? [Y/n]")
+        if ok.lower() == "y":
+            path = os.path.join(bundle_dir, name)
+            rmtree(path)
+
+
 @needs_config
 @supports_forcing
 def install_vim(cfg, force=False):
@@ -160,24 +191,8 @@
         'source %s' % nixslash(_p('vim', 'vimrc'))
     ])
 
-    if cfg.has_section('vimbundles'):
-        bundle_dir = _p('vim', 'bundle')
-        os.makedirs(bundle_dir, exist_ok=True)
-        existing_plugins = set(os.listdir(bundle_dir))
-
-        for name, url in cfg.items('vimbundles'):
-            path = os.path.join(bundle_dir, name)
-            if url.startswith('[git]'):
-                clone_git(url[len('[git]'):], path, force=force)
-            else:
-                clone_hg(url, path, force=force)
-
-            existing_plugins.discard(name)
-
-        for name in existing_plugins:
-            print("Removing plugin %s" % name)
-            path = os.path.join(bundle_dir, name)
-            rmtree(path)
+    _install_vim_bundle(cfg, 'vimbundles', _p('vim', 'bundle'), force)
+    _install_vim_bundle(cfg, 'vimbundles:local', _p('vim', 'local'), force)
 
 
 @run_priority(2)   # Needs to run before `fish`.
@@ -368,6 +383,7 @@
             clone_git(url[len('[git]'):], full_path, force=force)
         else:
             clone_hg(url, full_path, force=force)
+        print()
 
 
 @only_on_mac
@@ -447,7 +463,9 @@
     print('')
 
     cfg = configparser.ConfigParser()
-    cfg.read(_p('install.cfg'))
+    cfg.read([
+        _p('install.cfg'),
+        _p('local', 'local_install.cfg')])
 
     # Get all the methods in this module that are named `install_xxx`.
     mod_names = ['all']
@@ -461,8 +479,7 @@
 
     # See if we have any local install script.
     local_mod = None
-    local_install_py = os.path.join(dotfiles_dir, 'local',
-                                    'local_install.py')
+    local_install_py = _p('local', 'local_install.py')
     if os.path.isfile(local_install_py):
         import importlib.util
         spec = importlib.util.spec_from_file_location('local_install',
@@ -526,16 +543,25 @@
         try:
             func(*f_args, **f_kwargs)
         except Exception as ex:
-            failed_installs.append(name)
+            failed_installs.append((name, sys.exc_info()))
             print("ERROR: %s" % ex)
+            traceback.print_exc()
             if isinstance(ex, FatalInstallerError):
                 print("Aborting all remaining installs because '%s' failed!" % name)
                 break
             else:
                 print("Skipping install of '%s'." % name)
+
+        print()
+
     if failed_installs:
-        for name in failed_installs:
+        print()
+        print("----------------------------------")
+        print("ERROR: There were failed installs!")
+        for name, ex_info in failed_installs:
             print("ERROR: failed to install '%s'." % name)
+            print("ERROR: %s" % ex_info[1])
+            traceback.print_exception(*ex_info)
 
 
 def _get_install_func_priority(func_info):
--- a/vim/autoload/ludo.vim	Mon Apr 20 16:24:08 2020 -0700
+++ b/vim/autoload/ludo.vim	Wed Sep 30 21:17:47 2020 -0700
@@ -97,46 +97,24 @@
     call ludo#trace("Exclude list: ".join(g:pathogen_disabled, ', '))
 endfunction
 
-" Goyo writing mode tweaks
+" Toggle quicklist window
 "
-let s:ludo_revert = {}
+function! ludo#toggle_quicklist() abort
+	let l:qlwin = -1
+	let l:wincount = winnr('$')
+	for l:winidx in range(1, l:wincount)
+		let l:winbuftype = getwinvar(l:winidx, '&buftype', '')
+		if l:winbuftype == 'quickfix'
+			let l:qlwin = l:winidx
+			break
+		endif
+	endfor
 
-function! ludo#on_goyo_enter()
-    let s:ludo_revert = {
-                \'spell': &spell,
-                \'copyindent': &copyindent,
-                \'smartindent': &smartindent,
-                \'autoindent': &autoindent,
-                \'list': &list,
-                \'showmode': &showmode,
-                \'showcmd': &showcmd,
-                \'scrolloff': &scrolloff,
-                \'complete': &complete,
-                \'background': &background
-                \}
-    set spell 
-    set nocopyindent nosmartindent noautoindent nolist noshowmode noshowcmd
-    set scrolloff=999
-    set complete+=s
-    set bg=light
-    if !has('gui_running')
-        let g:solarized_termcolors=256
-    endif
-endfunction
-
-function! ludo#on_goyo_leave()
-    if len(s:ludo_revert) == 0
-        call ludo#error("Can't revert settings!")
-        return
-    endif
-    for [key, val] in items(s:ludo_revert)
-        execute 'let &'.key.' = '.string(val)
-    endfor
-    let s:ludo_revert = {}
-endfunction
-
-function! ludo#writingmode()
-    Goyo
+	if l:qlwin < 0
+		copen
+	else
+		cclose
+	endif
 endfunction
 
 " Better tags browser using FZF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vim/autoload/quickfixed.vim	Wed Sep 30 21:17:47 2020 -0700
@@ -0,0 +1,71 @@
+" Stolen from https://vimways.org/2018/colder-quickfix-lists/
+" ~/.vim/autoload/quickfixed.vim
+function! s:isLocation()
+    " Get dictionary of properties of the current window
+    let wininfo = filter(getwininfo(), {i,v -> v.winnr == winnr()})[0]
+    return wininfo.loclist
+endfunction
+
+function! s:length()
+    " Get the size of the current quickfix/location list
+    return len(s:isLocation() ? getloclist(0) : getqflist())
+endfunction
+
+function! s:getProperty(key, ...)
+    " getqflist() and getloclist() expect a dictionary argument
+    " If a 2nd argument has been passed in, use it as the value, else 0
+    let l:what = {a:key : a:0 ? a:1 : 0}
+    let l:listdict = s:isLocation() ? getloclist(0, l:what) : getqflist(l:what)
+    return get(l:listdict, a:key)
+endfunction
+
+function! s:isFirst()
+    return s:getProperty('nr') <= 1
+endfunction
+
+function! s:isLast()
+    return s:getProperty('nr') == s:getProperty('nr', '$')
+endfunction
+
+function! s:history(goNewer)
+    " Build the command: one of colder/cnewer/lolder/lnewer
+    let l:cmd = (s:isLocation() ? 'l' : 'c') . (a:goNewer ? 'newer' : 'older')
+
+    " Apply the cmd repeatedly until we hit a non-empty list, or first/last list
+    " is reached
+    while 1
+        if (a:goNewer && s:isLast()) || (!a:goNewer && s:isFirst()) | break | endif
+        " Run the command. Use :silent to suppress message-history output.
+        " Note that the :try wrapper is no longer necessary
+        silent execute l:cmd
+        if s:length() | break | endif
+    endwhile
+
+    " Set the height of the quickfix window to the size of the list, max-height 10
+    execute 'resize' min([ 10, max([ 1, s:length() ]) ])
+
+    " Echo a description of the new quickfix / location list.
+    " And make it look like a rainbow.
+    let l:nr = s:getProperty('nr')
+    let l:last = s:getProperty('nr', '$')
+    echohl MoreMsg | echon '('
+    echohl Identifier | echon l:nr
+    if l:last > 1
+        echohl LineNr | echon ' of '
+        echohl Identifier | echon l:last
+    endif
+    echohl MoreMsg | echon ') '
+    echohl MoreMsg | echon '['
+    echohl Identifier | echon s:length()
+    echohl MoreMsg | echon '] '
+    echohl Normal | echon s:getProperty('title')
+    echohl None
+endfunction
+
+function! quickfixed#older()
+    call s:history(0)
+endfunction
+
+function! quickfixed#newer()
+    call s:history(1)
+endfunction
--- a/vim/bundle.pathogenrc	Mon Apr 20 16:24:08 2020 -0700
+++ b/vim/bundle.pathogenrc	Wed Sep 30 21:17:47 2020 -0700
@@ -1,6 +0,0 @@
--ale
--interestingwords
-fzf
--LeaderF
--cpsm
--ctrlp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vim/ftplugin/qf.vim	Wed Sep 30 21:17:47 2020 -0700
@@ -0,0 +1,4 @@
+" Stolen from https://vimways.org/2018/colder-quickfix-lists/
+" Use <silent> so ":call quickfixed#older()" isn't output to the command line
+nnoremap <silent> <buffer> <Left> :call quickfixed#older()<CR>
+nnoremap <silent> <buffer> <Right> :call quickfixed#newer()<CR>
--- a/vim/local.pathogenrc	Mon Apr 20 16:24:08 2020 -0700
+++ b/vim/local.pathogenrc	Wed Sep 30 21:17:47 2020 -0700
@@ -1,6 +0,0 @@
--omnisharp-vim
--rtags
--vim-perforce
--vim-rtags
--vsremote
--YouCompleteMe
--- a/vim/vimrc	Mon Apr 20 16:24:08 2020 -0700
+++ b/vim/vimrc	Wed Sep 30 21:17:47 2020 -0700
@@ -162,6 +162,10 @@
 set smarttab
 set expandtab
 
+" Auto-reload files that have changed outside of Vim (which is useful
+" when reverting/syncing/whatever from the shell).
+set autoread
+
 " Default encoding
 set encoding=utf-8
 
@@ -208,7 +212,12 @@
     let g:solarized_termcolors = 256
     let g:solarized_termtrans = 1
 endif
-colorscheme solarized
+if ludo#platform() == "windows" && &term == "win32"
+    " Windows terminal sucks with colours, so pick an appropriate theme.
+    colorscheme xterm16
+else
+    colorscheme solarized
+endif
 
 " Enable file type detection.
 filetype indent plugin on
@@ -242,9 +251,9 @@
     let g:ackprg = 'ag --vimgrep'
 endif
 
-nnoremap <leader>a :Ack!<Space>
-nnoremap <leader>f :Ack! /<C-R><C-W>/ 
-vnoremap <leader>f "zy:Ack! /<C-R>z/ 
+nnoremap <Leader>a :Ack!<Space>
+nnoremap <Leader>f :Ack! <C-R><C-W> %:h<Tab>
+vnoremap <Leader>f "zy:Ack! <C-R>z %:h<Tab>
 
 " }}}
 
@@ -447,13 +456,23 @@
       \    },
       \}
 
-function! _LightlineFugitive()
-    return fugitive#head()
-endfunction
+if s:HasPlugin('fugitive')
+    function! _LightlineFugitive()
+        return fugitive#head()
+    endfunction
+else
+    function! _LightlineFugitive()
+    endfunction
+endif
 
-function! _LightlineLawrencium()
-    return lawrencium#statusline()
-endfunction
+if s:HasPlugin('lawrencium')
+    function! _LightlineLawrencium()
+        return lawrencium#statusline()
+    endfunction
+else
+    function! _LightlineLawrencium()
+    endfunction
+endif
 
 function! _LightlineCtrlPMark()
     if expand('%:t') =~ 'ControlP' && has_key(g:lightline, 'ctrlp_item')
@@ -468,9 +487,14 @@
     endif
 endfunction
 
-function! _LightlineGutentags()
-    return gutentags#statusline('', '', '♨')
-endfunction
+if s:HasPlugin('gutentags')
+    function! _LightlineGutentags()
+        return gutentags#statusline('', '', '♨')
+    endfunction
+else
+    function! _LightlineGutentags()
+    endfunction
+endif
 
 if s:HasPlugin('syntastic')
     function! _LightlineLinter()
@@ -491,15 +515,23 @@
     endfunction
 endif
 
-function! _LightlineYcmErrors()
-    let l:cnt = youcompleteme#GetErrorCount()
-    return l:cnt > 0 ? string(l:cnt) : ''
-endfunction
+if s:HasPlugin('youcompleteme')
+    function! _LightlineYcmErrors()
+        let l:cnt = youcompleteme#GetErrorCount()
+        return l:cnt > 0 ? string(l:cnt) : ''
+    endfunction
 
-function! _LightlineYcmWarnings()
-    let l:cnt = youcompleteme#GetWarningCount()
-    return l:cnt > 0 ? string(l:cnt) : ''
-endfunction
+    function! _LightlineYcmWarnings()
+        let l:cnt = youcompleteme#GetWarningCount()
+        return l:cnt > 0 ? string(l:cnt) : ''
+    endfunction
+else
+    function! _LightlineYcmErrors()
+    endfunction
+
+    function! _LightlineYcmWarnings()
+    endfunction
+endif
 " }}}
 
 " YouCompleteMe {{{
@@ -533,8 +565,8 @@
 augroup VimRCFileType_c
     au!
     autocmd FileType c,c++,cpp setlocal foldmethod=syntax
-    autocmd FileType c,c++,cpp setlocal colorcolumn=120
-    autocmd FileType c,c++,cpp setlocal synmaxcol=200
+    autocmd FileType c,c++,cpp setlocal colorcolumn=240
+    autocmd FileType c,c++,cpp setlocal synmaxcol=250
     autocmd FileType c,c++,cpp nnoremap <buffer> <localleader>z :call <SID>ToggleCppFolding()<CR>
 augroup END
 
@@ -542,8 +574,8 @@
     au!
     autocmd BufNewFile,BufRead *.xaml setlocal filetype=xml
     autocmd FileType cs setlocal foldmethod=syntax
-    autocmd FileType cs setlocal colorcolumn=120
-    autocmd FileType cs setlocal synmaxcol=200
+    autocmd FileType cs setlocal colorcolumn=240
+    autocmd FileType cs setlocal synmaxcol=250
 augroup END
 
 augroup VimRCFileType_css
@@ -669,6 +701,9 @@
 nnoremap ]l :lnext<cr>zvzz
 nnoremap [l :lprevious<cr>zvzz
 
+" Toggle quicklist.
+nnoremap <F5> :call ludo#toggle_quicklist()<cr>
+
 " Same with change and jump lists.
 nnoremap ]e g,zz
 nnoremap [e g;zz
@@ -698,11 +733,6 @@
 nnoremap n nzvzz
 nnoremap N Nzvzz
 
-" Writing mode.
-autocmd! User GoyoEnter nested call ludo#on_goyo_enter()
-autocmd! User GoyoLeave nested call ludo#on_goyo_leave()
-nmap <leader>p :call ludo#writingmode()<CR>
-
 " YCM mappings.
 if s:HasPlugin('youcompleteme')
     augroup VimRC_YouCompleteMe
@@ -712,6 +742,7 @@
         autocmd FileType cpp nnoremap <Leader>jh :YcmCompleter GoToDeclaration<cr>zv
         autocmd FileType cpp nnoremap <Leader>ji :YcmCompleter GoToInclude<cr>
         autocmd FileType cpp nnoremap <Leader>jc :YcmCompleter GetDoc<cr>
+        autocmd FileType cpp nnoremap <Leader>jt :YcmCompleter GetType<cr>
         autocmd FileType cpp nnoremap <Leader>je :YcmShowDetailedDiagnostic<cr>
     augroup END
 endif