on master help sign in
clippy lints
a16c6e2Blaž Hrastnik
helix-core/src/state.rs+2−2
@@ -274,13 +274,13 @@ fn is_word(ch: char) -> bool {
274#[derive(Debug, Eq, PartialEq)]
274#[derive(Debug, Eq, PartialEq)]
275enum Category {
275enum Category {
276 Whitespace,
276 Whitespace,
277− EOL,
277+ Eol,
278 Word,
278 Word,
279 Punctuation,
279 Punctuation,
280}
280}
281fn categorize(ch: char) -> Category {
281fn categorize(ch: char) -> Category {
282 if ch == '\n' {
282 if ch == '\n' {
283− Category::EOL
283+ Category::Eol
284 } else if ch.is_ascii_whitespace() {
284 } else if ch.is_ascii_whitespace() {
285 Category::Whitespace
285 Category::Whitespace
286 } else if ch.is_ascii_punctuation() {
286 } else if ch.is_ascii_punctuation() {
helix-core/src/syntax.rs+7−7
@@ -1,5 +1,5 @@
1use crate::{Change, Rope, RopeSlice, Transaction};
1use crate::{Change, Rope, RopeSlice, Transaction};
2−pub use helix_syntax::LANG;
2+pub use helix_syntax::Lang;
3pub use helix_syntax::{get_language, get_language_name};
3pub use helix_syntax::{get_language, get_language_name};
4
4
5use std::collections::HashMap;
5use std::collections::HashMap;
@@ -21,7 +21,7 @@ pub struct LanguageConfiguration {
21 //
21 //
22 // root_path
22 // root_path
23 //
23 //
24− pub(crate) language_id: LANG,
24+ pub(crate) language_id: Lang,
25 pub(crate) highlight_config: OnceCell<Option<Arc<HighlightConfiguration>>>,
25 pub(crate) highlight_config: OnceCell<Option<Arc<HighlightConfiguration>>>,
26 // tags_config OnceCell<> https://github.com/tree-sitter/tree-sitter/pull/583
26 // tags_config OnceCell<> https://github.com/tree-sitter/tree-sitter/pull/583
27}
27}
@@ -87,7 +87,7 @@ impl Loader {
87 LanguageConfiguration {
87 LanguageConfiguration {
88 scope: "source.rust".to_string(),
88 scope: "source.rust".to_string(),
89 file_types: vec!["rs".to_string()],
89 file_types: vec!["rs".to_string()],
90− language_id: LANG::Rust,
90+ language_id: Lang::Rust,
91 highlight_config: OnceCell::new(),
91 highlight_config: OnceCell::new(),
92 //
92 //
93 path: "../helix-syntax/languages/tree-sitter-rust".into(),
93 path: "../helix-syntax/languages/tree-sitter-rust".into(),
@@ -95,7 +95,7 @@ impl Loader {
95 LanguageConfiguration {
95 LanguageConfiguration {
96 scope: "source.toml".to_string(),
96 scope: "source.toml".to_string(),
97 file_types: vec!["toml".to_string()],
97 file_types: vec!["toml".to_string()],
98− language_id: LANG::Toml,
98+ language_id: Lang::Toml,
99 highlight_config: OnceCell::new(),
99 highlight_config: OnceCell::new(),
100 //
100 //
101 path: "../helix-syntax/languages/tree-sitter-toml".into(),
101 path: "../helix-syntax/languages/tree-sitter-toml".into(),
@@ -160,7 +160,7 @@ pub struct Syntax {
160impl Syntax {
160impl Syntax {
161 // buffer, grammar, config, grammars, sync_timeout?
161 // buffer, grammar, config, grammars, sync_timeout?
162 pub fn new(
162 pub fn new(
163− /*language: LANG,*/ source: &Rope,
163+ /*language: Lang,*/ source: &Rope,
164 config: Arc<HighlightConfiguration>,
164 config: Arc<HighlightConfiguration>,
165 ) -> Self {
165 ) -> Self {
166 // fetch grammar for parser based on language string
166 // fetch grammar for parser based on language string
@@ -779,10 +779,10 @@ impl HighlightConfiguration {
779 non_local_variable_patterns,
779 non_local_variable_patterns,
780 injection_content_capture_index,
780 injection_content_capture_index,
781 injection_language_capture_index,
781 injection_language_capture_index,
782+ local_scope_capture_index,
782 local_def_capture_index,
783 local_def_capture_index,
783 local_def_value_capture_index,
784 local_def_value_capture_index,
784 local_ref_capture_index,
785 local_ref_capture_index,
785− local_scope_capture_index,
786 })
786 })
787 }
787 }
788
788
@@ -1475,7 +1475,7 @@ fn test_parser() {
1475 .map(String::from)
1475 .map(String::from)
1476 .collect();
1476 .collect();
1477
1477
1478− let language = get_language(LANG::Rust);
1478+ let language = get_language(Lang::Rust);
1479 let mut config = HighlightConfiguration::new(
1479 let mut config = HighlightConfiguration::new(
1480 language,
1480 language,
1481 &std::fs::read_to_string(
1481 &std::fs::read_to_string(
helix-syntax/build.rs+21−25
@@ -13,13 +13,11 @@ fn get_debug() -> bool {
13
13
14fn collect_tree_sitter_dirs(ignore: Vec<String>) -> Vec<String> {
14fn collect_tree_sitter_dirs(ignore: Vec<String>) -> Vec<String> {
15 let mut dirs = Vec::new();
15 let mut dirs = Vec::new();
16− for entry in fs::read_dir("languages").unwrap() {
16+ for entry in fs::read_dir("languages").unwrap().flatten() {
17− if let Ok(entry) = entry {
18− let path = entry.path();
17+ let path = entry.path();
19− let dir = path.file_name().unwrap().to_str().unwrap().to_string();
18+ let dir = path.file_name().unwrap().to_str().unwrap().to_string();
20− if !ignore.contains(&dir) {
19+ if !ignore.contains(&dir) {
21− dirs.push(dir);
20+ dirs.push(dir);
22− }
23 }
21 }
24 }
22 }
25 dirs
23 dirs
@@ -31,24 +29,22 @@ fn collect_src_files(dir: &str) -> (Vec<String>, Vec<String>) {
31 let mut c_files = Vec::new();
29 let mut c_files = Vec::new();
32 let mut cpp_files = Vec::new();
30 let mut cpp_files = Vec::new();
33 let path = PathBuf::from("languages").join(&dir).join("src");
31 let path = PathBuf::from("languages").join(&dir).join("src");
34− for entry in fs::read_dir(path).unwrap() {
32+ for entry in fs::read_dir(path).unwrap().flatten() {
35− if let Ok(entry) = entry {
36− let path = entry.path();
33+ let path = entry.path();
37− if path
34+ if path
38− .file_stem()
35+ .file_stem()
39− .unwrap()
36+ .unwrap()
40− .to_str()
37+ .to_str()
41− .unwrap()
38+ .unwrap()
42− .starts_with("binding")
39+ .starts_with("binding")
43− {
40+ {
44− continue;
41+ continue;
45− }
42+ }
46− if let Some(ext) = path.extension() {
43+ if let Some(ext) = path.extension() {
47− if ext == "c" {
44+ if ext == "c" {
48− c_files.push(path.to_str().unwrap().to_string());
45+ c_files.push(path.to_str().unwrap().to_string());
49− } else if ext == "cc" || ext == "cpp" || ext == "cxx" {
46+ } else if ext == "cc" || ext == "cpp" || ext == "cxx" {
50− cpp_files.push(path.to_str().unwrap().to_string());
47+ cpp_files.push(path.to_str().unwrap().to_string());
51− }
52 }
48 }
53 }
49 }
54 }
50 }
helix-syntax/src/lib.rs+5−5
@@ -13,7 +13,7 @@ macro_rules! mk_extern {
13macro_rules! mk_enum {
13macro_rules! mk_enum {
14 ( $( $camel:ident ),* ) => {
14 ( $( $camel:ident ),* ) => {
15 #[derive(Clone, Copy, Debug, PartialEq)]
15 #[derive(Clone, Copy, Debug, PartialEq)]
16− pub enum LANG {
16+ pub enum Lang {
17 $(
17 $(
18 $camel,
18 $camel,
19 )*
19 )*
@@ -25,11 +25,11 @@ macro_rules! mk_enum {
25macro_rules! mk_get_language {
25macro_rules! mk_get_language {
26 ( $( ($camel:ident, $name:ident) ),* ) => {
26 ( $( ($camel:ident, $name:ident) ),* ) => {
27 #[must_use]
27 #[must_use]
28− pub fn get_language(lang: LANG) -> Language {
28+ pub fn get_language(lang: Lang) -> Language {
29 unsafe {
29 unsafe {
30 match lang {
30 match lang {
31 $(
31 $(
32− LANG::$camel => $name(),
32+ Lang::$camel => $name(),
33 )*
33 )*
34 }
34 }
35 }
35 }
@@ -41,10 +41,10 @@ macro_rules! mk_get_language {
41macro_rules! mk_get_language_name {
41macro_rules! mk_get_language_name {
42 ( $( $camel:ident ),* ) => {
42 ( $( $camel:ident ),* ) => {
43 #[must_use]
43 #[must_use]
44− pub const fn get_language_name(lang: LANG) -> &'static str {
44+ pub const fn get_language_name(lang: Lang) -> &'static str {
45 match lang {
45 match lang {
46 $(
46 $(
47− LANG::$camel => stringify!($camel),
47+ Lang::$camel => stringify!($camel),
48 )*
48 )*
49 }
49 }
50 }
50 }