diff options
| author | delta <darkussdelta@gmail.com> | 2025-10-29 16:35:38 +0100 |
|---|---|---|
| committer | delta <darkussdelta@gmail.com> | 2025-10-29 16:35:38 +0100 |
| commit | d7c66522cf365f516babcfeb1d4a2d36c3ea41af (patch) | |
| tree | 30c7d6103037b31170ae6d8fd58e3849e3cea823 | |
| parent | df418700b7d776f03ee5b58daa2d497cddb45aca (diff) | |
a small refactor
38 files changed, 1100 insertions, 1518 deletions
diff --git a/.config/awesome/misc/keys.lua b/.config/awesome/misc/keys.lua index 8d703b8..b36808b 100644 --- a/.config/awesome/misc/keys.lua +++ b/.config/awesome/misc/keys.lua @@ -132,15 +132,15 @@ awful.keyboard.append_global_keybindings { group = "awesome", desc = "toggle bar panel", }, - qbind { - mods = qbind.mods.M, - triggers = "l", - press = function() - powermenu:toggle() - end, - group = "awesome", - desc = "toggle powermenu", - }, + -- qbind { + -- mods = qbind.mods.M, + -- triggers = "l", + -- press = function() + -- powermenu:toggle() + -- end, + -- group = "awesome", + -- desc = "toggle powermenu", + -- }, qbind { triggers = "XF86AudioMute", @@ -305,7 +305,7 @@ awful.keyboard.append_global_keybindings { qbind { mods = qbind.mods.M, - triggers = "k", + triggers = "l", press = function() awful.spawn "xkblayout-state set +1" end, @@ -314,7 +314,7 @@ awful.keyboard.append_global_keybindings { }, qbind { mods = qbind.mods.MS, - triggers = "k", + triggers = "l", press = function() awful.spawn "xkblayout-state set -1" end, diff --git a/.config/awesome/prismite.lua b/.config/awesome/prismite.lua index 497a1b9..b9423e8 100644 --- a/.config/awesome/prismite.lua +++ b/.config/awesome/prismite.lua @@ -19,7 +19,6 @@ theme.fg_focus = qcolor.palette.fg() theme.fg_urgent = qcolor.palette.fg() theme.fg_minimize = qcolor.palette.fg() --- theme.useless_gap = dpi(2) theme.useless_gap = qui.PADDING / 2 theme.border_width = qui.BORDER_WIDTH theme.border_normal = qcolor.palette.border() @@ -34,9 +33,7 @@ theme.notification_max_width = qui.CHAR_WIDTH * 48 theme.notification_shape = qui.shape theme.notification_spacing = theme.useless_gap * 2 --- naughty.config.defaults.timeout = qvars.notif_timeout naughty.config.defaults.position = "bottom_right" --- naughty.config.defaults.border_width = qui.BORDER_WIDTH theme.tasklist_plain_task_name = true theme.enable_spawn_cursor = false diff --git a/.config/awesome/quarrel/init.lua b/.config/awesome/quarrel/init.lua deleted file mode 100644 index 5617c1a..0000000 --- a/.config/awesome/quarrel/init.lua +++ /dev/null @@ -1,12 +0,0 @@ -local n = require("naughty").notification - ----@class Quarrel -local quarrel = {} - ---- Send a notification with the specified message ----@param message any -function quarrel.debug(message) - n { message = tostring(message) } -end - -return quarrel diff --git a/.config/awesome/quarrel/native/Cargo.toml b/.config/awesome/quarrel/native/Cargo.toml index 2551507..1b98681 100644 --- a/.config/awesome/quarrel/native/Cargo.toml +++ b/.config/awesome/quarrel/native/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" [dependencies] freedesktop_entry_parser = "1.3.0" -cpc = "1.9.1" mlua = { version = "0.10.3", features = [ "module", "lua54", "serialize" ] } rayon = "1.6.1" serde = { version = "1.0.152", features = [ "derive" ] } @@ -23,6 +22,8 @@ ureq = "3.0.9" anyhow = { version = "1.0.97", features = ["backtrace"] } mdrop = { git = "https://github.com/frahz/mdrop" } sysinfo = "0.35.0" +fend-core = "1.5.7" +notify = "8.2.0" [lib] crate-type = ["cdylib"] diff --git a/.config/awesome/quarrel/native/init.lua b/.config/awesome/quarrel/native/init.lua index 6a823ba..fc0f4d3 100644 --- a/.config/awesome/quarrel/native/init.lua +++ b/.config/awesome/quarrel/native/init.lua @@ -8,11 +8,12 @@ package.cpath = package.cpath .. ";" .. cfg .. "quarrel/native/lib?.so" ---@field message string ---@field exec { [1]: string, [2]: boolean }? ----@alias query fun(input: string): Entry[] - ----@class Lenses ----@field [1] query Calculator lense ----@field [2] query Application lense +---@class Lense +---@field stale boolean +---@field name string +---@field query fun(self, input: string): (Entry|Entry[])? +---@field mark_stale fun(self) +---@field interrupt fun(self) ---@alias ReadMode "l" | "n" | string @@ -30,7 +31,7 @@ package.cpath = package.cpath .. ";" .. cfg .. "quarrel/native/lib?.so" ---@field get_essid fun(): string ---@class QuarrelNative ----@field lenses Lenses +---@field lenses Lense[] ---@field util Util ---@field net Net local qnative = require "qnative" diff --git a/.config/awesome/quarrel/native/libqnative.so b/.config/awesome/quarrel/native/libqnative.so index 5fc821d..e64f70a 120000 --- a/.config/awesome/quarrel/native/libqnative.so +++ b/.config/awesome/quarrel/native/libqnative.so @@ -1 +1 @@ -target/debug/libqnative.so
\ No newline at end of file +/home/delta/.config/awesome/quarrel/native/target/release/libqnative.so
\ No newline at end of file diff --git a/.config/awesome/quarrel/native/src/lenses/application.rs b/.config/awesome/quarrel/native/src/lenses/application.rs index 89b7bb4..38a7762 100644 --- a/.config/awesome/quarrel/native/src/lenses/application.rs +++ b/.config/awesome/quarrel/native/src/lenses/application.rs @@ -1,58 +1,118 @@ use std::{ - fs::read_dir, path::PathBuf + any::type_name, + fs::read_dir, + path::PathBuf, + sync::{ + atomic::{ + AtomicBool, + Ordering, + }, + Arc, + OnceLock, + RwLock, + }, }; use freedesktop_entry_parser as fd; use mlua::prelude::*; +use notify::RecommendedWatcher; use rayon::prelude::*; use url::Url; use crate::lenses::{ - Entry, - Lense, - Cache + Cache, Entries, Entry, Lense }; +static APPS_DIR: &'static str = "/usr/share/applications"; +static WATCHER: OnceLock<RecommendedWatcher> = OnceLock::new(); + #[derive(Default)] -pub struct Application(pub Cache); +pub struct Application { + cache: RwLock<Cache>, + should_interrupt: AtomicBool, +} impl Lense for Application { const NAME: &str = "Application"; - fn get_cache(&self) -> &Cache { - &self.0 + fn init() -> Arc<Self> { + let this = Arc::new(Application::default()); + let watcher_this = this.clone(); + WATCHER + .set( + notify::recommended_watcher(move |event| { + match event { + Ok(_) => { + // We don't care what specifically changed, just that *it did* + watcher_this.set_cache(Cache::Stale); + } + Err(err) => { + eprintln!("Watch error: {:?}", err) + } + } + }) + .expect("Failed to instantiate a watcher"), + ) + .expect("Failed to set a watcher"); + this + } + + #[inline] + fn set_cache(&self, cache: Cache) { + if let Err(err) = self.cache.write().map(|mut place| *place = cache) { + eprintln!( + "Failed to write cache value for {}: {:?}", + type_name::<Self>(), + err + ) + } + } + + #[inline] + fn get_cache(&self) -> Cache { + match self.cache.read() { + Ok(ok) => ok.clone(), + Err(err) => { + eprintln!( + "Failed to read cache value for {}: {:?}", + type_name::<Self>(), + err + ); + Cache::Stale + } + } + } + + #[inline] + fn set_interrupt(&self, interrupt: bool) { + // self.should_interrupt.store(interrupt, Ordering::Relaxed) } - fn set_cache(&mut self, cache: Cache) { - self.0 = cache; + #[inline] + fn get_interrupt(&self) -> bool { + false + // self.should_interrupt.load(Ordering::Relaxed) } - fn query(_: &Lua, input: String) -> Result<Vec<Entry>, anyhow::Error> { - let applications_dir = "/usr/share/applications"; - let entries = read_dir(applications_dir)? + fn entries(&self, _: &Lua, _: String) -> Result<Entries, anyhow::Error> { + let entries = read_dir(APPS_DIR)? .map(|result| result.map(|e| e.path())) .collect::<Result<Vec<_>, std::io::Error>>()?; - let parsed_entries: Vec<Entry> = entries + let parsed_entries: Entries = entries .into_par_iter() .filter(|path| path.extension().is_some_and(|ext| ext == "desktop")) - .filter_map(|path| { - parse_entry(path).ok().flatten() - }) - .collect(); + .filter_map(|path| parse_entry(path).ok().flatten()) + .collect::<Vec<Entry>>() + .into(); - Ok( - parsed_entries - .into_iter() - .filter(|entry| entry.message.to_lowercase().contains(&input.to_lowercase())) - .collect(), - ) + Ok(parsed_entries) } } fn parse_entry(path: PathBuf) -> Result<Option<Entry>, ()> { let Ok(entry) = fd::parse_entry(&path) else { - return Err(()) + return Err(()); }; let section = entry.section("Desktop Entry"); diff --git a/.config/awesome/quarrel/native/src/lenses/calculator.rs b/.config/awesome/quarrel/native/src/lenses/calculator.rs index 640bdeb..36f9805 100644 --- a/.config/awesome/quarrel/native/src/lenses/calculator.rs +++ b/.config/awesome/quarrel/native/src/lenses/calculator.rs @@ -1,40 +1,93 @@ -// use meval::eval_str; -use cpc::{ - eval, - units::Unit, +use std::sync::{ + atomic::{ + AtomicBool, + Ordering, + }, + Arc, + LazyLock, + Mutex, +}; + +use fend_core::{ + evaluate_with_interrupt, + Context, + Interrupt, }; use mlua::prelude::*; use crate::lenses::{ - Entry, - Cache, - Lense + Cache, Entries, Entry, Lense }; -pub struct Calculator; +static CTX: LazyLock<Mutex<Context>> = LazyLock::new(|| { + let mut ctx = Context::new(); + ctx.use_coulomb_and_farad(); + Mutex::new(ctx) +}); + +#[derive(Default)] +pub struct Calculator { + should_interrupt: AtomicBool, +} impl Lense for Calculator { const NAME: &str = "Calculator"; - fn get_cache(&self) -> &Cache { - &Cache::Stale + fn init() -> std::sync::Arc<Self> { + Arc::new(Calculator::default()) + } + + #[inline] + fn set_cache(&self, _: Cache) {} + + #[inline] + fn get_cache(&self) -> Cache { + Cache::Stale + } + + #[inline] + fn set_interrupt(&self, interrupt: bool) { + self.should_interrupt.store(interrupt, Ordering::Relaxed); } - fn set_cache(&mut self, _: Cache) {} + #[inline] + fn get_interrupt(&self) -> bool { + self.should_interrupt.load(Ordering::Relaxed) + } - fn query(_: &Lua, input: String) -> Result<Vec<Entry>, anyhow::Error> { - let result = match eval(input.trim(), true, Unit::Celsius, false) { + fn entries(&self, _: &Lua, input: String) -> Result<Entries, anyhow::Error> { + let result = match evaluate_with_interrupt( + input.trim(), + &mut CTX.lock().expect("Failed to acquire Fend context lock"), + self, + ) { Ok(result) => { - format!("{result}") + result.get_main_result().to_string() + } + Err(err) => { + err } - Err(err) => { return Err(anyhow::anyhow!(err)); }, }; - Ok(vec![Entry { + Ok(if result.is_empty() { + Entries::None + } else { + Entries::Single(Entry { message: result, exec: None, - }; 1] - ) + }) + }) + + } + + #[inline] + fn filter(&self, entries: Entries, _: String) -> Entries { + entries } } +impl Interrupt for Calculator { + fn should_interrupt(&self) -> bool { + self.should_interrupt.load(Ordering::Relaxed) + } +} diff --git a/.config/awesome/quarrel/native/src/lenses/mod.rs b/.config/awesome/quarrel/native/src/lenses/mod.rs index 6eb5b58..bb7f727 100644 --- a/.config/awesome/quarrel/native/src/lenses/mod.rs +++ b/.config/awesome/quarrel/native/src/lenses/mod.rs @@ -1,13 +1,66 @@ pub mod application; pub mod calculator; +use std::sync::Arc; + +use itertools::Itertools; use mlua::{ prelude::*, LuaSerdeExt, }; -use serde::{Serialize, Deserialize}; +use rayon::iter::FromParallelIterator; +use serde::{ + Deserialize, + Serialize, +}; + +#[derive(Clone, Debug)] +pub enum Entries { + Multiple(Vec<Entry>), + Single(Entry), + None +} -#[derive(Deserialize, Serialize, Clone)] +impl FromIterator<Entry> for Entries { + fn from_iter<T: IntoIterator<Item = Entry>>(iter: T) -> Self { + let mut iter = iter.into_iter(); + match (iter.next(), iter.next()) { + (None, None) => Self::None, + (Some(first), None) => Self::Single(first), + (None, Some(_)) => unreachable!(), + (Some(first), Some(second)) => { + let mut vec = Vec::from([first, second]); + vec.extend(iter); + Self::Multiple(vec) + }, + } + } +} + +impl From<Vec<Entry>> for Entries { + fn from(entries: Vec<Entry>) -> Self { + match entries.len() { + 0 => Self::None, + 1 => { + let entry = entries.into_iter().exactly_one().unwrap(); + Self::Single(entry) + }, + _ => Self::Multiple(entries) + } + } +} + +impl IntoLua for Entries { + fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> { + match self { + Entries::Multiple(entries) => entries.into_lua(lua), + Entries::Single(entry) => entry.into_lua(lua), + Entries::None => Ok(LuaValue::Nil) + } + } +} + +#[derive(Deserialize, Serialize, Clone, Debug)] pub struct Entry { pub message: String, pub exec: Option<(String, bool)>, @@ -15,7 +68,7 @@ pub struct Entry { impl IntoLua for Entry { fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> { - return lua.to_value(&self) + return lua.to_value(&self); } } @@ -25,55 +78,71 @@ impl FromLua for Entry { } } -#[derive(Default)] +#[derive(Default, Clone, Debug)] pub enum Cache { - Valid(Vec<Entry>), + Valid(Entries), #[default] - Stale + Stale, } -pub struct _Lense<T: Lense>(pub T); +pub struct _Lense<T: Lense>(pub Arc<T>); pub trait Lense { const NAME: &'static str; - fn set_cache(&mut self, cache: Cache); - fn get_cache(&self) -> &Cache; + fn init() -> Arc<Self>; + + fn set_cache(&self, cache: Cache); + fn get_cache(&self) -> Cache; + + fn set_interrupt(&self, interrupt: bool); + fn get_interrupt(&self) -> bool; - fn query(lua: &Lua, input: String) -> Result<Vec<Entry>, anyhow::Error>; + fn entries(&self, lua: &Lua, input: String) -> Result<Entries, anyhow::Error>; + fn filter(&self, entries: Entries, input: String) -> Entries { + let entry_contains = |entry: &Entry| { + entry.message.to_lowercase().contains(&input.to_lowercase()) + }; + match entries { + Entries::Multiple(entries) => entries.into_iter() + .filter(entry_contains) + .collect(), + Entries::Single(entry) => if entry_contains(&entry) { Entries::Single(entry) } else { Entries::None } + Entries::None => Entries::None + } + } } impl<T: Lense + 'static> LuaUserData for _Lense<T> { fn add_fields<F: LuaUserDataFields<Self>>(fields: &mut F) { - // fields.add_field_method_get("cache", |lua, this| { - // let cache = this.0.get_cache(); - // match cache { - // Cache::Valid(cache) => Ok(cache.clone().into_lua(lua)?), - // Cache::Stale => Ok(LuaNil) - // } - // }); - - // fields.add_field_method_set("cache", |_, this, cache: Vec<Entry>| { - // Ok(this.0.set_cache(Cache::Valid(cache))) - // }); - - fields.add_field_method_get("stale", |_, this| Ok(matches!(this.0.get_cache(), Cache::Stale))); + fields.add_field_method_get("stale", |_, this| { + Ok(matches!(this.0.get_cache(), Cache::Stale)) + }); fields.add_field("name", T::NAME); } fn add_methods<M: LuaUserDataMethods<Self>>(methods: &mut M) { methods.add_method_mut("query", |lua, this, input: String| { + this.0.set_interrupt(false); // reset interrupt so that we can use the lense again return Ok(match this.0.get_cache() { - Cache::Valid(entries) => entries.clone(), + Cache::Valid(entries) => this.0.filter(entries.clone(), input), Cache::Stale => { - let entries = T::query(lua, input).map_err(LuaError::external)?; + let entries = this.0.entries(lua, input.clone()).map_err(LuaError::external)?; + let mut entries = this.0.filter(entries, input); + match entries { + Entries::Multiple(ref mut entries) => entries.sort_by(|a, b| a.message.cmp(&b.message)), + _ => {} + } this.0.set_cache(Cache::Valid(entries.clone())); entries } }); }); - methods.add_method_mut("mark_stale", |_, this, _: ()| Ok(this.0.set_cache(Cache::Stale)) ); + methods.add_method_mut("mark_stale", |_, this, _: ()| { + Ok(this.0.set_cache(Cache::Stale)) + }); + methods.add_method_mut("interrupt", |_, this, _: ()| Ok(this.0.set_interrupt(true))); } } diff --git a/.config/awesome/quarrel/native/src/lib.rs b/.config/awesome/quarrel/native/src/lib.rs index 4f1780d..239ed2f 100644 --- a/.config/awesome/quarrel/native/src/lib.rs +++ b/.config/awesome/quarrel/native/src/lib.rs @@ -1,19 +1,19 @@ mod lenses; mod net; // mod http; -mod util; mod moondrop; +mod util; +use lenses::_Lense; use mlua::prelude::*; -use lenses::{ _Lense }; + +use crate::lenses::Lense; #[mlua::lua_module] fn qnative(lua: &Lua) -> LuaResult<LuaTable> { let lenses = lua.create_table()?; - lenses.push(_Lense(lenses::calculator::Calculator))?; - lenses.push(_Lense(lenses::application::Application::default()))?; - // lenses.set("1", lua.create_function(lenses::calculator::Application::query)?)?; - // lenses.set("2", lua.create_function(lenses::application::Application::query)?)?; + lenses.push(_Lense(lenses::calculator::Calculator::init()))?; + lenses.push(_Lense(lenses::application::Application::init()))?; let util = lua.create_table()?; util.set("decode_html", lua.create_function(util::decode_html)?)?; diff --git a/.config/awesome/quarrel/native/src/moondrop.rs b/.config/awesome/quarrel/native/src/moondrop.rs index d416ef6..62a8ea0 100644 --- a/.config/awesome/quarrel/native/src/moondrop.rs +++ b/.config/awesome/quarrel/native/src/moondrop.rs @@ -1,3 +1 @@ use mdrop::Moondrop; - - diff --git a/.config/awesome/quarrel/native/src/net/mod.rs b/.config/awesome/quarrel/native/src/net/mod.rs index dbd87b9..383e800 100644 --- a/.config/awesome/quarrel/native/src/net/mod.rs +++ b/.config/awesome/quarrel/native/src/net/mod.rs @@ -9,7 +9,10 @@ use std::{ c_void, }, mem::size_of, - os::fd::{IntoRawFd, RawFd}, + os::fd::{ + IntoRawFd, + RawFd, + }, }; use mlua::prelude::*; diff --git a/.config/awesome/quarrel/native/src/util.rs b/.config/awesome/quarrel/native/src/util.rs index 41096d8..5b9c5f5 100644 --- a/.config/awesome/quarrel/native/src/util.rs +++ b/.config/awesome/quarrel/native/src/util.rs @@ -4,7 +4,7 @@ use std::{ io::{ Read, Seek, - Write + Write, }, rc::Rc, str::FromStr, diff --git a/.config/awesome/quarrel/table.lua b/.config/awesome/quarrel/table.lua index 2ae15ee..49ed45e 100644 --- a/.config/awesome/quarrel/table.lua +++ b/.config/awesome/quarrel/table.lua @@ -35,6 +35,14 @@ function qtable.filter(t, f, dict) return nt end +--- Get a slice of a table +---@param t table +---@param i integer start of the slice +---@param j integer end of the slice (inclusive) +function qtable.slice(t, i, j) + return { table.unpack(t, i, j) } +end + -- This is taken from http://lua-users.org/wiki/SortedIteration -- This version is stripped of comments and empty lines + some stuff is renamed diff --git a/.config/awesome/quarrel/ui/init.lua b/.config/awesome/quarrel/ui/init.lua index 5acaa51..2b63694 100644 --- a/.config/awesome/quarrel/ui/init.lua +++ b/.config/awesome/quarrel/ui/init.lua @@ -36,6 +36,28 @@ function M.styled(target) }, target) end +--- Wraps a widget inside of a margin widget +---@param target table +---@return table +function M.padded(target) + return { + widget = wibox.container.margin, + margins = M.PADDING, + target, + } +end + +--- Wraps a widget inside of a margin widget +---@param target table +---@return table +function M.padded_big(target) + return { + widget = wibox.container.margin, + margins = M.BIG_PADDING, + target, + } +end + --- Generates a styled popup ---@param target table ---@return table @@ -59,6 +81,18 @@ end --- Generates icon widget ---@param args table ---@return table +function M.separator(args) + return wibox.widget(gtable.crush({ + widget = wibox.container.background, + bg = qcolor.palette.border(), + forced_height = not args.vertical and args.size, + forced_width = args.vertical and args.size, + }, args.widget or {})) +end + +--- Generates icon widget +---@param args table +---@return table function M.icon(args) return wibox.widget(gtable.crush({ widget = wibox.widget.imagebox, diff --git a/.config/awesome/ui/conductor/init.lua b/.config/awesome/ui/conductor/init.lua deleted file mode 100644 index 402945c..0000000 --- a/.config/awesome/ui/conductor/init.lua +++ /dev/null @@ -1,64 +0,0 @@ -local awful = require "awful" -local gshape = require "gears.shape" -local phosphor = require "assets.phosphor" -local q = require "quarrel" -local qui = require "quarrel.ui" -local qvars = require "quarrel.vars" -local wibox = require "wibox" - -local M = {} - -M._popup = qui.popup { - -- visible = false, - ontop = true, - placement = "right", - shape = function(cr, w, h) - gshape.partially_rounded_rect(cr, w, h, true, false, false, true, qui.BORDER_RADIUS) - end, - -- x = awful.screen.focused().geometry.width, - -- minimum_width = width, - -- maximum_width = width, - -- maximum_height = max_height, - widget = awful.widget.tasklist { - screen = awful.screen.focused(), - filter = awful.widget.tasklist.filter.allscreen, - layout = { - spacing = qui.BIG_PADDING, - layout = wibox.layout.fixed.vertical, - }, - widget_template = qui.styled { - widget = wibox.container.background, - { - { - widget = wibox.container.constraint, - strategy = "max", - height = qui.CHAR_HEIGHT, - width = qui.CHAR_HEIGHT, - { - widget = wibox.widget.imagebox, - id = "icon_role", - }, - }, - { - widget = wibox.container.constraint, - strategy = "max", - width = qui.CHAR_WIDTH * 24, - { - widget = wibox.widget.textbox, - id = "client_name", - }, - }, - layout = wibox.layout.fixed.horizontal, - spacing = qui.PADDING, - }, - create_callback = function(self, c) - self:get_children_by_id("client_name")[1].text = c.icon_name - end, - update_callback = function(self, c) - self:get_children_by_id("client_name")[1].text = c.name - end, - }, - }, -} - -return M diff --git a/.config/awesome/ui/fresnel/init.lua b/.config/awesome/ui/fresnel/init.lua index 5d091b6..dc8e333 100644 --- a/.config/awesome/ui/fresnel/init.lua +++ b/.config/awesome/ui/fresnel/init.lua @@ -1,5 +1,6 @@ -local al_prompt = require "lib.bling.widget.app_launcher.prompt" +local text_input = require "ui.fresnel.text_input" local awful = require "awful" +local qdebug = require "quarrel.debug" local cfg = require "misc.cfg" local gshape = require "gears.shape" local gtable = require "gears.table" @@ -13,19 +14,142 @@ local rubato = require "lib.rubato" local wibox = require "wibox" local btn = awful.button.names -local max_entries = 10 +local MAX_VISIBLE_ENTRIES = 10 +local DEFAULT_SCROLL_AMOUNT = 0 +local DEFAULT_SELECTED_IDX = 1 -local fresnel = {} +---@class (exact) Fresnel +---@field private _toggled boolean Whether fresnel is open +---@field private _entries (Entry|string)[] +---@field private _scroll_amount integer How many entries down are we +---@field private _prev_scroll_amount integer The _scroll_amount of the previous cycle +---@field private _visible_entries Entry[] The currently visible entries +---@field private _selected_idx integer The index of the currently selected entry. Is in the range 1.. +---@field private _prev_selected_idx integer The _selected_idx of the previous cycle +---@field private _active_lenses integer The number of lense titles in the _entries table +---@field private _lense_header_positions integer[] The positions of all the lense titles +---@field private _prev_text string +---@field private _first_query boolean +---@field private _make_header fun(string): wibox.container.background +---@field private _w_popup wibox.widget.base +---@field private _w_prompt wibox.widget.base +---@field private _w_status wibox.widget.base +---@field private _l_entries wibox.widget.base +---@field private _t_opacity table +---@field private _t_height table +local fresnel = { + _toggled = false, + _entries = {}, + _scroll_amount = DEFAULT_SCROLL_AMOUNT, + _prev_scroll_amount = DEFAULT_SCROLL_AMOUNT, + _visible_entries = {}, + _selected_idx = DEFAULT_SELECTED_IDX, + _prev_selected_idx = DEFAULT_SELECTED_IDX, + _lense_header_positions = {} +} -fresnel._toggled = false -fresnel._entries_exec = {} -fresnel._entries_offset = 0 -fresnel._entries_count = 0 -fresnel._visible_entries = 0 -fresnel._selected_index = 1 +---@private +---@param lense_name string +function fresnel._make_header(lense_name) + return wibox.widget { + widget = wibox.container.background, + fg = qcolor.palette.fg.low, + { + widget = wibox.container.margin, + margins = qui.PADDING, + { + { + widget = wibox.container.place, + { + widget = wibox.container.background, + bg = qcolor.palette.border(), + forced_height = qui.BORDER_WIDTH, + forced_width = qui.BIG_PADDING * 2, + }, + }, + { + widget = wibox.container.constraint, + strategy = "max", + height = qui.CHAR_HEIGHT, + { + widget = wibox.widget.textbox, + text = lense_name, + }, + }, + { + widget = wibox.container.place, + fill_horizontal = true, + content_fill_horizontal = true, + { + widget = wibox.container.background, + bg = qcolor.palette.border(), + forced_height = qui.BORDER_WIDTH, + }, + }, + layout = wibox.layout.fixed.horizontal, + spacing = qui.BIG_PADDING, + }, + }, + } +end -function fresnel:_exec_entry(entry_index) - local exec = self._entries_exec[entry_index] +---@private +---@param entry Entry +function fresnel:_make_entry(entry) + ---@class FresnelEntry : wibox.widget.base + ---@field _selected boolean + local entry_widget = wibox.widget { + widget = wibox.container.background, + shape = qui.shape, + { + widget = wibox.container.margin, + margins = qui.PADDING, + { + widget = wibox.container.constraint, + strategy = "max", + height = qui.CHAR_HEIGHT, + { + widget = wibox.widget.textbox, + text = entry.message, + }, + }, + }, + buttons = { + awful.button { + modifiers = {}, + button = btn.LEFT, + on_press = function() + fresnel:_exec_entry(entry) + end, + }, + }, + _selected = false, + } + + entry_widget:connect_signal("mouse::enter", function() + if entry_widget._selected == true then + return + end + entry_widget.bg = qcolor.palette.bg.high + end) + + entry_widget:connect_signal("mouse::leave", function() + if entry_widget._selected == true then + return + end + entry_widget.bg = qcolor.palette.bg() + end) + + return entry_widget +end + +---@private +---@param entry integer|Entry +function fresnel:_exec_entry(entry) + if type(entry) == "number" then + entry = self._visible_entries[entry] + end + local exec = entry.exec if type(exec) ~= "userdata" and type(exec) ~= "nil" then if exec[2] then awful.spawn(cfg.terminal .. " -e /bin/sh -c " .. exec[1] .. " 1>/dev/null 2>&1") @@ -35,172 +159,166 @@ function fresnel:_exec_entry(entry_index) end end -function fresnel:_update(query, scrolled) +---@private +---@param query string? +function fresnel:_update(query) query = query or "" - scrolled = scrolled or false + self._entries = {} + self._lense_header_positions = {} + self._active_lenses = 0 - if not scrolled then - self._selected_index = 1 - self._entries_offset = 0 + for _, lense in ipairs(qnative.lenses) do + local entries = lense:query(query) + if type(entries) == "table" then + table.insert(self._entries, lense.name) + table.insert(self._lense_header_positions, #self._entries) + if #entries > 0 then -- Entry[] + self._entries = gtable.join(self._entries, entries) + elseif entries.message then -- Entry + table.insert(self._entries, entries) + end + self._active_lenses = self._active_lenses + 1 + end -- either empty Entry[] or nil, in which case we shouldn't display them end - local layout = self._popup.widget:get_children_by_id("entry_layout")[1] - local status = self._popup.widget:get_children_by_id("status")[1] - local all_providers = {} - local entries_count = 0 + -- reset the scroll + if type(self._entries[1]) == "string" then + self._selected_idx = 2 -- to avoid selecting the header first + else + self._selected_idx = DEFAULT_SELECTED_IDX + end + self._scroll_amount = DEFAULT_SCROLL_AMOUNT + fresnel:_render(true) + self._first_query = false +end - self._entries_exec = {} - layout:reset() +---@private +---@param update boolean +function fresnel:_render(update) + local visible_entries_end = math.min(self._scroll_amount + MAX_VISIBLE_ENTRIES, #self._entries) + self._visible_entries = qtable.slice(self._entries, self._scroll_amount + 1, visible_entries_end) - for _, provider in qtable.opairs(qnative.lenses) do - local entries = provider(query) + local layout = fresnel._l_entries - table.sort(entries, function(a, b) - return a.message < b.message - end) + if self._scroll_amount ~= self._prev_scroll_amount or update or self._first_query then + layout:reset() + for i, entry in ipairs(self._visible_entries) do + if type(entry) == "string" then + layout:add(self._make_header(entry)) + else + local entry_widget = self:_make_entry(entry) + if self._selected_idx == i then + entry_widget._selected = true + entry_widget.bg = qcolor.palette.bg.high + end + layout:add(entry_widget) + end + end + elseif self._selected_idx ~= self._prev_selected_idx then + local entry_widget = layout.children[self._selected_idx] --[[@as FresnelEntry ]] + entry_widget._selected = true + entry_widget.bg = qcolor.palette.bg.high - all_providers = gtable.join(all_providers, entries) + local prev_entry_widget = layout.children[self._prev_selected_idx] --[[@as FresnelEntry ]] + prev_entry_widget._selected = false + prev_entry_widget.bg = qcolor.palette.bg() end - self._entries_count = #all_providers - - for i, entry in ipairs(all_providers) do - if i > self._entries_offset then - if entries_count == max_entries then - break - end - table.insert(self._entries_exec, entry.exec) - - local entry_widget = wibox.widget { - widget = wibox.container.background, - shape = qui.shape, - { - widget = wibox.container.margin, - margins = qui.PADDING, - { - widget = wibox.container.constraint, - strategy = "max", - height = qui.CHAR_HEIGHT, - { - { - widget = wibox.container.background, - fg = qcolor.palette.low, - { - widget = wibox.widget.textbox, - text = entry.provider .. " | ", - }, - }, - { - widget = wibox.widget.textbox, - text = entry.message, - }, - spacing = qui.PADDING, - layout = wibox.layout.fixed.horizontal, - }, - }, - }, - buttons = { - awful.button { - modifiers = {}, - button = btn.LEFT, - on_press = function() - self:_exec_entry(i) - end, - }, - }, - _selected = false, - } + local headers_passed = 0 + local current_position = self._scroll_amount + self._selected_idx + for _, position in ipairs(self._lense_header_positions) do + if current_position > position then + headers_passed = headers_passed + 1 + end + end + self._w_status.text = (self._scroll_amount + self._selected_idx - headers_passed) .. "/" .. (#self._entries - self._active_lenses) + self._prev_scroll_amount = self._scroll_amount + self._prev_selected_idx = self._selected_idx +end - if self._selected_index + self._entries_offset == i then - entry_widget._selected = true - entry_widget.bg = qcolor.palette.bg.high - end +---@param up boolean Whether to scroll up or down +function fresnel:scroll(up) + local direction = up and -1 or 1 + local offset = direction - entry_widget:connect_signal("mouse::enter", function() - if entry_widget._selected == true then - return - end - entry_widget.bg = qcolor.palette.bg.high - end) - entry_widget:connect_signal("mouse::leave", function() - if entry_widget._selected == true then - return - end - entry_widget.bg = qcolor.palette.bg() - end) + if type(self._entries[self._scroll_amount + self._selected_idx + offset]) == "string" then + offset = offset + direction + end - layout:add(entry_widget) + local new_selected_idx = self._selected_idx + offset + local new_position = self._scroll_amount + new_selected_idx + local new_scroll_amount = self._scroll_amount + offset - entries_count = entries_count + 1 - self._visible_entries = entries_count + if new_position < 1 then + if self._scroll_amount > 0 then + self._scroll_amount = self._scroll_amount + direction + self._selected_idx = self._selected_idx - direction + self:_render(false) end + return + elseif new_position > #self._entries then + return + end + + if up and new_selected_idx <= 0 then + self._scroll_amount = new_scroll_amount + elseif not up and new_selected_idx > #self._visible_entries then + self._scroll_amount = new_scroll_amount + else + self._selected_idx = new_selected_idx end - status.text = self._entries_offset + self._selected_index .. "/" .. self._entries_count + self:_render(false) end -fresnel._text = "" -fresnel._prompt = al_prompt { - prompt = "", - reset_on_stop = true, - ul_cursor = "low", - bg_cursor = qcolor.palette.bg.high, - changed_callback = function(text) - if fresnel._text == text then - return - end - if fresnel._toggled == false then - return - end - fresnel:_update(text) - fresnel._text = text - end, - keypressed_callback = function(mod, key) - if key == "Escape" or key == " " and mod.Mod4 then - fresnel:hide() - elseif key == "Return" then - fresnel:_exec_entry(fresnel._selected_index) - fresnel:hide() - elseif key == "Up" then - local next_index = fresnel._selected_index - 1 - if next_index < 1 and fresnel._entries_offset == 0 then - return - elseif next_index < 1 and fresnel._entries_offset > 0 then - fresnel._entries_offset = fresnel._entries_offset - 1 - else - fresnel._selected_index = next_index - end +fresnel._prev_text = "" +fresnel._w_prompt = wibox.widget { + widget = text_input, + reset_on_unfocus = true, + unfocus_keys = {}, +} - fresnel:_update(fresnel._text, true) - elseif key == "Down" then - local next_index = fresnel._selected_index + 1 - if - next_index > fresnel._visible_entries - and fresnel._entries_offset + fresnel._visible_entries == fresnel._entries_count - then - return - elseif - next_index > fresnel._visible_entries - and fresnel._entries_offset + fresnel._visible_entries < fresnel._entries_count - then - fresnel._entries_offset = fresnel._entries_offset + 1 - else - fresnel._selected_index = next_index - end +fresnel._w_prompt:connect_signal("unfocus", function () + fresnel:_hide() +end) - fresnel:_update(fresnel._text, true) - end - end, -} +fresnel._w_prompt:connect_signal("property::text", function(_, text) + fresnel:_update(text) +end) + +fresnel._w_prompt:connect_signal("key::press", function(_, _mods, key) + -- Convert index array to hash table + local mods = {} + for _, v in ipairs(_mods) do + mods[v] = true + end + + if key == "Escape" or key == " " and mods.Mod4 then + fresnel:hide() + elseif key == "Return" then + fresnel:_exec_entry(fresnel._selected_idx) + fresnel:hide() + elseif key == "k" and mods.Mod1 then + fresnel:scroll(true) + elseif key == "j" and mods.Mod1 then + fresnel:scroll(false) + end +end) local max_height = qui.BIG_PADDING * 2 + (qui.BIG_PADDING * 2 + qui.CHAR_HEIGHT) * 10 --- + qui.PADDING --- + qui.PADDING * 9 local width = awful.screen.focused().geometry.width / 2 -fresnel._popup = qui.popup { +fresnel._l_entries = wibox.widget { + spacing = qui.PADDING, + layout = wibox.layout.fixed.vertical, +} +fresnel._w_status = wibox.widget { + widget = wibox.widget.textbox, + text = "0/0", +} +fresnel._w_popup = qui.popup { -- visible = false, ontop = true, placement = false, @@ -222,7 +340,7 @@ fresnel._popup = qui.popup { { { widget = wibox.widget.textbox, - text = ">", + markup = [[<span foreground="]] .. qcolor.palette.yellow() .. [[">></span>]], }, { widget = wibox.container.margin, @@ -237,15 +355,11 @@ fresnel._popup = qui.popup { { widget = wibox.container.background, fg = qcolor.palette.fg(), - fresnel._prompt.textbox, + fresnel._w_prompt, }, }, }, - { - widget = wibox.widget.textbox, - text = "0/0", - id = "status", - }, + fresnel._w_status, layout = wibox.layout.align.horizontal, }, }, @@ -255,52 +369,60 @@ fresnel._popup = qui.popup { margins = { top = qui.PADDING, }, - { - spacing = qui.PADDING, - layout = wibox.layout.fixed.vertical, - id = "entry_layout", - }, + fresnel._l_entries, }, layout = wibox.layout.align.vertical, }, } + function fresnel:show() + self._prev_scroll_amount = DEFAULT_SCROLL_AMOUNT + self._prev_selected_idx = DEFAULT_SELECTED_IDX + self._first_query = true self._toggled = true - self._opacity_timed.target = 1 - self._height_timed:set(max_height) + self._t_opacity.target = 1 + self._t_height:set(max_height) self:_update() - self._prompt:start() + self._w_prompt:focus() end -function fresnel:hide() +---@private +function fresnel:_hide() self._toggled = false - self._opacity_timed.target = 0 - self._height_timed:set(0) - self._prompt:stop() + self._t_opacity.target = 0 + self._t_height:set(0) + for _, lense in ipairs(qnative.lenses) do + lense:interrupt() + end +end + +function fresnel:hide() + self._w_prompt:unfocus() + self:_hide() end -fresnel._height_timed = qanim:new { +fresnel._t_height = qanim:new { duration = qvars.anim_duration, pos = 0, easing = qvars.easing, subscribed = function(pos) - fresnel._popup.shape = function(cr, w) + fresnel._w_popup.shape = function(cr, w) gshape.partially_rounded_rect(cr, w, pos, false, false, true, true, qui.BORDER_RADIUS) end end, } -- TODO: optimize the search algo to be more efficient and not require making fresnel invisible -fresnel._opacity_timed = rubato.timed { +fresnel._t_opacity = rubato.timed { duration = qvars.anim_duration, pos = 0, subscribed = function(pos) - fresnel._popup.opacity = pos + fresnel._w_popup.opacity = pos if pos == 0 then - fresnel._popup.visible = false + fresnel._w_popup.visible = false else - fresnel._popup.visible = true + fresnel._w_popup.visible = true end end, } diff --git a/.config/awesome/ui/init.lua b/.config/awesome/ui/init.lua index 6ad1c7b..8ba64f9 100644 --- a/.config/awesome/ui/init.lua +++ b/.config/awesome/ui/init.lua @@ -1,4 +1,4 @@ require "ui.statusbar" require "ui.decorations" --- require "ui.conductor" +-- require "ui.tidy" -- require "ui.osd" diff --git a/.config/awesome/ui/statusbar/panel/widgets/mpris.lua b/.config/awesome/ui/statusbar/panel/widgets/mpris.lua index c27bf66..687bbb1 100644 --- a/.config/awesome/ui/statusbar/panel/widgets/mpris.lua +++ b/.config/awesome/ui/statusbar/panel/widgets/mpris.lua @@ -99,11 +99,8 @@ M.widget = wibox.widget(qui.styled { { widget = client_background, { - widget = wibox.container.margin, - margins = qui.BIG_PADDING, - { nil, - { + qui.padded_big { { { widget = wibox.container.background, @@ -122,7 +119,6 @@ M.widget = wibox.widget(qui.styled { }, { widget = wibox.container.margin, - right = qui.BIG_PADDING, left = qui.BIG_PADDING, { { @@ -160,7 +156,6 @@ M.widget = wibox.widget(qui.styled { { widget = wibox.container.margin, top = qui.BIG_PADDING, - right = qui.BIG_PADDING, { { widget = wibox.widget.textbox, @@ -188,12 +183,22 @@ M.widget = wibox.widget(qui.styled { layout = wibox.layout.align.vertical, }, { - layout = wibox.layout.flex.vertical, - spacing = qui.BIG_PADDING, - id = "client_list", + qui.separator { + size = qui.BORDER_WIDTH, + vertical = true + }, + { + widget = wibox.container.background, + bg = qcolor.palette.bg.high, + qui.padded_big { + layout = wibox.layout.flex.vertical, + spacing = qui.BIG_PADDING, + id = "client_list", + } + }, + layout = wibox.layout.fixed.horizontal, }, layout = wibox.layout.align.horizontal, - }, }, }, }) diff --git a/.config/awesome/ui/wicked/consts.lua b/.config/awesome/ui/wicked/consts.lua index e00cae5..c864483 100644 --- a/.config/awesome/ui/wicked/consts.lua +++ b/.config/awesome/ui/wicked/consts.lua @@ -1,5 +1,13 @@ +local qcolor = require "quarrel.color" + local C = {} C.NOTIF_TIMEOUT = 3 +C.LEVEL_COLORS = { + debug = qcolor.palette.purple(), + info = qcolor.palette.blue(), + warn = qcolor.palette.orange(), + error = qcolor.palette.red(), +} return C diff --git a/.config/awesome/ui/wicked/init.lua b/.config/awesome/ui/wicked/init.lua index dea28d5..dd3324d 100644 --- a/.config/awesome/ui/wicked/init.lua +++ b/.config/awesome/ui/wicked/init.lua @@ -8,13 +8,14 @@ local qvars = require "quarrel.vars" local wibox = require "wibox" local rtimed = require("lib.rubato").timed local easing = require("lib.rubato").easing +local consts = require "ui.wicked.consts" local gtimer = require "gears.timer" local qcolor = require "quarrel.color" local qmarkup = require "quarrel.markup" local M = require "ui.wicked.consts" -function M.new(n) +function M.new(n, _, n_args) local intertext_margin = (n.title ~= "" or n.message ~= "") and qui.PADDING or 0 local title_height = n.title ~= "" and qui.CHAR_HEIGHT or 0 local message_height = n.message ~= "" and qui.CHAR_HEIGHT or 0 @@ -25,7 +26,33 @@ function M.new(n) app_name = n.app_name end - local notif = naughty.layout.box { + local w_progress, t_progress + + local level_color = consts.LEVEL_COLORS[n_args.level] or (n.urgency == "critical" and qcolor.palette.yellow()) + + if n.timeout > 0 then + w_progress = wibox.widget { + widget = wibox.container.radialprogressbar, + max_value = M.NOTIF_TIMEOUT, + border_color = qcolor.palette.bg.lowest, + color = qcolor.palette.yellow(), + border_width = qui.PADDING / 2, + forced_height = qui.CHAR_HEIGHT, + forced_width = qui.CHAR_HEIGHT, + } + + t_progress = rtimed { + duration = n.timeout, + pos = 0, + easing = easing.none, + clamp_position = true, + subscribed = function(pos) + w_progress.value = pos + end, + } + end + + local w_notif = naughty.layout.box { notification = n, placement = function(d) return awful.placement.right(d, { @@ -50,6 +77,8 @@ function M.new(n) { qui.styled { widget = wibox.container.background, + forced_width = beautiful.notification_max_width, + -- border_color = border_color, point = function(geo, args) return { x = args.parent.width, @@ -57,114 +86,111 @@ function M.new(n) } end, { + widget = wibox.container.margin, + margins = qui.BIG_PADDING, { - widget = wibox.container.margin, - margins = qui.BIG_PADDING, - { - { - widget = wibox.widget.textbox, - markup = qmarkup(app_name, { bold = true }), - }, - nil, - { - - widget = wibox.container.radialprogressbar, - max_value = M.NOTIF_TIMEOUT, - border_color = qcolor.palette.bg.lowest, - color = qcolor.palette.yellow(), - border_width = qui.BORDER_WIDTH, - forced_height = qui.CHAR_HEIGHT, - forced_width = qui.CHAR_HEIGHT, - id = "progress", - }, - layout = wibox.layout.align.horizontal, - }, - }, - { - widget = wibox.container.constraint, - height = qui.BORDER_WIDTH, - width = beautiful.notification_max_width, - strategy = "exact", - { - widget = wibox.container.background, - bg = qcolor.palette.border(), - }, - }, - { - widget = wibox.container.margin, - margins = qui.BIG_PADDING, { widget = wibox.container.constraint, - height = n.icon and qui.CHAR_HEIGHT * 2 + qui.PADDING - or (title_height + message_height + intertext_margin), - strategy = "exact", + width = beautiful.notification_max_width - (qui.BIG_PADDING + qui.BORDER_WIDTH) * 2 - (level_color and qui.BIG_PADDING + qui.PADDING or 0), + strategy = "max", { + widget = wibox.container.place, + content_fill_horizontal = true, { - widget = wibox.container.background, { - widget = naughty.widget.icon, - shape = qui.shape, - notification = n, + { + widget = wibox.widget.textbox, + markup = qmarkup(app_name, { bold = true }), + }, + nil, + w_progress, + layout = wibox.layout.align.horizontal, }, - }, - { { widget = wibox.container.constraint, - height = title_height, + height = qui.BORDER_WIDTH, strategy = "exact", { - widget = wibox.widget.textbox, - text = n.title or "", + widget = wibox.container.background, + bg = qcolor.palette.border(), }, }, { widget = wibox.container.constraint, - height = message_height, + height = n.icon and qui.CHAR_HEIGHT * 2 + qui.PADDING + or (title_height + message_height + intertext_margin), strategy = "exact", { - widget = wibox.widget.textbox, - text = n.message or "", + { + widget = naughty.widget.icon, + shape = qui.shape, + notification = n, + }, + { + { + widget = wibox.container.constraint, + height = title_height, + strategy = "exact", + { + widget = wibox.widget.textbox, + text = n.title or "", + }, + }, + { + widget = wibox.container.constraint, + height = message_height, + strategy = "exact", + { + widget = wibox.widget.textbox, + text = n.message or "", + }, + }, + spacing = intertext_margin, + layout = wibox.layout.fixed.vertical, + }, + fill_space = true, + spacing = n.icon and qui.BIG_PADDING, + layout = wibox.layout.fixed.horizontal, }, }, - spacing = intertext_margin, layout = wibox.layout.fixed.vertical, + spacing = qui.BIG_PADDING, }, - fill_space = true, - spacing = n.icon and qui.BIG_PADDING or nil, - layout = wibox.layout.fixed.horizontal, }, }, + -- { + -- widget = wibox.container.constraint, + -- strategy = "max", + -- widget = wibox.container.place, + { + forced_width = qui.PADDING, + widget = wibox.container.background, + bg = level_color, + shape = qui.shape, + -- }, + }, + layout = wibox.layout.fixed.horizontal, + spacing = level_color and qui.BIG_PADDING, + -- expand = "outside" }, - layout = wibox.layout.fixed.vertical, }, id = "bg", }, layout = wibox.layout.manual, - id = "manual", }, }, } local hiding = false - local old_destroy = notif._private.destroy_callback + local old_destroy = w_notif._private.destroy_callback - local progress = rtimed { - duration = n.timeout, - pos = 0, - easing = easing.none, - clamp_position = true, - subscribed = function(pos) - notif.widget:get_children_by_id("progress")[1].value = pos - end, - } - - local position = qanim:new { + local t_position = qanim:new { duration = qvars.anim_duration, pos = 0, easing = qvars.easing, subscribed = function(pos) gtimer.delayed_call(function() - notif.widget.widget:move(1, function(geo, args) + w_notif.widget.widget:move(1, function(geo, args) if pos == 0 and hiding then old_destroy() end @@ -176,30 +202,30 @@ function M.new(n) end) end, } - local opacity = rtimed { + local t_opacity = rtimed { duration = qvars.anim_duration, intro = qvars.anim_intro, easing = easing.quadratic, pos = 0, clamp_position = true, subscribed = function(pos) - notif.opacity = pos + w_notif.opacity = pos end, } - n:disconnect_signal("destroyed", notif._private.destroy_callback) - function notif._private.destroy_callback() - opacity.target = 0 - position:set(0) + n:disconnect_signal("destroyed", w_notif._private.destroy_callback) + function w_notif._private.destroy_callback() + t_opacity.target = 0 + t_position:set(0) hiding = true end - n:weak_connect_signal("destroyed", notif._private.destroy_callback) + n:weak_connect_signal("destroyed", w_notif._private.destroy_callback) - --- for some reason when urgency is critical, it somehow makes it not disappear - --- why? dunno, FIXME - opacity.target = 1 - position:set(beautiful.notification_max_width) - progress.target = M.NOTIF_TIMEOUT + t_opacity.target = 1 + t_position:set(beautiful.notification_max_width) + if t_progress then + t_progress.target = M.NOTIF_TIMEOUT + end end return setmetatable(M, { diff --git a/.config/fish/colors.fish b/.config/fish/colors.fish index 381b0e9..fdc8987 100644 --- a/.config/fish/colors.fish +++ b/.config/fish/colors.fish @@ -9,15 +9,15 @@ set fish_color_error white set fish_color_param white set fish_color_valid_path white set fish_color_option white -set fish_color_comment "#77828c" +set fish_color_comment "#a8afb7" set fish_color_operator white set fish_color_escape yellow -set fish_color_autosuggestion "#77828c" +set fish_color_autosuggestion "#a8afb7" set fish_color_search_match --background=black # pager -set fish_pager_color_progress "#77828c" +set fish_pager_color_progress "#a8afb7" set fish_pager_color_prefix white -set fish_pager_color_completion "#77828c" -set fish_pager_color_description "#77828c" +set fish_pager_color_completion "#a8afb7" +set fish_pager_color_description "#a8afb7" set fish_pager_color_selected_background --background=black diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 59a861c..97e55eb 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -1,9 +1,6 @@ if not status is-interactive exit end -# for agent in $(pidof ssh-agent | string split " ") -# kill $agent -# end # xdg set -gx XDG_CONFIG_HOME "$HOME/.config" @@ -35,7 +32,6 @@ set -gx PNPM_HOME "$HOME/.local/share/pnpm" # program set -gx EDITOR "nvim" -# set -gx VISUAL "lite-xl" set -gx MANPAGER "nvim +Man!" set -gx MANWIDTH 999 set -gx PF_INFO "ascii title os wm editor shell kernel palette" @@ -57,7 +53,8 @@ source $FISH_CFG/bindings.fish # configs source $FISH_CFG/done_cfg.fish -# source /opt/asdf-vm/asdf.fish +# secrets +source $FISH_CFG/secret.fish # abbreviations & aliases abbr -a paru paru --limit 10 @@ -72,7 +69,6 @@ alias dots="git --git-dir=$HOME/.dots --work-tree=$HOME" # alias sudo="doas" alias ls="ls --color=auto" alias grep="grep -P --color=always" -alias molest="sudo touch" alias wget="wget --hsts-file=$XDG_DATA_HOME/wget-hsts" alias stylua="stylua -s" alias cd="z" @@ -91,10 +87,8 @@ function ssh export TERM=xterm-256color end function flac_preview - # nsxiv (ffmpeg -i $argv[1] -v 8 -t 30 -lavfi showspectrumpic=s=hd720 -f image2 pipe: | psub) - nsxiv (ffmpeg -i $argv[1] -v 8 -t 30 -lavfi showspectrumpic=s=2k -f image2 pipe: | psub) - - + nsxiv (ffmpeg -i $argv[1] -v 8 -t 30 -lavfi showspectrumpic=s=hd720 -f image2 pipe: | psub) + # nsxiv (ffmpeg -i $argv[1] -v 8 -t 30 -lavfi showspectrumpic=s=2k -f image2 pipe: | psub) end function multicd echo (string repeat -n (math (string length -- $argv[1]) - 1) ../) @@ -111,8 +105,36 @@ end abbr -a !! --position anywhere --function last_history_item # shell init -# eval "$(ssh-agent -c)" &>/dev/null fish_ssh_agent starship init fish | source zoxide init fish | source direnv hook fish | source + +function dl + yt-dlp -v --download-archive "archive.txt" \ + --write-info-json --write-thumbnail --embed-subs --embed-thumbnail --embed-metadata \ + --merge-output-format "mkv" -f "bestvideo[height<=1080][width<=1920]+bestaudio" \ + --abort-on-error -o "files/%(extractor_key)s%(id)s/item.%(ext)s" \ + --extractor-args "youtube:player-client=default,mweb" $argv +end + +function archive_website + wget \ + # Download the whole site. + --recursive \ + # Get all assets/elements (CSS/JS/images). + --page-requisites \ + # Save files with .html on the end. + --adjust-extension \ + # Include necessary assets from offsite as well. + --span-hosts \ + # Update links to still work in the static version. + --convert-links \ + # Modify filenames to work in Windows as well. + --restrict-file-names=windows \ + # Do not follow links outside this domain. + --domains yoursite.com \ + # Don't follow links outside the directory you pass in. + --no-parent \ + $argv # The URL to download +end diff --git a/.config/nvim/.luarc.json b/.config/nvim/.luarc.json index e69de29..8da96c2 100644 --- a/.config/nvim/.luarc.json +++ b/.config/nvim/.luarc.json @@ -0,0 +1,3 @@ +{ + "workspace.library": ["usr/share/nvim/runtime"] +} diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 91bfca2..8fdca68 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -5,10 +5,15 @@ require "options" require "cmds" require "autocmd" require "binds" +require "diagnostics" require("lazy").setup { spec = "plugins", dev = { - path = vim.fn.stdpath "config" .. "/lua/local_plugins" - } + path = vim.fn.stdpath "config" .. "/lua/local_plugins", + }, + ui = { + border = "rounded", + backdrop = 100, + }, } -vim.cmd[[colo prismite]] +vim.cmd [[colo prismite]] diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 229bff2..9daf3a7 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,35 +1,30 @@ { - "LuaSnip": { "branch": "master", "commit": "fb525166ccc30296fb3457441eb979113de46b00" }, - "alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" }, + "alpha-nvim": { "branch": "main", "commit": "2b3cbcdd980cae1e022409289245053f62fb50f6" }, "better-escape.nvim": { "branch": "master", "commit": "19a38aab94961016430905ebec30d272a01e9742" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, - "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, - "git-blame.nvim": { "branch": "master", "commit": "8503b199edf9a666fe7b1a989cf14e3c26b2eb03" }, - "indentmini.nvim": { "branch": "main", "commit": "6211f93b0c8161d2a2b4000b9bf0c01c0a115455" }, - "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "leap.nvim": { "branch": "main", "commit": "10c14af4ddfb34dbd7721f0bfb2b4d91f0558907" }, - "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "marks.nvim": { "branch": "master", "commit": "f353e8c08c50f39e99a9ed474172df7eddd89b72" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "f54e3c11fc9ebfcfc27e696182b0295b071d0811" }, - "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, + "blink.cmp": { "branch": "main", "commit": "a4ab037eefdb9949896ea8553f918bd6250d62bd" }, + "git-blame.nvim": { "branch": "master", "commit": "54da04264ec5313d602aebea7c5dc90141696ad7" }, + "hardtime.nvim": { "branch": "main", "commit": "6d7664d5bdfaea44c5f50b29f5239fab7b00c273" }, + "indentmini.nvim": { "branch": "main", "commit": "e0f1e381a3949ea6757365fa33f8f1722d3eae90" }, + "lazy.nvim": { "branch": "main", "commit": "1ea3c4085785f460fb0e46d2fe1ee895f5f9e7c1" }, + "leap.nvim": { "branch": "main", "commit": "aa204264ffaf83650ee676ef68f52e327688b048" }, + "lualine.nvim": { "branch": "master", "commit": "3946f0122255bc377d14a59b27b609fb3ab25768" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "2304ff65ecc8cb2afc2484de3e2ed9a407edf0b9" }, + "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, "mini.colors": { "branch": "main", "commit": "ef76867adda63d6010acdc8732a816c8527d276b" }, - "mini.comment": { "branch": "main", "commit": "51c173dffa17dc14c81169deaeea430bd394ab51" }, - "mini.surround": { "branch": "main", "commit": "1a2b59c77a0c4713a5bd8972da322f842f4821b1" }, - "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, + "noice.nvim": { "branch": "main", "commit": "38c702be0d8fea81527ee6a73e1e834e72481193" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-cokeline": { "branch": "main", "commit": "9fbed130683b7b6f73198c09e35ba4b33f547c08" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, - "nvim-lspconfig": { "branch": "master", "commit": "314b35335cc84bc2a085c84c69da955ba22da163" }, - "nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" }, - "nvim-tree.lua": { "branch": "master", "commit": "0a06f65bf06157972f20ca1dee03c97a0efcb188" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "51cf7c995ed1eb6642aecf19067ee634fa1b6ba2" }, + "nvim-lspconfig": { "branch": "master", "commit": "ac98db2f9f06a56498ec890a96928774eae412c3" }, + "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, + "nvim-tree.lua": { "branch": "master", "commit": "e397756d2a79d74314ea4cd3efc41300e91c0ff0" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, - "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "sessions.nvim": { "branch": "master", "commit": "f13158483e0b6255c6dfe473145ce4ee3495d844" }, + "nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "snacks.nvim": { "branch": "main", "commit": "b59ef39194d00584445ca9f32a90182b383d32de" }, + "statuscol.nvim": { "branch": "main", "commit": "c46172d0911aa5d49ba5f39f4351d1bb7aa289cc" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, - "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, + "trouble.nvim": { "branch": "main", "commit": "c098362fe603d3922095e7db595961e020bdf2d0" }, "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" } } diff --git a/.config/nvim/lua/binds.lua b/.config/nvim/lua/binds.lua index 55da905..4bcebb0 100644 --- a/.config/nvim/lua/binds.lua +++ b/.config/nvim/lua/binds.lua @@ -1,11 +1,7 @@ local map = vim.keymap.set -- local color_converter = require "color_converter" --- toggle nvim-tree -map("n", "<Leader>t", "<cmd>NvimTreeToggle<CR>") --- toggle trouble -map("n", "<Leader>e", "<cmd>TroubleToggle<CR>") --- undo +-- redo map("n", "U", "<C-r>") map("c", "<CR>", function() @@ -34,21 +30,6 @@ map("i", "<RIGHT>", "<NOP>") map("n", "<Leader>h", vim.lsp.buf.hover) map("n", "<Leader>gd", vim.lsp.buf.definition) -map("n", "<leader>bp", function() - require('cokeline.mappings').pick("focus") -end, { desc = "Pick a buffer to focus" }) -map("n", "<leader>bq", function() - require('cokeline.mappings').pick("close") -end, { desc = "Pick a buffer to close" }) -map("n", "<Leader>p", function () - require("cokeline.mappings").by_step("switch", -1) -end, { silent = true }) -map("n", "<Leader>n", function () - require("cokeline.mappings").by_step("switch", 1) -end, { silent = true }) - - --- local function setup_lsp_keys(_client, buffer) --- map("<Leader>d", vim.diagnostic.open_float, "Line diagnostics") --- --- end +map("n", "<C-l>", function() + vim.fn.setreg("/", "") +end) diff --git a/.config/nvim/lua/dash.lua b/.config/nvim/lua/dash.lua index fd9f03c..9079104 100644 --- a/.config/nvim/lua/dash.lua +++ b/.config/nvim/lua/dash.lua @@ -1,5 +1,5 @@ -local lazy = require "lazy" local alpha = require "alpha" +local lazy = require "lazy" vim.api.nvim_create_autocmd("ColorScheme", { callback = function() @@ -21,7 +21,6 @@ vim.api.nvim_create_autocmd("ColorScheme", { end, }) - return { layout = { { @@ -125,10 +124,12 @@ return { val = { { type = "text", - val = function() return lazy.stats().loaded .. " plugin" .. (lazy.stats().loaded == 1 and "" or "s") .. " loaded" end, + val = function() + return lazy.stats().loaded .. " plugin" .. (lazy.stats().loaded == 1 and "" or "s") .. " loaded" + end, opts = { position = "center", - } + }, }, { type = "text", @@ -137,10 +138,10 @@ return { position = "center", hl = { { "Comment", 0, 27 }, - { "DashEmphasis", 27, 35 } - } - } - } + { "DashEmphasis", 27, 35 }, + }, + }, + }, }, }, }, diff --git a/.config/nvim/lua/icons.lua b/.config/nvim/lua/icons.lua index e058e29..784b2ea 100644 --- a/.config/nvim/lua/icons.lua +++ b/.config/nvim/lua/icons.lua @@ -1,9 +1,13 @@ return { diagnostics = { - Error = " ", - Warn = " ", - Hint = " ", - Info = " ", + -- Error = " ", + -- Warn = " ", + -- Hint = " ", + -- Info = " ", + Error = "e", + Warn = "w", + Hint = "h", + Info = "i", }, kinds = { Array = " ", diff --git a/.config/nvim/lua/local_plugins/color_converter/lua/color_converter.lua b/.config/nvim/lua/local_plugins/color_converter/lua/color_converter.lua index ff8aa70..e2265f0 100644 --- a/.config/nvim/lua/local_plugins/color_converter/lua/color_converter.lua +++ b/.config/nvim/lua/local_plugins/color_converter/lua/color_converter.lua @@ -1,14 +1,10 @@ local menu = require "ui" return { - setup = function () - vim.api.nvim_create_user_command( - "ColorConverter", - function() - menu:mount() - end, - {} - ) + setup = function() + vim.api.nvim_create_user_command("ColorConverter", function() + menu:mount() + end, {}) end, - config = function(opt) end + config = function(opt) end, } diff --git a/.config/nvim/lua/local_plugins/color_converter/lua/ui.lua b/.config/nvim/lua/local_plugins/color_converter/lua/ui.lua index a2bf115..ddd9a85 100644 --- a/.config/nvim/lua/local_plugins/color_converter/lua/ui.lua +++ b/.config/nvim/lua/local_plugins/color_converter/lua/ui.lua @@ -1,47 +1,47 @@ +local Menu = require "nui.menu" local mcolors = require "mini.colors" -local Menu = require("nui.menu") local event = require("nui.utils.autocmd").event local popup_options = { - relative = "cursor", - position = { - row = 2, - col = 1, - }, - border = { - style = "rounded", - text = { - top = "[Choose Item]", - top_align = "center", + relative = "cursor", + position = { + row = 2, + col = 1, + }, + border = { + style = "rounded", + text = { + top = "[Choose Item]", + top_align = "center", + }, }, - }, } local menu = Menu(popup_options, { - lines = { - Menu.separator("Group One"), - Menu.item("Item 1"), - Menu.item("Item 2"), - Menu.separator("Group Two", { - char = "-", - text_align = "right", - }), - Menu.item("Item 3"), - Menu.item("Item 4"), - }, - -- max_width = 20, - keymap = { - focus_next = { "j", "<Down>", "<Tab>" }, - focus_prev = { "k", "<Up>", "<S-Tab>" }, - close = { "<Esc>", "<C-c>" }, - submit = { "<CR>", "<Space>" }, - }, - on_close = function() - print("CLOSED") - end, - on_submit = function(item) - print("SUBMITTED", vim.inspect(item)) - end, + lines = { + Menu.separator "Group One", + Menu.item "Item 1", + Menu.item "Item 2", + Menu.separator("Group Two", { + char = "-", + text_align = "right", + }), + Menu.item "Item 3", + Menu.item "Item 4", + }, + -- max_width = 20, + keymap = { + focus_next = { "j", "<Down>", "<Tab>" }, + focus_prev = { "k", "<Up>", "<S-Tab>" }, + close = { "<Esc>", "<C-c>" }, + submit = { "<CR>", "<Space>" }, + }, + on_close = function() + print "CLOSED" + end, + on_submit = function(item) + print("SUBMITTED", vim.inspect(item)) + end, }) return menu diff --git a/.config/nvim/lua/options.lua b/.config/nvim/lua/options.lua index 6153825..19e2b4c 100644 --- a/.config/nvim/lua/options.lua +++ b/.config/nvim/lua/options.lua @@ -1,28 +1,39 @@ -local o = vim.o local opt = vim.opt -o.smarttab = true -o.exrc = true -o.clipboard = "unnamedplus" -o.termguicolors = true -o.list = true -o.autochdir = true -o.wrap = false -o.number = true -o.relativenumber = true -o.expandtab = true -o.tabstop = 4 -o.smartindent = true -o.shiftwidth = 4 -o.sidescroll = 5 -o.timeout= false -o.scrolloff = 4 -o.sidescrolloff = 4 -o.sidescroll = 1 -o.cursorline = true -o.mouse = "" -o.fillchars = 'eob: ' +opt.smarttab = true +opt.exrc = true +opt.clipboard = "unnamedplus" +opt.termguicolors = true +opt.list = true +opt.autochdir = true +opt.wrap = false +opt.number = true +opt.relativenumber = true +opt.expandtab = true +opt.tabstop = 4 +opt.smartindent = true +opt.shiftwidth = 4 +opt.sidescroll = 5 +opt.timeout = false +opt.scrolloff = 4 +opt.sidescrolloff = 4 +opt.sidescroll = 1 +opt.cursorline = true +opt.mouse = "" +opt.ignorecase = true +opt.smartcase = true +opt.foldtext = "" +opt.foldlevel = 99 +opt.foldcolumn = "auto:1" vim.g.mapleader = " " vim.g.maplocalleader = vim.g.mapleader opt.listchars = { space = "⋅", tab = "--", precedes = "…", extends = "…" } +opt.fillchars = { + -- foldopen = "-", + -- foldclose = "+", + fold = " ", + foldsep = " ", + diff = "╱", + eob = " ", +} diff --git a/.config/nvim/lua/plugins/coding.lua b/.config/nvim/lua/plugins/coding.lua deleted file mode 100644 index fd636fa..0000000 --- a/.config/nvim/lua/plugins/coding.lua +++ /dev/null @@ -1,150 +0,0 @@ -return { - -- { "echasnovski/mini.move", config = true }, - { "echasnovski/mini.comment", config = true }, - { "max397574/better-escape.nvim", config = true }, - { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - config = function() - local configs = require "nvim-treesitter.configs" - configs.setup { - ensure_installed = { - "lua", - "c", - "vim", - "vimdoc", - "query", - "rust", - "fish", - "json", - "javascript", - "latex", - "markdown", - "markdown_inline", - "zig", - "typescript", - "toml", - "svelte", - "comment", - "html", - "typst", - "ron" - }, - highlight = { enable = true }, - indent = { enable = true }, - } - end, - }, - { - "ggandor/leap.nvim", - config = function() - local leap = require "leap" - leap.add_default_mappings() - leap.opts.highlight_unlabeled_phase_one_targets = true - end, - dependencies = { - "tpope/vim-repeat", - }, - }, - { - "hrsh7th/nvim-cmp", - opts = function() - vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) - local cmp = require "cmp" - local defaults = require "cmp.config.default"() - return { - enabled = function() - local context = require "cmp.config.context" - if vim.api.nvim_get_mode().mode == "c" then - return true - else - return not context.in_treesitter_capture "comment" and not context.in_syntax_group "Comment" - end - end, - - completion = { - completeopt = "menu,menuone,noinsert", - }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - mapping = cmp.mapping.preset.insert { - ["<C-j>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, - ["<C-k>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, - ["<C-b>"] = cmp.mapping.scroll_docs(-4), - ["<C-f>"] = cmp.mapping.scroll_docs(4), - ["<S-CR>"] = cmp.mapping.abort(), - ["<CR>"] = cmp.mapping.confirm { select = false }, - }, - sources = cmp.config.sources { - { name = "nvim_lsp" }, - { name = "path" }, - }, - formatting = { - format = function(_, item) - local icons = require("icons").kinds - if icons[item.kind] then - item.kind = icons[item.kind] .. item.kind - end - return item - end, - }, - experimental = { - ghost_text = { - hl_group = "CmpGhostText", - }, - }, - sorting = defaults.sorting, - } - end, - dependencies = { - { "L3MON4D3/LuaSnip", build = "make install_jsregexp" }, - "hrsh7th/cmp-path", - "saadparwaiz1/cmp_luasnip", - }, - disabled = true - }, - { - "NvChad/nvim-colorizer.lua", - opts = { - user_default_options = { RGB = true, RRGGBB = true, RRGGBBAA = true, always_update = true, names = false }, - }, - }, - { - "echasnovski/mini.surround", - version = false, - opts = { - mappings = { - add = "\\a", -- Add surrounding in Normal and Visual modes - delete = "\\d", -- Delete surrounding - find = "\\f", -- Find surrounding (to the right) - find_left = "\\F", -- Find surrounding (to the left) - highlight = "\\h", -- Highlight surrounding - replace = "\\r", -- Replace surrounding - update_n_lines = "\\n", -- Update `n_lines` - } - } - }, - { - "color_converter", - dev = true, - dependencies = { - { 'echasnovski/mini.colors', version = '*' }, - "MunifTanjim/nui.nvim", - }, - -- lazy = false, - cmd = "ColorConverter", - config = true - }, - -- { - -- "m4xshen/hardtime.nvim", - -- config = true, - -- disabled = true - -- } -} diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua index e0f2a96..100d92a 100644 --- a/.config/nvim/lua/plugins/colorscheme.lua +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -1,53 +1,7 @@ return { - -- { - -- "folke/tokyonight.nvim", - -- lazy = false, - -- priority = 1000, - -- config = function() - -- vim.cmd [[colorscheme tokyonight-night]] - -- end, - -- }, - -- { - -- "chadcat7/prism", - -- config = function() - -- require("prism"):setup { - -- customSchemes = { - -- { - -- name = "prismite", - -- background = "#1b2026", - -- foreground = "#d9dfe4", - -- cursorline = "#1f242b", - -- comment = "#434754", - -- darker = "#161b22", - -- cursor = "#fdc267", - -- black = "#1b2026", -- useful when background is transparent - -- color0 = "#1f242b", - -- color1 = "#df625d", - -- color2 = "#91d89a", - -- color3 = "#fdc267", - -- color4 = "#8ec6ff", - -- color5 = "#f2b9c1", - -- color6 = "#77e2e3", - -- color7 = "#d9dfe4", - -- color8 = "#373D41", - -- color9 = "#f1726b", - -- color10 = "#a1e9aa", - -- color11 = "#ffd79d", - -- color12 = "#add6ff", - -- color13 = "#ffcbd2", - -- color14 = "#88f3f3", - -- color15 = "#d9dfe4", - -- }, - -- }, - -- currentTheme = "prismite", - -- reset = true, - -- reload = { "lualine" }, - -- } - -- end, - -- enabled = false - -- }, { dir = "/home/delta/Documents/RealProjects/lua/prismite.nvim", + -- "https://git.twoexem.com/prismite.nvim", lazy = false, priority = 1000, config = function() diff --git a/.config/nvim/lua/plugins/editor.lua b/.config/nvim/lua/plugins/editor.lua deleted file mode 100644 index 47fe8b4..0000000 --- a/.config/nvim/lua/plugins/editor.lua +++ /dev/null @@ -1,24 +0,0 @@ -return { - -- { "Saecki/crates.nvim", config = true }, - { - "nvim-telescope/telescope.nvim", - config = true, - dependencies = { "nvim-lua/plenary.nvim" }, - }, - { - "natecraddock/sessions.nvim", - config = true - }, - { - "f-person/git-blame.nvim", - event = "VeryLazy", - opts = { - date_format = "%r" - }, - }, - { - "chentoast/marks.nvim", - -- event = "VeryLazy", - config = true - } -} diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 1063c5d..a438f3a 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -1,254 +1,210 @@ -local icons = require("icons") +local icons = require "icons" -- this is horrible and it should be redone someday -- but that day is not today +local _supports_method = {} + return { - { - "neovim/nvim-lspconfig", - -- enabled = false, - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - { "williamboman/mason.nvim", config = true, lazy = false }, - { "mason-org/mason-lspconfig.nvim", opts = { automatic_enable = false } }, - "hrsh7th/cmp-nvim-lsp", - }, - opts = { - diagnostics = { - }, - servers = { - lua_ls = { - settings = { - Lua = { - -- workspace = { - -- checkThirdParty = false, - -- library = { - -- vim.env.VIMRUNTIME, - -- }, - -- }, - completion = { - showWord = "Disable", - displayContext = 8, - }, - hint = { - enable = true, - }, - diagnostics = { "trailing-space" }, + "neovim/nvim-lspconfig", + -- enabled = false, + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + { "williamboman/mason.nvim", config = true, lazy = false }, + { "mason-org/mason-lspconfig.nvim", opts = { automatic_enable = false } }, + -- "hrsh7th/cmp-nvim-lsp", + "saghen/blink.cmp", + }, + opts = { + diagnostics = {}, + servers = { + lua_ls = { + settings = { + Lua = { + workspace = { + checkThirdParty = false, + }, + completion = { + showWord = "Disable", + displayContext = 8, + }, + hint = { + enable = true, }, + diagnostics = { "trailing-space" }, }, }, - rust_analyzer = { settings = { completion = { fullFunctionSignatures = true } } }, - ts_ls = {}, }, - setup = {} + rust_analyzer = { settings = { completion = { fullFunctionSignatures = true } } }, + ts_ls = {}, }, - config = function(_, opts) - local function on_attach(fn) - vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - local buffer = args.buf - local client = vim.lsp.get_client_by_id(args.data.client_id) - fn(client, buffer) - end, - }) + setup = {}, + inlay_hints = { + exclude = {}, + }, + }, + config = function(_, opts) + ---@param client vim.lsp.Client + local function _check_methods(client, buffer) + -- don't trigger on invalid buffers + if not vim.api.nvim_buf_is_valid(buffer) then + return end - - ---@param method string - ---@param fn fun(client:vim.lsp.Client, buffer) - local function on_supports_method(method, fn) - -- cache[method] = cache[method] or setmetatable({}, { __mode = "k" }) - return vim.api.nvim_create_autocmd("User", { - pattern = "LspSupportsMethod", - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - local buffer = args.data.buffer ---@type number - if client and method == args.data.method then - return fn(client, buffer) - end - end, - }) + -- don't trigger on non-listed buffers + if not vim.bo[buffer].buflisted then + return end - - -- function _check_methods(client, buffer) - -- if - -- -- don't trigger on invalid buffers - -- not vim.api.nvim_buf_is_valid(buffer) or - -- -- don't trigger on non-listed buffers - -- vim.bo[buffer].buflisted or - -- -- don't trigger on nofile buffers - -- vim.bo[buffer].buftype == "nofile" - -- then - -- return - -- end - -- for method, clients in pairs(M._supports_method) do - -- clients[client] = clients[client] or {} - -- if not clients[client][buffer] then - -- if client.supports_method and client.supports_method(method, { bufnr = buffer }) then - -- clients[client][buffer] = true - -- vim.api.nvim_exec_autocmds("User", { - -- pattern = "LspSupportsMethod", - -- data = { client_id = client.id, buffer = buffer, method = method }, - -- }) - -- end - -- end - -- end - -- end - - on_supports_method("textDocument/inlayHint", function(client, buffer) - if - vim.api.nvim_buf_is_valid(buffer) - and vim.bo[buffer].buftype == "" - and not vim.tbl_contains(opts.inlay_hints.exclude, vim.bo[buffer].filetype) - then - vim.lsp.inlay_hint.enable(true, { bufnr = buffer }) + -- don't trigger on nofile buffers + if vim.bo[buffer].buftype == "nofile" then + return + end + for method, clients in pairs(_supports_method) do + clients[client] = clients[client] or {} + if not clients[client][buffer] then + if client.supports_method and client.supports_method(method, { bufnr = buffer }) then + clients[client][buffer] = true + vim.api.nvim_exec_autocmds("User", { + pattern = "LspSupportsMethod", + data = { client_id = client.id, buffer = buffer, method = method }, + }) + end end - end) + end + end - vim.diagnostic.config({ - underline = true, - update_in_insert = false, - virtual_text = { - spacing = 4, - source = "if_many", - prefix = function(diagnostic) - for name, icon in pairs(icons.diagnostics) do - if diagnostic.severity == vim.diagnostic.severity[name:upper()] then - return icon - end - end + ---@param on_attach fun(client:vim.lsp.Client, buffer) + ---@param name? string + local function on_attach(_on_attach, name) + return vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local buffer = args.buf ---@type number + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client and (not name or client.name == name) then + return _on_attach(client, buffer) end + end, + }) + end - }, - severity_sort = true, + ---@param method string + ---@param fn fun(client:vim.lsp.Client, buffer) + local function on_supports_method(method, fn) + _supports_method[method] = _supports_method[method] or setmetatable({}, { __mode = "k" }) + return vim.api.nvim_create_autocmd("User", { + pattern = "LspSupportsMethod", + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + local buffer = args.data.buffer ---@type number + if client and method == args.data.method then + return fn(client, buffer) + end + end, }) + end - local servers = opts.servers - local cmp_nvim_lsp = require "cmp_nvim_lsp" - local capabilities = vim.tbl_deep_extend( - "force", - {}, - vim.lsp.protocol.make_client_capabilities(), - cmp_nvim_lsp.default_capabilities() - ) + ---@param fn fun(client:vim.lsp.Client, buffer):boolean? + ---@param opts? {group?: integer} + local function on_dynamic_capability(fn, opts) + return vim.api.nvim_create_autocmd("User", { + pattern = "LspDynamicCapability", + group = opts and opts.group or nil, + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + local buffer = args.data.buffer ---@type number + if client then + return fn(client, buffer) + end + end, + }) + end - local function setup(server) - local server_opts = vim.tbl_deep_extend("force", { - capabilities = vim.deepcopy(capabilities), - }, servers[server] or {}) + local register_capability = vim.lsp.handlers["client/registerCapability"] + vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx) + ---@diagnostic disable-next-line: no-unknown + local ret = register_capability(err, res, ctx) + local client = vim.lsp.get_client_by_id(ctx.client_id) + if client then + for buffer in pairs(client.attached_buffers) do + vim.api.nvim_exec_autocmds("User", { + pattern = "LspDynamicCapability", + data = { client_id = client.id, buffer = buffer }, + }) + end + end + return ret + end + on_attach(_check_methods) + on_dynamic_capability(_check_methods) - if opts.setup[server] then - if opts.setup[server](server, server_opts) then - return - end - elseif opts.setup["*"] then - if opts.setup["*"](server, server_opts) then - return + -- on_supports_method("textDocument/inlayHint", function(client, buffer) + -- if + -- vim.api.nvim_buf_is_valid(buffer) + -- and vim.bo[buffer].buftype == "" + -- and not vim.tbl_contains(opts.inlay_hints.exclude, vim.bo[buffer].filetype) + -- then + -- vim.lsp.inlay_hint.enable(true, { bufnr = buffer }) + -- end + -- end) + + vim.diagnostic.config { + underline = true, + update_in_insert = false, + virtual_text = { + spacing = 4, + source = "if_many", + prefix = function(diagnostic) + for name, icon in pairs(icons.diagnostics) do + if diagnostic.severity == vim.diagnostic.severity[name:upper()] then + return "[" .. icon .. "]" + end end + end, + }, + severity_sort = true, + } + + local servers = opts.servers + local blink_cmp = require "blink.cmp" + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + blink_cmp.get_lsp_capabilities({}, false) + ) + + local function setup(server) + local server_opts = vim.tbl_deep_extend("force", { + capabilities = vim.deepcopy(capabilities), + }, servers[server] or {}) + + if opts.setup[server] then + if opts.setup[server](server, server_opts) then + return + end + elseif opts.setup["*"] then + if opts.setup["*"](server, server_opts) then + return end - require("lspconfig")[server].setup(server_opts) end + vim.lsp.config(server, server_opts) + vim.lsp.enable(server) + end - local mlsp = require "mason-lspconfig" - local all_mslp_servers = require("mason-lspconfig").get_mappings().lspconfig_to_package + local mlsp = require "mason-lspconfig" + local all_mslp_servers = require("mason-lspconfig").get_mappings().lspconfig_to_package - local ensure_installed = {} - for server, server_opts in pairs(servers) do - if server_opts then - server_opts = server_opts == true and {} or server_opts - if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then - setup(server) - else - ensure_installed[#ensure_installed + 1] = server - end + local ensure_installed = {} + for server, server_opts in pairs(servers) do + if server_opts then + server_opts = server_opts == true and {} or server_opts + if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then + setup(server) + else + ensure_installed[#ensure_installed + 1] = server end end + end - -- mlsp.setup { ensure_installed = ensure_installed, handlers = { setup } } - mlsp.setup { ensure_installed = ensure_installed } - end, - -- config = function(_, opts) - -- local cache = {} - -- - -- - -- - -- - -- on_attach(function(client, buffer) - -- -- TODO: add keybinds - -- end) - -- - -- local register_capability = vim.lsp.handlers["client/registerCapability"] - -- - -- vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx) - -- local ret = register_capability(err, res, ctx) - -- local client_id = ctx.client_id - -- local client = vim.lsp.get_client_by_id(client_id) - -- local buffer = vim.api.nvim_get_current_buf() - -- -- TODO: add keybinds - -- return ret - -- end - -- - -- for name, icon in pairs(require("icons").diagnostics) do - -- name = "DiagnosticSign" .. name - -- vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) - -- end - -- - -- local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint - -- - -- - -- if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then - -- opts.diagnostics.virtual_text.prefix = vim.fn.has "nvim-0.10.0" == 0 and "●" - -- end - -- --- ) - -- - -- local servers = opts.servers - -- local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") - -- local capabilities = vim.tbl_deep_extend( - -- "force", - -- {}, - -- vim.lsp.protocol.make_client_capabilities(), - -- has_cmp and cmp_nvim_lsp.default_capabilities() or {}, - -- opts.capabilities or {} - -- ) - -- - -- local function setup(server) - -- local server_opts = vim.tbl_deep_extend("force", { - -- capabilities = vim.deepcopy(capabilities), - -- }, servers[server] or {}) - -- - -- if opts.setup[server] then - -- if opts.setup[server](server, server_opts) then - -- return - -- end - -- elseif opts.setup["*"] then - -- if opts.setup["*"](server, server_opts) then - -- return - -- end - -- end - -- require("lspconfig")[server].setup(server_opts) - -- end - -- - -- local have_mason, mlsp = pcall(require, "mason-lspconfig") - -- local all_mslp_servers = {} - -- if have_mason then - -- all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package) - -- end - -- - -- local ensure_installed = {} - -- for server, server_opts in pairs(servers) do - -- if server_opts then - -- server_opts = server_opts == true and {} or server_opts - -- if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then - -- setup(server) - -- else - -- ensure_installed[#ensure_installed + 1] = server - -- end - -- end - -- end - -- - -- if have_mason then - -- mlsp.setup { ensure_installed = ensure_installed, handlers = { setup } } - -- end - -- end, - }, + mlsp.setup { ensure_installed = ensure_installed } + end, } diff --git a/.config/nvim/lua/plugins/ui.lua b/.config/nvim/lua/plugins/ui.lua deleted file mode 100644 index e79ee3a..0000000 --- a/.config/nvim/lua/plugins/ui.lua +++ /dev/null @@ -1,477 +0,0 @@ -local leap_active = false -vim.api.nvim_create_autocmd("User", { - pattern = "LeapEnter", - callback = function() - leap_active = true - end, -}) - -vim.api.nvim_create_autocmd("User", { - pattern = "LeapLeave", - callback = function() - leap_active = false - end, -}) - -local nvim_tree_root = nil - -return { - { - "willothy/nvim-cokeline", - - config = function() - local hl = require("cokeline.hlgroups") - local is_picking_focus = require('cokeline.mappings').is_picking_focus - local is_picking_close = require('cokeline.mappings').is_picking_close - - local function has_diagnostics(buffer) - return buffer.diagnostics.errors > 0 or buffer.diagnostics.warnings > 0 or buffer.diagnostics.infos > 0 or buffer.diagnostics.hints > 0 - end - - require("cokeline").setup { - show_if_buffers_are_at_least = 0, - components = { - { - text = function(buffer) - return buffer.is_first and (require "cokeline.sidebar".get_width("left") == 0 and "" or "│") or "▎" - end, - fg = function() - return hl.get_hl_attr("WinSeparator", "fg") - end, - }, - { - text = function (buffer) - return (is_picking_focus() or is_picking_close()) and " " .. buffer.pick_letter or "" - end, - fg = function () - return hl.get_hl_attr("PrismiteYellow", "fg") - end - }, - { - text = function(buffer) - return " " .. buffer.devicon.icon - end, - fg = function(buffer) - return buffer.devicon.color - end, - }, - { - text = function(buffer) - return buffer.unique_prefix - end, - fg = function() - return hl.get_hl_attr("Comment", "fg") - end, - italic = true, - }, - { - text = function(buffer) - return buffer.filename - end, - }, - { - ---@param buffer Buffer - text = function(buffer) - return buffer.is_modified and " " or "" - end, - }, - { - text = function(buffer) - return has_diagnostics(buffer) and " [" or "" - end, - fg = function() - return hl.get_hl_attr("WinSeparator", "fg") - end, - }, - { - text = function(buffer) - local errors = buffer.diagnostics.errors - return errors > 0 and errors or "" - end, - fg = function () - return hl.get_hl_attr("DiagnosticError", "fg") - - end - }, - { - text = function (buffer) - local bd = buffer.diagnostics - return (bd.errors > 0 and (bd.warnings > 0 or bd.infos > 0 or bd.hints > 0)) and "|" or "" - end, - fg = function() - return hl.get_hl_attr("WinSeparator", "fg") - end, - }, - { - text = function(buffer) - local warnings = buffer.diagnostics.warnings - return warnings > 0 and warnings or "" - end, - fg = function () - return hl.get_hl_attr("DiagnosticWarn", "fg") - end - }, - { - text = function (buffer) - local bd = buffer.diagnostics - return (bd.warnings > 0 and (bd.infos > 0 or bd.hints > 0)) and "|" or "" - end, - fg = function() - return hl.get_hl_attr("WinSeparator", "fg") - end, - }, - { - text = function(buffer) - local infos = buffer.diagnostics.infos - return infos > 0 and infos or "" - end, - fg = function () - return hl.get_hl_attr("DiagnosticInfo", "fg") - end - }, - { - text = function (buffer) - local bd = buffer.diagnostics - return (bd.infos > 0 and bd.hints > 0) and "|" or "" - end, - fg = function() - return hl.get_hl_attr("WinSeparator", "fg") - end, - }, - { - text = function(buffer) - local hints = buffer.diagnostics.hints - return hints > 0 and hints or "" - end, - fg = function () - return hl.get_hl_attr("DiagnosticHint", "fg") - end - }, - { - text = function(buffer) - return has_diagnostics(buffer) and "]" or "" - end, - fg = function() - return hl.get_hl_attr("WinSeparator", "fg") - end, - }, - { - text = " " - } - }, - buffers = { - delete_on_right_click = false - }, - mappings = { - disable_mouse = true - }, - sidebar = { - components = { - { - text = function() - local width = require("cokeline.sidebar").get_width("left") - if #nvim_tree_root > width then - return nvim_tree_root:sub(1, width - 2) .. "…" - else - return nvim_tree_root - end - end, - bg = function() - return hl.get_hl_attr("TabLineSel", "bg") - end, - }, - { - text = function() - return string.rep( - " ", - math.max(0, require("cokeline.sidebar").get_width("left") - #nvim_tree_root) - ) - end, - bg = function() - return hl.get_hl_attr("TabLineSel", "bg") - end - }, - } - } - } - end, - dependencies = { "nvim-tree/nvim-web-devicons", "nvim-lua/plenary.nvim" }, - }, - { - "folke/trouble.nvim", - opts = {}, - dependencies = { "nvim-tree/nvim-web-devicons" }, - }, - { - "nvimdev/indentmini.nvim", - config = true, - opts = { - char = "▏" - } - }, - { - "folke/noice.nvim", - event = "VeryLazy", - opts = { - cmdline = { - format = { - cmdline = { icon = ":" }, - }, - }, - lsp = { - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - }, - presets = { - command_palette = true, - long_message_to_split = true, - inc_rename = false, - lsp_doc_border = true, - }, - messages = { - view_search = false, - }, - routes = { - { - filter = { - event = "msg_show", - kind = "", - find = "Already at newest change", - }, - view = "mini", - }, - { - filter = { - event = "msg_show", - kind = "", - find = "Already at oldest change", - }, - view = "mini", - }, - { - filter = { - event = "msg_show", - kind = "", - find = "E486: Pattern not found:" - }, - view = "mini" - }, - -- normal search - { - filter = { - event = "msg_show", - kind = "", - find = "E486: Pattern not found:" - }, - view = "mini" - }, - -- failed search - { - filter = { - event = "msg_show", - kind = "", - find = "E486: Pattern not found:" - }, - view = "mini" - }, - -- undo - { - filter = { - event = "msg_show", - kind = "", - find = "%d+ .+ line.?; before #%d+", - }, - view = "mini", - }, - { - filter = { - event = "msg_show", - kind = "", - find = "%d+ .+ line.?; before #%d+", - }, - view = "mini", - }, - -- redo - { - filter = { - event = "msg_show", - kind = "", - find = "%d+ change; after #%d+", - }, - view = "mini" - }, - }, - }, - dependencies = { - "MunifTanjim/nui.nvim", - "rcarriga/nvim-notify", - }, - }, - { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - opts = { - options = { - section_separators = { left = "", right = "" }, - component_separators = { left = "", right = "" }, - fmt = function(str) - return vim.trim(str) - end, - globalstatus = true, - disabled_filetypes = { "NvimTree" }, - }, - sections = { - lualine_a = { - "mode", - { - function() - return "[L]" - end, - cond = function () - return leap_active - end - }, - { - function() - local reg = vim.fn.reg_recording() - if reg == "" then return "" end -- not recording - return "[@" .. reg .. "]" - end - } - }, - lualine_b = { "filename" }, - lualine_c = { "diagnostics", "diff" }, - lualine_x = { - { - function () - local noice_loaded, noice = pcall(require, "noice") - if noice_loaded then - return noice.api.status.command.get() - else - return "" - end - end, - cond = function() - local noice_loaded, noice = pcall(require, "noice") - if noice_loaded then - return noice.api.status.command.has() - else - return false - end - end - } - }, - lualine_y = { "filetype" }, - lualine_z = { "searchcount", "progress", "location" }, - }, - }, - dependencies = { - "nvim-tree/nvim-web-devicons", - }, - }, - { "stevearc/dressing.nvim", config = true }, - { - "nvim-tree/nvim-tree.lua", - opts = { - sort_by = "case_sensitive", - view = { - width = 30, - }, - renderer = { - root_folder_label = function() return ".." end, - indent_markers = { - enable = true, - }, - icons = { - show = { - folder_arrow = false, - }, - glyphs = { - git = { - unstaged = "-", - staged = "+", - unmerged = "", - renamed = "", - untracked = "", - deleted = "", - ignored = "", - }, - }, - }, - }, - filters = { - git_ignored = false, - custom = { - "^.git$", - }, - }, - }, - config = function(_, opts) - local api = require("nvim-tree.api") - local Event = api.events.Event - - api.events.subscribe(Event.Ready, function() - nvim_tree_root = api.tree.get_nodes().absolute_path - end) - - api.events.subscribe(Event.TreeRendered, function() - nvim_tree_root = api.tree.get_nodes().absolute_path - end) - - require("nvim-tree").setup(vim.tbl_extend("force", opts, { - -- on_attach = function () - -- local function opts(desc) - -- return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } - -- end - -- - -- local function edit_or_open() - -- local node = api.tree.get_node_under_cursor() - -- - -- if node.nodes ~= nil then - -- -- expand or collapse folder - -- api.node.open.edit() - -- else - -- -- open file - -- api.node.open.edit() - -- -- Close the tree if file was opened - -- api.tree.close() - -- end - -- end - -- - -- -- open as vsplit on current node - -- local function vsplit_preview() - -- local node = api.tree.get_node_under_cursor() - -- - -- if node.nodes ~= nil then - -- -- expand or collapse folder - -- api.node.open.edit() - -- else - -- -- open file as vsplit - -- api.node.open.vertical() - -- end - -- - -- -- Finally refocus on tree if it was lost - -- api.tree.focus() - -- end - -- - -- vim.keymap.set("n", "l", edit_or_open, opts("Edit Or Open")) - -- vim.keymap.set("n", "h", api.tree.close, opts("Close")) - -- end - -- - })) - end, - dependencies = { - "nvim-tree/nvim-web-devicons", - }, - }, - { - "goolord/alpha-nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - require("alpha").setup(require "dash") - end, - }, -} diff --git a/.config/nvim/lua/plugins/utils.lua b/.config/nvim/lua/plugins/utils.lua deleted file mode 100644 index 3c16433..0000000 --- a/.config/nvim/lua/plugins/utils.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - { 'echasnovski/mini.colors', version = '*' }, - "MunifTanjim/nui.nvim", -} |
