Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Click the page indicator in the pagination bar to jump to a specific page. (#1364)
- Pagination now appears for filtered tables whose total row count is unknown, so you can page through them instead of seeing only the first page. (#1364)
- First Page and Last Page keyboard actions, unbound by default and assignable in Settings > Keyboard. (#1364)
- JSON and JSONB cells now display pretty-printed by default, keeping your original key order and exact numbers. Viewing or reformatting a value no longer marks the row as changed, and saving no longer reorders keys or rounds large integers.

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public extension CodeLanguage {
static let allLanguages: [CodeLanguage] = [
.bash,
.javascript,
.json,
.jsx,
.sql
]
Expand Down Expand Up @@ -67,6 +68,15 @@ public extension CodeLanguage {
highlights: ["highlights-jsx", "injections"]
)

/// A language structure for `JSON`
static let json: CodeLanguage = .init(
id: .json,
tsName: "json",
extensions: ["json"],
lineCommentString: "",
rangeCommentStrings: ("", "")
)

/// A language structure for `SQL`
static let sql: CodeLanguage = .init(
id: .sql,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,15 @@ public struct CodeLanguage {
.appendingPathComponent("Resources/tree-sitter-\(tsName)/\(highlights).scm")
}

/// Gets the TSLanguage from `tree-sitter` — only SQL, Bash, and JavaScript are supported
/// Gets the TSLanguage from `tree-sitter`. Only SQL, Bash, JavaScript, and JSON are supported
private var tsLanguage: OpaquePointer? {
switch id {
case .bash:
return tree_sitter_bash()
case .javascript, .jsx:
return tree_sitter_javascript()
case .json:
return tree_sitter_json()
case .sql:
return tree_sitter_sql()
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(pair
key: (_) @string.special.key)

(string) @string

(number) @number

[
(null)
(true)
(false)
] @constant.builtin

(escape_sequence) @escape

(comment) @comment
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum TreeSitterLanguage: String {
case html
case javascript
case jsdoc
case json
case jsx
case python
case ruby
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class TreeSitterModel {
return javascriptQuery
case .jsx:
return jsxQuery
case .json:
return jsonQuery
case .sql:
return sqlQuery
default:
Expand All @@ -47,6 +49,11 @@ public class TreeSitterModel {
return queryFor(.jsx)
}()

/// Query for `JSON` files.
public private(set) lazy var jsonQuery: Query? = {
return queryFor(.json)
}()

/// Query for `SQL` files.
public private(set) lazy var sqlQuery: Query? = {
return queryFor(.sql)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ typedef struct TSLanguage TSLanguage;
const TSLanguage *tree_sitter_sql(void);
const TSLanguage *tree_sitter_bash(void);
const TSLanguage *tree_sitter_javascript(void);
const TSLanguage *tree_sitter_json(void);

#endif /* TreeSitterGrammars_h */
Loading
Loading