syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.71k stars 4.9k forks source link

Company backends not loading in haskell layer #7426

Closed domdere closed 3 years ago

domdere commented 8 years ago

Description :octocat:

Company backends are not loaded in haskell layer.

For the reproduction steps, I used the ghci backend since its got less pre-reqs,

But I actually use the ghc-mod backend (i.e i actually have (haskell :variables haskell-completion-backend 'ghc-mod))

And I can see that this function is being run because the major mode key bindings are added to the SPC menu.

I don't know to reproduce it, but i have noticed under some rare conditions, the additional backends (company-{ghc|ghci|yasnippet}) do become active, But they never seem to be active on startup, if they ever do get triggered, its always sometime in the middle of a session

Reproduction guide :beetle:

  1. Activate haskell layer in .spacemacs with line (haskell :variables haskell-completion-backend 'ghci)
  2. Start Emacs
  3. Load haskell source file inside haskell project
  4. move cursor to the end of any word
  5. run M-x company-diag
  6. observe that neither company-ghci nor company-yasnippet are in the list.
  7. open up another haskell source file in the project
  8. repeat 4 and 5
  9. notice that company-ghci and company-yasnippet now appear in the backends list

Observed behaviour: :eyes: :broken_heart:

Neither company-ghci nor company-yasnippet appear in the list of backends active

Expected behaviour: :heart: :smile:

Expect to see company-ghci and company-yasnippet in the list of backends active/queried.

System Info :computer:

osx
auto-completion
chrome
deft
themes-megapack
git
version-control
restclient
syntax-checking
search-engine
c-c  
markdown
org
(scala :variables scala-enable-eldoc nil)
(haskell :variables haskell-completion-backend 'ghci)
latex
shell-scripts
shell
sql

Backtrace :paw_prints:

domdere commented 8 years ago

Ok, I've noticed that the backends (company-ghc and company-yasnippet) arent active until the next haskell source file loads, and whenever i switch back to the buffer for the first source file opened, the backends are still not active for that buffer...

(I've updated the reproduction steps)

d12frosted commented 8 years ago

Sorry for the silence. I'll take a look on this issue very soon.

d12frosted commented 8 years ago

As per point 7. You can just revisit the same file to make it working again.

So yeah, this is funny. Company is not properly set on first visit of hs file in project / session.

gilbertoalexsantos commented 8 years ago

Same issue happening here, also the part where company-ghci and company-yasnippet are only loaded after next haskell source file is loaded.

xiaohanyu commented 8 years ago

Same issue here.

rski commented 7 years ago

I think this happens because spacemacs-haskell//setup-completion-backend, the function that populates company-backends-haskell-mode, is called by the local-vars hook, which is called after the functions that populate the company backends so the haskell backends are not included there. This gets fixed when the next haskell file is opened, since company-backends-haskell-mode is populated already. Moving the call to setup-completion-backend to haskell/post-init-company[0], where the docs say it should be, works for ghci, but not when the completion backend is ghc-mod, because ghc-init is not available yet [1]:

An error occurred while post-configuring company in layer haskell (error: (void-function ghc-init))

I haven't checked with intero.

It seems to me that the way to fix this is by doing [0]. Fixing [1] should be done by moving (ghc-init) under haskell/init-ghc or some similar place. Any problems come up with the intero backend as a result of [0] need to be fixed as well.

If I understand the code correctly however, the haskell completion backend will no longer be settable via local variables. I'm not sure if it was ever set correctly this way though anyhow.

juxtin commented 7 years ago

Still experiencing this on the dev branch, but only when using (haskell :variables haskell-completion-backend 'ghc-mod). With intero as the completion backend, it's fine.

nrolland commented 6 years ago

same here, on develop branch, almost 2 years after. It's too bad haskell does not have a smooth, self contained, out of the box experience with emacs.

d12frosted commented 6 years ago

Hi @nrolland,

What completion backend did you try?


I'll take a look on this issue very soon.

P. S. Ok, it didn't happen. 😿

d12frosted commented 6 years ago

At long last, I've merged that PR into develop. Would be nice to have feedback.

Relevant commit is 152d41e.

nrolland commented 6 years ago

Thanks, I'll have a look when I do some haskell. given the multiple configurations available for haskell, wouldn't that make sense to have some specialized layers, like haskell-intero, haskell-dante, etc..

It would be great to have a dead simple way to reuse custom layers between GitHub users, so that we rely on the official spacemacs only as a (hopefully good) default.

kenranunderscore commented 5 years ago

@d12frosted I'm on fba9447cfef900e4d955f45a424e0df27c40b2f7 in develop right now and noticed a newly-started Haskell project not having completion (with neither ghci nor dante as completion backends). Upon stumbling over this issue, I checked the enabled modes and company wasn't there. I then tried adding another .hs file, which immediately made company appear and work. (In other languages/layers I use there doesn't seem to be any problem)

So I guess it's not really fixed yet, though with the easy workaround of opening a second Haskell source file once (or reopening the first one).

qcfu-bu commented 4 years ago

Can confirm that the bug still persists.

lebensterben commented 3 years ago

closing. If this is still a problem, please open a new issue with details. Alternatively, use haskell language server.