LanguageClient-neovim
LanguageClient-neovim copied to clipboard
Show type of expressions, not just identifiers
In e.g. haskell this is one of the most fundamental features. Another non-LSP plugin can already do that:

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
Can you help get the request vscode sent to server?
See also https://github.com/Microsoft/language-server-protocol/issues/377
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}]}}
The current selection is not passed in this request, right?
hmm, it should be. Let me check again what is happening.
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.
any news here?
It is done in the vscode client, by matching the spans of returned values.
is it possible to expand on what is missing for this to work ? as a haskellbeginner, this would definitely help.
any update on this?
Basically the work needs done to support this feature is
- Create a wrapper function to send this request to server and wait for server response.
- Quey span of current vim selection.
- 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.