haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.72k stars 366 forks source link

How do I use the Eval plugin? #425

Closed googleson78 closed 4 years ago

googleson78 commented 4 years ago

I'm using LanguageClient-neovim.

When I write something like, let's say

-- >>> 3 + 5

the only thing that happens is that the string Evaluate... pops up on the right of the comment (as nvim virtual text). I don't know how to interact with this - I only tried a codeAction and nothing pops up.

How do I interact with this via the lsp interface?

Anrock commented 4 years ago

I believe this question is about LanguageClient-neovim, not hls. Check out the docs of to see if there is something about triggering a codelens or create an issue about it in LanguageClient-neovim repo.

googleson78 commented 4 years ago

Thanks, it does support "code lens actions"!

My issue is rather that I can't find if it's mentioned anywhere that the evaluate thing is a "code lens" and that you're supposed to use the action associated with it.

Is it documented somewhere, and if not, would it be alright to put it in the README next to the feature description?

On a side-note if someone is willing to explain/give a pointer: For someone who hasn't programmed/directly used lsp: what's the decision process between deciding that something should be a "code lens" vs a "code action"?

jneira commented 4 years ago

Is it documented somewhere, and if not, would it be alright to put it in the README next to the feature description?

It would make sense for me.

what's the decision process between deciding that something should be a "code lens" vs a "code action"?

Afaik there is no a explicit process to take the decision, it depends on the implementer and varies from case to case.

Anrock commented 4 years ago

Quick'n'dirty PR with readme update: https://github.com/haskell/haskell-language-server/pull/428

tek commented 4 years ago

@googleson78 does anything happen when you run that code lens action thingy? I'm using coc.nvim, and when I hit code lens action, nothing happens on an Evaluate... line

googleson78 commented 4 years ago

@tek With the following file: asdf.hs

module Main where
-- >>> 3 + 5

if I do :call LanguageClient#handleCodeLensAction() I get the option to evaluate it (via LanguageClients mechanism for showing options), and if I select it my file changes to this:

module Main where
-- >>> 3 + 5
-- 8

the Main is there because of some bug (I think?, and I also think it was recently discussed somewhere around here and potentially fixed?) so I'm guessing either try adding a module declaration, or look at what coc.nvim does for "code lens action"

tek commented 4 years ago

I'm seeing this in the hls output:

2020-09-24 12:41:26.209277786 [ThreadId 1442559] - finish: runEvalCmd.ghcSession (took 0.00s)
2020-09-24 12:42:14.50019892 [ThreadId 1442564] - Plugin.makeCodeLens (ideLogger)
2020-09-24 12:42:14.500492612 [ThreadId 1442565] - finish: codeLens (took 0.00s)
2020-09-24 12:42:14.500763445 [ThreadId 1442567] - finish: importLens (took 0.00s)
2020-09-24 12:42:14.500818535 [ThreadId 1442569] - finish: importLens (took 0.00s)
[Error  - 12:42:15 PM] Request workspace/executeCommand failed.
  Message: BadDependency "GhcSessionDeps"
  Code: -32603
2020-09-24 12:42:15.212794328 [ThreadId 1442576] - finish: runEvalCmd.ghcSession (took 0.00s)
googleson78 commented 4 years ago

My original motivation/issue is now resolved, so I'm closing this.