diff options
Diffstat (limited to '.config')
86 files changed, 11610 insertions, 0 deletions
diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml new file mode 100644 index 0000000..6cddbeb --- /dev/null +++ b/.config/alacritty/alacritty.yml @@ -0,0 +1,92 @@ +# ~/.config/alacritty/alacritty.yml + + +live_config_reload: true + +window: + opacity: 0.8 + dynamic_title: true + dimensions: + columns: 0 + lines: 0 + + + #startup_mode: SimpleFullscreen + #position: + #x: 0 + #y: 0 + + padding: + x: 9 + y: 9 + + dynamic_padding: false + decorations: none + +scrolling: + history: 50000 + multiplier: 3 + + + +font: + normal: + family: JetBrains Mono Medium + #family: UbuntuMono Nerd Font Regular + size: 8.5 + #size: 8.5 +key_bindings: +- { key: V, mods: Control, action: Paste } +- { key: C, mods: Control, action: Copy } +- { key: C, mods: Control|Shift, chars: "\x03" } +- { key: N, mods: Control|Shift, action: SpawnNewInstance } +- { key: O, mods: Control|Shift, command: { program: "opacity-change.sh", args: ["-"] } } +- { key: P, mods: Control|Shift, command: { program: "opacity-change.sh", args: ["+"] } } +save_to_clipboard: true + +colors: + primary: + background: '#000000' + foreground: '#FFFACD' + normal: + black: '#313539' + red: '#b02626' + green: '#40a62f' + yellow: '#f2e635' + blue: '#314ad0' + magenta: '#b30ad0' + cyan: '#32d0fc' + white: '#acadb1' + bright: + black: '#676f78' + red: '#b55454' + green: '#78a670' + yellow: '#faf380' + blue: '#707fd0' + magenta: '#c583d0' + cyan: '#8adaf1' + white: '#e0e3e7' + + +#colors: +# primary: +# background: '#0F111A' +# foreground: '#8F93A2' +# normal: +# black: '#0F111A' +# red: '#FF5370' +# green: '#99C794' +# yellow: '#C4E88D' +# blue: '#82AAFF' +# magenta: '#C792EA' +# cyan: '#89DDFF' +# white: '#464B5D' +# bright: +# black: '#0F111A' +# red: '#FF5370' +# green: '#99C794' +# yellow: '#C4E88D' +# blue: '#82AAFF' +# magenta: '#C792EA' + # cyan: '#89DDFF' + # white: '#8F93A2' diff --git a/.config/bspwm/bspcmd b/.config/bspwm/bspcmd new file mode 100755 index 0000000..94bed26 --- /dev/null +++ b/.config/bspwm/bspcmd @@ -0,0 +1,37 @@ +#!/bin/bash + +CMD=${1:-help}; shift + +help() { + echo "Available commands:" + echo " * unhide - select and unhide window" +} + +unhide() { + action=${1:-list} + case $action in + "list") + selection=`for id in $(bspc query -N -n .hidden); do + title=$(xtitle $id) + [[ -z "$title" ]] && title="<unnamed>" + echo $id $title + done | rofi -dmenu -i -p "Hidden windows" | cut -f1 -d' '` + + [[ -z "$selection" ]] && exit 1 + + bspc node $selection -g hidden=off + ;; + esac +} + +case $CMD in + "help") + help + ;; + "unhide") + unhide $1 + ;; + *) + help + ;; +esac diff --git a/.config/bspwm/bspwmrc b/.config/bspwm/bspwmrc new file mode 100755 index 0000000..935f41b --- /dev/null +++ b/.config/bspwm/bspwmrc @@ -0,0 +1,184 @@ +#! /bin/sh + +#░█▀▄░█▀▀░█▀█░█░█░█▄█ +#░█▀▄░▀▀█░█▀▀░█▄█░█░█ +#░▀▀░░▀▀▀░▀░░░▀░▀░▀░▀ + +bspc monitor LVDS-1 -d 1 2 3 4 5 +bspc monitor HDMI-1 -d 6 7 8 9 0 +#xdo below -t $(xdo id -n root) $(xdo id -a polybar-bottom_LVDS-1) + +###---Global Settings---### +bspc config automatic_scheme alternate +bspc config initial_polarity second_child +bspc config pointer_action1 move +bspc config pointer_action2 resize_side +bspc config pointer_action2 resize_corner +bspc config focus_follows_pointer false +bspc config remove_disabled_monitors true +bspc config remove_unplugged_monitors true +bspc config merge_overlapping_monitors true +bspc config border_width 2 +bspc config window_gap 10 +bspc config split_ratio 0.52 +bspc config borderless_monocle true +bspc config gapless_monocle true +bspc config swallow_first_click false +bspc config pointer_modifier mod1 +#bspc config pointer_action1 resize_side +#bspc config pointer_action1 resize_corner +#bspc config pointer_action3 move +bspc config normal_border_color "#282828" +bspc config active_border_color "#ebdbb2" +bspc config focused_border_color "#77dd77" +bspc config presel_feedback_color "#BF616A" +#bspc config normal_border_color "#282828" +#bspc config active_border_color "#ebdbb2" +#bspc config focused_border_color "#fe8019" + +# remove all rules first +bspc rule -r *:* + +#bspc rule -a Plank layer=above manage=on border=off focus=off locked=off +bspc rule -a Plank layer=above border=off + + +###---Autostart---#### +#pkill sxhkd; sxhkd & +pgrep -x sxhkd > /dev/null || sxhkd & +picom -b --experimental-backends & +if [[ $(xrandr -q | grep 'HDMI-1 connected') ]]; then + xrandr --output LVDS-1 --primary --mode 1366x768 --rotate normal --output HDMI-1 --mode 1920x1080 --rotate normal --right-of LVDS-1 +fi +xfce4-panel --disable-wm-check & +"$HOME"/.config/polybar/launch.sh & +dunst & # notification daemon +unclutter & # Remove mouse when idle +nitrogen --force-setter=xinerama --restore & +bspc rule -a \* rectangle=680x700+340+40 +bspc rule -a '*:*:Picture-in-Picture' state=floating sticky=on layer=above +bspc rule -a '*:*:Picture in picture' state=floating sticky=on layer=above +#if [ -n "Picture-in-Picture" ]; then +# xdo raise "Picture-in-Picture" +#fi +bspc rule -a firefox:Toolkit focus=on state=floating sticky=on layer=above rectangle=320x190+1030+480 +#bspc rule -a firefox:Toolkit sticky=on state=floating +#bspc rule -a firefox desktop='^3' state=pseudo_tiled rectangle=1260x760+0+0 center=on follow=on +#bspc rule -a firefox:firefox state=floating rectangle=748x478+0+0 center=on sticky=on +#bspc rule -a firefox:Firefox state=floating rectangle=499x289+0+0 center=on sticky=on +#bspc rule -a InputOutput state=floating sticky=on +bspc rule -a "https://www.youtube.com - Enhancer for YouTube™ — Mozilla Firefox" state=floating sticky=on layer=above +#bspc rule -a firefox state=floating +bspc rule -a Zathura state=floating + +eww daemon & +#killall bspswallow +#pidof bspswallow | bspswallow & +#fcitx -d & +#plank & +#bspc rule -a scratchpad sticky=on state=floating rectangle=560x260+500+0 +#killall plank; plank; xdotool search --class Plank windowraise & +#xdotool search --onlyvisible --class Plank set_window $window_id windowraise & +#xdotool search --class Plank windowreparent & + +# SCRATCHPAD + +#scratchpad_xy="750x265" +#display_xy=$(xdpyinfo | grep -i dimensions | awk '{ print $2 }') +#half_display=$(echo $display_xy | tr 'x' ' ' | cut -f1 -d' ' | xargs -I _ echo _/2 | bc) +#half_scratchpad=$(echo $scratchpad_xy | tr 'x' ' ' | cut -f1 -d' ' | xargs -I _ echo _/2 | bc) +#offset=$(echo ${half_display}-${half_scratchpad} | bc) + +#sid=$(wmctrl -lx | grep scratch.scratchpad| cut -d' ' -f1| head -1) \ +#&& [ -z "$(echo $sid)" ] \ +# && alacritty -t scratchpad --class scratch,scratchpad -e zsh -c "zsh tmux attach -t scratch || tmux new -s scratch"\ +# & sleep 1 \ +# && sid=$(wmctrl -lx | grep scratch.scratchpad| cut -d' ' -f1| head -1) \ +# && echo "$sid" > /tmp/scratchID ; +#-e tmux attach -t scratchpad || tmux new -s scratchpad; +#-e zsh -c "macchina; zsh"\ +#bspc rule -a scratchpad sticky=on state=floating hidden=on rectangle=750x265+310+480 +#bspc rule -a scratchpad sticky=on state=floating rectangle=800x240+281+502 +#bspc rule -a scratchpad sticky=on state=floating focus=on rectangle=800x240+280+500 +#bspc rule -a alacritty sticky=on state=floating focus=on rectangle=680x700+340+40 + +#bspc rule -a scratchpad sticky=on state=floating focus=on rectangle=680x260+340+420 +#bspc rule -a scratchpad sticky=on state=floating focus=on rectangle=510x520+425+200 +#bspc rule -a scratchpad sticky=on state=floating focus=on rectangle=465x320+425+390 +#bspc rule -a scratchpad sticky=on state=floating focus=on rectangle=425x390+468+320 +bspc rule -a scratch sticky=on state=floating rectangle=575x320+393+370 +#bspc rule -a scratchpad sticky=on state=floating focus=on + + +#bspc rule -a scratch sticky=on state=floating focus=on rectangle=680x300+340+420 +bspc rule -a Heads-Up-Display sticky=on state=floating rectangle=320x140+1030+32 +[ "$1" = 0 ] && { + nm-applet & + plank & +} +#if [ -n plank ]; then +# xdo above plank +#fi +#xdotool search --classname plank windowraise +#xdotool search --classname plank windowraise +#xdotool getwindowfocus getwindowgeometry +#scratchpad -e bspc node -g hidden & +#xdotool search --sync --class scratchpad windowunmap --sync %@ +# Autostart +#plank=/tmp/bspwm-startup.lock +#if [ ! -f $plank ]; then +# echo "dummy" > $plank +# plank & +#fi +# Autostart +#touch /tmp/bspwm-startup.lock +#startup_lock_file=/tmp/bspwm-startup.lock +#if [ ! -f $startup_lock_file ]; then +# echo "dummy" > $startup_lock_file +# plank & +#fi + +pkill xfce4-power-manager; sleep 1 && nice -n 1 xfce4-power-manager & +pkill volumeicon; sleep 2 && nice -n 2 volumeicon & +pkill mictray; sleep 2 && nice -n 2 mictray & +#pkill blueman-applet; sleep 3 && nice -n 3 blueman-applet & +#pkill qlipper; sleep 6 && nice -n 6 qlipper & + +bspc subscribe node_state | while read -r _ _ _ _ state flag; do + if [[ "$state" != fullscreen ]]; then continue; fi + if [[ "$flag" == on ]]; then + xdo lower -N Plank + else + xdo raise -N Plank + fi +done & + +#killall plank; plank & +#bspc rule -a kitty sticky=on state=floating rectangle=420x260+11+22 +#pkill nm-applet; nm-applet & +#pkill xfce4-power-manager; xfce4-power-manager & +#pkill volumeicon; volumeicon & +#pkill mictray; mictray & +#pkill blueman-applet; blueman-applet & +#pkill qlipper; qlipper & +#flameshot & +#sleep 1 && nice -n 0 pkill nm-applet; nm-applet & +#sleep 2 && nice -n 1 pkill xfce4-power-manager; xfce4-power-manager & +#sleep 3 && nice -n 2 pkill volumeicon; volumeicon & +#sleep 4 && nice -n 2 pkill mictray; mictray & +#sleep 5 && nice -n 3 pkill blueman-applet; blueman-applet & +#sleep 6 && nice -n 5 pkill qlipper; qlipper & +#sleep 1 && nice -n 18 pkill udiskie; udiskie --no-automount --tray & +xrdb ~/.config/X11/.Xresources & +# Start tmux if not already running +# Calculate the center of the screen for a 600x400 scratchpad +# rectangle=WidthxHeight+Xoffset+Yoffset +#bspc rule -a scratchy sticky=on state=floating rectangle=${scratchpad_xy}+${offset}+0 +#xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" $(xdo id -n polybar bottom) +#xdo lower -N polybar bottom +#xdo above -N polybar bottom -t $(xdo id -N Bspwm -n root) +#xdo below -t $(xdo id -n root) $(xdo id -a polybar bottom) +#xdo lower -N "polybar" +#xdo above -N "polybar" -t $(xdo id -N Bspwm -n root) +#xdo below -t $(xdo id -n root) $(xdo id -a polybar-bottom_LDVS-1) +bspc config external_rules_command ~/.config/bspwm/scripts/external_rules.sh diff --git a/.config/bspwm/menu.sh b/.config/bspwm/menu.sh new file mode 100755 index 0000000..f678ae1 --- /dev/null +++ b/.config/bspwm/menu.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#1A237E" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun \ +-display-drun "Applications " -drun-display-format "{name}" \ +-hide-scrollbar true \ +-bw 0 \ +-lines 10 \ +-line-padding 10 \ +-padding 20 \ +-width 30 \ +-xoffset 27 -yoffset 60 \ +-location 1 \ +-columns 2 \ +-show-icons -icon-theme "Papirus" \ +-font "Fantasque Sans Mono 10" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground + diff --git a/.config/bspwm/noswallow b/.config/bspwm/noswallow new file mode 100644 index 0000000..139597f --- /dev/null +++ b/.config/bspwm/noswallow @@ -0,0 +1,2 @@ + + diff --git a/.config/bspwm/scripts/external_rules.sh b/.config/bspwm/scripts/external_rules.sh new file mode 100755 index 0000000..74fdaa0 --- /dev/null +++ b/.config/bspwm/scripts/external_rules.sh @@ -0,0 +1,39 @@ +#!/bin/env bash + +#instance=$3 +#[!-z"$3"] && xdo raise -a polybar-bottom_LVDS-1 +#[!-z"$3"] && xdo below -a polybar-bottom_LVDS-1 -t $(xdo id -N Bspwm -n root) + + +#bspc subscribe node_state | while read -r _ _ _ _ state flag; do +# if [[ "$state" != fullscreen ]]; then continue; fi +# if [[ "$flag" == on ]]; then +# xdo lower -N Plank +# else +# xdo raise -N Plank +# fi +#done & +# +#eval $4 +#bspc query -N -d ${desktop:-focused} -n .fullscreen >/dev/null && +# echo layer=above + + +#bspc subscribe node_state | while read -r _ _ _ _ state flag; do +# if [[ "$state" != fullscreen ]]; then continue; fi +# if [[ "$flag" == on ]]; then +# xdo lower -a polybar-bottom_LVDS-1 +# else +# xdo raise -a polybar-bottom_LVDS-1 +# fi +#done & + +# Allow any type of window to ignore fullscreen windows (allow fullscreen to +# stay) +wid="$1" +class="$2" +instance="$3" +eval "$4" + +[[ "$state" = floating ]] \ + && echo 'layer=above' diff --git a/.config/bspwm/swallow b/.config/bspwm/swallow new file mode 100644 index 0000000..21b7f00 --- /dev/null +++ b/.config/bspwm/swallow @@ -0,0 +1,3 @@ +sxiv +Sxiv +zathura diff --git a/.config/bspwm/sysmenu.sh b/.config/bspwm/sysmenu.sh new file mode 100755 index 0000000..1bdc35e --- /dev/null +++ b/.config/bspwm/sysmenu.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#1A237E" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +MENU="$(rofi -no-lazy-grab -sep "|" -dmenu -i -p 'System :' \ +-hide-scrollbar true \ +-bw 0 \ +-lines 4 \ +-line-padding 10 \ +-padding 20 \ +-width 15 \ +-xoffset -27 -yoffset 60 \ +-location 3 \ +-columns 1 \ +-show-icons -icon-theme "Papirus" \ +-font "Fantasque Sans Mono 10" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +<<< " Lock| Logout| Reboot| Shutdown")" +case "$MENU" in + *Lock) i3lock -c 282a36 -n ;; + *Logout) openbox --exit;; + *Reboot) sudo reboot ;; + *Shutdown) sudo shutdown -r now +esac + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground + diff --git a/.config/bspwm/terminals b/.config/bspwm/terminals new file mode 100644 index 0000000..414337e --- /dev/null +++ b/.config/bspwm/terminals @@ -0,0 +1 @@ +Alacritty diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc new file mode 100644 index 0000000..b9cf04f --- /dev/null +++ b/.config/dunst/dunstrc @@ -0,0 +1,500 @@ +# See dunst(5) for all configuration options + +[global] + ### Display ### + + # Which monitor should the notifications be displayed on. + monitor = 0 + + # Display notification on focused monitor. Possible modes are: + # mouse: follow mouse pointer + # keyboard: follow window with keyboard focus + # none: don't follow anything + # + # "keyboard" needs a window manager that exports the + # _NET_ACTIVE_WINDOW property. + # This should be the case for almost all modern window managers. + # + # If this option is set to mouse or keyboard, the monitor option + # will be ignored. + follow = mouse + + # The geometry of the window: + #[{width}]x{height}[+/-{x}+/-{y}] + # The geometry of the message window. + # The height is measured in number of notifications everything else + # in pixels. If the width is omitted but the height is given + # ("-geometry x2"), the message window expands over the whole screen + # (dmenu-like). If width is 0, the window expands to the longest + # message displayed. A positive x is measured from the left, a + # negative from the right side of the screen. Y is measured from + # the top and down respectively. + # The width can be negative. In this case the actual width is the + # screen width minus the width defined in within the geometry option. + geometry = "300x5-7+30" + + # Scale factor. It is auto-detected if value is 0. + scale = 0 + + # Turn on the progess bar. It appears when a progress hint is passed with + # for example dunstify -h int:value:12 + progress_bar = true + + # Set the progress bar height. This includes the frame, so make sure + # it's at least twice as big as the frame width. + progress_bar_height = 10 + + # Set the frame width of the progress bar + progress_bar_frame_width = 1 + + # Set the minimum width for the progress bar + progress_bar_min_width = 150 + + # Set the maximum width for the progress bar + progress_bar_max_width = 300 + + + # Show how many messages are currently hidden (because of geometry). + indicate_hidden = yes + + # Shrink window if it's smaller than the width. Will be ignored if + # width is 0. + shrink = no + + # The transparency of the window. Range: [0; 100]. + # This option will only work if a compositing window manager is + # present (e.g. xcompmgr, compiz, etc.). (X11 only) + transparency = 0 + + # The height of the entire notification. If the height is smaller + # than the font height and padding combined, it will be raised + # to the font height and padding. + notification_height = 45 + + # Draw a line of "separator_height" pixel height between two + # notifications. + # Set to 0 to disable. + separator_height = 2 + + # Padding between text and separator. + padding = 8 + + # Horizontal padding. + horizontal_padding = 15 + + # Padding between text and icon. + text_icon_padding = 12 + + # Defines width in pixels of frame around the notification window. + # Set to 0 to disable. + frame_width = 3 + + # Defines color of the frame around the notification window. + frame_color = "#f0f2f5" + #frame_color = "#2E3440" + + # Define a color for the separator. + # possible values are: + # * auto: dunst tries to find a color fitting to the background; + # * foreground: use the same color as the foreground; + # * frame: use the same color as the frame; + # * anything else will be interpreted as a X color. + separator_color = frame + + # Sort messages by urgency. + sort = yes + + # Don't remove messages, if the user is idle (no mouse or keyboard input) + # for longer than idle_threshold seconds. + # Set to 0 to disable. + # A client can set the 'transient' hint to bypass this. See the rules + # section for how to disable this if necessary + # idle_threshold = 120 + + ### Text ### + + font = UbuntuMono Nerd Font 9 + + # The spacing between lines. If the height is smaller than the + # font height, it will get raised to the font height. + line_height = 0 + + # Possible values are: + # full: Allow a small subset of html markup in notifications: + # <b>bold</b> + # <i>italic</i> + # <s>strikethrough</s> + # <u>underline</u> + # + # For a complete reference see + # <https://developer.gnome.org/pango/stable/pango-Markup.html>. + # + # strip: This setting is provided for compatibility with some broken + # clients that send markup even though it's not enabled on the + # server. Dunst will try to strip the markup but the parsing is + # simplistic so using this option outside of matching rules for + # specific applications *IS GREATLY DISCOURAGED*. + # + # no: Disable markup parsing, incoming notifications will be treated as + # plain text. Dunst will not advertise that it has the body-markup + # capability if this is set as a global setting. + # + # It's important to note that markup inside the format option will be parsed + # regardless of what this is set to. + markup = strip + show_indicators = false + + + # The format of the message. Possible variables are: + # %a appname + # %s summary + # %b body + # %i iconname (including its path) + # %I iconname (without its path) + # %p progress value if set ([ 0%] to [100%]) or nothing + # %n progress value if set without any extra characters + # %% Literal % + # Markup is allowed + format = "<b>%s</b>\n%b" + + # Alignment of message text. + # Possible values are "left", "center" and "right". + alignment = left + + # Vertical alignment of message text and icon. + # Possible values are "top", "center" and "bottom". + vertical_alignment = top + + # Show age of message if message is older than show_age_threshold + # seconds. + # Set to -1 to disable. + show_age_threshold = 60 + + # Split notifications into multiple lines if they don't fit into + # geometry. + word_wrap = yes + + # When word_wrap is set to no, specify where to make an ellipsis in long lines. + # Possible values are "start", "middle" and "end". + ellipsize = middle + + # Ignore newlines '\n' in notifications. + ignore_newline = no + + # Stack together notifications with the same content + stack_duplicates = true + + # Hide the count of stacked notifications with the same content + hide_duplicate_count = false + + # Display indicators for URLs (U) and actions (A). + show_indicators = false + + ### Icons ### + + # Align icons left/right/off + icon_position = left + + # Scale small icons up to this size, set to 0 to disable. Helpful + # for e.g. small files or high-dpi screens. In case of conflict, + # max_icon_size takes precedence over this. + min_icon_size = 0 + + # Scale larger icons down to this size, set to 0 to disable + max_icon_size = 32 + + # Paths to default icons. + icon_path = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/ + + ### History ### + + # Should a notification popped up from history be sticky or timeout + # as if it would normally do. + sticky_history = yes + + # Maximum amount of notifications kept in history + history_length = 20 + + ### Misc/Advanced ### + + # dmenu path. + dmenu = /usr/bin/dmenu -p dunst: + + # Browser for opening urls in context menu. + browser = /usr/bin/brave -new-tab + + # Always run rule-defined scripts, even if the notification is suppressed + always_run_script = true + + # Define the title of the windows spawned by dunst + title = Dunst + + # Define the class of the windows spawned by dunst + class = Dunst + + # Print a notification on startup. + # This is mainly for error detection, since dbus (re-)starts dunst + # automatically after a crash. + startup_notification = false + + # Manage dunst's desire for talking + # Can be one of the following values: + # crit: Critical features. Dunst aborts + # warn: Only non-fatal warnings + # mesg: Important Messages + # info: all unimportant stuff + # debug: all less than unimportant stuff + verbosity = mesg + + # Define the corner radius of the notification window + # in pixel size. If the radius is 0, you have no rounded + # corners. + # The radius will be automatically lowered if it exceeds half of the + # notification height to avoid clipping text and/or icons. + corner_radius = 0 + + # Ignore the dbus closeNotification message. + # Useful to enforce the timeout set by dunst configuration. Without this + # parameter, an application may close the notification sent before the + # user defined timeout. + ignore_dbusclose = false + + ### Wayland ### + # These settings are Wayland-specific. They have no effect when using X11 + + # Uncomment this if you want to let notications appear under fullscreen + # applications (default: overlay) + # layer = top + + # Set this to true to use X11 output on Wayland. + force_xwayland = false + + ### Legacy + + # Use the Xinerama extension instead of RandR for multi-monitor support. + # This setting is provided for compatibility with older nVidia drivers that + # do not support RandR and using it on systems that support RandR is highly + # discouraged. + # + # By enabling this setting dunst will not be able to detect when a monitor + # is connected or disconnected which might break follow mode if the screen + # layout changes. + force_xinerama = false + + ### mouse + + # Defines list of actions for each mouse event + # Possible values are: + # * none: Don't do anything. + # * do_action: Invoke the action determined by the action_name rule. If there is no + # such action, open the context menu. + # * open_url: If the notification has exactly one url, open it. If there are multiple + # ones, open the context menu. + # * close_current: Close current notification. + # * close_all: Close all notifications. + # * context: Open context menu for the notification. + # * context_all: Open context menu for all notifications. + # These values can be strung together for each mouse event, and + # will be executed in sequence. + mouse_left_click = close_current + mouse_middle_click = close_all + mouse_right_click = do_action + +# Experimental features that may or may not work correctly. Do not expect them +# to have a consistent behaviour across releases. +[experimental] + # Calculate the dpi to use on a per-monitor basis. + # If this setting is enabled the Xft.dpi value will be ignored and instead + # dunst will attempt to calculate an appropriate dpi value for each monitor + # using the resolution and physical size. This might be useful in setups + # where there are multiple screens with very different dpi values. + per_monitor_dpi = false + + +[urgency_low] + # IMPORTANT: colors have to be defined in quotation marks. + # Otherwise the "#" and following would be interpreted as a comment. + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + timeout = 5 + # Icon for notifications with low urgency, uncomment to enable + #icon = /path/to/icon + +[urgency_normal] + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + timeout = 10 + # Icon for notifications with normal urgency, uncomment to enable + #icon = /path/to/icon + +[urgency_critical] + background = "#00101212" + background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + frame_color = #a1dde7 + timeout = 30 + # Icon for notifications with critical urgency, uncomment to enable + #icon = /path/to/icon + +# Every section that isn't one of the above is interpreted as a rules to +# override settings for certain messages. +# +# Messages can be matched by +# appname (discouraged, see desktop_entry) +# body +# category +# desktop_entry +# icon +# match_transient +# msg_urgency +# stack_tag +# summary +# +# and you can override the +# background +# foreground +# format +# frame_color +# fullscreen +# new_icon +# set_stack_tag +# set_transient +# timeout +# urgency +# action_name +# +# Shell-like globbing will get expanded. +# +# Instead of the appname filter, it's recommended to use the desktop_entry filter. +# GLib based applications export their desktop-entry name. In comparison to the appname, +# the desktop-entry won't get localized. +# +# SCRIPTING +# You can specify a script that gets run when the rule matches by +# setting the "script" option. +# The script will be called as follows: +# script appname summary body icon urgency +# where urgency can be "LOW", "NORMAL" or "CRITICAL". +# +# NOTE: if you don't want a notification to be displayed, set the format +# to "". +# NOTE: It might be helpful to run dunst -print in a terminal in order +# to find fitting options for rules. + +# Disable the transient hint so that idle_threshold cannot be bypassed from the +# client +#[transient_disable] +# match_transient = yes +# set_transient = no +# +# Make the handling of transient notifications more strict by making them not +# be placed in history. +#[transient_history_ignore] +# match_transient = yes +# history_ignore = yes + +# fullscreen values +# show: show the notifications, regardless if there is a fullscreen window opened +# delay: displays the new notification, if there is no fullscreen window active +# If the notification is already drawn, it won't get undrawn. +# pushback: same as delay, but when switching into fullscreen, the notification will get +# withdrawn from screen again and will get delayed like a new notification +#[fullscreen_delay_everything] +# fullscreen = delay +#[fullscreen_show_critical] +# msg_urgency = critical +# fullscreen = show + +#[espeak] +# summary = "*" +# script = dunst_espeak.sh + +#[script-test] +# summary = "*script*" +# script = dunst_test.sh + +#[ignore] +# # This notification will not be displayed +# summary = "foobar" +# format = "" + +#[history-ignore] +# # This notification will not be saved in history +# summary = "foobar" +# history_ignore = yes + +#[skip-display] +# # This notification will not be displayed, but will be included in the history +# summary = "foobar" +# skip_display = yes + +#[signed_on] +# appname = Pidgin +# summary = "*signed on*" +# urgency = low +# +#[signed_off] +# appname = Pidgin +# summary = *signed off* +# urgency = low +# +#[says] +# appname = Pidgin +# summary = *says* +# urgency = critical +# +#[twitter] +# appname = Pidgin +# summary = *twitter.com* +# urgency = normal +[spotify] + appname = Spotify + Summary = *Song* + urgency = critical + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + +[Telegram] + appname = Telegram + summary = *New msg* + urgency = critical + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + +[Discord] + appname = Discord + Summary = *Ping* + urgency = critical + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + + + +[Brave] + appname = Brave + Summary = *Notification* + urgency = critical + background = "#00101212" + #background = "#fafafa" + foreground = "#CECCC9" + #foreground = "#2e2e2e" + + +# +#[stack-volumes] +# appname = "some_volume_notifiers" +# set_stack_tag = "volume" + +# +# vim: ft=cfg diff --git a/.config/eww/bar/main.yuck b/.config/eww/bar/main.yuck new file mode 100644 index 0000000..a379ace --- /dev/null +++ b/.config/eww/bar/main.yuck @@ -0,0 +1,193 @@ +(defwindow bar + :monitor 0 + :geometry (geometry :x -28 :y 0 :anchor "center right") +(bar)) + +(defwidget bar [] + (box + :class "bar" + :orientation "v" + :space-evenly false + (bar-group + (bar-item-center-window) + (bar-item-resize-ratio) + (bar-item-resize) + (bar-item-toggle-floaty) + (bar-item-close-window) + ) + (bar-group + (bar-item-balance) + (bar-item-rotate) + (bar-item-focus-parent) + ) + (bar-group + (bar-item-toggle-borders) + (bar-item-toggle-hidden) + (bar-item-toggle-monocle) + ) + (bar-group + (bar-item-empty-desktop) + (bar-item-cycle-desktops) + ) + (bar-group + ;(bar-item-clipboard) + (bar-item-screenshot) + (bar-item-power) + ) + ) +) + +(defwidget bar-group [] + (box + :class "bar-group" + :orientation "v" + (children) + ) +) + +(defwidget bar-item [icon ?color ?lclick ?rclick] + (box + :class "bar-item" + (eventbox + :onscroll "resize-window {}" + (button + :onclick lclick + :onrightclick rclick + ;:timeout 200 + (icon :name icon :color color) + ) + ) + ) +) + +(defwidget bar-item-balance [] + (bar-item + :icon "columns" + :color "yellow" + :lclick "bspc node @/ -B" + ) +) + +(defwidget bar-item-center-window [] + (bar-item + :icon "minimize" + :color "yellow" + :lclick "center-window" + ) +) + +(defwidget bar-item-clipboard [] + (bar-item + :icon "clipboard" + :color "yellow" + ) +) + +(defwidget bar-item-close-window [] + (bar-item + :icon "x-circle" + :color "red" + :lclick "close-window" + ) +) + +(defwidget bar-item-cycle-desktops [] + (bar-item + :icon "skip-forward" + :color "blue" + :lclick "show-desktop next" + :rclick "show-desktop prev" + ) +) + +(defwidget bar-item-empty-desktop [] + (bar-item + :icon "plus-circle" + :color "green" + :lclick "show-desktop empty" + ) +) + +(defwidget bar-item-focus-parent [] + (bar-item + :icon "arrow-up-circle" + :color "blue" + :lclick "bspc node -f @parent" + ) +) + +(defwidget bar-item-power [] + (bar-item + :icon "power" + :color "red" + :lclick "shut-down" + ) +) + +(defwidget bar-item-resize [] + (bar-item + :icon "maximize-2" + :color "blue" + :lclick "bspc node -z top_left -16 -9 \ + && bspc node -z bottom_right 16 9" + :rclick "bspc node -z top_left 16 9 \ + && bspc node -z bottom_right -16 -9" + ) +) + +(defwidget bar-item-resize-ratio [] + (bar-item + :icon "youtube" + :color "green" + :lclick "resize-ratio 16 9" + ) +) + +(defwidget bar-item-rotate [] + (bar-item + :icon "rotate-cw" + :color "green" + :lclick "bspc node -R 90" + ) +) + +(defwidget bar-item-screenshot [] + (bar-item + :icon "camera" + :color "purple" + :lclick "notify hello" + :rclick "scrot -s -l mode=edge,width=7,color=\"#FFFFFF\",opacity=20 -e 'mv $f ~/unsorted/screenshots'" + ) +) + +(defwidget bar-item-toggle-borders [] + (bar-item + :icon "maximize" + :icon {disableBorders ? "square" : "maximize"} + :color "purple" + :lclick "toggle-borders" + ) +) + +(defwidget bar-item-toggle-floaty [] + (bar-item + :icon {focusIsFloaty ? "corner-left-down" : "corner-right-up"} + :color "purple" + :lclick "toggle-floaty" + ) +) + +(defwidget bar-item-toggle-hidden [] + (bar-item + :icon "eye" + :color "red" + :lclick "toggle-hidden" + ) +) +(defwidget bar-item-toggle-monocle [] + (bar-item + :icon {monocleMode ? "zoom-out" : "zoom-in"} + :color "yellow" + :lclick "toggle-monocle" + ) +) diff --git a/.config/eww/bar/style.scss b/.config/eww/bar/style.scss new file mode 100644 index 0000000..121cd12 --- /dev/null +++ b/.config/eww/bar/style.scss @@ -0,0 +1,16 @@ +.bar { + background-color: $borderColor; + // border: $borderSize solid $borderColor; + padding: $borderSize 0 0 0; +} + +.bar-group { + background-color: $bgColor; + border-radius: $borderRadius; + margin: 0 $borderSize $borderSize $borderSize; + padding: 7; +} + +.bar-item { + padding: 7; +} diff --git a/.config/eww/dock/main.yuck b/.config/eww/dock/main.yuck new file mode 100644 index 0000000..a3ec73f --- /dev/null +++ b/.config/eww/dock/main.yuck @@ -0,0 +1,94 @@ +(defwindow dock + :monitor 0 + :geometry (geometry :x 0 :y -28 :anchor "bottom center") + (dock)) + +(defwidget dock [] + (box + :class "dock" + :space-evenly false + (dock-group + (dock-item + :icon "firefox" + :lclick "quick-app -c firefox -i Navigator&" + :rclick "firefox&" + ) + (dock-item + :icon "nautilus" + :lclick "quick-app -c Thunar -f thunar ~/unsorted" + ) + (dock-item + :icon "terminal" + :lclick "quick-app -c kitty -i quick -f kitty --name quick" + :rclick "cd ~ && kitty&" + ) + ) + (dock-group + (dock-item + :icon "email" + ) + (dock-item + :icon "telegram" + :lclick "quick-app -c TelegramDesktop -f telegram-desktop" + ) + (dock-item + :icon "weechat" + ) + (dock-item + :icon "discord-development" + :lclick "quick-app -c discord -f" + ) + ) + (dock-group + (dock-item + :icon "preferences-desktop-color" + ;:icon "openrgb" + ;:icon "gcolor3" + :lclick "quick-app -c Gcolor3 -f gcolor3" + ) + (dock-item + :icon "gnome-calculator" + :lclick "quick-app -c gnome-calculator -f" + ) + (dock-item + :icon "easyeffects" + :lclick "quick-app -c easyeffects -f" + ) + (dock-item + :icon "obs" + :lclick "quick-app -c obs -f" + ) + (dock-item + :icon "deepin-music-player" + ) + ) + (dock-group + (dock-item :icon "youtube" :lclick "quick-app -c mpv&") + (dock-item + :icon "steam" + :lclick "quick-app -c Steam steam&" + ) + (dock-item :icon "blender" :lclick "quick-app -c Blender blender&") + (dock-item :icon "godot" :lclick "quick-app -c Godot -f godot&") + (dock-item :icon "inkscape" :lclick "quick-app -c Inkscape inkscape&") + ) + ) +) + +(defwidget dock-group [] + (box + :class "dock-group" + (children) + ) +) + +(defwidget dock-item [icon ?lclick ?rclick] + (box + :class "dock-item" + (button + :onclick lclick + :onrightclick rclick + (image :path "${appIcons}${icon}.svg") + ) + ) +) diff --git a/.config/eww/dock/style.scss b/.config/eww/dock/style.scss new file mode 100644 index 0000000..4cc4515 --- /dev/null +++ b/.config/eww/dock/style.scss @@ -0,0 +1,16 @@ +.dock { + background-color: $borderColor; + // border: $borderSize solid $borderColor; + padding: 0 0 0 $borderSize; +} + +.dock-group { + background-color: $bgColor; + border-radius: $borderRadius; + margin: $borderSize $borderSize $borderSize 0; + padding: 5; +} + +.dock-item { + padding: 5; +} diff --git a/.config/eww/eww.scss b/.config/eww/eww.scss new file mode 100644 index 0000000..3c46de1 --- /dev/null +++ b/.config/eww/eww.scss @@ -0,0 +1,21 @@ +$borderColor: #24283b; +$borderRadius: 5px; +$borderSize: 5px; +$bgColor: #1a1b26; +$fgColor: #c0caf5; + +* { + all: unset; + color: $fgColor; +} + +// .window { +// background-color: $bgColor; +// border: $borderSize solid $borderColor; +// color: $fgColor; +// } + +@import "bar/style.scss"; +@import "dock/style.scss"; +@import "panel/style.scss"; +@import "status/style.scss"; diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck new file mode 100644 index 0000000..fbd1bc3 --- /dev/null +++ b/.config/eww/eww.yuck @@ -0,0 +1,26 @@ +(defvar appIcons "/usr/share/icons/Papirus-Dark/48x48/apps/") +(defvar barIcons "/home/sxrdusr/.local/share/icons/feather-icons/") + +(defvar disableBorders false) +(defvar externalMonitor false) +(defvar focusIsFloaty false) +(defvar monocleMode false) +(defvar ultrawide true) +(defvar brightness 10) +(defvar nightlight 0) +(defvar volume 10) + +(defpoll date :interval "1m" "date '+%B %d'") +(defpoll time :interval "2s" "date '+%H:%M'") + +(defwidget icon [name ?color ?size] + (image + :image-width {size?:20} + :path "${barIcons}/${color?:'white'}/${name}.svg" + ) +) + +(include "bar/main.yuck") +(include "dock/main.yuck") +(include "panel/main.yuck") +(include "status/main.yuck") diff --git a/.config/eww/panel/drives.yuck b/.config/eww/panel/drives.yuck new file mode 100644 index 0000000..122f0d8 --- /dev/null +++ b/.config/eww/panel/drives.yuck @@ -0,0 +1,77 @@ +(defwidget dock-drives [] + (box + :orientation "v" + (disk + :label "System" + :mount "/" + :space "100" + ) + (disk + :label "SSD 1" + :mount "/mnt/ssd250" + :space "250" + ) + (disk + :label "SSD 2" + :mount "/mnt/games" + :space "250" + ) + (disk + :label "HDD" + :mount "/mnt/hdd500" + :space "500" + ) + (disk + :label "RAID" + :mount "/mnt/raid" + :space "3000" + ) + ) +) + +(defwidget disk [label mount space] + (eventbox + :class "disk-wrapper" + (button + :onclick "quick file ${mount}" + (box + :class "disk" + :space-evenly false + (box + :class "disk-icon" + :width 30 + (image :path "/home/edwin/workspace/icons/hard-drive.svg") + ) + (box + :class "disk-usage" + :orientation "v" + :spacing 3 + :space-evenly false + (box + :class "disk-usage-text" + :width 140 + (box + :halign "start" + :valign "start" + label + ) + (box + :halign "end" + :valign "end" + :hexpand true + :vexpand true + "${round(EWW_DISK[mount].free/1000000000, 0)} GB" + ) + ) + (scale + :class "disk-usage-bar" + :marks "false" + :max 100 + :min 0 + :value {EWW_DISK[mount].used_perc} + ) + ) + ) + ) + ) +) diff --git a/.config/eww/panel/main.yuck b/.config/eww/panel/main.yuck new file mode 100644 index 0000000..ac8b559 --- /dev/null +++ b/.config/eww/panel/main.yuck @@ -0,0 +1,142 @@ +(defwindow panel + :monitor 0 + :geometry (geometry :x 28 :y 0 :anchor "center left") + (panel)) + +(defwidget panel [] + (box + :class "panel" + :orientation "v" + :space-evenly false + (panel-audio) + (panel-video) + ) +) + +; Panel Items + +(defwidget panel-buttons [] + (box + :class "panel-buttons" + :space-evenly false + (children) + ) +) + +(defwidget panel-checkbox [?change text ?value] + (button + :onclick change + (box + :class "panel-checkbox" + :space-evenly false + (icon :name {value ? "check-square" : "square"}) + text + ) + ) +) + +(defwidget panel-slider [icon ?setter ?value] + (eventbox + ;:onscroll setter + (box + :space-evenly false + (icon :name icon) + (scale + :class "panel-slider" + :min 0 + :max 11 + :onchange setter + :value value + ) + ) + ) +) + +; Panel Sections + +(defwidget panel-section [color icon title] + (box + :class "panel-section" + :orientation "v" + :space-evenly false + (box + :class "panel-header" + :spacing 10 + :space-evenly false + (icon :name icon :color color) + title + ) + (box + :orientation "v" + :space-evenly false + :spacing 14 + (children) + ) + ) +) + +(defwidget panel-audio [] + (panel-section + :color "green" + :icon "sliders" + :title "Audio" + + ; audio device + (panel-buttons + (button :onclick "set-output -a pci-0000_00_1b" "Bar") + (button :onclick "set-output -a stereo-game" "Headset") + (button :onclick "set-output -a HD3" "Speakers") + ) + + ; volume slider + (panel-slider + :icon "volume-2" + :setter "set-volume {}" + :value volume + ) + ) +) + +(defwidget panel-video [] + (panel-section + :color "red" + :icon "monitor" + :title "Video" + + ; wallpaper setter + (eventbox + :ondropped "set-wallpaper {}" + (button + :onclick "quick-app -c Thunar -f \ + && thunar /home/edwin/.local/share/backgrounds" + (image + :class "panel-wallpaper" + :path "/home/edwin/.config/wallpaper" + :image-height 108 + :image-width 256 + ) + ) + ) + + ; brightness slider + (panel-slider + :icon "sun" + :setter "set-brightness {}" + :value brightness + ) + + ; external monitor + (panel-checkbox + :change "set-output -e ${!externalMonitor}" + :text "External Monitor" + :value externalMonitor + ) + + ; ultrawide resolution + (panel-checkbox + :change "set-output -u ${!ultrawide}" + :text "Ultrawide Resolution" + :value ultrawide + ) + ) +) diff --git a/.config/eww/panel/style.scss b/.config/eww/panel/style.scss new file mode 100644 index 0000000..0f39959 --- /dev/null +++ b/.config/eww/panel/style.scss @@ -0,0 +1,69 @@ +.panel { + background-color: $borderColor; + padding: $borderSize; + + .button { + background-color: $borderColor; + border-radius: $borderRadius; + margin-left: 10; + padding: 8; + + &:first-child { + margin-left: 0; + } + } +} + +.panel-buttons { + button { + background-color: $borderColor; + border-radius: $borderRadius; + margin-left: 14; + padding: 7 9; + + &:first-child { + margin-left: 0; + } + } +} + +.panel-checkbox { + image { + margin-right: 10; + } +} + +.panel-header { + margin-bottom: 14; +} + +.panel-section { + background-color: $bgColor; + border-radius: $borderRadius; + margin-top: $borderSize; + padding: 14; + + &:first-child { + margin-top: 0; + } +} + +.panel-slider { + margin-left: 10; + + trough { + background-color: $borderColor; + border-radius: 5; + min-height: 10px; + min-width: 232px; + + highlight { + border-radius: 5; + background-color: #414868; + } + } +} + +.panel-wallpaper { + border: 3px solid $borderColor; +} diff --git a/.config/eww/status/main.yuck b/.config/eww/status/main.yuck new file mode 100644 index 0000000..c6ebd3e --- /dev/null +++ b/.config/eww/status/main.yuck @@ -0,0 +1,44 @@ +; windows +(defwindow status + :monitor 0 + :geometry (geometry :x 0 :y 28 :anchor "top center") + (status)) + +(defwidget status [] + (box + :class "status" + :space-evenly false + :spacing 5 + (status-item :color "green" :icon "clock" :text time) + (status-item :color "yellow" :icon "calendar" :text date) + (status-item + :color "red" + :icon "thermometer" + :text "${EWW_TEMPS["CPU"]}°" + ) + (status-item + :color "blue" + :icon "cpu" + :text "${round(EWW_CPU["avg"],0)}%" + ) + (status-item + :color "purple" + :icon "database" + :text "${round(EWW_RAM["used_mem_perc"],0)}%" + ) + ) +) + +(defwidget status-item [icon ?color text] + (box + :class "status-item" + :space-evenly false + :spacing 7 + (icon :color color :name icon) + text + ) +) + +(defwidget status-seperator [] + (box :class "status-seperator") +) diff --git a/.config/eww/status/style.scss b/.config/eww/status/style.scss new file mode 100644 index 0000000..a31257e --- /dev/null +++ b/.config/eww/status/style.scss @@ -0,0 +1,14 @@ +.status { + background-color: $borderColor; + border: $borderSize solid $borderColor; +} + +.status-item { + background-color: $bgColor; + border-radius: $borderRadius; + font-family: "Inter"; + font-size: 13; + font-weight: 700; + min-width: 60px; + padding: 7; +} diff --git a/.config/kitty/kitty.conf b/.config/kitty/kitty.conf new file mode 100644 index 0000000..c4e26eb --- /dev/null +++ b/.config/kitty/kitty.conf @@ -0,0 +1,818 @@ + +# vim:fileencoding=utf-8:ft=conf:foldmethod=marker + +#: Fonts {{{ + +#: kitty has very powerful font management. You can configure +#: individual font faces and even specify special fonts for particular +#: characters. + +font_family JetBrains Mono Medium +bold_font auto +italic_font auto +bold_italic_font auto + +#: You can specify different fonts for the bold/italic/bold-italic +#: variants. By default they are derived automatically, by the OSes +#: font system. Setting them manually is useful for font families that +#: have many weight variants like Book, Medium, Thick, etc. For +#: example: + +#: font_family Operator Mono Book +#: bold_font Operator Mono Medium +#: italic_font Operator Mono Book Italic +#: bold_italic_font Operator Mono Medium Italic + +font_size 11.0 + +#: Font size (in pts) + +# adjust_line_height 0 +# adjust_column_width 0 + +#: Change the size of each character cell kitty renders. You can use +#: either numbers, which are interpreted as pixels or percentages +#: (number followed by %), which are interpreted as percentages of the +#: unmodified values. You can use negative pixels or percentages less +#: than 100% to reduce sizes (but this might cause rendering +#: artifacts). + +# symbol_map U+E0A0-U+E0A2,U+E0B0-U+E0B3 PowerlineSymbols + +#: Map the specified unicode codepoints to a particular font. Useful +#: if you need special rendering for some symbols, such as for +#: Powerline. Avoids the need for patched fonts. Each unicode code +#: point is specified in the form U+<code point in hexadecimal>. You +#: can specify multiple code points, separated by commas and ranges +#: separated by hyphens. symbol_map itself can be specified multiple +#: times. Syntax is:: + +#: symbol_map codepoints Font Family Name + +# box_drawing_scale 0.001, 1, 1.5, 2 + +#: Change the sizes of the lines used for the box drawing unicode +#: characters These values are in pts. They will be scaled by the +#: monitor DPI to arrive at a pixel value. There must be four values +#: corresponding to thin, normal, thick, and very thick lines. + +#: }}} + +#: Cursor customization {{{ + +# cursor magenta +cursor white + +#: Default cursor color + +# cursor_shape block + +#: The cursor shape can be one of (block, beam, underline) + +cursor_blink_interval 0.5 +cursor_stop_blinking_after 15.0 + +#: The interval (in seconds) at which to blink the cursor. Set to zero +#: to disable blinking. Note that numbers smaller than repaint_delay +#: will be limited to repaint_delay. Stop blinking cursor after the +#: specified number of seconds of keyboard inactivity. Set to zero to +#: never stop blinking. + +#: }}} + +#: Scrollback {{{ + +scrollback_lines 20000 + +#: Number of lines of history to keep in memory for scrolling back. +#: Memory is allocated on demand. + +# scrollback_pager less --chop-long-lines --RAW-CONTROL-CHARS +INPUT_LINE_NUMBER + +#: Program with which to view scrollback in a new window. The +#: scrollback buffer is passed as STDIN to this program. If you change +#: it, make sure the program you use can handle ANSI escape sequences +#: for colors and text formatting. INPUT_LINE_NUMBER in the command +#: line above will be replaced by an integer representing which line +#: should be at the top of the screen. + +wheel_scroll_multiplier 5 + +#: Modify the amount scrolled by the mouse wheel or touchpad. Use +#: negative numbers to change scroll direction. + +#: }}} + +#: Mouse {{{ + +url_color #0087BD +url_style curly + +#: The color and style for highlighting URLs on mouse-over. url_style +#: can be one of: none, single, double, curly + +open_url_modifiers kitty_mod + +#: The modifier keys to press when clicking with the mouse on URLs to +#: open the URL + +open_url_with default + +#: The program with which to open URLs that are clicked on. The +#: special value default means to use the operating system's default +#: URL handler. + +copy_on_select yes + +#: Copy to clipboard on select. With this enabled, simply selecting +#: text with the mouse will cause the text to be copied to clipboard. +#: Useful on platforms such as macOS/Wayland that do not have the +#: concept of primary selectons. Note that this is a security risk, +#: as all programs, including websites open in your browser can read +#: the contents of the clipboard. + +# rectangle_select_modifiers ctrl+alt + +#: The modifiers to use rectangular selection (i.e. to select text in +#: a rectangular block with the mouse) + +# select_by_word_characters :@-./_~?&=%+# + +#: Characters considered part of a word when double clicking. In +#: addition to these characters any character that is marked as an +#: alpha-numeric character in the unicode database will be matched. + +click_interval 0.5 + +#: The interval between successive clicks to detect double/triple +#: clicks (in seconds) + +# mouse_hide_wait 3.0 + +#: Hide mouse cursor after the specified number of seconds of the +#: mouse not being used. Set to zero to disable mouse cursor hiding. + +# focus_follows_mouse no + +#: Set the active window to the window under the mouse when moving the +#: mouse around + +#: }}} + +#: Performance tuning {{{ + +repaint_delay 10 + +#: Delay (in milliseconds) between screen updates. Decreasing it, +#: increases frames-per-second (FPS) at the cost of more CPU usage. +#: The default value yields ~100 FPS which is more than sufficient for +#: most uses. Note that to actually achieve 100 FPS you have to either +#: set sync_to_monitor to no or use a monitor with a high refresh +#: rate. + +# input_delay 3 + +#: Delay (in milliseconds) before input from the program running in +#: the terminal is processed. Note that decreasing it will increase +#: responsiveness, but also increase CPU usage and might cause flicker +#: in full screen programs that redraw the entire screen on each loop, +#: because kitty is so fast that partial screen updates will be drawn. + +# sync_to_monitor yes + +#: Sync screen updates to the refresh rate of the monitor. This +#: prevents tearing (https://en.wikipedia.org/wiki/Screen_tearing) +#: when scrolling. However, it limits the rendering speed to the +#: refresh rate of your monitor. With a very high speed mouse/high +#: keyboard repeat rate, you may notice some slight input latency. If +#: so, set this to no. + +#: }}} + +#: Terminal bell {{{ + +enable_audio_bell no + +#: Enable/disable the audio bell. Useful in environments that require +#: silence. + +# visual_bell_duration 0.5 + +#: Visual bell duration. Flash the screen when a bell occurs for the +#: specified number of seconds. Set to zero to disable. + +window_alert_on_bell yes + +#: Request window attention on bell. Makes the dock icon bounce on +#: macOS or the taskbar flash on linux. + +bell_on_tab yes + +#: Show a bell symbol on the tab if a bell occurs in one of the +#: windows in the tab and the window is not the currently focused +#: window + +#: }}} + +#: Window layout {{{ + +# remember_window_size yes +# initial_window_width 640 +# initial_window_height 400 + +#: If enabled, the window size will be remembered so that new +#: instances of kitty will have the same size as the previous +#: instance. If disabled, the window will initially have size +#: configured by initial_window_width/height, in pixels. You can use a +#: suffix of "c" on the width/height values to have them interpreted +#: as number of cells instead of pixels. + +enabled_layouts * + +#: The enabled window layouts. A comma separated list of layout names. +#: The special value * means all layouts. The first listed layout will +#: be used as the startup layout. For a list of available layouts, see +#: the layouts. + +# window_resize_step_cells 2 +# window_resize_step_lines 2 + +#: The step size (in units of cell width/cell height) to use when +#: resizing windows. The cells value is used for horizontal resizing +#: and the lines value for vertical resizing. + +window_border_width 1 + +#: The width (in pts) of window borders. Will be rounded to the +#: nearest number of pixels based on screen resolution. Note that +#: borders are displayed only when more than one window is visible. +#: They are meant to separate multiple windows. + +window_margin_width 0 + +#: The window margin (in pts) (blank area outside the border) + +# single_window_margin_width -1000.0 + +#: The window margin (in pts) to use when only a single window is +#: visible. Negative values will cause the value of +#: window_margin_width to be used instead. + +window_padding_width 0 + +#: The window padding (in pts) (blank area between the text and the +#: window border) + +active_border_color #282c34 + +#: The color for the border of the active window + +inactive_border_color #22262d + +#: The color for the border of inactive windows + +# bell_border_color #ff5a00 + +#: The color for the border of inactive windows in which a bell has +#: occurred + +inactive_text_alpha .6 + +#: Fade the text in inactive windows by the specified amount (a number +#: between zero and one, with zero being fully faded). + +#: }}} + +#: Tab bar {{{ + +# tab_bar_edge bottom + +#: Which edge to show the tab bar on, top or bottom + +tab_bar_margin_width 4 + +#: The margin to the left and right of the tab bar (in pts) + +tab_bar_style fade + +#: The tab bar style, can be one of: fade or separator. In the fade +#: style, each tab's edges fade into the background color, in the +#: separator style, tabs are separated by a configurable separator. + +# tab_fade 0.25 0.5 0.75 1 +tab_fade 1 1 1 + +#: Control how each tab fades into the background when using fade for +#: the tab_bar_style. Each number is an alpha (between zero and one) +#: that controls how much the corresponding cell fades into the +#: background, with zero being no fade and one being full fade. You +#: can change the number of cells used by adding/removing entries to +#: this list. + +# tab_separator " " + +#: The separator between tabs in the tab bar when using separator as +#: the tab_bar_style. + +active_tab_foreground #282c34 +active_tab_background #abb2bf +active_tab_font_style bold +inactive_tab_foreground #5c6370 +inactive_tab_background #22262d +inactive_tab_font_style normal + +#: Tab bar colors and styles + +#: }}} + +#: Color scheme {{{ + +foreground #d8dee9 +#background #1d1f21 +background #000000 + +#: The foreground and background colors + +background_opacity 0.6 +dynamic_background_opacity yes +# Increase background opacity ctrl+shift+a>m + +# Decrease background opacity ctrl+shift+a>l + +# Full background opacity ctrl+shift+a>1 + +# Reset background opacity ctrl+shift+a>d + +#: The opacity of the background. A number between 0 and 1, where 1 is +#: opaque and 0 is fully transparent. This will only work if +#: supported by the OS (for instance, when using a compositor under +#: X11). Note that it only sets the default background color's +#: opacity. This is so that things like the status bar in vim, +#: powerline prompts, etc. still look good. But it means that if you +#: use a color theme with a background color in your editor, it will +#: not be rendered as transparent. Instead you should change the +#: default background color in your kitty config and not use a +#: background color in the editor color scheme. Or use the escape +#: codes to set the terminals default colors in a shell script to +#: launch your editor. Be aware that using a value less than 1.0 is a +#: (possibly significant) performance hit. If you want to dynamically +#: change transparency of windows set dynamic_background_opacity to +#: yes (this is off by default as it has a performance cost) + +dim_opacity 1.0 + +#: How much to dim text that has the DIM/FAINT attribute set. One +#: means no dimming and zero means fully dimmed (i.e. invisible). + +selection_foreground #000000 +selection_background #FFFACD + +#: The foreground and background for text selected with the mouse + + +#: The 16 terminal colors. There are 8 basic colors, each color has a +#: dull and bright version. You can also set the remaining colors from +#: the 256 color table as color16 to color255. + +#: black +color0 #313539 +color8 #676f78 + +#: red +color1 #b02626 +color9 #b55454 + +#: green +color2 #40a62f +color10 #78a670 + +#: yellow +color3 #f2e635 +color11 #faf380 + +#: blue +color4 #314ad0 +color12 #707fd0 + +#: magenta +color5 #b30ad0 +color13 #c583d0 + +#: cyan +color6 #32d0fc +color14 #8adaf1 + +#: white +color7 #acadb1 +color15 #e0e3e7 + + +#: }}} + +#: Advanced {{{ + +# shell zsh + +#: The shell program to execute. The default value of . means to use +#: whatever shell is set as the default shell for the current user. +#: Note that on macOS if you change this, you might need to add +#: --login to ensure that the shell starts in interactive mode and +#: reads its startup rc files. + +editor . + +#: The console editor to use when editing the kitty config file or +#: similar tasks. A value of . means to use the environment variable +#: EDITOR. Note that this environment variable has to be set not just +#: in your shell startup scripts but system-wide, otherwise kitty will +#: not see it. + +# close_on_child_death nvim + +#: Close the window when the child process (shell) exits. If no (the +#: default), the terminal will remain open when the child exits as +#: long as there are still processes outputting to the terminal (for +#: example disowned or backgrounded processes). If yes, the window +#: will close as soon as the child process exits. Note that setting it +#: to yes means that any background processes still using the terminal +#: can fail silently because their stdout/stderr/stdin no longer work. + +# allow_remote_control no + +#: Allow other programs to control kitty. If you turn this on other +#: programs can control all aspects of kitty, including sending text +#: to kitty windows, opening new windows, closing windows, reading the +#: content of windows, etc. Note that this even works over ssh +#: connections. + +# startup_session none + +#: Path to a session file to use for all kitty instances. Can be +#: overridden by using the kitty --session command line option for +#: individual instances. See sessions in the kitty documentation for +#: details. Note that relative paths are interpreted with respect to +#: the kitty config directory. Environment variables in the path are +#: expanded. + +# clipboard_control write-clipboard write-primary +clipboard_control write-primary write-clipboard no-append + +#: Allow programs running in kitty to read and write from the +#: clipboard. You can control exactly which actions are allowed. The +#: set of possible actions is: write-clipboard read-clipboard write- +#: primary read-primary The default is to allow writing to the +#: clipboard and primary selection. Note that enabling the read +#: functionality is a security risk as it means that any program, even +#: one running on a remote server via SSH can read your clipboard. + +#term xterm-kitty + +#: The value of the TERM environment variable to set. Changing this +#: can break many terminal programs, only change it if you know what +#: you are doing, not because you read some advice on Stack Overflow +#: to change it. + +#: }}} + +#: OS specific tweaks {{{ + +# macos_titlebar_color #22262d + +#: Change the color of the kitty window's titlebar on macOS. A value +#: of system means to use the default system color, a value of +#: background means to use the background color of the currently +#: active window and finally you can use an arbitrary color, such as +#: #12af59 or red. WARNING: This option works by using a hack, as +#: there is no proper Cocoa API for it. It sets the background color +#: of the entire window and makes the titlebar transparent. As such it +#: is incompatible with background_opacity. If you want to use both, +#: you are probably better off just hiding the titlebar with +#: macos_hide_titlebar. + +# macos_hide_titlebar no + +#: Hide the kitty window's title bar on macOS. + +hide_window_decorations no + +#: Hide the window decorations (title bar and window borders) on X11 +#: and Wayland. Whether this works and exactly what effect it has +#: depends on the window manager, as it is the job of the window +#: manager/compositor to draw window decorations. + +# macos_option_as_alt yes + +#: Use the option key as an alt key. With this set to no, kitty will +#: use the macOS native Option+Key = unicode character behavior. This +#: will break any Alt+key keyboard shortcuts in your terminal +#: programs, but you can use the macOS unicode input technique. + +# macos_hide_from_tasks no + +#: Hide the kitty window from running tasks (Option+Tab) on macOS. + +# macos_quit_when_last_window_closed no + +#: Have kitty quit when all the top-level windows are closed. By +#: default, kitty will stay running, even with no open windows, as is +#: the expected behavior on macOS. + +#: }}} + +#: Keyboard shortcuts {{{ + +#: For a list of key names, see: GLFW keys +#: <http://www.glfw.org/docs/latest/group__keys.html>. The name to use +#: is the part after the GLFW_KEY_ prefix. For a list of modifier +#: names, see: GLFW mods +#: <http://www.glfw.org/docs/latest/group__mods.html> + +#: On Linux you can also use XKB key names to bind keys that are not +#: supported by GLFW. See XKB keys +#: <https://github.com/xkbcommon/libxkbcommon/blob/master/xkbcommon/xkbcommon- +#: keysyms.h> for a list of key names. The name to use is the part +#: after the XKB_KEY_ prefix. Note that you should only use an XKB key +#: name for keys that are not present in the list of GLFW keys. + +#: You can use the special action no_op to unmap a keyboard shortcut +#: that is assigned in the default configuration. + +#: You can combine multiple actions to be triggered by a single +#: shortcut, using the syntax below:: + +#: map key combine <separator> action1 <separator> action2 <separator> action3 ... + +#: For example:: + +#: map kitty_mod+e combine : new_window : next_layout + +#: this will create a new window and switch to the next available +#: layout + +#: You can use multi-key shortcuts using the syntax shown below:: + +#: map key1>key2>key3 action + +#: For example:: + +#: map ctrl+f>2 set_font_size 20 + +# kitty_mod ctrl+shift + +#: The value of kitty_mod is used as the modifier for all default +#: shortcuts, you can change it in your kitty.conf to change the +#: modifiers for all the default shortcuts. + +# clear_all_shortcuts no + +#: You can have kitty remove all shortcut definition seen up to this +#: point. Useful, for instance, to remove the default shortcuts. + +#: Clipboard {{{ + +# map cmd+c copy_to_clipboard +#map kitty_mod+c copy_to_clipboard +# map cmd+v paste_from_clipboard +#map kitty_mod+v paste_from_clipboard +#map kitty_mod+s paste_from_selection +map shift+insert paste_from_selection +# map kitty_mod+o pass_selection_to_program +map ctrl+c copy_to_clipboard +map ctrl+v paste_from_clipboard + +#: You can also pass the contents of the current selection to any +#: program using pass_selection_to_program. By default, the system's +#: open program is used, but you can specify your own, for example:: + +#: map kitty_mod+o pass_selection_to_program firefox + +#: You can pass the current selection to a terminal program running in +#: a new kitty window, by using the @selection placeholder:: + +#: map kitty_mod+y new_window less @selection + +#: }}} + +#: Scrolling {{{ + +#map kitty_mod+up scroll_line_up +#map ctrl+k scroll_line_up +#map kitty_mod+k scroll_line_up +#map kitty_mod+down scroll_line_down +#map ctrl+j scroll_line_down +#map kitty_mod+j scroll_line_down +map kitty_mod+page_up scroll_page_up +map kitty_mod+page_down scroll_page_down +map kitty_mod+b scroll_page_up +map kitty_mod+f scroll_page_down +# map kitty_mod+home scroll_home +# map kitty_mod+end scroll_end +# map kitty_mod+h show_scrollback + +#: You can send the contents of the current screen + history buffer as +#: stdin to an arbitrary program using the placeholders @text (which +#: is the plain text) and @ansi (which includes text styling escape +#: codes). For only the current screen, use @screen or @ansi_screen. +#: For example, the following command opens the scrollback buffer in +#: less in a new window:: + +#: map kitty_mod+y new_window @ansi less +G -R + +#: }}} + +#: Window management {{{ + +# map kitty_mod+enter new_window +map kitty_mod+enter no_op +map kitty_mod+enter new_window_with_cwd + +#: You can open a new window running an arbitrary program, for +#: example:: + +#: map kitty_mod+y new_window mutt + +#: You can open a new window with the current working directory set to +#: the working directory of the current window using:: + +#: map ctrl+alt+enter new_window_with_cwd + +# map cmd+n new_os_window +# map kitty_mod+n new_os_window +# map kitty_mod+w close_window +# map kitty_mod+] next_window +# map kitty_mod+[ previous_window +map kitty_mod+j previous_window +map kitty_mod+k next_window +map kitty_mod+up move_window_forward +map kitty_mod+down move_window_backward +# map kitty_mod+f move_window_forward +# map kitty_mod+b move_window_backward +# map kitty_mod+` move_window_to_top +# map kitty_mod+r start_resizing_window +# map kitty_mod+1 first_window +# map kitty_mod+2 second_window +# map kitty_mod+3 third_window +# map kitty_mod+4 fourth_window +# map kitty_mod+5 fifth_window +# map kitty_mod+6 sixth_window +# map kitty_mod+7 seventh_window +# map kitty_mod+8 eighth_window +# map kitty_mod+9 ninth_window +# map kitty_mod+0 tenth_window +#: }}} + +#: Tab management {{{ + +# map kitty_mod+right next_tab +# map kitty_mod+left previous_tab +map kitty_mod+] no_op +map kitty_mod+] next_tab +map kitty_mod+[ no_op +map kitty_mod+[ previous_tab +# map kitty_mod+t new_tab +# map kitty_mod+q close_tab +# map kitty_mod+. move_tab_forward +# map kitty_mod+, move_tab_backward +map kitty_mod+right no_op +map kitty_mod+right move_tab_forward +map kitty_mod+left no_op +map kitty_mod+left move_tab_backward +# map kitty_mod+alt+t set_tab_title +map kitty_mod+t no_op +map kitty_mod+t new_tab_with_cwd + +#: You can also create shortcuts to go to specific tabs, with 1 being +#: the first tab:: + +#: map ctrl+alt+1 goto_tab 1 +#: map ctrl+alt+2 goto_tab 2 + +#: Just as with new_window above, you can also pass the name of +#: arbitrary commands to run when using new_tab and use +#: new_tab_with_cwd. +#: }}} + +#: Layout management {{{ + +# map kitty_mod+l next_layout + +#: You can also create shortcuts to switch to specific layouts:: + +map kitty_mod+0 no_op +map kitty_mod+0 goto_layout stack +map kitty_mod+9 no_op +map kitty_mod+9 goto_layout tall +map kitty_mod+8 no_op +map kitty_mod+8 goto_layout fat +#: map ctrl+alt+t goto_layout tall +#: map ctrl+alt+s goto_layout stack +#: }}} + +#: Font sizes {{{ + +#: You can change the font size for all top-level kitty windows at a +#: time or only the current one. + +map kitty_mod+equal change_font_size all +2.0 +map kitty_mod+minus change_font_size all -2.0 +map kitty_mod+backspace change_font_size all 0 + +#: To setup shortcuts for specific font sizes:: + +#: map kitty_mod+f6 change_font_size all 10.0 + +#: To setup shortcuts to change only the current window's font size:: + +#: map kitty_mod+f6 change_font_size current 10.0 +#: }}} + +#: Select and act on visible text {{{ + +#: Use the hints kitten to select text and either pass it to an +#: external program or insert it into the terminal or copy it to the +#: clipboard. + +# map kitty_mod+e kitten hints + +#: Open a currently visible URL using the keyboard. The program used +#: to open the URL is specified in open_url_with. + +# map kitty_mod+p>f kitten hints --type path --program - + +#: Select a path/filename and insert it into the terminal. Useful, for +#: instance to run git commands on a filename output from a previous +#: git command. + +# map kitty_mod+p>shift+f kitten hints --type path + +#: Select a path/filename and open it with the default open program. + +# map kitty_mod+p>l kitten hints --type line --program - + +#: Select a line of text and insert it into the terminal. Use for the +#: output of things like: ls -1 + +# map kitty_mod+p>w kitten hints --type word --program - + +#: Select words and insert into terminal. + +# map kitty_mod+p>h kitten hints --type hash --program - + +#: Select something that looks like a hash and insert it into the +#: terminal. Useful with git, which uses sha1 hashes to identify +#: commits + + +#: The hints kitten has many more modes of operation that you can map +#: to different shortcuts. For a full description see kittens/hints. +#: }}} + +#: Miscellaneous {{{ + + +# map kitty_mod+f11 toggle_fullscreen +# map kitty_mod+u input_unicode_character +# map kitty_mod+f2 edit_config_file +# map kitty_mod+escape kitty_shell window + +#: Open the kitty shell in a new window/tab/overlay/os_window to +#: control kitty using commands. + +# map kitty_mod+a>m set_background_opacity +0.1 +# map kitty_mod+a>l set_background_opacity -0.1 +# map kitty_mod+a>1 set_background_opacity 1 +# map kitty_mod+a>d set_background_opacity default +# +# map kitty_mod+a>m set_background_opacity +0.1 +# map kitty_mod+a>l set_background_opacity -0.1 +map kitty_mod+, set_background_opacity 1 +map kitty_mod+. set_background_opacity default + +#: You can tell kitty to send arbitrary (UTF-8) encoded text to the +#: client program when pressing specified shortcut keys. For example:: + +#: map ctrl+alt+a send_text all Special text + +#: This will send "Special text" when you press the ctrl+alt+a key +#: combination. The text to be sent is a python string literal so you +#: can use escapes like \x1b to send control codes or \u21fb to send +#: unicode characters (or you can just input the unicode characters +#: directly as UTF-8 text). The first argument to send_text is the +#: keyboard modes in which to activate the shortcut. The possible +#: values are normal or application or kitty or a comma separated +#: combination of them. The special keyword all means all modes. The +#: modes normal and application refer to the DECCKM cursor key mode +#: for terminals, and kitty refers to the special kitty extended +#: keyboard protocol. + +#: Another example, that outputs a word and then moves the cursor to +#: the start of the line (same as pressing the Home key):: + +#: map ctrl+alt+a send_text normal Word\x1b[H +#: map ctrl+alt+a send_text application Word\x1bOH + +#: }}} + +map ctrl+space send_text all \x10 + +# }}} diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore new file mode 100644 index 0000000..308d183 --- /dev/null +++ b/.config/nvim/.gitignore @@ -0,0 +1,2 @@ +plugin/packer_compiled.lua +startup.log diff --git a/.config/nvim/README.md b/.config/nvim/README.md new file mode 100644 index 0000000..630b8e5 --- /dev/null +++ b/.config/nvim/README.md @@ -0,0 +1 @@ +## Neovim diff --git a/.config/nvim/autoload/scripts.vim b/.config/nvim/autoload/scripts.vim new file mode 100644 index 0000000..5c695d3 --- /dev/null +++ b/.config/nvim/autoload/scripts.vim @@ -0,0 +1,15 @@ +if !exists('*scripts#save_and_exec') + function! scripts#save_and_exec() abort + if &filetype == 'vim' + :silent! write + :source % + elseif &filetype == 'lua' + :silent! write + :luafile % + endif + + return + endfunction +endif + + diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..f74ec11 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,138 @@ +--[[ + ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ + ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ + ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ + ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ + ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + " ------------------------------------------------ + Author: srdusr + Email: graytrevor98@gmail.com + Url: https://github.com/srdusr/nvim.git + ------------------------------------------------ " +--]] + +--[[init.]] + +-- ========================================================================== -- +-- == DEPENDENCIES == -- +-- ========================================================================== -- + +-- ripgrep - https://github.com/BurntSushi/ripgrep +-- fd - https://github.com/sharkdp/fd +-- git - https://git-scm.com/ +-- make - https://www.gnu.org/software/make/ +-- c compiler - gcc or tcc or zig + +-- -------------------------------------------------------------------------- -- + +-- Initialize config with this one liner in the terminal +--nvim --headless -c 'call mkdir(stdpath("config"), "p") | exe "edit" stdpath("config") . "/init.lua" | write | quit' + +-- See startup time +--nvim --startuptime startup.log -c exit && tail -100 startup.log + +-- Load impatient +local impatient_ok, impatient = pcall(require, "impatient") +if impatient_ok then + impatient.enable_profile() +end + +-- Check if we have the latest stable version of nvim +local utils = require("user.utils") +local expected_ver = "0.8.0" +local nvim_ver = utils.get_nvim_version() + +if nvim_ver ~= expected_ver then + local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver) +vim.api.nvim_err_writeln(msg) + return +end + +-- Schedule reading shadafile to improve the startup time +vim.opt.shadafile = "NONE" +vim.schedule(function() + vim.opt.shadafile = "" + vim.cmd("silent! rsh") +end) + + +-- Load/reload modules +local modules = { + "user.pack", -- Packer plugin manager + "user.opts", -- Options + "user.keys", -- Keymaps + "user.utils", -- Utilities + --"user.mods", -- Modules/functions + --"user.deps", -- Plugins + --"user.scripts", + "plugins.treesitter", + "plugins.telescope", + "plugins.nvim-tree", + "plugins.cmp", + "plugins.luasnip", + "plugins.colorizer", + "plugins.prettier", + "plugins.git", + "plugins.gitsigns", + "plugins.neoscroll", + "plugins.lsp", + "plugins.autopairs", + "plugins.null-ls", + "plugins.web-devicons", + "plugins.zen-mode", + "plugins.colorscheme", + "plugins.heirline", + --"plugins.dap", + --"plugins.toggleterm", + --"plugins.floatterm", +} + +-- Refresh module cache +for k, v in pairs(modules) do + package.loaded[v] = nil + require(v) +end + +-- Snippets +vim.g.snippets = "luasnip" + +-- Improve speed by disabling some default plugins/modules +local builtins = { + "gzip", + "zip", + "zipPlugin", + "tar", + "tarPlugin", + "getscript", + "getscriptPlugin", + "vimball", + "vimballPlugin", + "2html_plugin", + --"matchit", + --"matchparen", + "logiPat", + "rrhelper", + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "tutor_mode_plugin", + "fzf", + "spellfile_plugin", + "sleuth", +} + +for _, plugin in ipairs(builtins) do + vim.g["loaded_" .. plugin] = 1 +end +vim.g.do_filetype_nvim = 1 +vim.g.did_load_filetypes = 0 + +--vim.cmd[[ +--if maparg('<C-L>', 'n') ==# '' +-- nnoremap <silent> <C-L> :set lz!<CR>:nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>:set lz!<CR> +--endif]] +--vim.cmd[[autocmd VimEnter * set nolazyredraw lazyredraw]] +--vim.cmd[[autocmd VimEnter * redraw!]] + diff --git a/.config/nvim/lua/plugins/autopairs.lua b/.config/nvim/lua/plugins/autopairs.lua new file mode 100644 index 0000000..fc39d2e --- /dev/null +++ b/.config/nvim/lua/plugins/autopairs.lua @@ -0,0 +1,43 @@ +-- Setup nvim-cmp. +local status_ok, npairs = pcall(require, "nvim-autopairs") +if not status_ok then + return +end + +npairs.setup { + check_ts = true, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + map = "<M-e>", + pairs_map = { +['<'] = '>', +}, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + disable_in_macro = true, + disable_in_visualblock = true, + enalbe_moveright = true, + enable_afterquote = true, -- add bracket pairs after quote + enable_check_bracket_line = true, --- check bracket in same line + enable_bracket_in_quote = true, -- + break_undo = true, -- switch for basic rule break undo sequence + fast_wrap = { + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, +} + +local cmp_autopairs = require "nvim-autopairs.completion.cmp" +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } }) diff --git a/.config/nvim/lua/plugins/cmp-gh-source.lua b/.config/nvim/lua/plugins/cmp-gh-source.lua new file mode 100644 index 0000000..05bba55 --- /dev/null +++ b/.config/nvim/lua/plugins/cmp-gh-source.lua @@ -0,0 +1,72 @@ +local ok, Job = pcall(require, "plenary.job") +if not ok then + return +end + +local source = {} + +source.new = function() + local self = setmetatable({ cache = {} }, { __index = source }) + + return self +end + +source.complete = function(self, _, callback) + local bufnr = vim.api.nvim_get_current_buf() + + -- This just makes sure that we only hit the GH API once per session. + -- + -- You could remove this if you wanted, but this just makes it so we're + -- good programming citizens. + if not self.cache[bufnr] then + Job + :new({ + -- Uses `gh` executable to request the issues from the remote repository. + "gh", + "issue", + "list", + "--limit", + "1000", + "--json", + "title,number,body", + + on_exit = function(job) + local result = job:result() + local ok, parsed = pcall(vim.json.decode, table.concat(result, "")) + if not ok then + vim.notify "Failed to parse gh result" + return + end + + local items = {} + for _, gh_item in ipairs(parsed) do + gh_item.body = string.gsub(gh_item.body or "", "\r", "") + + table.insert(items, { + label = string.format("#%s", gh_item.number), + documentation = { + kind = "markdown", + value = string.format("# %s\n\n%s", gh_item.title, gh_item.body), + }, + }) + end + + callback { items = items, isIncomplete = false } + self.cache[bufnr] = items + end, + }) + :start() + else + callback { items = self.cache[bufnr], isIncomplete = false } + end +end + +source.get_trigger_characters = function() + return { "#" } +end + +source.is_available = function() + return vim.bo.filetype == "gitcommit" +end + +require("cmp").register_source("gh_issues", source.new()) diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua new file mode 100644 index 0000000..829a448 --- /dev/null +++ b/.config/nvim/lua/plugins/cmp.lua @@ -0,0 +1,332 @@ + +-- Setup nvim-cmp. +vim.opt.completeopt = "menu,menuone,noselect" +--vim.g.completeopt = "menu,menuone,noselect,noinsert" +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +--local WIDE_HEIGHT = 40 + +local opts = { + -- whether to highlight the currently hovered symbol + -- disable if your cpu usage is higher than you want it + -- or you just hate the highlight + -- default: true + highlight_hovered_item = true, + show_guides = true, +} +require("symbols-outline").setup(opts) + + +--local snippets_paths = function() +-- local plugins = { "friendly-snippets" } +-- local paths = {} +-- local path +-- local root_path = vim.env.HOME .. "/.vim/plugged/" +-- for _, plug in ipairs(plugins) do +-- path = root_path .. plug +-- if vim.fn.isdirectory(path) ~= 0 then +-- table.insert(paths, path) +-- end +-- end +-- return paths +--end +-- +--require("luasnip.loaders.from_vscode").lazy_load({ +-- paths = snippets_paths(), +-- include = nil, -- Load all languages +-- exclude = {}, +--}) + +--require("luasnip.loaders.from_vscode").lazy_load() +local lspkind = require("lspkind") +local kind_icons = { + Text = "", + Method = "m", --"", + Function = "", + Constructor = "", --"⚙️", + Field = "", + Variable = "", + Class = "ﴯ", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", +} +cmp.setup({ + snippet = { + --expand = function(args) + -- require("luasnip").lsp_expand(args.body) + --end, + expand = function(args) + local luasnip = require("luasnip") + if not luasnip then + return + end + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ +-- ["<CR>"] = cmp.mapping.confirm({ +-- behavior = cmp.ConfirmBehavior.Replace, +-- select = true, +-- }), + --["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), + --["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), + ['<C-y>'] = cmp.mapping.confirm({ select = true }), + --["<C-e>"] = cmp.mapping.close(), + --['<C-e>'] = cmp.mapping({ + -- i = cmp.mapping.abort(), + -- c = cmp.mapping.close(), + --}), + ["<C-e>"] = cmp.mapping({ + i = function() + if cmp.visible() then + cmp.abort() + require("user.utils").toggle_completion() + require("notify")("completion off") + else + cmp.complete() + require("user.utils").toggle_completion() + require("notify")("completion on") + end + end, + }), + --["<CR>"] = cmp.mapping({ + -- i = function(fallback) + -- if cmp.visible() then + -- cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + -- require("user.utils").toggle_completion() + -- else + -- fallback() + -- end + -- end, + --}), + +-- ["<C-e>"] = cmp.mapping({ +-- i = function() +-- if cmp.visible() then +-- require("notify")("visible") +-- cmp.abort() +-- else +-- require("notify")("not visible") +-- cmp.complete() +-- end +-- end, +-- c = function() +-- if cmp.visible() then +-- require("notify")("visible") +-- cmp.close() +-- else +-- require("notify")("not visible") +-- cmp.complete() +-- end +-- end, +-- }), + --['<CR>'] = cmp.config.disable, + ["<C-u>"] = cmp.mapping.scroll_docs(-4), + ["<C-d>"] = cmp.mapping.scroll_docs(4), + ["<C-Space>"] = cmp.mapping.complete(), + --['<C-o>'] = function(fallback) + -- if cmp.visible() then + -- cmp.mapping.confirm({ select = true })(fallback) + -- else + -- cmp.mapping.complete()(fallback) + -- end + --end + }), + + sources = cmp.config.sources({ + --{ name = "nvim_lua" }, + { name = "luasnip" }, + --{ name = 'luasnip', option = { use_show_condition = false } }, + { name = "gh_issues" }, + { name = "nvim_lsp", max_item_count = 6 }, + { name = "nvim_lua" }, + --{ name = "luasnip" }, + --{ name = "luasnip", keyword_length = 4 }, + --{ name = "buffer", keyword_length = 3 }, + { name = "path" }, + { name = "buffer", max_item_count = 6 }, + --{ name = "buffer", option = { get_bufnrs = function() + -- return vim.api.nvim_list_bufs() + --end + --}}, + { name = "cmp_git"}, + { name = "spell"}, + { name = "zsh" }, + { name = "treesitter" }, + { name = "calc" }, + { name = "nvim_lsp_signature_help" }, + --{ name = "cmdline" }, + --{ name = 'treesitter' }, + --{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=] }, --exclamation mark hangs a bit without this + --{name = 'luasnip', keyword_length = 2}, + }), + formatting = { + --formatting = { + --local icons = kind_icons + --format = function(entry, vim_item) + ----vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + ----vim_item.kind = lspkind.presets.default[vim_item.kind] + --vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + ----vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) + --vim_item.menu = ({ + ----nvim_lsp = "LSP", + ----luasnip = "snip", + ----buffer = "buf", + ----path = "path", + ----cmdline = "cmd", + --buffer = "[buf]", + --nvim_lsp = "[LSP]", + --nvim_lua = "[api]", + --path = "[path]", + --luasnip = "[snip]", + --cmdline = "[cmd]", + --gh_issues = "[issues]", + --})[entry.source.name] + --return vim_item + --end, + format = lspkind.cmp_format { + with_text = true, + menu = { + nvim_lsp = "[LSP]", + luasnip = "[snip]", + buffer = "[buf]", + nvim_lua = "[api]", + path = "[path]", + gh_issues = "[issues]", + spell = "[spell]", + zsh = "[zsh]", + treesitter = "[treesitter]", + calc = "[calc]", + nvim_lsp_signature_help = "[signature]", + cmdline = "[cmd]" + + }, + }, + --}, + + -- + -- + --fields = { "abbr", "kind", "menu" }, + -- format = lspkind.cmp_format({ + -- mode = 'symbol_text', -- show only symbol annotations + -- maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + -- }) + --format = require('lspkind').cmp_format { + -- with_text = true, + -- menu = { + -- luasnip = "Snip", + -- buffer = "Buf", + -- nvim_lsp = "LSP", + -- path = "Path", + -- cmdline = "Cmd", + -- cmp_git = "Git", + -- }, + --}, + }, + --format = function(entry, vim_item) + -- -- Kind icons + -- --vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + -- vim_item.kind = lspkind.presets.default[vim_item.kind] + -- -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + -- vim_item.menu = ({ + -- nvim_lsp = "LSP", + -- luasnip = "Snip", + -- buffer = "Buf", + -- path = "Path", + -- cmdline = "Cmd", + -- })[entry.source.name] + -- return vim_item + --end, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + + + event = {}, + + experimental = { + ghost_text = true, -- this feature conflicts with copilot.vim's preview. + hl_group = 'Nontext', + --native_menu = false, + }, + + view = { + entries = { name = 'custom', selection_order = 'top_down' }, + }, + + window = { + --completion = cmp.config.window.bordered(), + completion = { + border = { '', '', '', ' ', '', '', '', ' ' }, + --border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + --border = { '', '', '', '', '', '', '', '' }, + --border = "CmpBorder", + winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None', + --winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", + }, + --documentation = cmp.config.window.bordered(), + documentation = { + --max_height = math.floor(WIDE_HEIGHT * (WIDE_HEIGHT / vim.o.lines)), + --max_width = math.floor((WIDE_HEIGHT * 2) * (vim.o.columns / (WIDE_HEIGHT * 2 * 16 / 9))), + border = { '', '', '', ' ', '', '', '', ' ' }, + --border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + winhighlight = 'FloatBorder:NormalFloat', + }, + }, +}) + + +cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, +}) + +cmp.setup.cmdline(":", { + mapping = { + ["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), + ["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), + ["<C-y>"] = cmp.mapping(cmp.mapping.confirm({ select = true }), { 'i', 'c' }), + ["<C-e>"] = cmp.mapping(cmp.mapping.close(), { 'i', 'c' }), + ["<C-u>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + ["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + --["<C-k>"] = cmp.mapping.select_prev_item(), + --["<C-j>"] = cmp.mapping.select_next_item(), + --['<C-y>'] = cmp.mapping.confirm({ select = true }), + --["<C-e>"] = cmp.mapping.close(), + ----['<CR>'] = cmp.config.disable, + --["<C-u>"] = cmp.mapping.scroll_docs(-4), + --["<C-d>"] = cmp.mapping.scroll_docs(4), + --["<C-Space>"] = cmp.mapping.complete(), + }, + + sources = cmp.config.sources({ + { name = "path" }, + }, { + --{ name = "cmdline" }, + { name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=], keyword_length = 3 }, + }) +}) + + diff --git a/.config/nvim/lua/plugins/colorizer.lua b/.config/nvim/lua/plugins/colorizer.lua new file mode 100644 index 0000000..14d25e2 --- /dev/null +++ b/.config/nvim/lua/plugins/colorizer.lua @@ -0,0 +1,6 @@ +local status, colorizer = pcall(require, "colorizer") +if (not status) then return end + +colorizer.setup({ + '*'; +}) diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..1f76a40 --- /dev/null +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,39 @@ +-- Colorscheme +-- ayu gruvbox molokai onedark srcery everblush vscode edge nightfly doom-one +local colorscheme = "onedark" +local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) +if not status_ok then + vim.notify("colorscheme " .. colorscheme .. " not found!") + return +end + +vim.api.nvim_command("syntax on") +vim.api.nvim_command("highlight Normal guibg=none") +vim.api.nvim_command("highlight SignColumn guibg=none") +vim.api.nvim_command("highlight TabLine guibg=#333842 gui=bold") +--vim.api.nvim_command("highlight TabLine guibg=none gui=bold") +--vim.api.nvim_command("highlight TabLineSel guibg=none guifg=none gui=bold") +--vim.api.nvim_command("highlight StatusLine guibg=#333842 gui=bold") +--vim.api.nvim_command("highlight StatusLine guibg=#333842 guifg=#d6d3ea gui=bold") +--vim.api.nvim_command("highlight StatusLine guibg=none gui=bold") +--vim.api.nvim_command("highlight TabLineNC guibg=none gui=bold") +--vim.api.nvim_command("highlight TabLineSel guibg=#bd93f9 gui=bold") +vim.api.nvim_command("highlight Title guibg=none gui=bold") +--vim.api.nvim_command("highlight WinSeparator guibg=none gui=bold") +vim.api.nvim_command("highlight TabLineSel guibg=#333842 gui=bold") +vim.api.nvim_command("highlight TabLineFill guibg=none gui=bold") +vim.api.nvim_command("highlight WinBar guibg=none gui=bold") +vim.api.nvim_command("highlight NormalFloat guibg=none") +--vim.api.nvim_command("highlight MsgSeparator guibg=none") +--vim.api.nvim_command("highlight PmenuSel guibg=none") +--vim.api.nvim_command("highlight winblend guibg=none") +--vim.api.nvim_command("highlight StatusLine guibg=none gui=bold") +--vim.api.nvim_command("highlight StatusLineNC guibg=none gui=bold") +--vim.api.nvim_command("highlight StatusLineNC guibg=none ctermfg=Cyan guifg=#80a0ff gui=bold") +vim.cmd[[ +au WinEnter * setl winhl=WinSeparator:WinSeparatorA +au WinLeave * setl winhl=WinSeparator:WinSeparator +]] +require("notify").setup({ + background_colour = "#000000", +}) diff --git a/.config/nvim/lua/plugins/git.lua b/.config/nvim/lua/plugins/git.lua new file mode 100644 index 0000000..963f7f9 --- /dev/null +++ b/.config/nvim/lua/plugins/git.lua @@ -0,0 +1,11 @@ +local status, git = pcall(require, "git") +if (not status) then return end + +git.setup({ + keymaps = { + -- Open blame window + blame = "<Leader>gb", + -- Open file/folder in git repository + browse = "<Leader>go", + } +}) diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..53d1a1e --- /dev/null +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1 @@ +require('gitsigns').setup {} diff --git a/.config/nvim/lua/plugins/heirline.lua b/.config/nvim/lua/plugins/heirline.lua new file mode 100644 index 0000000..c05844b --- /dev/null +++ b/.config/nvim/lua/plugins/heirline.lua @@ -0,0 +1,1206 @@ +local conditions = require("heirline.conditions") +local utils = require("heirline.utils") + +local colors = { + --bg = "#23232e", + bg = nil, + nobg = nil, + white = "#f8f8f2", + black = "#000000", + darkgray = "#23232e", + gray = "#2d2b3a", + lightgray = "#d6d3ea", + pink = "#f92672", + green = "#50fa7b", + blue = "#39BAE6", + yellow = "#f1fa8c", + orange = "#ffb86c", + purple = "#BF40BF", + violet = "#7F00FF", + red = "#ff5555", + cyan = "#66d9eC", + diag = { + warn = utils.get_highlight("DiagnosticSignWarn").fg, + error = utils.get_highlight("DiagnosticSignError").fg, + hint = utils.get_highlight("DiagnosticSignHint").fg, + info = utils.get_highlight("DiagnosticSignInfo").fg, + }, + git = { + del = "#e95678", + add = "#a6e22e", + change = "#ae81ff", + }, +} + +require("heirline").load_colors(colors) + +local Align = { provider = "%=", hl = { bg = colors.bg } } +local Space = { provider = " ", hl = { bg = colors.bg } } +local Tab = { provider = " " } +local LeftSpace = { provider = "" } +local RightSpace = { provider = "" } +local RightSpace2 = { provider = "" } +local RightSpace3 = { provider = "" } +local Fill = { provider = "%=", hl = { bg = colors.nobg } } +local LeftSep = { provider = "" } +local RightSep = { provider = "" } + +local ViMode = { + init = function(self) + self.mode = vim.fn.mode(1) + if not self.once then + vim.cmd("au ModeChanged *:*o redrawstatus") + end + self.once = true + end, + static = { + mode_names = { + n = "NORMAL ", + no = "N·OPERATOR PENDING ", + nov = "N?", + noV = "N?", + ["no\22"] = "N? ", + niI = "Ni", + niR = "Nr", + niV = "Nv", + nt = "Nt", + v = "VISUAL ", + vs = "Vs", + V = "V·LINE ", + ["\22"] = "V·BLOCK ", + ["\22s"] = "V·BLOCK ", + s = "SELECT ", + S = "S·LINE ", + ["\19"] = "S·BLOCK ", + i = "INSERT ", + ix = "insert x ", + ic = "insert c ", + R = "REPLACE ", + Rc = "Rc", + Rx = "Rx", + Rv = "V·REPLACE ", + Rvc = "Rv", + Rvx = "Rv", + c = "COMMAND ", + cv = "VIM EX ", + ce = "EX ", + r = "PROMPT ", + rm = "MORE ", + ["r?"] = "CONFIRM ", + ["!"] = "SHELL ", + t = "TERMINAL ", + }, + }, + provider = function(self) + return " %2(" .. self.mode_names[self.mode] .. "%) " + end, + hl = function(self) + local color = self:mode_color() + return { fg = color, bold = true } + end, + update = { + "ModeChanged", + }, +} + +-- LSP +local LSPActive = { + condition = conditions.lsp_attached, + update = { "LspAttach", "LspDetach" }, + + provider = function() + local buf_clients = vim.lsp.buf_get_clients() + local buf_client_names = {} + + -- add client + for _, client in pairs(buf_clients) do + if client.name ~= "null-ls" then + table.insert(buf_client_names, client.name) + end + end + return "⚙️ " .. table.concat(buf_client_names, "") + end, + hl = { fg = colors.lightgray, bold = false }, +} + +-- Navic +local Navic = { + condition = require("nvim-navic").is_available, + static = { + -- create a type highlight map + type_hl = { + File = "Directory", + Module = "Include", + Namespace = "TSNamespace", + Package = "Include", + Class = "Struct", + Method = "Method", + Property = "TSProperty", + Field = "TSField", + Constructor = "TSConstructor ", + Enum = "TSField", + Interface = "Type", + Function = "Function", + Variable = "TSVariable", + Constant = "Constant", + String = "String", + Number = "Number", + Boolean = "Boolean", + Array = "TSField", + Object = "Type", + Key = "TSKeyword", + Null = "Comment", + EnumMember = "TSField", + Struct = "Struct", + Event = "Keyword", + Operator = "Operator", + TypeParameter = "Type", + }, + }, + init = function(self) + local data = require("nvim-navic").get_data() or {} + local children = {} + -- create a child for each level + for i, d in ipairs(data) do + local child = { + { + provider = d.icon, + hl = self.type_hl[d.type], + }, + { + provider = d.name, + -- highlight icon only or location name as well + -- hl = self.type_hl[d.type], + }, + } + -- add a separator only if needed + if #data > 1 and i < #data then + table.insert(child, { + provider = " > ", + hl = { fg = colors.white }, + }) + end + table.insert(children, child) + end + -- instantiate the new child, overwriting the previous one + self[1] = self:new(children, 1) + end, + hl = { fg = colors.white }, +} + +-- Diagnostics +local Diagnostics = { + + condition = conditions.has_diagnostics, + + static = { + error_icon = vim.fn.sign_getdefined("DiagnosticSignError")[1].text, + warn_icon = vim.fn.sign_getdefined("DiagnosticSignWarn")[1].text, + info_icon = vim.fn.sign_getdefined("DiagnosticSignInfo")[1].text, + hint_icon = vim.fn.sign_getdefined("DiagnosticSignHint")[1].text, + }, + + init = function(self) + self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }) + self.warnings = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }) + self.hints = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT }) + self.info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO }) + end, + + update = { "DiagnosticChanged", "BufEnter" }, + + { + provider = function(self) + -- 0 is just another output, we can decide to print it or not! + return self.errors > 0 and (self.error_icon .. self.errors .. " ") + end, + hl = { fg = colors.diag.error, bg = colors.bg }, + }, + { + provider = function(self) + return self.warnings > 0 and (self.warn_icon .. self.warnings .. " ") + end, + hl = { fg = colors.diag.warn, bg = colors.bg }, + }, + { + provider = function(self) + return self.info > 0 and (self.info_icon .. self.info .. " ") + end, + hl = { fg = colors.diag.info, bg = colors.bg }, + }, + { + provider = function(self) + return self.hints > 0 and (self.hint_icon .. self.hints) + end, + hl = { fg = colors.diag.hint, bg = colors.bg }, + }, + on_click = { + callback = function() + require("trouble").toggle({ mode = "document_diagnostics" }) + -- or + -- vim.diagnostic.setqflist() + end, + name = "heirline_diagnostics", + }, +} + +-- Git +-- For the ones who're not (too) afraid of changes! Uses gitsigns. +local Git = { + condition = conditions.is_git_repo, + + init = function(self) + self.status_dict = vim.b.gitsigns_status_dict + self.has_changes = self.status_dict.added ~= 0 or self.status_dict.removed ~= 0 or self.status_dict.changed ~= 0 + end, + --hl = { fg = "orange" }, + hl = { fg = colors.orange, bg = colors.bg }, + { -- git branch name + provider = function(self) + return " " .. self.status_dict.head + end, + --hl = { bold = true }, + hl = { bold = true, bg = colors.bg }, + }, + -- You could handle delimiters, icons and counts similar to Diagnostics + { + condition = function(self) + return self.has_changes + end, + --provider = "(" + provider = " ", + }, + { + provider = function(self) + local count = self.status_dict.added or 0 + --return count > 0 and ("+" .. count) + return count > 0 and (" " .. count) + end, + --hl = { fg = "git_add" }, + hl = { fg = colors.git.add, bg = colors.bg }, + }, + { + provider = function(self) + local count = self.status_dict.removed or 0 + --return count > 0 and ("-" .. count) + return count > 0 and (" " .. count) + end, + --hl = { fg = "git_del" }, + hl = { fg = colors.git.del, bg = colors.bg }, + }, + { + provider = function(self) + local count = self.status_dict.changed or 0 + --return count > 0 and ("~" .. count) + return count > 0 and (" 柳" .. count) + end, + --hl = { fg = "git_change" }, + hl = { fg = colors.git.change, bg = colors.bg }, + }, + --{ + -- condition = function(self) + -- return self.has_changes + -- end, + -- provider = ")", + --}, + on_click = { + callback = function() + -- If you want to use Fugitive: + -- vim.cmd("G") + + -- If you prefer Lazygit + -- use vim.defer_fn() if the callback requires + -- opening of a floating window + -- (this also applies to telescope) + vim.defer_fn(function() + vim.cmd("Lazygit") + end, 100) + end, + name = "heirline_git", + }, +} + +-- Debugger +-- Display informations from nvim-dap! +local DAPMessages = { + -- display the dap messages only on the debugged file + condition = function() + local session = require("dap").session() + if session then + local filename = vim.api.nvim_buf_get_name(0) + if session.config then + local progname = session.config.program + return filename == progname + end + end + return false + end, + provider = function() + return " " .. require("dap").status() + end, + hl = { fg = utils.get_highlight("Debug").fg }, + -- Debugger on_click: step-over, step-into, next, previous, stop buttons + -- coming soon! +} + +-- Tests +-- This requires the great ultest. +--local UltTest = { +-- condition = function() +-- return vim .api.nvim_call_function("ultest#is_test_file", {}) ~= 0 +-- end, +-- static = { +-- passed_icon = vim.fn.sign_getdefined("test_pass")[1].text, +-- failed_icon = vim.fn.sign_getdefined("test_fail")[1].text, +-- passed_hl = { fg = utils.get_highlight("UltestPass").fg }, +-- failed_hl = { fg = utils.get_highlight("UltestFail").fg }, +-- }, +-- init = function(self) +-- self.status = vim.api.nvim_call_function("ultest#status", {}) +-- end, +-- +-- -- again, if you'd like icons and numbers to be colored differently, +-- -- just split the component in two +-- { +-- provider = function(self) +-- return self.passed_icon .. self.status.passed .. " " +-- end, +-- hl = function(self) +-- return self.passed_hl +-- end, +-- }, +-- { +-- provider = function(self) +-- return self.failed_icon .. self.status.failed .. " " +-- end, +-- hl = function(self) +-- return self.failed_hl +-- end, +-- }, +-- { +-- provider = function(self) +-- return "of " .. self.status.tests - 1 +-- end, +-- }, +--} + +-- FileNameBlock: FileIcon, FileName and friends +local FileNameBlock = { + -- let's first set up some attributes needed by this component and it's children + init = function(self) + self.filename = vim.api.nvim_buf_get_name(0) + end, + --hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, + hl = { bg = colors.bg }, +} + +-- FileIcon, FileName, FileFlags and FileNameModifier +local FileIcon = { + init = function(self) + local filename = self.filename + local extension = vim.fn.fnamemodify(filename, ":e") + self.icon, self.icon_color = + require("nvim-web-devicons").get_icon_color(filename, extension, { default = true }) + end, + provider = function(self) + return self.icon and (self.icon .. " ") + end, + hl = function(self) + return { fg = self.icon_color, bg = colors.bg } + end, +} + +local FileName = { + provider = function(self) + -- first, trim the pattern relative to the current directory. For other + -- options, see :h filename-modifers + local filename = vim.fn.fnamemodify(self.filename, ":.") + if filename == "" then + return "No Name" + end + -- now, if the filename would occupy more than 1/4th of the available + -- space, we trim the file path to its initials + -- See Flexible Components section below for dynamic truncation + if not conditions.width_percent_below(#filename, 0.25) then + filename = vim.fn.pathshorten(filename) + end + return filename + end, + --hl = { fg = utils.get_highlight("Statusline").fg, bold = false, bg = colors.bg }, + hl = { fg = colors.white, bold = false, bg = colors.bg }, +} + +local FileFlags = { + { + provider = function() + if vim.bo.modified then + return " [+]" -- ±[+] + end + end, + hl = { fg = colors.green, bg = colors.bg }, + }, + { + provider = function() + if not vim.bo.modifiable or vim.bo.readonly then + return " " + end + end, + --hl = { fg = colors.orange }, + hl = { fg = colors.orange, bold = true, bg = colors.bg }, + }, +} + +local FileNameModifier = { + hl = function() + if vim.bo.modified then + return { fg = colors.green, bold = false, force = true } + end + end, +} + +-- FileType, FileEncoding and FileFormat +local FileType = { + provider = function() + return vim.bo.filetype + end, + hl = { fg = colors.white, bold = false, bg = colors.bg }, +} + +local FileEncoding = { + Space, + provider = function() + local enc = (vim.bo.fenc ~= "" and vim.bo.fenc) or vim.o.enc -- :h 'enc' + return enc:lower() + end, + --hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, + hl = { bg = colors.bg, bold = false }, +} + +local FileFormat = { + provider = function() + local fmt = vim.bo.fileformat + --return fmt ~= "unix" and fmt:upper() + return fmt ~= "unix" and fmt:lower() + end, + hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, +} + +-- FileSize and FileLastModified +local FileSize = { + provider = function() + -- stackoverflow, compute human readable file size + local suffix = { "b", "k", "M", "G", "T", "P", "E" } + local fsize = vim.fn.getfsize(vim.api.nvim_buf_get_name(0)) + fsize = (fsize < 0 and 0) or fsize + if fsize < 1024 then + return fsize .. suffix[1] + end + local i = math.floor((math.log(fsize) / math.log(1024))) + return string.format("%.2g%s", fsize / math.pow(1024, i), suffix[i + 1]) + end, + hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, +} + +local FileLastModified = { + -- did you know? Vim is full of functions! + provider = function() + local ftime = vim.fn.getftime(vim.api.nvim_buf_get_name(0)) + return (ftime > 0) and os.date("%c", ftime) + end, + hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, +} + +-- Spell +-- Add indicator when spell is set! +local Spell = { + condition = function() + return vim.wo.spell + end, + provider = " 暈", + hl = { bold = true, fg = colors.yellow }, +} + +local help_file_name = { + condition = function() + return vim.bo.filetype == "help" + end, + provider = function() + local filename = vim.api.nvim_buf_get_name(0) + return vim.fn.fnamemodify(filename, ":t") + end, + hl = { fg = colors.blue }, +} + +-- Cursor position: Ruler +--local Ruler = { + -- %l = current line number + -- %L = number of lines in the buffer + -- %c = column number + -- %P = percentage through file of displayed window + --provider = "%P %(%l/%L%):%c ", + --provider = "%3(%2l%):%c %P ", + --provider = "%7(%l/%3L%):%2c%P ", + --provider = "%3(%P%)", + --provider = "%7(%l/%3L%):%2c %P", + --provider = "%7 %p%% Ln %l, Col %c", + --provider = "%9( %P %2l/%L :%2c %)", + --provider = "%9(%2l%2( : %c%)/%L %P %)", + --provider = "%7(%l:%c/%L%) ", + --provider = "%6(%l:%1.5c/%L%) %P ", + --provider = "%6(%l:%1.5c/%L%) ", + --provider = "%3(%l:%1.5c/%L%) ", + --provider = "%7(%l/%3L%):%2c ", +-- provider = "%7(%l:%c%) ", + --provider = "%l:%c ", + --hl = { fg = utils.get_highlight("Statusline").fg, bold = true }, +-- hl = { fg = colors.darkgray, bold = true }, +--} +local leftruler = { Space, Align } +local rightruler = { Align, Space } +local cursor_location = { + --{ provider = "", hl = { fg = utils.get_highlight("StatusLine").bg, bold = true } }, +-- { provider = "%<%-05.10(%l:%c%)", hl = { fg = colors.darkgray, bold = true } }, +-- { provider = " ", hl = { fg = colors.darkgray, bold = true } }, + --{ provider = "%P %=%<%(%l,%c)" }, + --{ provider = " %w%-8.(%l,%c%)%>" }, + { provider = " %1(%4l:%-3(%c%) %)%*", hl = { fg = colors.black, bold = true } }, +} +local Ruler = { cursor_location } + + --utils.make_flexible_component( + -- 3, + -- { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + -- { provider = "%<" } + --), +--local cursor_location = { +-- { provider = "%7(%l:%c%) ", hl = { bold = true } }, +-- { +-- provider = " ", +-- hl = function(self) +-- local color = self:mode_color() +-- return { fg = color, bold = true } +-- end, +-- }, +--} + +local WordCount = { + condition = function() + return conditions.buffer_matches({ + filetype = { + "markdown", + "txt", + "vimwiki", + }, + }) + end, + Space, + { + provider = function() + return "W:" .. vim.fn.wordcount().words + end, + }, +} + +-- Working Directory +local WorkDir = { + init = function(self) + self.icon = (vim.fn.haslocaldir(0) == 1 and "l" or "g") .. " " .. " " + local cwd = vim.fn.getcwd(0) + self.cwd = vim.fn.fnamemodify(cwd, ":~") + end, + hl = { fg = "colors.blue", bold = true }, + flexible = 1, + { + -- evaluates to the full-lenth path + provider = function(self) + local trail = self.cwd:sub(-1) == "/" and "" or "/" + return self.icon .. self.cwd .. trail .." " + end, + }, + { + -- evaluates to the shortened path + provider = function(self) + local cwd = vim.fn.pathshorten(self.cwd) + local trail = self.cwd:sub(-1) == "/" and "" or "/" + return self.icon .. cwd .. trail .. " " + end, + }, + { + -- evaluates to "", hiding the component + provider = "", + } +} + +-- Snippets Indicator +-- This requires ultisnips +--local Snippets = { +-- -- check that we are in insert or select mode +-- condition = function() +-- return vim.tbl_contains({'s', 'i'}, vim.fn.mode()) +-- end, +-- provider = function() +-- local forward = (vim.fn["UltiSnips#CanJumpForwards"]() == 1) and "" or "" +-- local backward = (vim.fn["UltiSnips#CanJumpBackwards"]() == 1) and " " or "" +-- return backward .. forward +-- end, +-- hl = { fg = "red", bold = true }, +--} + +-- let's add the children to our FileNameBlock component +FileNameBlock = utils.insert( + FileNameBlock, + FileIcon, + utils.insert(FileNameModifier, FileName), -- a new table where FileName is a child of FileNameModifier + unpack(FileFlags), -- A small optimisation, since their parent does nothing + { provider = "%<" } -- this means that the statusline is cut here when there's not enough space +) + +local FileInfoBlock = { + -- let's first set up some attributes needed by this component and it's children + init = function(self) + self.filename = vim.api.nvim_buf_get_name(0) + end, +} + +FileInfoBlock = utils.insert( + FileInfoBlock, + Space, + FileIcon, + FileType, + { provider = "%<" } -- this means that the statusline is cut here when there's not enough space +) + +--ViMode = utils.surround({ "", "" }, function(self) +-- return self:mode_color() +--end, { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } }) +--local mysurroundedcomponent = { +--{provider='', hl = {...}}, +--{<your component>}, +--{provider = '>>>', hl = {...}} +--} +LeftSpace = utils.surround({ "", " " }, function(self) + return self:mode_color() +end, { LeftSpace, hl = { fg = utils.get_highlight("statusline").bg, force = true } }) + +RightSpace = utils.surround( + { "", "" }, + colors.gray, + { RightSpace, hl = { bg = utils.get_highlight("statusline").bg, force = true } } +) + +RightSpace2 = utils.surround( + { "█", "" }, + colors.darkgray, + { RightSpace2, hl = { fg = colors.darkgray, force = true } } +) + +RightSpace3 = utils.surround( + { "█", "" }, + utils.get_highlight("statusline").bg, + { RightSpace3, hl = { fg = colors.darkgray, force = true } } +) + +LSPActive = utils.surround({ "", "" }, function(self) + return self:mode_color() +end, { Space, LSPActive, hl = { bg = colors.darkgray, force = true } }) + +FileInfoBlock = utils.surround({ "", "" }, function(self) + return self:mode_color() +end, { FileInfoBlock, Space, hl = { bg = colors.gray, force = true } }) + +Ruler = utils.surround({ "", "" }, colors.gray, { Ruler, hl = { fg = colors.gray, force = true } }) + +local left = { + { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + --{ LeftSep, hl = function(self) + -- return { fg = self.mode_colors[self.mode], bg = utils.get_highlight("statusline").bg, bold = true, } + -- end, + --}, + { LeftSpace, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { FileNameBlock, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { Space, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { Git, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, +} +local middle = { + { Align, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { Navic, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { DAPMessages, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { Align, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, +} +local right = { + { Diagnostics, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { + RightSpace3, + hl = { bg = colors.darkgray, force = true }, + }, + { LSPActive, hl = { bg = colors.darkgray, force = true } }, + { RightSpace2, hl = { bg = colors.gray, force = true } }, + { FileInfoBlock, hl = { bg = colors.gray, force = true } }, + { RightSpace, hl = { fg = colors.gray, force = true } }, + --{ cursor_location, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + --utils.make_flexible_component( + -- 3, + -- { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + -- { provider = "%<" } + --), +} +--local Align = { provider = "%=", hl = { bg = colors.bg } } + +local sections = { left, middle, right } +local DefaultStatusline = { sections } +--LSPActive, Space, LSPMessages, Space, UltTest, Space, FileType, Space, Ruler, Space, ScrollBar + +local InactiveStatusline = { + condition = conditions.is_not_active, + { FileType, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { Space, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { FileName, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { Align, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, +} + +local SpecialStatusline = { + condition = function() + return conditions.buffer_matches({ + buftype = { "nofile", "prompt", "help", "quickfix" }, + filetype = { "^git.*", "fugitive" }, + }) + end, + + --FileType, + --Space, + --Align, + { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + { LeftSpace, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { FileType, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { Space, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { Align, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { RightSpace, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, +} + +local TerminalStatusline = { + + condition = function() + return conditions.buffer_matches({ buftype = { "terminal" } }) + end, + + --hl = { bg = colors.red }, + + -- Quickly add a condition to the ViMode to only show it when buffer is active! + --{ condition = conditions.is_active, ViMode, Space }, + { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + { LeftSpace, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { FileType, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { Space, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { Align, hl = { bg = utils.get_highlight("statusline").bg, force = true } }, + { RightSpace, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + --FileType, + --Space, + --TerminalName, + --Align, +} + +local StatusLine = { + + --hl = function() + -- if conditions.is_active() then + -- return "StatusLine" + -- else + -- return "StatusLineNC" + -- end + --end, + static = { + mode_colors = { + n = colors.blue, + i = colors.green, + v = colors.purple, + V = colors.purple, + ["\22"] = colors.purple, + c = colors.orange, + s = colors.purple, + S = colors.purple, + ["\19"] = colors.purple, + R = colors.red, + r = colors.red, + ["!"] = colors.orange, + t = colors.orange, + }, + mode_color = function(self) + local mode = conditions.is_active() and vim.fn.mode() or "n" + return self.mode_colors[mode] + end, + hl = function(self) + local color = self:mode_color() -- here! + return { bg = color } + end, + }, + fallthrough = false, + + SpecialStatusline, + TerminalStatusline, + InactiveStatusline, + DefaultStatusline, +} + + +-- +--- WinBar +-- +local WinbarFileNameBlock = { + -- let's first set up some attributes needed by this component and it's children + init = function(self) + self.filename = vim.api.nvim_buf_get_name(0) + end, + hl = { bg = colors.bg }, +} + +--local WinbarFileName = { +-- provider = function(self) +-- -- self.filename will be defined later, just keep looking at the example! +-- local filename = self.filename +-- filename = filename == "" and "No Name" or vim.fn.fnamemodify(filename, ":t") +-- return filename +-- end, +-- hl = function() +-- return { fg = colors.gray, italic = true } +-- end, +--} +local WinbarFileName = { + provider = function(self) + -- first, trim the pattern relative to the current directory. For other + -- options, see :h filename-modifers + local filename = vim.fn.fnamemodify(self.filename, ":.") + if filename == "" then + return "No Name" + end + -- now, if the filename would occupy more than 1/4th of the available + -- space, we trim the file path to its initials + -- See Flexible Components section below for dynamic truncation + if not conditions.width_percent_below(#filename, 0.25) then + filename = vim.fn.pathshorten(filename) + end + return filename + end, + --hl = { fg = utils.get_highlight("Statusline").fg, bold = false, bg = colors.bg }, + hl = { fg = colors.gray, bold = false, bg = colors.bg }, +} + +WinbarFileNameBlock = utils.insert( + WinbarFileNameBlock, + FileIcon, + utils.insert(WinbarFileName), -- a new table where FileName is a child of FileNameModifier + unpack(FileFlags), -- A small optimisation, since their parent does nothing + { provider = "%<" } -- this means that the statusline is cut here when there's not enough space +) + +vim.api.nvim_create_autocmd("User", { + pattern = "HeirlineInitWinbar", + callback = function(args) + local buf = args.buf + local buftype = vim.tbl_contains({ "prompt", "nofile", "help", "quickfix" }, vim.bo[buf].buftype) + local filetype = vim.tbl_contains({ "gitcommit", "fugitive" }, vim.bo[buf].filetype) + if buftype or filetype then + vim.opt_local.winbar = nil + end + end, +}) + +On_click = { + -- get the window id of the window in which the component was evaluated + minwid = function() + return vim.api.nvim_get_current_win() + end, + callback = function(_, minwid) + -- winid is the window id of the window the component was clicked from + local winid = minwid + -- do something with the window id, e.g.: + local buf = vim.api.nvim_win_get_buf(winid) + -- ... + end, +} + +local CloseButton = { + condition = function(self) + return not vim.bo.modified + end, + -- a small performance improvement: + -- re register the component callback only on layout/buffer changes. + update = { "WinNew", "WinClosed", "BufEnter" }, + { provider = " " }, + { + provider = "", + hl = { fg = "gray" }, + On_click = { + minwid = function() + return vim.api.nvim_get_current_win() + end, + callback = function(_, minwid) + vim.api.nvim_win_close(minwid, true) + end, + name = "heirline_winbar_close_button", + }, + }, +} + +local Center = { + fallthrough = false, + { -- Hide the winbar for special buffers + condition = function() + return conditions.buffer_matches({ + buftype = { "nofile", "prompt", "help", "quickfix" }, + filetype = { "^git.*", "fugitive" }, + }) + end, + init = function() + vim.opt_local.winbar = nil + end, + }, + { -- A special winbar for terminals + condition = function() + return conditions.buffer_matches({ buftype = { "terminal" } }) + end, + FileType, + Space, + --TerminalName, + }, + { -- An inactive winbar for regular files + condition = function() + return not conditions.is_active() + end, + --utils.surround({ "", "" }, colors.nobg, { FileIcon, { WinbarFileName, hl = { fg = colors.gray } }, FileFlags } ), + utils.surround({ "", "" }, colors.nobg, { WinbarFileNameBlock } ), + }, + -- A winbar for regular files + utils.surround({ "", "" }, colors.nobg, { FileNameBlock }), +} + +--local WinBar = { Align, Center, Align } +local WinBar = { Space, Center } + + +-- TabLine +--local TablineBufnr = { +-- provider = function(self) +-- return tostring(self.bufnr) .. "." +-- end, +-- hl = { fg = colors.white, bold = false }, +---- hl = "Comment", +--} + +-- we redefine the filename component, as we probably only want the tail and not the relative path +local TablineFileName = { + provider = function(self) + -- self.filename will be defined later, just keep looking at the example! + local filename = self.filename + filename = filename == "" and "No Name" or vim.fn.fnamemodify(filename, ":t") + return filename + end, + hl = function(self) + return { fg = colors.white, bold = self.is_active or self.is_visible, italic = true } + end, +} + +local TablineFileFlags = { + { + provider = function(self) + if vim.bo[self.bufnr].modified then + return " [+] " + end + end, + hl = { fg = colors.green }, + }, + { + provider = function(self) + if not vim.bo[self.bufnr].modifiable or vim.bo[self.bufnr].readonly then + return " " + end + end, + hl = { fg = "orange" }, + }, +} + +local TablineFileIcon = { + init = function(self) + local filename = self.filename + local extension = vim.fn.fnamemodify(filename, ":e") + self.icon, self.icon_color = + require("nvim-web-devicons").get_icon_color(filename, extension, { default = true }) + end, + provider = function(self) + return self.icon and (" " .. self.icon .. " ") + end, + hl = function(self) + return { fg = self.icon_color } + end, +} + +-- Here the filename block finally comes together +local TablineFileNameBlock = { + init = function(self) + self.filename = vim.api.nvim_buf_get_name(self.bufnr) + end, + hl = function(self) + if self.is_active then + return "TabLineSel" + -- why not? + --elseif not vim.api.nvim_buf_is_loaded(self.bufnr) then + --return { fg = "gray", bg = colors.bg } + else + return "TabLineFill" + end + end, + on_click = { + callback = function(_, minwid, _, button) + if button == "m" then -- close on mouse middle click + vim.api.nvim_buf_delete(minwid, { force = false }) + else + vim.api.nvim_win_set_buf(0, minwid) + end + end, + minwid = function(self) + return self.bufnr + end, + name = "heirline_tabline_buffer_callback", + }, + --TablineBufnr, + TablineFileIcon, + TablineFileName, + TablineFileFlags, +} + +-- a nice "x" button to close the buffer +local TablineCloseButton = { + condition = function(self) + return not vim.api.nvim_buf_get_option(self.bufnr, "modified") + end, + { provider = " " }, + { + provider = " ", + --hl = { fg = "red", bg = colors.bg }, + hl = { fg = colors.red }, + on_click = { + callback = function(_, minwid) + vim.api.nvim_buf_delete(minwid, { force = false }) + end, + minwid = function(self) + return self.bufnr + end, + name = "heirline_tabline_close_buffer_callback", + }, + }, +} + +-- The final touch! +local TablineBufferBlock = utils.surround({ "", "" }, function(self) + --local TablineBufferBlock = utils.surround({ "█", "█" }, function(self) + if self.is_active then + return utils.get_highlight("TabLineSel").bg + else + return utils.get_highlight("TabLineFill").bg + end +end, { Tab, TablineFileNameBlock, TablineCloseButton }) + +local BufferLine = utils.make_buflist( + TablineBufferBlock, + { provider = " ", hl = { fg = colors.white } }, -- left truncation, optional (defaults to "<") + { provider = " ", hl = { fg = colors.white } } -- right trunctation, also optional (defaults to ...... yep, ">") + -- by the way, open a lot of buffers and try clicking them ;) +) +-- TabList +local Tabpage = { + provider = function(self) + return "%" .. self.tabnr .. "T " .. self.tabnr .. " %T" + end, + hl = function(self) + if not self.is_active then + return "TabLineFill" + else + return "TabLineSel" + end + end, +} + +local TabpageClose = { + provider = "%999X %X", + --hl = "TabLine", + hl = { fg = colors.red, bg = colors.bg }, +} + +local TabPages = { + -- only show this component if there's 2 or more tabpages + condition = function() + return #vim.api.nvim_list_tabpages() >= 2 + end, + { + provider = "%=", + }, + utils.make_tablist(Tabpage), + TabpageClose, +} + +-- TabLineOffset +local TabLineOffset = { + condition = function(self) + local win = vim.api.nvim_tabpage_list_wins(0)[1] + local bufnr = vim.api.nvim_win_get_buf(win) + self.winid = win + + if vim.api.nvim_buf_get_option(bufnr, "filetype") == "NvimTree" then + self.title = "NvimTree" + return true + end + end, + + provider = function(self) + local title = self.title + local width = vim.api.nvim_win_get_width(self.winid) + local pad = math.ceil((width - #title) / 2) + return string.rep(" ", pad) .. title .. string.rep(" ", pad) + end, + + hl = function(self) + if vim.api.nvim_get_current_win() == self.winid then + return "TablineSel" + else + return "TablineFill" + end + end, +} + +local TabLine = { + TabLineOffset, + BufferLine, + TabPages, +} + +require("heirline").setup(StatusLine, WinBar, TabLine) + +-- Yep, with heirline we're driving manual! +--vim.cmd([[au FileType * if index(['wipe', 'delete', 'unload'], &bufhidden) >= 0 | set nobuflisted | endif]]) +-- +--local function get_bufs() +-- return vim.tbl_filter(function(bufnr) +-- return vim.api.nvim_buf_is_loaded(bufnr) and vim.bo[bufnr].buflisted +-- end, vim.api.nvim_list_bufs()) +--end +-- +--local function goto_buf(index) +-- local bufs = get_bufs() +-- if index > #bufs then +-- index = #bufs +-- end +-- vim.api.nvim_win_set_buf(0, bufs[index]) +--end +-- +--local function addKey(key, index) +-- vim.keymap.set("", "<A-" .. key .. ">", function() +-- goto_buf(index) +-- end, { noremap = true, silent = true }) +--end +-- +--for i = 1, 9 do +-- addKey(i, i) +--end +--addKey("0", 10) diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..4c5cf70 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,611 @@ + +local fn = vim.fn +local keymap = vim.keymap + +local utils = require("user.utils") + +local custom_attach = function(client, bufnr) + -- Enable completion triggered by <c-x><c-o> + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') +--vim.lsp.protocol.CompletionItemKind = {} + -- Mappings. + local map = function(mode, l, r, opts) + opts = opts or {} + opts.silent = true + opts.noremap = true + opts.buffer = bufnr + keymap.set(mode, l, r, opts) + end +--map("n", "gd", "<Cmd>Lspsaga lsp_finder<CR>") -- Press "o" to open the reference location +--map("n", "gp", "<Cmd>Lspsaga peek_definition<CR>") +-- --map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" }) + map("n", "<C-]>", vim.lsp.buf.definition) +-- map("n", "K", vim.lsp.buf.hover) +-- map("n", "<C-k>", vim.lsp.buf.signature_help) +-- map("n", "<leader>rn", vim.lsp.buf.rename, { desc = "varialble rename" }) +-- map("n", "gr", vim.lsp.buf.references, { desc = "show references" }) +-- map("n", "[d", vim.diagnostic.goto_prev, { desc = "previous diagnostic" }) +-- map("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic" }) + map("n", "<leader>q", function() + vim.diagnostic.setqflist({ open = true }) + end, { desc = "put diagnostic to qf" }) +-- --map.('n', '<space>q', vim.diagnostic.setloclist) +-- map("n", "ga", vim.lsp.buf.code_action, { desc = "LSP code action" }) +-- map("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" }) +-- map("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" }) +-- map("n", "<leader>wl", function() +-- print(vim.inspect(vim.lsp.buf.list_workspace_folders())) +-- end, { desc = "list workspace folder" }) +-- map("n", "gs", "vim.lsp.buf.document_symbol()<cr>") +-- map("n", "gw", "vim.lsp.buf.workspace_symbol()<cr>", { desc = "list workspace folder" }) +-- --map("n", "gs", ":lua vim.lsp.buf.document_symbol()<cr>") +-- map("n", "gt", ":lua vim.lsp.buf.type_definition()<cr>") +-- map("n", "gD", ":lua vim.lsp.buf.declaration()<cr>") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. +-- map("n", "gi", ":lua vim.lsp.buf.implementation()<cr>") + map("n", "go", ":lua vim.diagnostic.open_float()<cr>") +-- map("n", "gk", "<Cmd>Lspsaga diagnostic_jump_prev<CR>") +-- map("n", "gj", "<Cmd>Lspsaga diagnostic_jump_next<CR>") +--vim.api.nvim_set_keymap('n', '<leader>dd', '<cmd>lua vim.diagnostic.setloclist()<CR>', { noremap = true, silent = true }) + --nnoremap("gI", vim.lsp.buf.incoming_calls, opts) + -- + --nnoremap("<leader>cs", vim.lsp.buf.document_symbol, opts) + --nnoremap("<leader>cw", vim.lsp.buf.workspace_symbol, opts) + --nnoremap("<leader>rf", vim.lsp.buf.formatting, opts) + --require("which-key").register { + -- ["<leader>rf"] = "lsp: format buffer", + -- ["<leader>ca"] = "lsp: code action", + -- ["<leader>gd"] = "lsp: go to type definition", + -- ["gr"] = "lsp: references", + -- ["gi"] = "lsp: implementation", + -- ["gI"] = "lsp: incoming calls", + --} +--end +vim.g.diagnostics_visible = true +function _G.toggle_diagnostics() + if vim.g.diagnostics_visible then + vim.g.diagnostics_visible = false + vim.diagnostic.disable() + else + vim.g.diagnostics_visible = true + vim.diagnostic.enable() + end +end + +--map('n', '<Leader>m', ':call v:lua.toggle_diagnostics()<CR>') + +--vim.g.diagnostics_active = true +--function _G.toggle_diagnostics() +-- if vim.g.diagnostics_active then +-- vim.g.diagnostics_active = false +-- vim.lsp.diagnostic.clear(0) +-- vim.cmd([[exe "normal ii\<Esc>x"]]) +-- vim.lsp.handlers["textDocument/publishDiagnostics"] = function() end +-- else +-- vim.g.diagnostics_active = true +-- vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( +-- vim.lsp.diagnostic.on_publish_diagnostics, { +-- virtual_text = true, +-- signs = true, +-- underline = true, +-- update_in_insert = false, +-- } +-- ) +-- end +--end +-- +--map("n", "<leader>i", ":call v:lua.toggle_diagnostics()<CR>") + + + -- Set some key bindings conditional on server capabilities + if client.server_capabilities.documentFormattingProvider then + map("n", "<space>f", vim.lsp.buf.format, { desc = "format code" }) + end + + -- add rust specific keymappings + if client.name == "rust_analyzer" then + map("n", "<leader>rr", "<cmd>RustRunnables<CR>") + map("n", "<leader>ra", "<cmd>RustHoverAction<CR>") + end + +-- Highlight symbol under cursor + +-- Add the following to your on_attach (this allows checking server capabilities to avoid calling invalid commands. + +if client.server_capabilities.document_highlight then + vim.cmd [[ + hi! LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow + hi! LspReferenceText cterm=bold ctermbg=red guibg=LightYellow + hi! LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow + ]] + vim.api.nvim_create_augroup('lsp_document_highlight', { + clear = false + }) + vim.api.nvim_clear_autocmds({ + buffer = bufnr, + group = 'lsp_document_highlight', + }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + group = 'lsp_document_highlight', + buffer = bufnr, + callback = vim.lsp.buf.document_highlight, + }) + vim.api.nvim_create_autocmd('CursorMoved', { + group = 'lsp_document_highlight', + buffer = bufnr, + callback = vim.lsp.buf.clear_references, + }) +end + +--For diagnostics for specific cursor position +--vim.api.nvim_create_autocmd("CursorHold", { +-- buffer = bufnr, +-- callback = function() +-- local opts = { +-- focusable = false, +-- close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, +-- border = 'rounded', +-- source = 'always', +-- prefix = ' ', +-- scope = 'cursor', +-- } +-- vim.diagnostic.open_float(nil, opts) +-- end +--}) + -- Diagnostic position +-- vim.api.nvim_create_autocmd("CursorHold", { +-- buffer = bufnr, +-- callback = function() +-- local float_opts = { +-- focusable = false, +-- close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, +-- border = "rounded", +-- source = "always", -- show source in diagnostic popup window +-- prefix = " ", +-- } +-- +-- if not vim.b.diagnostics_pos then +-- vim.b.diagnostics_pos = { nil, nil } +-- end +-- +-- local cursor_pos = vim.api.nvim_win_get_cursor(0) +-- if +-- (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2]) +-- and #vim.diagnostic.get() > 0 +-- then +-- vim.diagnostic.open_float(nil, float_opts) +-- end +-- +-- vim.b.diagnostics_pos = cursor_pos +-- end, +-- }) + + -- The below command will highlight the current variable and its usages in the buffer. +-- if client.server_capabilities.documentHighlightProvider then +-- vim.cmd([[ +-- hi! link LspReferenceRead Visual +-- hi! link LspReferenceText Visual +-- hi! link LspReferenceWrite Visual +-- augroup lsp_document_highlight +-- autocmd! * <buffer> +-- autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() +-- autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight() +-- autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references() +-- augroup END +-- ]]) +-- end +-- + -- Only highlight if compatible with the language +-- if client.resolved_capabilities.document_highlight then +-- vim.cmd('augroup LspHighlight') +-- vim.cmd('autocmd!') +-- vim.cmd('autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()') +-- vim.cmd('autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()') +-- vim.cmd('augroup END') +-- end + + if vim.g.logging_level == "debug" then + local msg = string.format("Language server %s started!", client.name) + vim.notify(msg, vim.log.levels.DEBUG, { title = "Server?" }) + end +-- suppress error messages from lang servers +end +vim.lsp.set_log_level("debug") +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) +capabilities.textDocument.completion.completionItem.snippetSupport = true +capabilities.offsetEncoding = { "utf-16" } + +local lspconfig = require("lspconfig") + +if utils.executable("pylsp") then + lspconfig.pylsp.setup({ + settings = { + pylsp = { + plugins = { + pylint = { enabled = true, executable = "pylint" }, + pyflakes = { enabled = false }, + pycodestyle = { enabled = false }, + jedi_completion = { fuzzy = true }, + pyls_isort = { enabled = true }, + pylsp_mypy = { enabled = true }, + }, + }, + }, + flags = { + debounce_text_changes = 200, + }, + capabilities = capabilities, + }) +else + vim.notify("pylsp not found!", vim.log.levels.WARN, { title = "Server?" }) +end + +-- if utils.executable('pyright') then +-- lspconfig.pyright.setup{ +-- on_attach = custom_attach, +-- capabilities = capabilities +-- } +-- else +-- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Server?'}) +-- end + +if utils.executable("clangd") then + lspconfig.clangd.setup({ + on_attach = custom_attach, + capabilities = capabilities, + filetypes = { "c", "cpp", "cc" }, + flags = { + debounce_text_changes = 500, + }, + }) +else + vim.notify("clangd not found!", vim.log.levels.WARN, { title = "Server?" }) +end + +-- set up vim-language-server +if utils.executable("vim-language-server") then + lspconfig.vimls.setup({ + on_attach = custom_attach, + flags = { + debounce_text_changes = 500, + }, + capabilities = capabilities, + }) +else + vim.notify("vim-language-server not found!", vim.log.levels.WARN, { title = "Server?" }) +end + +-- set up bash-language-server +if utils.executable("bash-language-server") then + lspconfig.bashls.setup({ + on_attach = custom_attach, + capabilities = capabilities, + }) +end + +if utils.executable("lua-language-server") then + lspconfig.sumneko_lua.setup({ + on_attach = custom_attach, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { "vim" }, + }, + workspace = { + -- Make the server aware of Neovim runtime files, + library = { + fn.stdpath("data") .. "/site/pack/packer/opt/emmylua-nvim", + fn.stdpath("config"), + }, + maxPreload = 2000, + preloadFileSize = 50000, + }, + }, + }, + capabilities = capabilities, + }) +end + + +if utils.executable("rust-language-server") then +require("lspconfig").rust_analyzer.setup{ + cmd = { "rustup", "run", "nightly", "rust-analyzer" }, + on_attach = custom_attach, + flags = { + debounce_text_changes = 500, + }, + --[[ + settings = { + rust = { + unstable_features = true, + build_on_save = false, + all_features = true, + }, + } + --]] +} +end + +--vim.diagnostic.config({ +-- virtual_text = false, +-- underline = true, +--}) +vim.diagnostic.config({ + underline = false, + signs = true, + virtual_text = false, + float = { + show_header = true, + source = 'if_many', + border = 'rounded', + focusable = false, + }, + update_in_insert = false, -- default to false + severity_sort = false, -- default to false +}) +-- Show line diagnostics automatically in hover window +--vim.o.updatetime = 250 +--vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,})]] +--vim.cmd ([[ noremap <leader>a :autocmd! CursorHold,CursorHoldI <CR>]]) + +--vim.cmd [[ noremap <leader>a :autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,})<CR>]] +--local diagnostics_active = true +--local toggle_diagnostics = function() +-- diagnostics_active = not diagnostics_active +-- if diagnostics_active then +-- vim.o.updatetime = 250 +-- vim.cmd ([[autocmd! CursorHold,CursorHoldI <CR>]]) +-- --vim.diagnostic.open_float(nil, {focus=false}) +-- else +-- vim.o.updatetime = 250 +-- vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] +-- --vim.diagnostic.hide() +-- --vim.diagnostic.disable() +-- end +--end +--vim.keymap.set("n", "<leader>a", toggle_diagnostics) + +--function LspDiagnosticsFocus() +-- vim.api.nvim_command('set eventignore=WinLeave') +-- vim.api.nvim_command('autocmd CursorMoved <buffer> ++once set eventignore=""') +-- vim.diagnostic.open_float(nil, {focusable = false, scope = 'line', close_events = {"CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre", "WinLeave"}}) +--end +--vim.api.nvim_set_keymap('', '<Leader>a', '<Cmd>lua LspDiagnosticsFocus()<CR>', {silent = true}) + --vim.o.updatetime = 250 + +-- vim.o.updatetime = 250 +----vim.o.updatetime = 250 +----vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,})]] +----local diagnostics_active = true +--local toggle_diagnostics = function() +-- --diagnostics_active = not diagnostics_active +-- --if diagnostics_active then +-- --if vim.diagnostic.open_float() == true then +-- if vim.api.nvim_exec([[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] +--, true) then +-- vim.api.nvim_exec([[autocmd! CursorHold,CursorHoldI ]] +--, true) +-- else +-- vim.o.updatetime = 250 +-- vim.api.nvim_exec([[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]], true) +-- end +--end +--vim.keymap.set("n", "<leader>a", toggle_diagnostics) +-- +--vim.api.nvim_create_autocmd('CursorHold', { +-- vim.diagnostic.open_float(nil, {focus=false}) +-- +--}) + +vim.o.updatetime = 250 +vim.cmd[[ +augroup OpenFloat + autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) + +augroup END +]] +vim.cmd([[ +function! ToggleDiagnosticsOpenFloat() + " Switch the toggle variable + let g:DiagnosticsOpenFloat = !get(g:, 'DiagnosticsOpenFloat', 1) + + " Reset group + augroup OpenFloat + autocmd! + augroup END + + " Enable if toggled on + if g:DiagnosticsOpenFloat + augroup OpenFloat + autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) print ("vim.diagnostic.open_float enabled...") + augroup END + endif +endfunction +nnoremap <leader>o :call ToggleDiagnosticsOpenFloat()<CR>\|:echom "vim.diagnostic.open_float disabled . . ."<CR> +]]) + +--vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( +-- vim.lsp.handlers.hover, { +-- signs = true, +-- underline = false, +-- virtual_text = false, +-- show_diagnostic_autocmds = {'InsertLeave', 'TextChanged'}, +-- diagnostic_delay = 500 +-- }) +--vim.cmd [[autocmd CursorHold * lua vim.diagnostic.open_float(0, {scope="cursor", close_events = {"CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre", "WinLeave"}})]] + +--function LspDiagnosticsFocus() +-- vim.api.nvim_command('set eventignore=WinLeave') +-- vim.api.nvim_command('autocmd CursorMoved <buffer> ++once set eventignore=""') +-- vim.diagnostic.open_float(nil, {focusable = false, scope = 'line', close_events = {"CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre", "WinLeave"}}) +--end +--vim.api.nvim_set_keymap('', '<Leader>a', '<Cmd>lua LspDiagnosticsFocus()<CR>', {silent = true}) + +--local diagnostics_active = true +--map('n', '<leader>a', function() +-- diagnostics_active = not diagnostics_active +-- if diagnostics_active then +-- vim.diagnostic.show() +-- else +-- vim.diagnostic.hide() +-- end +--end) + +-- Global config for diagnostic +--vim.diagnostic.config({ +-- underline = false, +-- virtual_text = false, +-- signs = true, +-- severity_sort = true, +-- float = { +-- focusable = true, -- +-- style = "minimal", -- +-- --border = "rounded", +-- border = "shadow", +-- source = "always", +-- header = "", +-- prefix = "", +-- }, +--}) + +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + underline = true, + virtual_text = false, + signs = true, + update_in_insert = false, +}) + +--vim.lsp.buf.definition +vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) + +--vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) + +vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }) + +--local signs = { Error = " ", Warn = " ", Info = " ", Hint = " " } +--local signs = { Error = "✘", Warn = "▲", Info = "🛈 ", Hint = "⚑" } +local signs = { Error = "✘", Warn = "▲", Info = "", Hint = "⚑" } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +end + + +---- Location information about the last message printed. The format is +---- `(did print, buffer number, line number)`. +--local last_echo = { false, -1, -1 } +-- +---- The timer used for displaying a diagnostic in the commandline. +--local echo_timer = nil +-- +---- The timer after which to display a diagnostic in the commandline. +--local echo_timeout = 250 +-- +---- The highlight group to use for warning messages. +--local warning_hlgroup = 'WarningMsg' +-- +---- The highlight group to use for error messages. +--local error_hlgroup = 'ErrorMsg' +-- +---- If the first diagnostic line has fewer than this many characters, also add +---- the second line to it. +--local short_line_limit = 20 +-- +---- Shows the current line's diagnostics in a floating window. +--function show_line_diagnostics() +-- vim +-- .lsp +-- .diagnostic +-- .show_line_diagnostics({ severity_limit = 'Warning' }, vim.fn.bufnr('')) +--end +-- +---- Prints the first diagnostic for the current line. +--function echo_diagnostic() +-- if echo_timer then +-- echo_timer:stop() +-- end +-- +-- echo_timer = vim.defer_fn( +-- function() +-- local line = vim.fn.line('.') - 1 +-- local bufnr = vim.api.nvim_win_get_buf(0) +-- +-- if last_echo[1] and last_echo[2] == bufnr and last_echo[3] == line then +-- return +-- end +-- +-- local diags = vim +-- .lsp +-- .diagnostic +-- .get_line_diagnostics(bufnr, line, { severity_limit = 'Warning' }) +-- +-- if #diags == 0 then +-- -- If we previously echo'd a message, clear it out by echoing an empty +-- -- message. +-- if last_echo[1] then +-- last_echo = { false, -1, -1 } +-- +-- vim.api.nvim_command('echo ""') +-- end +-- +-- return +-- end +-- +-- last_echo = { true, bufnr, line } +-- +-- local diag = diags[1] +-- local width = vim.api.nvim_get_option('columns') - 15 +-- local lines = vim.split(diag.message, "\n") +-- local message = lines[1] +-- local trimmed = false +-- +-- if #lines > 1 and #message <= short_line_limit then +-- message = message .. ' ' .. lines[2] +-- end +-- +-- if width > 0 and #message >= width then +-- message = message:sub(1, width) .. '...' +-- end +-- +-- local kind = 'warning' +-- local hlgroup = warning_hlgroup +-- +-- if diag.severity == vim.lsp.protocol.DiagnosticSeverity.Error then +-- kind = 'error' +-- hlgroup = error_hlgroup +-- end +-- +-- local chunks = { +-- { kind .. ': ', hlgroup }, +-- { message } +-- } +-- +-- vim.api.nvim_echo(chunks, false, {}) +-- end, +-- echo_timeout +-- ) +--end +--vim.cmd([[ +-- autocmd CursorMoved * :lua echo_diagnostic() +--]]) +-- Highlight line number instead of having icons in sign column + +-- See the properties of the signs with sign list. + +--vim.cmd [[ +-- highlight! DiagnosticLineNrError guibg=#51202A guifg=#FF0000 gui=bold +-- highlight! DiagnosticLineNrWarn guibg=#51412A guifg=#FFA500 gui=bold +-- highlight! DiagnosticLineNrInfo guibg=#1E535D guifg=#00FFFF gui=bold +-- highlight! DiagnosticLineNrHint guibg=#1E205D guifg=#0000FF gui=bold +-- +-- sign define DiagnosticSignError text= texthl=DiagnosticSignError linehl= numhl=DiagnosticLineNrError +-- sign define DiagnosticSignWarn text= texthl=DiagnosticSignWarn linehl= numhl=DiagnosticLineNrWarn +-- sign define DiagnosticSignInfo text= texthl=DiagnosticSignInfo linehl= numhl=DiagnosticLineNrInfo +-- sign define DiagnosticSignHint text= texthl=DiagnosticSignHint linehl= numhl=DiagnosticLineNrHint +--]] + diff --git a/.config/nvim/lua/plugins/lspsaga.lua b/.config/nvim/lua/plugins/lspsaga.lua new file mode 100644 index 0000000..4161ce9 --- /dev/null +++ b/.config/nvim/lua/plugins/lspsaga.lua @@ -0,0 +1,46 @@ +return function() + local saga = require "lspsaga" + + saga.init_lsp_saga { + use_saga_diagnostic_sign = false, + finder_action_keys = { + vsplit = "v", + split = "s", + quit = { "q", "<ESC>" }, + }, + code_action_icon = "💡", + code_action_prompt = { + enable = false, + sign = false, + virtual_text = false, + }, + } + + require("as.highlights").highlight("LspSagaLightbulb", { guifg = "NONE", guibg = "NONE" }) + +-- as.vnoremap("<leader>ca", ":<c-u>lua require('lspsaga.codeaction').range_code_action()<CR>") +-- as.inoremap("<c-k>", "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>") +-- as.nnoremap("K", "<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>") +-- -- scroll down hover doc +-- as.nnoremap("<C-f>", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>") +-- -- scroll up hover doc +-- as.nnoremap("<C-b>", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>") + + require("which-key").register { + ["<leader>rn"] = { require("lspsaga.rename").rename, "lsp: rename" }, + ["<leader>ca"] = { require("lspsaga.codeaction").code_action, "lsp: code action" }, + ["gp"] = { require("lspsaga.provider").preview_definition, "lsp: preview definition" }, + ["gh"] = { require("lspsaga.provider").lsp_finder, "lsp: finder" }, + -- jump diagnostic + ["]c"] = { require("lspsaga.diagnostic").lsp_jump_diagnostic_prev, "lsp: previous diagnostic" }, + ["[c"] = { require("lspsaga.diagnostic").lsp_jump_diagnostic_next, "lsp: next diagnostic" }, + } + + -- augroup("LspSagaCursorCommands", { + -- { + -- events = { "CursorHold" }, + -- targets = { "*" }, + -- command = "lua require('lspsaga.diagnostic').show_cursor_diagnostics()", + -- }, + -- }) +end diff --git a/.config/nvim/lua/plugins/luasnip.lua b/.config/nvim/lua/plugins/luasnip.lua new file mode 100644 index 0000000..de2177e --- /dev/null +++ b/.config/nvim/lua/plugins/luasnip.lua @@ -0,0 +1,69 @@ +local ls = require "luasnip" -- + +require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" }) +--local options = { +ls.config.set_config { + history = true, + updateevents = "TextChanged,TextChangedI", + -- Autosnippets: + enable_autosnippets = true, -- + ext_opts = { -- + [require("luasnip.util.types").choiceNode] = { + active = { + virt_text = { { "«", "GruvboxOrange" } }, + }, + }, + }, +} + +--local keymap = vim.keymap +--local keymap = vim.api.nvim_set_keymap +local keymap = vim.keymap.set +--keymap('i', '<c-f>', 'luasnip#expand_or_jumpable() ? "<Plug>luasnip-expand-or-jump" : "<Tab>"', {expr = true, silent = true}) +keymap({ "i", "s"}, "<c-f>", function() + if ls.expand_or_jumpable() then + ls.expand() + end +end) + +keymap({ "i", "s"}, "<c-j>", function() + if ls.jumpable(1) then + ls.jump(1) + end +end) + +keymap({ "i", "s"}, "<c-k>", function() + if ls.jumpable(-1) then + ls.jump(-1) + end +end) + +keymap({ "i", "s"}, "<c-c>", function() + if ls.choice_active() then + ls.change_choice(1) + end +end) + +keymap({ "i", "s"}, "<a-c>", function() + if ls.choice_active() then + ls.change_choice(-1) + end +end) + +-- Character class Matching +-- %a letters (A-Z, a-z) +-- %c control characters (\n, \t, \r, ...) +-- %d digits (0-9) +-- %l lower-case letter (a-z) +-- %p punctuation characters (!, ?, &, ...) +-- %s space characters +-- %u upper-case letters +-- %w alphanumeric characters (A-Z, a-z, 0-9) +-- %x hexadecimal digits (\3, \4, ...) +-- %z the character with representation 0 +-- . Matches any character + + + + + diff --git a/.config/nvim/lua/plugins/mason.lua b/.config/nvim/lua/plugins/mason.lua new file mode 100644 index 0000000..c0fdca6 --- /dev/null +++ b/.config/nvim/lua/plugins/mason.lua @@ -0,0 +1,61 @@ +local status, mason = pcall(require, "mason") +if (not status) then return end +local status2, lspconfig = pcall(require, "mason-lspconfig") +if (not status2) then return end + +mason.setup({ + +}) + +lspconfig.setup { + ensure_installed = { "sumneko_lua" }, +} +local keymap = vim.api.nvim_set_keymap +local opts = { noremap = true } + + +keymap('n', 'gd', ':lua vim.lsp.buf.definition()<cr>', opts) +keymap('n', 'gD', ':lua vim.lsp.buf.declaration()<cr>', opts) +keymap('n', 'gi', ':lua vim.lsp.buf.implementation()<cr>', opts) +keymap('n', 'gw', ':lua vim.lsp.buf.document_symbol()<cr>', opts) +keymap('n', 'gw', ':lua vim.lsp.buf.workspace_symbol()<cr>', opts) +keymap('n', 'gr', ':lua vim.lsp.buf.references()<cr>', opts) +keymap('n', 'gt', ':lua vim.lsp.buf.type_definition()<cr>', opts) +keymap('n', 'K', ':lua vim.lsp.buf.hover()<cr>', opts) +keymap('n', '<c-k>', ':lua vim.lsp.buf.signature_help()<cr>', opts) +keymap('n', '<leader>af', ':lua vim.lsp.buf.code_action()<cr>', opts) +keymap('n', '<leader>rn', ':lua vim.lsp.buf.rename()<cr>', opts) + + + +--local mason = require("mason") +-- +--local options = { +-- ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim +-- +-- ui = { +-- icons = { +-- package_pending = " ", +-- package_installed = " ", +-- package_uninstalled = " ﮊ", +-- }, +-- +-- keymaps = { +-- toggle_server_expand = "<CR>", +-- install_server = "i", +-- update_server = "u", +-- check_server_version = "c", +-- update_all_servers = "U", +-- check_outdated_servers = "C", +-- uninstall_server = "X", +-- cancel_installation = "<C-c>", +-- }, +-- }, +-- +-- max_concurrent_installers = 10, +--} +-- +-- +-- +--mason.setup(options) + diff --git a/.config/nvim/lua/plugins/modify-blend.lua b/.config/nvim/lua/plugins/modify-blend.lua new file mode 100644 index 0000000..7c48815 --- /dev/null +++ b/.config/nvim/lua/plugins/modify-blend.lua @@ -0,0 +1,40 @@ +local ui = vim.api.nvim_list_uis()[1] + +local bufnr = vim.api.nvim_create_buf(false, true) +local win = vim.api.nvim_open_win(bufnr, true, { + relative = "editor", + width = ui.width, + height = ui.height, + row = 10, + col = 10, + style = "minimal", +}) + +vim.api.nvim_win_set_option(win, "winblend", 1) + +local blend_start = 15 +local offset = 1 + +CANCEL = false +local timer = vim.loop.new_timer() +timer:start( + 0, + 50, + vim.schedule_wrap(function() + blend_start = blend_start + offset + + if blend_start > 90 then + offset = -1 + elseif blend_start < 10 then + offset = 1 + end + + if CANCEL or not vim.api.nvim_win_is_valid(win) then + timer:close() + timer:stop() + return + end + + vim.cmd([[highlight NormalFloat blend=]] .. tostring(blend_start)) + end) +) diff --git a/.config/nvim/lua/plugins/neoscroll.lua b/.config/nvim/lua/plugins/neoscroll.lua new file mode 100644 index 0000000..d122584 --- /dev/null +++ b/.config/nvim/lua/plugins/neoscroll.lua @@ -0,0 +1,21 @@ +require("neoscroll").setup({ + easing_function = "quadratic", +}) + +local t = {} +-- Syntax: t[keys] = {function, {function arguments}} +-- Use the "sine" easing function +t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "20", [['cubic']] } } +t["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", "20", [['cubic']] } } +-- Use the "circular" easing function +t["<C-b>"] = { "scroll", { "-vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } } +t["<C-f>"] = { "scroll", { "vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } } +-- Pass "nil" to disable the easing animation (constant scrolling speed) +t["<C-y>"] = { "scroll", { "-0.10", "false", "100", nil } } +t["<C-e>"] = { "scroll", { "0.10", "false", "100", nil } } +-- When no easing function is provided the default easing function (in this case "quadratic") will be used +t["zt"] = { "zt", { "10" } } +t["zz"] = { "zz", { "10" } } +t["zb"] = { "zb", { "10" } } + +require("neoscroll.config").set_mappings(t) diff --git a/.config/nvim/lua/plugins/null-ls.lua b/.config/nvim/lua/plugins/null-ls.lua new file mode 100644 index 0000000..4573a54 --- /dev/null +++ b/.config/nvim/lua/plugins/null-ls.lua @@ -0,0 +1,44 @@ +local null_ls_status_ok, null_ls = pcall(require, "null-ls") +if not null_ls_status_ok then + return +end +--[[null-ls.]] +-- +-- null-language-server i.e. a sort of language server which does not provide any services such as formatting and diagnostics you expect from a language server. Instead it will need to install corresponding external “sources” and then hook these sources into the neovim lsp client through null-ls. +-- + +null_ls.setup({ + debug = true, + sources = { + require("null-ls").builtins.formatting.stylua, -- lua formatting + require("null-ls").builtins.formatting.prettier.with({ -- markdown, html/js formatting + filetypes = { "html", "css", "javascript", "javascriptreact", "markdown", "json", "yaml" }, + }), + require("null-ls").builtins.formatting.shfmt.with({ -- shell script formatting + filetypes = { "bash", "zsh", "sh" }, + }), + require("null-ls").builtins.diagnostics.shellcheck, -- shell script diagnostics + require("null-ls").builtins.code_actions.shellcheck, -- shell script code actions + --require("null-ls").builtins.formatting.black, + --require("null-ls").builtins.formatting.prettierd, + --require("null-ls").builtins.diagnostics.luacheck, + --require("null-ls").builtins.diagnostics.eslint, + --require("null-ls").builtins.diagnostics.eslint_d, + --require("null-ls").builtins.diagnostics.mdl, + --require("null-ls").builtins.diagnostics.vint, + --require("null-ls").builtins.codeactions.eslint_d, + --require("null-ls").builtins.completion.spell, + }, + on_attach = function(client, bufnr) + if client.server_capabilities.document_formatting then + local group = vim.api.nvim_create_augroup("NullLsFormatting", { clear = true }) + vim.api.nvim_create_autocmd("BufWritePre", { + callback = function() + vim.lsp.buf.formatting_sync(nil, 4000) + end, + buffer = bufnr, + group = group, + }) + end + end, +}) diff --git a/.config/nvim/lua/plugins/nvim-tree.lua b/.config/nvim/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..a1e10e0 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-tree.lua @@ -0,0 +1,69 @@ +local status_ok, nvim_tree = pcall(require, "nvim-tree") +if not status_ok then + return +end + +local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") +if not config_status_ok then + return +end + +local tree_cb = nvim_tree_config.nvim_tree_callback + +nvim_tree.setup({ + update_focused_file = { + enable = true, + update_cwd = true, + }, + renderer = { + root_folder_modifier = ":t", + icons = { + glyphs = { + default = "", + symlink = "", + folder = { + arrow_open = "", + arrow_closed = "", + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + symlink_open = "", + }, + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + untracked = "U", + deleted = "", + ignored = "◌", + }, + }, + }, + }, + diagnostics = { + enable = true, + show_on_dirs = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + view = { + width = 30, + --height = 30, + side = "left", + mappings = { + list = { + { key = { "l", "<CR>", "o" }, cb = tree_cb("edit") }, + { key = "h", cb = tree_cb("close_node") }, + { key = "v", cb = tree_cb("vsplit") }, + { key = "u", action = "dir_up" }, + }, + }, + }, +}) diff --git a/.config/nvim/lua/plugins/prettier.lua b/.config/nvim/lua/plugins/prettier.lua new file mode 100644 index 0000000..05d4665 --- /dev/null +++ b/.config/nvim/lua/plugins/prettier.lua @@ -0,0 +1,19 @@ +local status, prettier = pcall(require, "prettier") +if (not status) then return end + +prettier.setup { + bin = 'prettierd', + filetypes = { + "c", + "lua", + "vim", + --"css", + --"javascript", + --"javascriptreact", + --"typescript", + --"typescriptreact", + --"json", + --"scss", + "less" + } +} diff --git a/.config/nvim/lua/plugins/scripts/lsp-ext.lua b/.config/nvim/lua/plugins/scripts/lsp-ext.lua new file mode 100644 index 0000000..c4378c6 --- /dev/null +++ b/.config/nvim/lua/plugins/scripts/lsp-ext.lua @@ -0,0 +1,48 @@ +-- +-- lsp-ext.lua + + +M = {} + +function M.preview_location(location, context, before_context) + -- location may be LocationLink or Location (more useful for the former) + context = context or 15 + before_context = before_context or 0 + local uri = location.targetUri or location.uri + if uri == nil then + return + end + local bufnr = vim.uri_to_bufnr(uri) + if not vim.api.nvim_buf_is_loaded(bufnr) then + vim.fn.bufload(bufnr) + end + local range = location.targetRange or location.range + local contents = + vim.api.nvim_buf_get_lines(bufnr, range.start.line - before_context, range["end"].line + 1 + context, false) + local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype") + return vim.lsp.util.open_floating_preview(contents, filetype) +end + +function M.preview_location_callback(_, method, result) + local context = 15 + if result == nil or vim.tbl_isempty(result) then + print("No location found: " .. method) + return nil + end + if vim.tbl_islist(result) then + M.floating_buf, M.floating_win = M.preview_location(result[1], context) + else + M.floating_buf, M.floating_win = M.preview_location(result, context) + end +end + +function M.peek_definition() + if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then + vim.api.nvim_set_current_win(M.floating_win) + else + local params = vim.lsp.util.make_position_params() + return vim.lsp.buf_request(0, "textDocument/definition", params, M.preview_location_callback) + end +end + +return M diff --git a/.config/nvim/lua/plugins/scripts/setcolors.lua b/.config/nvim/lua/plugins/scripts/setcolors.lua new file mode 100644 index 0000000..605bc84 --- /dev/null +++ b/.config/nvim/lua/plugins/scripts/setcolors.lua @@ -0,0 +1,121 @@ +vim.cmd([[ +" Change the color scheme from a list of color scheme names. +" Version 2010-09-12 from http://vim.wikia.com/wiki/VimTip341 +" Press key: +" F8 next scheme +" Shift-F8 previous scheme +" Alt-F8 random scheme +" Set the list of color schemes used by the above (default is 'all'): +" :SetColors all (all $VIMRUNTIME/colors/*.vim) +" :SetColors my (names built into script) +" :SetColors blue ayu ron (these schemes) +" :SetColors (display current scheme names) +" Set the current color scheme based on time of day: +" :SetColors now +if v:version < 700 || exists('loaded_setcolors') || &cp + finish +endif + +let loaded_setcolors = 1 +let s:mycolors = ['everblush', 'ayu', 'gruvbox', 'molokai', 'onedark', 'srcery'] " colorscheme names that we use to set color + +" Set list of color scheme names that we will use, except +" argument 'now' actually changes the current color scheme. +function! s:SetColors(args) + if len(a:args) == 0 + echo 'Current color scheme names:' + let i = 0 + while i < len(s:mycolors) + echo ' '.join(map(s:mycolors[i : i+4], 'printf("%-14s", v:val)')) + let i += 5 + endwhile + elseif a:args == 'all' + let paths = split(globpath(&runtimepath, 'colors/*.vim'), "\n") + let s:mycolors = uniq(sort(map(paths, 'fnamemodify(v:val, ":t:r")'))) + echo 'List of colors set from all installed color schemes' + elseif a:args == 'my' + let c1 = 'default srcery everblush' + let c2 = 'gruvbox onedark' + let c3 = 'ayu molokai' + let s:mycolors = split(c1.' '.c2.' '.c3) + echo 'List of colors set from built-in names' + elseif a:args == 'now' + call s:HourColor() + else + let s:mycolors = split(a:args) + echo 'List of colors set from argument (space-separated names)' + endif +endfunction + +command! -nargs=* SetColors call s:SetColors('<args>') + +" Set next/previous/random (how = 1/-1/0) color from our list of colors. +" The 'random' index is actually set from the current time in seconds. +" Global (no 's:') so can easily call from command line. +function! NextColor(how) + call s:NextColor(a:how, 1) +endfunction + +" Helper function for NextColor(), allows echoing of the color name to be +" disabled. +function! s:NextColor(how, echo_color) + if len(s:mycolors) == 0 + call s:SetColors('all') + endif + if exists('g:colors_name') + let current = index(s:mycolors, g:colors_name) + else + let current = -1 + endif + let missing = [] + let how = a:how + for i in range(len(s:mycolors)) + if how == 0 + let current = localtime() % len(s:mycolors) + let how = 1 " in case random color does not exist + else + let current += how + if !(0 <= current && current < len(s:mycolors)) + let current = (how>0 ? 0 : len(s:mycolors)-1) + endif + endif + try + execute 'colorscheme '.s:mycolors[current] + break + catch /E185:/ + call add(missing, s:mycolors[current]) + endtry + endfor + redraw + if len(missing) > 0 + echo 'Error: colorscheme not found:' join(missing) + endif + if (a:echo_color) + echo g:colors_name + endif +endfunction + +nnoremap <leader>cn :call NextColor(1)<CR> +nnoremap <leader>cp :call NextColor(-1)<CR> +nnoremap <leader>cc :call NextColor(0)<CR> + +" Set color scheme according to current time of day. +function! s:HourColor() + let hr = str2nr(strftime('%H')) + if hr <= 3 + let i = 0 + elseif hr <= 7 + let i = 1 + elseif hr <= 14 + let i = 2 + elseif hr <= 18 + let i = 3 + else + let i = 4 + endif + let nowcolors = 'srcery onedark molokai' + execute 'colorscheme '.split(nowcolors)[i] + redraw + echo g:colors_name +endfunction +]]) diff --git a/.config/nvim/lua/plugins/scripts/toggleLsp.lua b/.config/nvim/lua/plugins/scripts/toggleLsp.lua new file mode 100644 index 0000000..28af698 --- /dev/null +++ b/.config/nvim/lua/plugins/scripts/toggleLsp.lua @@ -0,0 +1,40 @@ +local M = {} + +local check_function = function(bufnr, _) + local ok, result = pcall(vim.api.nvim_buf_get_var, bufnr, 'lsp_enabled') + -- No buffer local variable set, so just enable by default + if not ok then + return true + end + + return result +end + +vim.lsp.handlers["textDocument/publishDiagnostics"] = + vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + underline = check_function, + virtual_text = check_function, + signs = check_function + }) + +function M.Enable() + vim.b.lsp_enabled = true +end + +function M.Disable() + vim.b.lsp_enabled = false +end + +function M.Toggle() + if vim.b.lsp_enabled == false then + M.Enable() + else + M.Disable() + end +end + +vim.cmd [[ + command! -nargs=* ToggleLsp lua require'lsp.toggle'.Toggle() +]] + +return M diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..f878b77 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,357 @@ +local M = {} +local status_ok, telescope = pcall(require, "telescope") +if not status_ok then + return +end + + +--local actions = require("telescope.actions") +--local builtin = require("telescope.builtin") + +--local themes = require("telescope.themes") +--local utils = require("telescope.utils") +local actions = require("telescope.actions") +--local action_state = require("telescope.actions.state") +--local layout_actions = require("telescope.actions.layout") + +telescope.load_extension("fzf") +--telescope.load_extension("file_browser") +require("telescope").load_extension "file_browser" +require('telescope').load_extension('changed_files') +--require("telescope").load_extension("file_browser") +local fb_actions = require("telescope").extensions.file_browser.actions +--telescope.load_extension('media_files') + +telescope.setup({ + defaults = { + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + "--hidden", + "--fixed-strings", + "--trim", + }, + prompt_prefix = " ", + selection_caret = " ", + entry_prefix = " ", + path_display = { "tail" }, + --path_display = { "truncate" }, + --path_display = { "smart" }, + file_ignore_patterns = { + "packer_compiled.lua", + "%.DS_Store", + "%.git/", + "%.spl", + "%.log", + "%[No Name%]", -- new files / sometimes folders (netrw) + "/$", -- ignore folders (netrw) + "node_modules", + "%.png", + "%.zip", + "%.pxd", + "^.vim/", + "^.local/", + "^.cache/", + "^downloads/", + --"^node_modules/", + --"^undodir/", + }, + mappings = { + i = { + ["<C-n>"] = actions.cycle_history_next, + ["<C-p>"] = actions.cycle_history_prev, + + ["<C-j>"] = actions.move_selection_next, + ["<C-k>"] = actions.move_selection_previous, + + ["<C-c>"] = actions.close, + ["<Esc>"] = actions.close, -- close w/ one esc + --["<Esc>"] = "close", -- close w/ one esc + ["<?>"] = actions.which_key, -- keys from pressing <C-/> + + ["<Down>"] = actions.move_selection_next, + ["<Up>"] = actions.move_selection_previous, + + ["<CR>"] = actions.select_default, + ["<C-x>"] = actions.select_horizontal, + ["<C-y>"] = actions.select_vertical, + ["<C-t>"] = actions.select_tab, + + ["<C-u>"] = actions.preview_scrolling_up, + ["<C-d>"] = actions.preview_scrolling_down, + + ["<PageUp>"] = actions.results_scrolling_up, + ["<PageDown>"] = actions.results_scrolling_down, + + ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse, + ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better, + ["<C-q>"] = actions.send_to_qflist + actions.open_qflist, + ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist, + ["<C-l>"] = actions.complete_tag, + ["<C-_>"] = actions.which_key, -- keys from pressing <C-/> + --["<C-o>"] = function(prompt_bufnr) + -- local selection = require("telescope.actions.state").get_selected_entry() + -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") + -- require("telescope.actions").close(prompt_bufnr) + -- -- Depending on what you want put `cd`, `lcd`, `tcd` + -- vim.cmd(string.format("silent lcd %s", dir)) + --end, + }, + + n = { + ["<esc>"] = actions.close, + ["<q>"] = actions.close, + ["<CR>"] = actions.select_default, + ["<C-x>"] = actions.select_horizontal, + ["<C-y>"] = actions.select_vertical, + ["<C-t>"] = actions.select_tab, + + ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse, + ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better, + ["<C-q>"] = actions.send_to_qflist + actions.open_qflist, + ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist, + + ["j"] = actions.move_selection_next, + ["k"] = actions.move_selection_previous, + ["H"] = actions.move_to_top, + ["M"] = actions.move_to_middle, + ["L"] = actions.move_to_bottom, + + ["<Down>"] = actions.move_selection_next, + ["<Up>"] = actions.move_selection_previous, + ["gg"] = actions.move_to_top, + ["G"] = actions.move_to_bottom, + + ["<C-u>"] = actions.preview_scrolling_up, + ["<C-d>"] = actions.preview_scrolling_down, + + ["<PageUp>"] = actions.results_scrolling_up, + ["<PageDown>"] = actions.results_scrolling_down, + + ["?"] = actions.which_key, + --["<C-o>"] = function(prompt_bufnr) + -- local selection = require("telescope.actions.state").get_selected_entry() + -- local dir = vim.fn.fnamemodify(selection.path, ":p:h") + -- require("telescope.actions").close(prompt_bufnr) + -- -- Depending on what you want put `cd`, `lcd`, `tcd` + -- vim.cmd(string.format("silent lcd %s", dir)) + --end, + }, + }, + }, + preview = { + filesize_limit = 3, + timeout = 250, + }, + selection_strategy = "reset", + sorting_strategy = "ascending", + scroll_strategy = "limit", + color_devicons = true, + layout_strategy = 'horizontal', + layout_config = { + horizontal = { + height = 0.95, + preview_cutoff = 70, + width = 0.92, + preview_width = {0.55, max = 50} + }, + bottom_pane = { + height = 12, + preview_cutoff = 70, + prompt_position = "bottom", + }, + }, + pickers = { + live_grep = { + disable_coordinates = true, + layout_config = { + horizontal = { + preview_width = 0.55, + }, + }, + }, + }, + --pickers = { + --lsp_references = { + -- prompt_prefix='⬅️', + -- show_line=false, + -- trim_text=true, + -- include_declaration=false, + -- initial_mode = "normal", + --}, + --lsp_definitions = { + -- prompt_prefix='➡️', + -- show_line=false, + -- trim_text=true, + -- initial_mode = "normal", + --}, + --lsp_document_symbols = { + -- prompt_prefix='* ', + -- show_line = false, + --}, + --treesitter = { + -- prompt_prefix=' ', + -- show_line = false, + --}, + --find_files = { + -- cwd='%:p:h', + -- prompt_prefix=' ', + -- hidden = true, + -- follow = true, + --}, + --keymaps = { prompt_prefix='? ' }, + --oldfiles = { prompt_prefix=' ' }, + --highlights = { prompt_prefix=' ' }, + --git_files = { + -- prompt_prefix=' ', + -- show_untracked = true, + -- path_display = { "tail" }, + --}, + --buffers = { + -- prompt_prefix=' ', + -- ignore_current_buffer = true, + -- initial_mode = "normal", + -- sort_mru = true, + --}, + --live_grep = { + -- cwd='%:p:h', + -- disable_coordinates=true, + -- prompt_title='Search in Folder', + -- prompt_prefix=' ', + --}, + --spell_suggest = { + -- initial_mode = "normal", + -- prompt_prefix = "暈", + -- theme = "cursor", + -- layout_config = { cursor = { width = 0.3 } } + --}, + --colorscheme = { + -- enable_preview = true, + -- prompt_prefix = '', + -- results_title = '', + -- layout_strategy = "bottom_pane", + --}, + --}, + + extensions = { + file_browser = { + theme = "dropdown", + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = true, + mappings = { + -- your custom insert mode mappings + ["i"] = { + ["<C-w>"] = function() + vim.cmd("normal vbd") + end, + --["<C-h>"] = fb_actions.goto_parent_dir, + }, + ["n"] = { + -- your custom normal mode mappings + ["N"] = fb_actions.create, + --["<C-h>"] = fb_actions.goto_parent_dir, + --["/"] = function() + -- vim.cmd("startinsert") + --end, + }, + }, + }, + --["ui-select"] = { -- mostly code actions + -- initial_mode = "normal", + -- prompt_prefix = " ", + -- results_title = '', + -- layout_strategy = "bottom_pane", + -- sorting_strategy = "ascending", + -- layout_config = { bottom_pane = { height = 8 } }, + --}, + ["ui-select"] = { + require("telescope.themes").get_dropdown({}), + }, + }, +}) + +-------------------------------------------------------------------------------- + +-- have to be loaded after telescope config +--require("telescope").load_extension("ui-select") -- use telescope for selections like code actions +telescope.load_extension("ui-select") + +function M.find_configs() + require("telescope.builtin").find_files { + hidden = true, + no_ignore = false, + prompt_title = " Find Configs", + results_title = "Config Files", + path_display = { "smart" }, + search_dirs = { + "~/.config/nvim", + "~/.config/zsh", + "~/.config/tmux", + "~/.config/X11", + "~/.config/alacritty", + "~/.config/bspwm", + "~/.config/sxhkd", + }, + -- cwd = "~/.config/nvim/", + file_ignore_patterns = { + "~/.config/nvim/startup.log", + "packer_compiled.lua", + "resurrect", + "tmux/plugins", + --"^~/.config/tmux/plugins", + "%.txt", + ".git", + }, + layout_strategy = "horizontal", + layout_config = { preview_width = 0.65, width = 0.75 }, + } +end + +function M.grep_notes() + local opts = {} + opts.hidden = true + opts.search_dirs = { + "~/documents/notes/", + } + opts.prompt_prefix = " " + opts.prompt_title = " Grep Notes" + opts.path_display = { "smart" } + require("telescope.builtin").live_grep(opts) +end + +function M.find_notes() + require("telescope.builtin").find_files { + prompt_title = " Find Notes", + path_display = { "smart" }, + search_dirs = { + "~/documents", + }, + --cwd = "~documents/notes", + layout_strategy = "horizontal", + layout_config = { preview_width = 0.65, width = 0.75 }, + } +end + +function M.file_explorer() + require("telescope.builtin").file_browser({ + prompt_title = "File Browser", + cwd = "~", + layout_strategy = "horizontal", + }) +end + +function M.grep_current_dir() + local buffer_dir = require("telescope.utils").buffer_dir() + local opts = { + prompt_title = "Live Grep in " .. buffer_dir, + cwd = buffer_dir, + } + require("telescope.builtin").live_grep(opts) +end + +return M diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..b081ca3 --- /dev/null +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,34 @@ +local status, treesitter = pcall(require, "nvim-treesitter.configs") +if (not status) then return end + +treesitter.setup { + highlight = { + enable = true, + disable = {}, + }, + indent = { + enable = true, + disable = {}, + --disable = { "python", "css" } + }, + ensure_installed = { + "c", + "bash", + "lua", + "rust", + }, + --ensure_installed = "all", -- one of "all" or a list of languages + --ignore_install = { "" }, -- List of parsers to ignore installing + autotag = { + enable = true, + }, + efactor = { + highlight_definitions = { enable = true }, + highlight_current_scope = { enable = true } + } +} +--vim.opt.foldmethod = "expr" +--vim.opt.foldexpr = "nvim_treesitter#foldexpr()" + +--local parser_config = require "nvim-treesitter.parsers".get_parser_configs() +--parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" } diff --git a/.config/nvim/lua/plugins/web-devicons.lua b/.config/nvim/lua/plugins/web-devicons.lua new file mode 100644 index 0000000..b8396bc --- /dev/null +++ b/.config/nvim/lua/plugins/web-devicons.lua @@ -0,0 +1,12 @@ +local status, icons = pcall(require, "nvim-web-devicons") +if (not status) then return end + +icons.setup { + -- your personnal icons can go here (to override) + -- DevIcon will be appended to `name` + override = { + }, + -- globally enable default icons (default to false) + -- will get overriden by `get_icons` option + default = true +} diff --git a/.config/nvim/lua/plugins/zen-mode.lua b/.config/nvim/lua/plugins/zen-mode.lua new file mode 100644 index 0000000..7e52854 --- /dev/null +++ b/.config/nvim/lua/plugins/zen-mode.lua @@ -0,0 +1,7 @@ +local status, zenMode = pcall(require, "zen-mode") +if (not status) then return end + +zenMode.setup { +} + +vim.keymap.set('n', '<C-w>o', '<cmd>ZenMode<cr>', { silent = true }) diff --git a/.config/nvim/lua/user/keys.lua b/.config/nvim/lua/user/keys.lua new file mode 100644 index 0000000..2c07a5a --- /dev/null +++ b/.config/nvim/lua/user/keys.lua @@ -0,0 +1,651 @@ +--[[ key.lua ]] + +-- Shorten function name +--local keymap = vim.api.nvim_set_keymap +local keymap = vim.keymap + +--local function new_desc(d) +-- return { desc = d } +--end +-- +--local d = new_desc + +--local opts = { noremap = true, silent = true } +local term_opts = { noremap = true, silent = false } + local map = function(mode, l, r, opts) + opts = opts or {} + opts.silent = true + opts.noremap = true + keymap.set(mode, l, r, opts) + end + + +--------------- Standard Operations --------------- +-- Semi-colon as leader key +vim.g.mapleader = ";" +--vim.g.maplocalleader = ";" + +-- "jj" to exit insert-mode +map("i", "jj", "<esc>") + +map("n", "<leader>m", ":messages<CR>") +map("n", "<leader>cd", ":cd %:p:h<CR>:pwd<CR>") +-- Print last error message or use these commands | v:errmsgv | :statusmsg | :h execute() | +--nnoremap <silent><leader>x :put =trim(execute(input(':', '', 'command')))<CR> +-- Press <leader>x, then enter your command, such as 5mess and press <Enter>. The last five message lines will be added to the current buffer. +-- useful to copy error message when vim start + +-- save quickly +--map("n", ";w", ":w<CR>", d("Save buffer")) + +--map("n", "<leader>so", ":luafile %<CR>") + +--vim.cmd([[ +--let $my_vimrc = $localappdata.'/nvim/init.lua' +--nnoremap <leader>so :source $my_vimrc<cr> +--]]) + +-- Toggle between folds +--utils.map("n", "<F2>", "&foldlevel ? 'zM' : 'zR'", { expr = true }) + +-- Move to the next and previous item in the quickfixlist +--utils.map("n", "]c", "<Cmd>cnext<CR>") +--utils.map("n", "[c", "<Cmd>cprevious<CR>") + +-- Use space to toggle fold +--utils.map("n", "<Space>", "za") + +-- Hitting ESC when inside a terminal to get into normal mode +--utils.map("t", "<Esc>", [[<C-\><C-N>]]) + +-- select last change +--nnoremap gV `[v`] + +--map("n", "<esc>", function() +-- notify.dismiss() +-- vim.cmd.noh() +--end) + +--"nnore fast [e]dit and [s]ourcing .[v]imrc +--nnoremap <leader>ev :edit $MYVIMRC<CR> +--"fast macro +--nnoremap @ <cmd>set lazyredraw <bar> execute 'noautocmd norm! ' . v:count1 . '@' . getcharstr() <bar> set nolazyredraw<cr> +--xnoremap @ :<C-U>set lazyredraw <bar> execute "noautocmd '<,'>norm! " . v:count1 . "@" . getcharstr()<bar> set nolazyredraw<cr> + +--map("n", "<leader><CR>", ":runtime! /lua/plugins/*.lua<CR> | :runtime! /lua/user/*.lua<CR> | :luafile ~/.config/nvim/init.lua<CR>", print ("Nvim reloaded")) +--map("n", "<leader><CR>", ":lua require('init').unload_lua_namespace()<CR>", print ("Nvim reloaded")) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO)) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :lua require("notify")("completion off")") +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", vim.api.nvim_echo({{'first chunk and ', 'None'}, {'second chunk to echo', 'None'}}, false, {})) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", print ("Nvim config loading...")) +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echo ('hello') | <C-l><CR>") +map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nvim config loading...') | :sl! | echo ('')<CR>") +map("n", "<leader>u", ":echo '' | redraw<CR>") --clear messages +--map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>") +--vim.api.nvim_set_keymap("n", "<leader><CR>", "<cmd>lua ReloadConfig()<CR>", { noremap = true, silent = false }) + +map("n", "<Leader>tc", ":lua require('user.utils').toggle_completion()<CR>") +-- vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO) + +--vim.api.nvim_set_keymap('n', '<Leader>qr', '<cmd>:lua require("plugins.telescope").reload()<CR>', { noremap = true, silent = true }) + +--Easier split navigations, just ctrl-j instead of ctrl-w then j +map("n", "<C-J>", "<C-W><C-J>") +map("n", "<C-K>", "<C-W><C-K>") +map("n", "<C-L>", "<C-W><C-L>") +map("n", "<C-H>", "<C-W><C-H>") + +-- Combine buffers list with buffer name +map("n", "<Leader>b", ":buffers<CR>:buffer<Space>") +--map("n", "<leader>b", ":ls<cr>:b<space>") + +-- Map buffer next, prev and delete to <leader+(n/p/d)> +map("n", "<leader>n", ":bn<cr>") +map("n", "<leader>p", ":bp<cr>") +map("n", "<leader>d", ":bd<cr>") + +-- Disable default completion. +map('i', '<C-n>', '<Nop>') +map('i', '<C-p>', '<Nop>') + +-- Set alt + j/k to switch lines of texts or simply move them +map("n", "<A-k>", ':let save_a=@a<Cr><Up>"add"ap<Up>:let @a=save_a<Cr>') +map("n", "<A-j>", ':let save_a=@a<Cr>"add"ap:let @a=save_a<Cr>') + +map("i", "<C-l>", "<Del>") + +map("n", "<leader><C-l>", "<Cmd>!clear<CR>") + +map("n", "<leader>y", ":BufferPick<CR>") + +vim.cmd([[ + inoremap <A-h> <left> + inoremap <A-j> <down> + inoremap <A-k> <up> + inoremap <A-l> <right> +]]) + +vim.cmd([[ + cnoremap <A-h> <left> + cnoremap <A-j> <down> + cnoremap <A-k> <up> + cnoremap <A-l> <right> +]]) + +--vim.cmd([[ +-- cnoremap <C-A> <Home> +-- cnoremap <C-F> <Right> +-- cnoremap <C-B> <Left> +-- cnoremap <C-E> <End> +--]]) + +vim.cmd([[ + snoremap <A-h> <left> + snoremap <A-j> <down> + snoremap <A-k> <up> + snoremap <A-l> <right> +]]) + +-- move block easily +map("n", "<", "<<", term_opts) +map("n", ">", ">>", term_opts) +map("x", "<", "<gv", term_opts) +map("x", ">", ">gv", term_opts) + +-- Resize Panes +map("n", "<Leader>+", ":resize +5<CR>") +map("n", "<Leader>-", ":resize -5<CR>") +map("n", "<Leader><", ":vertical resize +5<CR>") +map("n", "<Leader>>", ":vertical resize -5<CR>") +map("n", "<Leader>=", "<C-w>=") + +-- New tab +map("n", "<C-T>e", ":tabedit") + +-- create tab like window +map("n", "<C-T>h", ":tabprevious<CR>") +map("n", "<C-T>l", ":tabnext<CR>") +map("n", "<C-T>n", ":tabnew<CR>") + +-- Vim TABs +map("n", "<leader>1", "1gt<CR>") +map("n", "<leader>2", "2gt<CR>") +map("n", "<leader>3", "3gt<CR>") +map("n", "<leader>4", "4gt<CR>") +map("n", "<leader>5", "5gt<CR>") +map("n", "<leader>6", "6gt<CR>") +map("n", "<leader>7", "7gt<CR>") +map("n", "<leader>8", "8gt<CR>") +map("n", "<leader>9", "9gt<CR>") +map("n", "<leader>0", "10gt<CR>") + +-- Split window +map("n", "<leader>h", ":split<CR>") +map("n", "<leader>v", ":vsplit<CR>") +map("n", "<leader>c", "<C-w>c") + +-- Toggle set number +map("n", "<leader>$", ":NumbersToggle<CR>") +map("n", "<leader>%", ":NumbersOnOff<CR>") + +-- Change mode to executable +map("n", "<leader>x", ":!chmod +x %<CR>") + +-- Paste without replace clipboard +map("v", "p", '"_dP') + +-- Paste end of line +--map("n", ",", "$p") +--vim.cmd([[ +-- nmap , $p +--]]) + +-- Select entire buffer +--map("v", "<aa>", "gg<S-v>G") + +-- Delete without changing the registers +--map('n', 'x', '"_x') + +-- Select all text in current buffer +--map('n', '<leader>a', ':keepjumps normal! ggVG<cr>') + +-- Swap two pieces of text, use x to cut in visual mode, then use Ctrl-x in +-- visual mode to select text to swap with +map("v", "<C-X>", "<Esc>`.``gvP``P") + +-- Keep Visual mode selection when indenting text +--utils.map("x", ">", ">gv") +--utils.map("x", "<", "<gv") + +-- Make visual pasting a word to not update the unnamed register +-- Thus, allowing us to repeatedly paste the word. {"_ : black-hole register} +--utils.map("v", "p", [["_dP]]) + +-- Whole-word search +--utils.map("n", "<leader>/", ":/\\<\\><Left><Left>", { silent = false }) + +-- EasyAlign keybindings +-- 'vipga' starts interactive EasyAlign in visual mode +-- 'gaip' starts interactive EasyAlign for text/motion object +--utils.map({ "n", "x" }, "ga", "<Plug>(EasyAlign)") +--utils.map({ "n", "x" }, "<leader>ga", "<Plug>(LiveEasyAlign)") + +-- Set a mark when moving more than 5 lines upwards/downards +-- this will populate the jumplist enabling us to jump back with Ctrl-O +--utils.map("n", "k", [[(v:count > 5 ? "m'" . v:count : "") . 'k']], { expr = true }) +--utils.map("n", "j", [[(v:count > 5 ? "m'" . v:count : "") . 'j']], { expr = true }) + +-- Zoom toggle a buffer in a new tab +--utils.map("n", "<leader>z", function() +-- require("tt.helper").zoomToggleNewTab() +--end, { desc = "Zoom toggle a buffer in a new tab" }) + +-- Hitting ESC when inside a terminal to get into normal mode +--utils.map("t", "<Esc>", [[<C-\><C-N>]]) + +-- markdown-preview +map("n", "<leader>md", "<Plug>MarkdownPreviewToggle") + + +-- Search and replace +map("v", "<leader>sr", 'y:%s/<C-r><C-r>"//g<Left><Left>c') +--vnoremap ; :call Get_visual_selection()<cr> +-- +--function! Get_visual_selection() +-- " Why is this not a built-in Vim script function?! +-- let [lnum1, col1] = getpos("'<")[1:2] +-- let [lnum2, col2] = getpos("'>")[1:2] +-- let lines = getline(lnum1, lnum2) +-- let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] +-- let lines[0] = lines[0][col1 - 1:] +-- let selection = join(lines,'\n') +-- let change = input('Change the selection with: ') +-- execute ":%s/".selection."/".change."/g" +--endfunction +vim.cmd([[ +let s:hidden_all = 0 +function! ToggleHiddenAll() + if s:hidden_all == 0 + let s:hidden_all = 1 + set noshowmode + set noruler + set laststatus=0 + set noshowcmd + else + let s:hidden_all = 0 + set showmode + set ruler + set laststatus=2 + set showcmd + endif +endfunction +nnoremap <S-h> :call ToggleHiddenAll()<CR> +]]) + +vim.cmd([[ + map <leader>s :up \| saveas! %:p:r-<C-R>=strftime("%y.%m.%d-%H:%M")<CR>-bak.<C-R>=expand("%:e")<CR> \| 3sleep \| e #<CR> +]]) + +-- Execute this file +--map("n", "<leader><leader>x", ":call scripts#save_and_exec()<CR>", print("save & exec")) +vim.cmd([[ + " Execute this file + nnoremap <leader><leader>x :call scripts#save_and_exec()<CR>\|:echom "save & exec . . ."<CR> + +]]) + +-------------- FZF -------------- +map("n", "<leader>fz", "<cmd>lua require('fzf-lua').files()<CR>") + +-------------- Telescope -------------- +--Telescope find_files cwd=.. +map("n", "<leader>fc", "<cmd>lua require('telescope.builtin').commands()<cr>") +map("n", "<leader>cf", "<cmd>Telescope changed_files<cr>") +map("n", "<leader>fk", "<cmd>lua require('telescope.builtin').keymaps()<cr>") +map("n", "<leader>fh", "<cmd>lua require('telescope.builtin').help_tags()<cr>") +--map( +-- "n", +-- "<leader>ft", +-- "<cmd>lua require('telescope.builtin').builtin(require('telescope.themes').get_dropdown({}))<cr>") + +-- maps.n["<leader>fF"] = { +-- function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end, +-- desc = "Search all files", +-- <cmd>Telescope find_files hidden=true<cr> +--map("n", "<leader>fh", "<cme>lua require('telecsope.builtin').file_files hidden=true<cr>") +map("n", "<leader>ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end) +--map("n", "<leader>fe", ":lua require('telescope.builtin').file_browser({cwd = '.'})<CR>") +map("n", "<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>") +map("n", "<leader>fb", "<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<cr>") +map("n", "<leader>fd", "<cmd>lua require('telescope.builtin').diagnostics()<cr>") +map("n", "<leader>fp", "<cmd>Telescope pickers<cr>") + +-- find notes +map("n", "<leader>fn", [[<Cmd>lua require'plugins.telescope'.find_notes()<CR>]]) +-- search notes +map("n", "<leader>fgn", [[<Cmd>lua require'plugins.telescope'.grep_notes()<CR>]]) +-- Find files in config dirs +map("n", "<leader>f.", [[<Cmd>lua require'plugins.telescope'.find_configs()<CR>]]) +--map("n", "<leader>fz", ":FZF<CR>") +--map("t", [[<Esc><Esc>]], [[<C-\><C-N>]]) +--map("n", "ff", ":NvimTreeToggle<CR>", {}) +map("n", "<leader>f", ":NvimTreeToggle<CR>", {}) +-- This <Esc><Esc> avoids crashing fzf menu running in TERMINAL MODE (:q if you do) +-- Find files in config dirs +--key_map("n", "<leader>e", ":lua require('plugins.telescope').find_configs()<CR>", opts) +--map("n", "<leader>f.", "<cmd>lua require('plugins.telescope').find_configs({})<cr>") +--map("n", "<leader>ft", "<cmd>lua require('plugins.telescope').file_explorer({})<cr>") +--map("n", "<leader>fd", "<cmd>lua require('plugins.telescope').find_notes({})<cr>") +map("n", "<leader>fm", "<cmd>lua require('telescope').extensions.media_files.media_files({})<cr>") +-- registers picker +map("n", "<leader>r", "<cmd>lua require('telescope.builtin').registers({})<CR>") +-- find files including gitignored +--keymap( +-- "n", +-- "<leader>fg", +-- "<cmd>lua require('telescope.builtin').find_files({find_command={'fd','--no-ignore-vcs'}})<CR>") +-- open available commands & run it +--map("n", "<leader>fc", "<cmd>lua require('telescope.builtin').commands({results_title='Commands Results'})<CR>") + +-------------- Autopairs -------------- +Toggle_autopairs = function() + local ok, autopairs = pcall(require, "nvim-autopairs") + if ok then + if autopairs.state.disabled then + autopairs.enable() + print("autopairs on") + else + autopairs.disable() + print("autopairs off") + end + else + print("autopairs not available") + end +end +map("n", "<leader>ww", ":lua Toggle_autopairs()<CR>", term_opts) + +-------------- Functions -------------- +-- Toggle transparency +vim.cmd([[ + let t:is_transparent = 0 + function! Toggle_transparent_background() + if t:is_transparent == 0 + hi Normal guibg=#111111 ctermbg=black + let t:is_transparent = 1 + else + hi Normal guibg=NONE ctermbg=NONE + let t:is_transparent = 0 + endif + endfunction + nnoremap <leader>tb :call Toggle_transparent_background()<CR> +]]) +--keymap('n', '<leader>tb', ':Toggle_transparent_background<CR>') + +-- Toggle zoom +vim.cmd([[ + function! s:ZoomToggle() abort + if exists('t:zoomed') && t:zoomed + execute t:zoom_winrestcmd + let t:zoomed = 0 + else + let t:zoom_winrestcmd = winrestcmd() + resize + vertical resize + let t:zoomed = 1 + endif + endfunction + command! ZoomToggle call s:ZoomToggle() + ]]) +map("n", "<leader>z", ":ZoomToggle<CR>") +-- "Zoom" a split window into a tab and/or close it +--keymap('n', '<Leader>,', ':tabnew %<CR>') +--keymap('n', '<Leader>.', ':tabclose<CR>') + +-- Open last closed buffer +vim.cmd([[ + function! OpenLastClosed() + let last_buf = bufname('#') + if empty(last_buf) + echo "No recently closed buffer found" + return + endif + let result = input("Open ". last_buf . " in (n)ormal (v)split, (t)ab or (s)plit ? (n/v/t/s) : ") + if empty(result) || (result !=# 'v' && result !=# 't' && result !=# 's' && result !=# 'n') + return + endif + if result ==# 't' + execute 'tabnew' + elseif result ==# 'v' + execute "vsplit" + elseif result ==# 's' + execute "split" + endif + execute 'b ' . last_buf + endfunction + ]]) +map("n", "<C-t>", ":call OpenLastClosed() <CR>") + +-- Tabularize +vim.cmd([[ + vnoremap <expr> <Leader>mm ':Tabularize /^\s*\S.*\zs' . split(&commentstring, '%s')[0] . "<CR>" + nnoremap <expr> <Leader>mm ':Tabularize /^\s*\S.*\zs' . split(&commentstring, '%s')[0] . "<CR>" + "nnoremap <leader>i mc40A <esc>080lDgelD`cP + "vnoremap <leader>ii mc0f-20i<Space><Esc>`cdt=j +]]) + +vim.cmd([[ + " Start interactive EasyAlign in visual mode (e.g. vipga) + xmap ga <Plug>(EasyAlign) + " Start interactive EasyAlign for a motion/text object (e.g. gaip) + nmap ga <Plug>(EasyAlign) + if !exists('g:easy_align_delimiters') + let g:easy_align_delimiters = {} + endif + let g:easy_align_delimiters['--'] = { 'pattern': '--', 'ignore_groups': ['String'] } + nnoremap <F1> 21A <Esc>d21\| + imap <F1> <Esc><F1>a +]]) +--:'<,'>EasyAlign /--/ +--EasyAlign /--/ +--:'<,'>Tabularize /-- + +--map("n", "<leader>,", ":hide<CR>") +--map("n", "<leader>.", ":unhide<CR>") + +--" Clean trailing whitespace +--nnoremap <leader>ww mz:%s/\s\+$//<cr>:let @/=''<cr>`z + +-- Save with root permission (not working for now) +--vim.api.nvim_create_user_command('W', 'w !sudo tee > /dev/null %', {}) + +-- Copy and Paste with <C-c> and <C-v> +--keymap('n', '<expr> p', (v:register =--= '"' && &clipboard =~ 'unnamed' ? '"*p' : '"' . v:register . 'p')'') +-- Use command :Vb for Visual Block or <C-q> since <C-v> is used for Copy +--command! Vb normal! <C-v> +-- Map <w!!> to save/edit a root permission/read-only file, only works in +-- traditional vim and not neovim +--keymap('c', 'w!! %!sudo tee > /dev/null') +--" Copying text to the system clipboard. +--" +--" For some reason Vim no longer wants to talk to the OS X pasteboard through "*. +--" Computers are bullshit. +--function! g:FuckingCopyTheTextPlease() +-- let old_z = @z +-- normal! gv"zy +-- call system('pbcopy', @z) +-- let @z = old_z +--endfunction +--noremap <leader>p :silent! set paste<CR>"*p:set nopaste<CR> +--" noremap <leader>p mz:r!pbpaste<cr>`z +--vnoremap <leader>y :<c-u>call g:FuckingCopyTheTextPlease()<cr> + +--" Indent/dedent/autoindent what you just pasted. +--nnoremap <lt>> V`]< +--nnoremap ><lt> V`]> +--nnoremap =- V`]= + +--" Keep the cursor in place while joining lines +--nnoremap J mzJ`z + +--" Toggle [i]nvisible characters +--nnoremap <leader>i :set list!<cr> +-- +--" Unfuck my screen +--nnoremap U :syntax sync fromstart<cr>:redraw!<cr> + +--" Ranger +--nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr> +--nnoremap <leader>R :silent !ranger<cr>:redraw!<cr> +-- +--" Insert Mode Completion {{{ +-- +--inoremap <c-f> <c-x><c-f> +--inoremap <c-]> <c-x><c-]> +--inoremap <c-l> <c-x><c-l> +---- Open the current file in the default program (on Mac this should just be just `open`) +--keymap('n', '<leader>x', ':!xdg-open %<cr><cr>') + +map("n", "<leader>fF", "<cmd>lua require('telescope.builtin').find_files()<cr>") +--keymap("n", "<leader>ff", "<cmd>lua require('telescope.builtin').find_files cwd=..()<cr>") +--keymap('n', '<leader>k', ':nohlsearch<CR>') +-- +--"This unsets the "last search pattern" register by hitting return +vim.cmd([[ + nnoremap <silent> <CR> :noh<CR><CR> +]]) + +--keymap('n', '<leader>Q', ':bufdo bdelete<CR>') +-- +---- Allow gf to open non-existent files +--keymap('', 'gf', ':edit <cfile><CR>') +-- +---- Reselect visual selection after indenting +--keymap('v', '<', '<gv') +--keymap('v', '>', '>gv') +-- +---- Maintain the cursor position when yanking a visual selection +---- http://ddrscott.github.io/blog/2016/yank-without-jank/ +--keymap('v', 'y', 'myy`y') +--keymap('v', 'Y', 'myY`y') +--keymap("n", "<C-q>", ":q<cr>") +--keymap("n", "<C-M-q>", ":qa!<cr>") + +--" Sort lines +--nnoremap <leader>s vip:!sort<cr> +--vnoremap <leader>s :!sort<cr> +-- +--" Tabs +--nnoremap <leader>( :tabprev<cr> +--nnoremap <leader>) :tabnext<cr> +-- +--" Wrap +--nnoremap <leader>W :set wrap!<cr> + +--set foldlevelstart=0 +-- +--" Space to toggle folds. +--nnoremap <Space> za +--vnoremap <Space> za +--" Make zO recursively open whatever fold we're in, even if it's partially open. +--nnoremap zO zczO + +-- Packer +--maps.n["<leader>pc"] = { "<cmd>PackerCompile<cr>", desc = "Packer Compile" } +--maps.n["<leader>pi"] = { "<cmd>PackerInstall<cr>", desc = "Packer Install" } +--maps.n["<leader>ps"] = { "<cmd>PackerSync<cr>", desc = "Packer Sync" } +--maps.n["<leader>pS"] = { "<cmd>PackerStatus<cr>", desc = "Packer Status" } +--maps.n["<leader>pu"] = { "<cmd>PackerUpdate<cr>", desc = "Packer Update" } +-- NeoTree +--if is_available "neo-tree.nvim" then +-- keymaps.n["<leader>e"] = { "<cmd>Neotree toggle<cr>", desc = "Toggle Explorer" } +-- keymaps.n["<leader>o"] = { "<cmd>Neotree focus<cr>", desc = "Focus Explorer" } +--end +-- Alpha +--if is_available "alpha-nvim" then maps.n["<leader>d"] = { "<cmd>Alpha<cr>", desc = "Alpha Dashboard" } end + +-- Package Manager +-- TODO: v2 rework these key bindings to be more general +--if is_available "mason.nvim" then maps.n["<leader>lI"] = { "<cmd>Mason<cr>", desc = "LSP installer" } end +-- Telescope +--if is_available "telescope.nvim" then +-- maps.n["<leader>fw"] = { function() require("telescope.builtin").live_grep() end, desc = "Search words" } +-- maps.n["<leader>fW"] = { +-- function() +-- require("telescope.builtin").live_grep { +-- additional_args = function(args) return vim.list_extend(args, { "--hidden", "--no-ignore" }) end, +-- } +-- end, +-- desc = "Search words in all files", +-- } +-- maps.n["<leader>gt"] = { function() require("telescope.builtin").git_status() end, desc = "Git status" } +-- maps.n["<leader>gb"] = { function() require("telescope.builtin").git_branches() end, desc = "Git branches" } +-- maps.n["<leader>gc"] = { function() require("telescope.builtin").git_commits() end, desc = "Git commits" } +-- maps.n["<leader>ff"] = { function() require("telescope.builtin").find_files() end, desc = "Search files" } +-- maps.n["<leader>fF"] = { +-- function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end, +-- desc = "Search all files", +-- } +-- maps.n["<leader>fb"] = { function() require("telescope.builtin").buffers() end, desc = "Search buffers" } +-- maps.n["<leader>fh"] = { function() require("telescope.builtin").help_tags() end, desc = "Search help" } +-- maps.n["<leader>fm"] = { function() require("telescope.builtin").marks() end, desc = "Search marks" } +-- maps.n["<leader>fo"] = { function() require("telescope.builtin").oldfiles() end, desc = "Search history" } +-- maps.n["<leader>fc"] = +-- { function() require("telescope.builtin").grep_string() end, desc = "Search for word under cursor" } +-- maps.n["<leader>sb"] = { function() require("telescope.builtin").git_branches() end, desc = "Git branches" } +-- maps.n["<leader>sh"] = { function() require("telescope.builtin").help_tags() end, desc = "Search help" } +-- maps.n["<leader>sm"] = { function() require("telescope.builtin").man_pages() end, desc = "Search man" } +-- maps.n["<leader>sn"] = +-- { function() require("telescope").extensions.notify.notify() end, desc = "Search notifications" } +-- maps.n["<leader>sr"] = { function() require("telescope.builtin").registers() end, desc = "Search registers" } +-- maps.n["<leader>sk"] = { function() require("telescope.builtin").keymaps() end, desc = "Search keymaps" } +-- maps.n["<leader>sc"] = { function() require("telescope.builtin").commands() end, desc = "Search commands" } +-- maps.n["<leader>ls"] = { +-- function() +-- local aerial_avail, _ = pcall(require, "aerial") +-- if aerial_avail then +-- require("telescope").extensions.aerial.aerial() +-- else +-- require("telescope.builtin").lsp_document_symbols() +-- end +-- end, +-- desc = "Search symbols", +-- } +-- maps.n["<leader>lR"] = { function() require("telescope.builtin").lsp_references() end, desc = "Search references" } +--end +-- +---- Terminal +--if is_available "toggleterm.nvim" then +-- local toggle_term_cmd = astronvim.toggle_term_cmd +-- maps.n["<C-\\>"] = { "<cmd>ToggleTerm<cr>", desc = "Toggle terminal" } +-- maps.n["<leader>gg"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" } +-- maps.n["<leader>tn"] = { function() toggle_term_cmd "node" end, desc = "ToggleTerm node" } +-- maps.n["<leader>tu"] = { function() toggle_term_cmd "ncdu" end, desc = "ToggleTerm NCDU" } +-- maps.n["<leader>tt"] = { function() toggle_term_cmd "htop" end, desc = "ToggleTerm htop" } +-- maps.n["<leader>tp"] = { function() toggle_term_cmd "python" end, desc = "ToggleTerm python" } +-- maps.n["<leader>tl"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" } +-- maps.n["<leader>tf"] = { "<cmd>ToggleTerm direction=float<cr>", desc = "ToggleTerm float" } +-- maps.n["<leader>th"] = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", desc = "ToggleTerm horizontal split" } +-- maps.n["<leader>tv"] = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", desc = "ToggleTerm vertical split" } +--end +-- +---- Stay in indent mode +--maps.v["<"] = { "<gv", desc = "unindent line" } +--maps.v[">"] = { ">gv", desc = "indent line" } +-- +---- Improved Terminal Mappings +--maps.t["<esc>"] = { "<C-\\><C-n>", desc = "Terminal normal mode" } +--maps.t["jk"] = { "<C-\\><C-n>", desc = "Terminal normal mode" } +--maps.t["<C-h>"] = { "<c-\\><c-n><c-w>h", desc = "Terminal left window navigation" } +--maps.t["<C-j>"] = { "<c-\\><c-n><c-w>j", desc = "Terminal down window navigation" } +--maps.t["<C-k>"] = { "<c-\\><c-n><c-w>k", desc = "Terminal up window navigation" } +--maps.t["<C-l>"] = { "<c-\\><c-n><c-w>l", desc = "Terminal right window naviation" } +-- LSP Installer +--if is_available "mason-lspconfig.nvim" then maps.n["<leader>li"] = { "<cmd>LspInfo<cr>", desc = "LSP information" } end + +-- ALE: toggle _ALE activity +--keymap('n', '<leader>a',[[:ALEToggle<CR>]]) + +--keymap('n', '<Leader>cd', ':call fzf#run({'source': 'fd -t d -H . ~', 'sink': 'cd'})<CR>') +-- ":lua require('neogen').generate()<CR>") +--keymap("n", "<leader>ww", ":set wrap!<CR>") +-- diff --git a/.config/nvim/lua/user/mods.lua b/.config/nvim/lua/user/mods.lua new file mode 100644 index 0000000..ec77173 --- /dev/null +++ b/.config/nvim/lua/user/mods.lua @@ -0,0 +1,138 @@ +--vim.cmd([[ +-- function RandomColorScheme() +-- let mycolors = split(globpath(&rtp,"**/colors/*.vim"),"\n") +-- exe 'so ' . mycolors[localtime() % len(mycolors)] +-- unlet mycolors +-- endfunction +-- +-- call RandomColorScheme() +-- +-- :command NewColor call RandomColorScheme() +--]]) + +--vim.cmd([[ +-- function RandomColorSchemeMyPicks() +-- let mypicks = ["pyte", "fokus", "github", "peachpuff", "morning", "simple256", "xcode", "gruvbox"] +-- let mypick = mypicks[localtime() % len(mypicks)] +-- echom mypick +-- execute 'colo' mypick +-- endfunction +-- +-- command NewColor call RandomColorSchemeMyPicks() +-- +-- let s:use_gui = exists('g:neovide') || has('gui_running') || (has('termguicolors') && &termguicolors) +-- if (s:use_gui) +-- call RandomColorSchemeMyPicks() +-- endif +--]]) + +vim.cmd([[ + let g:fzf_history_dir = '~/.local/share/fzf-history' + map <leader>z :FZF<CR> + map <leader>a :Files<CR> + map <leader>l :Lines<CR> + map <leader>L :BLines<CR> + map <leader>B :Buffers<CR> + map <leader>h :History:<CR> + nnoremap <leader>g :Rg<CR> + "nnoremap <leader>t :Tags<CR> + nnoremap <leader>m :Marks<CR> + " This is the default extra key bindings + let g:fzf_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-y': 'vsplit' } + let g:fzf_tags_command = 'ctags -R' + " Border color + let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } } + let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline' + let $FZF_DEFAULT_COMMAND="rg --files --hidden" + " Customize fzf colors to match your color scheme + let g:fzf_colors = + \ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } + " Get Files + command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0) + " Get text in files with Rg + command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1, + \ fzf#vim#with_preview(), <bang>0) + " Ripgrep advanced + function! RipgrepFzf(query, fullscreen) + let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true' + let initial_command = printf(command_fmt, shellescape(a:query)) + let reload_command = printf(command_fmt, '{q}') + let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} + call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) + endfunction + command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0) + " Git grep + command! -bang -nargs=* GGrep + \ call fzf#vim#grep( + \ 'git grep --line-number '.shellescape(<q-args>), 0, + \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0) + command! -bang FM call fzf#run(fzf#wrap({'source': 'cat ~/.fzf-marks | sed "s/.*: \(.*\)$/\1/" | sed "s#~#${HOME}#"', 'sink': 'lcd'}, <bang>0)) +]]) + +vim.cmd([[ + " Enable mouse scrollback + set mouse=a + tnoremap <Esc> <C-\><C-n> + tnoremap <c-b> <c-\><c-n> + function! ClearTerminal() + set scrollback=1 + let &g:scrollback=1 + echo &scrollback + call feedkeys("\i") + call feedkeys("clear\<CR>") + call feedkeys("\<C-\>\<C-n>") + call feedkeys("\i") + sleep 100m + let &scrollback=s:scroll_value + endfunction +]]) + +vim.cmd([[ + " :Rename {newname} + function! RenameFile() + let old_name = expand('%') + let new_name = input('New file name: ', expand('%'), 'file') + if new_name != '' && new_name != old_name + exec ':saveas ' . new_name + exec ':silent !rm ' . old_name + redraw! + endif + endfunction + map <leader>re :call RenameFile()<cr> +]]) + +--vim.cmd([[ +-- " Markdown Settings +-- autocmd BufNewFile,BufReadPost *.md set filetype=markdown +-- let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'sql', 'pug'] +-- let g:markdown_minlines = 100 +-- let g:instant_markdown_autostart = 0 +--]]) +-- +--vim.cmd([[ +-- " On The Fly Table mode +-- function! s:isAtStartOfLine(mapping) +-- let text_before_cursor = getline('.')[0 : col('.')-1] +-- let mapping_pattern = '\V' . escape(a:mapping, '\') +-- let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\') +-- return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$') +-- endfunction +--]]) diff --git a/.config/nvim/lua/user/opts.lua b/.config/nvim/lua/user/opts.lua new file mode 100644 index 0000000..6da4234 --- /dev/null +++ b/.config/nvim/lua/user/opts.lua @@ -0,0 +1,237 @@ +--[[ opts.lua ]] + +vim.cmd([[ + "filetype plugin indent on " Load indent files, to automatically do language-dependent indenting. + "autocmd BufEnter * :syntax sync fromstart + "syntax enable + let g:clipbrdDefaultReg = '+' + "set nocompatible + "autocmd FileType lua set comments=s1:---,m:--,ex:-- + nnoremap @ <cmd>execute "noautocmd norm! " . v:count1 . "@" . getcharstr()<cr> " Fast macros without lazyredraw + xnoremap @ :<C-U>execute "noautocmd '<,'>norm! " . v:count1 . "@" . getcharstr()<cr> +]]) + +-- Environment +--vim.opt.shell = "zsh" -- +vim.o.shell = "/bin/zsh" +vim.scriptencoding = "utf-8" -- +vim.opt.encoding = "utf-8" -- +vim.opt.fileencoding = "utf-8" -- +vim.g.python3_host_prog = "/usr/bin/python3" -- +vim.g.loaded_python3_provider = 1 -- +vim.g.sh_noisk = 1 -- iskeyword word boundaries when editing a 'sh' file +vim.o.autochdir = true +--vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,resize,winpos,terminal,globals" -- + +-- Colors +vim.opt.termguicolors = true + +-- Behaviour +vim.opt.clipboard:append({ "unnamedplus" }) -- Install xclip or this will slowdown startup +vim.opt.backspace = { "start", "eol", "indent" } -- Make backspace work as you would expect. +vim.opt.hidden = true -- Switch between buffers without having to save first. +vim.opt.splitbelow = true -- make split put the new buffer below the current buffer +vim.opt.splitright = true -- make vsplit put the new buffer on the right of the current buffer +vim.opt.scrolloff = 8 -- +vim.opt.sidescrolloff = 8 -- how many lines to scroll when using the scrollbar +vim.opt.autoread = true -- reload files if changed externally +vim.opt.display = "lastline" -- Show as much as possible of the last line. +vim.opt.inccommand = "split" -- +vim.opt.ttyfast = true -- Faster redrawing. +--vim.opt.lazyredraw = true -- Only redraw when necessary +vim.opt.keywordprg = ":help" -- :help options +vim.opt.ruler = true -- +vim.opt.errorbells = false -- +vim.opt.list = true -- Show non-printable characters. +vim.opt.showmatch = true -- +vim.opt.matchtime = 3 -- +vim.opt.showbreak = "↪ " -- +vim.opt.linebreak = true -- +vim.opt.exrc = true -- +--vim.opt.autochdir = true -- or use this to use <:e> to create a file in current directory +vim.opt.autoread = true -- if a file is changed outside of vim, automatically reload it without asking +--vim.opt.notimeout = true -- Timeout on keycodes and not mappings +vim.opt.ttimeout = true -- Makes terminal vim work sanely +vim.opt.ttimeoutlen = 10 -- +--vim.opt.timeoutlen = 100 -- time to wait for a mapped sequence to complete (in milliseconds) +--vim.cmd([[set diffopt = vertical = true]]) -- diffs are shown side-by-side not above/below + +-- Indent/tab +vim.opt.breakindent = true -- +vim.opt.autoindent = true -- Indent according to previous line. +vim.opt.copyindent = true -- Copy indent from the previous line +vim.opt.smarttab = false -- +vim.opt.tabstop = 2 -- +vim.opt.expandtab = true -- Indent according to previous line. +--vim.opt.expandtab = true -- Use spaces instead of tabs. +vim.opt.softtabstop = 2 -- Tab key indents by 2 spaces. +vim.opt.shiftwidth = 2 -- >> indents by 2 spaces. +vim.opt.shiftround = true -- >> indents to next multiple of 'shiftwidth'. +vim.opt.smartindent = true -- smart indent + +-- Column/statusline/Cl +vim.opt.number = true -- +vim.opt.title = true -- +--vim.opt.colorcolumn = "+1" -- +vim.opt.signcolumn = "yes:1" -- always show the sign column +--vim.opt.signcolumn = "yes:" .. vim.o.numberwidth +--vim.opt.signcolumn = "number" +--vim.opt.signcolumn = "no" -- +vim.opt.laststatus = 3 -- " Always show statusline. +vim.opt.showmode = true -- Show current mode in command-line, example: -- INSERT -- mode +vim.opt.showcmd = true -- Show the command in the status bar +vim.opt.cmdheight = 1 -- +--vim.opt.cmdheight = 0 -- +vim.opt.report = 0 -- Always report changed lines. +--local autocmd = vim.api.nvim_create_autocmd +--autocmd("bufenter", { +-- pattern = "*", +-- callback = function() +-- if vim.bo.ft ~= "terminal" then +-- vim.opt.statusline = "%!v:lua.require'ui.statusline'.run()" +-- else +-- vim.opt.statusline = "%#normal# " +-- end +-- end, +--}) +---- With vertical splits, the statusline would still show up at the +---- bottom of the split. A quick fix is to just set the statusline +---- to empty whitespace (it can't be an empty string because then +---- it'll get replaced by the default stline). +--vim.opt.stl = " " + +-- Backup/undo +vim.opt.backup = false -- +--vim.opt.noswapfile = true -- +--vim.opt.undofile = true -- +vim.opt.backupskip = { "/tmp/*", "/private/tmp/*" } -- + +-- Format +vim.opt.textwidth = 80 -- +vim.cmd([[let &t_Cs = "\e[4:3m"]]) -- Undercurl +vim.cmd([[let &t_Ce = "\e[4:0m"]]) -- +vim.opt.path:append({ "**" }) -- Finding files - Search down into subfolder +vim.cmd("set whichwrap+=<,>,[,],h,l") -- +vim.cmd([[set iskeyword+=-]]) -- +--vim.cmd([[set formatoptions-=cro]]) -- TODO: this doesn't seem to work +vim.opt.formatoptions = vim.opt.formatoptions + - "t" -- wrap with text width + + "c" -- wrap comments + + "r" -- insert comment after enter + - "o" -- insert comment after o/O + - "q" -- allow formatting of comments with gq + - "a" -- format paragraphs + + "n" -- recognized numbered lists + - "2" -- use indent of second line for paragraph + + "l" -- long lines are not broken + + "j" -- remove comment when joining lines +vim.opt.wrapscan = true -- " Searches wrap around end-of-file. +--vim.wo.number = true -- +--vim.opt.wrap = false -- No Wrap lines +--vim.opt.foldmethod = 'manual' -- +--vim.opt.foldmethod = "expr" -- +vim.opt.foldmethod = "manual" +vim.opt.foldlevel = 3 +vim.opt.confirm = true +vim.opt.shortmess:append("sI") +--vim.opt.shortmess = "a" +--vim.opt.shortmess = "sI" +--vim.o.shortmess = vim.o.shortmess:gsub('s', '') +vim.opt.fillchars = { + horiz = "━", + horizup = "┻", + horizdown = "┳", + vert = "┃", + vertleft = "┨", + vertright = "┣", + verthoriz = "╋", + fold = "⠀", + eob = " ", + diff = "┃", + msgsep = "‾", + foldopen = "▾", + foldsep = "│", + foldclose = "▸", +} +vim.opt.listchars = { tab = "▸ ", trail = "·" } -- +--vim.opt.fillchars:append({ eob = " " }) -- remove the ~ from end of buffer +vim.opt.modeline = true -- +vim.opt.modelines = 3 -- modelines (comments that set vim options on a per-file basis) +--vim.opt.modelineexpr = true +--vim.opt.nofoldenable = true -- turn folding off +--vim.opt.foldenable = false -- turn folding off +vim.o.showtabline = 2 + +-- Highlights +vim.opt.incsearch = true -- Highlight while searching with / or ?. +vim.opt.hlsearch = true -- Keep matches highlighted. +vim.opt.ignorecase = true -- ignore case in search patterns UNLESS /C or capital in search +vim.opt.smartcase = true -- smart case +vim.opt.synmaxcol = 200 -- Only highlight the first 200 columns. +vim.opt.winblend = 30 +--vim.opt.winblend = 5 +vim.opt.wildoptions = "pum" -- +--vim.opt.pumblend = 5 -- +vim.opt.pumblend = 12 -- +--vim.opt.pumblend=15 +vim.opt.pumheight = 10 -- pop up menu height + +-- Better Completion +vim.opt.complete = { ".", "w", "b", "u", "t" } -- +--vim.opt.completeopt = { "longest,menuone,preview" } -- +vim.opt.completeopt = {'menu', 'menuone', 'noselect'} +--vim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmp +--vim.opt.completeopt = { "menu", "menuone", "noselect" } -- + +-- Wildmenu completion -- +vim.opt.wildmenu = true -- +vim.opt.wildmode = { "list:longest" } -- +vim.opt.wildignore:append({ ".hg", ".git", ".svn" }) -- Version control +vim.opt.wildignore:append({ "*.aux", "*.out", "*.toc" }) -- LaTeX intermediate files +vim.opt.wildignore:append({ "*.jpg", "*.bmp", "*.gif", "*.png", "*.jpeg" }) -- binary images +vim.opt.wildignore:append({ "*.o", "*.obj", "*.exe", "*.dll", "*.manifest" }) -- compiled object files +vim.opt.wildignore:append({ "*.spl" }) -- compiled spelling word lists +vim.opt.wildignore:append({ "*.sw?" }) -- Vim swap files +vim.opt.wildignore:append({ "*.DS_Store" }) -- OSX bullshit +vim.opt.wildignore:append({ "*.luac" }) -- Lua byte code +vim.opt.wildignore:append({ "migrations" }) -- Django migrations +vim.opt.wildignore:append({ "*.pyc" }) -- Python byte code +vim.opt.wildignore:append({ "*.orig" }) -- Merge resolution files +vim.opt.wildignore:append({ "*/node_modules/*" }) -- + +-- Shada +vim.opt.shada = "!,'1000,f1,<1000,s100,:1000,/1000,h" + +-- Sessions +vim.opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" + +-- Cursorline +vim.cmd([[ " Only show cursorline in the current window and in normal mode + augroup cline + au! + au WinLeave,InsertEnter * set nocursorline + au WinEnter,InsertLeave * set cursorline + augroup END +]]) +vim.opt.cursorline = true -- +vim.opt.guicursor = "i:ver100,r:hor100" -- + +-- Trailing whitespace +vim.cmd([[ " Only show in insert mode + augroup trailing + au! + au InsertEnter * :set listchars-=trail:⌴ + au InsertLeave * :set listchars+=trail:⌴ + augroup END +]]) + +-- Line Return +vim.cmd([[ " Return to the same line when we reopen a file + augroup line_return + au! + au BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ execute 'normal! g`"zvzz' | + \ endif + augroup END +]]) diff --git a/.config/nvim/lua/user/pack.lua b/.config/nvim/lua/user/pack.lua new file mode 100644 index 0000000..ba309e6 --- /dev/null +++ b/.config/nvim/lua/user/pack.lua @@ -0,0 +1,404 @@ +local fn = vim.fn + +-- Automatically install packer +local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" +if fn.empty(fn.glob(install_path)) > 0 then + PACKER_BOOTSTRAP = fn.system({ + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + }) + print("Installing packer close and reopen Neovim...") + vim.cmd([[packadd packer.nvim]]) +end + +-- Autocommand that reloads neovim whenever you save the plugins.lua file +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost pack.lua source <afile> | PackerSync + augroup end +]]) + +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end + +-- Have packer use a popup window +packer.init({ + auto_reload_compiled = true, + display = { + open_fn = function() + return require("packer.util").float({ border = "rounded" }) + end, + }, +}) + +-- Install your plugins here +return packer.startup(function(use) + use("wbthomason/packer.nvim") -- Have packer manage itself + + use("lewis6991/impatient.nvim") + use("nvim-lua/plenary.nvim") -- Useful lua functions used ny lots of plugins + --use("jose-elias-alvarez/null-ls.nvim") + + -- lsp + use { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", + } + require("mason").setup() + local mason_lspconfig = require("mason-lspconfig") + mason_lspconfig.setup({ + ensure_installed = { + "pylsp", + "pyright", + "clangd", + --"vim-language-server", + --"bash-language-server", + --"lua-language-server", + "sumneko_lua", + } + }) + use({ "j-hui/fidget.nvim", + config = function() + require("fidget").setup() + end + }) + --use({ "folke/trouble.nvim", + -- config = function() + -- require("trouble").setup({ position = "right", }) + -- end + --}) + --use({ + --"folke/trouble.nvim", + --requires = "kyazdani42/nvim-web-devicons", + --config = function() + -- require("trouble").setup({ + -- --postion = "top", + -- postion = "right", + -- -- your configuration comes here + -- -- or leave it empty to use the default settings + -- -- refer to the configuration section below + -- }) + --end, + --}) + + --use({ + -- "https://git.sr.ht/~whynothugo/lsp_lines.nvim", -- See also: https://github.com/Maan2003/lsp_lines.nvim + -- config = function() + -- require("lsp_lines").setup() + + -- -- disable virtual_text since it's redundant due to lsp_lines. + -- vim.diagnostic.config({ + -- virtual_text = false, + -- }) + -- end, + --}) + use { "simrat39/symbols-outline.nvim", + config = function() + require("symbols-outline").setup({ + auto_close = true, + }) + end + } + use "antoinemadec/FixCursorHold.nvim" + use { "kosayoda/nvim-lightbulb", requires = { "antoinemadec/FixCursorHold.nvim" } } + --use("folke/lsp-colors.nvim") + use "mfussenegger/nvim-lint" + use "weilbith/nvim-code-action-menu" + use "simrat39/rust-tools.nvim" + use { "saecki/crates.nvim", + requires = { "nvim-lua/plenary.nvim" }, + config = function() + require("crates").setup() + end, + } + --use "lvimuser/lsp-inlayhints.nvim" -- rust-tools already provides this feature, but gopls doesn't + + -- null-ls + --use({ "jose-elias-alvarez/null-ls.nvim", + -- config = function() + -- require("null-ls").setup({ + -- sources = { + -- require("null-ls").builtins.diagnostics.checkmake, -- https://github.com/mrtazz/checkmake + -- } + -- }) + -- end + --}) + use({ + "jose-elias-alvarez/null-ls.nvim", + config = function() + require("null-ls").setup() + end, + requires = { "nvim-lua/plenary.nvim" }, + }) + use({ + "SmiteshP/nvim-navic", + requires = "neovim/nvim-lspconfig", + }) + + -- nvimlsp plugins + --use({ + -- "williamboman/mason.nvim", + -- config = function() + -- require("mason").setup() + -- require("mason-lspconfig").setup({ + -- ensure_installed = { "sumneko_lua", "clangd", "rust_analyzer" }, + -- }) + -- end, + --}) + --use("williamboman/mason.nvim") + --use("williamboman/mason-lspconfig.nvim") + --use("neovim/nvim-lspconfig") + --use("williamboman/nvim-lsp-installer") + --use("glepnir/lspsaga.nvim") + --use("nvim-lua/lsp-status.nvim") + --use({ + -- "glepnir/lspsaga.nvim", + -- branch = "main", + -- config = function() + -- local saga = require("lspsaga") + + -- saga.init_lsp_saga({ + -- -- your configuration + -- }) + -- end, + --}) + -- use("nvim-lua/popup.nvim") + --use("SmiteshP/nvim-gps") + -- autocomplete plugins + use("hrsh7th/nvim-cmp") + use("hrsh7th/cmp-nvim-lsp") + use("hrsh7th/cmp-buffer") + use("hrsh7th/cmp-path") + use("hrsh7th/cmp-cmdline") + use("petertriho/cmp-git") + use("tamago324/cmp-zsh") + use("f3fora/cmp-spell") + use("hrsh7th/cmp-calc") + use("saadparwaiz1/cmp_luasnip") + use("hrsh7th/cmp-nvim-lsp-signature-help") + use("onsails/lspkind-nvim") + + -- snippets + --use("L3MON4D3/LuaSnip") --snippet engine + use("L3MON4D3/LuaSnip") + use("rafamadriz/friendly-snippets") -- a bunch of snippets to use + --use("github/copilot.vim") + --use({ + --"zbirenbaum/copilot.lua", + --event = { "VimEnter" }, + --config = function() + --vim.defer_fn(function() + --require("plugins.copilot") + --end, 100) + --end, + --}) + --use({ + --"zbirenbaum/copilot-cmp", + --module = "copilot_cmp", + --}) + + -- treesitter plugins + use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }) --folding, jumping, refactoring... + use("nvim-treesitter/nvim-treesitter-refactor") + use("nvim-treesitter/nvim-treesitter-context") + --use({ + -- "danymat/neogen", + -- config = function() + -- require("neogen").setup({ snippet_engine = "luasnip" }) + -- end, + -- requires = "nvim-treesitter/nvim-treesitter", + --}) + --use({ "junegunn/fzf", run = ":call fzf#install()" }) + use('ibhagwan/fzf-lua') + -- telescope plugins + use("nvim-telescope/telescope.nvim") + use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) + use("tami5/sqlite.lua") + --use("nvim-telescope/telescope-frecency.nvim") + use("nvim-telescope/telescope-ui-select.nvim") + use("nvim-telescope/telescope-media-files.nvim") + use("nvim-telescope/telescope-file-browser.nvim") + -- search emoji and other symbols + use({ "nvim-telescope/telescope-symbols.nvim", after = "telescope.nvim" }) + use("axkirillov/telescope-changed-files") + --use({ + --"princejoogie/dir-telescope.nvim", + --requires = {"nvim-telescope/telescope.nvim"}, + --config = function() + -- require("dir-telescope").setup({ + -- hidden = true, + -- respect_gitignore = true, + -- }) + --end, + --}) + use("airblade/vim-rooter") + -- statusline plugins + --use("nvim-lualine/lualine.nvim") + --use({ + -- "nvim-lualine/lualine.nvim", + -- requires = { "kyazdani42/nvim-web-devicons", opt = true }, + --}) + --use({ + -- "folke/trouble.nvim", + -- requires = "kyazdani42/nvim-web-devicons", + -- config = function() + -- require("trouble").setup({ + -- -- your configuration comes here + -- -- or leave it empty to use the default settings + -- -- refer to the configuration section below + -- }) + -- end, + --}) + use("rebelot/heirline.nvim") + --use({ "akinsho/bufferline.nvim", tag = "v2.*", requires = "kyazdani42/nvim-web-devicons" }) + --use("itchyny/lightline.vim") + -- debug plugins + --use("puremourning/vimspector") + use("mfussenegger/nvim-dap") + use("rcarriga/nvim-dap-ui") + --use({ + -- "rcarriga/neotest", + -- requires = { + -- "nvim-lua/plenary.nvim", + -- "nvim-treesitter/nvim-treesitter", + -- "antoinemadec/FixCursorHold.nvim", + -- "rcarriga/neotest-python", + -- "rcarriga/neotest-vim-test", + -- "rcarriga/neotest-plenary", + -- "vim-test/vim-test", + -- }, + -- config = function() + -- require("plugins.neotest") + -- end, + --}) + --use("vim-test/vim-test") + --use({ + -- "rcarriga/vim-ultest", + -- requires = { "vim-test/vim-test" }, + -- run = ":UpdateRemotePlugins", + -- config = function() + -- require("plugins.ultest") + -- end, + --}) + -- UI + use("karb94/neoscroll.nvim") + use("folke/which-key.nvim") + use("MunifTanjim/prettier.nvim") -- Prettier plugin for Neovim's built-in LSP client + use("norcalli/nvim-colorizer.lua") + use("folke/zen-mode.nvim") + use("romainl/vim-cool") + --use("p00f/nvim-ts-rainbow") + --use("goolord/alpha-nvim") + --use("feline-nvim/feline.nvim") + --use({ "fgheng/winbar.nvim" }) + --use("vim-airline/vim-airline") + --use("kdheepak/tabline.nvim") + -- use({ + -- "kdheepak/tabline.nvim", + -- config = function() + -- require("tabline").setup({ enable = false }) + -- end, + -- requires = { "hoob3rt/lualine.nvim", "kyazdani42/nvim-web-devicons" }, + -- notification plugin + use("rcarriga/nvim-notify") + --use("lukas-reineke/indent-blankline.nvim") + use("kyazdani42/nvim-web-devicons") + -- Colorschemes + use("gruvbox-community/gruvbox") + use("srcery-colors/srcery-vim") + use("tomasr/molokai") + use("ayu-theme/ayu-vim") + --use("sjl/badwolf") + use("joshdick/onedark.vim") + use("everblush/everblush.nvim") + use("EdenEast/nightfox.nvim") + use("bluz71/vim-nightfly-guicolors") + --use({ "shaunsingh/oxocarbon.nvim", run = "./install.sh" }) + use("jacoborus/tender.vim") + use("sainnhe/sonokai") + use("NTBBloodbath/doom-one.nvim") + + -- Utilities + use("nathom/filetype.nvim") + use("christoomey/vim-tmux-navigator") + use("preservim/vimux") + use("myusuf3/numbers.vim") + use("windwp/nvim-autopairs") + use("lewis6991/gitsigns.nvim") + use("dinhhuy258/git.nvim") -- For git blame & browse + use("kyazdani42/nvim-tree.lua") + use("numToStr/Comment.nvim") + --use("akinsho/toggleterm.nvim") + --use("godlygeek/tabular") + --use("Vonr/align.nvim") + --use("junegunn/vim-easy-align") + --use("dstein64/vim-startuptime") + use("tweekmonster/startuptime.vim") + -- use("luukvbaal/stabilize.nvim") + --use("rhysd/clever-f.vim") + --use("ggandor/lightspeed.nvim") -- use 'cl' and 'cc' instead of 's' and 'S' respectively + --use("ggandor/leap.nvim") + use({ + "ggandor/leap.nvim", + config = function() + require('leap').add_default_mappings() + --require("leap").set_default_keymaps() + --vim.keymap.set('n', '-', '<Plug>(leap-forward)', {}) + --vim.keymap.set('n', '_', '<Plug>(leap-backward)', {}) + end, + }) + use({ "ggandor/flit.nvim", + config = function() + require("flit").setup() + end, + }) + + --use("Shatur/neovim-session-manager") + --use("rmagatti/auto-session") + --use("rmagatti/session-lens") + --use("ahmedkhalf/project.nvim") + --use("aserowy/tmux.nvim") + --use("wakatime/vim-wakatime") + --use("tpope/vim-eunuch") + -- Handy unix command inside Vim (Rename, Move etc.) + use({ "tpope/vim-eunuch", cmd = { "Rename", "Delete" } }) + --use("tpope/vim-fugitive") + --use("tpope/vim-surround") + --use("tpope/vim-obsession") + --use("tpope/vim-unimpaired") + --use("voldikss/vim-floaterm") + --use("vimpostor/vim-tpipeline") + --use({ + -- "vimwiki/vimwiki", + -- config = function() + -- vim.g.vimwiki_list = { + -- { + -- path = "~/", + -- syntax = "markdown", + -- ext = ".md", + -- }, + -- } + -- vim.g.vimwiki_ext2syntax = { + -- [".md"] = "markdown", + -- [".markdown"] = "markdown", + -- [".mdown"] = "markdown", + use({ + "iamcco/markdown-preview.nvim", + run = function() vim.fn["mkdp#util#install"]() end, + }) + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if PACKER_BOOTSTRAP then + require("packer").sync() + end +end) diff --git a/.config/nvim/lua/user/utils.lua b/.config/nvim/lua/user/utils.lua new file mode 100644 index 0000000..bfb5faa --- /dev/null +++ b/.config/nvim/lua/user/utils.lua @@ -0,0 +1,85 @@ +local fn = vim.fn + +local M = {} + +function M.executable(name) + if fn.executable(name) > 0 then + return true + end + + return false +end + +--- check whether a feature exists in Nvim +--- @feat: string +--- the feature name, like `nvim-0.7` or `unix`. +--- return: bool +M.has = function(feat) + if fn.has(feat) == 1 then + return true + end + + return false +end + +--- Create a dir if it does not exist +function M.may_create_dir(dir) + local res = fn.isdirectory(dir) + + if res == 0 then + fn.mkdir(dir, "p") + end +end + +M['unload_lua_namespace'] = function(prefix) + local prefix_with_dot = prefix .. '.' + for key, value in pairs(package.loaded) do + if key == prefix or key:sub(1, #prefix_with_dot) == prefix_with_dot then + package.loaded[key] = nil + end + end +end + +-- toggle cmp completion +vim.g.cmp_toggle_flag = false -- initialize +local normal_buftype = function() + return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" +end +M.toggle_completion = function() + local ok, cmp = pcall(require, "cmp") + if ok then + local next_cmp_toggle_flag = not vim.g.cmp_toggle_flag + if next_cmp_toggle_flag then + print("completion on") + else + print("completion off") + end + cmp.setup({ + enabled = function() + vim.g.cmp_toggle_flag = next_cmp_toggle_flag + if next_cmp_toggle_flag then + return normal_buftype + else + return next_cmp_toggle_flag + end + end, + }) + else + print("completion not available") + end +end + +function M.get_nvim_version() + local actual_ver = vim.version() + + local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch) + return nvim_ver_str +end + +function M.add_pack(name) + local status, error = pcall(vim.cmd, "packadd " .. name) + + return status +end + +return M diff --git a/.config/nvim/snippets/boilerplate.lua b/.config/nvim/snippets/boilerplate.lua new file mode 100644 index 0000000..04e973a --- /dev/null +++ b/.config/nvim/snippets/boilerplate.lua @@ -0,0 +1,75 @@ +local ls = require("luasnip") --{{{ +local s = ls.s +local i = ls.i +local t = ls.t + +local d = ls.dynamic_node +local c = ls.choice_node +local f = ls.function_node +local sn = ls.snippet_node + +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep + +local snippets, autosnippets = {}, {} --}}} + +local group = vim.api.nvim_create_augroup("Lua Snippets", { clear = true }) +local file_pattern = "*.lua" + +local function cs(trigger, nodes, opts) --{{{ + local snippet = s(trigger, nodes) + local target_table = snippets + + local pattern = file_pattern + local keymaps = {} + + if opts ~= nil then + -- check for custom pattern + if opts.pattern then + pattern = opts.pattern + end + + -- if opts is a string + if type(opts) == "string" then + if opts == "auto" then + target_table = autosnippets + else + table.insert(keymaps, { "i", opts }) + end + end + + -- if opts is a table + if opts ~= nil and type(opts) == "table" then + for _, keymap in ipairs(opts) do + if type(keymap) == "string" then + table.insert(keymaps, { "i", keymap }) + else + table.insert(keymaps, keymap) + end + end + end + + -- set autocmd for each keymap + if opts ~= "auto" then + for _, keymap in ipairs(keymaps) do + vim.api.nvim_create_autocmd("BufEnter", { + pattern = pattern, + group = group, + callback = function() + vim.keymap.set(keymap[1], keymap[2], function() + ls.snip_expand(snippet) + end, { noremap = true, silent = true, buffer = true }) + end, + }) + end + end + end + + table.insert(target_table, snippet) -- insert snippet into appropriate table +end --}}} + +-- Start Refactoring -- + +-- End Refactoring -- + +return snippets, autosnippets diff --git a/.config/nvim/snippets/lua.lua b/.config/nvim/snippets/lua.lua new file mode 100644 index 0000000..523d2f4 --- /dev/null +++ b/.config/nvim/snippets/lua.lua @@ -0,0 +1,264 @@ + +local ls = require("luasnip") --{{{ +local s = ls.s --> snippet +local i = ls.i --> insert node +local t = ls.t --> text node + +local d = ls.dynamic_node +local c = ls.choice_node --> takes in a pos as first arg and a table of nodes +local f = ls.function_node +local sn = ls.snippet_node + +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep + +local snippets, autosnippets = {}, {} --}}} + +local group = vim.api.nvim_create_augroup("Lua Snippets", { clear = true }) +local file_pattern = "*.lua" + +local function cs(trigger, nodes, opts) --{{{ + local snippet = s(trigger, nodes) + local target_table = snippets + + local pattern = file_pattern + local keymaps = {} + + if opts ~= nil then + -- check for custom pattern + if opts.pattern then + pattern = opts.pattern + end + + -- if opts is a string + if type(opts) == "string" then + if opts == "auto" then + target_table = autosnippets + else + table.insert(keymaps, { "i", opts }) + end + end + + -- if opts is a table + if opts ~= nil and type(opts) == "table" then + for _, keymap in ipairs(opts) do + if type(keymap) == "string" then + table.insert(keymaps, { "i", keymap }) + else + table.insert(keymaps, keymap) + end + end + end + + -- set autocmd for each keymap + if opts ~= "auto" then + for _, keymap in ipairs(keymaps) do + vim.api.nvim_create_autocmd("BufEnter", { + pattern = pattern, + group = group, + callback = function() + vim.keymap.set(keymap[1], keymap[2], function() + ls.snip_expand(snippet) + end, { noremap = true, silent = true, buffer = true }) + end, + }) + end + end + end + + table.insert(target_table, snippet) -- insert snippet into appropriate table +end --}}} + +-- Start Refactoring -- + +cs("CMD", { -- [CMD] multiline vim.cmd{{{ + t({ "vim.cmd[[", " " }), + i(1, ""), + t({ "", "]]" }), +}) --}}} +cs("cmd", fmt("vim.cmd[[{}]]", { i(1, "") })) -- single line vim.cmd +cs({ -- github import for packer{{{ + trig = "https://github%.com/([%w-%._]+)/([%w-%._]+)!", + regTrig = true, + hidden = true, +}, { + t([[use "]]), + f(function(_, snip) + return snip.captures[1] + end), + t("/"), + f(function(_, snip) + return snip.captures[2] + end), + t({ [["]], "" }), + i(1, ""), +}, "auto") --}}} + +cs( -- {regexSnippet} LuaSnippet{{{ + "regexSnippet", + fmt( + [=[ +cs( -- {} +{{ trig = "{}", regTrig = true, hidden = true }}, fmt([[ +{} +]], {{ + {} +}})) + ]=], + { + i(1, "Description"), + i(2, ""), + i(3, ""), + i(4, ""), + } + ), + { pattern = "*/snippets/*.lua", "<C-d>" } +) --}}} +cs( -- [luaSnippet] LuaSnippet{{{ + "luaSnippet", + fmt( + [=[ +cs("{}", fmt( -- {} +[[ +{} +]], {{ + {} + }}){}) + ]=], + { + i(1, ""), + i(2, "Description"), + i(3, ""), + i(4, ""), + c(5, { + t(""), + fmt([[, "{}"]], { i(1, "keymap") }), + fmt([[, {{ pattern = "{}", {} }}]], { i(1, "*/snippets/*.lua"), i(2, "keymap") }), + }), + } + ), + { pattern = "*/snippets/*.lua", "jcs" } +) --}}} + +cs( -- choice_node_snippet luaSnip choice node{{{ + "choice_node_snippet", + fmt( + [[ +c({}, {{ {} }}), +]], + { + i(1, ""), + i(2, ""), + } + ), + { pattern = "*/snippets/*.lua", "jcn" } +) --}}} + +cs( -- [function] Lua function snippet{{{ + "function", + fmt( + [[ +function {}({}) + {} +end +]], + { + i(1, ""), + i(2, ""), + i(3, ""), + } + ), + "jff" +) --}}} +cs( -- [local_function] Lua function snippet{{{ + "local_function", + fmt( + [[ +local function {}({}) + {} +end +]], + { + i(1, ""), + i(2, ""), + i(3, ""), + } + ), + "jlf" +) --}}} +cs( -- [local] Lua local variable snippet{{{ + "local", + fmt( + [[ +local {} = {} + ]], + { i(1, ""), i(2, "") } + ), + "jk" +) --}}} +-- Tutorial Snippets go here -- +local myFirstSnippet = s("myFirstSnippet", { + t("Hi! This is my first snippet in Luasnip "), + i(1, "placeholder"), + t({"", "this is another text node", ""}), + i(2, "put here"), +}) +table.insert(snippets, myFirstSnippet) + + + +local mySecondSnippet = s( + "mySecondSnippet", + fmt( + [[ + local {} = function({}) + {} {{ im in a curly braces }} + end {} + ]], + { + i(1, "myVar"), + c(2, { t(""), i(1, "myArg") }), + i(3, "-- TODO: something"), + i(4, "-- nice") + } + ) +) +table.insert(snippets, mySecondSnippet) + +local myFirstAutoSnippet = s("automatic", { t("This was auto triggered") }) +table.insert(autosnippets, myFirstAutoSnippet) + +local mySecondAutoSnippet = s({ trig = "digit(%d)(%d)", regTrig = true }, { + f(function(_, snip) + return snip.captures[1] .. " + " + end), + f(function(_, snip) + return snip.captures[2] + end), +}) +table.insert(autosnippets, mySecondAutoSnippet) + + + + + + + + +-- End Refactoring -- + +return snippets, autosnippets + + + + + + + + + + + + + + diff --git a/.config/nvim/snippets/markdown.lua b/.config/nvim/snippets/markdown.lua new file mode 100644 index 0000000..d0d1487 --- /dev/null +++ b/.config/nvim/snippets/markdown.lua @@ -0,0 +1,58 @@ +local ls = require("luasnip") +local s = ls.s +local i = ls.i +local t = ls.t + +local d = ls.dynamic_node +local c = ls.choice_node +local f = ls.function_node +local sn = ls.snippet_node + +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep + +-- -- + +local snippets = {} +local autosnippets = {} + +local autocmd = vim.api.nvim_create_autocmd +local augroup = vim.api.nvim_create_augroup +local map = vim.keymap.set +local opts = { noremap = true, silent = true, buffer = true } +local group = augroup("Markdown Snippets", { clear = true }) + +local function cs(trigger, nodes, keymap) --> cs stands for create snippet + local snippet = s(trigger, nodes) + table.insert(snippets, snippet) + + if keymap ~= nil then + local pattern = "*.md" + if type(keymap) == "table" then + pattern = keymap[1] + keymap = keymap[2] + end + autocmd("BufEnter", { + pattern = pattern, + group = group, + callback = function() + map({ "i" }, keymap, function() + ls.snip_expand(snippet) + end, opts) + end, + }) + end +end + +local function lp(package_name) -- Load Package Function + package.loaded[package_name] = nil + return require(package_name) +end + +-- Utility Functions -- + +-- Start Refactoring -- + +-- Start Refactoring -- + +return snippets, autosnippets diff --git a/.config/picom/picom.conf b/.config/picom/picom.conf new file mode 100644 index 0000000..521907c --- /dev/null +++ b/.config/picom/picom.conf @@ -0,0 +1,488 @@ +################################# +# Animations # +################################# +# requires https://github.com/jonaburg/picom +# (These are also the default values) +transition-length = 300 +transition-pow-x = 0.1 +transition-pow-y = 0.1 +transition-pow-w = 0.1 +transition-pow-h = 0.1 +size-transition = true + + +################################# +# Corners # +################################# +# requires: https://github.com/sdhand/compton or https://github.com/jonaburg/picom +corner-radius = 10.0; +rounded-corners-exclude = [ +#"window_type = 'normal'", +# "class_g = 'Bspwm' && class_i = 'presel_feedback'", +# "class_g = 'URxvt'", +# "class_g = 'alacritty'", +# "class_g = 'Org.gnome.Nautilus'", +# "class_g = 'Nemo'", + "class_g = 'firefox'", +# "class_g = 'Rofi'", +# "class_g = 'Spotify'", +# "class_g = 'discord'", +# "class_g = 'Code'", +# "class_g = 'TelegramDesktop'", +# "class_g = 'YouTube Music'", + "class_g = 'Polybar'" +# "class_g = 'qutebrowser'", +# "class_g = 'Zathura'", +# "class_g = 'Pavucontrol'" + +]; +round-borders = 1; +#round-borders-exclude = [ +# "class_g = 'TelegramDesktop'", +#]; + + + +################################# +# Shadows # +################################# + + +# Enabled client-side shadows on windows. Note desktop windows +# (windows with '_NET_WM_WINDOW_TYPE_DESKTOP') never get shadow, +# unless explicitly requested using the wintypes option. +# +# shadow = false +shadow = true; + +# The blur radius for shadows, in pixels. (defaults to 12) +# shadow-radius = 12 +shadow-radius = 20; + +# The opacity of shadows. (0.0 - 1.0, defaults to 0.75) +# shadow-opacity = .75 + +# The left offset for shadows, in pixels. (defaults to -15) +# shadow-offset-x = -15 +shadow-offset-x = -5; + +# The top offset for shadows, in pixels. (defaults to -15) +# shadow-offset-y = -15 +shadow-offset-y = -5; + +# Avoid drawing shadows on dock/panel windows. This option is deprecated, +# you should use the *wintypes* option in your config file instead. +# +# no-dock-shadow = false + +# Don't draw shadows on drag-and-drop windows. This option is deprecated, +# you should use the *wintypes* option in your config file instead. +# +# no-dnd-shadow = false + +# Red color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-red = 0 + +# Green color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-green = 0 + +# Blue color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-blue = 0 + +# Do not paint shadows on shaped windows. Note shaped windows +# here means windows setting its shape through X Shape extension. +# Those using ARGB background is beyond our control. +# Deprecated, use +# shadow-exclude = 'bounding_shaped' +# or +# shadow-exclude = 'bounding_shaped && !rounded_corners' +# instead. +# +# shadow-ignore-shaped = '' + +# Specify a list of conditions of windows that should have no shadow. +# +# examples: +# shadow-exclude = "n:e:Notification"; +# +# shadow-exclude = [] +shadow-exclude = [ + "name = 'Notification'", + "class_g = 'Conky'", + "class_g ?= 'Notify-osd'", + "class_g = 'Cairo-clock'", + "class_g = 'Polybar'", + # "class_g = 'Rofi'" + "_GTK_FRAME_EXTENTS@:c" + ]; + +# Specify a X geometry that describes the region in which shadow should not +# be painted in, such as a dock window region. Use +# shadow-exclude-reg = "x10+0+0" +# for example, if the 10 pixels on the bottom of the screen should not have shadows painted on. +# +# shadow-exclude-reg = "" + +# Crop shadow of a window fully on a particular Xinerama screen to the screen. +# xinerama-shadow-crop = false + + +################################# +# Fading # +################################# + + +# Fade windows in/out when opening/closing and when opacity changes, +# unless no-fading-openclose is used. +# fading = false +fading = true + +# Opacity change between steps while fading in. (0.01 - 1.0, defaults to 0.028) +# fade-in-step = 0.028 +fade-in-step = 0.08; + +# Opacity change between steps while fading out. (0.01 - 1.0, defaults to 0.03) +# fade-out-step = 0.03 +fade-out-step = 0.08; + +# The time between steps in fade step, in milliseconds. (> 0, defaults to 10) +# fade-delta = 10 + +# Specify a list of conditions of windows that should not be faded. +# fade-exclude = [] + +# Do not fade on window open/close. +# no-fading-openclose = false + +# Do not fade destroyed ARGB windows with WM frame. Workaround of bugs in Openbox, Fluxbox, etc. +# no-fading-destroyed-argb = false + + +################################# +# Transparency / Opacity # +################################# + +# Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0) +# inactive-opacity = 1 +inactive-opacity = 1; + +# Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default) +# frame-opacity = 1.0 +frame-opacity = 1; + +# Default opacity for dropdown menus and popup menus. (0.0 - 1.0, defaults to 1.0) +# menu-opacity = 1.0 + +# Let inactive opacity set by -i override the '_NET_WM_OPACITY' values of windows. +# inactive-opacity-override = true +inactive-opacity-override = false; + +# Default opacity for active windows. (0.0 - 1.0, defaults to 1.0) +active-opacity = 1.0; + +# Dim inactive windows. (0.0 - 1.0, defaults to 0.0) +inactive-dim = 0.2 + +# Specify a list of conditions of windows that should always be considered focused. +# focus-exclude = [] +focus-exclude = ["class_g = 'Plank'", "class_g = 'st'", "class_g = 'kitty'", "class_g = 'Alacritty'", "class_g = 'firefox'"]; + +# Use fixed inactive dim value, instead of adjusting according to window opacity. +# inactive-dim-fixed = 1.0 + +# Specify a list of opacity rules, in the format `PERCENT:PATTERN`, +# like `50:name *= "Firefox"`. picom-trans is recommended over this. +# Note we don't make any guarantee about possible conflicts with other +# programs that set '_NET_WM_WINDOW_OPACITY' on frame or client windows. +# example: +# opacity-rule = [ "80:class_g = 'URxvt'" ]; +opacity-rule = ["100:class_g = 'st' && focused", "100:class_g = 'st' && !focused", "80:class_g = 'URxvt'", "100:class_g = 'firefox'", "100:class_g = 'Zathura'", "80:class_g = 'Spotify'", "80:class_g *?= 'Rofi'", "100:class_g = 'kitty' && focused", "100:class_g = 'kitty' && !focused", "100:class_g = 'Alacritty' && focused", "100:class_g = 'Alacritty' && !focused"]; +# +#opacity-rule = ["85:class_g ?= 'Alacritty' && focused"]; + +#blur-background-exclude = ["class_g = 'scratchpad'"]; + +################################# +# Background-Blurring # +################################# + + +# Parameters for background blurring, see the *BLUR* section for more information. +blur-method = "dual_kawase"; +#blur-method = "gaussian"; +blur-strength = 6; +# blur-size = 12 +# +# blur-deviation = false + +# Blur background of semi-transparent / ARGB windows. +# Bad in performance, with driver-dependent behavior. +# The name of the switch may change without prior notifications. +# +blur-background = false; + +# Blur background of windows when the window frame is not opaque. +# Implies: +# blur-background +# Bad in performance, with driver-dependent behavior. The name may change. +# +# blur-background-frame = false + + +# Use fixed blur strength rather than adjusting according to window opacity. +#blur-background-fixed = false + + +# Specify the blur convolution kernel, with the following format: +# example: +# blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1"; +# +# blur-kern = '' +#blur-kern = "3x3box"; +blur-kern = "7x7box"; + +# Exclude conditions for background blur. +# blur-background-exclude = [] +blur-background-exclude = [ + "window_type = 'dock'", + "window_type = 'desktop'", + "_GTK_FRAME_EXTENTS@:c", + "class_g = 'kitty'", + "class_g = 'Alacritty'", +# "class_g = 'Polybar'", + "class_g = 'URxvt'", + "class_g = 'St'", + "class_g = 'scratch'", + "class_g = 'Heads-Up-Display'", + "class_g = 'Firefox'", + "class_g = 'firefox'", + "class_g = 'discord'", + "class_g = 'Rofi'", + "class_g = 'Zathura'" +]; + +################################# +# General Settings # +################################# + +# Daemonize process. Fork to background after initialization. Causes issues with certain (badly-written) drivers. +# daemon = false + +# Specify the backend to use: `xrender`, `glx`, or `xr_glx_hybrid`. +# `xrender` is the default one. +# +experimental-backends = true; +#backend = 'glx' +backend = "glx"; +#backend = "xrender"; + +# Enable/disable VSync. +# vsync = false +vsync = true + +# Enable remote control via D-Bus. See the *D-BUS API* section below for more details. +# dbus = false + +# Try to detect WM windows (a non-override-redirect window with no +# child that has 'WM_STATE') and mark them as active. +# +# mark-wmwin-focused = false +mark-wmwin-focused = true; + +# Mark override-redirect windows that doesn't have a child window with 'WM_STATE' focused. +mark-ovredir-focused = false; +#mark-ovredir-focused = true; + +# Try to detect windows with rounded corners and don't consider them +# shaped windows. The accuracy is not very high, unfortunately. +# +# detect-rounded-corners = false +detect-rounded-corners = true; + +# Detect '_NET_WM_OPACITY' on client windows, useful for window managers +# not passing '_NET_WM_OPACITY' of client windows to frame windows. +# +# detect-client-opacity = false +detect-client-opacity = true; + +# Specify refresh rate of the screen. If not specified or 0, picom will +# try detecting this with X RandR extension. +# +# refresh-rate = 60 +refresh-rate = 0 + +# Limit picom to repaint at most once every 1 / 'refresh_rate' second to +# boost performance. This should not be used with +# vsync drm/opengl/opengl-oml +# as they essentially does sw-opti's job already, +# unless you wish to specify a lower refresh rate than the actual value. +# +# sw-opti = + +# Use EWMH '_NET_ACTIVE_WINDOW' to determine currently focused window, +# rather than listening to 'FocusIn'/'FocusOut' event. Might have more accuracy, +# provided that the WM supports it. +# +# use-ewmh-active-win = false + +# Unredirect all windows if a full-screen opaque window is detected, +# to maximize performance for full-screen windows. Known to cause flickering +# when redirecting/unredirecting windows. +# +# unredir-if-possible = false + +# Delay before unredirecting the window, in milliseconds. Defaults to 0. +# unredir-if-possible-delay = 0 + +# Conditions of windows that shouldn't be considered full-screen for unredirecting screen. +# unredir-if-possible-exclude = [] + +# Use 'WM_TRANSIENT_FOR' to group windows, and consider windows +# in the same group focused at the same time. +# +# detect-transient = false +detect-transient = true + +# Use 'WM_CLIENT_LEADER' to group windows, and consider windows in the same +# group focused at the same time. 'WM_TRANSIENT_FOR' has higher priority if +# detect-transient is enabled, too. +# +# detect-client-leader = false +detect-client-leader = true + +# Resize damaged region by a specific number of pixels. +# A positive value enlarges it while a negative one shrinks it. +# If the value is positive, those additional pixels will not be actually painted +# to screen, only used in blur calculation, and such. (Due to technical limitations, +# with use-damage, those pixels will still be incorrectly painted to screen.) +# Primarily used to fix the line corruption issues of blur, +# in which case you should use the blur radius value here +# (e.g. with a 3x3 kernel, you should use `--resize-damage 1`, +# with a 5x5 one you use `--resize-damage 2`, and so on). +# May or may not work with *--glx-no-stencil*. Shrinking doesn't function correctly. +# +# resize-damage = 1 + +# Specify a list of conditions of windows that should be painted with inverted color. +# Resource-hogging, and is not well tested. +# +# invert-color-include = [] + +# GLX backend: Avoid using stencil buffer, useful if you don't have a stencil buffer. +# Might cause incorrect opacity when rendering transparent content (but never +# practically happened) and may not work with blur-background. +# My tests show a 15% performance boost. Recommended. +# +# glx-no-stencil = false + +# GLX backend: Avoid rebinding pixmap on window damage. +# Probably could improve performance on rapid window content changes, +# but is known to break things on some drivers (LLVMpipe, xf86-video-intel, etc.). +# Recommended if it works. +# +# glx-no-rebind-pixmap = false + +# Disable the use of damage information. +# This cause the whole screen to be redrawn everytime, instead of the part of the screen +# has actually changed. Potentially degrades the performance, but might fix some artifacts. +# The opposing option is use-damage +# +# no-use-damage = false +use-damage = true + +# Use X Sync fence to sync clients' draw calls, to make sure all draw +# calls are finished before picom starts drawing. Needed on nvidia-drivers +# with GLX backend for some users. +# +# xrender-sync-fence = false + +# GLX backend: Use specified GLSL fragment shader for rendering window contents. +# See `compton-default-fshader-win.glsl` and `compton-fake-transparency-fshader-win.glsl` +# in the source tree for examples. +# +# glx-fshader-win = '' + +# Force all windows to be painted with blending. Useful if you +# have a glx-fshader-win that could turn opaque pixels transparent. +# +# force-win-blend = false + +# Do not use EWMH to detect fullscreen windows. +# Reverts to checking if a window is fullscreen based only on its size and coordinates. +# +# no-ewmh-fullscreen = false + +# Dimming bright windows so their brightness doesn't exceed this set value. +# Brightness of a window is estimated by averaging all pixels in the window, +# so this could comes with a performance hit. +# Setting this to 1.0 disables this behaviour. Requires --use-damage to be disabled. (default: 1.0) +# +# max-brightness = 1.0 + +# Make transparent windows clip other windows like non-transparent windows do, +# instead of blending on top of them. +# +# transparent-clipping = false + +# Set the log level. Possible values are: +# "trace", "debug", "info", "warn", "error" +# in increasing level of importance. Case doesn't matter. +# If using the "TRACE" log level, it's better to log into a file +# using *--log-file*, since it can generate a huge stream of logs. +# +# log-level = "debug" +log-level = "warn"; + +# Set the log file. +# If *--log-file* is never specified, logs will be written to stderr. +# Otherwise, logs will to written to the given file, though some of the early +# logs might still be written to the stderr. +# When setting this option from the config file, it is recommended to use an absolute path. +# +# log-file = '/path/to/your/log/file' + +# Show all X errors (for debugging) +# show-all-xerrors = false + +# Write process ID to a file. +# write-pid-path = '/path/to/your/log/file' + +# Window type settings +# +# 'WINDOW_TYPE' is one of the 15 window types defined in EWMH standard: +# "unknown", "desktop", "dock", "toolbar", "menu", "utility", +# "splash", "dialog", "normal", "dropdown_menu", "popup_menu", +# "tooltip", "notification", "combo", and "dnd". +# +# Following per window-type options are available: :: +# +# fade, shadow::: +# Controls window-type-specific shadow and fade settings. +# +# opacity::: +# Controls default opacity of the window type. +# +# focus::: +# Controls whether the window of this type is to be always considered focused. +# (By default, all window types except "normal" and "dialog" has this on.) +# +# full-shadow::: +# Controls whether shadow is drawn under the parts of the window that you +# normally won't be able to see. Useful when the window has parts of it +# transparent, and you want shadows in those areas. +# +# redir-ignore::: +# Controls whether this type of windows should cause screen to become +# redirected again after been unredirected. If you have unredir-if-possible +# set, and doesn't want certain window to cause unnecessary screen redirection, +# you can set this to `true`. +# +wintypes: +{ + tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; full-shadow = false; }; + dock = { shadow = false; } + dnd = { shadow = false; } + popup_menu = { opacity = 0.8; } + dropdown_menu = { opacity = 0.8; } +}; + diff --git a/.config/polybar/config b/.config/polybar/config new file mode 100644 index 0000000..24ac5e3 --- /dev/null +++ b/.config/polybar/config @@ -0,0 +1,816 @@ +;========================================================== +; +; +; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗ +; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗ +; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝ +; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗ +; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║ +; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ +; +; +; To learn more about how to configure Polybar +; go to https://github.com/polybar/polybar +; +; The README contains a lot of information +; +;========================================================== + +[colors] +background = #aa000000 +;background = #aa101212 +;background = #00000000 +background-alt = #aaCECCC9 +;foreground = #aaCECCC9 +foreground = #fafafa +foreground-alt = #aaCECCC9 +primary = #aaCECCC9 +secondary = #aaCECCC9 +alert = #aaCECCC9 +non = #aaCECCC9 +;background = #aa000000 +blue = #61afef +dark_blue = #42A5F5 +nord = #81a1c1 +light_blue = #ADD8E6 +;green = #a0c980 +purple = #c882e7 +orange = #E57C46 +;orange = #d08770 +gray = #676E95 +red = #EC7875 +pink = #EC407A +yellow = #FDD835 +;yellow = #ECBE7B +amber = #FBC02D +indigo = #6C77BB +green = #61C766 +lime = #B9C244 +cyber = #53E2AE + +[bar/top] +;width = 100% +width = 99.15% +height = 24 +offset-x = 0.5% +offset-y = 0.5% +radius = 10.0 +;radius = 0 +fixed-center = true +bottom = false +enable-ipc = true +tray-position = right +tray-padding = 4 +tray-background = ${colors.background} +;tray-offest-x = -15 +;tray-offset-x = 400 +;tray-offset-x = -95 +;tray-offset-x = -208 +;tray-offset-x = -178 +;tray-offset-x = -183 +tray-offset-x = -188 +;tray-offset-x = -210 +tray-offset-y = -0.9 +tray-detached = true + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 0 +line-color = ${colors.background-alt} + +;border-top-size = 1 +;border-bottom-size = 1 +;border-right-size = 1 +;border-left-size = 1 +;border-color = ${colors.foreground} +;border-size = 2 +;border-color = ${colors.background} + +padding-left = 0 +padding-right = 0 + +module-margin-left = 0 +module-margin-right = 0 +; Font for date +font-0 = "SF Pro Mono:style=Display Bold:size=10;2" +; Font for crypto, dunst +font-1 = "Material Design Icons:style=Bold:size=11.5;2" +; Font for menu +font-2 = "Material Design Icons:style=Bold:size=13.5;2" +; Font for controlCenter +font-3 = "SF Pro:style=Medium:size=10.5;2" +; Font for search +font-4 = "SF Pro:style=Medium:size=9.5;2" +; Font for bspwm/workspaces +font-5 = "UbuntuMono Nerd font:size=11;2" + +modules-left = sep menu sep close sep minimize sep maximize sep xwindow sep +modules-center = bspwm +modules-right = spotify spotify-prev spotify-play-pause spotify-next long-sep dunst search control date sep + +;modules-left = sep menu +;modules-center = date +;modules-right = bspwm whitespace crypto dunst search control space + +;modules-right = crypto dunst search date sep powermenu sep +;modules-right = crypto toggle_spotify volume backlight battery network notification powermenu + +wm-restack = bspwm +;wm-restack = bspwm + +override-redirect = true + +;; scroll-up = bspwm-desknext +;; scroll-down = bspwm-deskprev + +;scroll-up = i3wm-wsnext +;scroll-down = i3wm-wsprev + +cursor-click = pointer +cursor-scroll = ns-resize + +[module/menu] +type = custom/text +content = +content-font = 3 +content-padding = 1 +content-foreground = ${colors.foreground} +click-left = ~/.config/polybar/scripts/menu.sh +click-right = ~/.config/polybar/scripts/menu_full.sh + +[module/bspwm] +type = internal/bspwm +format = <label-state> +;format = <label-state> <label-mode> +format-padding = 0 +;format-padding-right = 2 +format-foreground = ${colors.foreground} +index-sort = true +enable-click = true +reverse-scroll = true +#reverse-scroll = false + +label-focused = +label-focused-padding = 2 + +label-occupied = +label-occupied-padding = 2 + +label-empty = +label-empty-padding = 2 + + +[module/sepp] +type = custom/text +content = " " + + +[module/close] +type = custom/text +content-foreground = ${colors.red} +content-padding = 1 +content = +click-left = "xdotool getwindowfocus windowkill" + +[module/minimize] +type = custom/text +content-foreground = ${colors.yellow} +content-padding = 1 +content = +click-left = bspc node -g hidden +click-right = ${HOME}/.config/bspwm/bspcmd unhide + +;label = +[module/maximize] +type = custom/text +content-foreground = ${colors.green} +content-padding = 1 +content = +;click-left = bspc node -t {fullscreen} +click-left = bspc node -t ~floating +click-right = bspc desktop -l next +#bspc node -t \~{fullscreen}; + +[module/blur-toggle] +type = custom/ipc +hook-0 = echo +hook-1 = echo +click-left = ~/.local/bin/scripts/blurtoggle.sh +initial = 1 +format-foreground = ${colors.foreground} + + +[module/battery] +type = internal/battery +full-t = 99 +time-format = %H:%M +battery = BAT1 +adapter = ACAD +format-padding = 1 +format-charging = <animation-charging> <label-charging> +format-charging-background = +label-charging = %percentage%% +format-discharging = <ramp-capacity> <label-discharging> +format-discharging-background = +label-discharging = %percentage%% +format-full = <label-full> +format-full-prefix = " " +format-full-prefix-foreground = ${colors.green} +;format-foreground = ${colors.green} +ramp-capacity-0 = +ramp-capacity-1 = +ramp-capacity-2 = +ramp-capacity-3 = +ramp-capacity-4 = +ramp-capacity-5 = +ramp-capacity-6 = +ramp-capacity-7 = +ramp-capacity-8 = +ramp-capacity-9 = + +ramp-capacity-0-foreground = ${colors.red} +ramp-capacity-1-foreground = ${colors.red} +ramp-capacity-foreground = ${colors.green} +;ramp-capacity-foreground = ${colors.foreground} +bar-capacity-width = 10 + +animation-charging-0 = +animation-charging-1 = +animation-charging-2 = +animation-charging-3 = +animation-charging-4 = +animation-charging-5 = +animation-charging-6 = +animation-charging-foreground = ${colors.green} + +animation-charging-framerate = 750 + +[module/xbacklight] +type = internal/xbacklight +enable-scroll = true + +[module/backlight] +inherit = module/xbacklight +type = internal/backlight +card = intel_backlight +format-backlight = <ramp-backlight> <label> +format-padding = 1 +format-prefix = " " +format-prefix-foreground = ${colors.indigo} +label = %percentage%% +label-foreground = ${colors.foreground} + +[module/bluetooth] +type = custom/script +exec = ~/.config/polybar/scripts/bluetooth.sh +tail = true +click-left = exec blueberry & +click-right = exec $HOME/.config/polybar/scripts/toggle_bluetooth.sh + +[module/network] +type = custom/script +exec = ~/.config/polybar/scripts/check-network.sh +format-background = +format-foreground = ${colors.light_blue} +click-left = networkmanager_dmenu & +click-right = nm-applet +tail = true +format-padding = 1 + + +;[module/date] +;type = internal/date +;interval = 30 +;label = %time% +;label-padding = 2 +;label-background = +;time = %H:%M +;time-alt = %Y-%m-%d + +[module/date] +type = internal/date +interval = 1 +label = %date%, %time% +label-padding = 2.5 +label-background = +date = %a %d %b +time = %H:%M + +;[module/powermenu] +;type = custom/text +;content = +;;content = 襤 +;content-foreground = ${colors.red} +;content-padding = 1 +;label-margin = 3 +;click-left = ~/.config/polybar/scripts/sysmenu.sh +;click-right = ~/.config/polybar/scripts/sysmenu.sh + +[module/control] +type = custom/text +content = +;content = 襤 +content-foreground = ${colors.foreground} +content-padding = 1 +label-margin = 10 +click-left = ~/.config/polybar/scripts/sysmenu.sh +click-right = ~/.config/polybar/scripts/sysmenu.sh + + +;[module/title] +;type = internal/xwindow +;; Available tags: +;; <label> (default) +;format = <label> +;format-background = ${colors.background} +;format-foreground = ${colors.foreground} +;format-padding = 1 +;label-maxlen = 10 +;label-empty = " " + + +;[module/bspwm] +;type = internal/bspwm +;format = <label-state> +;;format = <label-state> <label-mode> +;format-padding = 1 +;format-foreground = ${colors.foreground} +;index-sort = true +;enable-click = true +;reverse-scroll = true +;#reverse-scroll = false +; +;label-focused = +;label-focused-padding = 2 +; +;label-occupied = +;label-occupied-padding = 2 +; +;label-empty = +;label-empty-padding = 2 +; +;label-monocle = " " +;label-tiled = " " +;label-fullscreen = " " +;label-floating = " " +;label-pseudotiled = " " +;label-locked = " " +;;label-sticky = " " +;label-private = " " + +; Separator in between workspaces +;label-separator = | +;label-separator-padding = 10 +;label-separator-foreground = #ffb52a +[module/search] +type = custom/text +content = "" +; hack nerd +content-padding = 1 +content-font = 5 +;content-padding-right = 5 +content-foreground = ${colors.foreground} +click-left = rofi -show drun +;click-left = ~/.config/polybar/scripts/menu.sh + + + +[module/crypto] +type = custom/script +exec = echo +format = <label> +format-padding = 1 +label-padding = +content-background = +format-foreground = ${colors.foreground} +interval = 60 +click-left = cryptonotify +click-right = $TERMINAL -e cointop & + +[module/now-playing] +type = custom/script +tail = true +;format-prefix = "" +format = <label> +exec = ~/.config/polybar/scripts/now-playing.sh +click-right = "kill -USR1 $(pgrep --oldest --parent %pid%)" + + +[module/sep] +type = custom/text +content = " " + +[module/long-sep] +type = custom/text +content = " " + +[module/space] +type = custom/text +content = " " + +[module/whitespace] +type = custom/text +content = " " + +[module/xwindow] +type = internal/xwindow +label = %title:0:60:...% +format-foreground = ${colors.foreground} +format-padding = 6 + +[module/arch] +typ = custom/text +content = " " +format-foreground = ${colors.foreground} +format-padding = 4 + + + +[module/workspaces] +type = internal/xworkspaces +pin-workspaces = true +enable-click = true +enable-scroll = true +format-padding = 1 + +icon-default = + +format = <label-state> +format-background = ${colors.bg1} +label-active = " " +label-occupied = " " +label-urgent = " " +label-empty = " " + +label-empty-padding = 1 +label-active-padding = 1 +label-urgent-padding = 1 +label-occupied-padding = 1 + +label-empty-foreground = ${colors.foreground} +label-active-foreground = ${colors.acolor} +label-urgent-foreground = ${colors.curgent} +label-occupied-foreground = ${colors.foreground} + +[module/spotify] +type = custom/script +tail = true +interval = 1 +; prefix symbol is shown before the text +format-prefix = "" +format = <label> +exec = ~/.config/polybar/scripts/scroll_spotify_status.sh + +[module/spotify-prev] +type = custom/script +tail = true +interval = 1 +exec = echo " " +format = <label> +click-left = playerctl previous -p spotify + +[module/spotify-play-pause] +type = custom/ipc +tail = true +interval = 1 +hook-0 = echo "" +hook-1 = echo "" +initial = 1 +click-left = playerctl play-pause -p spotify + +[module/spotify-next] +type = custom/script +#type = custom/ipc +tail = true +interval = 1 +exec = echo " " +format = <label> +click-left = playerctl next -p spotify + +[module/toggle_spotify] +type = custom/text +content = " " +content-padding = 1 +content-foreground = ${colors.pink} +click-left = spotify +click-right = spotify + +[module/cmus] +type = custom/script + +exec = ~/.config/polybar/scripts/cmus.sh +exec-if = pgrep -x cmus +interval = 1 + +click-left = cmus-remote --next +click-right = cmus-remote --prev +click-middle = cmus-remote --pause +scroll-up = cmus-remote --volume +5% +scroll-down = cmus-remote --volume -5% + +label-font = 1 +format = <label> +format-underline = ${colors.foreground-alt} +label = %output% +label-maxlen = 50 + +[module/notification] +type = custom/text +content = +content-padding = 0 +content-foreground = ${colors.foreground-alt} +click-left = sh rofi_notif_center.sh +click-right = sh rofi_notif_center.sh + +[module/dunst] +type = custom/text +content-foreground = ${colors.foreground} +content-padding = 1 +content = +click-left = "dunstctl history-pop" + +[module/popup-calendar] +type = custom/script +exec = ~/.config/polybar/scripts/popup-calendar.sh +interval = 5 +click-left = ~/.config/polybar/scripts/popup-calendar.sh --popup & + +;[module/dunst] +;type = custom/ipc +;initial = 1 +;format-foreground = ${colors.foreground} +;hook-0 = echo "%{A1:notify-send dunstctl && polybar-msg hook dunst 2:}%{A}" & +;hook-1 = echo "%{A1:notify-send dunstctl && polybar-msg hook dunst 1:}%{A}" & + +[module/eww] +type = custom/text +content = +content-padding = 0 +content-foreground = #d8dee9 +click-left = sh toggle_eww.sh +click-right = sh toggle_eww.sh + +[module/pulseaudio] +type = internal/pulseaudio +ramp-volume-foreground = #8959a8 +format-volume-padding = 0 +format-volume-margin = 0 +format-volume = <ramp-volume> +use-ui-max = true +interval = 5 + +ramp-volume-0 = " " +ramp-volume-1 = " " +ramp-volume-2 = " " + + +label-muted = +label-muted-background = #3e999f +format-muted-foreground = #3e999f +format-muted-overline = #3e999f +format-muted-margin = 2 +format-muted-padding = 2 + +[module/volume] +type = internal/pulseaudio +format-volume = <ramp-volume> <label-volume> +format-volume-font = 10 +format-volume-padding = 0 +;ramp-volume-foreground = ${colors.foreground} +label-volume = %percentage%% +label-volume-padding = 0 +;label-muted-foreground = ${colors.foreground} +;format-volume-foreground = ${colors.purple} +format-muted-foreground = ${colors.red} +format-muted-underline = ${colors.red} +ramp-volume-foreground = ${colors.purple} +label-muted = "婢 " +ramp-volume-0 = "" +ramp-volume-1 = "" +ramp-volume-2 = "" +ramp-volume-3 = "" +ramp-volume-4 = "" +ramp-volume-5 = "" +ramp-volume-6 = "" + + +[module/xkeyboard] +type = internal/xkeyboard +blacklist-0 = num lock + +format-prefix = +format-foreground = ${colors.foreground-alt} +label-layout = " %layout%" + +label-indicator-foreground = ${colors.alert} +label-indicator-padding = 2 + +[module/filesystem] +type = internal/fs +interval = 25 + +mount-0 = / + +format-mounted = <label-mounted> +format-mounted-foreground = #b48ead +format-mounted-prefix = " " +label-mounted = " %free%" + +format-unmounted = <label-unmounted> +format-unmounted-prefix = +label-unmounted = %mountpoint%: not mounted + +[module/updates] +type = custom/script +exec = xbps-updates +format = <label> +interval = 4600 +label = %output% +label-padding = 2 +label-foreground = #81A1C1 + + +[module/cpu] +type = internal/cpu +interval = 2 +format-prefix = " " +format-prefix-foreground = #b48ead +label = %percentage:2%% + + +[module/memory] +type = internal/memory +interval = 2 +format-prefix = " " +format-prefix-foreground = #5e81ac +label = %percentage_used%% + +[module/globalmenu] +type = custom/script +exec = ~/.config/polybar/globalmenu.sh +format = <label> +label = %output% +;type = custom/ipc +;hook-0 = xfce4-panel | sed -e 's/^"//' -e 's/"$//' +;;exec = awk /usr/bin/xfce4-panel +;initial = 1 +;format-underline = ${colors.cyber} +;format-padding = 1 + +[module/global] +type = custom/script +exec = ~/.config/polybar/globaldmenu +label = %output% + +[settings] +screenchange-reload = true +;compositing-background = xor +;compositing-background = screen +;compositing-foreground = source +;compositing-border = over +;pseudo-transparency = false + +[global/wm] +margin-top = 0 +margin-bottom = 0 + +[module/options_open] +type = custom/text +content-foreground = ${colors.foreground} +content = "" +click-left = ~/.config/polybar/scripts/polybar_wrapper options + +[module/options_close] +type = custom/text +content-foreground = ${colors.primary} +content = "" +click-left = ~/.config/polybar/scripts/polybar_wrapper options + +;[bar/bottom] +;width = 8% +;height = 15 +;offset-x = 46% +;;offset-x = 35% +;;offset-x = 0.5% +;offset-y = 2.5% +;radius = 7.0 +;fixed-center = true +;bottom = false +;enable-ipc = true +;;tray-offset-x = 515 +;;tray-detached = true +; +;background = ${colors.background} +;foreground = ${colors.foreground} +; +;line-size = 0 +;line-color = ${colors.background-alt} +; +;;border-top-size = 1 +;;border-bottom-size = 1 +;;border-right-size = 1 +;;border-left-size = 1 +;;border-color = ${colors.foreground} +;;border-size = 2 +;;border-color = ${colors.background} +; +;padding-left = 0 +;padding-right = 0 +; +;module-margin-left = 0 +;module-margin-right = 0 +;; Font for date +;font-0 = "SF Pro Mono:style=Display Bold:size=10;2" +;; Font for bspwm/workspaces +;font-1 = "UbuntuMono Nerd font:size=10.5;2" +;; Font for crypto, dunst +;font-2 = "Material Design Icons:style=Bold:size=11;3" +;; Font for menu +;font-3 = "Material Design Icons:style=Bold:size=14;5" +;; Font for search and controlCenter +;font-4 = "SF Pro:style=Medium:size=10.5;3" +; +;modules-center = bspwm sepp +; +;;wm-restack = bspwm +; +;override-redirect = true +; +;;; scroll-up = bspwm-desknext +;;; scroll-down = bspwm-deskprev +; +;;scroll-up = i3wm-wsnext +;;scroll-down = i3wm-wsprev +; +;cursor-click = pointer +;cursor-scroll = ns-resize +; +; +;[bar/left] +;width = 5% +;height = 15 +;offset-x = 2.5% +;;offset-x = 35% +;;offset-x = 0.5% +;offset-y = 2.5% +;radius = 7.0 +;fixed-center = true +;bottom = false +;enable-ipc = true +;;tray-offset-x = 515 +;;tray-detached = true +; +;background = ${colors.background} +;foreground = ${colors.foreground} +; +;line-size = 0 +;line-color = ${colors.background-alt} +; +;;border-top-size = 1 +;;border-bottom-size = 1 +;;border-right-size = 1 +;;border-left-size = 1 +;;border-color = ${colors.foreground} +;;border-size = 2 +;;border-color = ${colors.background} +; +;padding-left = 0 +;padding-right = 0 +; +;module-margin-left = 0 +;module-margin-right = 0 +;; Font for date +;font-0 = "SF Pro Mono:style=Display Bold:size=10;2" +;; Font for bspwm/workspaces +;font-1 = "UbuntuMono Nerd font:size=11.5;2" +;; Font for crypto, dunst +;font-2 = "Material Design Icons:style=Bold:size=11;3" +;; Font for menu +;font-3 = "Material Design Icons:style=Bold:size=14;5" +;; Font for search and controlCenter +;font-4 = "SF Pro:style=Medium:size=10.5;3" +; +;modules-left = close blank minimize blank maximize blank +; +;;wm-restack = bspwm +; +;override-redirect = true +; +;;; scroll-up = bspwm-desknext +;;; scroll-down = bspwm-deskprev +; +;;scroll-up = i3wm-wsnext +;;scroll-down = i3wm-wsprev +; +;cursor-click = pointer +;cursor-scroll = ns-resize +; +;;[module/decorations] +;;type = custom/text +; +;[module/blank] +;type = custom/text +;content = " " + +; vim:ft=dosini diff --git a/.config/polybar/launch.sh b/.config/polybar/launch.sh new file mode 100755 index 0000000..1c0ac10 --- /dev/null +++ b/.config/polybar/launch.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env sh + +# Terminate already running bar instances +killall -q polybar + +# Wait until the processes have been shut down +while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done + +# Launch bar +polybar top & +#polybar bottom & +#polybar left & +#polybar top_external & + +#sleep 5 && xdo raise -N "polybar-bottom_LVDS-1" & +if [[ $(xrandr -q | grep 'HDMI-1 connected') ]]: then + polybar top_external & +fi diff --git a/.config/polybar/scripts/bluetooth.sh b/.config/polybar/scripts/bluetooth.sh new file mode 100755 index 0000000..061604b --- /dev/null +++ b/.config/polybar/scripts/bluetooth.sh @@ -0,0 +1,12 @@ +#!/bin/sh +if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] +then + echo "" +else + if [ $(echo info | bluetoothctl | grep 'Device' | wc -c) -eq 0 ] + then + echo "" + fi + echo "" +fi + diff --git a/.config/polybar/scripts/check-network.sh b/.config/polybar/scripts/check-network.sh new file mode 100755 index 0000000..dabe74c --- /dev/null +++ b/.config/polybar/scripts/check-network.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +count=0 +disconnected="睊" +wireless_connected="直" +ethernet_connected="泌" + +ID="$(ip link | awk '/state UP/ {print $2}')" + +while true; do + if (ping -c 1 archlinux.org || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) &>/dev/null; then + if [[ $ID == e* ]]; then + echo "$ethernet_connected" ; sleep 25 + else + echo "$wireless_connected" ; sleep 25 + fi + else + echo "$disconnected" ; sleep 0.5 + fi +done + diff --git a/.config/polybar/scripts/check_updates.sh b/.config/polybar/scripts/check_updates.sh new file mode 100755 index 0000000..52e51a9 --- /dev/null +++ b/.config/polybar/scripts/check_updates.sh @@ -0,0 +1,118 @@ + +#!/usr/bin/bash +# +# checkupdates: Safely print a list of pending updates. +# +# Copyright (c) 2013 Kyle Keen <keenerd@gmail.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +declare -r myname='checkupdates' +declare -r myver='1.0.0' + +plain() { + (( QUIET )) && return + local mesg=$1; shift + printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 +} + +msg() { + (( QUIET )) && return + local mesg=$1; shift + printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 +} + +msg2() { + (( QUIET )) && return + local mesg=$1; shift + printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&1 +} + +ask() { + local mesg=$1; shift + printf "${BLUE}::${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}" "$@" >&1 +} + +warning() { + local mesg=$1; shift + printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +error() { + local mesg=$1; shift + printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 +} + +# check if messages are to be printed using color +unset ALL_OFF BOLD BLUE GREEN RED YELLOW +if [[ -t 2 && ! $USE_COLOR = "n" ]]; then + # prefer terminal safe colored and bold text when tput is supported + if tput setaf 0 &>/dev/null; then + ALL_OFF="$(tput sgr0)" + BOLD="$(tput bold)" + BLUE="${BOLD}$(tput setaf 4)" + GREEN="${BOLD}$(tput setaf 2)" + RED="${BOLD}$(tput setaf 1)" + YELLOW="${BOLD}$(tput setaf 3)" + else + ALL_OFF="\e[1;0m" + BOLD="\e[1;1m" + BLUE="${BOLD}\e[1;34m" + GREEN="${BOLD}\e[1;32m" + RED="${BOLD}\e[1;31m" + YELLOW="${BOLD}\e[1;33m" + fi +fi +readonly ALL_OFF BOLD BLUE GREEN RED YELLOW + + +if (( $# > 0 )); then + echo "${myname} v${myver}" + echo + echo "Safely print a list of pending updates" + echo + echo "Usage: ${myname}" + echo + echo 'Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database.' + exit 0 +fi + +if ! type -P fakeroot >/dev/null; then + error 'Cannot find the fakeroot binary.' + exit 1 +fi + +if [[ -z $CHECKUPDATES_DB ]]; then + CHECKUPDATES_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/" +fi + +trap 'rm -f $CHECKUPDATES_DB/db.lck' INT TERM EXIT + +DBPath="$(pacman-conf DBPath)" +if [[ -z "$DBPath" ]] || [[ ! -d "$DBPath" ]]; then + DBPath="/var/lib/pacman/" +fi + +mkdir -p "$CHECKUPDATES_DB" +ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null +if ! fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null; then + error 'Cannot fetch updates' + exit 1 +fi +pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]' + +exit 0 + +# vim: set noet: diff --git a/.config/polybar/scripts/cmus.sh b/.config/polybar/scripts/cmus.sh new file mode 100755 index 0000000..2f42c63 --- /dev/null +++ b/.config/polybar/scripts/cmus.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +prepend_zero () { + seq -f "%02g" $1 $1 +} + +artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-)) + +if [[ $artist = *[!\ ]* ]]; then + song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-)) + position=$(cmus-remote -C status | grep position | cut -c 10-) + minutes1=$(prepend_zero $(($position / 60))) + seconds1=$(prepend_zero $(($position % 60))) + duration=$(cmus-remote -C status | grep duration | cut -c 10-) + minutes2=$(prepend_zero $(($duration / 60))) + seconds2=$(prepend_zero $(($duration % 60))) + echo -n "$artist - $song " +else + echo +fi + +#prepend_zero () { +# seq -f "%02g" $1 $1 +#} +# +#artist=$(echo -n $(cmus-remote -C status | grep "tag artist" | cut -c 12-)) +# +#if [[ $artist = *[!\ ]* ]]; then +# song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-)) +# position=$(cmus-remote -C status | grep position | cut -c 10-) +# minutes1=$(prepend_zero $(($position / 60))) +# seconds1=$(prepend_zero $(($position % 60))) +# duration=$(cmus-remote -C status | grep duration | cut -c 10-) +# minutes2=$(prepend_zero $(($duration / 60))) +# seconds2=$(prepend_zero $(($duration % 60))) +# echo -n "$artist - $song [$minutes1:$seconds1/$minutes2:$seconds2]" +#else +# echo +#fi diff --git a/.config/polybar/scripts/get_spotify_status.sh b/.config/polybar/scripts/get_spotify_status.sh new file mode 100755 index 0000000..f04400d --- /dev/null +++ b/.config/polybar/scripts/get_spotify_status.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# The name of polybar bar which houses the main spotify module and the control modules. +PARENT_BAR="now-playing" +PARENT_BAR_PID=$(pgrep -a "polybar" | grep "$PARENT_BAR" | cut -d" " -f1) + +# Set the source audio player here. +# Players supporting the MPRIS spec are supported. +# Examples: spotify, vlc, chrome, mpv and others. +# Use `playerctld` to always detect the latest player. +# See more here: https://github.com/altdesktop/playerctl/#selecting-players-to-control +#PLAYER="spotify" +PLAYER="playerctld" + +# Format of the information displayed +# Eg. {{ artist }} - {{ album }} - {{ title }} +# See more attributes here: https://github.com/altdesktop/playerctl/#printing-properties-and-metadata +FORMAT="{{ title }} - {{ artist }}" + +# Sends $2 as message to all polybar PIDs that are part of $1 +update_hooks() { + while IFS= read -r id + do + polybar-msg -p "$id" hook spotify-play-pause $2 1>/dev/null 2>&1 + done < <(echo "$1") +} + +PLAYERCTL_STATUS=$(playerctl --player=$PLAYER status 2>/dev/null) +EXIT_CODE=$? + +if [ $EXIT_CODE -eq 0 ]; then + STATUS=$PLAYERCTL_STATUS +else + STATUS="No player is running" +fi + +if [ "$1" == "--status" ]; then + echo "$STATUS" +else + if [ "$STATUS" = "Stopped" ]; then + echo "No music is playing" + elif [ "$STATUS" = "Paused" ]; then + update_hooks "$PARENT_BAR_PID" 2 + playerctl --player=$PLAYER metadata --format "$FORMAT" + elif [ "$STATUS" = "No player is running" ]; then + echo "" + else + update_hooks "$PARENT_BAR_PID" 1 + playerctl --player=$PLAYER metadata --format "$FORMAT" + fi +fi + diff --git a/.config/polybar/scripts/menu.sh b/.config/polybar/scripts/menu.sh new file mode 100755 index 0000000..93f3779 --- /dev/null +++ b/.config/polybar/scripts/menu.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#FF6F00" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true \ +-hide-sidebar-mode true \ +-bw 0 \ +-lines 15 \ +-line-padding 10 \ +-padding 0 \ +-width 20 \ +-xoffset 7 -yoffset 28 \ +-location 1 \ +-columns 1 \ +-show-icons -icon-theme "Papirus" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" +#rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true -sidebar-mode false -bw 0 -lines 6 -line-padding 10 -padding 20 -width 30 -xoffset 7 -yoffset 25 -location 1 -columns 2 -show-icons -icon-theme "Papirus" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground + diff --git a/.config/polybar/scripts/menu.shsave b/.config/polybar/scripts/menu.shsave new file mode 100755 index 0000000..ea5bf8e --- /dev/null +++ b/.config/polybar/scripts/menu.shsave @@ -0,0 +1,63 @@ +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#FF6F00" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar false \ +-hide-sidebar-mode true \ +-bw 0 \ +-lines 15 \ +-line-padding 10 \ +-padding 0 \ +-width 20 \ +-xoffset 7 -yoffset 28 \ +-location 1 \ +-columns 1 \ +-show-icons -icon-theme "Papirus" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" +#rofi -no-lazy-grab -show drun -display-drun "Applications " -drun-display-format "{name}" -hide-scrollbar true -sidebar-mode false -bw 0 -lines 6 -line-padding 10 -padding 20 -width 30 -xoffset 7 -yoffset 25 -location 1 -columns 2 -show-icons -icon-theme "Papirus" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground + diff --git a/.config/polybar/scripts/menu_full.sh b/.config/polybar/scripts/menu_full.sh new file mode 100755 index 0000000..9f898a4 --- /dev/null +++ b/.config/polybar/scripts/menu_full.sh @@ -0,0 +1,65 @@ + +#!/bin/bash + +# Custom Rofi Script + +BORDER="#1F1F1F" +SEPARATOR="#1F1F1F" +FOREGROUND="#A9ABB0" +BACKGROUND="#1F1F1F" +BACKGROUND_ALT="#252525" +HIGHLIGHT_BACKGROUND="#FF6F00" +HIGHLIGHT_FOREGROUND="#FFFFFF" + +BLACK="#000000" +WHITE="#ffffff" +RED="#e53935" +GREEN="#43a047" +YELLOW="#fdd835" +BLUE="#1e88e5" +MAGENTA="#00897b" +CYAN="#00acc1" +PINK="#d81b60" +PURPLE="#8e24aa" +INDIGO="#3949ab" +TEAL="#00897b" +LIME="#c0ca33" +AMBER="#ffb300" +ORANGE="#fb8c00" +BROWN="#6d4c41" +GREY="#757575" +BLUE_GREY="#546e7a" +DEEP_PURPLE="#5e35b1" +DEEP_ORANGE="#f4511e" +LIGHT_BLUE="#039be5" +LIGHT_GREEN="#7cb342" + +# Launch Rofi +rofi -no-lazy-grab -show drun \ +-display-drun "Applications " -drun-display-format "{name}" \ +-hide-scrollbar true \ +-bw 0 \ +-lines 10 \ +-line-padding 15 \ +-padding 60 \ +-width 30 \ +-xoffset 10 -yoffset 40 \ +-location 1 \ +-fullscreen \ +-columns 4 \ +-show-icons -icon-theme "Papirus" \ +-font "Fantasque Sans Mono 10" \ +-color-enabled true \ +-color-window "$BACKGROUND,$BORDER,$SEPARATOR" \ +-color-normal "$BACKGROUND_ALT,$FOREGROUND,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-active "$BACKGROUND,$MAGENTA,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" \ +-color-urgent "$BACKGROUND,$YELLOW,$BACKGROUND_ALT,$HIGHLIGHT_BACKGROUND,$HIGHLIGHT_FOREGROUND" + +# More Options +# -fullscreen \ + +# Theming help +# color window = background, border, separator +# color normal = background, foreground, background-alt, highlight-background, highlight-foreground +# color active = background, foreground, background-alt, highlight-background, highlight-foreground +# color urgent = background, foreground, background-alt, highlight-background, highlight-foreground diff --git a/.config/polybar/scripts/now-playing.sh b/.config/polybar/scripts/now-playing.sh new file mode 100755 index 0000000..8fa6000 --- /dev/null +++ b/.config/polybar/scripts/now-playing.sh @@ -0,0 +1,217 @@ +#!/usr/bin/env python3 +import dbus +import signal +import time +from unicodedata import east_asian_width + +# Config options + +# (int) : Length of media info string. If length of string exceedes this value, the text will scroll. Default value is 20 +message_display_len = 20 + +# (int) : Font index of polybar. this value should be 1 more than the font value specified in polybar config. +font_index = 1 + +# (float) : Update speed of the text in seconds. +update_delay = 0.3 + +# (list) : list of chars containing previous, play, pause, next glyphs for media controls in respective order +control_chars = ['','','',''] + +# (dict) : dict of char icons to display as prefix. +# If player name is available as key, then use the corressponding icon, +# else default key value. +# example: +display_player_prefix = { + "spotify": ' ', + "firefox": ' ', + "default": ' ' +} + +# (list) : list of metadata fields based on mpris sepecification. +# For more details/ field names, refer [mpris sepecification](https://www.freedesktop.org/wiki/Specifications/mpris-spec/metadata/) +metadata_fields = ["xesam:title", "xesam:artist"] + +# (char) : separator for metadata fields +metadata_separator = "-" + +# (bool) : Hide text when no player is available? True disables the output for no players. +hide_output = False + +# Defult initialization +current_player = None +player_names = None +players = None +message = None +display_text = "" +display_prefix = " " +display_suffix = "" +last_player_name = None + +session_bus = dbus.SessionBus() + +def get_name(player_name ): + if player_name not in player_names: + return + name = ".".join(player_name.split(".")[3:]) + return name + +def get_name_by_index(index): + if index >= len(player_names): + return + return get_name(player_names[index]) + +def get_status(player): + status = "" + try: + status = player.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus', dbus_interface='org.freedesktop.DBus.Properties') + except Exception as e: + pass + return status + +def get_metadata(player): + metadata = {} + try: + metadata = player.Get('org.mpris.MediaPlayer2.Player', 'Metadata', dbus_interface='org.freedesktop.DBus.Properties') + except Exception as e: + pass + return metadata + +def update_prefix_suffix(player_name="", status=""): + global display_prefix, display_suffix, status_paused + + player_option = "" + if player_name != "": + player_option = "-p " + player_name + + prev_button = "%%{A:playerctl %s previous :}%c%%{A}" %(player_option,control_chars[0]) + play_button = "%%{A:playerctl %s play :}%c%%{A}" %(player_option,control_chars[1]) + pause_button = "%%{A:playerctl %s pause :}%c%%{A}" %(player_option,control_chars[2]) + next_button = "%%{A:playerctl %s next :}%c%%{A}" %(player_option,control_chars[3]) + + suffix = "| " + prev_button + if status == "Playing": + suffix += " "+pause_button + status_paused = False + else: + suffix += " "+play_button + status_paused = True + suffix += " "+next_button + # print(suffix) + display_suffix = suffix + + for key in display_player_prefix.keys(): + if key in player_name: + display_prefix = display_player_prefix[key] + break + else: + display_prefix = display_player_prefix["default"] + +def update_players(): + global player_names, players, session_bus, current_player, last_player_name + player_names = [service for service in session_bus.list_names() if service.startswith('org.mpris.MediaPlayer2.')] + players = [session_bus.get_object(service, '/org/mpris/MediaPlayer2') for service in player_names] + if last_player_name != get_name(current_player): + for index, player in enumerate(player_names): + if get_name(player) == last_player_name: + current_player = index + +def handle_event(*args): + global current_player, players, last_player_name + update_players() + if len(players) == 0: + return + current_player += 1 + current_player %= len(players) + last_player_name = getname_by_index(current_player) +# print("SIGUSR1: updated values - current_player = %d players len = %d"%(current_player,len(players))) + +def update_message(): + global players, current_player,player_names, message, display_text, message_display_len, display_suffix, last_player_name + if len(players) == 0: + tmp_message = "No player available" + update_prefix_suffix() + else: + name = get_name_by_index(current_player) + status = get_status(players[current_player]) + metadata_obj = get_metadata(players[current_player]) + metadata_string_list = [] + for field in metadata_fields: + result = metadata_obj.get(field) + if type(result) == dbus.Array: + result = result[0] + if not result: + result = "No "+field.split(":")[1] + metadata_string_list.append(str(result)) + metadata_string = (" "+metadata_separator+" ").join(metadata_string_list) + if visual_len(metadata_string) > message_display_len: + metadata_string = " " + metadata_string + " |" + update_prefix_suffix(name,status) + tmp_message = "" + if metadata_string: + tmp_message += str(metadata_string) + last_player_name = name + if message != tmp_message: + message = tmp_message + display_text = message + +def scroll(): + global display_text, message_display_len, status_paused + if not status_paused: + if len(display_text) > message_display_len: + display_text = display_text[1:] + display_text[0] + elif len(display_text) < message_display_len: + display_text += " "*(message_display_len - len(display_text)) + +def visual_len(text): + visual_length = 0 + for ch in text: + width = east_asian_width(ch) + if width == 'W' or width == 'F': + visual_length += 1 + visual_length += 1 + return visual_length + +def make_visual_len(text, visual_desired_length): + visual_length = 0 + altered_text = '' + for char in text: + if visual_length < visual_desired_length: + width = east_asian_width(char) + if width == 'W' or width == 'F': + visual_length += 2 + else: + visual_length += 1 + altered_text += char + else: + break + if visual_length == visual_desired_length + 1: + altered_text = altered_text[:-1] + ' ' + elif visual_length < visual_desired_length: + altered_text += ' ' * (visual_desired_length - visual_length) + return altered_text + +def print_text(): + global display_text, message_display_len, players, player_names, display_prefix, display_suffix + if hide_output and len(players)==0: + print("", flush = True) + return + scroll() + print(display_prefix + " " + + "%%{T%d}" % (font_index) + + make_visual_len(display_text, message_display_len) + + "%{T-}" + display_suffix, flush=True) + +def main(): + global current_player, players + update_players() + current_player = 0 + while True: + time.sleep(update_delay) + update_players() + update_message() + print_text() + +if __name__ == '__main__': + signal.signal(signal.SIGUSR1, handle_event) + main() diff --git a/.config/polybar/scripts/polybar_wrapper b/.config/polybar/scripts/polybar_wrapper new file mode 100755 index 0000000..901bb28 --- /dev/null +++ b/.config/polybar/scripts/polybar_wrapper @@ -0,0 +1,92 @@ +#!/bin/bash + +DIR=$(dirname $(realpath $0)) + +WINDOW_ID_CONKY=/tmp/conky_window_id +WINDOW_ID_TOP=/tmp/polybar_top_window_id +WINDOW_ID_EXPANDED=/tmp/polybar_expanded_window_id + +conky_launch() { + # Hacky X11 magic to make Conky appear above polybar + killall conky + # xdotool search can't find Conky's window but fortunately Conky outputs it + conky -c ~/.config/conky/config 2> /tmp/conky_out + # Extract the hex window id from Conky's output + HEX=$(awk '/drawing to created window/ {print $NF}' /tmp/conky_out | tr -d '()' | awk -Fx '{print $2}') + WIN_ID=$(( 16#$HEX )) # convert to decimal + xdotool windowunmap $WIN_ID + echo $WIN_ID > $WINDOW_ID_CONKY +} + +polybar_launch() { + killall polybar + + polybar top & + xdotool search --sync --pid $! > $WINDOW_ID_TOP + + polybar expanded & + xdotool search --sync --pid $! > $WINDOW_ID_EXPANDED + + bar_collapse +} + +launch() { + # Temporarily disable conky until I update the config + # conky_launch + # sleep 0.2 + polybar_launch +} + +bar_expand() { + xdotool windowmap $(cat $WINDOW_ID_EXPANDED) + xdotool windowunmap $(cat $WINDOW_ID_TOP) +} + +bar_collapse() { + xdotool windowunmap $(cat $WINDOW_ID_EXPANDED) + xdotool windowmap $(cat $WINDOW_ID_TOP) +} + +rofi_open() { + options_close + bar_expand & + rofi -modi run -show run + bar_collapse +} + +drun_open() { + bar_expand & + rofi -theme drun -modi drun -show drun -drun-categories Custom + bar_collapse +} + +search_open() { + options_close + bar_expand & + rofi -theme window -modi window -show window + bar_collapse +} + +options_open() { + bar_expand + $DIR/rofi_option_menu + bar_collapse + # echo "open" > /tmp/polybar_side_panel_state + # ID_CONKY=$(cat $WINDOW_ID_CONKY) + # xdotool windowmap $ID_CONKY + # xdotool windowraise $ID_CONKY + # ~/.config/i3/scripts/music_player show_applet +} + +case "$1" in + rofi) + rofi_open;; + search) + search_open;; + drun) + drun_open;; + options) + options_open;; + launch) + launch;; +esac diff --git a/.config/polybar/scripts/popup-calendar.sh b/.config/polybar/scripts/popup-calendar.sh new file mode 100755 index 0000000..4e5303c --- /dev/null +++ b/.config/polybar/scripts/popup-calendar.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +BAR_HEIGHT=22 # polybar height +BORDER_SIZE=1 # border size from your wm settings +YAD_WIDTH=222 # 222 is minimum possible value +YAD_HEIGHT=193 # 193 is minimum possible value +DATE="$(date +"%a %d %b, %H:%M")" + +case "$1" in +--popup) + if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then + exit 0 + fi + + eval "$(xdotool getmouselocation --shell)" + eval "$(xdotool getdisplaygeometry --shell)" + + # X + if [ "$((X + YAD_WIDTH / 2 + BORDER_SIZE))" -gt "$WIDTH" ]; then #Right side + : $((pos_x = WIDTH - YAD_WIDTH - BORDER_SIZE)) + elif [ "$((X - YAD_WIDTH / 2 - BORDER_SIZE))" -lt 0 ]; then #Left side + : $((pos_x = BORDER_SIZE)) + else #Center + : $((pos_x = X - YAD_WIDTH / 2)) + fi + + # Y + if [ "$Y" -gt "$((HEIGHT / 2))" ]; then #Bottom + : $((pos_y = HEIGHT - YAD_HEIGHT - BAR_HEIGHT - BORDER_SIZE)) + else #Top + : $((pos_y = BAR_HEIGHT + BORDER_SIZE)) + fi + + yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \ + --width="$YAD_WIDTH" --height="$YAD_HEIGHT" --posx="$pos_x" --posy="$pos_y" \ + --title="yad-calendar" --borders=0 >/dev/null & + ;; +*) + echo "$DATE" + ;; +esac diff --git a/.config/polybar/scripts/rofi-power.sh b/.config/polybar/scripts/rofi-power.sh new file mode 100755 index 0000000..87ac92c --- /dev/null +++ b/.config/polybar/scripts/rofi-power.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh +# +# A rofi powered menu to execute power related action. +# Uses: amixer mpc poweroff reboot rofi rofi-prompt + +power_off='' +reboot='' +lock='' +suspend='鈴' +log_out='' + +chosen=$(printf '%s;%s;%s;%s;%s\n' "$power_off" "$reboot" "$lock" "$suspend" \ + "$log_out" \ + | rofi -theme '~/.config/rofi/themes/power.rasi' \ + -dmenu \ + -sep ';' \ + -selected-row 2) + +case "$chosen" in + "$power_off") + rofi-prompt --query 'Shutdown?' && poweroff + ;; + + "$reboot") + rofi-prompt --query 'Reboot?' && reboot + ;; + + "$lock") + # TODO Add your lockscreen command. + ;; + + "$suspend") + # Pause music and mute volume before suspending. + mpc --quiet pause + amixer set Master mute + # TODO Add your suspend command. + ;; + + "$log_out") + # TODO Add your log out command. + ;; + + *) exit 1 ;; +esac + diff --git a/.config/polybar/scripts/scroll_spotify_status.sh b/.config/polybar/scripts/scroll_spotify_status.sh new file mode 100755 index 0000000..74e0bfd --- /dev/null +++ b/.config/polybar/scripts/scroll_spotify_status.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# see man zscroll for documentation of the following parameters +zscroll -l 20 \ + --delay 0.1 \ + --scroll-padding " " \ + --match-command "$HOME/.config/polybar/scripts/get_spotify_status.sh --status" \ + --match-text "Playing" "--scroll 1" \ + --match-text "Paused" "--scroll 0" \ + --update-check true "$HOME/.config/polybar/scripts/get_spotify_status.sh" & + +wait diff --git a/.config/polybar/scripts/sysmenu.sh b/.config/polybar/scripts/sysmenu.sh new file mode 100755 index 0000000..721bc1d --- /dev/null +++ b/.config/polybar/scripts/sysmenu.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# display a power menu to: shutdown, reboot, +# lock, logout, and suspend. This script can be +# executed by clicking on the polybar powermenu module +# or with a keyboard shortcut + + +# options to be displayed +shutdown=" Shutdown" +reboot=" Reboot" +lock=" Lock" +logout=" Logout" +suspend=" Suspend" + +uptime=$(uptime -p | sed -e 's/up //g') + +# options passed into variable +options="$shutdown\n$reboot\n$lock\n$logout\n$suspend" + +chosen="$(echo -e "$options" | rofi -no-lazy-grab -sep -lines 5 -hide-scrollbar true -border 0 -padding 0 -height 2px -width 15 -xoffset -8 -yoffset 28 -location 3 -columns 1 -dmenu -p 'System ' "$uptime")" + +case $chosen in +$shutdown) + systemctl poweroff + ;; +$reboot) + systemctl reboot + ;; +$lock) + betterlockscreen --lock dimblur + ;; +$logout) + bspc quit + ;; +$suspend) + systemctl suspend + ;; +esac + diff --git a/.config/polybar/scripts/sysmenu.shsave b/.config/polybar/scripts/sysmenu.shsave new file mode 100755 index 0000000..00ce125 --- /dev/null +++ b/.config/polybar/scripts/sysmenu.shsave @@ -0,0 +1,40 @@ +#!/bin/bash + +# display a power menu to: shutdown, reboot, +# lock, logout, and suspend. This script can be +# executed by clicking on the polybar powermenu module +# or with a keyboard shortcut + + +# options to be displayed +shutdown=" Shutdown" +reboot=" Reboot" +lock=" Lock" +logout=" Logout" +suspend=" Suspend" + +uptime=$(uptime -p | sed -e 's/up //g') + +# options passed into variable +options="$shutdown\n$reboot\n$lock\n$logout\n$suspend" + +chosen="$(echo -e "$options" | rofi -no-lazy-grab -sep -lines 5 -hide-scrollbar true -border 0 -padding 0 -height 2px -width 15 -xoffset -10 -yoffset 28 -location 3 -columns 1 -dmenu -p 'System ' "$uptime")" + +case $chosen in +$shutdown) + systemctl poweroff + ;; +$reboot) + systemctl reboot + ;; +$lock) + betterlockscreen --lock dimblur + ;; +$logout) + bspc quit + ;; +$suspend) + systemctl suspend + ;; +esac + diff --git a/.config/polybar/scripts/system-usb-mount.sh b/.config/polybar/scripts/system-usb-mount.sh new file mode 100755 index 0000000..63e9187 --- /dev/null +++ b/.config/polybar/scripts/system-usb-mount.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +devices=$(lsblk -Jplno NAME,TYPE,RM,SIZE,MOUNTPOINT,VENDOR) + +case "$1" in + --mount) + for mount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do + udisksctl mount --no-user-interaction -b "$mount" + + mountpoint=$(udisksctl mount --no-user-interaction -b $mount) + mountpoint=$(echo $mountpoint | cut -d " " -f 4- | tr -d ".") + kitty -e "bash -lc 'pcmanfm $mountpoint'" & + done + ;; + --unmount) + for unmount in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .name'); do + udisksctl unmount --no-user-interaction -b "$unmount" + udisksctl power-off --no-user-interaction -b "$unmount" + done + ;; + *) + output="" + counter=0 + + for unmounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint == null) | .name'); do + unmounted=$(echo "$unmounted" | tr -d "[:digit:]") + unmounted=$(echo "$devices" | jq -r '.blockdevices[] | select(.name == "'"$unmounted"'") | .vendor') + unmounted=$(echo "$unmounted" | tr -d ' ') + + if [ $counter -eq 0 ]; then + space="" + else + space=" " + fi + counter=$((counter + 1)) + + output="$output$space#1 $unmounted" + done + + for mounted in $(echo "$devices" | jq -r '.blockdevices[] | select(.type == "part") | select(.rm == true) | select(.mountpoint != null) | .size'); do + if [ $counter -eq 0 ]; then + space="" + else + space=" " + fi + counter=$((counter + 1)) + + output="$output$space#2 $mounted" + done + + echo "$output" + ;; +esac diff --git a/.config/polybar/scripts/toggle_bluetooth.sh b/.config/polybar/scripts/toggle_bluetooth.sh new file mode 100755 index 0000000..899d5ec --- /dev/null +++ b/.config/polybar/scripts/toggle_bluetooth.sh @@ -0,0 +1,8 @@ +#!/bin/sh +if [ $(bluetoothctl show | grep "Powered: yes" | wc -c) -eq 0 ] +then + bluetoothctl power on +else + bluetoothctl power off +fi + diff --git a/.config/sxhkd/show_help.sh b/.config/sxhkd/show_help.sh new file mode 100755 index 0000000..bd0cd6c --- /dev/null +++ b/.config/sxhkd/show_help.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cat ~/.config/sxhkd/sxhkdrc | awk '/^[a-z]/ && last {print $0,"\t",last} {last=""} /^#/{last=$0}' | column -t -s $'\t' | rofi -dmenu -i -no-show-icons -width 1000 + diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc new file mode 100755 index 0000000..7d7ef9a --- /dev/null +++ b/.config/sxhkd/sxhkdrc @@ -0,0 +1,486 @@ +# +# wm independent hotkeys +# + + +# help +super + F1 + ~/.config/sxhkd/show_help.sh -m -3 + +# application menu +super + a + ~/.config/polybar/scripts/menu.sh + +# shutdown menu +ctrl + alt + Delete + ~/.config/polybar/scripts/sysmenu.sh + +# run launcher +super + r + rofi -show run + +# toggle sticky +#super + q +# bspc node -g sticky=on + +# Scratchpad Terminal +super + e + ~/.local/bin/scripts/Heads-Up-Display + +super + {equal,minus} + layer.sh {+,-} + +# Scratchpad +super + semicolon + ~/.local/bin/scripts/scratchpad + +super + x + ~/.local/bin/scripts/scratchpad + +#{~/.local/bin/scripts/scratchpad, bspc rule -a \* -o state=floating sticky=on floating=on rectangle=680x260+340+460} +#sid=$(cat /tmp/scratchID);\ +#cid=$(cat /tmp/calcID);\ +#wmctrl -ir $sid -b toggle,hidden && wmctrl -ir $cid -b add,hidden; wmctrl -ia $sid + +#super + apostrophe +# {~/.local/bin/scripts/scratchpad, bspc rule -a \* -o state=floating sticky=on floating=on rectangle=680x700+340+40} + + +#super + x +# ~/.local/bin/scripts/scratchpad + +# open st (simple terminal) +#super + colon +# st + +# Bitwarden-rofi +super + shift + b + rofi-rbw + #bwmenu -c 15 + +# thunderbird mail +#super + shift + m +# thunderbird + +# discord +super + shift + d + discord + +# Spotify +super + shift + y + spotify + +# lockscreen +super + Escape + betterlockscreen -l + +# Show clipmenu +alt + x + rofi -modi "clipboard:greenclip print" -show clipboard -run-command '{cmd}' \ + -location 1 \ + -m -3 \ + -no-show-icons \ + -theme-str '* \{ font: 10px; \}' \ + -theme-str 'listview \{ spacing: 0; \}' \ + -theme-str 'window \{ width: 20em; \}' + +# terminal emulator +super + Return +#super + x + alacritty + #urxvt + #$TERMINAL + +super + shift + z + zathura + +# program launcher +super + @space + rofi -show drun + +# task switcher +alt + Tab + rofi -show window + +# browser +super + w + $BROWSER + +# neovim +#super + v +# kitty -e nvim + +# alacritty +#super + x +# kitty + +# file manager nnn +super + n + $TERMINAL -e nnn + +# file manager ranger +super + shift + r + $TERMINAL -e ranger + +# file manager pcmanfm (GUI) +super + shift + f + pcmanfm + +# Dictionary +super + ctrl + w + goldendict + +# Thesaurus +super + shift + w + artha + +# screenshots tool (selection) +ctrl + Print + flameshot gui -p ~/pictures/screenshots + +# screenshots tool (screen) +shift + Print + flameshot full -p ~/pictures/screenshots + +# turn off compositor +super + shift + p + toggleprogram "picom" "--experimental-backends" + +#picom-trans -c -10 +#picom-trans -c +10 + +# make sxhkd reload its configuration files: +super + ctrl + x + pkill -USR1 -x sxhkd; dunstify "Sxhkd configuration reloaded" + + +# +# bspwm hotkeys +# + +# quit/restart bspwm +super + alt + shift + {q,r} + bspc {quit,wm -r} +#super + alt + {q,r} +# bspc {quit,wm -r} + + +# launch eww +#super + ctrl + a +# ~/.config/eww/launch_widgets.sh + + +# close and kill +super + d + bspc node -c + +# alternate between the tiled and monocle layout +super + m + bspc desktop -l next + + +# send the newest marked node to the newest preselected node +super + y + bspc node newest.marked.local -n newest.!automatic.local + +# swap the current node and the biggest window +super + g + bspc node -s biggest.window + +# +# state/flags +# + +# set the window state +#super + {t,shift + t,s,f} +# bspc node -t {tiled,pseudo_tiled,floating,fullscreen} + +# set the window state +super + {t,shift + t,s} + bspc node -t {tiled,pseudo_tiled,floating}; \ + xdo raise -N Plank; \ + xdo raise -N '*:*:Picture in picture'; \ + xdo raise -N "Picture-in-Picture" +# xdo raise -N Plank; \ +# xdo raise -a polybar-left_LVDS-1; \ +# xdo raise -a polybar-bottom_LVDS-1 + + #polybar-msg cmd show + + +#xdo raise -p $(pidof polybar-bottom_LDVS-1) +#bspc node -t \~fullscreen +super + {f} + bspc node -t \~fullscreen + #bspc window -t floating=off; \ + #bspc node -t {fullscreen}; \ + #xdo lower -N Plank +# xdo lower -N Plank; \ +# xdo lower -a polybar-left_LVDS-1; \ +# xdo lower -a polybar-bottom_LVDS-1 + #bspc node -t \~{fullscreen}; \ + +# set the node flags +super + ctrl + {m,x,y,z} + bspc node -g {marked,locked,sticky,private} + +# +# focus/swap +# + +# focus the node in the given direction +super + {_,shift + }{h,j,k,l} + bspc node -{f,s} {west,south,north,east} + +# focus the node for the given path jump +#super + {p,b,comma,period} +# bspc node -f @{parent,brother,first,second} + +# focus the next/previous window in the current desktop +super + {_,shift + }c + bspc node -f {next,prev}.local.!hidden.window + +# focus the next/previous desktop in the current monitor +super + bracket{left,right} + bspc desktop -f {prev,next}.local + +# focus the last node/desktop +super + {grave,Tab} + bspc {node,desktop} -f last + +# focus the older or newer node in the focus history +#super + {o,i} +# bspc wm -h off; \ +# bspc node {older,newer} -f; \ +# bspc wm -h on + +# focus or send to the given desktop +super + {_,shift + }{1-9,0} + bspc {desktop -f,node -d} '^{1-9,10}' + +# Hide/Unhide Window +#super + p +# ~/.local/bin/scripts/winhide.sh + +# hide window +super + comma + bspc node -g hidden + +# unhide window +super + period + ${HOME}/.config/bspwm/bspcmd unhide + +# +# preselect +# + +# preselect the direction +super + ctrl + {h,j,k,l} + bspc node -p {west,south,north,east} + +# preselect the ratio +super + ctrl + {1-9} + bspc node -o 0.{1-9} + +# cancel the preselection for the focused node +super + ctrl + space + bspc node -p cancel + +# cancel the preselection for the focused desktop +super + ctrl + shift + space + bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel + +# Close all receptacle +super + shift + i + for win in `bspc query -N -n .leaf.\!window`; do bspc node $win -k ; done; + +# Insert receptacle +super + i; {h,j,k,l} + bspc node --presel-dir {west,south,north,east} -i + +# Move to rectacle +super + ctrl + i + bspreceptacle + +# Balance nodes +super + alt + i + bspc node @/ -B + +# +# move/resize +# + +# Move a floating window or swap with any other adjacent tiled/pseudo_tiled window +ctrl + alt + {h,j,k,l} + { dir=west dx=-20 dy=0 \ + , dir=south dx=0 dy=20 \ + , dir=north dx=0 dy=-20 \ + , dir=east dx=20 dy=0 \ + }; \ + bspc node --move "$dx" "$dy" || bspc node --swap $dir + +#shift + alt + {h,j,k,l} +shift + alt + {h,j,k,l} + bspwm_resize.sh {west,south,north,east} + +super + shift + s + bspc node -t pseudo_tiled; bspc node -t floating && wtp 340 40 680 700 "$(pfw)" + +# floating into similar monocle layout +super + shift + m + bspc node -t pseudo_tiled; bspc node -t floating && wtp 10 40 1342 716 "$(pfw)" + #bspc node -t pseudo_tiled; bspc node -t floating && wtp 1 26 1360 735 "$(pfw)" + +#super + shift + z +# bspc node -t floating && wtp 340 40 680 700 "$(pfw)" + +# Spawn next window/program in floating mode +ctrl + alt + 1 + bspc rule -a '*' -o state=floating rectangle=680x700+340+40 +# Spawn next window/program in smaller scratchpad like floating mode +ctrl + alt + 2 + bspc rule -a '*' -o state=floating rectangle=478x291+656+214 +#super + e : {h,j,k,l} +# bspwm_resize.sh expand {west,south,north,east} 50 +# +#super + shift + e : {h,j,k,l} +# bspwm_resize.sh contract {west,south,north,east} 50 +#super + colon +# bspc rule -a scratchpad -o state=floating rectangle=680x700+340+40 +# resize floating windows +#shift + alt + {h,j,k,l} +# xdo resize {-w -20,-h +20,-h -20,-w +20} +# resize floating windows +#shift + alt + {h,j,k,l} +# xdo resize {-w -20,-h +20,-h -20,-w +20} + +# resize windows i3 style +#shift + alt + {h,j,k,l} +# ;bash ~/.config/sxhkd/resize {x -, y +, y -, x +} + +# expand a window by moving one of its side outward +#alt + shift + {h,j,k,l} +# bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0} + +# contract a window by moving one of its side inward +#alt + ctrl + {h,j,k,l} +# bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0} +# expand/contract a window + +#alt + shift + {h,j,k,l} +# bspc node -z {left -20 0 || bspc node -z right -20 0, \ +# bottom 0 20 || bspc node -z top 0 20,\ +# top 0 -20 || bspc node -z bottom 0 -20,\ +# right 20 0 || bspc node -z left 20 0} + +# move a floating window +#ctrl + alt + {h,j,k,l} +# bspc node -v {-20 0,0 20,0 -20,20 0} + + +# move a floating window +#super + {Left,Down,Up,Right} + +# move a tiled window to any direction +super + shift + {h,j,k,l} + /path/to/bspwm_smart_move {west,south,north,east} + +# rotate windows to different nodes +super + ctrl + r + bspc node @parent -R 90 + +################################## +# Control Multimedia # +################################## + +#super + {F6,F7,F8} +# playerctl {previous,play-pause,next} + +{XF86AudioStop,XF86AudioPlay,XF86AudioPrev,XF86AudioNext} + playerctl {stop,play-pause,previous,next} + +alt + shift + {Left,Up,Right} + playerctl {previous,play-pause,next} + + +# Brightness control +XF86MonBrightness{Up,Down} + brightnessctl s 5%{+,-} + +alt + {Up,Down} + brightnessctl s 5%{+,-} + + +# Volume control +XF86Audio{Raise,Lower}Volume + pulsemixer --change-volume {+,-}10 + +alt + {Right,Left} + pulsemixer --change-volume {+,-}10 + + + +##################################### +# MPC-MPD Multimedia Keybindings # +##################################### + +super + {XF86AudioPrev,XF86AudioPlay,XF86AudioStop,XF86AudioNext} + mpc {prev,toggle,stop,next} + + +# xdotool {{{ + +# move mouse cursor +alt + {a,s,w,d,q,e,z,c} + xdotool mousemove_relative --sync {-- -24 0, 0 24, -- 0 -24, 24 0, -- -24 -24, -- 24 -24, -- -24 24,-- 24 24} + +# move mouse cursor with extra jump size +ctrl + alt + {a,s,w,d,q,e,z,c} + xdotool mousemove_relative --sync {-- -48 0, 0 48, -- 0 -48, 48 0, -- -48 -48, -- 48 -48, -- -48 48,-- 48 48} + +# move mouse cursor with lower jump size +shift + alt + {a,s,w,d,q,e,z,c} + xdotool mousemove_relative --sync {-- -8 0, 0 8, -- 0 -8, 8 0, -- -8 -8, -- 8 -8, -- -8 8,-- 8 8} + +# emulate left mouse click +alt + i + xdotool click --clearmodifiers 1 +#alt + q +# xdotool click --repeat 2 1 + +# emulate left mouse click select +alt + shift + i + xdotool mousedown 1 sleep 0.5 mousemove_relative --sync {-- -8 0, 0 8, -- 0 -8, 8 0} sleep 0.5 mouseup 1 + +# emulate mouse scroll button +alt + p + xdotool click --clearmodifiers 2 + +# emulate mouse right click +alt + o + xdotool click --clearmodifiers 3 + +# emulate mouse scroll up +alt + m + xdotool click --clearmodifiers 4 + +# emulate mouse scroll down +alt + n + xdotool click --clearmodifiers 5 + +# emulate home key +alt + ctrl + Left + xdotool keyup Left key --clearmodifiers Home + +# emulate end key +alt + ctrl + Right + xdotool keyup Right key --clearmodifiers End + +# emulate delete key +~alt + BackSpace + xte 'keyup Alt_L' 'key Delete' 'keydown Alt_L' + +# Emulate home/end keys +#ctrl + alt + @{Up,Down} +# xte 'keyup Control_L' 'keyup Alt_L' 'key {Home,End}' + diff --git a/.config/tmux/left-status.sh b/.config/tmux/left-status.sh new file mode 100755 index 0000000..afceea8 --- /dev/null +++ b/.config/tmux/left-status.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +function ip-address() { + # Loop through the interfaces and check for the interface that is up. + for file in /sys/class/net/*; do + iface=$(basename $file); + read status < $file/operstate; + [ "$status" == "up" ] && ip addr show $iface | awk '/inet /{printf $2" "}' + done +} + +function vpn-connection() { + # Check for tun0 interface. + [ -d /sys/class/net/tun0 ] && printf "%s " 'VPN*' +} + +function main() { + # Comment out any function you do not need. + ip-address + vpn-connection +} + +# Calling the main function which will call the other functions. +main diff --git a/.config/tmux/right-status.sh b/.config/tmux/right-status.sh new file mode 100755 index 0000000..82502c4 --- /dev/null +++ b/.config/tmux/right-status.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +function memory-usage() { + if [ "$(which bc)" ]; then + # Display used, total, and percentage of memory using the free command. + read used total <<< $(free -m | awk '/Mem/{printf $2" "$3}') + # Calculate the percentage of memory used with bc. + percent=$(bc -l <<< "100 * $total / $used") + # Feed the variables into awk and print the values with formating. + awk -v u=$used -v t=$total -v p=$percent 'BEGIN {printf "%s/%s Mem %.1f% ", t, u, p}' + fi +} + +function main() { + # Comment out any function you do not need. + memory-usage +} + +# Calling the main function which will call the other functions. +main diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf new file mode 100644 index 0000000..3085f2b --- /dev/null +++ b/.config/tmux/tmux.conf @@ -0,0 +1,306 @@ +# ████████╗███╗ ███╗██╗ ██╗██╗ ██╗ +# ╚══██╔══╝████╗ ████║██║ ██║╚██╗██╔╝ +# ██║ ██╔████╔██║██║ ██║ ╚███╔╝ +# ██║ ██║╚██╔╝██║██║ ██║ ██╔██╗ +# ██║ ██║ ╚═╝ ██║╚██████╔╝██╔╝ ██╗ +# ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ +#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― +# Setting the prefix from C-b to C-s +unbind C-b +set -g prefix C-s +# Ensure that we can send Ctrl-S to other apps +bind C-s send-prefix +#set -g prefix M-Space +#set -g prefix C-Space +#setting the delay between prefix and command +set-option -sg escape-time 10 +#set -s escape-time 0 +# Vi mode in tmux, can confirm this working by pressing <prefix>:list-keys -T copy-mode-vi +# <prefix>[ to enter copy-mode to allow copying text or view history buffer, including search with / and ?. Screenwise vertical movemont with <ctrl-f> or <ctrl-b> +set-window-option -g mode-keys vi +# Reload the file with Prefix r +#bind r source-file ~/.tmux.conf \; display "Reloaded!" +bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!" +#set -g history-limit 10000 + +# use the mouse +#set-window-option -g mode-mouse on +#set -g mouse-select-pane on +#set -g mouse-resize-pane on +#set -g mouse-select-window on + +# pane movement +bind-key j command-prompt -p "send pane to:" "join-pane -t '%%'" + +# Pane resizing, default is D,U,L,R +bind -r H resize-pane -L 20 +bind -r J resize-pane -D 20 +bind -r K resize-pane -U 20 +bind -r L resize-pane -R 20 + +bind-key M-j resize-pane -D 5 +bind-key M-k resize-pane -U 5 +bind-key M-h resize-pane -L 5 +bind-key M-l resize-pane -R 5 + +# Hide a pane and bring it back with <prefix>! and <prefix>@ respectively +bind-key ! break-pane -d -n _hidden_pane +bind-key @ join-pane -s $.0 +# enable activity alerts +#setw -g monitor-activity on +#set -g visual-activity on + +# Update the status bar every sixty seconds +#set -g status-interval 60 + +# set colors for the active window +#setw -g window-status-current-fg white +#setw -g window-status-current-bg red +#setw -g window-status-current-attr bright +#set -g status-style fg="#000000",bg="#53E2AE" +#set -g pane-active-border-style bg=default,fg="#fe8019" +#set -g pane-border-style fg="#53E2AE" + +## COLOUR (Solarized light) + +## default statusbar colors +#set-option -g status-bg default +#set-option -g status-fg green +#set-option -g status-attr default +# +## default window title colors +#set-window-option -g window-status-fg magenta +#set-window-option -g window-status-bg default +#set-window-option -g window-status-attr dim +# +#set -g status-left-length 85 +#set -g status-left "#[fg=yellow bg=default]#h #[fg=blue] #S #[fg=yellow] #I " +#set -g window-status-current-format "#[fg=black,bold bg=default]│#[fg=white bg=cyan]#W#[fg=black,bold bg=default]│" +#set -g status-right "#[fg=magenta] #[bg=gray] %b %d %Y %l:%M %p" +#set -g status-justify centre + + +# active window title colors +#set-window-option -g window-status-current-fg cyan +#set-window-option -g window-status-current-bg default +#set-window-option -g window-status-current-attr bright + + +# pane border +# set-option -g pane-border-fg black +# set-option -g pane-border-bg black +# set-option -g pane-active-border-fg red +# set-option -g pane-active-border-bg default +# allow 'autoread' to work in neovim by focus events +# focus events enabled for terminals that support them +set-option -g focus-events on + +# super useful when using "grouped sessions" and multi-monitor setup +setw -g aggressive-resize on + + + +set -g mouse on + +# Vi mode in tmux, can confirm this working by pressing <prefix>:list-keys -T copy-mode-vi +# <prefix>[ to enter copy-mode to allow copying text or view history buffer, including search with / and ?. Screenwise vertical movemont with <ctrl-f> or <ctrl-b> +set-window-option -g mode-keys vi + + +# change selection <space> and enter to vi keybinding +#bind-key -T copy-mode-vi 'v' send -X begin-selection +#bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel + +# X clipboard integration +# Vim style +#bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -i -sel clip > /dev/null" + +#for copying to sys clipboard +#bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard" +#bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard" +#bind -T copy-mode-vi C-c send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard" + +# map copy mode to ctrl+alt+v +bind-key -n 'M-v' copy-mode + +bind-key -T copy-mode-vi v send -X begin-selection + +if-shell -b 'echo $XDG_SESSION_TYPE | grep -q x11' "\ + bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \ + bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard > /dev/null'; \ + bind-key C-M-v run 'xclip -out -selection clipboard | tmux load-buffer - ; tmux paste-buffer'" + +if-shell -b 'echo $XDG_SESSION_TYPE | grep -q wayland' "\ + bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'wl-copy'; \ + bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'wl-copy'; \ + bind-key C-p run 'wl-paste --no-newline | tmux load-buffer - ; tmux paste-buffer'" "\ + \ + bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'cat - >/dev/clipboard'; \ + bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'cat - >/dev/clipboard'; \ + bind-key C-M-v run 'cat /dev/clipboard | tmux load-buffer - ; tmux paste-buffer'" + + + + +# Vim style copy to clipboard +#bind-key p run "xclip -o -sel clip | tmux load-buffer - ; tmux paste-buffer" + + +# Change split <Prefix>% and <Prefix>" to <Prefix>| and <Prefix>- +bind v split-window -h -c "#{pane_current_path}" +bind h split-window -v -c "#{pane_current_path}" +#bind-key v split-window -h +#bind-key s split-window -v + + +# smart pane switching with awareness of vim splits +bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L" +bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D" +bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U" +bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R" +#bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l" + +# use prefix + l to clear terminal +bind C-l send-keys 'C-l' +## set the default TERM +#set-option -g default-terminal "screen-256color" +#set-option -g default-terminal "tmux-256color" +#set -g default-terminal screen +# update the TERM variable of terminal emulator when creating a new session or attaching a existing session +#set -g update-environment 'DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY TERM' +# determine if we should enable 256-colour support +#if "[[ ${TERM} =~ 256color || ${TERM} == fbterm ]]" 'set -g default-terminal screen-256color' +#set -g default-terminal "tmux-256color" +#set -ga terminal-overrides ",xterm-256color:Tc" +#set-option -g default-terminal "tmux-256color" +set-option -sa terminal-overrides ",tmux-256color:Tc" +#set-option -sa terminal-overrides ",xterm*:Tc" +set-option -sa terminal-overrides ",xterm*:Tc,alacritty*:Tc" +# Enable RGB colour if running in xterm(1) +#set-option -sa terminal-overrides ",xterm*:Tc" +#set -ga terminal-overrides ",*256col*:Tc" + +## Detach from current session +#bind -n M-d detach-client +# +## Popup scratch session +#bind -n M-g display-popup -E "tmux new-session -A -s scratch" +# +## non-popup +#bind C-j new-window -n "session-switcher" "\ +# tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ +# sed '/^$/d' |\ +# fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ +# xargs tmux switch-client -t" +## popup +#bind C-j display-popup -E "\ +# tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ +# sed '/^$/d' |\ +# fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ +# xargs tmux switch-client -t" +#bind -n M-f display-popup -E "\ +# tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\ +# sed '/^$/d' |\ +# fzf --reverse --header jump-to-session --preview 'tmux capture-pane -pt {}' |\ +# xargs tmux switch-client -t" +# +#bind -n M-? list-keys +#bind -n M-1 select-window -t :=1 +#bind -n M-2 select-window -t :=2 +#bind -n M-3 select-window -t :=3 +#bind -n M-4 select-window -t :=4 +#bind -n M-5 select-window -t :=5 +#bind -n M-6 select-window -t :=6 +#bind -n M-7 select-window -t :=7 +#bind -n M-8 select-window -t :=8 +#bind -n M-9 select-window -t :=9 +#bind -n M-0 select-window -t :=0 + +# Colors for pane borders(default) +setw -g pane-border-style fg=white +setw -g pane-active-border-style fg=green + +# Active pane normal, other shaded out +setw -g window-style fg=colour240 +setw -g window-active-style fg=white + + +#set -g focus-events on +#set -g status-style bg=default +# Set the position of window lists +#set -g status-justify centre +# Set the status bar position +set -g status-position bottom # [top, bottom] +set -g status on +set -g status-interval 1 + + +set -g status-style fg=#50fa7b,bg=black +#set -g status-style fg=DeepSkyBlue1,bg=black +#set -g status-style fg=black,bg=gray + +#set -g status-left-style default +# Display the session name +#set -g status-left "#[fg=green] ❐ #S #[default]" + +## Left +#set -g status-left '' +set -g status-left-length 60 +set -g status-left "#[fg=#50fa7b] ❐ #S #( ~/.config/tmux/left-status.sh )" +bind o set-option status-left "#[fg=#50fa7b] ❐ #S" # toggle left-status script off +bind C-o set-option status-left "#[fg=#50fa7b] ❐ #S #( ~/.config/tmux/left-status.sh )" # toggle left status script on +#set -g status-left "#[fg=DeepSkyBlue1] ❐ #S #( ~/.config/tmux/left-status.sh )" +#set -g status-left "#[fg=black] ❐ #S #( ~/.config/tmux/left-status.sh )" + +# Highlight the current window. +setw -g window-status-current-style fg=#50fa7b,bg=black,bright +#setw -g window-status-current-style fg=DeepSkyBlue1,bg=black,bright +#setw -g window-status-current-style fg=color235,bg=silver,bright +set -g window-status-current-format ' #I:#W ' +#set -g status-format[0] '#[align=left] ❐ #S #( ~/.config/tmux/left-status.sh )#[align=absolute-centre]#[list=on] #I #W #[nolist]#[align=right] %H:%M %d-%m-%Y #H ' +set -g status-justify absolute-centre +## Right +# Set right side status bar length and style +set-option -g status-right "" +set -g status-right-length 60 +#set -g status-right-length 140 +#set -g status-right-style default +#set -ag status-right "#[fg=black] %H:%M %d-%m-%Y #H " +set -ag status-right "#[fg=#50fa7b] #{?client_prefix,#[reverse] Prefix #[noreverse] ,} #( ~/.config/tmux/right-status.sh ) %H:%M %d-%m-%Y #H " +#set -ag status-right "#[fg=DeepSkyBlue1] #( ~/.config/tmux/right-status.sh ) %H:%M %d-%m-%Y #H " +#set -ag status-right "#[fg=black] #( ~/.config/tmux/right-status.sh ) %H:%M %d-%m-%Y #H " + +# list of plugins +set -g @plugin 'tmux-plugins/tpm' +#set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'tmux-plugins/tmux-resurrect' +set -g @plugin 'tmux-plugins/tmux-continuum' +set -g @plugin 'christoomey/vim-tmux-navigator' +#set -g @plugin 'tmux-plugins/tmux-yank' + + +# Plugins settings +# Plugin to save and restore tmux sessions after restart +# * Save with: prefix + Ctrl-s +# * Restore with: prefix + Ctlr-r + # restore vim and nvim sessions as well + # for vim + set -g @resurrect-strategy-vim 'session' + # for neovim + set -g @resurrect-strategy-nvim 'session' +# Automatic restore + set -g @continuum-restore 'on' +# Change default save and restore keybindings + set -g @resurrect-save 'W' + set -g @resurrect-restore 'E' +# set -g @continuum-boot 'on' +## Restore Panes +# set -g @resurrect-capture-pane-contents 'on' +# This a hook for tmux-resurrect which tells it to kill session 0 before restoring the panels +set -g @resurrect-hook-pre-restore-pane-processes 'tmux switch-client -n && tmux kill-session -t=0' +# plugin uninstall + # Delete or comment out the plugin in .tmux.conf. + # Press <prefix> + alt + u to remove the plugin. +# TMUX plugin manager (keep at the bottom of tmux.conf) +#run -b '~/.tmux/plugins/tpm/tpm' +run -b '~/.config/tmux/plugins/tpm/tpm' diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile new file mode 100644 index 0000000..8ab0499 --- /dev/null +++ b/.config/zsh/.zprofile @@ -0,0 +1,5 @@ +if [[ "$(tty)" = "/dev/tty1" ]]; then + pgrep bspwm || startx "$XDG_CONFIG_HOME/X11/xinitrc" +fi + +#eval "$(gh completion -s zsh)" diff --git a/.config/zsh/.zshenv b/.config/zsh/.zshenv new file mode 100644 index 0000000..abacc95 --- /dev/null +++ b/.config/zsh/.zshenv @@ -0,0 +1,155 @@ + +#export XINITRC="$HOME/.config/X11/.xinitrc" +#export INPUTRC="${XDG_CONFIG_HOME:-$HOME/.config}/X11/.inputrc" +#export ZDOTDIR="${XDG_CONFIG_HOME:-$HOME/.config}/zsh" +#export XAUTHORITY="$XDG_RUNTIME_DIR/.Xauthority" # This line will break some DMs. +#export XINITRC="$XDG_CONFIG_HOME"/X11/xinitrc +#export XAUTHORITY="$XDG_RUNTIME_DIR"/Xauthority + +# Path +#export PATH="$PATH:${$(find ~/.local/bin ~/.local/share/npm/bin -type d -printf %p:)%%:}" +export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local:$HOME/.local/bin:$HOME/.local/bin/scripts:$HOME/Scripts:$HOME/.local/bin/statusbar + + +# Default Programs: +export EDITOR="nvim" +export VISUAL="nvim" +export READER="zathura" +export TERMINAL="alacritty" +export COLORTERM="truecolor" +export TERM="xterm-256color" +export BROWSER="firefox" +export OPENER="xdg-open" +export PAGER="less" +export WM="bspwm" +export XDG_SESSION_TYPE=X11 + +# XDG Paths: +export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:="$HOME/.config"} +#export XDG_DATA_HOME=${XDG_DATA_HOME:="$HOME/.local/share"} +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_CACHE_HOME=${XDG_CACHE_HOME:="$HOME/.cache"} +export XINITRC="$HOME/.config/X11/.xinitrc" +export INPUTRC="${XDG_CONFIG_HOME:-$HOME/.config}/X11/.inputrc" +export ICEAUTHORITY="$XDG_CACHE_HOME"/.ICEauthority +export ZDOTDIR="$XDG_CONFIG_HOME/zsh" +export HISTFILE="$ZDOTDIR/.zhistory" # History filepath +export HISTSIZE=1000000 # Maximum events for internal history +export SAVEHIST=1000000 # Maximum events in history file +export BANG_HIST # Treat the '!' character specially during expansion. +export EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format. +export INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. +export SHARE_HISTORY # Share history between all sessions. +export HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history. +export HIST_IGNORE_DUPS # Don't record an entry that was just recorded again. +export HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate. +export HIST_FIND_NO_DUPS # Do not display a line previously found. +export HIST_IGNORE_SPACE # Don't record an entry starting with a space. +export HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file. +export HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. +export HIST_VERIFY # Don't execute immediately upon history expansion. +export HIST_BEEP # Beep when accessing nonexistent history. + +# Other XDG Paths: +export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc +export NVM_DIR="$XDG_DATA_HOME"/nvm +export NODE_REPL_HISTORY="$XDG_DATA_HOME"/node_repl_history +export ASPROOT="${XDG_CACHE_HOME:-$HOME/.cache}/asp" +# fixing paths +export XSERVERRC="$XDG_CONFIG_HOME"/X11/xserverrc +#export GEM_PATH="$XDG_DATA_HOME/ruby/gems" +#export GEM_SPEC_CACHE="$XDG_DATA_HOME/ruby/specs" +#export GEM_HOME="$XDG_DATA_HOME/ruby/gems" +#export GOPATH="$XDG_DATA_HOME"/go +export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME"/java +export GTK2_RC_FILES="$XDG_CONFIG_HOME"/gtk-2.0/gtkrc +#export CARGO_HOME="$XDG_DATA_HOME"/cargo +#export PATH=$CARGO_HOME/bin:$PATH +export RIPGREP_CONFIG_PATH="$XDG_CONFIG_HOME/ripgrep/ripgreprc" +#export WORKON_HOME="$XDG_DATA_HOME"/virtualenvs +export WGETRC="$XDG_CONFIG_HOME"/wget/wgetrc +export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker +export IPYTHONDIR="$XDG_CONFIG_HOME"/jupyter, export JUPYTER_CONFIG_DIR="$XDG_CONFIG_HOME"/jupyter +export CARGO_HOME=$HOME/.cargo +export PATH="$HOME/.cargo/bin:$PATH" +#export RUSTUP_HOME=$HOME/.cargo/bin +## RUST +#typeset -U path +#path+=(~/.cargo/bin) +#export RUST_SRC_PATH=$(rustc --print sysroot)/lib/rustlib/src/rust/src +#export RUST_SRC_PATH=$HOME/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src +#export GOPATH=$HOME/go +#export GORACE='' +#export KINDLEGEN_HOME=/Users/adben/Downloads/KindleGen_Mac_i386_v2_9 +#export GOROOT=$GO_HOME +#export PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting +#export PATH=$PATH:$HOME/.local/bin # for stack - haskell +#export PATH=$PATH:/usr/local/lib/ruby/gems/2.6.0/bin + +# xsession start script + +#export USERXSESSION="$XDG_CONFIG_HOME/X11/xsession" +#export USERXSESSIONRC="$XDG_CONFIG_HOME/X11/xsessionrc" +#export ALTUSERXSESSION="$XDG_CONFIG_HOME/X11/Xsession" +#export ERRFILE="$XDG_CONFIG_HOME/X11/xsession-errors" + +# Doesn't seem to work +#export ANDROID_SDK_HOME="$XDG_CONFIG_HOME"/android +#export ANDROID_AVD_HOME="$XDG_DATA_HOME"/android +#export ANDROID_EMULATOR_HOME="$XDG_DATA_HOME"/android +#export ADB_VENDOR_KEY="$XDG_CONFIG_HOME"/android +# Disable files +#export LESSHISTFILE=- + + +# Program settings +#export MOZ_USE_XINPUT2="1" # Mozilla smooth scrolling/touchpads. + + +#export tmux.conf=XDG_CONFIG_HOME/tmux/tmux.conf +#export CARGO_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/cargo" +#export GOPATH="${XDG_DATA_HOME:-$HOME/.local/share}/go" +# Scaling +#export QT_AUTO_SCREEN_SCALE_FACTOR=0 +#export QT_SCALE_FACTOR=1 +#export QT_SCREEN_SCALE_FACTORS="1;1;1" +#export GDK_SCALE=1 +#export GDK_DPI_SCALE=1 + + +#export VIDEO="mpv" +#export IMAGE="sxiv" + +#xbindkeys -f "$XDG_CONFIG_HOME"/xbindkeys/config +# Path +#path=("$HOME/scripts" "$HOME/scripts/alsa" "$HOME/scripts/dragon" "$HOME/scripts/lf" "$HOME/scripts/i3" "$HOME/scripts/pulse" +# "$HOME/scripts/polybar" "$HOME/scripts/bspwm" "$HOME/scripts/lemonbar" "$HOME/scripts/transmission" +# "$HOME/bin/tweetdeck-linux-x64" "$XDG_DATA_HOME/ruby/gems/bin" "$HOME/go/bin" "$HOME/.local/share/cargo/bin" +# "$XDG_DATA_HOME/npm/bin" "$HOME/.local/bin" "$path[@]") +#export PATH + +#typeset -U PATH path +export GTK_IM_MODULE='fcitx' +export QT_IM_MODULE='fcitx' +export SDL_IM_MODULE='fcitx' +export XMODIFIERS='@im=fcitx' + + + + +# Start blinking +#export LESS_TERMCAP_mb=$(tput bold; tput setaf 2) # green +# Start bold +#export LESS_TERMCAP_md=$(tput bold; tput setaf 2) # green +# Start stand out +#export LESS_TERMCAP_so=$(tput bold; tput setaf 3) # yellow +# End standout +#export LESS_TERMCAP_se=$(tput rmso; tput sgr0) +# Start underline +#export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 1) # red +# End Underline +#export LESS_TERMCAP_ue=$(tput sgr0) +# End bold, blinking, standout, underline +#export LESS_TERMCAP_me=$(tput sgr0). +#. "/home/sxrdusr/.local/share/cargo/env" +. "$HOME/.cargo/env" diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc new file mode 100644 index 0000000..9b92422 --- /dev/null +++ b/.config/zsh/.zshrc @@ -0,0 +1,409 @@ + +# ███████╗███████╗██╗ ██╗██████╗ ██████╗ +# ╚══███╔╝██╔════╝██║ ██║██╔══██╗██╔════╝ +# ███╔╝ ███████╗███████║██████╔╝██║ +# ███╔╝ ╚════██║██╔══██║██╔══██╗██║ +# ███████╗███████║██║ ██║██║ ██║╚██████╗ +# ╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ + +export PATH=$HOME/bin:/usr/local/bin:/sbin:/usr/sbin:$PATH +#export PYTHONPATH=/usr/local/bin/python3 +#if [[ ! $(tmux list-sessions) ]]; then +# tmux +#fi + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +# Allow CTRL+D to exit zsh with partial command line (non empty line) +exit_zsh() { exit } +zle -N exit_zsh +bindkey '^D' exit_zsh + +# Some other useful functionalities +setopt autocd # Automatically cd into typed directory. +stty intr '^q' # free Ctrl+C for copy use Ctrl+q instead +stty lnext '^-' # free Ctrl+V for paste use ^- instead +stty stop undef # Disable ctrl-s to freeze terminal. +stty start undef + +export PATH="$HOME/.local/bin:$PATH" +export VIRTUAL_ENV_DISABLE_PROMPT=true +#unsetopt BEEP +# Enable various options +setopt interactive_comments beep extendedglob nomatch notify completeinword prompt_subst + +########## Prompt(s) ########## + +# Enable colors and change prompt: +autoload -U colors && colors # Load colors +#autoload -U promptinit && promptinit +#prompt fade red +# Prompt with Vi insert-mode/normal-mode and blinking '$', note blinking '$' only works on some terminals. +terminfo_down_sc=$terminfo[cud1]$terminfo[cuu1]$terminfo[sc]$terminfo[cud1] + +function insert-mode () { echo "-- INSERT --" } +function normal-mode () { echo "-- NORMAL --" } + + +git_branch_test_color() { + local ref=$(git symbolic-ref --short HEAD 2> /dev/null) + if [ -n "${ref}" ]; then + if [ -n "$(git status --porcelain)" ]; then + local gitstatuscolor='%F{196}' + else + local gitstatuscolor='%F{82}' + fi + echo "${gitstatuscolor}${ref}" + else + echo "" + fi +} +#PROMPT='%9c$(git_branch_test_color)%F{none} %# ' + +#echo "${gitstatuscolor} (${ref})" + +autoload -Uz add-zsh-hook vcs_info +zstyle ':vcs_info:*' stagedstr ' +%F{15}staged%f' +zstyle ':vcs_info:*' unstagedstr ' -%F{15}unstaged%f' +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:*' actionformats '%F{5}%F{2}%b%F{3}|%F{1}%a%F{5}%f ' +zstyle ':vcs_info:*' formats \ + '%F{208} '$'\uE0A0'' %f$(git_branch_test_color)%f%F{76}%c%F{3}%u%f ' + #'%{-[%F{226}'$'\uE0A0''%f%{%F{76}%b%f%}]%} %F{76}%c%F{3}%u%f' + #'%F{226}'$'\uE0A0''%f%{(%F{76}%b%f)%} %F{76}%c%F{3}%u%f' +zstyle ':vcs_info:git*+set-message:*' hooks git-untracked +zstyle ':vcs_info:*' enable git ++vi-git-untracked() { + if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ + [[ $(git ls-files --other --directory --exclude-standard | sed q | wc -l | tr -d ' ') == 1 ]] ; then + hook_com[unstaged]+='%F{196} !%f%F{15}untracked%f' +fi +} +#hook_com[unstaged]+=' %F{15}(%f%F{196}!%f%F{15})untracked%f' + + +#RPROMPT='%F{5}[%F{2}%n%F{5}] %F{3}%3~ ${vcs_info_msg_0_} %f%# ' +#add-zsh-hook +function my_precmd () { + vcs_info + PS1="%{┌─[%F{145}%n%f] %F{39}%0~%f%} ${vcs_info_msg_0_} + %{%{$terminfo_down_sc$(insert-mode)$terminfo[rc]%}%{└─%{["%{$(tput setaf 226)%}""%{$(tput blink)%}"%{$%}"%{$(tput sgr0)%}"%{%G]%}%}%}%}" +} + +function set-prompt () { + case ${KEYMAP} in + (vicmd) VI_MODE="$(normal-mode)" ;; + (main|viins) VI_MODE="$(insert-mode)" ;; + (*) VI_MODE="$(insert-mode)" ;; + esac + PS1="%{┌─[%F{145}%n%f] %F{39}%0~%f%} ${vcs_info_msg_0_} + %{%{$terminfo_down_sc$VI_MODE$terminfo[rc]%}%{└─%{["%{$(tput setaf 226)%}""%{$(tput blink)%}"%{$%}"%{$(tput sgr0)%}"%{%G]%}%}%}%}" +} +add-zsh-hook precmd my_precmd +RPROMPT='%(?..[%F{196}%?%f] )' +#RPROMPT="%K{172}${vcs_info_msg_0_}%k%(?..[%F{196}%?%f] )" + +#autoload -Uz vcs_info +#zstyle ':vcs_info:*' stagedstr 'M' +#zstyle ':vcs_info:*' unstagedstr 'M' +#zstyle ':vcs_info:*' check-for-changes true +#zstyle ':vcs_info:*' actionformats '%{(%F{76}%b%F{3}|%F{1}%a%%f%}) ' +#zstyle ':vcs_info:*' formats \ +# '%{(%F{76}%b%f)%} %F{76}%c%F{3}%u%f' +#zstyle ':vcs_info:git*+set-message:*' hooks git-untracked +#zstyle ':vcs_info:*' enable git +#+vi-git-untracked() { +# if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ +# [[ $(git ls-files --other --directory --exclude-standard | sed q | wc -l | tr -d ' ') == 1 ]] ; then +# hook_com[unstaged]+='%F{1}??%f' +#fi +#} +# +# +##RPROMPT='%F{5}[%F{2}%n%F{5}] %F{3}%3~ ${vcs_info_msg_0_} %f%# ' +#precmd () { +# print -rP " +#" +# #PS1="┌─[%F{48}%n%f]-[%F{154}%B%m%b%f]-[%F{202}%#%f%F{39}%0~%f] +# PS1="%{┌─[%F{48}%n%f] %F{119}%#%f%F{119}%0~%f%}] ${vcs_info_msg_0_} +# %{%{$terminfo_down_sc$(insert-mode)$terminfo[rc]%}%{└─%{["%{$(tput setaf 226)%}""%{$(tput blink)%}"%{$%}"%{$(tput sgr0)%}"%{%G]%}%}%}%}" +#} && { vcs_info } +# +#function set-prompt () { +# case ${KEYMAP} in +# (vicmd) VI_MODE="$(normal-mode)" ;; +# (main|viins) VI_MODE="$(insert-mode)" ;; +# (*) VI_MODE="$(insert-mode)" ;; +# esac +# PS1="%{┌─[%F{48}%n%f] %F{119}%#%f%F{119}%0~%f%} ${vcs_info_msg_0_} +# %{%{$terminfo_down_sc$VI_MODE$terminfo[rc]%}%{└─%{["%{$(tput setaf 226)%}""%{$(tput blink)%}"%{$%}"%{$(tput sgr0)%}"%{%G]%}%}%}%}" +#} +#PS1="%{┌─[%F{48}%n%f]-[%F{48}%B%m%b%f]-[%F{48}%#%f%F{48}%0~%f]%} +function zle-line-init zle-keymap-select { + set-prompt + zle reset-prompt + case $KEYMAP in + vicmd) echo -ne '\e[1 q';; # block + viins|main) echo -ne '\e[5 q';; # beam + esac +} + +preexec () { print -rn -- $terminfo[el]; echo -ne '\e[5 q' ; } + +zle -N zle-line-init +zle -N zle-keymap-select + +# Load version control information +#autoload -Uz vcs_info +#precmd() { vcs_info } + +# Format the vcs_info_msg_0_ variable +#zstyle ':vcs_info:git:*' formats 'on branch %b' + +# Set up the right-side prompt (with git branch name) and throw conditional error Code + + +## function to return current branch name while suppressing errors. +#function git_branch() { +# branch=$(git symbolic-ref HEAD 2> /dev/null | awk 'BEGIN{FS="/"} {print $NF}') +# if [[ $branch == "" ]]; then +# : +# else +# echo ' (' $branch ') ' +# fi +#} + +#setopt prompt_subst # allow command substitution inside the prompt +#PROMPT='%~ $(git_branch) >' # set the prompt value + +#autoload -Uz add-zsh-hook vcs_info +#setopt prompt_subst +#add-zsh-hook precmd my_precmd +# +#zstyle ':vcs_info:git:*' formats '%b' +# +#function my_precmd { +# local theUser='%B%F{39}%n%f%b' +# local theHost='%B%F{white}@%m%f%b' +# local git1="%F{220}~%f$(git_prompt_info)" +# local rcAndArrow='%(?.%F{white}.%B%F{red}[%?])»%f%b' +# +# vcs_info +# local git2color='cyan' +# [[ "${vcs_info_msg_0_}" == "master" ]] && git2color='196' +# local git2="||%F{${git2color}}${vcs_info_msg_0_}%f||" +# +# psvar[1]="${theUser}${theHost} ${git1} ${rcAndArrow} " +# psvar[2]="${git2}" +#} +# +#PROMPT='${psvar[1]}' +#RPROMPT='${psvar[2]}' + + + +########## Auto-completion ########## + +#autoload -U promptinit && promptinit +autoload -Uz compinit && compinit + +# Accept completion with <tab> or Ctrl+i and go to next/previous suggestions with Vi like keys: Ctrl+n/p +zmodload -i zsh/complist +accept-and-complete-next-history() { + zle expand-or-complete-prefix +} + +zle -N accept-and-complete-next-history +bindkey -M menuselect '^i' accept-and-complete-next-history +bindkey '^n' expand-or-complete +bindkey '^p' reverse-menu-complete +zstyle ':completion:*' menu select=1 + + + +########## Vi mode ########## + +export KEYTIMEOUT=25 +export EDITOR=$VISUAL +export VISUAL=nvim +bindkey -M viins '^?' backward-delete-char +bindkey -M viins '^[[3~' delete-char +bindkey -M vicmd '^[[3~' delete-char +bindkey -r '\e/' +bindkey -M viins 'jj' vi-cmd-mode +bindkey "^W" backward-kill-word +bindkey "^H" backward-delete-char # Control-h also deletes the previous char +bindkey "^U" backward-kill-line + +bindkey "^[j" history-search-forward # or you can bind it to the down key "^[[B" +bindkey "^[k" history-search-backward # or you can bind it to Up key "^[[A" +bindkey '^X' autosuggest-execute +bindkey '^Y' autosuggest-accept + +# Edit line in vim with alt-e +autoload edit-command-line; zle -N edit-command-line +bindkey '^e' edit-command-line +#bindkey '^[e' edit-command-line # alt + e + +########## Useful Commands/Alias ########## + +# Enter directory and list contents +cd() { + if [ -n "$1" ]; then + builtin cd "$@" && ls -pvA --color=auto --group-directories-first + else + builtin cd ~ && ls -pvA --color=auto --group-directories-first + fi +} + +# Back up a file. Usage "backupthis <filename>" +backupthis() { + cp -riv $1 ${1}-$(date +%Y%m%d%H%M).backup; +} + +# Let FZF use ripgrep by default +if type rg &> /dev/null; then + export FZF_DEFAULT_COMMAND='rg --files' + export FZF_DEFAULT_OPTS='-m --height 50% --border' +fi +# Setup fzf +# --------- +if [[ ! "$PATH" == */root/.local/share/nvim/plugged/fzf/bin* ]]; then + export PATH="${PATH:+${PATH}:}/root/.local/share/nvim/plugged/fzf/bin" +fi + +# Spawn a clone of current terminal +putstate () { + declare +x >~/environment.tmp + declare -x >>~/environment.tmp + echo cd "$PWD" >>~/environment.tmp +} + +getstate () { + . ~/environment.tmp +} + +# cd using "up n" as a command up as many directories, example "up 3" +up() { + # default parameter to 1 if non provided + declare -i d=${@:-1} + # ensure given parameter is non-negative. Print error and return if it is + (( $d < 0 )) && (>&2 echo "up: Error: negative value provided") && return 1; + # remove last d directories from pwd, append "/" in case result is empty + cd "$(pwd | sed -E 's;(/[^/]*){0,'$d'}$;;')/"; +} + +# More history for cd and use "cd -TAB" +setopt AUTO_PUSHD # pushes the old directory onto the stack +zstyle ':completion:*:directory-stack' list-colors '=(#b) #([0-9]#)*( *)==95=38;5;12' + +# List upto last 10 visited directories using "d" and quickly cd into any specific one +# using just a number from "0" to "9" +alias d="dirs -v | head -10" +alias 0="cd +0" +alias 1="cd +1" +alias 2="cd +2" +alias 3="cd +3" +alias 4="cd +4" +alias 5="cd +5" +alias 6="cd +6" +alias 7="cd +7" +alias 8="cd +8" +alias 9="cd +9" + +# Allow nnn filemanager to cd on quit +nnn() { + declare -x +g NNN_TMPFILE=$(mktemp --tmpdir $0.XXXX) + trap "rm -f $NNN_TMPFILE" EXIT + =nnn $@ + [ -s $NNN_TMPFILE ] && source $NNN_TMPFILE +} + +# Use lf to switch directories and bind it to ctrl-o +#lfcd () { +# tmp="$(mktemp)" +# lf -last-dir-path="$tmp" "$@" +# if [ -f "$tmp" ]; then +# dir="$(cat "$tmp")" +# rm -f "$tmp" >/dev/null +# [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" +# fi +#} +#bindkey -s '^o' 'lfcd\n' +#bindkey -s '^a' 'bc -lq\n' +#bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n' + +alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME' +#alias cfg='config subtree pull --prefx' +#alias gsp="git subtree push --prefix=_site git@github.com:mertnuhoglu/blog_datascience.git" +#alias gsp="git subtree push.local/bin/scripts https://github.com/srdusr/scripts.git main --squash +function gsp +{ + # Config file for subtrees + # + # Format: + # <prefix>;<remote address>;<remote branch> + # # Lines starting with '#' will be ignored + GIT_SUBTREE_FILE="$PWD/.gitsubtrees" + + if [ ! -f $GIT_SUBTREE_FILE ]; then + echo "Nothing to do - file <`basename $GIT_SUBTREE_FILE`> does not exist." + return + fi + + OLD_IFS=$IFS + IFS=$'\n' + for LINE in $(cat $GIT_SUBTREE_FILE); do + + # Skip lines starting with '#'. + if [[ $LINE = \#* ]]; then + continue + fi + + # Parse the current line. + PREFIX=`echo $LINE | cut -d';' -f 1` + REMOTE=`echo $LINE | cut -d';' -f 2` + BRANCH=`echo $LINE | cut -d';' -f 3` + + # Push to the remote. + echo "config subtree pull --prefix=$PREFIX $REMOTE $BRANCH" + config subtree pull --prefix=$PREFIX $REMOTE $BRANCH + done +} +alias vi='nvim' +alias nv='nvim' +alias trash="gio trash" +alias trash_restore='gio trash --restore "$(gio trash --list | fzf | cut -f 1)"' +alias ec='$EDITOR $HOME/.config/zsh/.zshrc' +alias sc="source $HOME/.config/zsh/.zshrc" + +# confirmation # +alias mv='mv -i' +alias cp='cp -i' +alias ln='ln -i' +alias rm='rm -i' + +# suspend(sleep)/hibernate and lock screen if using systemctl +alias suspend='systemctl suspend && betterlockscreen --lock dimblur' +alias hibernate='systemctl hibernate' + +########## Source Plugins, should be last ########## + +# load zsh-vi-mode +#source /usr/share/zsh/plugins/zsh-vi-mode/zsh-vi-mode.plugin.zsh + +# Load zsh-syntax-highlighting +source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null + +# Load fzf keybindings and completion +source /usr/share/fzf/key-bindings.zsh +source /usr/share/fzf/completion.zsh +source /usr/share/fzf-marks/fzf-marks.plugin.zsh 2>/dev/null + +# Suggest aliases for commands +source /usr/share/zsh/plugins/zsh-you-should-use/you-should-use.plugin.zsh 2>/dev/null + +# Load fish like auto suggestions +source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh +source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh |
