No results shown when filetype is haskell (with haskellmode-vim) #34

Closed
arnar opened this Issue Jan 27, 2012 · 4 comments

Projects

None yet

5 participants

arnar commented Jan 27, 2012

I use haskellmode-vim and when I have a buffer open which is has the haskell filetype, invoking :Ack! always gives an empty quickfix window, even though the same query returns results when run from the shell prompt.

Here is a diff on ":set all" output between a plain buffer (where :Ack works as expected) and a buffer with the haskell filetype: https://gist.github.com/1688263

Sorry for filing this as an issue, I'm just out of ideas on how to debug it and could use some help with that. My whole vim config is available at https://github.com/arnar/vim-config

The cause of the problem is the following line in .vimrc. Not sure yet how to fix it. Commenting out this line makes Ack work, but then disables using most of the functionality of haskell mode.

au Bufenter *.hs compiler ghc

dmalkr commented Jul 29, 2013

haskellmode-vim redefines "shellpile" varialbe, so you need to fix ack.vim:

  let grepprg_bak=&grepprg
  let grepformat_bak=&grepformat
  let shellpipe_bak=&shellpipe
  try
    " workaround for haskellvim
    let &shellpipe=">"
    let &grepprg=g:ackprg
    let &grepformat=g:ackformat
    silent execute a:cmd . " " . escape(l:grepargs, '|')
  finally
    let &grepprg=grepprg_bak
    let &grepformat=grepformat_bak
    let &shellpipe=shellpipe_bak
  endtry
Contributor
kassio commented Mar 12, 2014

I'll close it for now, but if the @malphunction's solution does not work feel free to reopen.

@kassio kassio closed this Mar 12, 2014

As a patch:

diff --git a/autoload/ack.vim b/autoload/ack.vim
index fae73b1..b13911a 100644
--- a/autoload/ack.vim
+++ b/autoload/ack.vim
@@ -23,10 +23,13 @@ function! ack#Ack(cmd, args)
   let grepformat_bak = &grepformat
   let &grepprg=l:ackprg_run
   let &grepformat=g:ackformat
+  let shellpipe_bak=&shellpipe

   try
     " NOTE: we escape special chars, but not everything using shellescape to
     "       allow for passing arguments etc
+    " workaround for haskellvim
+    let &shellpipe=">"
     if g:ack_use_dispatch
       let &l:errorformat = g:ackformat
       let &l:makeprg=g:ackprg." " . escape(l:grepargs, '|#%')
@@ -38,6 +41,7 @@ function! ack#Ack(cmd, args)
   finally
     let &grepprg=grepprg_bak
     let &grepformat=grepformat_bak
+    let &shellpipe=shellpipe_bak
   endtry

   if a:cmd =~# '^l'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment