add rust syntax
parent
5c9f272f54
commit
381062518e
|
@ -746,6 +746,8 @@ new_file_buffer :: proc(allocator: mem.Allocator, file_path: string, base_dir: s
|
||||||
file_type: ts.LanguageType = .None
|
file_type: ts.LanguageType = .None
|
||||||
if extension == ".odin" {
|
if extension == ".odin" {
|
||||||
file_type = .Odin
|
file_type = .Odin
|
||||||
|
} else if extension == ".rs" {
|
||||||
|
file_type = .Rust
|
||||||
} else if extension == ".json" {
|
} else if extension == ".json" {
|
||||||
file_type = .Json
|
file_type = .Json
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,11 @@ foreign ts_odin {
|
||||||
tree_sitter_odin :: proc "c" () -> Language ---
|
tree_sitter_odin :: proc "c" () -> Language ---
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreign import ts_rust "../../bin/libtree-sitter-rust.a"
|
||||||
|
foreign ts_rust {
|
||||||
|
tree_sitter_rust :: proc "c" () -> Language ---
|
||||||
|
}
|
||||||
|
|
||||||
foreign import ts_json "../../bin/libtree-sitter-json.a"
|
foreign import ts_json "../../bin/libtree-sitter-json.a"
|
||||||
foreign ts_json {
|
foreign ts_json {
|
||||||
tree_sitter_json :: proc "c" () -> Language ---
|
tree_sitter_json :: proc "c" () -> Language ---
|
||||||
|
@ -123,6 +128,7 @@ LanguageType :: enum {
|
||||||
None,
|
None,
|
||||||
Json,
|
Json,
|
||||||
Odin,
|
Odin,
|
||||||
|
Rust,
|
||||||
}
|
}
|
||||||
|
|
||||||
TestStuff :: struct {
|
TestStuff :: struct {
|
||||||
|
@ -211,6 +217,7 @@ make_state :: proc(type: LanguageType, allocator := context.allocator) -> State
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case .None: {}
|
case .None: {}
|
||||||
case .Odin: language = tree_sitter_odin()
|
case .Odin: language = tree_sitter_odin()
|
||||||
|
case .Rust: language = tree_sitter_rust()
|
||||||
case .Json: language = tree_sitter_json()
|
case .Json: language = tree_sitter_json()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +241,7 @@ delete_state :: proc(state: ^State) {
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_buffer :: proc(state: ^State, input: Input) {
|
parse_buffer :: proc(state: ^State, input: Input) {
|
||||||
if state.parser == nil {
|
if state.parser == nil || state.language_type == .None {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,6 +322,27 @@ load_highlights :: proc(state: ^State) {
|
||||||
capture_to_color["comment"] = .Gray
|
capture_to_color["comment"] = .Gray
|
||||||
|
|
||||||
}
|
}
|
||||||
|
case .Rust: {
|
||||||
|
capture_to_color["string"] = .Green
|
||||||
|
capture_to_color["comment"] = .Gray
|
||||||
|
|
||||||
|
capture_to_color["type"] = .BrightBlue
|
||||||
|
|
||||||
|
capture_to_color["type.builtin"] = .Aqua
|
||||||
|
|
||||||
|
capture_to_color["label"] = .Red
|
||||||
|
capture_to_color["variable.builtin"] = .Red
|
||||||
|
|
||||||
|
capture_to_color["keyword"] = .Blue
|
||||||
|
capture_to_color["function"] = .Blue
|
||||||
|
capture_to_color["function.method"] = .Blue
|
||||||
|
|
||||||
|
capture_to_color["property"] = .BrightYellow
|
||||||
|
capture_to_color["constructor"] = .Yellow
|
||||||
|
capture_to_color["attribute"] = .BrightGray
|
||||||
|
|
||||||
|
capture_to_color["constant.builtin"] = .Purple
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path: string
|
path: string
|
||||||
|
@ -327,6 +355,9 @@ load_highlights :: proc(state: ^State) {
|
||||||
case .Odin: {
|
case .Odin: {
|
||||||
path = "../tree-sitter-odin/queries/highlights.scm"
|
path = "../tree-sitter-odin/queries/highlights.scm"
|
||||||
}
|
}
|
||||||
|
case .Rust: {
|
||||||
|
path = "../tree-sitter-rust/queries/highlights.scm"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fd, err := os.open(path)
|
fd, err := os.open(path)
|
||||||
|
|
Loading…
Reference in New Issue