I have a personal Editor that implements its own "protocol" for Code completion and would like to switch to Language server protocol to relieve myself from some development burden. However I have not been able to fully comprehend the LSP Documentation concerning client implementation. It's mixed up with Server implementation and cannot find clear difference between the two.
Much of online documentation (including questions on SO) revolved around VSCode extensions of which I have zero knowledge and are not helpful.
I would appreciate any help to get started writing a simple client that just queries autocomplete. I write my editor in C++ and would appreciate any tutorial that explains how to create client. I can understand Python, C, C#, Pure JavaScript, C++, PHP and similar languages, so I can easily follow any tutorial in those languages.
If anything is not clear let me know so that I can explain (this being my first post in LSP :) )
The LSP Client plugin provides many language features such as code completion, code navigation or finding references based on the Language Server Protocol. Once you have enabled the LSP Client in the plugin page, a new page called LSP Client will appear in your Kate configuration dialog.
Go to Tools > Options > File Locations > System > Expand section 'Support Files Search Path' , On righ side click on New tab and Browse and select folder D:\LISP Files (Move up this path) > Apply and Ok. Restart DraftSight or Open New file startup. lsp file will load automatically .
The way this happens with LSP is: The client opens the file and sends textDocument/didOpen to the server. The server analyzes the file and sends the textDocument/publishDiagnostics notification. The client parses the results and displays error indicators in the editor.
The Language Server Protocol (LSP) is a common protocol, in the form of JSON RPC v2. 0, used to provide language service features to various code editors.
Mattie of course lead me to the right direction. The most difficult was for me to understand the request/response. LSP have a very helpful page on that with unfortunate name (IMHO) that had misled me , "inspection". It turns out to be a good example on request/response.
I've successfully written a client that receives completion results from a server. Here's (approximately) what it does:
initialize
initialized
notificationtextDocument/didOpen
At this point, your server should be ready to answer the textDocument/completion
request. Depending on the response, you may also need to use completionItem/resolve
as well. To date, I've never needed this for the servers I've used, however.
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With