I’m fairly new to Language Server Protocol (LSP) and need some guidance on solving the following use case. I want to implement this on the server side to maximize compatibility with different IDEs.
Use Case:
I need to check if my project contains a license file, but only if:
- The project is tracked by Git. (search for a .git folder in the root)
- The remote origin URL contains “github.com”. (analyze .git/config)
What I’ve Researched:
-
workspace/diagnostic
Method:- This seemed promising initially.
- When I subscribed to this method, it fired randomly (at least for me and I had not control on how I often I would scan).
- It included a
partialResultToken
with different GUIDs per request, which I don’t know how to handle and couldn’t find much information on.
-
workspace/didChangeWorkspaceFolders
Notification:- This notification is sent by the client.
- However, notifications aren’t meant to have responses. How would one send back diagnostics.
The workspace events I mentioned above don’t include any workspace information. Do I really have to maintain the state from the initialize
event?
I also considered scanning for the file during the initialize
event but stepped away from that idea.
Question:
Am I on the right track, or is there a better way to send diagnostics to the client to indicate that the file is missing? How can I handle this use case effectively using LSP?