Language-server-protocol: Clarify usage of {{value}} and cursor position after completion

Created on 4 Oct 2016  路  13Comments  路  Source: microsoft/language-server-protocol

In #81, I learned that {{}} can be used in a completion item to indicate where cursor should be placed. The protocol documentation doesn't mention that. Can it please be added? Also some related questions:

  • Does this apply to any TextEdit or only completion ones?
  • Is this something that is configured?
  • Would it make sense to avoid this workaround and have the TextEdit also contain an (optional) recommendation of a cursor position?
clarification

Most helpful comment

It is #75.

And we made some progress on this for the upcoming 1.8 release and it got already merged into some of the LSP client and server libraries for node.

All 13 comments

This is related to #75.

This was without any intention and we need to carefully think about how we deal with cursor positions in the protocol itself. I tried to stay away from this so far by not exposing any properties to manipulate the cursor position.

See this interesting comment https://github.com/eclipselabs/eclipse-language-service/issues/57#issuecomment-254629377 . A solution could be that placeHolderStart and placeHolderEnd should be part of the completionOptions returned with the capabilities.

Close as dup of #82

@mickaelistria Did you intend to say that it's closed as a dupe of #75?

It is #75.

And we made some progress on this for the upcoming 1.8 release and it got already merged into some of the LSP client and server libraries for node.

What kind of progress were done? Anything that applies to the protocol already?

Yes, but not speced yet. The 2.6.x version of the node libraries available do have preliminary support for it in the protocol.d.ts. Look at SnippetString.

@dbaeumer I am looking at the CompletionItem changes on the 2.6.x node libraries for this one. CompletionItem.insertText is now defined as insertText?: string | SnippetString; Unfortunately these union types are hard to map on languages such as Java, @svenefftinge has been working on a solution but the options are ranging from bad to worse. Can we spec this differently than the current node library implementation so that it is easier for strongly typed folks?

@gorkem for the upcoming 3.0 library I speced a TypedString which can either be a normal string or a snippet string. So for people that can't deal with OR types they can always sent a TypedString.

Just for clarification. The final design uses a insertTextFormat kind but provides the same functionality as the TypeString (no or types)

@akosyakov, @svenefftinge does the insertTextFormat solution work for you?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kaloyan-raev picture kaloyan-raev  路  6Comments

Eskibear picture Eskibear  路  3Comments

ljw1004 picture ljw1004  路  3Comments

davidanthoff picture davidanthoff  路  3Comments

marekdedic picture marekdedic  路  5Comments