Skip to content

Commit

Permalink
Updates to work against DanielG/ghc-mod#823
Browse files Browse the repository at this point in the history
  • Loading branch information
carlohamalainen committed Sep 24, 2016
1 parent a3f00c4 commit 47811da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions after/ftplugin/haskell/ghcmod.vim
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ command! -buffer -nargs=0 -bang GhcModCheckAsync call ghcmod#command#async_make(
command! -buffer -nargs=0 -bang GhcModLintAsync call ghcmod#command#async_make('lint', <bang>0)
command! -buffer -nargs=0 -bang GhcModCheckAndLintAsync call ghcmod#command#check_and_lint_async(<bang>0)
command! -buffer -nargs=0 -bang GhcModExpand call ghcmod#command#expand(<bang>0)
command! -buffer -nargs=? -bang GhcModOpenDoc call ghcmod#command#opendoc(<q-args>, <bang>0)
command! -buffer -nargs=? -bang GhcModDocUrl call ghcmod#command#echo_doc_url(<q-args>, <bang>0)
command! -buffer -nargs=? -bang GhcModOpenDoc call ghcmod#command#opendoc(<q-args>, <bang>0, 0)
command! -buffer -nargs=? -bang GhcModDocUrl call ghcmod#command#echo_doc_url(<q-args>, <bang>0, 0)
command! -buffer -nargs=? -bang GhcModOpenHaddockVismode call ghcmod#command#opendoc(<q-args>, <bang>0, 1)
command! -buffer -nargs=? -bang GhcModEchoUrlVismode call ghcmod#command#echo_doc_url(<q-args>, <bang>0, 1)

Expand Down
5 changes: 2 additions & 3 deletions autoload/ghcmod.vim
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ function! ghcmod#get_doc_url(path, module, fexp, line, col) "{{{
let l:cmd = ghcmod#build_command(['imported-from', a:path, a:line, a:col, a:fexp])
let l:output = ghcmod#system(l:cmd)
let l:lines = split(l:output, '\n')
let l:lastline = l:lines[-1]

if l:lastline =~ "^file.*"
return l:lastline
if len(l:lines) > 0
return l:lines[0]
endif
endfunction "}}}

Expand Down
14 changes: 9 additions & 5 deletions autoload/ghcmod/command.vim
Original file line number Diff line number Diff line change
Expand Up @@ -290,21 +290,25 @@ function! ghcmod#command#opendoc(fexp, force, vismode) "{{{

let l:doc_url = ghcmod#get_doc_url(l:path, ghcmod#detect_module(), l:fexp, l:line, l:col)

if l:doc_url =~ '^file'
let l:bits = split(l:doc_url)

if len(l:bits) == 3
let l:the_url = l:bits[-1]

if exists('g:ghcmod_browser')
execute 'silent !' . g:ghcmod_browser . ' ' . l:doc_url . ' >& /dev/null &'
execute 'silent !' . g:ghcmod_browser . ' ' . l:the_url . ' >& /dev/null &'
execute ':redraw!'
else
if has("win")
echo 'Error, not implemented. Go here: ' . l:doc_url
echo 'Error, not implemented. Go here: ' . l:the_url
endif

if has("unix")
if system('uname')=~'Darwin'
" Redirect output to /dev/null?
execute "silent !open " . l:doc_url
execute "silent !open " . l:the_url
else
execute "silent !xdg-open " . l:doc_url . ' >& /dev/null'
execute "silent !xdg-open " . l:the_url . ' >& /dev/null'
endif

execute ':redraw!'
Expand Down

0 comments on commit 47811da

Please sign in to comment.