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

Support generating LSIF and/or SCIP index. #4119

Open
eownerdead opened this issue Mar 6, 2024 · 3 comments
Open

Support generating LSIF and/or SCIP index. #4119

eownerdead opened this issue Mar 6, 2024 · 3 comments
Labels
type: enhancement New feature or request

Comments

@eownerdead
Copy link

eownerdead commented Mar 6, 2024

Is your enhancement request related to a problem? Please describe.

Server Index Format (LSIF) and its successor SCIP Code Intelligence Protocol (SCIP) is a language-agnostic index format like ctags. It's developed by and used in sourcegraph, which provides web interfaces for code browsing with code navigation. Though there is already an LSIF implementation for Haskell, it has not maintained for long time.

Describe the solution you'd like

Adding a feature to generate SCIP index to this.
Also, we can get LSIF index with the SCIP to LSIF converter

Describe alternatives you've considered

Implement as a separated project.

Additional context

I know that rust-analyzer had this functionality, but I can't find any document...

Discussion at clangd

@fendor
Copy link
Collaborator

fendor commented Mar 6, 2024

Hi, thank you for your feature request!

This looks like a nice thing to have!

@michaelpj
Copy link
Collaborator

Interesting. It seems to me that it should be possible to produce SCIP (which does seem better than LSIF, I never liked LSIF) from HIE files. That could be an independent library from HLS, which HLS could then use to simplify some of its internals. I think many cases where we use HIE files directly could instead use SCIP information, although I don't know if that buys us anything.

In some cases we could move functionality over, e.g. our new semantic tokens plugin could I think just be part of the SCIP indexer, since it contains very similar information. (cc @soulomoon )

I think this would be a nice standalone project. Probably too late to sneak it into GSOC? (There's even already a Haskell binding for SCIP!)

@soulomoon
Copy link
Collaborator

soulomoon commented Mar 7, 2024

sounds interesting, I'll take a look.


Yes we can generate SCIP from HIE files.
And semantic tokens can depend solely on it.
But with one pitfall, hie file does not contain enough information to infer the Kind for a symbol if it is not defined in the file.

HLS use lookupKind to find this information.

If we solely base the generation on HIE files, I am not sure how much does it take us to generate hie files for all its dependencies(It need the hie file where the symbol is defined to get its Kind). And we might need to find a way to generate hie file for the base package ship with ghc as we have the same problem for the Goto dependency definition plugin #3749.

An alternative would be to add the Tything information (Not only the Type, since something is missing e.g. we can not tell if a name is pattern synonyms by looking at Type) to the HIE file, we use something like tyThingSemantic for the semantic token extraction) to capture some of the information we care about from TyThing and put the result into a new field of IdentifierDetails.


To prove the concept, we can make some changes like this to HieAst in ghc https://github.com/soulomoon/ghc/pull/1/files, then we can use just HieFile to create SCIP or semantic tokens


Alternatively we might expand the namespaces in ghc.
https://gitlab.haskell.org/ghc/ghc/-/issues/24544, chang to add EntityInfo to HieAst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants