├── .gitattributes ├── .gitignore ├── .vscode └── launch.json ├── .vscodeignore ├── CHANGELOG.md ├── README.md ├── images ├── kahroba.png └── kahroba.svg ├── language-configuration.json ├── package.json ├── snippets └── kahroba.json ├── syntaxes └── kahroba.tmLanguage.json └── vsc-extension-quickstart.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behavior to automatically normalize line endings. 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.vsix -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ] 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "kahroba" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | ## [1.1.1] 7 | - Updated Features in README.md 8 | 9 | ## [1.1.0] 10 | 11 | - fix the Kahroba extension installation command. 12 | - edit (.khb) file extension to (.krb) 13 | 14 | ## [1.0.0] 15 | 16 | - Initial release of kahroba extension -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kahroba extension for Visual Studio Code 2 | This extension contains Kahroba Snippets and Commands. 3 | ## Installation 4 | Launch _Quick Open_: 5 | 6 | - _Linux_ : `Ctrl+P` 7 | - _macOS_ : `⌘P` 8 | - _Windows_ : `Ctrl+P` 9 | 10 | Paste the following command and press `Enter`: 11 | 12 | ```shell 13 | ext install AmirhosseinMalekian.kahroba 14 | ``` 15 | 16 | ## Quick start 17 | - **Step 1.** [Install a supported version of Kahroba on your system](https://github.com/kahroba-lang/kahroba) 18 | - **Step 2.** [Install the Kahroba extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=AmirhosseinMalekian.kahroba). 19 | - **Step 3.** Open or create a Kahroba file and start coding! 20 | 21 | ## Features 22 | * [Code autocompletion] - Autocompletion for Kahroba keywords, functions, and variables. 23 | * [Code snippets] - Code snippets are templates that make it easier to enter repeating code patterns, such as loops or conditional-statements. 24 | * [Highlighting] - Syntax highlighting for Kahroba code. 25 | 26 | ## Supported file extensions 27 | * (.kahroba) 28 | * (.krb) 29 | 30 | ## Snippets 31 | Below is a list of all available snippets and the triggers of each one. The **⇥** means the `TAB` key. 32 | 33 | | Snippet | Content | 34 | | ------- | --------------------------------------------- | 35 | | `in→` | input | 36 | | `fn→` | function declaration | 37 | | `for→` | for loop | 38 | | `ie→` | if/else statement | 39 | | `if→` | if statement | 40 | | `el→` | else statement | 41 | | `pl→` | println | 42 | | `p→` | print | 43 | -------------------------------------------------------------------------------- /images/kahroba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kahroba-lang/vscode/531f5548fb5b5d0fbf5c313809de4b2caf6df2ac/images/kahroba.png -------------------------------------------------------------------------------- /images/kahroba.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | // symbol used for single line comment. Remove this entry if your language does not support line comments 4 | "lineComment": "//" 5 | }, 6 | // symbols used as brackets 7 | "brackets": [ 8 | ["{", "}"], 9 | ["[", "]"], 10 | ["(", ")"] 11 | ], 12 | // symbols that are auto closed when typing 13 | "autoClosingPairs": [ 14 | ["{", "}"], 15 | ["[", "]"], 16 | ["(", ")"], 17 | ["\"", "\""], 18 | ["'", "'"] 19 | ], 20 | // symbols that can be used to surround a selection 21 | "surroundingPairs": [ 22 | ["{", "}"], 23 | ["[", "]"], 24 | ["(", ")"], 25 | ["\"", "\""] 26 | ], 27 | "folding": { 28 | "markers": { 29 | "start": "^\\s*//\\s*#?region\\b", 30 | "end": "^\\s*//\\s*#?endregion\\b" 31 | } 32 | }, 33 | "onEnterRules": [ 34 | { 35 | "beforeText": "^\\s*(?:fn|for|if|else).*?:\\s*$", 36 | "action": { "indent": "indent" } 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kahroba", 3 | "displayName": "Kahroba", 4 | "description": "Kahroba language support for Visual Studio Code", 5 | "version": "1.1.1", 6 | "publisher": "AmirhosseinMalekian", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/kahroba-lang/vscode" 10 | }, 11 | "icon": "images/kahroba.png", 12 | "engines": { 13 | "vscode": "^1.71.0" 14 | }, 15 | "categories": [ 16 | "Programming Languages", 17 | "Snippets" 18 | ], 19 | "contributes": { 20 | "languages": [ 21 | { 22 | "id": "kahroba", 23 | "aliases": [ 24 | "Kahroba", 25 | "kahroba", 26 | "KAHROBA" 27 | ], 28 | "extensions": [ 29 | ".kahroba", 30 | ".krb" 31 | ], 32 | "configuration": "./language-configuration.json" 33 | } 34 | ], 35 | "grammars": [ 36 | { 37 | "language": "kahroba", 38 | "scopeName": "source.kahroba", 39 | "path": "./syntaxes/kahroba.tmLanguage.json" 40 | } 41 | ], 42 | "snippets": [ 43 | { 44 | "language": "kahroba", 45 | "path": "./snippets/kahroba.json" 46 | } 47 | ] 48 | } 49 | } -------------------------------------------------------------------------------- /snippets/kahroba.json: -------------------------------------------------------------------------------- 1 | { 2 | "if statement": { 3 | "prefix": "if", 4 | "body": "if ${1:condition} {\n\t$0\n}", 5 | "description": "Code snippet for an if statement" 6 | }, 7 | "if/else statement": { 8 | "prefix": "ie", 9 | "body": "if ${1:condition} {\n\t$2\n} else {\n\t$0\n}", 10 | "description": "Code snippet for an if statement with else" 11 | }, 12 | "else": { 13 | "prefix": "el", 14 | "body": "else {\n\t$0\n}", 15 | "description": "Code snippet for an else" 16 | }, 17 | "for": { 18 | "prefix": "for", 19 | "body": "for ${1:target_list} in ${2:expression_list} {\n\t$0\n}", 20 | "description": "Code snippet for a for loop" 21 | }, 22 | "function declaration": { 23 | "prefix": "fn", 24 | "body": "fn ${1:funcname}(${2:parameter_list}) {\n\t$0\n}", 25 | "description": "Snippet for function declaration" 26 | }, 27 | "println": { 28 | "prefix": "pl", 29 | "body": "println(\"$1\")", 30 | "description": "Snippet for println()" 31 | }, 32 | "print": { 33 | "prefix": "p", 34 | "body": "print(\"$1\")", 35 | "description": "Snippet for print()" 36 | }, 37 | "input": { 38 | "prefix": "in", 39 | "body": "input(\"$1\")", 40 | "description": "Snippet for input()" 41 | } 42 | } -------------------------------------------------------------------------------- /syntaxes/kahroba.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", 3 | "name": "Kahroba", 4 | "scopeName": "source.kahroba", 5 | "patterns": [ 6 | { 7 | "include": "#comments" 8 | }, 9 | { 10 | "include": "#strings" 11 | }, 12 | { 13 | "comment": "Syntax error using arrays", 14 | "match": "\\[\\](\\s+)", 15 | "captures": { 16 | "1": { 17 | "name": "invalid.illegal.array.kahroba" 18 | } 19 | } 20 | }, 21 | { 22 | "comment": "Syntax error numeric literals", 23 | "match": "\\b0[0-7]*[89]\\d*\\b", 24 | "name": "invalid.illegal.numeric.kahroba" 25 | }, 26 | { 27 | "comment": "Built-in functions", 28 | "match": "\\b(len|swap|print|println|input)\\b(?=\\()", 29 | "name": "support.function.builtin.kahroba" 30 | }, 31 | { 32 | "comment": "Function declarations", 33 | "match": "^(\\bfn\\b)(?:\\s+(\\([^\\)]+\\)\\s+)?(\\w+)(?=\\())?", 34 | "captures": { 35 | "1": { 36 | "name": "keyword.function.kahroba" 37 | }, 38 | "2": { 39 | "patterns": [ 40 | { 41 | "include": "#brackets" 42 | }, 43 | { 44 | "include": "#operators" 45 | } 46 | ] 47 | }, 48 | "3": { 49 | "patterns": [ 50 | { 51 | "match": "\\d\\w*", 52 | "name": "invalid.illegal.identifier.kahroba" 53 | }, 54 | { 55 | "match": "\\w+", 56 | "name": "entity.name.function.kahroba" 57 | } 58 | ] 59 | } 60 | } 61 | }, 62 | { 63 | "comment": "Functions", 64 | "match": "(\\bfn\\b)|(\\w+)(?=\\()", 65 | "captures": { 66 | "1": { 67 | "name": "keyword.function.kahroba" 68 | }, 69 | "2": { 70 | "patterns": [ 71 | { 72 | "match": "\\d\\w*", 73 | "name": "invalid.illegal.identifier.kahroba" 74 | }, 75 | { 76 | "match": "\\w+", 77 | "name": "support.function.kahroba" 78 | } 79 | ] 80 | } 81 | } 82 | }, 83 | { 84 | "include": "#numeric_literals" 85 | }, 86 | { 87 | "comment": "Language constants", 88 | "match": "\\b(true|false)\\b", 89 | "name": "constant.language.kahroba" 90 | }, 91 | { 92 | "match": "\\b\\w+(?=\\s*=)", 93 | "captures": { 94 | "0": { 95 | "patterns": [ 96 | { 97 | "match": "\\d\\w*", 98 | "name": "invalid.illegal.identifier.kahroba" 99 | }, 100 | { 101 | "match": "\\w+", 102 | "name": "variable.other.assignment.kahroba" 103 | }, 104 | { 105 | "include": "#delimiters" 106 | } 107 | ] 108 | } 109 | } 110 | }, 111 | { 112 | "include": "#brackets" 113 | }, 114 | { 115 | "include": "#delimiters" 116 | }, 117 | { 118 | "include": "#keywords" 119 | }, 120 | { 121 | "include": "#operators" 122 | } 123 | ], 124 | "repository": { 125 | "strings": { 126 | "name": "string.quoted.double.kahroba", 127 | "begin": "\"", 128 | "end": "\"", 129 | "patterns": [ 130 | { 131 | "name": "constant.character.escape.kahroba", 132 | "match": "\\\\." 133 | } 134 | ] 135 | }, 136 | "comments": { 137 | "patterns": [ 138 | { 139 | "name": "comment.line.double-slash.kahroba", 140 | "begin": "(\\/\\/)", 141 | "beginCaptures": { 142 | "1": { 143 | "name": "punctuation.definition.comment.kahroba" 144 | } 145 | }, 146 | "end": "(?:\\n|$)" 147 | } 148 | ] 149 | }, 150 | "brackets": { 151 | "patterns": [ 152 | { 153 | "begin": "{", 154 | "beginCaptures": { 155 | "0": { 156 | "name": "punctuation.definition.begin.bracket.curly.kahroba" 157 | } 158 | }, 159 | "end": "}", 160 | "endCaptures": { 161 | "0": { 162 | "name": "punctuation.definition.end.bracket.curly.kahroba" 163 | } 164 | }, 165 | "patterns": [ 166 | { 167 | "include": "$self" 168 | } 169 | ] 170 | }, 171 | { 172 | "begin": "\\(", 173 | "beginCaptures": { 174 | "0": { 175 | "name": "punctuation.definition.begin.bracket.round.kahroba" 176 | } 177 | }, 178 | "end": "\\)", 179 | "endCaptures": { 180 | "0": { 181 | "name": "punctuation.definition.end.bracket.round.kahroba" 182 | } 183 | }, 184 | "patterns": [ 185 | { 186 | "include": "$self" 187 | } 188 | ] 189 | }, 190 | { 191 | "match": "\\[|\\]", 192 | "name": "punctuation.definition.bracket.square.kahroba" 193 | } 194 | ] 195 | }, 196 | "operators": { 197 | "comment": "Note that the order here is very important!", 198 | "patterns": [ 199 | { 200 | "match": "(==|!=|<=|>=|<(?!<)|>(?!>))", 201 | "name": "keyword.operator.comparison.kahroba" 202 | }, 203 | { 204 | "match": "(!)", 205 | "name": "keyword.operator.logical.kahroba" 206 | }, 207 | { 208 | "match": "(=)", 209 | "name": "keyword.operator.assignment.kahroba" 210 | }, 211 | { 212 | "match": "(\\+|\\-|\\*|/)", 213 | "name": "keyword.operator.arithmetic.kahroba" 214 | }, 215 | { 216 | "match": "\\.\\.", 217 | "name": "keyword.operator.dotdot.kahroba" 218 | } 219 | ] 220 | }, 221 | "numeric_literals": { 222 | "match": "(?/.vscode/extensions` folder and restart Code. 29 | * To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. 30 | --------------------------------------------------------------------------------