microsoft / microsoft/language-server-protocol

General code snippets completion questions

Open
#801 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

completion discussion
Dominant language
TypeScript
Stars
13k
Forks
1k
Avg merge
6d 1h
Merged PRs (30d)
10

Description

Right now, we're on the middle of enabling code snippet support for the LSP client on Spyder and after reading the documentation regarding code snippet completions for textDocument/completion response, I have several questions regarding code completions on general. Here they are listed in order:

1. How should nested snippets be handled on placeholder snippets?

The documentation states that placeholders can be nested inside another, e.g., ${1:another ${2:placeholder}}, however it is not clear how clients should handle such cases, nor a clear case use example is presented. From my point of view, it is not clear if the example should behave identically to a choice completion ${1|another,placeholder|}?

Moreover, as any kind of snippet is allowed, what are the guidelines to process and present them, for instance, what would happen if the following snippet is entered? ${1: ${var: someplace_holder}}

2. How should conditional format be handled for regex snippets?

According to the grammar presented on the documentation, a regex can be applied to some variable to apply some transformations using a series of format flags presented as follows:

format      ::= '$' int | '${' int '}'
                | '${' int ':' '/upcase' | '/downcase' | '/capitalize' '}'
                | '${' int ':+' if '}'
                | '${' int ':?' if ':' else '}'
                | '${' int ':-' else '}' | '${' int ':' else '}'

While the first three options are clear and easy to understand thanks to an example given on the documentation, the latter ones related to conditional manipulations of the regex results are not clear enough, is it possible to have an example about those?

3. Where should variables be looked on?

The documentation states that the TM_* variables should be implemented by clients and be supported by default, and while the documentation is clear about the aforementioned variables, it is not clear where variables live when their value are custom. Should they be searched on the environment variables of the client process? Or should they be looked on the source code symbols using textDocument/documentSymbol? What happens with variable transformations for custom variable names, are they even allowed?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the code snippet completion documentation and the quoted grammar first. The issue asks maintainers to clarify nested snippets, regex conditionals, and custom-variable lookup; done would be documented, agreed behavior or examples for each question.

Written by the indexing model from the issue text.

Assessment

Domain
api, documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.