Skip to content

Commit 72a2d5e

Browse files
authored
fix: format imports (lapce#1431)
* fix: add nightly options * style: format/sort imports
1 parent 7b61e48 commit 72a2d5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+390
-414
lines changed

.rustfmt.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
max_width = 85
2+
# below requires nightly
3+
# imports_granularity = "Crate"
4+
# group_imports = "StdExternalCrate"

lapce-core/src/buffer/test.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use super::Buffer;
22

33
mod editing {
4+
use xi_rope::Rope;
5+
46
use super::*;
57
use crate::{editor::EditType, selection::Selection};
6-
use xi_rope::Rope;
78

89
#[test]
910
fn is_pristine() {

lapce-core/src/cursor.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
use serde::{Deserialize, Serialize};
22
use xi_rope::{RopeDelta, Transformer};
33

4-
use crate::buffer::Buffer;
5-
use crate::mode::{Mode, MotionMode, VisualMode};
6-
use crate::register::RegisterData;
7-
use crate::selection::{InsertDrift, SelRegion, Selection};
4+
use crate::{
5+
buffer::Buffer,
6+
mode::{Mode, MotionMode, VisualMode},
7+
register::RegisterData,
8+
selection::{InsertDrift, SelRegion, Selection},
9+
};
810

911
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
1012
pub enum ColPosition {

lapce-core/src/editor.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1384,10 +1384,12 @@ enum DuplicateDirection {
13841384

13851385
#[cfg(test)]
13861386
mod test {
1387-
use crate::buffer::Buffer;
1388-
use crate::cursor::{Cursor, CursorMode};
1389-
use crate::editor::{DuplicateDirection, Editor};
1390-
use crate::selection::{SelRegion, Selection};
1387+
use crate::{
1388+
buffer::Buffer,
1389+
cursor::{Cursor, CursorMode},
1390+
editor::{DuplicateDirection, Editor},
1391+
selection::{SelRegion, Selection},
1392+
};
13911393

13921394
#[test]
13931395
fn test_insert_simple() {

lapce-core/src/language.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -915,9 +915,10 @@ mod test {
915915
// function(s) in the module become unused. Hence turning off the lints.
916916
#![allow(unused, unreachable_code)]
917917

918-
use super::LapceLanguage;
919918
use std::path::PathBuf;
920919

920+
use super::LapceLanguage;
921+
921922
fn assert_language(expected: LapceLanguage, exts: &[&str]) {
922923
for ext in exts {
923924
let path = PathBuf::from(&format!("a.{ext}"));

lapce-core/src/selection.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use serde::{Deserialize, Serialize};
21
use std::cmp::{max, min, Ordering};
2+
3+
use serde::{Deserialize, Serialize};
34
use xi_rope::{RopeDelta, Transformer};
45

56
use crate::cursor::ColPosition;
@@ -534,9 +535,11 @@ fn remove_n_at<T>(v: &mut Vec<T>, index: usize, n: usize) {
534535

535536
#[cfg(test)]
536537
mod test {
537-
use crate::buffer::Buffer;
538-
use crate::editor::EditType;
539-
use crate::selection::{InsertDrift, SelRegion, Selection};
538+
use crate::{
539+
buffer::Buffer,
540+
editor::EditType,
541+
selection::{InsertDrift, SelRegion, Selection},
542+
};
540543

541544
#[test]
542545
fn should_return_selection_region_min() {

lapce-core/src/style.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::str;
22

33
use lapce_rpc::style::{LineStyle, Style};
4-
54
use xi_rope::{spans::Spans, LinesMetric, Rope};
65

76
pub const SCOPES: &[&str] = &[

lapce-core/src/syntax/highlight.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ use tree_sitter::{
2020
};
2121
use xi_rope::Rope;
2222

23-
use crate::{language::LapceLanguage, style::SCOPES};
24-
2523
use super::{util::RopeProvider, PARSER};
24+
use crate::{language::LapceLanguage, style::SCOPES};
2625

2726
macro_rules! declare_language_highlights {
2827
($($name:ident: $feature_name:expr),* $(,)?) => {

lapce-core/src/syntax/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ use xi_rope::{
2424
Interval, Rope, RopeDelta,
2525
};
2626

27-
use crate::{
28-
language::LapceLanguage,
29-
lens::{Lens, LensBuilder},
30-
style::SCOPES,
31-
};
32-
3327
use self::{
3428
edit::generate_edits,
3529
highlight::{
@@ -39,6 +33,11 @@ use self::{
3933
},
4034
util::{matching_char, RopeProvider},
4135
};
36+
use crate::{
37+
language::LapceLanguage,
38+
lens::{Lens, LensBuilder},
39+
style::SCOPES,
40+
};
4241

4342
mod edit;
4443
pub mod highlight;

lapce-core/src/word.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,7 @@ fn classify_boundary(
420420
prev: CharClassification,
421421
next: CharClassification,
422422
) -> WordBoundary {
423-
use self::CharClassification::*;
424-
use self::WordBoundary::*;
423+
use self::{CharClassification::*, WordBoundary::*};
425424
match (prev, next) {
426425
(Lf, Lf) => Start,
427426
(Lf, Space) => Interior,
@@ -442,9 +441,10 @@ fn classify_boundary(
442441

443442
#[cfg(test)]
444443
mod test {
445-
use super::WordCursor;
446444
use xi_rope::Rope;
447445

446+
use super::WordCursor;
447+
448448
#[test]
449449
fn prev_boundary_should_be_none_at_position_zero() {
450450
let rope = Rope::from("Hello world");

lapce-data/src/command.rs

+23-16
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@ use druid::{
55
EventCtx, FileInfo, Point, Rect, Selector, SingleUse, Size, WidgetId, WindowId,
66
};
77
use indexmap::IndexMap;
8-
use lapce_core::buffer::DiffLines;
9-
use lapce_core::command::{
10-
EditCommand, FocusCommand, MotionModeCommand, MoveCommand, MultiSelectionCommand,
8+
use lapce_core::{
9+
buffer::DiffLines,
10+
command::{
11+
EditCommand, FocusCommand, MotionModeCommand, MoveCommand,
12+
MultiSelectionCommand,
13+
},
14+
syntax::Syntax,
1115
};
12-
use lapce_core::syntax::Syntax;
13-
use lapce_rpc::plugin::{PluginId, VoltInfo, VoltMetadata};
1416
use lapce_rpc::{
15-
buffer::BufferId, file::FileNodeItem, source_control::DiffInfo, style::Style,
17+
buffer::BufferId,
18+
file::FileNodeItem,
19+
plugin::{PluginId, VoltInfo, VoltMetadata},
20+
source_control::DiffInfo,
21+
style::Style,
1622
terminal::TermId,
1723
};
1824
use lsp_types::{
@@ -25,22 +31,23 @@ use strum::{self, EnumMessage, IntoEnumIterator};
2531
use strum_macros::{Display, EnumIter, EnumMessage, EnumString, IntoStaticStr};
2632
use xi_rope::{spans::Spans, Rope};
2733

28-
use crate::alert::AlertContentData;
29-
use crate::data::{LapceMainSplitData, LapceTabData, LapceWorkspace};
30-
use crate::document::BufferContent;
31-
use crate::editor::{EditorPosition, Line, LineCol};
32-
use crate::menu::MenuKind;
33-
use crate::rich_text::RichText;
34-
use crate::selection_range::SelectionRangeDirection;
35-
use crate::update::ReleaseInfo;
3634
use crate::{
37-
data::{EditorTabChild, SplitContent},
38-
editor::EditorLocation,
35+
alert::AlertContentData,
36+
data::{
37+
EditorTabChild, LapceMainSplitData, LapceTabData, LapceWorkspace,
38+
SplitContent,
39+
},
40+
document::BufferContent,
41+
editor::{EditorLocation, EditorPosition, Line, LineCol},
3942
keypress::{KeyMap, KeyPress},
43+
menu::MenuKind,
4044
palette::{PaletteItem, PaletteType},
4145
proxy::ProxyStatus,
46+
rich_text::RichText,
4247
search::Match,
48+
selection_range::SelectionRangeDirection,
4349
split::{SplitDirection, SplitMoveDirection},
50+
update::ReleaseInfo,
4451
};
4552

4653
pub const LAPCE_OPEN_FOLDER: Selector<FileInfo> = Selector::new("lapce.open-folder");

lapce-data/src/completion.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{fmt::Display, path::PathBuf, sync::Arc};
1+
use std::{fmt::Display, path::PathBuf, str::FromStr, sync::Arc};
22

33
use anyhow::Error;
44
use druid::{EventCtx, Size, WidgetId};
@@ -8,7 +8,6 @@ use lapce_core::command::FocusCommand;
88
use lapce_rpc::{buffer::BufferId, plugin::PluginId};
99
use lsp_types::{CompletionItem, CompletionResponse, Position};
1010
use regex::Regex;
11-
use std::str::FromStr;
1211

1312
use crate::{config::LapceConfig, list::ListData, proxy::LapceProxy};
1413

lapce-data/src/config.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::{
2+
collections::HashMap,
23
io::Write,
34
path::{Path, PathBuf},
45
sync::Arc,
@@ -9,11 +10,11 @@ use druid::{
910
Color, ExtEventSink, FontFamily, Size, Target,
1011
};
1112
use indexmap::IndexMap;
13+
pub use lapce_proxy::APPLICATION_NAME;
1214
use lapce_proxy::{directory::Directory, plugin::wasi::find_all_volts};
1315
use once_cell::sync::Lazy;
1416
use parking_lot::{Mutex, RwLock};
1517
use serde::{Deserialize, Serialize};
16-
use std::collections::HashMap;
1718
use structdesc::FieldNames;
1819
use thiserror::Error;
1920
use toml_edit::easy as toml;
@@ -23,8 +24,6 @@ use crate::{
2324
data::{LapceWorkspace, LapceWorkspaceType},
2425
};
2526

26-
pub use lapce_proxy::APPLICATION_NAME;
27-
2827
pub const LOGO: &str = include_str!("../../extra/images/logo.svg");
2928
const DEFAULT_SETTINGS: &str = include_str!("../../defaults/settings.toml");
3029
const DEFAULT_LIGHT_THEME: &str = include_str!("../../defaults/light-theme.toml");

lapce-data/src/data.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#[cfg(target_os = "windows")]
2+
use std::env;
13
use std::{
24
cell::RefCell,
35
cmp::Ordering,
@@ -10,16 +12,12 @@ use std::{
1012
time::Instant,
1113
};
1214

13-
#[cfg(target_os = "windows")]
14-
use std::env;
15-
1615
use anyhow::{anyhow, Result};
1716
use crossbeam_channel::{unbounded, Receiver, Sender};
1817
use druid::{
1918
piet::PietText, theme, Command, Data, Env, EventCtx, ExtEventSink,
2019
FileDialogOptions, Lens, Point, Rect, Size, Target, Vec2, WidgetId, WindowId,
2120
};
22-
2321
use itertools::Itertools;
2422
use lapce_core::{
2523
command::{FocusCommand, MultiSelectionCommand},
@@ -40,7 +38,6 @@ use lapce_rpc::{
4038
terminal::TermId,
4139
RpcMessage,
4240
};
43-
4441
use lsp_types::{Diagnostic, DiagnosticSeverity, Position, ProgressToken, TextEdit};
4542
use notify::Watcher;
4643
use serde::{Deserialize, Serialize};

lapce-data/src/db.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use std::{
99
use anyhow::{anyhow, Result};
1010
use crossbeam_channel::{unbounded, Sender};
1111
use druid::{ExtEventSink, Point, Rect, Size, Vec2, WidgetId};
12-
1312
use lapce_proxy::directory::Directory;
1413
use serde::{Deserialize, Serialize};
1514
use xi_rope::Rope;

lapce-data/src/document.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use xi_rope::{
4444
Interval, Rope, RopeDelta, Transformer,
4545
};
4646

47-
use crate::selection_range::SelectionRangeDirection;
4847
use crate::{
4948
command::{InitBufferContentCb, LapceUICommand, LAPCE_UI_COMMAND},
5049
config::{LapceConfig, LapceTheme},
@@ -53,7 +52,7 @@ use crate::{
5352
find::{Find, FindProgress},
5453
history::DocumentHistory,
5554
proxy::LapceProxy,
56-
selection_range::SyntaxSelectionRanges,
55+
selection_range::{SelectionRangeDirection, SyntaxSelectionRanges},
5756
settings::SettingsValueKind,
5857
};
5958

0 commit comments

Comments
 (0)