diff --git a/.rustfmt.toml b/.rustfmt.toml index 3c676082..06900d0d 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1 +1,4 @@ max_width = 85 +# below requires nightly +# imports_granularity = "Crate" +# group_imports = "StdExternalCrate" diff --git a/lapce-core/src/buffer/test.rs b/lapce-core/src/buffer/test.rs index 122d9d15..a736e6d9 100644 --- a/lapce-core/src/buffer/test.rs +++ b/lapce-core/src/buffer/test.rs @@ -1,9 +1,10 @@ use super::Buffer; mod editing { + use xi_rope::Rope; + use super::*; use crate::{editor::EditType, selection::Selection}; - use xi_rope::Rope; #[test] fn is_pristine() { diff --git a/lapce-core/src/cursor.rs b/lapce-core/src/cursor.rs index da740322..e20ebba9 100644 --- a/lapce-core/src/cursor.rs +++ b/lapce-core/src/cursor.rs @@ -1,10 +1,12 @@ use serde::{Deserialize, Serialize}; use xi_rope::{RopeDelta, Transformer}; -use crate::buffer::Buffer; -use crate::mode::{Mode, MotionMode, VisualMode}; -use crate::register::RegisterData; -use crate::selection::{InsertDrift, SelRegion, Selection}; +use crate::{ + buffer::Buffer, + mode::{Mode, MotionMode, VisualMode}, + register::RegisterData, + selection::{InsertDrift, SelRegion, Selection}, +}; #[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)] pub enum ColPosition { diff --git a/lapce-core/src/editor.rs b/lapce-core/src/editor.rs index e6985ff0..3692b76e 100644 --- a/lapce-core/src/editor.rs +++ b/lapce-core/src/editor.rs @@ -1384,10 +1384,12 @@ enum DuplicateDirection { #[cfg(test)] mod test { - use crate::buffer::Buffer; - use crate::cursor::{Cursor, CursorMode}; - use crate::editor::{DuplicateDirection, Editor}; - use crate::selection::{SelRegion, Selection}; + use crate::{ + buffer::Buffer, + cursor::{Cursor, CursorMode}, + editor::{DuplicateDirection, Editor}, + selection::{SelRegion, Selection}, + }; #[test] fn test_insert_simple() { diff --git a/lapce-core/src/language.rs b/lapce-core/src/language.rs index 0854ed54..0bc0da37 100644 --- a/lapce-core/src/language.rs +++ b/lapce-core/src/language.rs @@ -915,9 +915,10 @@ mod test { // function(s) in the module become unused. Hence turning off the lints. #![allow(unused, unreachable_code)] - use super::LapceLanguage; use std::path::PathBuf; + use super::LapceLanguage; + fn assert_language(expected: LapceLanguage, exts: &[&str]) { for ext in exts { let path = PathBuf::from(&format!("a.{ext}")); diff --git a/lapce-core/src/selection.rs b/lapce-core/src/selection.rs index b38a8211..ca5b805e 100644 --- a/lapce-core/src/selection.rs +++ b/lapce-core/src/selection.rs @@ -1,5 +1,6 @@ -use serde::{Deserialize, Serialize}; use std::cmp::{max, min, Ordering}; + +use serde::{Deserialize, Serialize}; use xi_rope::{RopeDelta, Transformer}; use crate::cursor::ColPosition; @@ -534,9 +535,11 @@ fn remove_n_at(v: &mut Vec, index: usize, n: usize) { #[cfg(test)] mod test { - use crate::buffer::Buffer; - use crate::editor::EditType; - use crate::selection::{InsertDrift, SelRegion, Selection}; + use crate::{ + buffer::Buffer, + editor::EditType, + selection::{InsertDrift, SelRegion, Selection}, + }; #[test] fn should_return_selection_region_min() { diff --git a/lapce-core/src/style.rs b/lapce-core/src/style.rs index 406801d3..75279d22 100644 --- a/lapce-core/src/style.rs +++ b/lapce-core/src/style.rs @@ -1,7 +1,6 @@ use std::str; use lapce_rpc::style::{LineStyle, Style}; - use xi_rope::{spans::Spans, LinesMetric, Rope}; pub const SCOPES: &[&str] = &[ diff --git a/lapce-core/src/syntax/highlight.rs b/lapce-core/src/syntax/highlight.rs index 4af758ff..feecc916 100644 --- a/lapce-core/src/syntax/highlight.rs +++ b/lapce-core/src/syntax/highlight.rs @@ -20,9 +20,8 @@ }; use xi_rope::Rope; -use crate::{language::LapceLanguage, style::SCOPES}; - use super::{util::RopeProvider, PARSER}; +use crate::{language::LapceLanguage, style::SCOPES}; macro_rules! declare_language_highlights { ($($name:ident: $feature_name:expr),* $(,)?) => { diff --git a/lapce-core/src/syntax/mod.rs b/lapce-core/src/syntax/mod.rs index 1b87c6f0..fad0edd8 100644 --- a/lapce-core/src/syntax/mod.rs +++ b/lapce-core/src/syntax/mod.rs @@ -24,12 +24,6 @@ Interval, Rope, RopeDelta, }; -use crate::{ - language::LapceLanguage, - lens::{Lens, LensBuilder}, - style::SCOPES, -}; - use self::{ edit::generate_edits, highlight::{ @@ -39,6 +33,11 @@ }, util::{matching_char, RopeProvider}, }; +use crate::{ + language::LapceLanguage, + lens::{Lens, LensBuilder}, + style::SCOPES, +}; mod edit; pub mod highlight; diff --git a/lapce-core/src/word.rs b/lapce-core/src/word.rs index d0615196..c2934943 100644 --- a/lapce-core/src/word.rs +++ b/lapce-core/src/word.rs @@ -420,8 +420,7 @@ fn classify_boundary( prev: CharClassification, next: CharClassification, ) -> WordBoundary { - use self::CharClassification::*; - use self::WordBoundary::*; + use self::{CharClassification::*, WordBoundary::*}; match (prev, next) { (Lf, Lf) => Start, (Lf, Space) => Interior, @@ -442,9 +441,10 @@ fn classify_boundary( #[cfg(test)] mod test { - use super::WordCursor; use xi_rope::Rope; + use super::WordCursor; + #[test] fn prev_boundary_should_be_none_at_position_zero() { let rope = Rope::from("Hello world"); diff --git a/lapce-data/src/command.rs b/lapce-data/src/command.rs index 2db8003d..12214ae3 100644 --- a/lapce-data/src/command.rs +++ b/lapce-data/src/command.rs @@ -5,14 +5,20 @@ EventCtx, FileInfo, Point, Rect, Selector, SingleUse, Size, WidgetId, WindowId, }; use indexmap::IndexMap; -use lapce_core::buffer::DiffLines; -use lapce_core::command::{ - EditCommand, FocusCommand, MotionModeCommand, MoveCommand, MultiSelectionCommand, +use lapce_core::{ + buffer::DiffLines, + command::{ + EditCommand, FocusCommand, MotionModeCommand, MoveCommand, + MultiSelectionCommand, + }, + syntax::Syntax, }; -use lapce_core::syntax::Syntax; -use lapce_rpc::plugin::{PluginId, VoltInfo, VoltMetadata}; use lapce_rpc::{ - buffer::BufferId, file::FileNodeItem, source_control::DiffInfo, style::Style, + buffer::BufferId, + file::FileNodeItem, + plugin::{PluginId, VoltInfo, VoltMetadata}, + source_control::DiffInfo, + style::Style, terminal::TermId, }; use lsp_types::{ @@ -25,22 +31,23 @@ use strum_macros::{Display, EnumIter, EnumMessage, EnumString, IntoStaticStr}; use xi_rope::{spans::Spans, Rope}; -use crate::alert::AlertContentData; -use crate::data::{LapceMainSplitData, LapceTabData, LapceWorkspace}; -use crate::document::BufferContent; -use crate::editor::{EditorPosition, Line, LineCol}; -use crate::menu::MenuKind; -use crate::rich_text::RichText; -use crate::selection_range::SelectionRangeDirection; -use crate::update::ReleaseInfo; use crate::{ - data::{EditorTabChild, SplitContent}, - editor::EditorLocation, + alert::AlertContentData, + data::{ + EditorTabChild, LapceMainSplitData, LapceTabData, LapceWorkspace, + SplitContent, + }, + document::BufferContent, + editor::{EditorLocation, EditorPosition, Line, LineCol}, keypress::{KeyMap, KeyPress}, + menu::MenuKind, palette::{PaletteItem, PaletteType}, proxy::ProxyStatus, + rich_text::RichText, search::Match, + selection_range::SelectionRangeDirection, split::{SplitDirection, SplitMoveDirection}, + update::ReleaseInfo, }; pub const LAPCE_OPEN_FOLDER: Selector = Selector::new("lapce.open-folder"); diff --git a/lapce-data/src/completion.rs b/lapce-data/src/completion.rs index c050f3df..56d6e88c 100644 --- a/lapce-data/src/completion.rs +++ b/lapce-data/src/completion.rs @@ -1,4 +1,4 @@ -use std::{fmt::Display, path::PathBuf, sync::Arc}; +use std::{fmt::Display, path::PathBuf, str::FromStr, sync::Arc}; use anyhow::Error; use druid::{EventCtx, Size, WidgetId}; @@ -8,7 +8,6 @@ use lapce_rpc::{buffer::BufferId, plugin::PluginId}; use lsp_types::{CompletionItem, CompletionResponse, Position}; use regex::Regex; -use std::str::FromStr; use crate::{config::LapceConfig, list::ListData, proxy::LapceProxy}; diff --git a/lapce-data/src/config.rs b/lapce-data/src/config.rs index 82d579f6..8eb5ded9 100644 --- a/lapce-data/src/config.rs +++ b/lapce-data/src/config.rs @@ -1,4 +1,5 @@ use std::{ + collections::HashMap, io::Write, path::{Path, PathBuf}, sync::Arc, @@ -9,11 +10,11 @@ Color, ExtEventSink, FontFamily, Size, Target, }; use indexmap::IndexMap; +pub use lapce_proxy::APPLICATION_NAME; use lapce_proxy::{directory::Directory, plugin::wasi::find_all_volts}; use once_cell::sync::Lazy; use parking_lot::{Mutex, RwLock}; use serde::{Deserialize, Serialize}; -use std::collections::HashMap; use structdesc::FieldNames; use thiserror::Error; use toml_edit::easy as toml; @@ -23,8 +24,6 @@ data::{LapceWorkspace, LapceWorkspaceType}, }; -pub use lapce_proxy::APPLICATION_NAME; - pub const LOGO: &str = include_str!("../../extra/images/logo.svg"); const DEFAULT_SETTINGS: &str = include_str!("../../defaults/settings.toml"); const DEFAULT_LIGHT_THEME: &str = include_str!("../../defaults/light-theme.toml"); diff --git a/lapce-data/src/data.rs b/lapce-data/src/data.rs index 9469ef01..8eb02998 100644 --- a/lapce-data/src/data.rs +++ b/lapce-data/src/data.rs @@ -1,3 +1,5 @@ +#[cfg(target_os = "windows")] +use std::env; use std::{ cell::RefCell, cmp::Ordering, @@ -10,16 +12,12 @@ time::Instant, }; -#[cfg(target_os = "windows")] -use std::env; - use anyhow::{anyhow, Result}; use crossbeam_channel::{unbounded, Receiver, Sender}; use druid::{ piet::PietText, theme, Command, Data, Env, EventCtx, ExtEventSink, FileDialogOptions, Lens, Point, Rect, Size, Target, Vec2, WidgetId, WindowId, }; - use itertools::Itertools; use lapce_core::{ command::{FocusCommand, MultiSelectionCommand}, @@ -40,7 +38,6 @@ terminal::TermId, RpcMessage, }; - use lsp_types::{Diagnostic, DiagnosticSeverity, Position, ProgressToken, TextEdit}; use notify::Watcher; use serde::{Deserialize, Serialize}; diff --git a/lapce-data/src/db.rs b/lapce-data/src/db.rs index dcad57d9..aa72e2cf 100644 --- a/lapce-data/src/db.rs +++ b/lapce-data/src/db.rs @@ -9,7 +9,6 @@ use anyhow::{anyhow, Result}; use crossbeam_channel::{unbounded, Sender}; use druid::{ExtEventSink, Point, Rect, Size, Vec2, WidgetId}; - use lapce_proxy::directory::Directory; use serde::{Deserialize, Serialize}; use xi_rope::Rope; diff --git a/lapce-data/src/document.rs b/lapce-data/src/document.rs index 7b075829..866843f4 100644 --- a/lapce-data/src/document.rs +++ b/lapce-data/src/document.rs @@ -44,7 +44,6 @@ Interval, Rope, RopeDelta, Transformer, }; -use crate::selection_range::SelectionRangeDirection; use crate::{ command::{InitBufferContentCb, LapceUICommand, LAPCE_UI_COMMAND}, config::{LapceConfig, LapceTheme}, @@ -53,7 +52,7 @@ find::{Find, FindProgress}, history::DocumentHistory, proxy::LapceProxy, - selection_range::SyntaxSelectionRanges, + selection_range::{SelectionRangeDirection, SyntaxSelectionRanges}, settings::SettingsValueKind, }; diff --git a/lapce-data/src/editor.rs b/lapce-data/src/editor.rs index 8bffb230..df5b6a15 100644 --- a/lapce-data/src/editor.rs +++ b/lapce-data/src/editor.rs @@ -1,79 +1,62 @@ -use crate::command::InitBufferContentCb; -use crate::command::LapceCommand; -use crate::command::LAPCE_COMMAND; -use crate::command::LAPCE_SAVE_FILE_AS; -use crate::command::{CommandExecuted, CommandKind}; -use crate::completion::{CompletionData, CompletionStatus, Snippet}; -use crate::config::LapceConfig; -use crate::data::EditorView; -use crate::data::FocusArea; -use crate::data::{ - EditorDiagnostic, InlineFindDirection, LapceEditorData, LapceMainSplitData, - SplitContent, +use std::{ + cmp::Ordering, + collections::HashMap, + iter::Iterator, + path::{Path, PathBuf}, + str::FromStr, + sync::Arc, + thread, + time::Duration, }; -use crate::document::BufferContent; -use crate::document::Document; -use crate::document::LocalBufferKind; -use crate::hover::HoverData; -use crate::hover::HoverStatus; -use crate::keypress::KeyMap; -use crate::keypress::KeyPressFocus; -use crate::palette::PaletteData; -use crate::proxy::path_from_url; -use crate::rename::RenameData; -use crate::selection_range::SelectionRangeDirection; -use crate::{ - command::{ - EnsureVisiblePosition, InitBufferContent, LapceUICommand, LAPCE_UI_COMMAND, - }, - split::SplitMoveDirection, -}; -use crate::{find::Find, split::SplitDirection}; -use crate::{proxy::LapceProxy, source_control::SourceControlData}; + use anyhow::{anyhow, Result}; use crossbeam_channel::{self, bounded}; -use druid::piet::PietTextLayout; -use druid::piet::Svg; -use druid::FileDialogOptions; -use druid::Modifiers; use druid::{ - piet::PietText, Command, Env, EventCtx, Point, Rect, Target, Vec2, WidgetId, + piet::{PietText, PietTextLayout, Svg}, + Command, Env, EventCtx, ExtEventSink, FileDialogOptions, Modifiers, MouseEvent, + Point, Rect, Target, Vec2, WidgetId, }; -use druid::{ExtEventSink, MouseEvent}; use indexmap::IndexMap; -use lapce_core::buffer::Buffer; -use lapce_core::buffer::{DiffLines, InvalLines}; -use lapce_core::command::{ - EditCommand, FocusCommand, MotionModeCommand, MultiSelectionCommand, -}; -use lapce_core::editor::EditType; -use lapce_core::mode::{Mode, MotionMode}; -use lapce_core::selection::InsertDrift; -use lapce_core::selection::Selection; pub use lapce_core::syntax::Syntax; -use lapce_rpc::proxy::ProxyResponse; -use lsp_types::request::GotoTypeDefinitionResponse; -use lsp_types::CodeActionOrCommand; -use lsp_types::CompletionTextEdit; -use lsp_types::DocumentChangeOperation; -use lsp_types::DocumentChanges; -use lsp_types::OneOf; -use lsp_types::ResourceOp; -use lsp_types::TextEdit; -use lsp_types::Url; -use lsp_types::WorkspaceEdit; -use lsp_types::{ - CodeActionResponse, CompletionItem, DiagnosticSeverity, GotoDefinitionResponse, - Location, Position, +use lapce_core::{ + buffer::{Buffer, DiffLines, InvalLines}, + command::{EditCommand, FocusCommand, MotionModeCommand, MultiSelectionCommand}, + editor::EditType, + mode::{Mode, MotionMode}, + selection::{InsertDrift, Selection}, +}; +use lapce_rpc::proxy::ProxyResponse; +use lsp_types::{ + request::GotoTypeDefinitionResponse, CodeActionOrCommand, CodeActionResponse, + CompletionItem, CompletionTextEdit, DiagnosticSeverity, DocumentChangeOperation, + DocumentChanges, GotoDefinitionResponse, Location, OneOf, Position, ResourceOp, + TextEdit, Url, WorkspaceEdit, +}; +use xi_rope::{Rope, RopeDelta, Transformer}; + +use crate::{ + command::{ + CommandExecuted, CommandKind, EnsureVisiblePosition, InitBufferContent, + InitBufferContentCb, LapceCommand, LapceUICommand, LAPCE_COMMAND, + LAPCE_SAVE_FILE_AS, LAPCE_UI_COMMAND, + }, + completion::{CompletionData, CompletionStatus, Snippet}, + config::LapceConfig, + data::{ + EditorDiagnostic, EditorView, FocusArea, InlineFindDirection, + LapceEditorData, LapceMainSplitData, SplitContent, + }, + document::{BufferContent, Document, LocalBufferKind}, + find::Find, + hover::{HoverData, HoverStatus}, + keypress::{KeyMap, KeyPressFocus}, + palette::PaletteData, + proxy::{path_from_url, LapceProxy}, + rename::RenameData, + selection_range::SelectionRangeDirection, + source_control::SourceControlData, + split::{SplitDirection, SplitMoveDirection}, }; -use std::cmp::Ordering; -use std::path::Path; -use std::thread; -use std::{collections::HashMap, sync::Arc}; -use std::{iter::Iterator, path::PathBuf}; -use std::{str::FromStr, time::Duration}; -use xi_rope::Rope; -use xi_rope::{RopeDelta, Transformer}; pub struct LapceUI {} diff --git a/lapce-data/src/explorer.rs b/lapce-data/src/explorer.rs index 465d4a12..837e86f5 100644 --- a/lapce-data/src/explorer.rs +++ b/lapce-data/src/explorer.rs @@ -1,25 +1,20 @@ -use std::collections::HashMap; -use std::path::Path; -use std::path::PathBuf; -use std::sync::Arc; +use std::{ + collections::HashMap, + path::{Path, PathBuf}, + sync::Arc, +}; -use druid::Command; -use druid::EventCtx; -use druid::ExtEventSink; -use druid::{Target, WidgetId}; - -use lapce_core::cursor::CursorMode; -use lapce_core::selection::Selection; -use lapce_rpc::file::FileNodeItem; -use lapce_rpc::proxy::ProxyResponse; +use druid::{Command, EventCtx, ExtEventSink, Target, WidgetId}; +use lapce_core::{cursor::CursorMode, selection::Selection}; +use lapce_rpc::{file::FileNodeItem, proxy::ProxyResponse}; use xi_rope::Rope; -use crate::data::LapceMainSplitData; -use crate::data::LapceWorkspace; -use crate::document::LocalBufferKind; -use crate::proxy::LapceProxy; - -use crate::{command::LapceUICommand, command::LAPCE_UI_COMMAND}; +use crate::{ + command::{LapceUICommand, LAPCE_UI_COMMAND}, + data::{LapceMainSplitData, LapceWorkspace}, + document::LocalBufferKind, + proxy::LapceProxy, +}; #[derive(Clone)] pub enum Naming { diff --git a/lapce-data/src/find.rs b/lapce-data/src/find.rs index 1520154b..4fd17694 100644 --- a/lapce-data/src/find.rs +++ b/lapce-data/src/find.rs @@ -1,10 +1,11 @@ +use std::cmp::{max, min}; + use lapce_core::{ selection::{InsertDrift, SelRegion, Selection}, word::WordCursor, }; use regex::{Regex, RegexBuilder}; use serde::{Deserialize, Serialize}; -use std::cmp::{max, min}; use xi_rope::{ delta::DeltaRegion, find::{find, is_multiline_regex, CaseMatching}, diff --git a/lapce-data/src/keypress/mod.rs b/lapce-data/src/keypress/mod.rs index 07d9d46d..7d6d4c30 100644 --- a/lapce-data/src/keypress/mod.rs +++ b/lapce-data/src/keypress/mod.rs @@ -1,17 +1,14 @@ #![allow(clippy::module_inception)] -use std::path::PathBuf; -use std::sync::Arc; +use std::{path::PathBuf, sync::Arc}; use anyhow::Result; -use druid::piet::{PietTextLayout, Text, TextLayout, TextLayoutBuilder}; -use druid::{Command, KbKey}; use druid::{ - Env, EventCtx, ExtEventSink, KeyEvent, Modifiers, PaintCtx, Point, Rect, - RenderContext, Size, Target, + piet::{PietTextLayout, Text, TextLayout, TextLayoutBuilder}, + Command, Env, EventCtx, ExtEventSink, KbKey, KeyEvent, Modifiers, PaintCtx, + Point, Rect, RenderContext, Size, Target, }; -use fuzzy_matcher::skim::SkimMatcherV2; -use fuzzy_matcher::FuzzyMatcher; +use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher}; use indexmap::IndexMap; use itertools::Itertools; use lapce_core::mode::{Mode, Modes}; @@ -19,15 +16,17 @@ mod keypress; mod loader; -use crate::command::{ - lapce_internal_commands, CommandExecuted, CommandKind, LapceCommand, - LapceUICommand, LAPCE_COMMAND, LAPCE_UI_COMMAND, -}; -use crate::config::{LapceConfig, LapceTheme}; -use crate::keypress::loader::KeyMapLoader; - pub use keypress::KeyPress; +use crate::{ + command::{ + lapce_internal_commands, CommandExecuted, CommandKind, LapceCommand, + LapceUICommand, LAPCE_COMMAND, LAPCE_UI_COMMAND, + }, + config::{LapceConfig, LapceTheme}, + keypress::loader::KeyMapLoader, +}; + const DEFAULT_KEYMAPS_COMMON: &str = include_str!("../../../defaults/keymaps-common.toml"); const DEFAULT_KEYMAPS_MACOS: &str = @@ -740,9 +739,10 @@ fn parse_first(condition: &'a str) -> Self { #[cfg(test)] mod test { - use crate::keypress::{Condition, KeyPressData, KeyPressFocus}; use lapce_core::mode::Mode; + use crate::keypress::{Condition, KeyPressData, KeyPressFocus}; + struct MockFocus { accepted_conditions: &'static [&'static str], } diff --git a/lapce-data/src/palette.rs b/lapce-data/src/palette.rs index 7d1d6c96..efd44947 100644 --- a/lapce-data/src/palette.rs +++ b/lapce-data/src/palette.rs @@ -1,38 +1,39 @@ +use std::{cmp::Ordering, collections::HashSet, path::PathBuf, sync::Arc}; + use alacritty_terminal::{grid::Dimensions, term::cell::Flags}; use anyhow::Result; use crossbeam_channel::{unbounded, Receiver, Sender, TryRecvError}; -use druid::{Command, ExtEventSink, Lens, Modifiers, Target, WidgetId}; -use druid::{Data, Env, EventCtx}; -use fuzzy_matcher::skim::SkimMatcherV2; -use fuzzy_matcher::FuzzyMatcher; +use druid::{ + Command, Data, Env, EventCtx, ExtEventSink, Lens, Modifiers, Target, WidgetId, +}; +use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher}; use itertools::Itertools; -use lapce_core::command::{EditCommand, FocusCommand}; -use lapce_core::language::LapceLanguage; -use lapce_core::mode::Mode; +use lapce_core::{ + command::{EditCommand, FocusCommand}, + language::LapceLanguage, + mode::Mode, +}; use lapce_rpc::proxy::ProxyResponse; use lsp_types::{DocumentSymbolResponse, Position, Range, SymbolKind}; -use std::cmp::Ordering; -use std::collections::HashSet; -use std::path::PathBuf; -use std::sync::Arc; use uuid::Uuid; -use crate::command::CommandKind; -use crate::data::{LapceWorkspace, LapceWorkspaceType}; -use crate::document::BufferContent; -use crate::editor::EditorLocation; -use crate::list::ListData; -use crate::panel::PanelKind; -use crate::proxy::path_from_url; use crate::{ - command::LAPCE_UI_COMMAND, - command::{CommandExecuted, LAPCE_COMMAND}, - command::{LapceCommand, LapceUICommand}, + command::{ + CommandExecuted, CommandKind, LapceCommand, LapceUICommand, LAPCE_COMMAND, + LAPCE_UI_COMMAND, + }, config::LapceConfig, - data::{FocusArea, LapceMainSplitData, LapceTabData}, + data::{ + FocusArea, LapceMainSplitData, LapceTabData, LapceWorkspace, + LapceWorkspaceType, + }, + document::BufferContent, + editor::EditorLocation, find::Find, keypress::{KeyPressData, KeyPressFocus}, - proxy::LapceProxy, + list::ListData, + panel::PanelKind, + proxy::{path_from_url, LapceProxy}, terminal::TerminalSplitData, }; diff --git a/lapce-data/src/plugin.rs b/lapce-data/src/plugin.rs index ec4f9f62..85d92b6b 100644 --- a/lapce-data/src/plugin.rs +++ b/lapce-data/src/plugin.rs @@ -8,9 +8,8 @@ use lapce_proxy::plugin::{download_volt, wasi::find_all_volts}; use lapce_rpc::plugin::{VoltInfo, VoltMetadata}; use lsp_types::Url; -use strum_macros::Display; - use plugin_install_status::PluginInstallStatus; +use strum_macros::Display; use crate::{ command::{LapceUICommand, LAPCE_UI_COMMAND}, diff --git a/lapce-data/src/problem.rs b/lapce-data/src/problem.rs index 6e0b7120..64da8e94 100644 --- a/lapce-data/src/problem.rs +++ b/lapce-data/src/problem.rs @@ -1,6 +1,6 @@ +use std::{collections::HashMap, path::PathBuf}; + use druid::WidgetId; -use std::collections::HashMap; -use std::path::PathBuf; #[derive(Clone)] pub struct ProblemData { diff --git a/lapce-data/src/proxy.rs b/lapce-data/src/proxy.rs index 74aebbc2..5b262b6d 100644 --- a/lapce-data/src/proxy.rs +++ b/lapce-data/src/proxy.rs @@ -1,37 +1,39 @@ -use std::io::BufReader; #[cfg(target_os = "windows")] use std::os::windows::process::CommandExt; -use std::path::Path; -use std::process::{Command, Stdio}; -use std::thread; -use std::{collections::HashMap, io::Write}; -use std::{path::PathBuf, str::FromStr, sync::Arc}; +use std::{ + collections::HashMap, + io::{BufReader, Write}, + path::{Path, PathBuf}, + process::{Command, Stdio}, + str::FromStr, + sync::Arc, + thread, +}; use anyhow::{anyhow, Result}; use crossbeam_channel::Sender; -use druid::{ExtEventSink, WidgetId}; -use druid::{Target, WindowId}; +use druid::{ExtEventSink, Target, WidgetId, WindowId}; use flate2::read::GzDecoder; -use lapce_proxy::directory::Directory; -use lapce_proxy::dispatch::Dispatcher; -use lapce_proxy::APPLICATION_NAME; pub use lapce_proxy::VERSION; -use lapce_rpc::core::{CoreHandler, CoreNotification, CoreRequest, CoreRpcHandler}; -use lapce_rpc::proxy::{ProxyRpc, ProxyRpcHandler}; -use lapce_rpc::stdio::stdio_transport; -use lapce_rpc::terminal::TermId; -use lapce_rpc::RequestId; -use lapce_rpc::RpcMessage; +use lapce_proxy::{directory::Directory, dispatch::Dispatcher, APPLICATION_NAME}; +use lapce_rpc::{ + core::{CoreHandler, CoreNotification, CoreRequest, CoreRpcHandler}, + proxy::{ProxyRpc, ProxyRpcHandler}, + stdio::stdio_transport, + terminal::TermId, + RequestId, RpcMessage, +}; use lsp_types::Url; use parking_lot::Mutex; use serde_json::Value; use thiserror::Error; use xi_rope::Rope; -use crate::command::LapceUICommand; -use crate::command::LAPCE_UI_COMMAND; -use crate::data::{LapceWorkspace, LapceWorkspaceType}; -use crate::terminal::RawTerminal; +use crate::{ + command::{LapceUICommand, LAPCE_UI_COMMAND}, + data::{LapceWorkspace, LapceWorkspaceType}, + terminal::RawTerminal, +}; const UNIX_PROXY_SCRIPT: &[u8] = include_bytes!("../../extra/proxy.sh"); const WINDOWS_PROXY_SCRIPT: &[u8] = include_bytes!("../../extra/proxy.ps1"); diff --git a/lapce-data/src/rich_text.rs b/lapce-data/src/rich_text.rs index ab0fa80c..27b3196f 100644 --- a/lapce-data/src/rich_text.rs +++ b/lapce-data/src/rich_text.rs @@ -4,10 +4,10 @@ }; use druid::{ - piet::TextStorage as PietTextStorage, - piet::{PietTextLayoutBuilder, TextLayoutBuilder}, - text::{Attribute, AttributeSpans, Link}, - text::{EnvUpdateCtx, TextStorage}, + piet::{ + PietTextLayoutBuilder, TextLayoutBuilder, TextStorage as PietTextStorage, + }, + text::{Attribute, AttributeSpans, EnvUpdateCtx, Link, TextStorage}, ArcStr, Color, Command, Data, Env, FontDescriptor, FontFamily, FontStyle, FontWeight, KeyOrValue, }; diff --git a/lapce-data/src/selection_range.rs b/lapce-data/src/selection_range.rs index 9f8ce86f..84d92efc 100644 --- a/lapce-data/src/selection_range.rs +++ b/lapce-data/src/selection_range.rs @@ -93,10 +93,11 @@ fn count(&self) -> usize { #[cfg(test)] mod test { - use crate::selection_range::SyntaxSelectionRanges; use lapce_rpc::buffer::BufferId; use lsp_types::{Position, Range, SelectionRange}; + use crate::selection_range::SyntaxSelectionRanges; + #[test] fn should_get_next_selection_range() { let range_zero = Range { diff --git a/lapce-data/src/signature.rs b/lapce-data/src/signature.rs index 5ccec727..1c798b08 100644 --- a/lapce-data/src/signature.rs +++ b/lapce-data/src/signature.rs @@ -1,5 +1,4 @@ -use lsp_types::ParameterLabel; -use lsp_types::SignatureHelp; +use lsp_types::{ParameterLabel, SignatureHelp}; #[derive(Clone)] pub struct SignatureState { diff --git a/lapce-proxy/src/buffer.rs b/lapce-proxy/src/buffer.rs index cd9a6c5e..4b414d10 100644 --- a/lapce-proxy/src/buffer.rs +++ b/lapce-proxy/src/buffer.rs @@ -1,14 +1,19 @@ +use std::{ + borrow::Cow, + ffi::OsString, + fs, + fs::File, + io::{Read, Write}, + path::{Path, PathBuf}, + time::SystemTime, +}; + use anyhow::{anyhow, Result}; -use lapce_core::buffer::rope_text::CharIndicesJoin; -use lapce_core::encoding::offset_utf8_to_utf16; +use lapce_core::{ + buffer::rope_text::CharIndicesJoin, encoding::offset_utf8_to_utf16, +}; use lapce_rpc::buffer::BufferId; use lsp_types::*; -use std::ffi::OsString; -use std::fs; -use std::fs::File; -use std::io::{Read, Write}; -use std::path::PathBuf; -use std::{borrow::Cow, path::Path, time::SystemTime}; use xi_rope::{interval::IntervalBounds, rope::Rope, RopeDelta}; #[derive(Clone)] diff --git a/lapce-proxy/src/dispatch.rs b/lapce-proxy/src/dispatch.rs index 69a4c957..80f1e3c6 100644 --- a/lapce-proxy/src/dispatch.rs +++ b/lapce-proxy/src/dispatch.rs @@ -1,38 +1,42 @@ -use crate::buffer::{get_mod_time, load_file, Buffer}; -use crate::plugin::catalog::PluginCatalog; -use crate::plugin::{remove_volt, PluginCatalogRpcHandler}; -use crate::terminal::Terminal; -use crate::watcher::{FileWatcher, Notify, WatchToken}; -use alacritty_terminal::event_loop::Msg; -use alacritty_terminal::term::SizeInfo; +use std::{ + collections::{HashMap, HashSet}, + fs, + path::{Path, PathBuf}, + sync::Arc, + thread, + time::Duration, +}; + +use alacritty_terminal::{event_loop::Msg, term::SizeInfo}; use anyhow::{anyhow, Context, Result}; use crossbeam_channel::Sender; -use git2::build::CheckoutBuilder; -use git2::{DiffOptions, Repository}; +use git2::{build::CheckoutBuilder, DiffOptions, Repository}; use grep_matcher::Matcher; use grep_regex::RegexMatcherBuilder; -use grep_searcher::sinks::UTF8; -use grep_searcher::SearcherBuilder; -use lapce_rpc::core::{CoreNotification, CoreRpcHandler}; -use lapce_rpc::file::FileNodeItem; -use lapce_rpc::proxy::{ - ProxyHandler, ProxyNotification, ProxyRequest, ProxyResponse, ProxyRpcHandler, +use grep_searcher::{sinks::UTF8, SearcherBuilder}; +use lapce_rpc::{ + core::{CoreNotification, CoreRpcHandler}, + file::FileNodeItem, + proxy::{ + ProxyHandler, ProxyNotification, ProxyRequest, ProxyResponse, + ProxyRpcHandler, + }, + source_control::{DiffInfo, FileDiff}, + style::{LineStyle, SemanticStyles}, + terminal::TermId, + RequestId, RpcError, }; -use lapce_rpc::source_control::{DiffInfo, FileDiff}; -use lapce_rpc::style::{LineStyle, SemanticStyles}; -use lapce_rpc::terminal::TermId; -use lapce_rpc::{RequestId, RpcError}; use lsp_types::{Position, Range, TextDocumentItem, Url}; use parking_lot::Mutex; -use std::collections::HashMap; -use std::collections::HashSet; -use std::fs; -use std::path::{Path, PathBuf}; -use std::sync::Arc; -use std::thread; -use std::time::Duration; use xi_rope::Rope; +use crate::{ + buffer::{get_mod_time, load_file, Buffer}, + plugin::{catalog::PluginCatalog, remove_volt, PluginCatalogRpcHandler}, + terminal::Terminal, + watcher::{FileWatcher, Notify, WatchToken}, +}; + const OPEN_FILE_EVENT_TOKEN: WatchToken = WatchToken(1); const WORKSPACE_EVENT_TOKEN: WatchToken = WatchToken(2); diff --git a/lapce-proxy/src/plugin/catalog.rs b/lapce-proxy/src/plugin/catalog.rs index cac420ca..ece85379 100644 --- a/lapce-proxy/src/plugin/catalog.rs +++ b/lapce-proxy/src/plugin/catalog.rs @@ -23,13 +23,12 @@ use serde_json::Value; use xi_rope::{Rope, RopeDelta}; -use crate::plugin::{install_volt, wasi::enable_volt}; - use super::{ psp::{ClonableCallback, PluginServerRpc, PluginServerRpcHandler, RpcCallback}, wasi::{load_all_volts, start_volt}, PluginCatalogNotification, PluginCatalogRpcHandler, }; +use crate::plugin::{install_volt, wasi::enable_volt}; pub struct PluginCatalog { workspace: Option, diff --git a/lapce-proxy/src/plugin/lsp.rs b/lapce-proxy/src/plugin/lsp.rs index 1183ca67..4a3a703e 100644 --- a/lapce-proxy/src/plugin/lsp.rs +++ b/lapce-proxy/src/plugin/lsp.rs @@ -20,12 +20,11 @@ use serde_json::{json, Value}; use xi_rope::Rope; -use crate::{buffer::Buffer, plugin::PluginCatalogRpcHandler}; - use super::psp::{ handle_plugin_server_message, PluginHandlerNotification, PluginHostHandler, PluginServerHandler, PluginServerRpcHandler, RpcCallback, }; +use crate::{buffer::Buffer, plugin::PluginCatalogRpcHandler}; const HEADER_CONTENT_LENGTH: &str = "content-length"; const HEADER_CONTENT_TYPE: &str = "content-type"; diff --git a/lapce-proxy/src/plugin/mod.rs b/lapce-proxy/src/plugin/mod.rs index 31e1fe26..2fc03881 100644 --- a/lapce-proxy/src/plugin/mod.rs +++ b/lapce-proxy/src/plugin/mod.rs @@ -3,22 +3,36 @@ pub mod psp; pub mod wasi; +use std::{ + collections::HashMap, + fs, + io::Write, + path::{Path, PathBuf}, + sync::{ + atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}, + Arc, + }, + thread, +}; + use anyhow::{anyhow, Result}; use crossbeam_channel::{Receiver, Sender}; use dyn_clone::DynClone; -use lapce_rpc::core::CoreRpcHandler; -use lapce_rpc::plugin::{PluginId, VoltInfo, VoltMetadata}; -use lapce_rpc::proxy::ProxyRpcHandler; -use lapce_rpc::style::LineStyle; -use lapce_rpc::{RequestId, RpcError}; -use lsp_types::request::{ - CodeActionRequest, Completion, DocumentSymbolRequest, Formatting, - GotoDefinition, GotoTypeDefinition, GotoTypeDefinitionParams, - GotoTypeDefinitionResponse, HoverRequest, InlayHintRequest, - PrepareRenameRequest, References, Rename, Request, ResolveCompletionItem, - SelectionRangeRequest, SemanticTokensFullRequest, WorkspaceSymbol, +use lapce_rpc::{ + core::CoreRpcHandler, + plugin::{PluginId, VoltInfo, VoltMetadata}, + proxy::ProxyRpcHandler, + style::LineStyle, + RequestId, RpcError, }; use lsp_types::{ + request::{ + CodeActionRequest, Completion, DocumentSymbolRequest, Formatting, + GotoDefinition, GotoTypeDefinition, GotoTypeDefinitionParams, + GotoTypeDefinitionResponse, HoverRequest, InlayHintRequest, + PrepareRenameRequest, References, Rename, Request, ResolveCompletionItem, + SelectionRangeRequest, SemanticTokensFullRequest, WorkspaceSymbol, + }, CodeActionContext, CodeActionParams, CodeActionResponse, CompletionItem, CompletionParams, CompletionResponse, DocumentFormattingParams, DocumentSymbolParams, DocumentSymbolResponse, FormattingOptions, @@ -31,24 +45,16 @@ WorkspaceSymbolParams, }; use parking_lot::Mutex; -use serde::de::DeserializeOwned; -use serde::{Deserialize, Serialize}; +use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::Value; -use std::collections::HashMap; -use std::fs; -use std::io::Write; -use std::path::{Path, PathBuf}; -use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; -use std::sync::Arc; -use std::thread; use xi_rope::{Rope, RopeDelta}; -use crate::buffer::language_id_from_path; -use crate::directory::Directory; - -use self::catalog::PluginCatalog; -use self::psp::{ClonableCallback, PluginServerRpcHandler, RpcCallback}; -use self::wasi::{load_volt, start_volt}; +use self::{ + catalog::PluginCatalog, + psp::{ClonableCallback, PluginServerRpcHandler, RpcCallback}, + wasi::{load_volt, start_volt}, +}; +use crate::{buffer::language_id_from_path, directory::Directory}; pub type PluginName = String; diff --git a/lapce-proxy/src/plugin/wasi.rs b/lapce-proxy/src/plugin/wasi.rs index 0d72a9fe..366d9fe7 100644 --- a/lapce-proxy/src/plugin/wasi.rs +++ b/lapce-proxy/src/plugin/wasi.rs @@ -27,8 +27,6 @@ use wasmtime_wasi::WasiCtxBuilder; use xi_rope::{Rope, RopeDelta}; -use crate::{directory::Directory, plugin::psp::PluginServerRpcHandler}; - use super::{ psp::{ handle_plugin_server_message, PluginHandlerNotification, PluginHostHandler, @@ -36,6 +34,7 @@ }, PluginCatalogRpcHandler, }; +use crate::{directory::Directory, plugin::psp::PluginServerRpcHandler}; #[derive(Default)] pub struct WasiPipe { diff --git a/lapce-rpc/src/core.rs b/lapce-rpc/src/core.rs index 32134827..e6b92c01 100644 --- a/lapce-rpc/src/core.rs +++ b/lapce-rpc/src/core.rs @@ -1,7 +1,3 @@ -use crossbeam_channel::{Receiver, Sender}; -use lsp_types::{CompletionResponse, ProgressParams, PublishDiagnosticsParams}; -use parking_lot::Mutex; -use serde::{Deserialize, Serialize}; use std::{ collections::HashMap, path::PathBuf, @@ -11,6 +7,11 @@ }, }; +use crossbeam_channel::{Receiver, Sender}; +use lsp_types::{CompletionResponse, ProgressParams, PublishDiagnosticsParams}; +use parking_lot::Mutex; +use serde::{Deserialize, Serialize}; + use crate::{ file::FileNodeItem, plugin::{PluginId, VoltInfo, VoltMetadata}, diff --git a/lapce-rpc/src/lib.rs b/lapce-rpc/src/lib.rs index 4bd43293..5d4c230a 100644 --- a/lapce-rpc/src/lib.rs +++ b/lapce-rpc/src/lib.rs @@ -10,12 +10,8 @@ pub mod style; pub mod terminal; -pub use parse::Call; -pub use parse::RequestId; -pub use parse::RpcObject; -use serde::Deserialize; -use serde::Serialize; - +pub use parse::{Call, RequestId, RpcObject}; +use serde::{Deserialize, Serialize}; pub use stdio::stdio_transport; #[derive(Debug)] diff --git a/lapce-rpc/src/stdio.rs b/lapce-rpc/src/stdio.rs index 2277d0f4..4d0ebfed 100644 --- a/lapce-rpc/src/stdio.rs +++ b/lapce-rpc/src/stdio.rs @@ -1,12 +1,13 @@ -use anyhow::Result; -use crossbeam_channel::{Receiver, Sender}; -use serde::{de::DeserializeOwned, Serialize}; -use serde_json::{json, Value}; use std::{ io::{self, BufRead, Write}, thread, }; +use anyhow::Result; +use crossbeam_channel::{Receiver, Sender}; +use serde::{de::DeserializeOwned, Serialize}; +use serde_json::{json, Value}; + use crate::{RpcError, RpcMessage, RpcObject}; pub fn stdio_transport( diff --git a/lapce-ui/src/app.rs b/lapce-ui/src/app.rs index fcca3451..5ae945bd 100644 --- a/lapce-ui/src/app.rs +++ b/lapce-ui/src/app.rs @@ -19,8 +19,11 @@ proxy::VERSION, }; -use crate::{logging::override_log_levels, tab::LAPCE_TAB_META}; -use crate::{tab::LapceTabHeader, window::LapceWindow}; +use crate::{ + logging::override_log_levels, + tab::{LapceTabHeader, LAPCE_TAB_META}, + window::LapceWindow, +}; #[derive(Parser)] #[clap(name = "Lapce")] diff --git a/lapce-ui/src/completion.rs b/lapce-ui/src/completion.rs index b67f0ef4..aee4ad47 100644 --- a/lapce-ui/src/completion.rs +++ b/lapce-ui/src/completion.rs @@ -1,4 +1,4 @@ -use std::{fmt::Display, sync::Arc}; +use std::{fmt::Display, str::FromStr, sync::Arc}; use anyhow::Error; use druid::{ @@ -20,7 +20,6 @@ }; use lsp_types::{Documentation, MarkupKind}; use regex::Regex; -use std::str::FromStr; use crate::{ list::{List, ListPaint}, diff --git a/lapce-ui/src/editor.rs b/lapce-ui/src/editor.rs index 398bc195..10c6983a 100644 --- a/lapce-ui/src/editor.rs +++ b/lapce-ui/src/editor.rs @@ -1,40 +1,35 @@ -use std::collections::HashMap; -use std::time::Duration; -use std::{iter::Iterator, sync::Arc}; +use std::{collections::HashMap, iter::Iterator, sync::Arc, time::Duration}; use druid::{ kurbo::{BezPath, Line}, piet::{PietText, PietTextLayout, Text, TextLayout as _, TextLayoutBuilder}, BoxConstraints, Color, Command, Env, Event, EventCtx, InternalLifeCycle, - LayoutCtx, LifeCycle, LifeCycleCtx, MouseButton, MouseEvent, PaintCtx, Point, - Rect, RenderContext, Size, Target, UpdateCtx, Widget, WidgetId, + LayoutCtx, LifeCycle, LifeCycleCtx, Modifiers, MouseButton, MouseEvent, + PaintCtx, Point, Rect, RenderContext, Size, Target, TimerToken, UpdateCtx, + Widget, WidgetId, }; -use druid::{Modifiers, TimerToken}; -use lapce_core::buffer::DiffLines; -use lapce_core::command::EditCommand; use lapce_core::{ - command::FocusCommand, + buffer::DiffLines, + command::{EditCommand, FocusCommand}, cursor::{ColPosition, CursorMode}, mode::{Mode, VisualMode}, }; -use lapce_data::command::CommandKind; -use lapce_data::data::{EditorView, LapceData}; -use lapce_data::document::{BufferContent, LocalBufferKind}; -use lapce_data::history::DocumentHistory; -use lapce_data::hover::HoverStatus; -use lapce_data::keypress::KeyPressFocus; -use lapce_data::menu::MenuKind; -use lapce_data::palette::PaletteStatus; -use lapce_data::panel::{PanelData, PanelKind}; -use lapce_data::selection_range::SyntaxSelectionRanges; use lapce_data::{ command::{ - LapceCommand, LapceUICommand, LapceWorkbenchCommand, LAPCE_UI_COMMAND, + CommandKind, LapceCommand, LapceUICommand, LapceWorkbenchCommand, + LAPCE_UI_COMMAND, }, config::{LapceConfig, LapceTheme}, - data::LapceTabData, + data::{EditorView, LapceData, LapceTabData}, + document::{BufferContent, LocalBufferKind}, editor::{LapceEditorBufferData, Syntax}, - menu::MenuItem, + history::DocumentHistory, + hover::HoverStatus, + keypress::KeyPressFocus, + menu::{MenuItem, MenuKind}, + palette::PaletteStatus, + panel::{PanelData, PanelKind}, + selection_range::SyntaxSelectionRanges, }; use lsp_types::{CodeActionOrCommand, DiagnosticSeverity}; diff --git a/lapce-ui/src/editor/container.rs b/lapce-ui/src/editor/container.rs index febb5052..9c17aab9 100644 --- a/lapce-ui/src/editor/container.rs +++ b/lapce-ui/src/editor/container.rs @@ -5,13 +5,12 @@ }; use lapce_data::{config::LapceTheme, data::LapceTabData}; +use super::bread_crumb::LapceEditorBreadCrumb; use crate::{ editor::{gutter::LapceEditorGutter, LapceEditor}, scroll::{LapceIdentityWrapper, LapcePadding, LapceScroll}, }; -use super::bread_crumb::LapceEditorBreadCrumb; - pub struct LapceEditorContainer { pub view_id: WidgetId, pub scroll_id: WidgetId, diff --git a/lapce-ui/src/editor/gutter.rs b/lapce-ui/src/editor/gutter.rs index 47e96f7b..b6034490 100644 --- a/lapce-ui/src/editor/gutter.rs +++ b/lapce-ui/src/editor/gutter.rs @@ -1,4 +1,3 @@ -use crate::svg::get_svg; use druid::{ piet::{PietText, Text, TextLayout, TextLayoutBuilder}, BoxConstraints, Command, Env, Event, EventCtx, LayoutCtx, LifeCycle, @@ -13,6 +12,8 @@ editor::{LapceEditorBufferData, Syntax}, }; +use crate::svg::get_svg; + pub struct LapceEditorGutter { view_id: WidgetId, width: f64, diff --git a/lapce-ui/src/editor/tab.rs b/lapce-ui/src/editor/tab.rs index eaae046f..cf6b88f0 100644 --- a/lapce-ui/src/editor/tab.rs +++ b/lapce-ui/src/editor/tab.rs @@ -21,12 +21,11 @@ split::{SplitDirection, SplitMoveDirection}, }; -use crate::editor::{ - tab_header::LapceEditorTabHeader, view::editor_tab_child_widget, +use crate::{ + editor::{tab_header::LapceEditorTabHeader, view::editor_tab_child_widget}, + svg::get_svg, }; -use crate::svg::get_svg; - pub struct LapceEditorTab { pub widget_id: WidgetId, header: WidgetPod, diff --git a/lapce-ui/src/explorer.rs b/lapce-ui/src/explorer.rs index 02aca176..6b5e67c1 100644 --- a/lapce-ui/src/explorer.rs +++ b/lapce-ui/src/explorer.rs @@ -1,34 +1,29 @@ -use std::sync::Arc; -use std::{collections::HashMap, path::Path}; +use std::{collections::HashMap, path::Path, sync::Arc}; -use druid::menu::MenuEventCtx; -use druid::piet::TextAttribute; use druid::{ - piet::{Text, TextLayoutBuilder}, - BoxConstraints, Command, Cursor, Env, Event, EventCtx, LayoutCtx, LifeCycle, - LifeCycleCtx, PaintCtx, Point, Rect, RenderContext, Size, Target, UpdateCtx, - Widget, WidgetExt, WidgetId, WidgetPod, + menu::MenuEventCtx, + piet::{Text, TextAttribute, TextLayoutBuilder}, + BoxConstraints, Command, Cursor, Env, Event, EventCtx, ExtEventSink, KbKey, + LayoutCtx, LifeCycle, LifeCycleCtx, PaintCtx, Point, Rect, RenderContext, Size, + Target, UpdateCtx, Widget, WidgetExt, WidgetId, WidgetPod, WindowId, }; -use druid::{ExtEventSink, KbKey, WindowId}; use itertools::Itertools; use lapce_core::command::FocusCommand; -use lapce_data::command::{CommandKind, LapceCommand, LAPCE_COMMAND}; -use lapce_data::data::{EditorTabChild, LapceData, LapceEditorData}; -use lapce_data::document::{BufferContent, LocalBufferKind}; -use lapce_data::explorer::FileExplorerData; -use lapce_data::explorer::Naming; -use lapce_data::panel::PanelKind; -use lapce_data::proxy::{LapceProxy, VERSION}; use lapce_data::{ - command::LapceUICommand, - command::LAPCE_UI_COMMAND, + command::{ + CommandKind, LapceCommand, LapceUICommand, LAPCE_COMMAND, LAPCE_UI_COMMAND, + }, config::{LapceConfig, LapceTheme}, - data::LapceTabData, + data::{EditorTabChild, LapceData, LapceEditorData, LapceTabData}, + document::{BufferContent, LocalBufferKind}, + explorer::{FileExplorerData, Naming}, + panel::PanelKind, + proxy::{LapceProxy, VERSION}, }; use lapce_rpc::file::FileNodeItem; -use crate::editor::view::LapceEditorView; use crate::{ + editor::view::LapceEditorView, panel::{LapcePanel, PanelHeaderKind, PanelSizing}, scroll::LapceScroll, svg::{file_svg, get_svg}, diff --git a/lapce-ui/src/palette.rs b/lapce-ui/src/palette.rs index 3cd64849..94e6de94 100644 --- a/lapce-ui/src/palette.rs +++ b/lapce-ui/src/palette.rs @@ -1,32 +1,28 @@ -use std::path::Path; -use std::sync::Arc; +use std::{path::Path, sync::Arc}; -use druid::kurbo::Line; -use druid::piet::{Svg, TextAttribute, TextLayout}; use druid::{ - kurbo::Rect, - piet::{Text, TextLayoutBuilder}, - BoxConstraints, Command, Data, Env, Event, EventCtx, LayoutCtx, LifeCycle, - LifeCycleCtx, PaintCtx, Point, RenderContext, Size, Target, UpdateCtx, Widget, - WidgetExt, WidgetId, WidgetPod, + kurbo::{Line, Rect}, + piet::{Svg, Text, TextAttribute, TextLayout, TextLayoutBuilder}, + BoxConstraints, Command, Data, Env, Event, EventCtx, FontWeight, LayoutCtx, + LifeCycle, LifeCycleCtx, Modifiers, PaintCtx, Point, RenderContext, Size, + Target, UpdateCtx, Widget, WidgetExt, WidgetId, WidgetPod, }; -use druid::{FontWeight, Modifiers}; -use lapce_data::command::LAPCE_COMMAND; -use lapce_data::data::LapceWorkspaceType; -use lapce_data::list::ListData; -use lapce_data::palette::{PaletteItem, PaletteItemContent, PaletteListData}; use lapce_data::{ - command::{LapceUICommand, LAPCE_UI_COMMAND}, + command::{LapceUICommand, LAPCE_COMMAND, LAPCE_UI_COMMAND}, config::LapceTheme, - data::LapceTabData, + data::{LapceTabData, LapceWorkspaceType}, keypress::KeyPressFocus, - palette::{PaletteStatus, PaletteType, PaletteViewData}, + list::ListData, + palette::{ + PaletteItem, PaletteItemContent, PaletteListData, PaletteStatus, + PaletteType, PaletteViewData, + }, }; use lsp_types::SymbolKind; -use crate::list::{List, ListPaint}; use crate::{ editor::view::LapceEditorView, + list::{List, ListPaint}, svg::{file_svg, symbol_svg}, }; diff --git a/lapce-ui/src/plugin.rs b/lapce-ui/src/plugin.rs index a653f00b..5fb393a7 100644 --- a/lapce-ui/src/plugin.rs +++ b/lapce-ui/src/plugin.rs @@ -1,8 +1,3 @@ -use crate::{ - panel::PanelSizing, - scroll::LapceScroll, - svg::{get_svg, logo_svg}, -}; use druid::{ kurbo::Line, piet::{ @@ -27,7 +22,11 @@ rich_text::RichText, }; -use crate::panel::{LapcePanel, PanelHeaderKind}; +use crate::{ + panel::{LapcePanel, PanelHeaderKind, PanelSizing}, + scroll::LapceScroll, + svg::{get_svg, logo_svg}, +}; pub struct Plugin { line_height: f64, diff --git a/lapce-ui/src/scroll.rs b/lapce-ui/src/scroll.rs index e513da73..68c9bb1d 100644 --- a/lapce-ui/src/scroll.rs +++ b/lapce-ui/src/scroll.rs @@ -1,16 +1,11 @@ -use std::time::Duration; -use std::time::Instant; +use std::time::{Duration, Instant}; -use druid::Cursor; use druid::{ kurbo::{Affine, Point, Rect, Size, Vec2}, - Insets, WidgetId, + theme, BoxConstraints, Cursor, Data, Env, Event, EventCtx, Insets, LayoutCtx, + LifeCycle, LifeCycleCtx, PaintCtx, RenderContext, TimerToken, UpdateCtx, Widget, + WidgetId, WidgetPod, }; -use druid::{ - theme, BoxConstraints, Data, Env, Event, EventCtx, LayoutCtx, LifeCycle, - LifeCycleCtx, PaintCtx, RenderContext, TimerToken, UpdateCtx, Widget, WidgetPod, -}; - use lapce_data::{ command::{LapceUICommand, LAPCE_UI_COMMAND}, config::{GetConfig, LapceConfig, LapceTheme}, diff --git a/lapce-ui/src/split.rs b/lapce-ui/src/split.rs index 0d82e2c6..947f646e 100644 --- a/lapce-ui/src/split.rs +++ b/lapce-ui/src/split.rs @@ -1,21 +1,11 @@ -use crate::{ - editor::{ - tab::LapceEditorTab, - view::{editor_tab_child_widget, LapceEditorView}, - }, - terminal::LapceTerminalView, -}; use std::sync::Arc; -use crate::svg::logo_svg; use druid::{ kurbo::{Line, Rect}, piet::{PietTextLayout, Text, TextLayout, TextLayoutBuilder}, - Command, Target, WidgetId, -}; -use druid::{ - BoxConstraints, Env, Event, EventCtx, LayoutCtx, LifeCycle, LifeCycleCtx, - PaintCtx, Point, RenderContext, Size, UpdateCtx, Widget, WidgetExt, WidgetPod, + BoxConstraints, Command, Env, Event, EventCtx, LayoutCtx, LifeCycle, + LifeCycleCtx, PaintCtx, Point, RenderContext, Size, Target, UpdateCtx, Widget, + WidgetExt, WidgetId, WidgetPod, }; use lapce_data::{ command::{ @@ -31,6 +21,15 @@ }; use lapce_rpc::terminal::TermId; +use crate::{ + editor::{ + tab::LapceEditorTab, + view::{editor_tab_child_widget, LapceEditorView}, + }, + svg::logo_svg, + terminal::LapceTerminalView, +}; + struct LapceDynamicSplit { widget_id: WidgetId, children: Vec, diff --git a/lapce-ui/src/svg.rs b/lapce-ui/src/svg.rs index 4a5dd3ae..b67be891 100644 --- a/lapce-ui/src/svg.rs +++ b/lapce-ui/src/svg.rs @@ -2,11 +2,10 @@ use druid::{piet::Svg, Color}; use include_dir::{include_dir, Dir}; +use lapce_data::config::{LapceConfig, LOGO}; use lsp_types::{CompletionItemKind, SymbolKind}; use once_cell::sync::Lazy; -use lapce_data::config::{LapceConfig, LOGO}; - const ICONS_DIR: Dir = include_dir!("../icons"); static SVG_STORE: Lazy = Lazy::new(SvgStore::new); diff --git a/lapce-ui/src/title.rs b/lapce-ui/src/title.rs index 438145a9..5906a9aa 100644 --- a/lapce-ui/src/title.rs +++ b/lapce-ui/src/title.rs @@ -1,35 +1,31 @@ use std::sync::Arc; -use crate::list::List; -#[cfg(not(target_os = "macos"))] -use crate::window::window_controls; -use crate::{palette::Palette, svg::get_svg}; -use druid::{kurbo::Circle, InternalEvent}; use druid::{ - kurbo::Line, + kurbo::{Circle, Line}, piet::{PietText, PietTextLayout, Svg, Text, TextLayout, TextLayoutBuilder}, - BoxConstraints, Color, Command, Env, Event, EventCtx, LayoutCtx, LifeCycle, - LifeCycleCtx, MouseEvent, PaintCtx, Point, Rect, Region, RenderContext, Size, - Target, Widget, WidgetExt, WidgetPod, WindowState, + BoxConstraints, Color, Command, Env, Event, EventCtx, InternalEvent, LayoutCtx, + LifeCycle, LifeCycleCtx, MouseEvent, PaintCtx, Point, Rect, Region, + RenderContext, Size, Target, Widget, WidgetExt, WidgetId, WidgetPod, + WindowConfig, WindowState, }; -use druid::{WidgetId, WindowConfig}; use lapce_core::command::FocusCommand; -use lapce_data::command::LAPCE_COMMAND; -use lapce_data::data::FocusArea; -use lapce_data::list::ListData; -use lapce_data::proxy::VERSION; use lapce_data::{ command::{ CommandKind, LapceCommand, LapceUICommand, LapceWorkbenchCommand, - LAPCE_UI_COMMAND, + LAPCE_COMMAND, LAPCE_UI_COMMAND, }, config::LapceTheme, - data::{LapceTabData, LapceWorkspaceType}, + data::{FocusArea, LapceTabData, LapceWorkspaceType}, + list::ListData, menu::{MenuItem, MenuKind}, palette::PaletteStatus, - proxy::ProxyStatus, + proxy::{ProxyStatus, VERSION}, }; +#[cfg(not(target_os = "macos"))] +use crate::window::window_controls; +use crate::{list::List, palette::Palette, svg::get_svg}; + pub struct Title { widget_id: WidgetId, mouse_pos: Point, diff --git a/lapce-ui/src/window.rs b/lapce-ui/src/window.rs index 6fc91b20..ee83daac 100644 --- a/lapce-ui/src/window.rs +++ b/lapce-ui/src/window.rs @@ -1,3 +1,5 @@ +use std::{cmp::Ordering, sync::Arc}; + use druid::{ kurbo::Line, widget::{LensWrap, WidgetExt}, @@ -10,8 +12,6 @@ config::{LapceConfig, LapceTheme}, data::{LapceTabData, LapceTabLens, LapceWindowData, LapceWorkspace}, }; -use std::cmp::Ordering; -use std::sync::Arc; use crate::tab::{LapceTab, LapceTabHeader, LapceTabMeta, LAPCE_TAB_META}; @@ -805,9 +805,10 @@ pub fn window_controls( Vec<(Rect, Command)>, Vec<(druid::piet::Svg, Rect, druid::Color)>, ) { - use crate::svg::get_svg; use druid::Color; + use crate::svg::get_svg; + let mut commands = Vec::new(); let minimise_rect = Size::new(width, width)