From 259b72f330d172f80fafa8b6a5dccfe226050c06 Mon Sep 17 00:00:00 2001 From: Romain Lafourcade Date: Wed, 19 Oct 2016 16:11:37 +0200 Subject: [PATCH 1/2] Prototype for TheLemonMan on #vim --- after/ftplugin/qf.vim | 2 ++ autoload/qf.vim | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/after/ftplugin/qf.vim b/after/ftplugin/qf.vim index 083b6f6..c42a408 100644 --- a/after/ftplugin/qf.vim +++ b/after/ftplugin/qf.vim @@ -50,6 +50,8 @@ if exists("g:qf_mapping_ack_style") else nnoremap O :cclose endif + " preview entry under the cursor + nnoremap p :call qf#PreviewFileUnderCursor() endif " filter the location/quickfix list diff --git a/autoload/qf.vim b/autoload/qf.vim index 8f512c9..5ade310 100644 --- a/autoload/qf.vim +++ b/autoload/qf.vim @@ -13,6 +13,14 @@ let s:save_cpo = &cpo set cpo&vim +function qf#PreviewFileUnderCursor() + let cur_list = b:isLoc == 1 ? getloclist('.') : getqflist() + let cur_line = getline(line('.')) + let cur_file = substitute(cur_line, '|.*$', '', '') + let cur_pos = substitute(cur_line, '^\(.\{-}|\)\(\d\+\)\(.*\)', '\2', '') + execute "pedit +" . cur_pos . " " cur_file +endfunction + " helper function " " returns 1 if the window with the given number is a quickfix window " " 0 if the window with the given number is not a quickfix window From 4a772151f0f9ade59b9721eb2d94d60bd8ffd87b Mon Sep 17 00:00:00 2001 From: Romain Lafourcade Date: Sun, 23 Oct 2016 11:44:56 +0200 Subject: [PATCH 2/2] Ready to ship --- after/ftplugin/qf.vim | 2 +- autoload/qf.vim | 5 +++-- doc/qf.txt | 1 + plugin/qf.vim | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/after/ftplugin/qf.vim b/after/ftplugin/qf.vim index c42a408..ccefaea 100644 --- a/after/ftplugin/qf.vim +++ b/after/ftplugin/qf.vim @@ -1,6 +1,6 @@ " vim-qf - Tame the quickfix window " Maintainer: romainl -" Version: 0.0.9 +" Version: 0.1.0 " License: MIT " Location: after/ftplugin/qf.vim " Website: https://github.com/romainl/vim-qf diff --git a/autoload/qf.vim b/autoload/qf.vim index 5ade310..98d0d9f 100644 --- a/autoload/qf.vim +++ b/autoload/qf.vim @@ -1,6 +1,6 @@ " vim-qf - Tame the quickfix window " Maintainer: romainl -" Version: 0.0.9 +" Version: 0.1.0 " License: MIT " Location: autoload/qf.vim " Website: https://github.com/romainl/vim-qf @@ -13,11 +13,12 @@ let s:save_cpo = &cpo set cpo&vim +" open the current entry in th preview window function qf#PreviewFileUnderCursor() let cur_list = b:isLoc == 1 ? getloclist('.') : getqflist() let cur_line = getline(line('.')) let cur_file = substitute(cur_line, '|.*$', '', '') - let cur_pos = substitute(cur_line, '^\(.\{-}|\)\(\d\+\)\(.*\)', '\2', '') + let cur_pos = substitute(cur_line, '^\(.\{-}|\)\(\d\+\)\(.*\)', '\2', '') execute "pedit +" . cur_pos . " " cur_file endfunction diff --git a/doc/qf.txt b/doc/qf.txt index 85f8881..184bb9d 100644 --- a/doc/qf.txt +++ b/doc/qf.txt @@ -179,6 +179,7 @@ Ack.vim-inspired mappings available only in location/quickfix windows: t - open entry in a new tab o - open entry and come back O - open entry and close the location/quickfix window + p - open entry in a preview window Add the line below to your vimrc to enable this feature: > diff --git a/plugin/qf.vim b/plugin/qf.vim index 712bf3f..8ce5c53 100644 --- a/plugin/qf.vim +++ b/plugin/qf.vim @@ -1,6 +1,6 @@ " vim-qf - Tame the quickfix window " Maintainer: romainl -" Version: 0.0.9 +" Version: 0.1.0 " License: MIT " Location: plugin/qf.vim " Website: https://github.com/romainl/vim-qf