mileszs / ack.vim

Vim plugin for the Perl module / CLI script 'ack'
Other
3.08k stars 396 forks source link

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

Closed arnar closed 10 years ago

arnar commented 12 years ago

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

dandennison84 commented 12 years ago

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 11 years ago

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
kassio commented 10 years ago

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

reiddraper commented 9 years ago

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'