Skip to content

Commit

Permalink
chore: rustfmt with nightly options ♻️
Browse files Browse the repository at this point in the history
  • Loading branch information
kdheepak committed Aug 29, 2023
1 parent ae44577 commit 11d95bc
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 188 deletions.
2 changes: 2 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
max_width = 150
tab_spaces = 2
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "stable"
channel = "nightly"
140 changes: 54 additions & 86 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,94 +1,64 @@
use crate::calendar::Calendar;
use crate::completion::{get_start_word_under_cursor, CompletionList};
use crate::config;
use crate::config::Config;
use crate::event::Event;
use crate::help::Help;
use crate::keyconfig::KeyConfig;
use crate::scrollbar::Scrollbar;
use crate::table::{Row, Table, TableMode, TableState};
use crate::task_report::TaskReportTable;
use crate::ui;
use crate::utils;

use std::cmp::Ordering;
use std::collections::{HashMap, HashSet};
use std::convert::TryInto;
use std::fs;
use std::path::Path;

use std::io::Read;
use std::io::Write;

use std::time::SystemTime;

use ratatui::symbols::bar::FULL;
use task_hookrs::date::Date;
use task_hookrs::import::import;
use task_hookrs::status::TaskStatus;
use task_hookrs::task::Task;
use uuid::Uuid;

use unicode_segmentation::Graphemes;
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
use std::{
borrow::Borrow,
cmp::Ordering,
collections::{HashMap, HashSet},
convert::TryInto,
fs, io,
io::{Read, Write},
path::Path,
sync::{mpsc, Arc, Mutex},
time::{Duration, Instant, SystemTime},
};

use anyhow::{anyhow, Context as AnyhowContext, Result};
use chrono::{DateTime, Datelike, FixedOffset, Local, NaiveDate, NaiveDateTime, TimeZone, Timelike};

use anyhow::Context as AnyhowContext;
use anyhow::{anyhow, Result};

use std::sync::mpsc;

use std::sync::{Arc, Mutex};

use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture},
execute,
style::style,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use futures::SinkExt;
use lazy_static::lazy_static;
use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use ratatui::{
backend::Backend,
backend::{Backend, CrosstermBackend},
layout::{Alignment, Constraint, Direction, Layout, Margin, Rect},
style::{Color, Modifier, Style},
symbols::bar::FULL,
terminal::Frame,
text::{Line, Span, Text},
widgets::{Block, BorderType, Borders, Clear, Gauge, LineGauge, List, ListItem, Paragraph, Wrap},
widgets::{Block, BorderType, Borders, Clear, Gauge, LineGauge, List, ListItem, Paragraph, Tabs, Wrap},
Terminal,
};
use std::time::Duration;

use rustyline::history::SearchDirection as HistoryDirection;
use rustyline::line_buffer::LineBuffer;
use rustyline::At;
use rustyline::Editor;
use rustyline::Word;

use crate::history::HistoryContext;

use ratatui::{backend::CrosstermBackend, Terminal};
use std::io;

use regex::Regex;

use lazy_static::lazy_static;

use crate::action::Action;
use crate::event::KeyCode;
use crate::pane::context::{ContextDetails, ContextsState};
use crate::pane::project::ProjectsState;
use crate::pane::Pane;

use crossterm::style::style;
use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};

use futures::SinkExt;
use std::borrow::Borrow;
use std::time::Instant;
use task_hookrs::project::Project;

use rustyline::{history::SearchDirection as HistoryDirection, line_buffer::LineBuffer, At, Editor, Word};
use task_hookrs::{date::Date, import::import, project::Project, status::TaskStatus, task::Task};
use unicode_segmentation::{Graphemes, UnicodeSegmentation};
use unicode_width::UnicodeWidthStr;
use uuid::Uuid;
use versions::Versioning;

use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use ratatui::widgets::Tabs;
use crate::{
action::Action,
calendar::Calendar,
completion::{get_start_word_under_cursor, CompletionList},
config,
config::Config,
event::{Event, KeyCode},
help::Help,
history::HistoryContext,
keyconfig::KeyConfig,
pane::{
context::{ContextDetails, ContextsState},
project::ProjectsState,
Pane,
},
scrollbar::Scrollbar,
table::{Row, Table, TableMode, TableState},
task_report::TaskReportTable,
ui, utils,
};

const MAX_LINE: usize = 4096;

Expand Down Expand Up @@ -3731,13 +3701,11 @@ pub fn remove_tag(task: &mut Task, tag: &str) {

#[cfg(test)]
mod tests {
use std::{ffi::OsStr, fmt::Write, fs::File, io, path::Path};

use ratatui::{backend::TestBackend, buffer::Buffer};

use super::*;
use ratatui::backend::TestBackend;
use ratatui::buffer::Buffer;
use std::ffi::OsStr;
use std::fs::File;
use std::path::Path;
use std::{fmt::Write, io};

/// Returns a string representation of the given buffer for debugging purpose.
fn buffer_view(buffer: &Buffer) -> String {
Expand Down
5 changes: 2 additions & 3 deletions src/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use std::fmt;

const COL_WIDTH: usize = 21;

use chrono::{format::Fixed, DateTime, Datelike, Duration, FixedOffset, Local, Month, NaiveDate, NaiveDateTime, TimeZone};
use std::cmp::min;

use chrono::{format::Fixed, DateTime, Datelike, Duration, FixedOffset, Local, Month, NaiveDate, NaiveDateTime, TimeZone};
use ratatui::{
buffer::Buffer,
layout::Rect,
Expand All @@ -15,8 +16,6 @@ use ratatui::{
widgets::{Block, Widget},
};

use std::cmp::min;

#[derive(Debug, Clone)]
pub struct Calendar<'a> {
pub block: Option<Block<'a>>,
Expand Down
21 changes: 11 additions & 10 deletions src/completion.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::{error::Error, io};

use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use ratatui::{
layout::{Constraint, Corner, Direction, Layout},
Expand All @@ -6,16 +8,15 @@ use ratatui::{
widgets::{Block, Borders, List, ListItem, ListState},
Terminal,
};
use std::{error::Error, io};

use rustyline::highlight::{Highlighter, MatchingBracketHighlighter};
use rustyline::hint::Hinter;
use rustyline::line_buffer::LineBuffer;
use rustyline::Context;
use rustyline::{error::ReadlineError, history::FileHistory};

use unicode_segmentation::Graphemes;
use unicode_segmentation::UnicodeSegmentation;
use rustyline::{
error::ReadlineError,
highlight::{Highlighter, MatchingBracketHighlighter},
hint::Hinter,
history::FileHistory,
line_buffer::LineBuffer,
Context,
};
use unicode_segmentation::{Graphemes, UnicodeSegmentation};
use unicode_width::UnicodeWidthStr;

pub fn get_start_word_under_cursor(line: &str, cursor_pos: usize) -> usize {
Expand Down
8 changes: 3 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::{collections::HashMap, error::Error, str};

use anyhow::{Context, Result};
use ratatui::{
style::{Color, Modifier, Style},
symbols::bar::FULL,
symbols::line::DOUBLE_VERTICAL,
symbols::{bar::FULL, line::DOUBLE_VERTICAL},
};
use std::collections::HashMap;
use std::error::Error;
use std::str;

trait TaskWarriorBool {
fn get_bool(&self) -> Option<bool>;
Expand Down
13 changes: 7 additions & 6 deletions src/event.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crossterm::event::KeyEvent;
use crossterm::event::{
KeyCode::{BackTab, Backspace, Char, Delete, Down, End, Enter, Esc, Home, Insert, Left, Null, PageDown, PageUp, Right, Tab, Up, F},
KeyEvent, KeyModifiers,
};
use futures::StreamExt;
use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use serde::{Deserialize, Serialize};
use tokio::{sync::mpsc, sync::oneshot, task::JoinHandle};

use crossterm::event::{
KeyCode::{BackTab, Backspace, Char, Delete, Down, End, Enter, Esc, Home, Insert, Left, Null, PageDown, PageUp, Right, Tab, Up, F},
KeyModifiers,
use tokio::{
sync::{mpsc, oneshot},
task::JoinHandle,
};

#[derive(Debug, Clone, Copy)]
Expand Down
15 changes: 9 additions & 6 deletions src/history.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use std::{
fs::File,
path::{Path, PathBuf},
};

use anyhow::{anyhow, Result};
use rustyline::error::ReadlineError;
use rustyline::history::DefaultHistory;
use rustyline::history::History;
use rustyline::history::SearchDirection;
use std::fs::File;
use std::path::{Path, PathBuf};
use rustyline::{
error::ReadlineError,
history::{DefaultHistory, History, SearchDirection},
};

pub struct HistoryContext {
history: DefaultHistory,
Expand Down
8 changes: 4 additions & 4 deletions src/keyconfig.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::event::KeyCode;
use std::{collections::HashSet, error::Error, hash::Hash};

use anyhow::{anyhow, Result};
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::error::Error;
use std::hash::Hash;

use crate::event::KeyCode;

#[derive(Serialize, Deserialize, Debug)]
pub struct KeyConfig {
Expand Down
34 changes: 17 additions & 17 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,34 @@ mod task_report;
mod ui;
mod utils;

use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use log4rs::append::file::FileAppender;
use log4rs::config::{Appender, Config, Logger, Root};
use log4rs::encode::pattern::PatternEncoder;
use std::env;
use std::error::Error;
use std::io::{self, Write};
use std::panic;
use std::path::{Path, PathBuf};
use std::time::Duration;
use std::{
env,
error::Error,
io::{self, Write},
panic,
path::{Path, PathBuf},
time::Duration,
};

use anyhow::Result;
use app::{Mode, TaskwarriorTui};
use crossterm::{
cursor,
event::{DisableMouseCapture, EnableMouseCapture, EventStream},
execute,
terminal::{disable_raw_mode, enable_raw_mode, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen},
};
use futures::stream::{FuturesUnordered, StreamExt};
use ratatui::{backend::CrosstermBackend, Terminal};

use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter};
use log4rs::{
append::file::FileAppender,
config::{Appender, Config, Logger, Root},
encode::pattern::PatternEncoder,
};
use path_clean::PathClean;
use ratatui::{backend::CrosstermBackend, Terminal};

use app::{Mode, TaskwarriorTui};

use crate::action::Action;
use crate::event::Event;
use crate::keyconfig::KeyConfig;
use crate::{action::Action, event::Event, keyconfig::KeyConfig};

const LOG_PATTERN: &str = "{d(%Y-%m-%d %H:%M:%S)} | {l} | {f}:{L} | {m}{n}";

Expand Down
Loading

0 comments on commit 11d95bc

Please sign in to comment.