Skip to content

Commit

Permalink
adds support for constant declaration, function calling and coco.nut …
Browse files Browse the repository at this point in the history
…file (#6)
  • Loading branch information
sarvalabs-sarthak authored Sep 13, 2023
1 parent 10b5c54 commit 2b166a9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cocolang-lsp-client",
"displayName": "Cocolang LSP Client",
"description": "Syntax Highlighting for Cocolang on Visual Studio Code",
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",
"publisher": "sarvalabs",
"author": {
Expand Down
Binary file added icons/coco-grey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 19 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Cocolang",
"icon": "icons/coco.png",
"description": "Syntax Highlighting for Cocolang on Visual Studio Code",
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",
"publisher": "sarvalabs",
"author": {
Expand Down Expand Up @@ -43,13 +43,31 @@
"dark": "./icons/coco.png"
},
"configuration": "./languages/language-configuration.json"
},
{
"id": "coco_nut",
"extensions": [
".nut"
],
"aliases": [
"coco.nut",
"Coco Nut"
],
"icon": {
"light": "./icons/coco-grey.png",
"dark": "./icons/coco-grey.png"
}
}
],
"grammars": [
{
"language": "coco",
"scopeName": "source.coco",
"path": "./syntaxes/coco.tmLanguage.json"
},
{
"language": "coco_nut",
"scopeName": "source.coconut"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cocolang-lsp-server",
"displayName": "Cocolang LSP Server",
"description": "Syntax Highlighting for Cocolang on Visual Studio Code",
"version": "0.2.0",
"version": "0.2.1",
"license": "MIT",
"publisher": "sarvalabs",
"author": {
Expand Down
22 changes: 17 additions & 5 deletions server/src/modules/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,20 @@ export const completionItems = (): CompletionItem[] => {
data: 10
},
{
label: 'method',
label: 'coco',
kind: CompletionItemKind.Text,
data: 10
data: 11
},
{
label: 'coco',
label: 'var',
kind: CompletionItemKind.Text,
data: 11
}
data: 12
},
{
label: 'const',
kind: CompletionItemKind.Text,
data: 13
},
]
}

Expand Down Expand Up @@ -114,6 +119,13 @@ export const completionDetails = (item: CompletionItem): CompletionItem => {
item.detail = 'module declaration';
item.documentation = 'The name of the module is one of Coco’s superglobals. It can be used to access the state information of the module as well as other information about the logic module.';
break;
case 12:
item.detail = 'var declaration';
item.documentation = 'The var keyword is used to declare named variables with a specific type assigned in Coco';
break;
case 13:
item.detail = 'const declaration';
item.documentation = 'The const keyword is used to declare named constant values of a specific type in Coco'
default:
break;
}
Expand Down
15 changes: 15 additions & 0 deletions syntaxes/coco.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@
},
"constants": {
"patterns": [
{
"name": "constant.declaration.coco",
"match": "\\b(const)\\b\\s+((?:[a-zA-Z_][a-zA-Z0-9_]*\\s*,\\s*)*[a-zA-Z_][a-zA-Z0-9_]*)\\s+([a-zA-Z_][a-zA-Z0-9_]+\\b)?",
"captures": {
"1": {
"name": "keyword.const.coco"
},
"2": {
"name": "variable.other.declaration.coco"
},
"3": {
"name": "storage.type.coco"
}
}
},
{
"comment": "Numeric Value Declaration",
"match": "\\b((0x[0-9a-fA-F]+)|(0[0-7]+i?)|(\\d+([Ee]\\d+)?i?)|(\\d+[Ee][-+]\\d+i?))\\b",
Expand Down

0 comments on commit 2b166a9

Please sign in to comment.