LanguageClient-neovim icon indicating copy to clipboard operation
LanguageClient-neovim copied to clipboard

Show type of expressions, not just identifiers

Open hasufell opened this issue 7 years ago • 11 comments

In e.g. haskell this is one of the most fundamental features. Another non-LSP plugin can already do that:

peek 2018-06-15 12-09

From what I heard the haskell language server also has support for it (e.g. in VS Code): https://github.com/DanielG/ghc-mod/issues/900#issuecomment-397517309

hasufell avatar Jun 15 '18 10:06 hasufell

Can you help get the request vscode sent to server?

autozimu avatar Jun 15 '18 20:06 autozimu

See also https://github.com/Microsoft/language-server-protocol/issues/377

alanz avatar Jun 16 '18 07:06 alanz

This is what HIE sends

2018-06-16 10:30:41.246839896 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":8,"method":"workspace/executeCommand","params":{"command":"ghcmod:type","arguments":[{"file":"file:///home/alanz/tmp/hie-test-project/src/Main.hs","pos":{"line":3,"character":7},"include_constraints":true}]}}

alanz avatar Jun 16 '18 08:06 alanz

The current selection is not passed in this request, right?

autozimu avatar Jun 20 '18 01:06 autozimu

hmm, it should be. Let me check again what is happening.

alanz avatar Jun 20 '18 07:06 alanz

The

2018-06-20 11:29:41.393211089 [ThreadId 4] - --->
{"jsonrpc":"2.0","id":8
,"method":"workspace/executeCommand"
,"params":{"command":"ghcmod:type"
,"arguments":[{"file":"file:///home/alanz/tmp/hie-test-project/src/Main.hs"
                   ,"pos":{"line":3,"character":7},"include_constraints":true}]}}
2018-06-20 11:29:41.395925475 [ThreadId 5] - <--2--
{"result":[
  [{"start":{"line":3,"character":7},"end":{"line":3,"character":15}},"String -> IO ()"]
 ,[{"start":{"line":3,"character":7},"end":{"line":3,"character":33}},"IO ()"]
 ,[{"start":{"line":3,"character":0},"end":{"line":3,"character":33}},"IO ()"]]
,"jsonrpc":"2.0","id":8}

The command returns the types of all SrcSpans that cross over the given point. The plugin then matches the one that concides with the selected range.

alanz avatar Jun 20 '18 09:06 alanz

any news here?

hasufell avatar Sep 09 '18 14:09 hasufell

It is done in the vscode client, by matching the spans of returned values.

alanz avatar Sep 09 '18 15:09 alanz

is it possible to expand on what is missing for this to work ? as a haskellbeginner, this would definitely help.

teto avatar Nov 30 '18 06:11 teto

any update on this?

pshemass avatar Jan 27 '19 00:01 pshemass

Basically the work needs done to support this feature is

  1. Create a wrapper function to send this request to server and wait for server response.
  2. Quey span of current vim selection.
  3. Display correct type info based on span matching.

This isn't too much work in itself. But since is isn't in formal protocol and I don't use haskell myself, it is low prioritized on my TODO list. Happy to take any PR to make this happen though.

autozimu avatar Jan 28 '19 07:01 autozimu