Skip to content
Open
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
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ tree-sitter-html = "<0.25.0"
tree-sitter-java = "<0.25.0"
tree-sitter-javascript = "<0.26.0"
tree-sitter-lua = "<0.25.0"
tree-sitter-odin-codebook = "1.4.0"
tree-sitter-php = "<0.25.0"
tree-sitter-python = "<0.26.0"
tree-sitter-r = "1.1.0"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,19 @@ Codebook is in active development. As better dictionaries are added, words that
| Language | Status |
| --- | --- |
| C | ✅ |
| C# | ⚠️ |
| C++ | ⚠️ |
| CSS | ⚠️ |
| Elixir | ⚠️ |
| Go | ✅ |
| HTML | ⚠️ |
| Haskell | ⚠️ |
| HTML | ⚠️ |
| Java | ✅ |
| JavaScript | ✅ |
| LaTeX | ⚠️ |
| Lua | ✅ |
| Markdown | ✅ |
| Odin | ✅ |
| PHP | ⚠️ |
| Plain Text | ✅ |
| Python | ✅ |
Expand All @@ -156,7 +158,6 @@ Codebook is in active development. As better dictionaries are added, words that
| TypeScript | ✅ |
| Typst | ⚠️ |
| Zig | ✅ |
| C# | ⚠️ |

✅ = Good to go.
⚠️ = Supported, but needs more testing. Help us improve!
Expand Down
1 change: 1 addition & 0 deletions crates/codebook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ tree-sitter-java.workspace = true
tree-sitter-javascript.workspace = true
codebook-tree-sitter-latex.workspace = true
tree-sitter-lua.workspace = true
tree-sitter-odin-codebook.workspace = true
tree-sitter-php.workspace = true
tree-sitter-python.workspace = true
tree-sitter-r.workspace = true
Expand Down
10 changes: 9 additions & 1 deletion crates/codebook/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum LanguageType {
Javascript,
Latex,
Lua,
Odin,
Php,
Python,
R,
Expand Down Expand Up @@ -187,7 +188,13 @@ pub static LANGUAGE_SETTINGS: &[LanguageSetting] = &[
query: include_str!("queries/bash.scm"),
extensions: &["sh", "bash"],
},
// Added PHP
LanguageSetting {
type_: LanguageType::Odin,
ids: &["odin"],
dictionary_ids: &["odin"],
query: include_str!("queries/odin.scm"),
extensions: &["odin"],
},
LanguageSetting {
type_: LanguageType::Php,
ids: &["php"],
Expand Down Expand Up @@ -251,6 +258,7 @@ impl LanguageSetting {
LanguageType::Javascript => Some(tree_sitter_javascript::LANGUAGE.into()),
LanguageType::Latex => Some(codebook_tree_sitter_latex::LANGUAGE.into()),
LanguageType::Lua => Some(tree_sitter_lua::LANGUAGE.into()),
LanguageType::Odin => Some(tree_sitter_odin_codebook::LANGUAGE.into()),
LanguageType::Php => Some(tree_sitter_php::LANGUAGE_PHP.into()),
LanguageType::Python => Some(tree_sitter_python::LANGUAGE.into()),
LanguageType::R => Some(tree_sitter_r::LANGUAGE.into()),
Expand Down
44 changes: 44 additions & 0 deletions crates/codebook/src/queries/odin.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
; Comments
(comment) @comment
(block_comment) @comment

; Procedure declarations (including parameter names)
(procedure_declaration
(expression) @identifier)
(overloaded_procedure_declaration
(expression) @identifier)
(parameter
(identifier) @identifier)
(default_parameter
(identifier) @identifier)

; Variables and constants identifiers (declaration-only)
(var_declaration
(expression) @identifier ":")
(assignment_statement
(expression) @identifier ":=")
(const_declaration
(expression)+ @identifier)
(const_type_declaration
(expression)+ @identifier)

; Struct, enum, union, bit_fields names
(struct_declaration
(expression) @identifier)
(enum_declaration
(expression) @identifier)
(union_declaration
(expression) @identifier)
(bit_field_declaration
(expression) @identifier "::")

; Fields and enum variant names
(field
(identifier) @identifier)
(bit_field_member
name: (identifier) @identifier)
(enum_member
name: (identifier) @identifier)

; Strings
(string_content) @string
98 changes: 98 additions & 0 deletions crates/codebook/tests/examples/example.odin
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package main

import "core:fmt"

// Test program for the Codebook spell-checking tool.
// The goal is to spellcheck comments, strings,
// identifiers during declarations, but not during usage

// Commennt
/*
Block cooment
/*
Netsed block
*/
*/

my_proecdure :: proc(my_prameter: int, another_paramter: f64) {
fmt.println(cast(f64)my_prameter + another_paramter)
}

another_porocedure :: proc(my_prameter: f64, another_paramter: int) {
fmt.println(my_prameter + cast(f64)another_paramter)
}

overloded_procedure:: proc{my_proecdure, another_porocedure}

with_deafult :: proc(my_prameter:= 42) {
fmt.println(my_prameter)
}

with_varidic :: proc(numberes: ..int) {
fmt.println(numberes)
}

MY_CONSATANT : int : 123
ANOTHER_COONSTANT :: 456

main :: proc() {
declaring_without_assignement: int
declaring_anotther, and_annother: int
with_assignement := 42
assignement_with_explicit_type : int = 33
and_another_one, and_more := "Helloep", "Wordl"
fmt.println(
MY_CONSATANT,
ANOTHER_COONSTANT,
declaring_without_assignement,
declaring_anotther,
with_assignement,
assignement_with_explicit_type,
and_another_one,
and_more,
)

MyAwseomeStruct :: struct {
my_field: f32,
another_field: f32,
}
foo := MyAwseomeStruct{1, 2}
fmt.println(foo.my_field, foo.another_field)

CompacotStruct :: struct {
aples, banananas, ornages: int
}
bar := CompacotStruct{3, 4, 5}
fmt.println(bar.aples, bar.banananas, bar.ornages)

TWOOF :: 2
MyCratfyEnum :: enum {
Aapple,
Baanana = 2,
Oranege = TWOOF,
}
buzz := MyCratfyEnum.Baanana
fmt.println(buzz)

MyUnberakableUnion :: union {int, bool}

MyFruttyInstruction :: bit_field u64 {
verison: u8 | 3,
ttl: u8 | 8,
fruit: MyCratfyEnum | TWOOF,
opration: u8 | 3,
left_opernd: u16 | 16,
right_oprand: u16 | 16,
destination: u16 | 16,
}
i := MyFruttyInstruction{}
i.fruit = .Baanana
fmt.println(i.left_opernd, i.right_oprand)

fmt.println("Helolo, Wlorld!")

overloded_procedure(33, 3.3)
overloded_procedure(4, 44.4)
with_deafult(42)
with_varidic(1, 2, 3)
}
Loading