Skip to content

Commit

Permalink
Merge branch 'toggle-windows'
Browse files Browse the repository at this point in the history
  • Loading branch information
romainl committed Sep 11, 2016
2 parents 23aba2d + 29ffdcb commit a16c506
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 28 deletions.
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@

## Features

* disable soft-wrapping in the location/quickfix window
* disable relative numbers in the location/quickfix window
* quickfix buffers are hidden from `:ls` and buffer navigation
* optional Ack.vim-inspired mappings
* optional mappings for `:cnext`, `:cprevious`, `:lnext`, `:lprevious`
that wrap around the beginning and end of the list
* optional mapping for jumping to and from the location/quickfix window
* filter and restore the current list
* perform commands on each line in the current list
* perform commands on each file in the current list
* open the location/quickfix window automatically after `:make`, `:grep`,
`:lvimgrep` and friends if there are valid locations/errors
* quit Vim if the last window is a location/quickfix window
* close location window automatically when quitting parent window
* jump to next group of entries belonging to same file ("file grouping")
* save and load named lists
### Global features

- quickfix buffers are hidden from `:ls` and buffer navigation
- optional mappings for `:cnext`, `:cprevious`, `:lnext`, `:lprevious`
that wrap around the beginning and end of the list
- optional mapping for jumping to and from the location/quickfix window,
- optional mappings for toggling location/quickfix windows
- open the location/quickfix window automatically after `:make`, `:grep`,
`:lvimgrep` and friends if there are valid locations/errors
- quit Vim if the last window is a location/quickfix window
- close the location window automatically when quitting parent window

### Local features

- disable soft-wrapping in the location/quickfix window
- disable relative numbers in the location/quickfix window
- optional Ack.vim-inspired mappings
- filter and restore the current list
- perform commands on each line in the current list
- perform commands on each file in the current list
- jump to next group of entries belonging to same file ("file grouping")
- save and load named lists


## Installation
Expand Down
2 changes: 1 addition & 1 deletion after/ftplugin/qf.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" vim-qf - Tame the quickfix window
" Maintainer: romainl <[email protected]>
" Version: 0.0.8
" Version: 0.0.9
" License: MIT
" Location: after/ftplugin/qf.vim
" Website: https://github.com/romainl/vim-qf
Expand Down
73 changes: 72 additions & 1 deletion autoload/qf.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" vim-qf - Tame the quickfix window
" Maintainer: romainl <[email protected]>
" Version: 0.0.8
" Version: 0.0.9
" License: MIT
" Location: autoload/qf.vim
" Website: https://github.com/romainl/vim-qf
Expand All @@ -13,6 +13,77 @@
let s:save_cpo = &cpo
set cpo&vim

function qf#IsQfWindow(nmbr)
if getwinvar(a:nmbr, "&filetype") == "qf"
return qf#IsLocWindow(a:nmbr) ? 0 : 1
endif

return 0
endfunction

function qf#IsLocWindow(nmbr)
return getbufvar(winbufnr(a:nmbr), "isLoc") == 1
endfunction

function qf#ToggleQfWindow()
let has_qf_window = 0

if ! qf#IsQfWindow(winnr())
let t:my_winview = winsaveview()
endif

for winnumber in range(winnr("$"))
if qf#IsQfWindow(winnumber + 1)
call s:CloseWindow('c')
return
endif
endfor

call s:OpenWindow('c')
endfunction

function qf#ToggleLocWindow()
let has_loc_window = 0

if ! qf#IsLocWindow(winnr())
let t:my_winview = winsaveview()
endif

if qf#IsLocWindow(winnr())
call s:CloseWindow('l')
return
endif

for i in range(winnr("$"))
if qf#IsLocWindow(i) && getloclist(0) == getloclist(i)
call s:CloseWindow('l')
endif
endfor

call s:OpenWindow('l')
endfunction

function s:OpenWindow(prefix)
exec a:prefix . 'window'

wincmd p

if exists("my_winview")
call winrestview(t:my_winview)
endif

wincmd p
endfunction

function s:CloseWindow(prefix)
exec a:prefix . 'close'

if exists("my_winview")
call winrestview(t:my_winview)
endif
endfunction


" jump to previous/next file grouping
function qf#GetFilePath(line) abort
return substitute(a:line, '|.*$', '', '')
Expand Down
47 changes: 38 additions & 9 deletions doc/qf.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*qf.txt* A plugin to make working with the quickfix list/window smoother.


VIM-QF DOCUMENTATION by Romain Lafourcade
VIM-QF DOCUMENTATION by Romain Lafourcade


Help on using vim-qf *qf* *vim-qf*
Expand All @@ -22,22 +22,26 @@ vim-qf--short for "vim-quickfix"--is a small collection of settings,
commands and mappings put together to make working with the location/quickfix
list/window smoother.

Here are the features provided by this plugin:
Here are the features provided globally by this plugin:

- disable soft-wrapping in the location/quickfix window
- disable relative numbers in the location/quickfix window
- quickfix buffers are hidden from |:ls| and buffer navigation
- optional Ack.vim-inspired mappings
- optional mappings for |:cnext|, |:cprevious|, |:lnext|, |:lprevious|
that wrap around the beginning and end of the list
- optional mapping for jumping to and from the location/quickfix window,
- filter and restore the current list
- perform commands on each line in the curent list
- perform commands on each file in the curent list
- optional mappings for toggling location/quickfix windows
- open the location/quickfix window automatically after |:make|, |:grep|,
|:lvimgrep| and friends if there are valid locations/errors
- quit Vim if the last window is a location/quickfix window
- close location window automatically when quitting parent window
- close the location window automatically when quitting parent window

And the local features:

- disable soft-wrapping in the location/quickfix window
- disable relative numbers in the location/quickfix window
- optional Ack.vim-inspired mappings
- filter and restore the current list
- perform commands on each line in the current list
- perform commands on each file in the current list
- jump to next group of entries belonging to same file ("file grouping")
- save and load named lists

Expand Down Expand Up @@ -82,6 +86,8 @@ Available global mappings:
<Plug>QfLprevious ............................. |QfLprevious|
<Plug>QfLnext ................................. |QfLnext|
<Plug>QfSwitch ................................ |QfSwitch|
<Plug>QfCtoggle ............................... |QfCtoggle|
<Plug>QfLtoggle ............................... |QfLtoggle|

Available local mappings:

Expand Down Expand Up @@ -130,6 +136,29 @@ Example: >
nmap ç <Plug>QfSwitch
<
------------------------------------------------------------------------------
*QfCtoggle*
Scope: global ~
Default: none ~

Toggle the quickfix window. Uses |:cwindow| and |:cclose| under the hood.

Example: >
nmap <F5> <Plug>QfCtoggle
<
------------------------------------------------------------------------------
*QfLtoggle*
Scope: global ~
Default: none ~

Toggle the current window's location window or the current location window.
Uses |:lwindow| and |:lclose| under the hood.

Example: >
nmap <F6> <Plug>QfLtoggle
<
------------------------------------------------------------------------------
*QfPreviousFile*
*QfNextFile*
Expand Down
7 changes: 6 additions & 1 deletion plugin/qf.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" vim-qf - Tame the quickfix window
" Maintainer: romainl <[email protected]>
" Version: 0.0.8
" Version: 0.0.9
" License: MIT
" Location: plugin/qf.vim
" Website: https://github.com/romainl/vim-qf
Expand All @@ -26,6 +26,11 @@ nnoremap <silent> <Plug>QfCnext :call qf#WrapCommand('down', 'c')<CR>
nnoremap <silent> <Plug>QfLprevious :call qf#WrapCommand('down', 'l')<CR>
nnoremap <silent> <Plug>QfLnext :call qf#WrapCommand('up', 'l')<CR>
" <Plug>QfCtoggle toggles the quickfix window
" <Plug>QfLtoggle toggles the location window
nnoremap <silent> <Plug>QfCtoggle :call qf#ToggleQfWindow()<CR>
nnoremap <silent> <Plug>QfLtoggle :call qf#ToggleLocWindow()<CR>
" jump to and from the location/quickfix window
nnoremap <expr> <silent> <Plug>QfSwitch &filetype == "qf" ? "<C-w>p" : "<C-w>b"
Expand Down

0 comments on commit a16c506

Please sign in to comment.