Skip to content

Commit

Permalink
Update tree-sitter
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Apr 8, 2024
1 parent 6af3b5b commit b8f6e77
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
14 changes: 7 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
</div>
<div id="query-container" style="">
<textarea id="query-input" style="display: none">
["when" "and" "or" "not" "in" "not in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword

[
(boolean)
(nil)
Expand All @@ -75,19 +73,21 @@
(alias) @module
(char) @constant

[
(string)
(charlist)
] @string

[
(atom)
(quoted_atom)
(keyword)
(quoted_keyword)
] @string.special.symbol

[
(string)
(charlist)
] @string
(comment) @comment

(comment) @comment</textarea>
["when" "and" "or" "not" "in" "not in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword</textarea>
</div>
</div>

Expand Down
26 changes: 12 additions & 14 deletions playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ let tree;
const parser = new TreeSitter();
const codeEditor = CodeMirror.fromTextArea(codeInput, {
lineNumbers: true,
showCursorWhenSelecting: true,
tabSize: 2
showCursorWhenSelecting: true
});

const queryEditor = CodeMirror.fromTextArea(queryInput, {
lineNumbers: true,
showCursorWhenSelecting: true,
tabSize: 2
showCursorWhenSelecting: true
});

const cluster = new Clusterize({
Expand Down Expand Up @@ -84,7 +82,7 @@ let tree;
async function handleLanguageChange() {
const newLanguageName = languageSelect.value;
if (!languagesByName[newLanguageName]) {
const url = './tree-sitter-elixir.wasm'
const url = './tree-sitter-elixir.wasm';
languageSelect.disabled = true;
try {
languagesByName[newLanguageName] = await TreeSitter.Language.load(url);
Expand Down Expand Up @@ -177,7 +175,7 @@ let tree;
const start = cursor.startPosition;
const end = cursor.endPosition;
const id = cursor.nodeId;
let fieldName = cursor.currentFieldName();
let fieldName = cursor.currentFieldName;
if (fieldName) {
fieldName += ': ';
} else {
Expand Down Expand Up @@ -423,10 +421,10 @@ let tree;
}

function loadState() {
const language = localStorage.getItem("languageElixir");
const sourceCode = localStorage.getItem("sourceCodeElixir");
const query = localStorage.getItem("queryElixir");
const queryEnabled = localStorage.getItem("queryEnabledElixir");
const language = localStorage.getItem("language");
const sourceCode = localStorage.getItem("sourceCode");
const query = localStorage.getItem("query");
const queryEnabled = localStorage.getItem("queryEnabled");
if (language != null && sourceCode != null && query != null) {
queryInput.value = query;
codeInput.value = sourceCode;
Expand All @@ -436,14 +434,14 @@ let tree;
}

function saveState() {
localStorage.setItem("languageElixir", languageSelect.value);
localStorage.setItem("sourceCodeElixir", codeEditor.getValue());
localStorage.setItem("language", languageSelect.value);
localStorage.setItem("sourceCode", codeEditor.getValue());
saveQueryState();
}

function saveQueryState() {
localStorage.setItem("queryEnabledElixir", queryCheckbox.checked);
localStorage.setItem("queryElixir", queryEditor.getValue());
localStorage.setItem("queryEnabled", queryCheckbox.checked);
localStorage.setItem("query", queryEditor.getValue());
}

function debounce(func, wait, immediate) {
Expand Down
2 changes: 1 addition & 1 deletion tree-sitter.js

Large diffs are not rendered by default.

Binary file modified tree-sitter.wasm
Binary file not shown.

0 comments on commit b8f6e77

Please sign in to comment.