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

Autocomplete shortcuts #208

Open
pervoj opened this issue Jul 9, 2021 · 2 comments
Open

Autocomplete shortcuts #208

pervoj opened this issue Jul 9, 2021 · 2 comments
Labels
enhancement A new feature help wanted Tasks for newcomers

Comments

@pervoj
Copy link

pervoj commented Jul 9, 2021

It would be nice to have a feature in VLS similar to the one in IntelliJ. Simple shortcuts that could be used to autocomplete a longer command.

For example, main for the main() method, sout for stdout.printf(), or sirl for stdin.read_line(). Or even vmain for the main() method of type void.

@Prince781 Prince781 added the enhancement A new feature label Jul 9, 2021
@Prince781 Prince781 added the help wanted Tasks for newcomers label Jul 23, 2021
@gouthamkrishnakv
Copy link

I'm fairly sure that's called a Snippet. Yeah having snippets would be a nice addition to the language server itself.

@Prince781
Copy link
Member

Prince781 commented Nov 30, 2022

We already have many snippets in VLS for common statements/expressions:

if (nearest_symbol is Vala.Callable) {
completions.add_all_array ({
new CompletionItem.keyword ("catch", "catch ($1) {$2}$0"),
new CompletionItem.keyword ("delete", "delete $1;$0"),
new CompletionItem.keyword ("do", "do {$2} while (${1:<condition>});$0"),
new CompletionItem.keyword ("else"),
new CompletionItem.keyword ("else if", "else if (${1:<condition>})$0"),
new CompletionItem.keyword ("finally", "finally {$1}$0"),
new CompletionItem.keyword ("false"),
new CompletionItem.keyword ("for", "for (${3:var} ${1:i} = ${2:<expression>}; ${4:<condition>}; ${5:<expression>})$0"),
new CompletionItem.keyword ("foreach", "foreach (${3:var} ${1:item} in ${2:<expression>})$0"),
new CompletionItem.keyword ("if", "if (${1:<condition>})$0"),
new CompletionItem.keyword ("in", "in ${1:<expression>}$0"),
new CompletionItem.keyword ("is", "is ${1:<type>}$0"),
new CompletionItem.keyword ("new"),
new CompletionItem.keyword ("null"),
new CompletionItem.keyword ("return", "return ${1:<expression>};$0"),
new CompletionItem.keyword ("switch", "switch (${1:<expression>}) {$0}"),
new CompletionItem.keyword ("throw"),
new CompletionItem.keyword ("true"),
new CompletionItem.keyword ("try", "try {$1} catch ($2) {$3}$0"),
new CompletionItem.keyword ("var", "var ${1:<var-name>} = $0"),
new CompletionItem.keyword ("while", "while (${1:<condition>})$0"),
#if VALA_0_50
new CompletionItem.keyword ("with", "with (${1:<expression>}) {$0}"),
#endif
new CompletionItem.keyword ("yield"),
});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature help wanted Tasks for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants