diff --git a/absytree.nimble b/absytree.nimble index f28f2b5d..f3ebbe0b 100644 --- a/absytree.nimble +++ b/absytree.nimble @@ -36,7 +36,7 @@ requires "https://github.com/Nimaoth/nimtreesitter-api >= 0.1.11" requires "https://github.com/Nimaoth/nimwasmtime >= 0.1.5" # Use this to include all treesitter languages (takes longer to download) -requires "https://github.com/Nimaoth/nimtreesitter >= 0.1.5" +requires "https://github.com/Nimaoth/nimtreesitter >= 0.1.6" # Use these to only install specific treesitter languages. These don't work with the lock file # requires "https://github.com/Nimaoth/nimtreesitter?subdir=treesitter_nim >= 0.1.3" @@ -86,6 +86,13 @@ proc getCommandLineParams(): string = return "" return commandLineParams[3..^1].join(" ") +task setup2, "Setup": + exec "nimble setup" + when defined(windows): + cpFile "nimble.paths", "nimble-win.paths" + else: + cpFile "nimble.paths", "nimble-linux.paths" + task buildDesktop, "Build the desktop version": selfExec fmt"c -o:ast{exe} -d:exposeScriptingApi -d:absytreeBuildWasmtime --passC:-std=gnu11 {getCommandLineParams()} ./src/absytree.nim" # selfExec fmt"c --passL:advapi32.lib -o:ast{exe} -d:exposeScriptingApi -d:absytreeBuildWasmtime {getCommandLineParams()} ./src/absytree.nim" diff --git a/config.nims b/config.nims index 4a331149..b5cfedf3 100644 --- a/config.nims +++ b/config.nims @@ -46,8 +46,7 @@ switch("d", "wasm3VerboseErrorMessages") # Configure which treesitter languages are compiled into the editor (ignored on js backend) # switch("d", "treesitterBuiltins=cpp,nim,agda,bash,c,css,go,html,java,javascript,python,ruby,rust,scala,csharp,zig,haskell") -# switch("d", "treesitterBuiltins=cpp,nim,c,css,html,javascript,python,rust,csharp") -switch("d", "treesitterBuiltins=cpp,c,nim,csharp,rust,python,javascript") +switch("d", "treesitterBuiltins=cpp,c,nim,csharp,rust,python,javascript,json") # Automatically build wasmtime when compiling the editor const absytreeBuildWasmtime {.booldefine.} = false @@ -91,9 +90,6 @@ when defined(musl): # Disable system clipboard because it doesn't build with musl right now switch("d", "enableSystemClipboard=false") - # Remove nim from treesitterBuiltins because it doesn't build with musl right now - switch("d", "treesitterBuiltins=cpp,c,nim,csharp,rust,python,javascript") - else: switch("d", "ssl") diff --git a/config/settings.json b/config/settings.json index 87b2e2a8..598b0626 100644 --- a/config/settings.json +++ b/config/settings.json @@ -54,6 +54,7 @@ "\.zig$": "zig", "\.md$": "markdown", "\.scm$": "query", + "\.toml$": "toml", "/(vector|string|thread|iostream)$": "cpp", ".+/MSVC/.+/include(/.+?)*/[a-z0-9_]+$": "cpp", ".+/include/c\\+\\+(/.+?)+/[a-z0-9_]+$": "cpp" @@ -126,7 +127,24 @@ "ignoreContextLinePrefix": "{" }, "typescript": { - "treesitter": "tree-sitter/tree-sitter-typescript", + "treesitter": "tree-sitter/tree-sitter-typescript/typescript", + "tabWidth": 4, + "indent": "tab", + "indentAfter": [ + ":", + "=", + "(", + "{", + "[" + ], + "lineComment": "//", + "blockComment": [ + "/*", + "*/" + ] + }, + "tsx": { + "treesitter": "tree-sitter/tree-sitter-typescript/tsx", "tabWidth": 4, "indent": "tab", "indentAfter": [ @@ -257,8 +275,56 @@ "indent": "spaces", "blockComment": [ "" ] }, + "scala": { + "treesitter": "tree-sitter/tree-sitter-scala" + }, + "regex": { + "treesitter": "tree-sitter/tree-sitter-regex" + }, + "ocaml": { + "treesitter": "tree-sitter/tree-sitter-ocaml/grammars/interface" + }, "ocaml": { "treesitter": "tree-sitter/tree-sitter-ocaml/grammars/ocaml" + }, + "ocaml": { + "treesitter": "tree-sitter/tree-sitter-ocaml/grammars/type" + }, + "php": { + "treesitter": "tree-sitter/tree-sitter-php/php" + }, + "php": { + "treesitter": "tree-sitter/tree-sitter-php/php_only" + }, + "ruby": { + "treesitter": "tree-sitter/tree-sitter-ruby" + }, + "jsdoc": { + "treesitter": "tree-sitter/tree-sitter-jsdoc" + }, + "go": { + "treesitter": "tree-sitter/tree-sitter-go" + }, + "ql": { + "treesitter": "tree-sitter/tree-sitter-ql" + }, + "bash": { + "treesitter": "tree-sitter/tree-sitter-bash" + }, + "css": { + "treesitter": "tree-sitter/tree-sitter-css" + }, + "haskell": { + "treesitter": "tree-sitter/tree-sitter-haskell" + }, + "agda": { + "treesitter": "tree-sitter/tree-sitter-agda" + }, + "toml": { + "treesitter": "tree-sitter-grammars/tree-sitter-toml" + }, + "swift": { + "treesitter": "alex-pinkus/tree-sitter-swift" } }, diff --git a/languages/json/queries/highlights.scm b/languages/json/queries/highlights.scm new file mode 100644 index 00000000..ece8392f --- /dev/null +++ b/languages/json/queries/highlights.scm @@ -0,0 +1,16 @@ +(pair + key: (_) @string.special.key) + +(string) @string + +(number) @number + +[ + (null) + (true) + (false) +] @constant.builtin + +(escape_sequence) @escape + +(comment) @comment diff --git a/nimble.lock b/nimble.lock index 2b328960..ef4462c9 100644 --- a/nimble.lock +++ b/nimble.lock @@ -262,13 +262,13 @@ } }, "nimtreesitter": { - "version": "0.1.5", - "vcsRevision": "fb3cb90b534f464f93416813663a7734a0d8d313", + "version": "0.1.6", + "vcsRevision": "8e0af3c1efecfd624a169790d29a8b5e0b11edd6", "url": "https://github.com/Nimaoth/nimtreesitter", "downloadMethod": "git", "dependencies": [], "checksums": { - "sha1": "05ef2b4a9e16c0e1d20a290ca549dbac21be0012" + "sha1": "27ee351ba63063becf7b2739597dfc778634a4f0" } }, "nimwasmtime": { diff --git a/src/text/custom_treesitter.nim b/src/text/custom_treesitter.nim index 4752a34a..4666e720 100644 --- a/src/text/custom_treesitter.nim +++ b/src/text/custom_treesitter.nim @@ -174,6 +174,8 @@ else: import treesitter_scala/treesitter_scala/scala when useBuiltinTreesitterLanguage("typescript"): import treesitter_typescript/treesitter_typescript/typescript + when useBuiltinTreesitterLanguage("json"): + import treesitter_json/treesitter_json/json type TSQuery* = ref object impl: ptr ts.TSQuery @@ -611,6 +613,7 @@ proc loadLanguage(languageId: string, config: JsonNode): Future[Option[TSLanguag of "typescript": tryGetLanguage(treeSitterTypecript) of "nim": tryGetLanguage(treeSitterNim) of "zig": tryGetLanguage(treeSitterZig) + of "json": tryGetLanguage(treeSitterJson) else: log(lvlWarn, fmt"Failed to init treesitter for language '{languageId}'") TSLanguage.none