[Haskell-cafe] hie + neovim + coc.nvim on NixOS

Marc Busqué marc at lamarciana.com
Sat Oct 5 13:35:04 UTC 2019


Hi Cafe,

this is an adapted version of a question I already posted on NixOS
discussion forum, so far with no luck [1]:

I’m trying to replicate the configuration from an article on a NixOS
machine [2].

That’s, I’m trying to use hie on neovim, through coc.nvim, with NixOS as
operating system. For now, I want it to work for a project which uses
GHC 8.6.5 through Stack.

So far I’ve been able to:

- Install hie version for GHC 8.6.5:

```
let
   all-hies = import (fetchTarball "https://github.com/infinisil/all-hies/tarball/master") {};
in
   {
     environment.systemPackages = with pkgs; [
       (all-hies.selection { selector = p: { inherit (p) ghc865; }; })
     ];
```

- Install neovim 4.x to have floating window feauture, which is only
   available in master, as far as I know:

```
let
   nixPkgsMaster = import (fetchTarball "https://github.com/NixOS/nixpkgs/tarball/master") {};
in
   {
     environment.systemPackages = with pkgs; [
       nixPkgsMaster.neovim
     ];
   }
```

- I configured coc.nvim [3] to use hie, together with `haskell-vim`
   plugin.

I'm using Plug for this:

```
Plug 'neoclide/coc.nvim', { 'do': 'yarn install --frozen-lockfile' }
Plug 'neovimhaskell/haskell-vim'
```

And I have configured coc.nvim as its documentation suggests [4].

- I found that having hie for GHC 8.6.5 was not enough and that I had to
   install manually the compiler for 8.6.5. I think it is needed in
   NixOS. If I’m wrong, please, tell me. So, I added
   `haskell.compiler.ghc865` in `environment.systemPackages`.

- Besides, I have following haskell tools: `haskellPackages.hlint`,
   `haskellPackages.apply-refact` and `haskellPackages.hindent`.

With all of that, hie is somehow working on neovim, but there are a lot
of things missing.

For example, one thing that is working is `:call CocAction('format')`.
It also points me to some hlint warnings underlying their lines.

However, there are a lot of functionalities missing.

- Autocompletion is anything but intellisense.

- I can’t quickfix hlint warnings. It says `[coc.nvim] No quickfix
   action available`

- Trying to rename returns `[coc.nvim] Error on 'rename': rename: "HaRe:
   file not loaded for refactoring"`

- It gives me no type information when I press K on a word (being K
   mapped as coc.nvim suggests)

I think that my NixOS configuration is the culprit here, because I’m not
too experienced with it and I see it needs to be very specific when
configuring haskell. I’m wondering if I’m missing some extra haskell
package. I tried with `haskell.packages.ghc865.hoogle` hoping it would
make a difference in showing me types or documentation, but no luck
here.

Thanks for any insight you can give me.

- [1] https://discourse.nixos.org/t/configuration-needed-for-haskell-ide-environment/4240
- [2] http://marco-lopes.com/articles/Vim-and-Haskell-in-2019/
- [3] https://github.com/neoclide/coc.nvim
- [4] https://github.com/neoclide/coc.nvim#example-vim-configuration

Marc Busqué
http://waiting-for-dev.github.io/about/


More information about the Haskell-Cafe mailing list