Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show type of expressions, not just identifiers #471

Open
hasufell opened this issue Jun 15, 2018 · 11 comments
Open

Show type of expressions, not just identifiers #471

hasufell opened this issue Jun 15, 2018 · 11 comments

Comments

@hasufell
Copy link

hasufell commented Jun 15, 2018

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): DanielG/ghc-mod#900 (comment)

@autozimu
Copy link
Owner

Can you help get the request vscode sent to server?

@alanz
Copy link

alanz commented Jun 16, 2018

@alanz
Copy link

alanz commented Jun 16, 2018

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}]}}

@autozimu
Copy link
Owner

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

@alanz
Copy link

alanz commented Jun 20, 2018

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

@alanz
Copy link

alanz commented Jun 20, 2018

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.

@hasufell
Copy link
Author

hasufell commented Sep 9, 2018

any news here?

@alanz
Copy link

alanz commented Sep 9, 2018

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

@teto
Copy link

teto commented Nov 30, 2018

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

@pshemass
Copy link

any update on this?

@autozimu
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants