-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inclusion of Lua 5.0.3 keywords, standard library, and select sub-lib…
…raries (#12) Modified Lua.plist to more accurately reflect the on-instrument vanilla Lua features.
- Loading branch information
Showing
10 changed files
with
2,138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/* | ||
* Copyright 2018 Tektronix Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
'use strict' | ||
|
||
import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' | ||
|
||
const coroutineCompletions: Array<CompletionItem> = [ | ||
{ | ||
kind: CompletionItemKind.Module, | ||
label: 'coroutine' | ||
}, | ||
{ | ||
data: ['coroutine'], | ||
documentation: { | ||
kind: MarkupKind.Markdown, | ||
value: '```lua\nfunction create(f)\n```\n\ncoroutine.create(f) -> thread\n\ | ||
\n\ | ||
Creates and returns a new coroutine whose body is the given function f.' | ||
}, | ||
kind: CompletionItemKind.Function, | ||
label: 'create' | ||
}, | ||
{ | ||
data: ['coroutine'], | ||
documentation: { | ||
kind: MarkupKind.Markdown, | ||
value: '```lua\nfunction resume(co, ...)\n```\n\ | ||
\n\ | ||
coroutine.resume(co, ...) -> false, string\n\ | ||
\n\ | ||
coroutine.resume(co, ...) -> true, yield arguments\n\ | ||
\n\ | ||
Starts the execution of the given coroutine co or resumes its execution from the last yield call. The first value \ | ||
returned by this function indicates the error status of the coroutine co.\n\ | ||
\n\ | ||
If the error status is false, then the next value returned is the error message; otherwise the following values are \ | ||
those passed to the yield function.' | ||
}, | ||
kind: CompletionItemKind.Function, | ||
label: 'resume' | ||
}, | ||
{ | ||
data: ['coroutine'], | ||
documentation: { | ||
kind: MarkupKind.Markdown, | ||
value: '```lua\nfunction status(co)\n```\n\ncoroutine.status(co) -> string\n\ | ||
\n\ | ||
Returns the status of the given coroutine co as a string. Possible statuses are "running", "suspended", and "dead".' | ||
}, | ||
kind: CompletionItemKind.Function, | ||
label: 'status' | ||
}, | ||
{ | ||
data: ['coroutine'], | ||
documentation: { | ||
kind: MarkupKind.Markdown, | ||
value: '```lua\nfunction wrap(f)\n```\n\ncoroutine.wrap(f) -> function\n\ | ||
\n\ | ||
Creates a new coroutine whose body is the given function f and returns a function that resumes the coroutine each \ | ||
time it is called.\n\ | ||
\n\ | ||
Arguments passed to the returned function behave like those passed to a typical resume call. Return values from the \ | ||
resulting function do not include an error status boolean.' | ||
}, | ||
kind: CompletionItemKind.Function, | ||
label: 'wrap' | ||
}, | ||
{ | ||
data: ['coroutine'], | ||
documentation: { | ||
kind: MarkupKind.Markdown, | ||
value: '```lua\nfunction yield(...)\n```\n\ncoroutine.yield(...)\n\ | ||
\n\ | ||
Suspends execution of the current coroutine. Any arguments given are returned as extra results to the resume function.' | ||
}, | ||
kind: CompletionItemKind.Function, | ||
label: 'yield' | ||
}, | ||
] | ||
|
||
const coroutineSignatures: Array<SignatureInformation> = [ | ||
SignatureInformation.create( | ||
'coroutine.create(f)', | ||
undefined, | ||
ParameterInformation.create( | ||
'f', | ||
'A function to use as the coroutine body.' | ||
), | ||
), | ||
SignatureInformation.create( | ||
'coroutine.resume(co, ...)', | ||
undefined, | ||
ParameterInformation.create( | ||
'co', | ||
'A coroutine object of type "thread".' | ||
), | ||
ParameterInformation.create( | ||
'...', | ||
'Zero or more arguments to pass to the coroutine.' | ||
), | ||
), | ||
SignatureInformation.create( | ||
'coroutine.status(co)', | ||
undefined, | ||
ParameterInformation.create( | ||
'co', | ||
'A coroutine object of type "thread".' | ||
), | ||
), | ||
SignatureInformation.create( | ||
'coroutine.wrap(f)', | ||
undefined, | ||
ParameterInformation.create( | ||
'f', | ||
'A function to use as the coroutine body.' | ||
), | ||
), | ||
SignatureInformation.create( | ||
'coroutine.yield(...)', | ||
undefined, | ||
ParameterInformation.create( | ||
'...', | ||
'Zero or more arguments to return as extra results to the resume function.' | ||
), | ||
), | ||
] | ||
|
||
export async function getCoroutineCompletions(): Promise<Array<CompletionItem>> { | ||
return new Promise<Array<CompletionItem>>(( | ||
resolve: (value?: Array<CompletionItem>) => void, | ||
reject: (reason?: Error) => void | ||
): void => { | ||
try { | ||
resolve(coroutineCompletions) | ||
} catch (e) { | ||
reject(new Error(e.toString())) | ||
} | ||
}) | ||
} | ||
|
||
export async function getCoroutineSignatures(): Promise<Array<SignatureInformation>> { | ||
return new Promise<Array<SignatureInformation>>(( | ||
resolve: (value?: Array<SignatureInformation>) => void, | ||
reject: (reason?: Error) => void | ||
): void => { | ||
try { | ||
resolve(coroutineSignatures) | ||
} catch (e) { | ||
reject(new Error(e.toString())) | ||
} | ||
}) | ||
} |
Oops, something went wrong.