Created
January 7, 2018 02:52
-
-
Save ezyang/4bb9707ed48e50f9fc54de074bfcab45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Make, but with a few improvements: write before we try it, suppress | |
" the output (it's going to show up in the quickfix buffer) and induce | |
" a redraw, because some output might leak out anyway | |
map m :w<CR>:silent make<CR>:redraw!<CR> | |
" Make the quickfix buffer only three lines high, so we conserve screen estate | |
au FileType qf call AdjustWindowHeight(3, 6) | |
function! AdjustWindowHeight(minheight, maxheight) | |
let l = 1 | |
let n_lines = 0 | |
let w_width = winwidth(0) | |
while l <= line('$')-3 | |
" number to float for division | |
let l_len = strlen(getline(l)) + 0.0 | |
let line_width = l_len/w_width | |
let n_lines += float2nr(ceil(line_width)) | |
let l += 1 | |
endw | |
exe max([min([n_lines, a:maxheight]), a:minheight]) . "wincmd _" | |
endfunction | |
" Make, but with a few improvements: write before we try it, suppress | |
" the output (it's going to show up in the quickfix buffer) and induce | |
" a redraw, because some output might leak out anyway | |
map m :w<CR>:silent make<CR>:redraw!<CR> | |
" Make the quickfix buffer only three lines high, so we conserve screen estate | |
au FileType qf call AdjustWindowHeight(3, 6) | |
function! AdjustWindowHeight(minheight, maxheight) | |
let l = 1 | |
let n_lines = 0 | |
let w_width = winwidth(0) | |
while l <= line('$')-3 | |
" number to float for division | |
let l_len = strlen(getline(l)) + 0.0 | |
let line_width = l_len/w_width | |
let n_lines += float2nr(ceil(line_width)) | |
let l += 1 | |
endw | |
exe max([min([n_lines, a:maxheight]), a:minheight]) . "wincmd _" | |
endfunction | |
" Skip QuickFix window when cycling buffers | |
nnoremap <silent> <C-w><C-w> <C-w><C-w>:if &buftype ==# 'quickfix'<Bar>wincmd w<Bar>endif<CR> | |
" From http://vim.wikia.com/wiki/Show_entire_multiline_error_in_quickfix | |
" Because Vim is dumb and doesn't flush multiline at the top | |
" I picked the keys based on unimpaired (though I'm not using them.) | |
map ]q :cwindow<CR>:cn<CR><c-w>bz<CR><CR> | |
map [q :cwindow<CR>:cp<CR><c-w>bz<CR><CR> | |
map ]e :lnext<CR><CR> | |
map [e :lprev<CR><CR> | |
" Automatically open the QuickFix window after make | |
function! Mycwindow() | |
cwindow | |
" Cribbed from http://vim.1045645.n5.nabble.com/detecting-whether-the-quickfix-window-is-open-td1155292.html | |
for i in range(1, winnr('$')) | |
let bnum = winbufnr(i) | |
if getbufvar(bnum, '&buftype') == 'quickfix' | |
cc | |
" It would be better to use bnum to jump but | |
" whatever this works | |
call feedkeys("\<c-w>bz\<CR>\<CR>") | |
return | |
endif | |
endfor | |
endfunction | |
autocmd QuickFixCmdPost [^l]* nested call Mycwindow() | |
autocmd QuickFixCmdPost l* nested lwindow | |
set errorformat^=%-G%.%#bound\ at%.%# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment