Giter Site home page Giter Site logo

neco-ghc's Introduction

neco-ghc: ghc-mod/hhpc completion for neocomplcache/neocomplete/deoplete

A completion plugin for Haskell, using ghc-mod or hhpc

What is neco-ghc

This plugin supports the following completion.

  • pragma
  • language
  • importing a module
  • importing a function of a module
  • function based on importing modules

neco-ghc was originally implemented by @eagletmt on July 25, 2010, and then ujihisa added some new features.

Install

  • Install the ghc-mod package by stack install ghc-mod or cabal install ghc-mod OR install the hhp package by stack install hhp or cabal install hhp
  • Unarchive neco-ghc and put it into a dir of your &rtp.

Note: If you use ghc-mod 5.4, you should use ghc-mod 5.5+. Because, ghc-mod 5.5 fixes the rootdir problem.

DanielG/ghc-mod#665

Usage

neco-ghc provides necoghc#omnifunc for omni-completion. I recommend adding the following in your ~/.vim/ftplugin/haskell.vim.

" Disable haskell-vim omnifunc
let g:haskellmode_completion_ghc = 0
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc

See :help compl-omni for details on omni-completion.

Completion engines

This plugin can be used as a source of neocomplete.vim or neocomplcache.vim or deoplete.nvim. You can enjoy auto-completions without any specific configuration.

This plugin also should work with YouCompleteMe. To enable auto-completions, you have to add the following setting.

let g:ycm_semantic_triggers = {'haskell' : ['.']}

Options

g:necoghc_enable_detailed_browse

Default: 0

Show detailed information (type) of symbols. You can enable it by adding let g:necoghc_enable_detailed_browse = 1 in your vimrc. While it is quite useful, it will take longer boot time.

This feature was introduced in ghc-mod 1.11.5.

g:necoghc_debug

Default: 0

Show error message if ghc-mod/hhpc command fails. Usually it will be noisy if ghc-mod browse Your.Project.Module always fails. Use this flag only if you have some trouble.

g:necoghc_use_stack

Default: 0

Allow using stack's own ghc-mod/hhpc. If you are using ghc-mod, it will change direct ghc-mod mod calls to stack exec --no-stack-exe ghc-mod -- instead. The same goes for hhpc. Use this flag if your globally installed ghc-mod/hhpc doesn't work properly with your stack projects.

Troubleshoot

Q: neco-ghc does not work

Check the $PATH variable in vim contains the path to your ghc-mod/hhpc command. Or you can execute :NecoGhcDiagnostics command for debug.

Q: Completion isn't working for local functions or modules

#44

It's a limitation of ghc-mod. ghc-mod can show symbols of installed modules only. ghc-mod cannot show symbols of developing modules or current source file.

License

BSD3 License, the same license as ghc-mod.

neco-ghc's People

Contributors

ajnsit avatar andy-morris avatar dbeecham avatar eagletmt avatar ianbollinger avatar ichizok avatar itchyny avatar jakubfijalkowski avatar jdagilliland avatar khorser avatar macthecadillac avatar roman avatar seanparsons avatar shougo avatar skahack avatar themayarose avatar ujihisa avatar wilywampa avatar woehr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neco-ghc's Issues

ghc-mod CLI interface changed

I'm currently running ghc-mod version 5.1.1.0. Running "ghc-mod" in the terminal does not display the version number. I was able to fix it on my local repo using the following patch (More would need to be done to maintain backwards compatibility, though):

From 2ef36ad3a63b53a4475f63259a3680335922d547 Mon Sep 17 00:00:00 2001
From: Lucas Hart <[email protected]>
Date: Mon, 13 Oct 2014 05:07:58 -0400
Subject: [PATCH] Use new ghc-mod CLI interface for version retrieval.

---
 autoload/necoghc.vim                   | 2 +-
 autoload/neocomplcache/sources/ghc.vim | 4 ++--
 autoload/neocomplete/sources/ghc.vim   | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/autoload/necoghc.vim b/autoload/necoghc.vim
index 480fa38..931888d 100644
--- a/autoload/necoghc.vim
+++ b/autoload/necoghc.vim
@@ -344,7 +344,7 @@ function! s:dangling_import(n) "{{{
 endfunction "}}}

 function! necoghc#ghc_mod_version() "{{{
-  let l:ret = s:system(['ghc-mod'])
+  let l:ret = s:system(['ghc-mod', 'version'])
   return matchstr(l:ret, 'ghc-mod version \zs\d\+\.\d\+\.\d\+')
 endfunction "}}}

diff --git a/autoload/neocomplcache/sources/ghc.vim b/autoload/neocomplcache/sources/ghc.vim
index bb2bc25..8f98bcd 100644
--- a/autoload/neocomplcache/sources/ghc.vim
+++ b/autoload/neocomplcache/sources/ghc.vim
@@ -50,8 +50,8 @@ function! neocomplcache#sources#ghc#define()
     return {}
   endif
   let l:version = necoghc#ghc_mod_version()
-  if l:version < '1.0.8'
-    call neocomplcache#print_warning("neco-ghc requires ghc-mod 1.0.8+")
+  if l:version < '5.1.1'
+    call neocomplcache#print_warning("neco-ghc requires ghc-mod 5.1.1+")
     call neocomplcache#print_warning("detected version: " . l:version)
     return {}
   endif
diff --git a/autoload/neocomplete/sources/ghc.vim b/autoload/neocomplete/sources/ghc.vim
index aece780..c927b8c 100644
--- a/autoload/neocomplete/sources/ghc.vim
+++ b/autoload/neocomplete/sources/ghc.vim
@@ -54,8 +54,8 @@ function! neocomplete#sources#ghc#define()
   endif

   let mod_version = necoghc#ghc_mod_version()
-  if mod_version < '1.0.8'
-    call neocomplete#print_warning("neco-ghc requires ghc-mod 1.0.8+")
+  if mod_version < '5.1.1'
+    call neocomplete#print_warning("neco-ghc requires ghc-mod 5.1.1+")
     call neocomplete#print_warning("detected version: " . mod_version)
     return {}
   endif
-- 
2.1.2

Vim error: E117, E116

Error detected while processing function neocomplcache#enable..neocomplcache#sou
rces#ghc#define..<SNR>48_ghc_mod_version:
line    1:
E117: Unknown function: vimproc#system
Press ENTER or type command to continue
Error detected while processing function neocomplcache#enable..neocomplcache#sou
rces#ghc#define..<SNR>48_ghc_mod_version:
line    2:
E117: Unknown function: vimproc#get_last_errmsg
Press ENTER or type command to continue
Error detected while processing function neocomplcache#enable..neocomplcache#sou
rces#ghc#define..<SNR>48_ghc_mod_version:
line    2:
E116: Invalid arguments for function matchlist(vimproc#get_last_errmsg(), 'ghc-m
od version \(.....\)')[1]
Press ENTER or type command to continue

Neocomplcache works well before I put ghc.vim into ~/.vim/autoload/neocomplcache/sources.
Error shown above ocurred after I put ghc.vim and run vim test.hs.

  • vim version Vi IMproved 7.3
  • ghc-mod version 0.6.2
  • neocomplcache version 6.1
  • OS version 3.0-ARCH

List indexing error.

Sometimes s:ghc_mod() throws an error:

Error occured in source's gather_candidates()!
function neocomplete#complete#auto_complete..neocomplete#complete#manual_complete..neocomplete#complete#_get_results..neocomplete#complete#_set_results_words..310..necoghc#get_complete_words..n
ecoghc#browse..<SNR>257_ghc_mod_caching_browse..<SNR>257_ghc_mod, line 6
Vim(if):E684: list index out of range: 0
Source name is ghc

Output of :NecoGhcDiagnostics:

Current filetype: haskell
ghc-mod is executable: 1
omnifunc: necoghc#omnifunc
neocomplete.vim: 2
neocomplcache.vim: 0
YouCompleteMe: 0
vimproc.vim: 800
ghc-mod: 4.1.6
Imported modules: Prelude, Data.Maybe, System.Exit, Control.Monad, Data.Version, Data.Functor, Data.ByteString, System.Process, System.Environment, Syste
m.IO, Data.Time, Data.List, System.Directory
Number of symbols in Prelude: 235

By the way, the name of the command is NecoGhcDiagnostics in https://github.com/eagletmt/neco-ghc/blob/master/plugin/necoghc.vim, but NecoGhcDiagnosis in https://github.com/eagletmt/neco-ghc/blob/master/CONTRIBUTING.md.

Errors during completition with PackageImports extention.

Please look at https://gist.github.com/drchaos/6579167

When I press Ctrl+X, Crtl+O I see such errors:

Error detected while processing function necoghc#omnifunc..necoghc#caching_modules..61_extract_modules:
line 21:
E713: Cannot use empty key for Dictionary
Press ENTER or type command to continue
Error detected while processing function necoghc#omnifunc..necoghc#caching_modules..61_extract_modules:
line 23:
E713: Cannot use empty key for Dictionary
Press ENTER or type command to continue
Error detected while processing function necoghc#omnifunc..necoghc#caching_modules..61_extract_modules:
line 23:
E15: Invalid expression: l:modules[l:name].qualified || l:qualified
Press ENTER or type command to continue

And only after that correct competition list.

Only prelude functions are available for completion

I used to have this working, but I've switched from using hsenv to using cabal sandboxes and function completion no longer works correctly. No matter what has been imported, only Prelude functions are available for completion; basically my import statements are ignored.

Setting let g:necoghc_debug = 1 in my .vimrc produces no additional output.

The other completions, such as import completions, work just fine. Any ideas?

neco-ghc not working when ghc-mod is installed from ubuntu repo

I am using ubuntu 12.04 and I had installed ghc-mod package from software center. neco-ghc was not working until I installed ghc-mod using cabal instead. The one in software center is slightly outdated which may be related to this.

Anyway, it's not quite a problem for me, I just wanted to document it for people googling the same problem. Great addon, thanks..

Unknown function: neocomplcache#get_syn_name

Hi, I am using neco-ghc together with neocomplcache.vim.

When I try to complete from import Dat, I got the following error message

function neocomplcache#complete#auto_complete..neocomplcache#complete#manual_complete..neocomplcache#complete#_get_results..neocomplcache#complete#_set_results_words..225, line 22
Vim(let):E117: Unknown function: neocomplcache#get_syn_name
Source name is ghc
Error occured in source's gather_candidates()!

I have no idea how could make it fine, or should i provide more information?

Thanks

Completion not working for pragma and language

Minimal vimrc to reproduce the problem.

if has('vim_starting')
  if &compatible
    set nocompatible
  endif

  runtime macros/matchit.vim
  set runtimepath+=~/.vim/bundle/neobundle.vim/
endif

call neobundle#begin(expand('~/.vim/bundle/'))
NeoBundleFetch 'Shougo/neobundle.vim'
NeoBundle 'eagletmt/neco-ghc'

call neobundle#end()
filetype plugin indent on
setlocal omnifunc=necoghc#omnifunc
vim -u ~/.vimrc hello.hs

Following the example in readme, type {-# OP|, | is where cursor is, then hit <c-x><c-o>, it says Omni completion (^O^N^P) Pattern not found.

The same for language completion case in the readme.

ENV

vim: 7.4
nvim: ubuntu daily build

MacVim

I'm using the same configuration of vim on windows and mac (i have my .vim folder on a git repository https://github.com/amunra81/vim.git ). The neco-ghc on windows it works very well, but on os x it shows (on the completion popup list) just elements from the file(s) i have it opened and no functions from imported library or others.

1st fact) when I have the neocompletion off the Omnicomplition (C-X,C-U) it shows me the full list of completion elements. But when I put NeoComplCacheEnable , only elements from the page appears

2nd fact) ghc-mod works fine in command line, in VimShell and also with VimProc

Can't make completion to work with neocomplete

I just don't know what it's going on. It seems that neocomplete is not sourcing necoghc... because if I force omnicompletion (<C-x><C-o>) it works fine.

:NecoGhcDiagnostics
Current filetype: haskell
ghc-mod is executable: 1
omnifunc: necoghc#omnifunc
neocomplete.vim: 2
neocomplcache.vim: 0
YouCompleteMe: 0
vimproc.vim: 800
ghc-mod:
Imported modules: Prelude
Number of symbols in Prelude: 235

For example, | is the cursor:

{-# LANGUAGE im|

... only shows neosnippet completions.

My neocomplete configuration is quite simple:

let g:neocomplete#enable_at_startup=1

How can I continue troubleshooting this?

Documentation could be improved

neco-ghc was not working for me, even though I followed the documentation. The documentation says that the following line should be added to .vim/ftplugin/haskell.vim:

setlocal omnifunc=necoghc#omnifunc

First of all, this is imho a bad idea anyway (I am using git to keep my plugins up to date and I don't want to push them). Furthermore, it just did not work.

Fixing the first one is easier. IMHO it would be better, if the documentation would say, that one should add the following to the .vimrc:

autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc

The problem is, that haskell-vim overrides the omnifunc variable in compiler/ghc.vim - so if one has the haskell-vim installed, the following line is necessary as well (also in .vimrc):

let g:haskellmode_completion_ghc=0

After this change, everything works like a charme

Poor error behaviour when failing to find project root.

I encountered this issue when using a combination of nix and stack.

I have ghc-7.10.3 installed, but my stack.yaml specified using ghc-7.10.2.

During the call to necoghc#boot s:get_ghcmod_root returned this string:

Compiler version mismatched, found ghc-7.10.3 (x86_64), but expected minor version match with ghc-7.10.2 (x86_64) (based on resolver setting in /home/jophish/project/stack.yaml).
Try running "stack setup" to install the correct GHC into /home/jophish/.stack/programs/x86_64-linux/
Bootstrapping stack project
environment failed: readCreateProcess: /home/jophish/.nix-profile/bin/stack "path" (exit 1): failed

Although this error isn't the fault of neco-ghc the error message returned from the vimscript was fairly cryptic:

Error detected while processing function necoghc#boot..<SNR>104_ghc_mod_caching_browse..<SNR>104_ghc_mod:
line   13:
E77: Too many file names
Error detected while processing function necoghc#boot..<SNR>104_ghc_mod_caching_browse:
line   12:
E170: Missing :endfor

It would be nice for neco-ghc to bubble up this error message to the vim user.

freeze/block/pause soon after startup

I'm using Neovim and Deoplete. After loading a Haskell file and typing a few characters, the editor freezes for a minute or so. Disabling neco-ghc eliminates the freeze. I thought that using this plugin with Neovim and Deoplete would mean no freezes, but perhaps I'm doing it wrong, or perhaps support for async isn't in neco-ghc?

Accessing the full completion [Feature Request]

I'm using neco-ghc with neocomplete.
When I type "import dtsu" the following completions show:
Data.~ [ghc] [ghc] Data.Sequence
Distribution.~ [ghc] [ghc] Distribution.TestSuite

These complete to "Data" and "Distribution" respectively. Is there a way to have them complete to Data.Sequence and Distribution.TestSuite?

Also, why does [ghc] show up twice?

Pragma and language completions broken

Trying to complete either pragmas or language extensions fails and gives a list of Prelude identifiers instead. For example,

{-# OP<try completing here>

and

{-# LANGUAGE O<try completing here>

both just give a list of Prelude identifiers. Using vim 7.4, the latest neco-ghc from this repo and ghc-mod 5.2.1.

No autocomplete for YouCompleteMe

I've done the following to attempt to alleviate the problem:

  • ghc-mod installed from the [haskell-core] repo on Arch Linux, version 3.1.5
  • Ensured that ghc-mod is on my PATH
  • Up-to-date versions of both YouCompleteMe and neco-ghc
  • added setlocal omnifunc=necoghc#omnifunc to my .vimrc

However, I don't get any autocompletions at all, beyond simple textual suggestions. I'm not sure if installing ghc-mod from cabal would solve the problem, but I'd rather not do this if I don't have to.

number of symbols in prelude: 0

results of NecoGhcDiagnostics:

Current filetype: haskell
ghc-mod is executable: 1
omnifunc: necoghc#omnifunc
neocomplete.vim: 0
neocomplcache.vim: 0
YouCompleteMe: 0
vimproc.vim: 902
ghc-mod: 5.6.0.0
Imported modules: Prelude
Number of symbols in Prelude: 0

I'm running latest neovim with latest deoplete and neco-ghc.

how to completion function name?

I installed ghc-mod and neco-ghc, but it seems no work at all.
the error message:

ghc.vim: GHCi reports errors (try :make?)

-- Omni completion (^O^N^P) Pattern not found

Is really no need setting anything else besides installing ghc-mod?

Support configurable base dir

For multi-folder projects not using cabal omnicompletion doesn't work

For example, if I have 2 modules Foo.Bar and Baz.Quux, and Foo.Bar has import Baz.Quux, and I try to autocomplete a fully qualified name Baz.Quux. omnicompletion complains:

Baz.Quux:0:0:Error:Could not find module `Baz.Quux'

To fix that I need to add the base directory of my project (the directory with Foo and Baz subdirectories) to ghc search path using ghc-mod -g option.

See https://github.com/eagletmt/ghcmod-vim/blob/master/autoload/ghcmod.vim#L353 for an inspiration.

Note that .cabal heuristic ( #5 ) is not enough - sometimes base dir differs from .cabal dir, or a project can use ghc --make instead of Cabal for builds. So .cabal support and configurable basedir support are independent tasks.

Completion only works for Prelude names

In this program

{-# LANGUAGE OverloadedStrings #-}

import Control.Monad.Identity (Identity)
import Control.Wire
import Prelude hiding ((.),id)
import Text.Printf
import System.Random
import qualified Data.List as L

testApp :: Wire () Identity a String
testApp = "yes" . (holdFor 0.5 $ periodically 1) <|>  "no"

main = do
  gen <- getStdGen
  loop testApp clockSession where
  loop w session = do
    (mx, w', session') <- stepSessionP w session ()
    case mx of
       Left ex -> putStrLn ("Inhibited: " ++ show ex)
       Right x -> putStrLn ("Produced: " ++ show x)
    loop w' session'

I only get completions for names in Prelude. ghc-mod list and ghc-mod browse return expected results.

What's the recommended way to use on single file with stack?

Currently I wrap nvim in a shell function in a way such that if its opening a haskell file, then invoke as something like stack exec -- nvim $*. This makes neco-ghc completion in Haskell file outside of project works, otherwise it can't find packages installed "globally" by stack (those packages stack builded without a project). However I noticed that in stack project, neco-ghc completion doesn't work anymore today. And here's the output of NecoGhcDiagnostics:

Current filetype: haskell
ghc-mod is executable: 1
omnifunc: necoghc#omnifunc
neocomplete.vim: 0
neocomplcache.vim: 0
YouCompleteMe: 0
vimproc.vim: 902
ghc-mod: 5.7.0.0
Imported modules: Prelude, Text.Hamlet, Network.Wai, Servant, Data.Proxy
Number of symbols in Prelude: 0

After some digging, I think here's what happens:
when stack exec, STACK_EXE is set to the binary of stack, and when in stack project ghc-mod would output a warning line before the browse command's output: Warning: STACK_EXE set, preferring Stack project, causing s:ghc_mod_caching_async break too early. Removing the break the completion works but this shouldn't be the way to do...

If I invoke nvim directly the completion works fine in stack project, but not outside of project.

So what's the correctly (or recommended) way to use neco-ghc in these two occasions? supposing I want to use a "universal" nvim command.

Completion when importing individual names

The frontpage example of

import Data.List (<C-x><C-u>

(where completefunc is set to necoghc#omnifunc) doesn't work for me, but everything else does. The given example will report that there are no completions available. However, if I add a single letter, such that at least one identifier exists in the module that begins with this letter, it works as expected and I get back a list of all such identifiers.

i.e.

import Data.List (a<C-x><C-u>

will give me the "all", "and" and "any" completions.

Is this a regression or is it a problem on my end? Any idea what might be causing it?

Add support for literate haskell

I would like to see support for literate haskell in neco-ghc.

(1) A very rough, but probably acceptable as a temporary solution, is to merely filter out any "> " on line beginnings (substitute(line, "^> ", "")) before parsing the line.
(2) A better solution is to only treat lines beginning with "> " as haskell, and any other as text.
(3) In addition to bird-style ("> code"), there is also LaTeX-style literate haskell, though since this is not decidable per-line, some state-keeping is necessary, which makes implementation harder. I don't use this style of coding, and I personally don't see the benefit in using it, so I don't really care.

I'm trying to understand the code in order to implement (1) and hopefully (maybe) (2), but there is a slight lack of comments in the code (this is somewhat ironic, considering what I'm trying to do :)), so I wanted to create this issue to see if I could get any help in this. If not in coding, then perhaps some help in understanding all the bits and pieces.

Deoplete source calling ghc-mod in non-haskell buffer

Deoplete source init is calling necoghc#boot function (https://github.com/eagletmt/neco-ghc/blob/master/rplugin/python3/deoplete/sources/ghc.py#L22-L23) even when the current buffer is a non Haskell file. This causes error for me as I do not currently have ghc-mod installed. I do not have ghc-mod because I'm not currently working with Haskell, but I would like to keep this plugin installed for future use.

Very quick check to omnicomplete and boot code shows that omnifunc is calling boot and boot is no-op after the first call as it uses a cache var. Maybe it would make sense to move boot call in deoplete source to get_complete_position?

In neocomplete source, boot is called from on_init but maybe that is only called for haskell buffers?

[deoplete] Traceback (most recent call last):                                                                         
[deoplete]   File "/home/juho/.config/nvim/bundle/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 57, in com
pletion_begin                                                                                                         
[deoplete]     complete_position, candidates = self.gather_candidates(context)                                        
[deoplete]   File "/home/juho/.config/nvim/bundle/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 86, in gat
her_candidates                                                                                                        
[deoplete]     self.load_sources()                                                                                    
[deoplete]   File "/home/juho/.config/nvim/bundle/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 275, in lo
ad_sources                                                                                                            
[deoplete]     self.__sources[name] = source.Source(self.__vim)                                                       
[deoplete]   File "/home/juho/.config/nvim/bundle_haskell/neco-ghc/rplugin/python3/deoplete/sources/ghc.py", line 23, 
in __init__                                                                                                           
[deoplete]     self.vim.call('necoghc#boot')                                                                          
[deoplete]   File "/home/juho/.local/lib/python3.4/site-packages/neovim/api/nvim.py", line 132, in call               
[deoplete]     return self._session.request('vim_call_function', name, args, **kwargs)                                
[deoplete]   File "/home/juho/.local/lib/python3.4/site-packages/neovim/api/common.py", line 230, in request          
[deoplete]     return walk(self._in, self._session.request(name, *args, **kwargs),                                    
[deoplete]   File "/home/juho/.local/lib/python3.4/site-packages/neovim/msgpack_rpc/session.py", line 90, in request  
[deoplete]     raise self.error_wrapper(err)                                                                          
[deoplete] neovim.api.nvim.NvimError: b'vimproc#get_command_name: File "ghc-mod" is not found.'                       
[deoplete] An error has occurred. Please execute :messages command. 

unclear complete candidates order

It is very wired that the complete candidates are sorted in a mystery way
screenshot from 2016-05-21 21-18-31
everything is right except the order
maybe is my misconfig
this is my init.vim(vimrc)
init (copy).txt
in othercase it always start with the longest one
I use the neco-ghc neovim and deoplete

Completion only working on project's root directory

Autocompletion is only working on project-level haskell source codes of cabal-install initialized projects while it doesn't work at all on stack-initialized projects. I'm pretty new from python world so I might be missing something.

My directory structure is generated by following commands:

~ $ mkdir my_project && cd my_project
~/my_project $ cabal init
~/my_project $ cabal sandbox init

which yields

my_project  
|-- Setup.hs  
|-- cabal.sandbox.config  
|-- src / Lib.hs

Autocompletion works (it suggests Prelude module's keywords) when I edit Setup.hs but I suggests nothing when I try edit src/Lib.hs.

My :NecoGhcDiagnotics command outputs

Current filetype: haskell                                                                                                                                                                                                    
ghc-mod is executable: 1                                                                                                                                                                                                     
omnifunc: necoghc#omnifunc                                                                                                                                                                                                   
neocomplete.vim: 0                                                                                                                                                                                                           
neocomplcache.vim: 2                                                                                                                                                                                                         
YouCompleteMe: 0                                                                                                                                                                                                             
vimproc.vim: 900                                                                                                                                                                                                             
ghc-mod: 5.4.0.0                                                                                                                                                                                                             
Imported modules: Prelude                                                                                                                                                                                                    
Number of symbols in Prelude: 0     

when I edit src/Lib.hs while

Current filetype: haskell                                                                                                                                                                                                    
ghc-mod is executable: 1                                                                                                                                                                                                     
omnifunc: necoghc#omnifunc                                                                                                                                                                                                   
neocomplete.vim: 0                                                                                                                                                                                                           
neocomplcache.vim: 2                                                                                                                                                                                                         
YouCompleteMe: 0                                                                                                                                                                                                             
vimproc.vim: 900                                                                                                                                                                                                             
ghc-mod: 5.4.0.0                                                                                                                                                                                                             
Imported modules: Distribution.Simple, Prelude                                                                                                                                                                               
Number of symbols in Prelude: 235   

is the output of the command when I'm editing Setup.hs.

It clearly looks like ghc-mod is not detecting any symbols when I'm editing src/Lib.hs.. why is this happening?

Completion on "{-# LAN" does not work anymore :(

Previously, when I typed {-# LAN and triggered omnicompletion, it was completed to {-# LANGUAGE. As of the latest master this does not work anymore.

Was this removed, or could it be an issue with my setup? If it was removed, how can I convince you to bring it back?

Error: compiler not supported: ghc

Hi..I'm getting this error:

Error detected while processing BufEnter Auto commands for "8.hs"
E666 compiler not supported: ghc

I've installed ghc-mod and it's in my classpath

xx@xx:~/.cabal$ whereis ghc-mod
ghc-mod: /usr/local/bin/ghc-mod

How can I fix it??..thanks!!...

necoghc#omnifunc used but no smart suggestions (YouCompleteMe)

Hi. I am using YouCompleteMe and neco-ghc (installed from Vundle) on vim 7.4.

I've done the

let g:ycm_semantic_triggers = {'haskell' : ['.']}

and added what I was supposed to add to the ftype file. :echo &omnifunc returns necoghc#omnifunc when I open a .hs file.

However, I only get the generic suggestions that YouCompleteMe gives. For example, I have a LANGUAGE pragma, so I get LANGUAGE as a suggestion if I type LANG. But if I try to do the fancy imports, for example, as shown in readme.md, I get nothing.

I tried hitting C-x, C-o, C-space and C-p.

Completion isn't working for local functions or modules

Completion works only for system-wide and cabal libraries. If I create some very simple source file it will not complete functions from this file, or any other module created by me.
NecoGhcDiagnostics output:

Current filetype: haskell
ghc-mod is executable: 1
omnifunc: necoghc#omnifunc
neocomplete.vim: 0
neocomplcache.vim: 0
YouCompleteMe: 2
vimproc.vim: 800
ghc-mod: 5.2.1.2
Imported modules: Prelude, MyModule
Number of symbols in Prelude: 235

neco-ghc doesn't work on macOS

I'm getting "Pattern not found" for all symbols/imports. Latest neco-ghc is installed, GHC version 8.0.2. Recommended neco-ghc configuration is in .vimrc file:

let g:haskellmode_completion_ghc = 0
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc

NecoGhcDiagnostics output:

Current filetype: haskell
ghc-mod is executable: 1
omnifunc: necoghc#omnifunc
neocomplete.vim: 2
neocomplcache.vim: 0
YouCompleteMe: 0
vimproc.vim: 902
ghc-mod: 5.6.0.0
Imported modules: Prelude, Data.
Number of symbols in Prelude: 0

Failed to autocomplete after using cabal, reporting permission denied

Hi,

if my project has cabal setup, autocompletion stops working. if I just write some haskell script wildly it works perfectly.

it reports:

cabal-helper-wrapper: /home/hu/.ghc-mod/cabal-helper/cabal-helper-0.3.6.0-Cabal-1.22.2.0: createProcess: runInteractiveProcess: exec: permission denied (Permission denied)

and

ghc-mod: readCreateProcess: /home/hu/.cabal/libexec/cabal-helper-wrapper "/home/hu/Projects/Haskell/TestProject/dist" "entrypoints" "source-dirs" "ghc-options" "ghc-src-options" "ghc-pkg-options" "ghc-merged-pkg-options" "ghc-lang-options" "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" (exit 1): failed

however, ghcmod is install under my home folder, there shouldn't be permission issue. Could you help and have a look at that?

following is a brandnew test project just to try presence of cabal.

errr

Pass `--silent` flag to ghc-mod

When ghc-mod is invoked without the --silent flag it sometimes prints warning messages that mess with the Vim plugin parsing the output:

$ ghc-mod expand src/Model/Prob.hs 
Warning: 'dist/setup-config' exists, ignoring Stack and using cabal-install instead
Dummy:0:0:Error:src/Model/Types.hs:197:1-19: Splicing declarations
$ ghc-mod --silent expand src/Model/Prob.hs 
Dummy:0:0:Error:src/Model/Types.hs:197:1-19: Splicing declarations 

ghc-mod should be probably always invoked with --silent to get clean output.

Error upon updating to latest neocomplete

After updating to yesterday's git version of neocomplete (with GHC 7.8.3 and ghc-mod 4.1.6 on Arch Linux), I recieved the following error message:

Error detected while processing function ghcmod#util#check_version..ghcmod#util#ghc_mod_version..vimproc#system..<SNR>102_system..<SNR>102_read_pgroup..<SNR>102_read_pipes..<SNR>102_read..<SNR>102_vp_pipe_read..<SNR>102_libcall_raw_read:
line   12:
E605: Exception not caught: vimproc: vp_pipe_read: '0A6768632D6D6F642076657273696F6E20342E312E3620636F6D70696C65642062792047484320372E382E330A55736167653A0A09206768632D6D6F64206C697374205B2D67204748435F6F707431202D67204748435F6F707432202E2
E2E5D205B2D6C5D205B2D645D0A09206768632D6D6F64206C616E67205B2D6C5D0A09206768632D6D6F6420666C6167205B2D6C5D0A09206768632D6D6F642062726F777365205B2D67204748435F6F707431202D67204748435F6F707432202E2E2E5D205B2D6C5D205B2D6F5D205B2D645D205B2D715D
205B3C7061636B6167653E3A5D3C6D6F64756C653E205B5B3C7061636B6167653E3A5D3C6D6F64756C653E202E2E2E5D0A09206768632D6D6F6420636865636B205B2D67204748435F6F707431202D67204748435F6F707432202E2E2E5D203C4861736B656C6C46696C65732E2E2E3E0A09206768632D6
D6F6420657870616E64205B2D67204748435F6F707431202D67204748435F6F707432202E2E2E5D203C4861736B656C6C46696C65732E2E2E3E0A09206768632D6D6F64206465627567205B2D67204748435F6F707431202D67204748435F6F707432202E2E2E5D200A09206768632D6D6F6420696E666F
205B2D67204748435F6F707431202D67204748435F6F707432202E2E2E5D203C4861
Error detected while processing function ghcmod#util#check_version..ghcmod#util#ghc_mod_version..vimproc#system..<SNR>102_system..<SNR>102_read_pgroup..<SNR>102_read_pipes..<SNR>102_read:
line   12:
E170: Missing :endwhile
Error detected while processing function ghcmod#util#check_version..ghcmod#util#ghc_mod_version..vimproc#system..<SNR>102_system..<SNR>102_read_pgroup:
line    7:
E171: Missing :endif
Error detected while processing function ghcmod#util#check_version..ghcmod#util#ghc_mod_version..vimproc#system..<SNR>102_system:
line   69:
E171: Missing :endif
Error detected while processing function ghcmod#util#check_version..ghcmod#util#ghc_mod_version:
line    2:
E171: Missing :endif
Error detected while processing /home/joel/.vim/bundle/ghcmod-vim/after/ftplugin/haskell/ghcmod.vim:
line   31:
E171: Missing :endif

It obviously has something to do with a version mismatch, but I can't make heads nor tails of it beyond that. Any advice on how to appease the error?

poor performace

it seems everything is fine with neocoomplcache ver 7.1
but some problem with newest master branch

here when i just press a space on a new line, it will call ghc-mod once, and press more spaces will call ghc-mod more times.

and when i am not editing a haskell file ( i mean file name ends with .hs ) it will still call ghc-mod. which make the whole vim very slow.

E666: compiler not supported: ghc

Open haskell source file:

Messages maintainer: Bram Moolenaar <[email protected]>          
Error detected while processing function HaskellMode:
line    1:
E666: compiler not supported: ghc

GHC version:

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.0.3

Completion only works if ghc-mod is installed into the sandbox.

I've found others recommending installing ghc-mod into the sandbox and when I did that previously it worked. However I'm trying to have a clean build set up where all the command line tools are in ~/.cabal/bin and no other dependencies are installed.

This seems to result in the code completion just showing me things that are already present inside the file, which seems wrong full stop.

How to use it with tab?

I'm currently using YCM as an interface to this plugin and followed instructions for YCM in README but it only works with . Is there any way to use it with tab?

omnicompletion fails when invoked in {-# | #-}

When I trigger omnicompletion in this situation (where »|« is the cursor)
{-# |
all pragmas are completed as expected.

However, when I trigger in this situation
{-# | #-}
no completions are shown.

I would expect the same behaviour as in the first case.

Is this a bug? Or intended behaviour?

Output of NecoGhcDiagnosis:
Current filetype: haskell
ghc-mod is executable: 1
omnifunc: necoghc#omnifunc
neocomplete.vim: 2
neocomplcache.vim: 0
YouCompleteMe: 0
vimproc.vim: 800
ghc-mod: 4.1.1
Imported modules: Prelude, A, Data.List
Number of symbols in Prelude: 235

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.