Skip to content

Commit c1fb59c

Browse files
committed
Merge pull request #37 from shiena/patch/another_quickfix
Add another way to open the quickfix
2 parents 2e12424 + 4e4ace3 commit c1fb59c

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,21 @@ let g:ghcmod_hlint_options = ['--ignore=Redundant $']
9292

9393
![lint](http://cache.gyazo.com/3b64724ce2587e03761fe618457f1c2e.png)
9494

95+
If you'd like to open in another way the quickfix, set `g:ghcmod_open_quickfix_function`.
96+
97+
```vim
98+
let g:ghcmod_open_quickfix_function = 'GhcModQuickFix'
99+
function! GhcModQuickFix()
100+
" for unite.vim and unite-quickfix
101+
:Unite -no-empty quickfix
102+
103+
" for ctrlp
104+
":CtrlPQuickfix
105+
106+
" for FuzzyFinder
107+
":FufQuickfix
108+
endfunction
109+
```
95110

96111
### :GhcModCheckAsync, :GhcModLintAsync, :GhcModCheckAndLintAsync
97112
You can run check and/or lint asynchronously.

autoload/ghcmod/command.vim

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function! ghcmod#command#make(type, force) "{{{
153153

154154
let l:qflist = ghcmod#make(a:type, l:path)
155155
call setqflist(l:qflist)
156-
cwindow
156+
call s:open_quickfix()
157157
if empty(l:qflist)
158158
echo printf('ghc-mod %s: No errors found', a:type)
159159
endif
@@ -168,7 +168,7 @@ function! ghcmod#command#async_make(type, force) "{{{
168168
let l:callback = { 'type': a:type }
169169
function! l:callback.on_finish(qflist)
170170
call setqflist(a:qflist)
171-
cwindow
171+
call s:open_quickfix()
172172
if &l:buftype ==# 'quickfix'
173173
" go back to original window
174174
wincmd p
@@ -194,7 +194,7 @@ function! ghcmod#command#check_and_lint_async(force) "{{{
194194
let self.first = 0
195195
else
196196
call setqflist(a:qflist, 'a')
197-
cwindow
197+
call s:open_quickfix()
198198
if &l:buftype ==# 'quickfix'
199199
" go back to original window
200200
wincmd p
@@ -218,7 +218,21 @@ function! ghcmod#command#expand(force) "{{{
218218
endif
219219

220220
call setqflist(ghcmod#expand(l:path))
221-
cwindow
221+
call s:open_quickfix()
222222
endfunction "}}}
223223

224+
function! s:open_quickfix()
225+
let l:func = get(g:, 'ghcmod_open_quickfix_function', '')
226+
if empty(l:func)
227+
cwindow
228+
else
229+
try
230+
call call(l:func, [])
231+
catch
232+
echomsg substitute(v:exception, '^.*:[WE]\d\+: ', '', '')
233+
\ .': Please check g:ghcmod_open_quickfix_function'
234+
endtry
235+
endif
236+
endfunction
237+
224238
" vim: set ts=2 sw=2 et fdm=marker:

0 commit comments

Comments
 (0)