diff --git a/lsp/src/vfs.rs b/lsp/src/vfs.rs index c533954..af7aba9 100644 --- a/lsp/src/vfs.rs +++ b/lsp/src/vfs.rs @@ -2,7 +2,9 @@ use indexmap::IndexMap; use lsp_types::Url; use nil::{Change, FileId, FilePos}; use std::collections::HashMap; -use std::{fmt, mem, path::PathBuf, sync::Arc}; +use std::path::PathBuf; +use std::sync::Arc; +use std::{fmt, mem}; use text_size::TextSize; #[derive(Debug, Clone, PartialEq, Eq, Hash)] diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..c1578aa --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +imports_granularity = "Module" diff --git a/src/base.rs b/src/base.rs index 21c0db2..6d13727 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,6 +1,7 @@ use rowan::{TextRange, TextSize}; use salsa::Durability; -use std::{fmt, sync::Arc}; +use std::fmt; +use std::sync::Arc; use syntax::Parse; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] diff --git a/src/def/lower.rs b/src/def/lower.rs index 3d939ff..d178762 100644 --- a/src/def/lower.rs +++ b/src/def/lower.rs @@ -9,10 +9,8 @@ use rowan::ast::AstNode; use rowan::TextRange; use smol_str::SmolStr; use std::str; -use syntax::{ - ast::{self, HasBindings, HasStringParts, LiteralKind}, - Parse, -}; +use syntax::ast::{self, HasBindings, HasStringParts, LiteralKind}; +use syntax::Parse; pub(super) fn lower(parse: InFile) -> (Module, ModuleSourceMap) { let diagnostics = parse diff --git a/src/def/mod.rs b/src/def/mod.rs index 830dca0..0c71627 100644 --- a/src/def/mod.rs +++ b/src/def/mod.rs @@ -4,14 +4,14 @@ mod scope; #[cfg(test)] mod tests; -use crate::{ - base::SourceDatabase, - {Diagnostic, FileId}, -}; +use crate::base::SourceDatabase; +use crate::{Diagnostic, FileId}; use la_arena::{Arena, ArenaMap, Idx}; use ordered_float::OrderedFloat; use smol_str::SmolStr; -use std::{collections::HashMap, ops, sync::Arc}; +use std::collections::HashMap; +use std::ops; +use std::sync::Arc; pub use self::scope::{ModuleScopes, ResolveResult, ScopeData, ScopeId}; pub use syntax::ast::{BinaryOpKind as BinaryOp, UnaryOpKind as UnaryOp}; diff --git a/src/def/scope.rs b/src/def/scope.rs index b41f3e7..65e29b5 100644 --- a/src/def/scope.rs +++ b/src/def/scope.rs @@ -2,7 +2,9 @@ use super::{BindingKey, BindingValue, Bindings, DefDatabase, Expr, ExprId, Modul use crate::{builtin, FileId}; use la_arena::{Arena, ArenaMap, Idx}; use smol_str::SmolStr; -use std::{collections::HashMap, iter, ops, sync::Arc}; +use std::collections::HashMap; +use std::sync::Arc; +use std::{iter, ops}; #[derive(Default, Debug, Clone, PartialEq, Eq)] pub struct ModuleScopes { @@ -208,10 +210,8 @@ impl ScopeData { #[cfg(test)] mod tests { use super::ScopeKind; - use crate::{ - def::{AstPtr, DefDatabase, ResolveResult, SourceDatabase}, - tests::TestDB, - }; + use crate::def::{AstPtr, DefDatabase, ResolveResult, SourceDatabase}; + use crate::tests::TestDB; use expect_test::{expect, Expect}; use rowan::ast::AstNode; use syntax::{ast, match_ast}; diff --git a/src/ide/completion.rs b/src/ide/completion.rs index ceaaba3..8402b84 100644 --- a/src/ide/completion.rs +++ b/src/ide/completion.rs @@ -1,8 +1,5 @@ -use crate::{ - builtin, - def::{AstPtr, DefDatabase}, - FileId, -}; +use crate::def::{AstPtr, DefDatabase}; +use crate::{builtin, FileId}; use rowan::ast::AstNode; use smol_str::SmolStr; use syntax::{ast, match_ast, SyntaxKind, TextRange, TextSize, T}; diff --git a/src/ide/goto_definition.rs b/src/ide/goto_definition.rs index 14428e2..c9c4400 100644 --- a/src/ide/goto_definition.rs +++ b/src/ide/goto_definition.rs @@ -1,9 +1,8 @@ use super::NavigationTarget; -use crate::{ - def::{AstPtr, DefDatabase, ResolveResult}, - FileId, -}; -use rowan::{ast::AstNode, TextSize}; +use crate::def::{AstPtr, DefDatabase, ResolveResult}; +use crate::FileId; +use rowan::ast::AstNode; +use rowan::TextSize; use syntax::{ast, match_ast, SyntaxKind, T}; pub(crate) fn goto_definition( diff --git a/src/ide/mod.rs b/src/ide/mod.rs index 105cfeb..caf29ff 100644 --- a/src/ide/mod.rs +++ b/src/ide/mod.rs @@ -1,7 +1,9 @@ mod completion; mod goto_definition; -use crate::{base::SourceDatabaseStorage, def::DefDatabaseStorage, Change, FileId, FilePos}; +use crate::base::SourceDatabaseStorage; +use crate::def::DefDatabaseStorage; +use crate::{Change, FileId, FilePos}; use rowan::TextRange; use salsa::{Cancelled, Database, Durability, ParallelDatabase}; use std::fmt; diff --git a/src/tests.rs b/src/tests.rs index c8a5811..84c7bbd 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,7 +1,8 @@ use crate::base::{SourceDatabase, SourceDatabaseStorage}; use crate::def::DefDatabaseStorage; use crate::{Change, FileId}; -use rowan::{ast::AstNode, TextSize}; +use rowan::ast::AstNode; +use rowan::TextSize; use std::ops; use syntax::{NixLanguage, SyntaxNode}; diff --git a/syntax/src/ast.rs b/syntax/src/ast.rs index dc15fee..7538b0e 100644 --- a/syntax/src/ast.rs +++ b/syntax/src/ast.rs @@ -1,13 +1,7 @@ -use super::{ - NixLanguage, - SyntaxKind::{self, *}, - SyntaxNode, SyntaxToken, -}; -use crate::SyntaxElementChildren; -use rowan::ast::{ - support::{child, children, token}, - AstChildren, AstNode, -}; +use crate::SyntaxKind::{self, *}; +use crate::{NixLanguage, SyntaxElementChildren, SyntaxNode, SyntaxToken}; +use rowan::ast::support::{child, children, token}; +use rowan::ast::{AstChildren, AstNode}; use rowan::NodeOrToken; #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/syntax/src/lexer.rs b/syntax/src/lexer.rs index 9e4138f..7313647 100644 --- a/syntax/src/lexer.rs +++ b/syntax/src/lexer.rs @@ -1,10 +1,8 @@ use crate::SyntaxKind::{self, *}; use once_cell::sync::Lazy; -use regex_automata::{ - dfa::{dense, Automaton}, - nfa::thompson, - SyntaxConfig, -}; +use regex_automata::dfa::{dense, Automaton}; +use regex_automata::nfa::thompson; +use regex_automata::SyntaxConfig; use rowan::{TextRange, TextSize}; use std::ptr; diff --git a/syntax/src/lib.rs b/syntax/src/lib.rs index c0e5940..21a1ce3 100644 --- a/syntax/src/lib.rs +++ b/syntax/src/lib.rs @@ -10,8 +10,7 @@ mod tests; use core::fmt; -pub use rowan; -pub use rowan::{TextRange, TextSize}; +pub use rowan::{self, TextRange, TextSize}; pub use self::kind::SyntaxKind; pub use self::parser::{parse_file, Parse}; diff --git a/syntax/src/parser.rs b/syntax/src/parser.rs index 7df2652..0fc2c96 100644 --- a/syntax/src/parser.rs +++ b/syntax/src/parser.rs @@ -1,10 +1,8 @@ -use crate::{ - ast::SourceFile, - lexer, Error, - SyntaxKind::{self, *}, - SyntaxNode, -}; -use rowan::{ast::AstNode, Checkpoint, GreenNode, GreenNodeBuilder, TextSize}; +use crate::ast::SourceFile; +use crate::SyntaxKind::{self, *}; +use crate::{lexer, Error, SyntaxNode}; +use rowan::ast::AstNode; +use rowan::{Checkpoint, GreenNode, GreenNodeBuilder, TextSize}; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Parse {