diff vim/vimrc @ 504:015e94f44cc0

Merged changes.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 30 Sep 2020 21:17:47 -0700
parents b452486b97c5
children 232351531855
line wrap: on
line diff
--- 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