diff --git a/.bashrc b/.bashrc index 123d179..770cc3c 100644 --- a/.bashrc +++ b/.bashrc @@ -19,10 +19,10 @@ export EDITOR=nvim # ----------------------------------------------------- # ALIASES # ----------------------------------------------------- - alias c='clear' -alias nf='neofetch' -alias pf='pfetch' +alias nf='fastfetch' +alias pf='fastfetch' +alias ff='fastfetch' alias ls='eza -a --icons' alias ll='eza -al --icons' alias lt='eza -a --tree --level=1 --icons' @@ -45,7 +45,9 @@ alias ml4w='~/dotfiles/apps/ML4W_Welcome-x86_64.AppImage' alias ml4w-settings='~/dotfiles/apps/ML4W_Dotfiles_Settings-x86_64.AppImage' alias ml4w-sidebar='~/dotfiles/eww/ml4w-sidebar/launch.sh' alias ml4w-hyprland='~/dotfiles/apps/ML4W_Hyprland_Settings-x86_64.AppImage' -alias ml4w-diagnosis='~/dotfiles/scripts/diagnosis.sh' +alias ml4w-diagnosis='~/dotfiles/hypr/scripts/diagnosis.sh' +alias ml4w-hyprland-diagnosis='~/dotfiles/hypr/scripts/diagnosis.sh' +alias ml4w-qtile-diagnosis='~/dotfiles/qtile/scripts/diagnosis.sh' # ----------------------------------------------------- # Window Managers @@ -57,7 +59,6 @@ alias Qtile='startx' # ----------------------------------------------------- # GIT # ----------------------------------------------------- - alias gs="git status" alias ga="git add" alias gc="git commit -m" @@ -71,7 +72,6 @@ alias gcredential="git config credential.helper store" # ----------------------------------------------------- # SCRIPTS # ----------------------------------------------------- - alias gr='python ~/dotfiles/scripts/growthrate.py' alias ChatGPT='python ~/mychatgpt/mychatgpt.py' alias chat='python ~/mychatgpt/mychatgpt.py' @@ -80,14 +80,12 @@ alias ascii='~/dotfiles/scripts/figlet.sh' # ----------------------------------------------------- # VIRTUAL MACHINE # ----------------------------------------------------- - alias vm='~/private/launchvm.sh' alias lg='~/dotfiles/scripts/looking-glass.sh' # ----------------------------------------------------- # EDIT CONFIG FILES # ----------------------------------------------------- - alias confq='$EDITOR ~/dotfiles/qtile/config.py' alias confp='$EDITOR ~/dotfiles/picom/picom.conf' alias confb='$EDITOR ~/dotfiles/.bashrc' @@ -95,13 +93,11 @@ alias confb='$EDITOR ~/dotfiles/.bashrc' # ----------------------------------------------------- # EDIT NOTES # ----------------------------------------------------- - alias notes='$EDITOR ~/notes.txt' # ----------------------------------------------------- # SYSTEM # ----------------------------------------------------- - alias update-grub='sudo grub-mkconfig -o /boot/grub/grub.cfg' alias setkb='setxkbmap de;echo "Keyboard set back to de."' @@ -131,12 +127,12 @@ eval "$(starship init bash)" cat ~/.cache/wal/sequences # ----------------------------------------------------- -# PFETCH if on wm +# Fastfetch if on wm # ----------------------------------------------------- -echo "" if [[ $(tty) == *"pts"* ]]; then - pfetch + fastfetch --config examples/13 else + echo if [ -f /bin/qtile ]; then echo "Start Qtile X11 with command Qtile" fi diff --git a/.install/backup.sh b/.install/backup.sh index 9628e5c..3f1070a 100755 --- a/.install/backup.sh +++ b/.install/backup.sh @@ -80,7 +80,7 @@ if [ -d ~/dotfiles ] || ! test -L ~/.bashrc || [ -d ~/.config/hypr ] || [ -d ~/. if ! test -L ~/.config/swappy && [ -d ~/.config/swappy ] ;then echo " - $HOME/.config/swappy/" fi - + echo # Start Backup if gum confirm "Do you want to create a backup?" ;then diff --git a/.install/bashrc.sh b/.install/bashrc.sh index 65db75b..f297daa 100755 --- a/.install/bashrc.sh +++ b/.install/bashrc.sh @@ -11,8 +11,9 @@ fi if [ -f ~/dotfiles-versions/backups/$datets/.bashrc-old ]; then echo "Backup is already available here ~/dotfiles-versions/backups/$datets/.bashrc-old" fi +echo if [ ! -L ~/.bashrc ] && [ -f ~/.bashrc ]; then - bash_confirm="Do you want to replace your existing .bashrc file with the dotfiles .bashrc file?" + bash_confirm="Do you want to replace your existing .bashrc file with the ML4W dotfiles .bashrc file?" if gum confirm "$bash_confirm" ;then rm ~/.bashrc _installSymLink .bashrc ~/.bashrc ~/dotfiles/.bashrc ~/.bashrc @@ -22,7 +23,7 @@ if [ ! -L ~/.bashrc ] && [ -f ~/.bashrc ]; then echo "Installation of the .bashrc file skipped." fi else - bash_confirm="Do you want to install the dotfiles .bashrc file now?" + bash_confirm="Do you want to install the ML4W dotfiles .bashrc file now?" if gum confirm "$bash_confirm" ;then if [ -L ~/.bashrc ] || [ -f ~/.bashrc ]; then rm ~/.bashrc diff --git a/.install/cleanup.sh b/.install/cleanup.sh index 86542a6..d06f0f6 100644 --- a/.install/cleanup.sh +++ b/.install/cleanup.sh @@ -13,24 +13,6 @@ if [[ $(_isInstalledPacman "ttf-ms-fonts") == 0 ]]; then fi fi -# Check for running NetworkManager.service -if [[ $(systemctl list-units --all -t service --full --no-legend "NetworkManager.service" | sed 's/^\s*//g' | cut -f1 -d' ') == "NetworkManager.service" ]];then - echo ":: NetworkManager.service already running." -else - sudo systemctl enable NetworkManager.service - sudo systemctl start NetworkManager.service - echo ":: NetworkManager.service activated successfully." -fi - -# Check for running bluetooth.service -if [[ $(systemctl list-units --all -t service --full --no-legend "bluetooth.service" | sed 's/^\s*//g' | cut -f1 -d' ') == "bluetooth.service" ]];then - echo ":: bluetooth.service already running." -else - sudo systemctl enable bluetooth.service - sudo systemctl start bluetooth.service - echo ":: bluetooth.service activated successfully." -fi - if [ -d ~/dotfiles/hypr/settings/ ] ;then rm -rf ~/dotfiles/hypr/settings echo ":: ~/dotfiles/hypr/settings removed." @@ -43,6 +25,10 @@ if [ -f ~/dotfiles/.settings/eww-monitor.sh ] ;then fi fi +# Replace pfetch and neofetch with fastfetch +sed -i "s/pfetch/fastfetch/g" ~/dotfiles/.bashrc +sed -i "s/neofetch/fastfetch/g" ~/dotfiles/.bashrc + # Create default folder structure xdg-user-dirs-update echo diff --git a/.install/confirm-start.sh b/.install/confirm-start.sh index db66c1a..4599bf5 100644 --- a/.install/confirm-start.sh +++ b/.install/confirm-start.sh @@ -2,7 +2,6 @@ # Confirm Start # ------------------------------------------------------ -echo "You can cancel the installation at any time with CTRL + C" SCRIPT=$(realpath "$0") SCRIPTPATH=$(dirname "$SCRIPT") if [ $SCRIPTPATH = "/home/$USER/dotfiles" ]; then @@ -18,7 +17,8 @@ if [ ! -d ~/dotfiles ];then if gum confirm "DO YOU WANT TO START THE INSTALLATION OF THE ML4W DOTFILES NOW?" ;then echo "Installation started." elif [ $? -eq 130 ]; then - exit 130 + echo ":: Installation canceled." + exit 130 else echo ":: Installation canceled." exit; @@ -27,7 +27,8 @@ else if gum confirm "DO YOU WANT TO START THE UPDATE OF YOUR ML4W DOTFILES NOW?" ;then echo ":: Update started." elif [ $? -eq 130 ]; then - exit 130 + echo ":: Update canceled." + exit 130 else echo ":: Update canceled." exit; diff --git a/.install/copy.sh b/.install/copy.sh index 262b81f..0f090ef 100644 --- a/.install/copy.sh +++ b/.install/copy.sh @@ -13,22 +13,23 @@ fi if [ ! -d ~/dotfiles ]; then echo "The script will now remove existing directories and files from ~/.config/" echo "and copy your prepared configuration from ~/dotfiles-versions/$version to ~/dotfiles" -echo "" +echo echo "Symbolic links will then be created from ~/dotfiles into your ~/.config/ directory." -echo "" +echo fi if [[ ! $(tty) == *"pts"* ]] && [ -d ~/dotfiles ]; then echo "You're running the script in tty. You can delete the existing ~/dotfiles folder now for a clean installation." echo "If not, the script will overwrite existing files but will not remove additional files or folders of your custom configuration." - echo "" + echo else if [ -d ~/dotfiles ]; then echo "The script will overwrite existing files but will not remove additional files or folders from your custom configuration." + echo fi fi if [ ! -d ~/dotfiles ]; then echo "PLEASE BACKUP YOUR EXISTING CONFIGURATIONS in .config IF NEEDED!" - echo "" + echo fi if gum confirm "Do you want to install the prepared dotfiles now?" ;then @@ -50,8 +51,10 @@ if gum confirm "Do you want to install the prepared dotfiles now?" ;then echo "Skipped: DEV MODE!" fi elif [ $? -eq 130 ]; then - exit 130 + echo ":: Installation canceled" + exit 130 else + echo ":: Installation canceled" exit fi -echo "" +echo diff --git a/.install/diagnosis.sh b/.install/diagnosis.sh index ff2791c..7cd6f8e 100644 --- a/.install/diagnosis.sh +++ b/.install/diagnosis.sh @@ -4,7 +4,7 @@ echo -e "${NONE}" echo "The system check will test that essential packages and " echo "execution commands are available now on your system." - +echo if gum confirm "Do you want to run a short system check?" ;then _folderExists "$HOME/dotfiles" "Please repeat the installation." diff --git a/.install/displaymanager.sh b/.install/displaymanager.sh index 5948379..93d54fb 100755 --- a/.install/displaymanager.sh +++ b/.install/displaymanager.sh @@ -2,6 +2,7 @@ # Disable display manager # ------------------------------------------------------ disman=0 +profile="Hyprland" echo -e "${GREEN}" figlet "Display Manager" echo -e "${NONE}" @@ -30,12 +31,14 @@ if [ ! -d ~/dotfiles ];then disman=0 echo "You have already installed a display manager on your system." echo "How do you want to proceed?" + echo dmsel=$(gum choose "Keep current setup" "Deactivate current display manager" "Install sddm and theme") else disman=1 echo "There is no display manager installed on your system." echo "After the installation/update of the dotfiles, you can start Hyprland with command Hyprland and Qtile with commmand Qtile (or startx)." echo "How do you want to proceed?" + echo dmsel=$(gum choose "Keep current setup" "Install sddm and theme") fi else @@ -43,59 +46,79 @@ else disman=0 echo "You have already installed a display manager. If your display manager is working fine, you can keep the current setup." echo "How do you want to proceed?" + echo dmsel=$(gum choose "Keep current setup" "Deactivate current display manager" "Install sddm and theme") else disman=1 echo "There is no display manager installed on your system. You're starting Hyprland/Qtile with commands on tty." echo "How do you want to proceed?" + echo dmsel=$(gum choose "Keep current setup" "Install sddm and theme") fi fi if [ -z "${dmsel}" ] ;then - echo "Installation canceled." + echo ":: Installation canceled." exit fi if [ "$dmsel" == "Install sddm and theme" ] ;then disman=0 # Try to force the installation of sddm - echo "Install sddm" - yay -S --noconfirm sddm sddm-sugar-candy-git --ask 4 + echo ":: Install sddm" + yay -S --noconfirm sddm --ask 4 + # Enable sddm if [ -f /etc/systemd/system/display-manager.service ]; then sudo rm /etc/systemd/system/display-manager.service fi sudo systemctl enable sddm.service + # Create sddm.conf.d folder if [ ! -d /etc/sddm.conf.d/ ]; then sudo mkdir /etc/sddm.conf.d - echo "Folder /etc/sddm.conf.d created." + echo ":: Folder /etc/sddm.conf.d created." fi + # Copy sddm.conf sudo cp sddm/sddm.conf /etc/sddm.conf.d/ - echo "File /etc/sddm.conf.d/sddm.conf updated." + echo ":: File /etc/sddm.conf.d/sddm.conf updated." + # Download and install sugar candy theme if not exists + if [ ! -d /usr/share/sddm/themes/sugar-candy ]; then + if [ -f ~/Downloads/sddm-sugar-candy-master.zip ] ;then + rm ~/Downloads/sddm-sugar-candy-master.zip + fi + wget -P ~/Downloads/ https://framagit.org/MarianArlt/sddm-sugar-candy/-/archive/master/sddm-sugar-candy-master.zip + if [ -f ~/Downloads/sddm-sugar-candy-master.zip ] ;then + unzip -o -q ~/Downloads/sddm-sugar-candy-master.zip -d ~/Downloads/ + if [ ! -d /usr/share/sddm/themes/sugar-candy ] ;then + sudo mkdir -p /usr/share/sddm/themes/sugar-candy + fi + sudo cp -r ~/Downloads/sddm-sugar-candy-master/* /usr/share/sddm/themes/sugar-candy + echo ":: SDDM Sugar Candy Theme installed" + else + echo "ERROR: Sugar Candy Download not found" + fi + fi + + # Install background wallpaper for sddm if [ -f /usr/share/sddm/themes/sugar-candy/theme.conf ]; then - - # Cache file for holding the current wallpaper sudo cp wallpapers/default.jpg /usr/share/sddm/themes/sugar-candy/Backgrounds/current_wallpaper.jpg - echo "Default wallpaper copied into /usr/share/sddm/themes/sugar-candy/Backgrounds/" - + echo ":: Default wallpaper copied into /usr/share/sddm/themes/sugar-candy/Backgrounds/" sudo cp sddm/theme.conf /usr/share/sddm/themes/sugar-candy/ sudo sed -i 's/CURRENTWALLPAPER/'"current_wallpaper.jpg"'/' /usr/share/sddm/themes/sugar-candy/theme.conf - echo "File theme.conf updated in /usr/share/sddm/themes/sugar-candy/" - + echo ":: File theme.conf updated in /usr/share/sddm/themes/sugar-candy/" fi elif [ "$dmsel" == "Deactivate current display manager" ] ;then sudo rm /etc/systemd/system/display-manager.service - echo "Current display manager deactivated." + echo ":: Current display manager deactivated." disman=1 elif [ "$dmsel" == "Keep current setup" ] ;then - echo "Keep current setup." + echo ":: sddm setup skipped." else - echo "Keep current setup." + echo ":: sddm setup skipped." fi diff --git a/.install/fish.sh b/.install/fish.sh new file mode 100644 index 0000000..4eea7ff --- /dev/null +++ b/.install/fish.sh @@ -0,0 +1,6 @@ +# ------------------------------------------------------ +# install fish +# ------------------------------------------------------ +packagesPacman=("fish"); +packagesYay=(); +source .install/install-packages.sh diff --git a/.install/hidpi.sh b/.install/hidpi.sh index 8aa5546..510035a 100755 --- a/.install/hidpi.sh +++ b/.install/hidpi.sh @@ -11,7 +11,11 @@ hidpiconfirm="Do you want 2x hidpi scale?" if gum confirm "$hidpiconfirm"; then sed -i -E 's/size = [0-9]+(\.[0-9]+)?/size = 16/' ~/dotfiles-versions/$version/alacritty/alacritty.toml sed -i -E 's/[0-9]+(\.[0-9]+)?/16/' ~/dotfiles-versions/$version/.settings/rofi-font.rasi - echo -e '\n\n# hidpi scale\nsource = ~/dotfiles/hypr/conf/hidpi.conf' >> ~/dotfiles-versions/$version/hypr/conf/custom.conf + echo -e '\n# -----------------------------------------------------' >> ~/dotfiles-versions/$version/hypr/hyprland.conf + echo -e '# HiDPI Scaling' >> ~/dotfiles-versions/$version/hypr/hyprland.conf + echo -e '# -----------------------------------------------------' >> ~/dotfiles-versions/$version/hypr/hyprland.conf + echo -e 'source = ~/dotfiles/hypr/conf/hidpi.conf' >> ~/dotfiles-versions/$version/hypr/hyprland.conf sed -i -E 's/1/2/' ~/dotfiles-versions/$version/hypr/conf/monitors/default.conf + #sed -i -E 's/24/32/' ~/dotfiles-versions/$version/hypr/conf/cursor.conf echo ":: finished hidpi patch." fi diff --git a/.install/hook.sh b/.install/hook.sh index 99b2597..b792377 100755 --- a/.install/hook.sh +++ b/.install/hook.sh @@ -6,9 +6,13 @@ echo -e "${GREEN}" figlet "Hook" echo -e "${NONE}" echo ":: The script has detected a hook.sh script." + echo if gum confirm "Do you want to run the script now?"; then source ~/dotfiles-versions/hook.sh echo ":: hook.sh executed!" + elif [ $? -eq 130 ]; then + echo ":: Installation canceled." + exit 130 else echo ":: Execution of hook.sh skipped." fi diff --git a/.install/hyprland-dotfiles.sh b/.install/hyprland-dotfiles.sh index 551d6a8..bddd974 100644 --- a/.install/hyprland-dotfiles.sh +++ b/.install/hyprland-dotfiles.sh @@ -40,7 +40,7 @@ fi if [ -d ~/dotfiles-versions/$version/swappy ]; then _installSymLink swappy ~/.config/swappy ~/dotfiles/swappy/ ~/.config fi -if [ -d ~/dotfiles-versions/$version/swappy ]; then +if [ -d ~/dotfiles-versions/$version/eww ]; then _installSymLink eww ~/.config/eww ~/dotfiles/eww/ ~/.config fi if [ -d ~/dotfiles-versions/$version/fastfetch ]; then @@ -49,5 +49,12 @@ fi if [ -f ~/dotfiles-versions/$version/chrome-flags.conf ]; then _installSymLink chrome-flags ~/.config/chrome-flags.conf ~/dotfiles/chrome-flags.conf ~/.config fi +if [ -d ~/dotfiles-versions/$version/Vimix-hyprcursors ]; then + if [ ! -d ~/.local/share/icons ]; then mkdir -pv ~/.local/share/icons; fi + _installSymLink Vimix-hyprcursors ~/.local/share/icons/Vimix-hyprcursors ~/dotfiles/Vimix-hyprcursors ~/.local/share/icons/ +fi +if [ -d ~/dotfiles-versions/$version/ranger ]; then + _installSymLink ranger ~/.config/ranger ~/dotfiles/ranger/ ~/.config +fi echo ":: Symbolic links created." echo diff --git a/.install/includes/excludes.txt b/.install/includes/excludes.txt index 3d894e2..363c9f5 100644 --- a/.install/includes/excludes.txt +++ b/.install/includes/excludes.txt @@ -6,4 +6,5 @@ gtk README.md CHANGELOG LICENSE -install.sh \ No newline at end of file +install.sh +setup.sh \ No newline at end of file diff --git a/.install/installer.sh b/.install/installer.sh index 24e19e4..9caa70f 100644 --- a/.install/installer.sh +++ b/.install/installer.sh @@ -7,10 +7,11 @@ echo -e "${NONE}" if [ -d ~/dotfiles ] ;then echo "Do you want to check for new packages only (faster installation)" echo "or do you want to reinstall all packages again? (more robust and can help to fix issues)" + echo if gum confirm "How do you want to proceed?" --affirmative "New packages only" --negative "Force reinstallation" ;then force_install=0 elif [ $? -eq 130 ]; then - echo "Installation canceled." + echo ":: Installation canceled." exit 130 else force_install=1 @@ -18,10 +19,11 @@ if [ -d ~/dotfiles ] ;then else echo "Do you want to reinstall all already installed packages and install the required new packages? (recommended and more robust)" echo "or do you want to install the new required packages only? (could be faster installation)" + echo if gum confirm "How do you want to proceed?" --affirmative "Reinstall all packages" --negative "Install new packages only" ;then force_install=1 elif [ $? -eq 130 ]; then - echo "Installation canceled." + echo ":: Installation canceled." exit 130 else force_install=0 diff --git a/.install/keyboard.sh b/.install/keyboard.sh index 0db08db..7069c50 100755 --- a/.install/keyboard.sh +++ b/.install/keyboard.sh @@ -6,48 +6,85 @@ echo -e "${GREEN}" figlet "Keyboard" echo -e "${NONE}" -# Default layout and variants -keyboard_layout="us" - -_setupKeyboardLayout() { - echo "" - echo "Start typing = Search, RETURN = Confirm, CTRL-C = Cancel" - keyboard_layout=$(localectl list-x11-keymap-layouts | gum filter --height 15 --placeholder "Find your keyboard layout...") - echo "" - echo ":: Keyboard layout changed to $keyboard_layout" - echo "" - _confirmKeyboard -} - -_confirmKeyboard() { - echo "Current selected keyboard setup:" - echo "Keyboard layout: $keyboard_layout" - if gum confirm "Do you want proceed with this keyboard setup?" --affirmative "Proceed" --negative "Change" ;then - return 0 - elif [ $? -eq 130 ]; then - exit 130 - else - _setupKeyboardLayout - fi -} - +setkeyboard=0 if [ "$restored" == "1" ]; then echo ":: You have already restored your settings into the new installation." -else + echo "You can repeat the keyboard setup again to choose between a desktop and laptop optimized configuration." + echo + if gum confirm "Do you want to setup your keyboard again?" ;then + setkeyboard=0 + elif [ $? -eq 130 ]; then + echo ":: Installation canceled." + exit 130 + else + echo ":: Keyboard setup skipped." + setkeyboard=1 + fi +fi + +if [ "$setkeyboard" == "0" ] ;then + + # Default layout and variants + keyboard_layout="us" + keyboard_variant="" + + _setupKeyboardLayout() { + keyboard_layout=$(localectl list-x11-keymap-layouts | gum filter --height 15 --placeholder "Find your keyboard layout...") + echo ":: Keyboard layout changed to $keyboard_layout" + _setupKeyboardVariant + } + + _setupKeyboardVariant() { + if gum confirm "Do you want to set a variant of the keyboard?" ; then + keyboard_variant=$(localectl list-x11-keymap-variants | gum filter --height 15 --placeholder "Find your keyboard layout...") + echo ":: Keyboard variant changed to $keyboard_variant" + fi + _confirmKeyboard + } + + _confirmKeyboard() { + echo + echo "Current selected keyboard setup:" + echo "Keyboard layout: $keyboard_layout" + echo "Keyboard variant: $keyboard_variant" + echo + if gum confirm "Do you want proceed with this keyboard setup?" --affirmative "Proceed" --negative "Change" ;then + return 0 + elif [ $? -eq 130 ]; then + exit 130 + else + _setupKeyboardLayout + fi + } + _confirmKeyboard - - cp .install/templates/keyboard.conf ~/dotfiles-versions/$version/hypr/conf/keyboard.conf + + if gum confirm "Are you using a laptop and would you like to enable the laptop presets?"; then + cp .install/templates/keyboard-laptop.conf ~/dotfiles-versions/$version/hypr/conf/keyboard.conf + echo "source = ~/dotfiles/hypr/conf/layouts/laptop.conf" > ~/dotfiles-versions/$version/hypr/conf/layout.conf + elif [ $? -eq 130 ]; then + echo ":: Installation canceled." + exit 130 + else + cp .install/templates/keyboard-default.conf ~/dotfiles-versions/$version/hypr/conf/keyboard.conf + fi cp .install/templates/autostart.sh ~/dotfiles-versions/$version/qtile/autostart.sh SEARCH="KEYBOARD_LAYOUT" REPLACE="$keyboard_layout" sed -i "s/$SEARCH/$REPLACE/g" ~/dotfiles-versions/$version/hypr/conf/keyboard.conf + SEARCH="KEYBOARD_VARIANT" + REPLACE="$keyboard_variant" + sed -i "s/$SEARCH/$REPLACE/g" ~/dotfiles-versions/$version/hypr/conf/keyboard.conf + SEARCH="KEYBOARD_LAYOUT" REPLACE="$keyboard_layout" sed -i "s/$SEARCH/$REPLACE/g" ~/dotfiles-versions/$version/qtile/autostart.sh - echo "" - echo ":: Keyboard setup updated successfully." + echo + echo ":: Keyboard setup complete." + echo echo "PLEASE NOTE: You can update your keyboard layout later in ~/dotfiles/hypr/conf/keyboard.conf" -fi + +fi diff --git a/.install/neovim.sh b/.install/neovim.sh index 5c58e63..662368b 100755 --- a/.install/neovim.sh +++ b/.install/neovim.sh @@ -7,9 +7,13 @@ echo -e "${GREEN}" figlet "Neovim" echo -e "${NONE}" echo ":: The script has detected a nvim folder." + echo if gum confirm "Do you want to install the ML4W Neovim configuration?"; then echo ":: ML4W Neovim configuration will be installed" neovim=1 + elif [ $? -eq 130 ]; then + echo ":: Installation canceled." + exit 130 else rm -rf ~/dotfiles-versions/$version/nvim/ echo ":: Installation of ML4W Neovim configuration skipped." diff --git a/.install/packages/general-packages.sh b/.install/packages/general-packages.sh index badf97e..f3912ba 100644 --- a/.install/packages/general-packages.sh +++ b/.install/packages/general-packages.sh @@ -7,63 +7,51 @@ packagesPacman=( "fastfetch" "ranger" "btop" - "bluez" - "bluez-utils" "neovim" "wget" "unzip" - "alacritty" - "chromium" - "dunst" + "alacritty" + "dunst" "starship" - "mpv" - "thunar" - "mousepad" - "noto-fonts" - "otf-font-awesome" - "ttf-fira-sans" + "mpv" + "thunar" + "nautilus" + "noto-fonts" + "otf-font-awesome" + "ttf-fira-sans" "ttf-fira-code" "ttf-firacode-nerd" - "ttf-firacode-nerd" - "figlet" - "vlc" - "eza" - "python-pip" - "python-psutil" - "python-rich" - "python-click" + "ttf-firacode-nerd" + "figlet" + "vlc" + "eza" + "python-pip" + "python-psutil" + "python-rich" "python-pywal" - "python-gobject" - "pavucontrol" - "tumbler" - "blueman" + "pavucontrol" + "tumbler" "papirus-icon-theme" - "breeze-icons" - "polkit-gnome" - "brightnessctl" "gum" "man-pages" - "nm-connection-editor" "gvfs" "xdg-user-dirs" - "networkmanager" - "network-manager-applet" +# "xdg-desktop-portal-gtk" "xarchiver" "thunar-archive-plugin" "zip" "fuse2" - "gtk4" - "libadwaita" "xdg-desktop-portal" "qalculate-gtk" "imagemagick" - "guvcview" "jq" "rofi-wayland" + "fastfetch" ); packagesYay=( "vimix-cursors" + "orchis-theme" "trizen" - "pacseek" + "google-chrome" ); diff --git a/.install/packages/hyprland-packages.sh b/.install/packages/hyprland-packages.sh index 5ca80b0..a05a068 100644 --- a/.install/packages/hyprland-packages.sh +++ b/.install/packages/hyprland-packages.sh @@ -1,22 +1,21 @@ packagesPacman=( "hyprland" "hyprpaper" - "xdg-desktop-portal-hyprland" - "waybar" - "grim" + "hyprlock" + "hypridle" + # "xdg-desktop-portal-hyprland" + "waybar" + "grim" "slurp" "swappy" "cliphist" - "hyprlock" - "hypridle" "kitty" -); +) packagesYay=( "pyprland" - "swww" "wlogout" "nwg-look" - "emote" "eww" -); + "hyprshade" +) diff --git a/.install/paralleldownloads.sh b/.install/paralleldownloads.sh new file mode 100755 index 0000000..cb2be44 --- /dev/null +++ b/.install/paralleldownloads.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# ------------------------------------------------------ +# Activate parallel downloads +# ------------------------------------------------------ + +# Search for the line containing "ParallelDownloads = 5" +line=$(grep "ParallelDownloads = 5" /etc/pacman.conf) + +# Check if the line starts with a '#' character +if [[ $line == \#* ]]; then + echo -e "${GREEN}" + figlet "Downloads" + echo -e "${NONE}" + echo ":: You can activate parallel downloads in pacman.conf to speedup the download of packages?" + if gum confirm "Do you want to activate parallel downloads?"; then + + # Remove the '#' character from the beginning of the line + echo ":: Modifying pacman.conf to enable parallel downloads." + new_line=$(echo $line | sed 's/^#//') + + # Replace the original line with the new line in the configuration file + sudo sed -i "s/$line/$new_line/g" /etc/pacman.conf + + # Display a message indicating that the line was modified + echo ":: Modified line: $new_line" + elif [ $? -eq 130 ]; then + exit + else + echo ":: Activation of parallel downloads skipped." + fi +else + # Check if the line is already uncommented + if [[ $line == ParallelDownloads\ =\ 5 ]]; then + # Display a message indicating that the line does not need to be modified + echo ":: pacman.conf already optimized for parallel downloads." + else + # Display a message indicating that the line is missing or commented out + echo ":: Parallel downloads could not be activated. Required configuration in /etc/pacman.conf could not found." + fi +fi + +# Activate Color in pacman.conf +if grep -Fxq "#Color" /etc/pacman.conf +then + sudo sed -i 's/^#Color/Color/' /etc/pacman.conf + echo ":: Color activated in pacman.conf" +else + echo ":: Color is already activated in pacman.conf" +fi +if grep -Fxq "# Color" /etc/pacman.conf +then + sudo sed -i 's/^# Color/Color/' /etc/pacman.conf + echo ":: Color activated in pacman.conf" +fi +echo \ No newline at end of file diff --git a/.install/profile.sh b/.install/profile.sh index 8acaadd..0c5ec58 100755 --- a/.install/profile.sh +++ b/.install/profile.sh @@ -4,13 +4,13 @@ echo -e "${GREEN}" figlet "Profile" echo -e "${NONE}" - -echo "SPACE = select/unselect a profile. RETURN = confirm. No selection = CANCEL" +echo "Please select your installation profile." +echo profile=$(gum choose --no-limit --cursor-prefix "( ) " --selected-prefix "(x) " --unselected-prefix "( ) " "Hyprland" "Qtile") if [ -z "${profile}" ] ;then - echo "No profile selected. Installation canceled." + echo ":: No profile selected. Installation canceled." exit else - echo "Profile/s selected:" $profile + echo ":: Profile/s selected:" $profile fi diff --git a/.install/reboot.sh b/.install/reboot.sh index 7f59583..709f2c6 100644 --- a/.install/reboot.sh +++ b/.install/reboot.sh @@ -6,9 +6,9 @@ echo -e "${GREEN}" figlet "Reboot" echo -e "${NONE}" echo "A reboot of your system is recommended." +echo if gum confirm "Do you want to reboot your system now?" ;then - echo ":: Rebooting now ..." - sleep 3 + gum spin --spinner dot --title "Rebooting now..." -- sleep 3 systemctl reboot elif [ $? -eq 130 ]; then exit 130 diff --git a/.install/restore.sh b/.install/restore.sh index 178e000..31cd3ef 100755 --- a/.install/restore.sh +++ b/.install/restore.sh @@ -8,13 +8,20 @@ monitorrestored=0 _showRestoreOptions() { echo "The following configurations can be transferred into the new installation." - echo "(SPACE = select/unselect a profile. RETURN = confirm. CTRL-C/No selection = Skip Restore)" - echo "" + echo restorelist="" if [ -f ~/dotfiles/.bashrc ]; then restorelist+="~/dotfiles/.bashrc " selectedlist+="~/dotfiles/.bashrc," fi + if [ -f ~/dotfiles/.zshrc ]; then + restorelist+="~/dotfiles/.zshrc " + selectedlist+="~/dotfiles/.zshrc," + fi + if [ -f ~/dotfiles/.p10k.zsh ]; then + restorelist+="~/dotfiles/.p10k.zsh " + selectedlist+="~/dotfiles/.p10k.zsh," + fi if [ -d ~/dotfiles/.settings ]; then restorelist+="~/dotfiles/.settings " selectedlist+="~/dotfiles/.settings," @@ -25,7 +32,7 @@ _showRestoreOptions() { then restorelist+="~/dotfiles/hypr/hypridle.conf " selectedlist+="~/dotfiles/hypr/hypridle.conf," - fi + fi fi if [ -f ~/dotfiles/hypr/conf/custom.conf ]; then restorelist+="~/dotfiles/hypr/conf/custom.conf " @@ -43,6 +50,10 @@ _showRestoreOptions() { restorelist+="~/dotfiles/hypr/conf/environment.conf " selectedlist+="~/dotfiles/hypr/conf/environment.conf," fi + if [ -f ~/dotfiles/hypr/conf/layout.conf ] && [ -d ~/dotfiles/hypr/conf/layouts/ ]; then + restorelist+="~/dotfiles/hypr/conf/layout.conf " + selectedlist+="~/dotfiles/hypr/conf/layout.conf," + fi if [ -f ~/dotfiles/hypr/conf/windowrule.conf ] && [ -d ~/dotfiles/hypr/conf/windowrules/ ]; then restorelist+="~/dotfiles/hypr/conf/windowrule.conf " selectedlist+="~/dotfiles/hypr/conf/windowrule.conf," @@ -72,13 +83,13 @@ _showRestoreOptions() { fi restoreselect=$(gum choose --no-limit --height 20 --cursor-prefix "( ) " --selected-prefix "(x) " --unselected-prefix "( ) " --selected="$selectedlist" $restorelist) if [ ! -z "$restoreselect" ] ;then - echo "Selected to restore:" + echo "Selected to restore:" echo "$restoreselect" echo "" confirmrestore=$(gum choose "Start restore" "Change restore" "Skip restore") if [ "$confirmrestore" == "Start restore" ] ;then _startRestore - elif [ "$confirmrestore" == "Change restore" ]; then + elif [ "$confirmrestore" == "Change restore" ]; then _showRestoreOptions else echo ":: Restore skipped." @@ -88,10 +99,10 @@ _showRestoreOptions() { echo "No files selected to restore." confirmrestore=$(gum choose "Change restore" "Skip restore") if [ -z "${confirmrestore}" ] ;then - echo "Installation canceled." + echo ":: Installation canceled." exit fi - if [ "$confirmrestore" == "Change restore" ]; then + if [ "$confirmrestore" == "Change restore" ]; then echo "" _showRestoreOptions else @@ -132,11 +143,11 @@ _startRestore() { cp ~/dotfiles/hypr/conf/keyboard.conf ~/dotfiles-versions/$version/hypr/conf/ echo ":: Hyprland keyboard.conf restored!" fi - fi + fi if [[ $restoreselect == *"~/dotfiles/hypr/conf/monitor.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then if [ -f ~/dotfiles/hypr/conf/monitor.conf ]; then cp ~/dotfiles/hypr/conf/monitor.conf ~/dotfiles-versions/$version/hypr/conf/ - echo ":: Hyprland monitor.conf restored!" + echo ":: Hyprland monitor.conf restored!" fi fi if [[ $restoreselect == *"~/dotfiles/hypr/conf/keybinding.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then @@ -150,13 +161,19 @@ _startRestore() { cp ~/dotfiles/hypr/conf/environment.conf ~/dotfiles-versions/$version/hypr/conf/ echo ":: Hyprland environment.conf restored!" fi - fi + fi + if [[ $restoreselect == *"~/dotfiles/hypr/conf/layout.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then + if [ -f ~/dotfiles/hypr/conf/layout.conf ]; then + cp ~/dotfiles/hypr/conf/layout.conf ~/dotfiles-versions/$version/hypr/conf/ + echo ":: Hyprland layout.conf restored!" + fi + fi if [[ $restoreselect == *"~/dotfiles/hypr/conf/windowrule.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then if [ -f ~/dotfiles/hypr/conf/windowrule.conf ]; then cp ~/dotfiles/hypr/conf/windowrule.conf ~/dotfiles-versions/$version/hypr/conf/ echo ":: Hyprland windowrule.conf restored!" fi - fi + fi if [[ $restoreselect == *"~/dotfiles/hypr/conf/animation.conf"* ]] || [[ $restoreselect == *"All"* ]] ; then if [ -f ~/dotfiles/hypr/conf/animation.conf ]; then cp ~/dotfiles/hypr/conf/animation.conf ~/dotfiles-versions/$version/hypr/conf/ diff --git a/.install/templates/keyboard.conf b/.install/templates/keyboard-default.conf similarity index 66% rename from .install/templates/keyboard.conf rename to .install/templates/keyboard-default.conf index 6bed3fa..794e1ee 100644 --- a/.install/templates/keyboard.conf +++ b/.install/templates/keyboard-default.conf @@ -4,11 +4,11 @@ # ----------------------------------------------------- input { kb_layout = KEYBOARD_LAYOUT - kb_variant = + kb_variant = KEYBOARD_VARIANT kb_model = kb_options = numlock_by_default = true - mouse_refocus=false + mouse_refocus = false # For United States # kb_layout = us @@ -18,7 +18,17 @@ input { follow_mouse = 1 touchpad { + # for desktop natural_scroll = false + + # for laptop + # natural_scroll = yes + # middle_button_emulation = true + # clickfinger_behavior = 1 } sensitivity = 0 # -1.0 - 1.0, 0 means no modification. } + +gestures { + workspace_swipe = true +} \ No newline at end of file diff --git a/.install/templates/keyboard-laptop.conf b/.install/templates/keyboard-laptop.conf new file mode 100644 index 0000000..1ab5d0f --- /dev/null +++ b/.install/templates/keyboard-laptop.conf @@ -0,0 +1,35 @@ +# ----------------------------------------------------- +# Keyboard Layout +# https://wiki.hyprland.org/Configuring/Variables/#input +# ----------------------------------------------------- +input { + kb_layout = KEYBOARD_LAYOUT + kb_variant = KEYBOARD_VARIANT + kb_model = + kb_options = + numlock_by_default = true + mouse_refocus = false + + # For United States + # kb_layout = us + # kb_variant = intl + # kb_model = pc105 + # kb_options = + + follow_mouse = 1 + touchpad { + # for desktop + # natural_scroll = false + + # for laptop + natural_scroll = true + middle_button_emulation = true + clickfinger_behavior = true + disable_while_typing = true + } + sensitivity = 0 # -1.0 - 1.0, 0 means no modification. +} + +gestures { + workspace_swipe = true +} \ No newline at end of file diff --git a/.install/updatesystem.sh b/.install/updatesystem.sh index e3891a7..05973c8 100644 --- a/.install/updatesystem.sh +++ b/.install/updatesystem.sh @@ -6,12 +6,14 @@ echo -e "${GREEN}" figlet "System Update" echo -e "${NONE}" echo "It's important that your system is up-to-date before you proceed." +echo if gum confirm "Do you want to update your system with yay now?" ;then echo ":: Update started" yay elif [ $? -eq 130 ]; then + echo ":: Installation canceled." exit 130 -else +else echo ":: System update skipped" fi echo diff --git a/.install/vm.sh b/.install/vm.sh index 8fae350..0b4dd91 100755 --- a/.install/vm.sh +++ b/.install/vm.sh @@ -4,6 +4,7 @@ echo -e "${GREEN}" figlet "KVM VM" echo -e "${NONE}" echo "The script has detected that you run the installation in a KVM virtual machine." + echo if grep -Fxq "kvm.conf" ~/dotfiles-versions/$version/hypr/conf/environment.conf then echo ":: KVM Environment already set." diff --git a/.install/yay.sh b/.install/yay.sh index 9ca0f0b..6a84464 100644 --- a/.install/yay.sh +++ b/.install/yay.sh @@ -1,12 +1,12 @@ # ------------------------------------------------------ # Check if yay is installed # ------------------------------------------------------ -echo -e "${GREEN}" -figlet "yay" -echo -e "${NONE}" if sudo pacman -Qs yay > /dev/null ; then echo ":: yay is already installed!" else + echo -e "${GREEN}" + figlet "yay" + echo -e "${NONE}" echo ":: yay is not installed. Starting the installation!" _installPackagesPacman "base-devel" SCRIPT=$(realpath "$0") @@ -18,4 +18,4 @@ else cd $temp_path echo ":: yay has been installed successfully." fi -echo "" \ No newline at end of file +echo \ No newline at end of file diff --git a/.install/zsh.sh b/.install/zsh.sh new file mode 100644 index 0000000..da46dc8 --- /dev/null +++ b/.install/zsh.sh @@ -0,0 +1,22 @@ +# ------------------------------------------------------ +# install zsh and zinit +# ------------------------------------------------------ +packagesPacman=("zsh"); + +echo "Please select the zsh plugin manager:" +zsh_manager=$(gum choose --limit=1 --cursor-prefix "( ) " --selected-prefix "(x) " --unselected-prefix "( ) " "oh my zsh" "zinit") +if [[ "${zsh_manager}" == *"oh my zsh"* ]]; then + source .install/install-packages.sh + if [ ! -d ~/.oh-my-zsh ]; then + RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" + fi + git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k + git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions + git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting + _installSymLink zshrc ~/.zshrc ~/dotfiles/.zshrc_ohmyzsh ~/.zshrc +else + packagesYay=("zinit"); + source .install/install-packages.sh + _installSymLink zshrc ~/.zshrc ~/dotfiles/.zshrc_zinit ~/.zshrc +fi +_installSymLink p10k ~/.p10k.zsh ~/dotfiles/.p10k.zsh ~/ diff --git a/.install/zshfish.sh b/.install/zshfish.sh new file mode 100644 index 0000000..453d9b4 --- /dev/null +++ b/.install/zshfish.sh @@ -0,0 +1,25 @@ +# ------------------------------------------------------ +# Select additional shell +# ------------------------------------------------------ +echo -e "${GREEN}" +figlet "Zsh Fish" +echo -e "${NONE}" +echo "Please select if you want to install zsh or fish." +echo +zshfish=$(gum choose --no-limit --cursor-prefix "( ) " --selected-prefix "(x) " --unselected-prefix "( ) " "zsh" "fish") + +if [ -z "${zshfish}" ] ;then + echo ":: No shell selected. Keep using bash." +else + echo "Please select your default shell." + echo + shell=$(echo -e "bash\n$zshfish" | gum choose --limit=1 --cursor-prefix "( ) " --selected-prefix "(x) " --unselected-prefix "( ) ") + if [[ $zshfish == *"zsh"* ]]; then + echo ":: zsh selected" + source .install/zsh.sh + fi + if [[ $zshfish == *"fish"* ]]; then + echo ":: fish selected" + source .install/fish.sh + fi +fi diff --git a/.p10k.zsh b/.p10k.zsh new file mode 100644 index 0000000..a1f121b --- /dev/null +++ b/.p10k.zsh @@ -0,0 +1,1718 @@ +# Generated by Powerlevel10k configuration wizard on 2024-06-07 at 00:20 EDT. +# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 04242. +# Wizard options: nerdfont-v3 + powerline, small icons, unicode, lean, 24h time, +# 2 lines, disconnected, no frame, compact, many icons, concise, instant_prompt=verbose. +# Type `p10k configure` to generate another config. +# +# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate +# your own config based on it. +# +# Tip: Looking for a nice color? Here's a one-liner to print colormap. +# +# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done + +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +() { + emulate -L zsh -o extended_glob + + # Unset all configuration options. This allows you to apply configuration changes without + # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. + unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' + + # Zsh >= 5.1 is required. + [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + + # The list of segments shown on the left. Fill it with the most important segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + os_icon # os identifier + dir # current directory + vcs # git status + # =========================[ Line #2 ]========================= + newline # \n + prompt_char # prompt symbol + ) + + # The list of segments shown on the right. Fill it with less important segments. + # Right prompt on the last prompt line (where you are typing your commands) gets + # automatically hidden when the input line reaches it. Right prompt above the + # last prompt line gets hidden if it would overlap with left prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + status # exit code of the last command + command_execution_time # duration of the last command + background_jobs # presence of background jobs + direnv # direnv status (https://direnv.net/) + asdf # asdf version manager (https://github.com/asdf-vm/asdf) + virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) + anaconda # conda environment (https://conda.io/) + pyenv # python environment (https://github.com/pyenv/pyenv) + goenv # go environment (https://github.com/syndbg/goenv) + nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) + nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) + nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) + # node_version # node.js version + # go_version # go version (https://golang.org) + # rust_version # rustc version (https://www.rust-lang.org) + # dotnet_version # .NET version (https://dotnet.microsoft.com) + # php_version # php version (https://www.php.net/) + # laravel_version # laravel php framework version (https://laravel.com/) + # java_version # java version (https://www.java.com/) + # package # name@version from package.json (https://docs.npmjs.com/files/package.json) + rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) + rvm # ruby version from rvm (https://rvm.io) + fvm # flutter version management (https://github.com/leoafarias/fvm) + luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) + jenv # java version from jenv (https://github.com/jenv/jenv) + plenv # perl version from plenv (https://github.com/tokuhirom/plenv) + perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) + phpenv # php version from phpenv (https://github.com/phpenv/phpenv) + scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) + haskell_stack # haskell version from stack (https://haskellstack.org/) + kubecontext # current kubernetes context (https://kubernetes.io/) + terraform # terraform workspace (https://www.terraform.io) + # terraform_version # terraform version (https://www.terraform.io) + aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) + azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) + gcloud # google cloud cli account and project (https://cloud.google.com/) + google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) + toolbox # toolbox name (https://github.com/containers/toolbox) + context # user@hostname + nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + ranger # ranger shell (https://github.com/ranger/ranger) + yazi # yazi shell (https://github.com/sxyazi/yazi) + nnn # nnn shell (https://github.com/jarun/nnn) + lf # lf shell (https://github.com/gokcehan/lf) + xplr # xplr shell (https://github.com/sayanarijit/xplr) + vim_shell # vim shell indicator (:sh) + midnight_commander # midnight commander shell (https://midnight-commander.org/) + nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) + chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) + # vpn_ip # virtual private network indicator + # load # CPU load + # disk_usage # disk usage + # ram # free RAM + # swap # used swap + todo # todo items (https://github.com/todotxt/todo.txt-cli) + timewarrior # timewarrior tracking status (https://timewarrior.net/) + taskwarrior # taskwarrior task count (https://taskwarrior.org/) + per_directory_history # Oh My Zsh per-directory-history local/global indicator + # cpu_arch # CPU architecture + time # current time + # =========================[ Line #2 ]========================= + newline + # ip # ip address and bandwidth usage for a specified network interface + # public_ip # public IP address + # proxy # system-wide http/https/ftp proxy + # battery # internal battery + # wifi # wifi speed + # example # example user-defined segment (see prompt_example function below) + ) + + # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. + typeset -g POWERLEVEL9K_MODE=nerdfont-v3 + # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid + # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. + typeset -g POWERLEVEL9K_ICON_PADDING=none + + # Basic style options that define the overall look of your prompt. You probably don't want to + # change them. + typeset -g POWERLEVEL9K_BACKGROUND= # transparent background + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol + + # When set to true, icons appear before content on both sides of the prompt. When set + # to false, icons go after content. If empty or not set, icons go before content in the left + # prompt and after content in the right prompt. + # + # You can also override it for a specific segment: + # + # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false + # + # Or for a specific segment in specific state: + # + # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false + typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true + + # Add an empty line before each prompt. + typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false + + # Connect left prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX= + # Connect right prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX= + + # The left end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + # The right end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= + + # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll + # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and + # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below. + typeset -g POWERLEVEL9K_SHOW_RULER=false + typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·' + typeset -g POWERLEVEL9K_RULER_FOREGROUND=242 + + # Filler between left and right prompt on the first prompt line. You can set it to '·' or '─' + # to make it easier to see the alignment between left and right prompt and to separate prompt + # from command output. It serves the same purpose as ruler (see above) without increasing + # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false + # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact + # prompt. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' + if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then + # The color of the filler. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=242 + # Add a space between the end of left prompt and the filler. + typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' ' + # Add a space between the filler and the start of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' ' + # Start filler from the edge of the screen if there are no left segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' + # End filler on the edge of the screen if there are no right segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' + fi + + #################################[ os_icon: os identifier ]################################## + # OS identifier color. + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND= + # Custom icon. + # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' + + ################################[ prompt_char: prompt symbol ]################################ + # Green prompt symbol if the last command succeeded. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76 + # Red prompt symbol if the last command failed. + typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196 + # Default prompt symbol. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' + # Prompt symbol in command vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' + # Prompt symbol in visual vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' + # Prompt symbol in overwrite vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true + # No line terminator if prompt_char is the last segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' + # No line introducer if prompt_char is the first segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + + ##################################[ dir: current directory ]################################## + # Default current directory color. + typeset -g POWERLEVEL9K_DIR_FOREGROUND=31 + # If directory is too long, shorten some of its segments to the shortest possible unique + # prefix. The shortened directory can be tab-completed to the original. + typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique + # Replace removed segment suffixes with this symbol. + typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= + # Color of the shortened directory segments. + typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=103 + # Color of the anchor directory segments. Anchor segments are never shortened. The first + # segment is always an anchor. + typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39 + # Display anchor directory segments in bold. + typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true + # Don't shorten directories that contain any of these files. They are anchors. + local anchor_files=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .go-version + .ruby-version + .lua-version + .java-version + .perl-version + .php-version + .tool-versions + .shorten_folder_marker + .svn + .terraform + CVS + Cargo.toml + composer.json + go.mod + package.json + stack.yaml + ) + typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" + # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains + # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is + # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) + # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers + # and other directories don't. + # + # Optionally, "first" and "last" can be followed by ":" where is an integer. + # This moves the truncation point to the right (positive offset) or to the left (negative offset) + # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0" + # respectively. + typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false + # Don't shorten this many last directory segments. They are anchors. + typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + # Shorten directory if it's longer than this even if there is space for it. The value can + # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, + # directory will be shortened only when prompt doesn't fit or when other parameters demand it + # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). + # If set to `0`, directory will always be shortened to its minimum length. + typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this + # many columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least + # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 + # If set to true, embed a hyperlink into the directory. Useful for quickly + # opening a directory in the file manager simply by clicking the link. + # Can also be handy when the directory is shortened, as it allows you to see + # the full directory that was used in previous commands. + typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + + # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON + # and POWERLEVEL9K_DIR_CLASSES below. + typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 + + # The default icon shown next to non-writable and non-existent directories when + # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3. + # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' + + # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different + # directories. It must be an array with 3 * N elements. Each triplet consists of: + # + # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with + # extended_glob option enabled. + # 2. Directory class for the purpose of styling. + # 3. An empty string. + # + # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. + # + # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories + # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=( + # '~/work(|/*)' WORK '' + # '~(|/*)' HOME '' + # '*' DEFAULT '') + # + # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one + # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or + # WORK_NON_EXISTENT. + # + # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an + # option to define custom colors and icons for different directory classes. + # + # # Styling for WORK. + # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39 + # + # # Styling for WORK_NOT_WRITABLE. + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39 + # + # # Styling for WORK_NON_EXISTENT. + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39 + # + # If a styling parameter isn't explicitly defined for some class, it falls back to the classless + # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls + # back to POWERLEVEL9K_DIR_FOREGROUND. + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=() + + # Custom prefix. + # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' + + #####################################[ vcs: git status ]###################################### + # Branch icon. Set this parameter to '\UE0A0 ' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 ' + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + + # Formatter for Git status. + # + # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # + # You can edit the function to customize how Git status looks. + # + # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: + # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. + function my_git_formatter() { + emulate -L zsh + + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from + # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. + typeset -g my_git_format=$P9K_CONTENT + return + fi + + if (( $1 )); then + # Styling for up-to-date Git status. + local meta='%f' # default foreground + local clean='%76F' # green foreground + local modified='%178F' # yellow foreground + local untracked='%39F' # blue foreground + local conflicted='%196F' # red foreground + else + # Styling for incomplete and stale Git status. + local meta='%244F' # grey foreground + local clean='%244F' # grey foreground + local modified='%244F' # grey foreground + local untracked='%244F' # grey foreground + local conflicted='%244F' # grey foreground + fi + + local res + + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then + local branch=${(V)VCS_STATUS_LOCAL_BRANCH} + # If local branch name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}" + fi + + if [[ -n $VCS_STATUS_TAG + # Show tag only if not on a branch. + # Tip: To always show tag, delete the next line. + && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line + ]]; then + local tag=${(V)VCS_STATUS_TAG} + # If tag name is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show tag name in full without truncation, delete the next line. + (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line + res+="${meta}#${clean}${tag//\%/%%}" + fi + + # Display the current Git commit if there is no branch and no tag. + # Tip: To always display the current Git commit, delete the next line. + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line + res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + + # Show tracking branch name if it differs from local branch. + if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" + fi + + # Display "wip" if the latest commit's summary contains "wip" or "WIP". + if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then + res+=" ${modified}wip" + fi + + if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then + # ⇣42 if behind the remote. + (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " + (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + elif [[ -n $VCS_STATUS_REMOTE_BRANCH ]]; then + # Tip: Uncomment the next line to display '=' if up to date with the remote. + # res+=" ${clean}=" + fi + + # ⇠42 if behind the push remote. + (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" + (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " + # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. + (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" + # "─" if the number of unstaged files is unknown. This can happen due to + # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower + # than the number of files in the Git index, or due to bash.showDirtyState being set to false + # in the repository config. The number of staged and untracked files may also be unknown + # in this case. + (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" + + typeset -g my_git_format=$res + } + functions -M my_git_formatter 2>/dev/null + + # Don't count the number of unstaged, untracked and conflicted files in Git repositories with + # more than this many files in the index. Negative value means infinity. + # + # If you are working in Git repositories with tens of millions of files and seeing performance + # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output + # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's + # config: `git config bash.showDirtyState false`. + typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 + + # Don't show Git status in prompt for repositories whose workdir matches this pattern. + # For example, if set to '~', the Git repository at $HOME/.git will be ignored. + # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. + typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' + + # Disable the default Git status formatting. + typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true + # Install our own Git status formatter. + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' + typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' + # Enable counters for staged, unstaged, etc. + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + + # Icon color. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 + typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244 + # Custom icon. + # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_VCS_PREFIX='%fon ' + + # Show status of repositories of these types. You can add svn and/or hg if you are + # using them. If you do, your prompt may become slow even when your current directory + # isn't in an svn or hg repository. + typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) + + # These settings are used for repositories other than Git or when gitstatusd fails and + # Powerlevel10k has to fall back to using vcs_info. + typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 + + ##########################[ status: exit code of the last command ]########################### + # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and + # style them independently from the regular OK and ERROR state. + typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true + + # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as + # it will signify success by turning green. + typeset -g POWERLEVEL9K_STATUS_OK=false + typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when some part of a pipe command fails but the overall exit status is zero. It may look + # like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as + # it will signify error by turning red. + typeset -g POWERLEVEL9K_STATUS_ERROR=false + typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when the last command was terminated by a signal. + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160 + # Use terse signal names: "INT" instead of "SIGINT(2)". + typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when some part of a pipe command fails and the overall exit status is also non-zero. + # It may look like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' + + ###################[ command_execution_time: duration of the last command ]################### + # Show duration of the last command if takes at least this many seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 + # Show this many fractional digits. Zero means round to seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + # Execution time color. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=101 + # Duration format: 1d 2h 3m 4s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' + # Custom icon. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook ' + + #######################[ background_jobs: presence of background jobs ]####################### + # Don't show the number of background jobs. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false + # Background jobs color. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ direnv: direnv status (https://direnv.net/) ]######################## + # Direnv color. + typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### + # Default asdf color. Only used to display tools for which there is no color override (see below). + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND. + typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66 + + # There are four parameters that can be used to hide asdf tools. Each parameter describes + # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at + # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to + # hide a tool, it gets shown. + # + # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and + # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: + # + # asdf local python 3.8.1 + # asdf global python 3.8.1 + # + # After running both commands the current python version is 3.8.1 and its source is "local" as + # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, + # it'll hide python version in this case because 3.8.1 is the same as the global version. + # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't + # contain "local". + + # Hide tool versions that don't come from one of these sources. + # + # Available sources: + # + # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" + # - local `asdf current` says "set by /some/not/home/directory/file" + # - global `asdf current` says "set by /home/username/file" + # + # Note: If this parameter is set to (shell local global), it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. + typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) + + # If set to false, hide tool versions that are the same as global. + # + # Note: The name of this parameter doesn't reflect its meaning at all. + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. + typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false + + # If set to false, hide tool versions that are equal to "system". + # + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. + typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true + + # If set to non-empty value, hide tools unless there is a file matching the specified file pattern + # in the current directory, or its parent directory, or its grandparent directory, and so on. + # + # Note: If this parameter is set to empty value, it won't hide tools. + # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. + # + # Example: Hide nodejs version when there is no package.json and no *.js files in the current + # directory, in `..`, in `../..` and so on. + # + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' + typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= + + # Ruby version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168 + # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Python version from asdf. + typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Go version from asdf. + typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Node.js version from asdf. + typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=70 + # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Rust version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar' + + # .NET Core version from asdf. + typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=134 + # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_DOTNET_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Flutter version from asdf. + typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=38 + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Lua version from asdf. + typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Java version from asdf. + typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Perl version from asdf. + typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=67 + # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Erlang version from asdf. + typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=125 + # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Elixir version from asdf. + typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=129 + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Postgres version from asdf. + typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=31 + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Haskell version from asdf. + typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=172 + # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Julia version from asdf. + typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=70 + # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar' + + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### + # NordVPN connection indicator color. + typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 + # Hide NordVPN connection indicator when not connected. + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= + # Custom icon. + # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ####################[ yazi: yazi shell (https://github.com/sxyazi/yazi) ]##################### + # Yazi shell color. + typeset -g POWERLEVEL9K_YAZI_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_YAZI_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### + # Nnn shell color. + typeset -g POWERLEVEL9K_NNN_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ lf: lf shell (https://github.com/gokcehan/lf) ]####################### + # lf shell color. + typeset -g POWERLEVEL9K_LF_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_LF_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## + # xplr shell color. + typeset -g POWERLEVEL9K_XPLR_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########################[ vim_shell: vim shell indicator (:sh) ]########################### + # Vim shell indicator color. + typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34 + # Custom icon. + # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]###### + # Midnight Commander shell color. + typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]## + # Nix shell color. + typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74 + + # Display the icon of nix_shell if PATH contains a subdirectory of /nix/store. + # typeset -g POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH=false + + # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. + # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################[ chezmoi_shell: chezmoi shell (https://www.chezmoi.io/) ]################## + # chezmoi shell color. + typeset -g POWERLEVEL9K_CHEZMOI_SHELL_FOREGROUND=33 + # Custom icon. + # typeset -g POWERLEVEL9K_CHEZMOI_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ disk_usage: disk usage ]################################## + # Colors for different levels of disk usage. + typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35 + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=220 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=160 + # Thresholds for different levels of disk usage (percentage points). + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 + # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. + typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false + # Custom icon. + # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ ram: free RAM ]####################################### + # RAM color. + typeset -g POWERLEVEL9K_RAM_FOREGROUND=66 + # Custom icon. + # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################################[ swap: used swap ]###################################### + # Swap color. + typeset -g POWERLEVEL9K_SWAP_FOREGROUND=96 + # Custom icon. + # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ load: CPU load ]###################################### + # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. + typeset -g POWERLEVEL9K_LOAD_WHICH=5 + # Load color when load is under 50%. + typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66 + # Load color when load is between 50% and 70%. + typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178 + # Load color when load is over 70%. + typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166 + # Custom icon. + # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ + # Todo color. + typeset -g POWERLEVEL9K_TODO_FOREGROUND=110 + # Hide todo when the total number of tasks is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true + # Hide todo when the number of tasks after filtering is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false + + # Todo format. The following parameters are available within the expansion. + # + # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. + # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. + # + # These variables correspond to the last line of the output of `todo.sh -p ls`: + # + # TODO: 24 of 42 tasks shown + # + # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. + # + # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ + # Timewarrior color. + typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110 + # If the tracked task is longer than 24 characters, truncate and append "…". + # Tip: To always display tasks without truncation, delete the following parameter. + # Tip: To hide task names and display just the icon when time tracking is enabled, set the + # value of the following parameter to "". + typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' + + # Custom icon. + # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## + # Taskwarrior color. + typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74 + + # Taskwarrior segment format. The following parameters are available within the expansion. + # + # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. + # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. + # + # Zero values are represented as empty parameters. + # + # The default format: + # + # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' + # + # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]####### + # Color when using local/global history. + typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=135 + typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=130 + + # Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon. + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION='' + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION='' + + # Custom icon. + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ cpu_arch: CPU architecture ]################################ + # CPU architecture color. + typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172 + + # Hide the segment when on a specific CPU architecture. + # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= + # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ context: user@hostname ]################################## + # Context color when running with privileges. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 + # Context color in SSH without privileges. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180 + # Default context color (no privileges, no SSH). + typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 + + # Context format when running with privileges: bold user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' + # Context format when in SSH without privileges: user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' + # Default context format (no privileges, no SSH): user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' + + # Don't show context unless running with privileges or in SSH. + # Tip: Remove the next line to always show context. + typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith ' + + ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### + # Python virtual environment color. + typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37 + # Don't show Python version next to the virtual environment name. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false + # If set to "false", won't show virtualenv if pyenv is already shown. + # If set to "if-different", won't show virtualenv if it's the same as pyenv. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ anaconda: conda environment (https://conda.io/) ]###################### + # Anaconda environment color. + typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37 + + # Anaconda segment format. The following parameters are available within the expansion. + # + # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment. + # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment. + # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below). + # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version). + # + # CONDA_PROMPT_MODIFIER can be configured with the following command: + # + # conda config --set env_prompt '({default_env}) ' + # + # The last argument is a Python format string that can use the following variables: + # + # - prefix The same as CONDA_PREFIX. + # - default_env The same as CONDA_DEFAULT_ENV. + # - name The last segment of CONDA_PREFIX. + # - stacked_env Comma-separated list of names in the environment stack. The first element is + # always the same as default_env. + # + # Note: '({default_env}) ' is the default value of env_prompt. + # + # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER + # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former + # is empty. + typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}' + + # Custom icon. + # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ + # Pyenv color. + typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37 + # Hide python version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) + # If set to false, hide python version if it's the same as global: + # $(pyenv version-name) == $(pyenv global). + typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide python version if it's equal to "system". + typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true + + # Pyenv segment format. The following parameters are available within the expansion. + # + # - P9K_CONTENT Current pyenv environment (pyenv version-name). + # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). + # + # The default format has the following logic: + # + # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or + # starts with "$P9K_PYENV_PYTHON_VERSION/". + # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". + typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' + + # Custom icon. + # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ + # Goenv color. + typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37 + # Hide go version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) + # If set to false, hide go version if it's the same as global: + # $(goenv version-name) == $(goenv global). + typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide go version if it's equal to "system". + typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## + # Nodenv color. + typeset -g POWERLEVEL9K_NODENV_FOREGROUND=70 + # Hide node version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) + # If set to false, hide node version if it's the same as global: + # $(nodenv version-name) == $(nodenv global). + typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### + # Nvm color. + typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 + # If set to false, hide node version if it's the same as default: + # $(nvm version current) == $(nvm version default). + typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ + # Nodeenv color. + typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=70 + # Don't show Node version next to the environment name. + typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false + # Separate environment name from Node version only with a space. + typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############################[ node_version: node.js version ]############################### + # Node version color. + typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=70 + # Show node version only when in a directory tree containing package.json. + typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ go_version: go version (https://golang.org) ]######################## + # Go version color. + typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 + # Show go version only when in a go project subdirectory. + typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## + # Rust version color. + typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 + # Show rust version only when in a rust project subdirectory. + typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ####################[ java_version: java version (https://www.java.com/) ]#################### + # Java version color. + typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=32 + # Show java version only when in a java project subdirectory. + typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true + # Show brief version. + typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false + # Custom icon. + # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### + # Package color. + typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=117 + # Package format. The following parameters are available within the expansion. + # + # - P9K_PACKAGE_NAME The value of `name` field in package.json. + # - P9K_PACKAGE_VERSION The value of `version` field in package.json. + # + # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' + # Custom icon. + # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## + # Rbenv color. + typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 + # Hide ruby version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) + # If set to false, hide ruby version if it's the same as global: + # $(rbenv version-name) == $(rbenv global). + typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide ruby version if it's equal to "system". + typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## + # Rvm color. + typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 + # Don't show @gemset at the end. + typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false + # Don't show ruby- at the front. + typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ + # Fvm color. + typeset -g POWERLEVEL9K_FVM_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### + # Lua color. + typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32 + # Hide lua version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) + # If set to false, hide lua version if it's the same as global: + # $(luaenv version-name) == $(luaenv global). + typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide lua version if it's equal to "system". + typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ + # Java color. + typeset -g POWERLEVEL9K_JENV_FOREGROUND=32 + # Hide java version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) + # If set to false, hide java version if it's the same as global: + # $(jenv version-name) == $(jenv global). + typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide java version if it's equal to "system". + typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ + # Perl color. + typeset -g POWERLEVEL9K_PLENV_FOREGROUND=67 + # Hide perl version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) + # If set to false, hide perl version if it's the same as global: + # $(plenv version-name) == $(plenv global). + typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide perl version if it's equal to "system". + typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ + # Perlbrew color. + typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 + # Show perlbrew version only when in a perl project subdirectory. + typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true + # Don't show "perl-" at the front. + typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide php version if it's equal to "system". + typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]####### + # Scala color. + typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=160 + # Hide scala version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global) + # If set to false, hide scala version if it's the same as global: + # $(scalaenv version-name) == $(scalaenv global). + typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide scala version if it's equal to "system". + typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### + # Haskell color. + typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172 + # Hide haskell version if it doesn't come from one of these sources. + # + # shell: version is set by STACK_YAML + # local: version is set by stack.yaml up the directory tree + # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) + typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) + # If set to false, hide haskell version if it's the same as in the implicit global project. + typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true + # Custom icon. + # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# + # Show kubecontext only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show kubecontext. + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold|kubent|kubecolor|cmctl|sparkctl' + + # Kubernetes context classes for the purpose of using different colors, icons and expansions with + # different contexts. + # + # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current kubernetes context gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current kubernetes context is "deathray-testing/default", its class is TEST + # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=134 + # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext + # segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # Within the expansion the following parameters are always available: + # + # - P9K_CONTENT The content that would've been displayed if there was no content + # expansion defined. + # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE + # in the output of `kubectl config get-contexts`. If there is no + # namespace, the parameter is set to "default". + # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the + # output of `kubectl config get-contexts`. + # + # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), + # the following extra parameters are available: + # + # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. + # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. + # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. + # + # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, + # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=gke + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + # + # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=eks + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= + # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + # Append the current context's namespace if it's not "default". + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' + + # Custom prefix. + # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' + + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # Don't show terraform workspace if it's literally "default". + typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false + # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current terraform workspace gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' OTHER) + # + # If your current terraform workspace is "project_test", its class is TEST because "project_test" + # doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' OTHER) + typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38 + # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ terraform_version: terraform version (https://www.terraform.io) ]############## + # Terraform version color. + typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# + # Show aws only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show aws. + typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|terraform|pulumi|terragrunt' + + # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current AWS profile gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current AWS profile is "company_test", its class is TEST + # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208 + # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # AWS segment format. The following parameters are available within the expansion. + # + # - P9K_AWS_PROFILE The name of the current AWS profile. + # - P9K_AWS_REGION The region associated with the current AWS profile. + typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' + + #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# + # AWS Elastic Beanstalk environment color. + typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Show azure only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show azure. + typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' + + # POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current azure account name gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_AZURE_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_AZURE_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' OTHER) + # + # If your current azure account is "company_test", its class is TEST because "company_test" + # doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_AZURE_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_AZURE_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' OTHER) + + # Azure account name color. + typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=32 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### + # Show gcloud only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show gcloud. + typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' + # Google cloud color. + typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32 + + # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or + # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative + # enough. You can use the following parameters in the expansions. Each of them corresponds to the + # output of `gcloud` tool. + # + # Parameter | Source + # -------------------------|-------------------------------------------------------------------- + # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' + # P9K_GCLOUD_ACCOUNT | gcloud config get-value account + # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project + # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'. + # + # Obtaining project name requires sending a request to Google servers. This can take a long time + # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud + # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets + # set and gcloud prompt segment transitions to state COMPLETE. + # + # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL + # and COMPLETE. You can also hide gcloud in state PARTIAL by setting + # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and + # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. + typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' + typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' + + # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name + # this often. Negative value disables periodic polling. In this mode project name is retrieved + # only when the current configuration, account or project id changes. + typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 + + # Custom icon. + # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# + # Show google_app_cred only when the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show google_app_cred. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' + + # Google application credentials classes for the purpose of using different colors, icons and + # expansions with different credentials. + # + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first + # element in each pair defines a pattern against which the current kubernetes context gets + # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion + # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION + # parameters, you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. + # The first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD + # '*:*test*:*' TEST + # '*' DEFAULT) + # + # If your current Google application credentials is "service_account deathray-testing x@y.com", + # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD # These values are examples that are unlikely + # '*:*test*:*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by + # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # You can use the following parameters in the expansion. Each of them corresponds to one of the + # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. + # + # Parameter | JSON key file field + # ---------------------------------+--------------- + # P9K_GOOGLE_APP_CRED_TYPE | type + # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id + # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' + + ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### + # Toolbox color. + typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=178 + # Don't display the name of the toolbox if it matches fedora-toolbox-*. + typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' + # Custom icon. + # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%fin ' + + ###############################[ public_ip: public IP address ]############################### + # Public IP color. + typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 + # Custom icon. + # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ########################[ vpn_ip: virtual private network indicator ]######################### + # VPN IP color. + typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81 + # When on VPN, show just an icon without the IP address. + # Tip: To display the private IP address when on VPN, remove the next line. + typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= + # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN + # to see the name of the interface. + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)' + # If set to true, show one segment per matching network interface. If set to false, show only + # one segment corresponding to the first matching network interface. + # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. + typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false + # Custom icon. + # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### + # IP color. + typeset -g POWERLEVEL9K_IP_FOREGROUND=38 + # The following parameters are accessible within the expansion: + # + # Parameter | Meaning + # ----------------------+------------------------------------------- + # P9K_IP_IP | IP address + # P9K_IP_INTERFACE | network interface + # P9K_IP_RX_BYTES | total number of bytes received + # P9K_IP_TX_BYTES | total number of bytes sent + # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt + # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt + # P9K_IP_RX_RATE | receive rate (since last prompt) + # P9K_IP_TX_RATE | send rate (since last prompt) + typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %70F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %215F⇡$P9K_IP_TX_RATE}' + # Show information for the first network interface whose name matches this regular expression. + # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. + typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*' + # Custom icon. + # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ battery: internal battery ]################################# + # Show battery in red when it's below this level and not connected to power supply. + typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 + typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 + # Show battery in green when it's charging or fully charged. + typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70 + # Show battery in yellow when it's discharging. + typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 + # Battery pictograms going from low to high level of charge. + typeset -g POWERLEVEL9K_BATTERY_STAGES='\UF008E\UF007A\UF007B\UF007C\UF007D\UF007E\UF007F\UF0080\UF0081\UF0082\UF0079' + # Don't show the remaining time to charge/discharge. + typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false + + #####################################[ wifi: wifi speed ]##################################### + # WiFi color. + typeset -g POWERLEVEL9K_WIFI_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). + # + # # Wifi colors and icons for different signal strength levels (low to high). + # typeset -g my_wifi_fg=(68 68 68 68 68) # <-- change these values + # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values + # + # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' + # + # The following parameters are accessible within the expansions: + # + # Parameter | Meaning + # ----------------------+--------------- + # P9K_WIFI_SSID | service set identifier, a.k.a. network name + # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown + # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second + # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 + # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 + # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) + + ####################################[ time: current time ]#################################### + # Current time color. + typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 + # Format for the current time: 09:51:02. See `man 3 strftime`. + typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' + # If set to true, time will update when you hit enter. This way prompts for the past + # commands will contain the start times of their commands as opposed to the default + # behavior where they contain the end times of their preceding commands. + typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false + # Custom icon. + # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_TIME_PREFIX='%fat ' + + # Example of a user-defined prompt segment. Function prompt_example will be called on every + # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or + # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. + # + # Type `p10k help segment` for documentation and a more sophisticated example. + function prompt_example() { + p10k segment -f 208 -i '⭐' -t 'hello, %n' + } + + # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job + # is to generate the prompt segment for display in instant prompt. See + # https://github.com/romkatv/powerlevel10k#instant-prompt. + # + # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function + # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k + # will replay these calls without actually calling instant_prompt_*. It is imperative that + # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this + # rule is not observed, the content of instant prompt will be incorrect. + # + # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If + # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. + function instant_prompt_example() { + # Since prompt_example always makes the same `p10k segment` calls, we can call it from + # instant_prompt_example. This will give us the same `example` prompt segment in the instant + # and regular prompts. + prompt_example + } + + # User-defined prompt segments can be customized the same way as built-in segments. + # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 + # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt + # when accepting a command line. Supported values: + # + # - off: Don't change prompt when accepting a command line. + # - always: Trim down prompt when accepting a command line. + # - same-dir: Trim down prompt when accepting a command line unless this is the first command + # typed after changing current working directory. + typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off + + # Instant prompt mode. + # + # - off: Disable instant prompt. Choose this if you've tried instant prompt and found + # it incompatible with your zsh configuration files. + # - quiet: Enable instant prompt and don't print warnings when detecting console output + # during zsh initialization. Choose this if you've read and understood + # https://github.com/romkatv/powerlevel10k#instant-prompt. + # - verbose: Enable instant prompt and print a warning when detecting console output during + # zsh initialization. Choose this if you've never tried instant prompt, haven't + # seen the warning, or if you are unsure what this all means. + typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose + + # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. + # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload + # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you + # really need it. + typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true + + # If p10k is already loaded, reload configuration. + # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. + (( ! $+functions[p10k] )) || p10k reload +} + +# Tell `p10k configure` which file it should overwrite. +typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} + +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/.settings/browser.sh b/.settings/browser.sh index e090179..988464c 100755 --- a/.settings/browser.sh +++ b/.settings/browser.sh @@ -1 +1 @@ -chromium +google-chrome-stable diff --git a/.settings/editor.sh b/.settings/editor.sh index 4401e48..58c11b4 100755 --- a/.settings/editor.sh +++ b/.settings/editor.sh @@ -1 +1 @@ -mousepad \ No newline at end of file +~/dotfiles/.settings/terminal.sh -e vim \ No newline at end of file diff --git a/.settings/filemanager.sh b/.settings/filemanager.sh index af8fd0e..9f0175d 100755 --- a/.settings/filemanager.sh +++ b/.settings/filemanager.sh @@ -1 +1 @@ -thunar \ No newline at end of file +nautilus \ No newline at end of file diff --git a/.settings/hyprshade.sh b/.settings/hyprshade.sh new file mode 100644 index 0000000..c0cdbd8 --- /dev/null +++ b/.settings/hyprshade.sh @@ -0,0 +1 @@ +hyprshade_filter="blue-light-filter" \ No newline at end of file diff --git a/.settings/networkmanager.sh b/.settings/networkmanager.sh index f3d8804..e69de29 100755 --- a/.settings/networkmanager.sh +++ b/.settings/networkmanager.sh @@ -1 +0,0 @@ -nm-connection-editor \ No newline at end of file diff --git a/.settings/software.sh b/.settings/software.sh index 61bd6e1..e69de29 100755 --- a/.settings/software.sh +++ b/.settings/software.sh @@ -1 +0,0 @@ -alacritty -e pacseek \ No newline at end of file diff --git a/.settings/terminal.sh b/.settings/terminal.sh index f681b82..e6feb0f 100755 --- a/.settings/terminal.sh +++ b/.settings/terminal.sh @@ -1 +1 @@ -alacritty \ No newline at end of file +kitty diff --git a/.settings/wallpaper-effect.sh b/.settings/wallpaper-effect.sh new file mode 100644 index 0000000..cfb931e --- /dev/null +++ b/.settings/wallpaper-effect.sh @@ -0,0 +1 @@ +off diff --git a/.settings/wallpaper-folder.sh b/.settings/wallpaper-folder.sh new file mode 100644 index 0000000..8d138d1 --- /dev/null +++ b/.settings/wallpaper-folder.sh @@ -0,0 +1,2 @@ +# Enter the path to the folder that includes your wallpapers +wallpaper_folder=$HOME/wallpaper \ No newline at end of file diff --git a/.version/name b/.version/name index 0a35d8c..8ac3ac6 100644 --- a/.version/name +++ b/.version/name @@ -1 +1 @@ -2.9 \ No newline at end of file +2.9.1.2 \ No newline at end of file diff --git a/.version/version b/.version/version index 7b34ebb..c43cfd3 100644 --- a/.version/version +++ b/.version/version @@ -1 +1 @@ -2900 \ No newline at end of file +2912 \ No newline at end of file diff --git a/.zshrc b/.zshrc deleted file mode 100644 index bb724dc..0000000 --- a/.zshrc +++ /dev/null @@ -1,128 +0,0 @@ -# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. -# Initialization code that may require console input (password prompts, [y/n] -# confirmations, etc.) must go above this block; everything else may go below. -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi - -# If you come from bash you might have to change your $PATH. -export PATH=$HOME/bin:$HOME/.cargo/bin:$HOME/.local/bin:/usr/local/bin:$PATH - -# Path to your oh-my-zsh installation. -export ZSH="$HOME/.oh-my-zsh" - -# Set name of the theme to load --- if set to "random", it will -# load a random theme each time oh-my-zsh is loaded, in which case, -# to know which specific one was loaded, run: echo $RANDOM_THEME -# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes -# ZSH_THEME="robbyrussell" -ZSH_THEME="powerlevel10k/powerlevel10k" - -# Set list of themes to pick from when loading at random -# Setting this variable when ZSH_THEME=random will cause zsh to load -# a theme from this variable instead of looking in $ZSH/themes/ -# If set to an empty array, this variable will have no effect. -# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. -# Case-sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment one of the following lines to change the auto-update behavior -# zstyle ':omz:update' mode disabled # disable automatic updates -# zstyle ':omz:update' mode auto # update automatically without asking -# zstyle ':omz:update' mode reminder # just remind me to update when it's time - -# Uncomment the following line to change how often to auto-update (in days). -# zstyle ':omz:update' frequency 13 - -# Uncomment the following line if pasting URLs and other text is messed up. -# DISABLE_MAGIC_FUNCTIONS="true" - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -# You can also set it to another string to have that shown instead of the default red dots. -# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" -# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) -# COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# You can set one of the optional three formats: -# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# or set a custom format using the strftime function format specifications, -# see 'man strftime' for details. -# HIST_STAMPS="mm/dd/yyyy" - -# Would you like to use another custom folder than $ZSH/custom? -# ZSH_CUSTOM=/path/to/new-custom-folder - -# Which plugins would you like to load? -# Standard plugins can be found in $ZSH/plugins/ -# Custom plugins may be added to $ZSH_CUSTOM/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. -plugins=(git colored-man-pages eza z sudo zsh-autosuggestions fast-syntax-highlighting) - -source $ZSH/oh-my-zsh.sh - -# User configuration - -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='mvim' -# fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" - -alias sshkoko="TERM=xterm-256color ssh ywang2020@koko-login.hpc.fau.edu" -alias wakemac="wakeonlan 18:C0:4D:8D:56:0E" -alias ls="eza --icons=auto" -alias githashselector="git log --oneline | gum filter | cut -d' ' -f1" -alias bat="bat --paging=never" - -# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. -[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh - -eval $(thefuck --alias) -eval "$(fzf --zsh)" - -# ----------------------------------------------------- -# PYWAL -# ----------------------------------------------------- -cat ~/.cache/wal/sequences - -export EDITOR=nvim diff --git a/.zshrc_ohmyzsh b/.zshrc_ohmyzsh new file mode 100644 index 0000000..a1d2802 --- /dev/null +++ b/.zshrc_ohmyzsh @@ -0,0 +1,88 @@ +# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. +# Initialization code that may require console input (password prompts, [y/n] +# confirmations, etc.) must go above this block; everything else may go below. +if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" +fi + +# ----------------------------------------------------- +# Oh my zsh settings +# ----------------------------------------------------- + +# Path to your oh-my-zsh installation. +export ZSH="$HOME/.oh-my-zsh" + +# ZSH_THEME="robbyrussell" +ZSH_THEME="powerlevel10k/powerlevel10k" + +# Uncomment the following line to use hyphen-insensitive completion. +# Case-sensitive completion must be off. _ and - will be interchangeable. +# HYPHEN_INSENSITIVE="true" + +zstyle ':omz:update' mode auto + +# Uncomment the following line to display red dots whilst waiting for completion. +# You can also set it to another string to have that shown instead of the default red dots. +# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" +# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) +COMPLETION_WAITING_DOTS="true" + +# ----------------------------------------------------- +# Plugins +# ----------------------------------------------------- +plugins=(git colored-man-pages eza z sudo zsh-autosuggestions fast-syntax-highlighting) + +source $ZSH/oh-my-zsh.sh + +# ----------------------------------------------------- +# Variables +# ----------------------------------------------------- +export PATH=$HOME/.cargo/bin:$HOME/.local/bin:/usr/local/bin:$PATH +# export MANPATH="/usr/local/man:$MANPATH" + +export LANG=en_US.UTF-8 + +export EDITOR='nvim' + +export MAKEFLAGS='-j$(nproc)' +export CFLAGS='-march=native -O2 -pipe' + +# ----------------------------------------------------- +# Alias +# ----------------------------------------------------- +alias sshkoko="TERM=xterm-256color ssh ywang2020@koko-login.hpc.fau.edu" +alias wakemac="wakeonlan 18:C0:4D:8D:56:0E" +alias ls="eza --icons=auto" +alias githashselector="git log --oneline | gum filter | cut -d' ' -f1" +alias bat="bat --paging=never" +alias code="code --ozone-platform=wayland --enable-wayland-ime" +# fix ssh if in kitty +if [[ "$TERM" == "xterm-kitty" && -z "$SSH_CONNECTION" ]]; then + alias ssh="kitty +kitten ssh" +fi + +# ----------------------------------------------------- +# Completion +# ----------------------------------------------------- +[[ -f /home/wyj/.dart-cli-completion/zsh-config.zsh ]] && . /home/wyj/.dart-cli-completion/zsh-config.zsh || true + +# ----------------------------------------------------- +# evals +# ----------------------------------------------------- +eval $(thefuck --alias) +eval "$(fzf --zsh)" + +# ----------------------------------------------------- +# PYWAL +# ----------------------------------------------------- +cat ~/.cache/wal/sequences + +# ----------------------------------------------------- +# Custom +# ----------------------------------------------------- +[[ ! -f ~/.custom.zsh ]] || source ~/.custom.zsh + +# ----------------------------------------------------- +# miscs +# ----------------------------------------------------- +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh diff --git a/.zshrc_zinit b/.zshrc_zinit new file mode 100644 index 0000000..d13af97 --- /dev/null +++ b/.zshrc_zinit @@ -0,0 +1,64 @@ +# --------------------------------------------------- +# Zinit and plugins +# --------------------------------------------------- +source /usr/share/zinit/zinit.zsh + +# Load powerlevel10k theme +zinit ice depth"1" # git clone depth +zinit light romkatv/powerlevel10k + +# Load plugins +zinit light zsh-users/zsh-autosuggestions +zinit light zdharma-continuum/fast-syntax-highlighting +# oh-my-zsh plugins +zi snippet OMZL::git.zsh +zi snippet OMZP::git +zi snippet OMZP::sudo +zi snippet OMZP::colored-man-pages +zi snippet OMZP::eza +zi snippet OMZP::z +# others +zplugin ice as"program" pick"bin/git-dsf" +zplugin light zdharma-continuum/zsh-diff-so-fancy + +# ---------------------------------------------------- +# Variables +# ---------------------------------------------------- +export PATH=$HOME/bin:$HOME/.cargo/bin:$HOME/.local/bin:/usr/local/bin:$PATH +export EDITOR=vim + +# ---------------------------------------------------- +# Alias +# ---------------------------------------------------- +alias sshkoko="TERM=xterm-256color ssh ywang2020@koko-login.hpc.fau.edu" +alias wakemac="wakeonlan 18:C0:4D:8D:56:0E" +alias eza="eza --icons=auto" +alias githashselector="git log --oneline | gum filter | cut -d' ' -f1" +alias bat="bat --paging=never" + +# ----------------------------------------------------- +# evals +# ----------------------------------------------------- +eval $(thefuck --alias) +eval "$(fzf --zsh)" + +# ----------------------------------------------------- +# Miscs +# ----------------------------------------------------- +# fix ssh if in kitty +if [[ "$TERM" == "xterm-kitty" && -z "$SSH_CONNECTION" ]]; then + alias ssh="kitty +kitten ssh" +fi + +# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh + +# ----------------------------------------------------- +# PYWAL +# ----------------------------------------------------- +cat ~/.cache/wal/sequences + +# ----------------------------------------------------- +# Custom +# ----------------------------------------------------- +[[ ! -f ~/.custom.zsh ]] || source ~/.custom.zsh diff --git a/CHANGELOG b/CHANGELOG.md similarity index 81% rename from CHANGELOG rename to CHANGELOG.md index bb361da..0e68330 100644 --- a/CHANGELOG +++ b/CHANGELOG.md @@ -1,3 +1,39 @@ +Version 2.9.1.2 +https://gitlab.com/stephan-raabe/dotfiles/-/releases/2.9.1.1 +-------------------------------------------------------- +- Workspaces module in waybar updated to enable scroll to change the workspace https://gitlab.com/stephan-raabe/dotfiles/-/merge_requests/114 +- More functions deactivated in Game Mode (SUPER+ALT+G) +- Keybindings rofi menu updated with keybinding description. Open with right mouse click on Apps waybar module +- Fixed bug of ML4W Hyprland Settings App with Hyprland 0.41.0 + +Version 2.9.1.1 +https://gitlab.com/stephan-raabe/dotfiles/-/releases/2.9.1.1 +-------------------------------------------------------- +- New installation method for sddm sugar candy theme. Instead of using yay, the installer will download the ZIP from the repository, extract it to the Downloads folder and copy the files to the destination folder. +- A gamemode can be toggled with SUPER+ALT+G. The gaming mode will disable the animations and blur. +- Added a black ML4W Icon for black waybar themes + +Version 2.9.1 +https://gitlab.com/stephan-raabe/dotfiles/-/releases/2.9.1 +-------------------------------------------------------- +- Hyprpaper is the default wallpaper engine. swww will not be installed by the installer anymore. You can still switch to swww in the Dotfiles Settings App (System tab) but you need to install swww manually with yay -S swww +- pfetch has been replaced with fastfetch (requires an update of the .bashrc) https://gitlab.com/stephan-raabe/dotfiles/-/issues/315 +- Directory for wallpapers can be customized with new .settings/wallpaper-folder.sh https://gitlab.com/stephan-raabe/dotfiles/-/issues/325 +- Screen shading possible with hyprshade. SUPER+SHIFT+S to toggle hyprshade. The shader can be defined with the shader module in waybar or in ~/dotfiles/.settings/hyprshade.sh +For auto-activation at a dedicated time please set the filter to off and follow the instructions here https://github.com/loqusion/hyprshade. https://gitlab.com/stephan-raabe/dotfiles/-/issues/329 +- Nautilus defined as the new default file manager. Thunar is still available. +- Waybar can be toggles with SUPER+CTRL+B https://gitlab.com/stephan-raabe/dotfiles/-/issues/299 +- Installation script optimized for new gum +- During the installation of the keyboard, it can be selected between a desktop and laptop optimized configuration https://gitlab.com/stephan-raabe/dotfiles/-/issues/319. +- RDP launch script updated https://gitlab.com/stephan-raabe/dotfiles/-/issues/336 +- Nvidia environment configuration updated https://gitlab.com/stephan-raabe/dotfiles/-/issues/327 +- Pacman can be configured for parallel downloads, colors and more during the installation and with the ML4W Settings app https://gitlab.com/stephan-raabe/dotfiles/-/issues/316 +- Image conversions with imagemagick can be enabled for wallpapers. Right click on wallpaper module in waybar. You can add more effects in ~/dotfiles/hypr/effects/wallpaper +- ChatGPT Window opens on the left screen side in floating mode +- New default wallpaper +- Added hypridle inhibitor waybar module to toggle screen locking with hyprlock +- Tooltips added to all waybar modules + Version 2.9 https://gitlab.com/stephan-raabe/dotfiles/-/releases/2.9 -------------------------------------------------------- diff --git a/README.md b/README.md index f468a6c..2f50c53 100644 --- a/README.md +++ b/README.md @@ -1,538 +1,53 @@ -# ML4W Dotfiles 2.9 +# ML4W Dotfiles 2.9.1.2 -An advanced configuration of Hyprland and Qtile for Arch Linux based distributions. This package includes an installation script to install and setup the required components. +An advanced configuration of Hyprland for Arch Linux based distributions. This package includes an installation script to install and setup the required components. -[![Screenshot](screenshots/v29/screenshot-29-1.png "Screenshot")](screenshots/v29/screenshot-29-1.png) +[![Screenshot](screenshots/screenshot2.png "Screenshot")](screenshots/screenshot2.png) The ML4W Dotfiles are available as - main release (Official release): [https://gitlab.com/stephan-raabe/dotfiles](https://gitlab.com/stephan-raabe/dotfiles) - rolling release (Development release): [https://gitlab.com/stephan-raabe/dotfiles/-/tree/dev](https://gitlab.com/stephan-raabe/dotfiles/-/tree/dev) -YouTube Video [https://youtu.be/HMxHUvN6VGo](https://youtu.be/HMxHUvN6VGo) - -[TOC] - -# Installation - -The package includes an installation script that will guide you through all steps of the installation or update process. - -> PLEASE NOTE: Every Linux distribution and setup can be different. Therefore, I cannot guarantee that the installation will work everywhere. Installation on your own risk. - -## Supported platforms - -The dotfiles are tested with the following Arch based distributions: - -- Arch Linux (recommended) -- EndeavourOS -- Garuda Linux -- Arco Linux - -The installation should work on all Arch Linux based distributions as well. - -> **For Manjaro users:** Hyprland and required packages are under ongoing development. That's why it could be possible that some packages are not immediatly available on Manjaro. But usually, the packages will be published later. Maybe you can install required packages manually. - -> **For Arco Linux users:** Please reinstall/force the installation of all packages during the installation/update process of the install script. The script will also offer to remove ttf-ms-fonts if installed to avoid issues with icons on waybar. - -## Before you start - -**PLEASE BACKUP YOUR EXISTING .config FOLDER WITH YOUR DOTFILES BEFORE STARTING THE SCRIPTS FOR INITIAL INSTALLTION.** - -The installation script will create a backups from configurations of your .config folder that will be overwritten from the installation procedure and previous ML4W Dotfiles installation. - -If possible, please create a snapshot of your current system if snapper or Timeshift is installed and available. +YouTube Video [https://youtu.be/HMxHUvN6VGo](https://youtu.be/HMxHUvN6VGo) ## Installation -The easiest way to install the ML4W Dotfiles is to use the ML4W Dotfiles Installer App. +The installation should work on all Arch Linux based distributions. [You can find more information here](https://gitlab.com/stephan-raabe/dotfiles/-/wikis/home). -[You can download the app here.](https://gitlab.com/stephan-raabe/dotfiles/-/raw/main/apps/installer.AppImage) (Right click + Save link as... into your Downloads Folder) +The easiest way is to use the setup.sh script. The script will download all files from GitLab and start the installation automatically. + +Just copy/enter the following command into your terminal. ``` -# 1.) Change to the Downloads folder -cd ~/Downloads - -# 2.) Make the file executable -chmod +x installer.AppImage - -# 3.) Start the App from your terminal with -./installer.AppImage +bash <(curl -s https://gitlab.com/stephan-raabe/dotfiles/-/raw/main/setup.sh) ``` -Or with download the Installer App with wget if your starting point is a minimal Arch Linux with without DE from tty: +> PLEASE NOTE: Every Linux distribution, setup and personal configuration can be different. Therefore, I cannot guarantee that the ML4W Dotfiles will work everywhere. Installation at your own risk. -``` -# 0.) Install required packages -sudo pacman -S wget fuse2 # Only required for Minimal Arch installations. If wget or libfuse.so.2 is not installed. +## Wiki -# 1.) Create Downloads folder -mkdir ~/Downloads # If Downloads folder doesn't exists +You can find the complete documentation of the ML4W Dotfiles in the Wiki. [Open the Wiki here](https://gitlab.com/stephan-raabe/dotfiles/-/wikis/home) -# 2.) Download the installer -wget -P ~/Downloads/ https://gitlab.com/stephan-raabe/dotfiles/-/raw/main/apps/installer.AppImage +## Contributing -# 3.) Change to the Downloads folder -cd ~/Downloads +Thanks for using the ML4W Dotfiles on your system. If you find a problem or a bug, please [report your issue on this page](https://gitlab.com/stephan-raabe/dotfiles/-/issues/?sort=created_date&state=opened). -# 4.) Make the file executable -chmod +x installer.AppImage +You can also visit the [ML4W Discord Server](https://discord.gg/c4fJK7Za3g) to start a discussion with other users. -# 5.) Start the App from your terminal with -./installer.AppImage +## Screenshots -``` +[![Screenshot](screenshots/screenshot1.png "Screenshot")](screenshots/screenshot1.png) -Alternatively you can install with GIT. +[![Screenshot](screenshots/screenshot3.png "Screenshot")](screenshots/screenshot3.png) -## Update +[![Screenshot](screenshots/screenshot4.png "Screenshot")](screenshots/screenshot5.png) -You can use the integrated update feature to update your dotfiles to the main or rolling release whenever you want. - -![Update](screenshots/welcome-update-dotfiles.png "Updates") - -Start the ML4W Welcome App. You will see a notification when an update is available. You can start the update or re-installation of the ML4W Dotfiles at any time. - -You can force a clean re-installation of the dotfiles by removing the folder ~/dotfiles before starting the installation. - -> Please note that you can create a backup of your existing configuration with the backup feature of the install script. It's recommended to remove the folder ~/dotfiles only after creating a backup. - -## Uninstall - -You can use the integrated uninstallation function (ML4W Dotfiles Uninstaller App) to remove the ML4W Dotfiles from your system. - -Please select "Uninstall Dotfiles" from the ML4W Welcome App or execute ~/dotfiles/uninstall.sh - -The ML4W Dotfiles Uninstaller App will remove the dotfiles folder, related symbolic links and the desktop files of the ML4W Apps. - -The script will also try to restore old configurations back into .config if available and restored during the installation of the ML4W Dotfiles. - -## Installation in a KVM virtual machine - -Qtile X11 works fine in a KVM virtual machine. The Hyprland performance is low but it's enough for testing new features. - -In virt-manager please make sure that 3D acceleration is enabled in Video Virtio and the Listen type is set to None in Display Spice. - -To fix the mouse issue on Hyprland, open the Hyprland settings with SUPER + CTRL + S and select in Environments the variation kvm.conf - -## Hyprland & NVIDIA - -There is no official Hyprland support for Nvidia hardware. However, you might make it work properly following this page. -https://wiki.hyprland.org/Nvidia/ - -Users have reported that Hyprland with dotfiles could be installed successfully on setups with NVDIA GPUs using the nouveau open source drivers. - -Please select the following variation in the settings script (system/environment): - -https://gitlab.com/stephan-raabe/dotfiles/-/blob/main/hypr/conf/environments/nvidia.conf - -Or set the included environment variables in hyprland.conf - -## Installation Hook - -The installation script will prepare the configuration files in a folder ~/dotfiles-versions/[version] before copy the files into the final destination in ~/dotfiles - -If you want to modify the installation files just before everytime the copy procedure starts, you can create a file hook.sh in the folder ~/dotfiles-versions - -You can for example delete folders and files or update existing configurations. - -``` -#!/bin/bash -rm -rf ~/dotfiles-versions/$version/vim/ -rm -rf ~/dotfiles-versions/$version/nvim/ -``` - -This script will for example remove the vim and nvim folder before the installation. The symbolic link will not be created because the source folder doesn't exits. - -You can find a template in .install/templates/hook.sh - -## Launch Hyprland from tty - -The suggested method to start Hyprland is from tty with the command Hyprland because login managers (display managers) are not officially supported (https://wiki.hyprland.org/Getting-Started/Master-Tutorial/#launching-hyprland) - -``` -# Start Hyprland -Hyprland -``` - -You can install a custom tty login issue (layout) with the dotfiles installer. - -## Launch Hyprland with a Display Manager - -I made good experiences with the Display Manager SDDM (https://github.com/sddm/sddm). Also gdm could work. - -``` -yay -S sddm -``` - -The dotfiles installation script will offer to deactivate the installed display manager and to activate SDDM. - -The dotfiles package also includes a configuration for the SDDM theme sdd-sugar-candy (https://github.com/Kangie/sddm-sugar-candy) and a configuration to run SDDM in X11 mode to get the best compatibility. - -With the Hyprland settings script you can copy the current wallpaper into SDDM and use it as a background. - -Please check the troubleshooting section in case of issues. - -## Screenlock, suspend and DPMS - -Hypridle will start Hyprlock after 10 minutes of inactivity and will try to suspend one minutes later. - -In the ML4W Dotfiles Settings App you can define the timeouts for Hyprlock, suspend and DPSM. - -The selected hypridle configuration can be restored from the ML4W installer during a dotfiles update. - -The ML4W Dotfiles are using the recommended configuration from https://wiki.hyprland.org/Hypr-Ecosystem/hypridle/ - -# Some important key bindings - -- SUPER + RETURN: Alacritty -- SUPER + CTRL + RETURN: rofi application launcher -- SUPER + SHIFT + W: Change wallpaper -- SUPER + PRINT: Screenshot -- SUPER + CTRL + Q: Logout screen -- SUPER + CTRL + S: Settings script on Hyprland -- SUPER + SHIFT + B: Reload waybar on Hyprland - -All keybindings for Hyprland with right mouse click on Apps in waybar or here: - -- [Hyprland keybindings overview](hypr/conf/keybindings/default.conf) -- [Qtile keybindings overview](qtile/config.py) - -# Hyprland - -[![Screenshot](screenshots/v29/screenshot-29-2.png "Screenshot")](screenshots/v29/screenshot-29-2.png) - - -[![Screenshot](screenshots/v29/screenshot-29-3.png "Screenshot")](screenshots/v29/screenshot-29-3.png) - - -Watch on YouTube - -## ML4W Sidebar - -With the ML4W Sidebar you have access to all included ML4W Applications and some system information. In addition, you start the main power features for your system. - -You can also start the sidebar from the terminal with -``` -ml4w-sidebar -``` - - - -## ML4W Welcome App - -After starting the ML4W dotfiles for the first time, the ML4W Welcome App opens. This app is the starting point to discover the Hyprland setup. - -You can also start the Welcome App from the terminal with -``` -ml4w -``` - - - -The welcome screen includes the most important keybindings to open a terminal or a browser. - -You can start the ML4W Welcome App by clicking on the L icon on the right side in waybar, using the rofi application launcher or by typing ml4w in your terminal (if you're using the .bashrc from the dotfiles). - -In the Settings Menu you can access the following functions: - -- Update Wallpaper: Opens the wallpaper selector -- Change Waybar Theme: Opens the waybar theme switcher and gives access to the available themes for the waybar status bar -- Change GTK Theme: Opens nwg-look to select the theme for GTK 3 applications incl. widgets, icons and cursors -- Refresh GTK Settings: Reloads the Hyprland GTK configuration (required when changing the mouse cursor) -- Hyprland Settings: Opens the Hyprland Settings script to customize the look and feel, environment variables, monitor resolution, etc. -- Network Settings: Select your network configuration incl. WiFi -- Update your System: Starts the terminal application to update your Arch packages (pacman & yay) -- Cleanup your System: Removes old orphans and cached files generated during previous installations -- Reload Waybar: Reloads the waybar -- Toggle Waybar: You can hide or show waybar when you want to try our other status bars. - -You can find the sourcecode of the ML4W Welcome App in this repository: -https://gitlab.com/stephan-raabe/ml4w-welcome - -## ML4W Dotfiles Settings App - -You can open the ML4W dotfiles settings app with SUPER + CTRL + S to change selected dotfiles configurations and choose from variations for your hyprland.conf to customize your desktop even more. - - - -You can create custom variations by copying a file from the ~/dotfiles/hypr/conf subfolders like monitor/default.conf, give the file a custom name (e.g., mymonitor.conf) and select the variation in the dotfiles settings app in the corresponding section. - -> The ML4W Dotfiles Settings App replaces strings from several configuration files directly or based on replacement comments e.g., // START WORKSPACES That's why you shouldn't remove any of theses comments or markers to ensure full functionality of the app. - -You can also edit the file custom.conf which is included at the bottom of the hyprland.conf and can hold you personal configurations. - -You can find the sourcecode of the ML4W Dotfiles Settings App in this repository: -https://gitlab.com/stephan-raabe/ml4w-dotfiles-settings - -You can also start the Dotfiles App from the terminal with -``` -ml4w-settings -``` - -## ML4W Hyprland Settings App - -This applications supports you to customize your Hyprland installation. You can overwrite the existing configuration with custom values without adding complex configuration files. - -[![Screenshot](screenshots/screenshot-hyprland-settings.png "ML4W Hyprland Settings")](screenshots/screenshot.png) - -YOu can start the application from the application launcher, the ML4W Sidebar by clicking the ML4W Logo or from the welcome app. - -The app shows variables and current values of your running Hyprland. - -You can change the values and overwrite the existing values. The change will be axecuted immediatly. - -In the Set Variables tab you can see which values you have overwritten and can restore the old values be removing the entry. - -You can also start the Hyprland App from the terminal with - -``` -ml4w-hyprland -``` - -You can find the sourcecode of the ML4W Hyprland Settings App in this repository: -https://gitlab.com/stephan-raabe/ml4w-hyprland-settings - -## Hyprland Configuration Variations - -With configuration variations, you can customize settings and configurations for your Hyprland installation. You can manage, create and edit Hyprland Configuration Variations in the ML4W Dotfiles Settings App. - - - -[You can find more information here.](hypr/conf/README.md) - -> Please don't edit the shipped configuration variations. These will be overwritten with every update of the ML4W dotfiles. Create your own custom variation instead. - -## Wallpaper with swww or hyprpaper and Pywal - -Included is a pywal configuration that changes the color scheme based on a randomly selected wallpaper. With the key binding SUPER + SHIFT + W you can change the wallpaper coming from the folder ~/wallpaper/. - -SUPER + CTRL + W opens rofi with a list of installed wallpapers in ~/wallpaper/ for your individual selection. - -In case of issues with swww, you can switch between the Wallpaper application swww and hyprpaper. Open the ML4W Dotfiles Settings app and select the tab system. At the top you can find the Wallpaper Engine Selector. - -> PLEASE NOTE: A logout and login is required to activate the new wallpaper application. - -The hyprpaper engine uses a template stored in dotfiles/.settings/hyprpaper.tpl You can add additional configurations there. The WALLPAPER placeholder will be replaced with the current wallpaper. - -## Waybar themes and themeswitcher - -In addition, you can switch the Waybar Template with SUPER + CTRL + T or by pressing the "..." icon in Waybar with the themeswitcher. - -The templates are available in ~/dotfiles/waybar/themes. You can add your own personal themes into this folder. - -[You can find more information here.](waybar/README.md) - -## Screensharing and recording - -More information you can find here: -https://gist.github.com/PowerBall253/2dea6ddf6974ba4e5d26c3139ffb7580 - -> Please note that every Arch Linux system is different and I cannot guarantee that everything works fine on your system. - -## Main packages - -- Terminal: alacritty -- Editor: nvim -- Prompt: starship -- Wallpaper: hyprpaper (swww optional) -- Icons: Font Awesome -- Launch Menus: Rofi (Wayland) -- Colorscheme: pywal -- Browsers: Chromium -- Filemanager: Thunar -- Cursor: Bibata Modern Ice -- Icons: Papirus-Icon-Theme -- Status Bar: waybar -- Screenshots: grim & slurp -- Clipboard Manager: cliphist -- Logout: wlogout -- Idle Manager: hypridle -- Screenlock: hyprlock - -# Qtile X11 - -Click to watch on YouTube - -Click to watch on YouTube - -## Wallpaper and Pywal - -Included is a pywal configuration that changes the color scheme based on a randomly selected wallpaper. With the key binding SUPER + SHIFT + W you can change the wallpaper coming from the folder ~/wallpaper/. - -SUPER + CTRL + W opens rofi with a list of installed wallpapers in ~/wallpaper/ for your individual selection. - -## Main Packages - -- Terminal: alacritty -- Editor: nvim -- Prompt: starship -- Icons: Font Awesome -- Launch Menus: Rofi -- Colorscheme: pywal -- Browsers: Chromium -- Filemanager: Thunar -- Cursor: Bibata Modern Ice -- Icons: Papirus-Icon-Theme -- Status Bar: Qtile status bar -- Compositor: picom (optional) -- Screenshots: scrot - -# Installation/Update with GIT - -## Installation with GIT - -You can also install the dotfiles by cloning the latest main release: - -``` -# 1.) Change into your Downloads folder (create the folder if not available) -cd ~/Downloads - -# 2.) Clone the dotfiles repository into the Downloads folder -git clone --depth=1 https://gitlab.com/stephan-raabe/dotfiles.git - -# 3.) Change into the dotfiles folder -cd dotfiles - -# 4.) Start the installation -./install.sh - -``` - -## Installation with GIT (Rolling release) - -You can install the dotfiles by cloning the latest development version from the rolling release: - -``` -# 1.) Change into your Downloads folder (create the folder if not available) -cd ~/Downloads - -# 2.) Clone the dotfiles repository into the Downloads folder -git clone https://gitlab.com/stephan-raabe/dotfiles.git - -# 3.) Change into the new dotfiles folder -cd dotfiles - -# 4.) Checkout the dev branch -git checkout dev - -# 4.) Start the installation -./install.sh - -``` - -## Update with GIT - -Please follow the steps to update from earlier dotfiles versions to 2.8.3 - -``` -# 1.) Remove existing downloaded dotfiles -rm -rf ~/Downloads/dotfiles - -# 2.) Change into your Downloads folder -cd ~/Downloads - -# 3.) Clone the dotfiles repository into the Downloads folder -git clone --depth=1 https://gitlab.com/stephan-raabe/dotfiles.git - -# 4.) Change into the dotfiles folder -cd dotfiles - -# 5.) Start the installation -./install.sh - -``` - -# Base Hyprland installation with Hyperland Starter Package - -If you want to install only the core packages of Hyprland as a starting point for your Hyprland experiments please also try my Hyprland Starter script: https://gitlab.com/stephan-raabe/hyprland-starter - -# Troubleshooting - -The ML4W Welcome App includes a system diagnosis feature available in the menu with the three dots. - -Please run the diagnosis to see if all essential packages and related commands are available on your system. - -If not, you need to install the missing packages manually. - -## rofi (application launcher) is not working - -If the installation of rofi-wayland fails in the installation/update procedure please try to install it manually: - -``` -yay -S rofi-wayland -``` - -If rofi-wayland isn't available please try rofi: - -``` -yay -S rofi -``` - -## hypridle and hyprlock is not starting after an update of the dotfiles - -Please make sure that hypridle and hyprlock has been installed successfully with - -``` -yay -S hypridle hyprlock -``` - -If there is an file conflict the remove the files manually with: - -``` -sudo rm /usr/lib/debug/usr/bin/hypridle.debug -sudo rm /usr/lib/debug/usr/bin/hyprlock.debug -``` - -and start the installation again with - -``` -yay -S hypridle hyprlock -``` - -## Missing icons in waybar - -In case of missing icons on waybar, it's due to a conflict between several installed fonts (can happen especially on Arco Linux). Please make sure that ttf-ms-fonts is uninstalled and ttf-font-awesome and otf-font-awesome are installed with - -``` -yay -R ttf-ms-fonts -yay -S ttf-font-awesome otf-font-awesome -``` - -## SDDM not showing (only black screen with cursor) - -Switch to another tty with CTRL + ALT + F3 Now you can login with your user. - -Start Hyprland with Hyprland. - -You can try to reinstall all sddm related packages. - -``` -yay -S sddm-git sddm-sugar-candy-git -``` - -Or you can install another display manager. - -To stop, disable and remove sddm service. - -``` -sudo systemctl stop sddm.service -sudo systemctl disable sddm.service -sudo rm /etc/systemd/system/display-manager.service -``` - -## Waybar is not loading - -There could be a conflict with xdg-desktop-portal-gtk or xdg-desktop-portal-gnome. Please try to remove the package if installed with: - -``` -sudo pacman -R xdg-desktop-portal-gtk -``` - -# Wallpaper repository +## Wallpaper repository You can find my wallpaper collection in the repository https://gitlab.com/stephan-raabe/wallpaper -# Special Thanks +## Special Thanks THANK YOU very much for all your support, contributions and ideas: @@ -540,17 +55,20 @@ THANK YOU very much for all your support, contributions and ideas: - Don Williams: https://github.com/dwilliam62 - Teodor Orzechowski: https://gitlab.com/sq6gtt - Jamie Deppeler: https://gitlab.com/bknight2k +- Yingjie Wang: https://gitlab.com/GaugeAndGravity +- Daniel Gerber: https://gitlab.com/dan.john.gerber +- https://gitlab.com/muee and many more... Thanks to all YouTube subscribers for all your great feedback. -# Inspirations +## Inspirations The following projects have inspired me: -- https://github.com/dianaw353/hyprland-configuration-rootfs - https://github.com/prasanthrangan/hyprdots - https://github.com/sudo-harun/dotfiles +- https://github.com/dianaw353/hyprland-configuration-rootfs and many more... diff --git a/Vimix-hyprcursors/hyprcursors/alias.hlc b/Vimix-hyprcursors/hyprcursors/alias.hlc new file mode 100644 index 0000000..57284db Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/alias.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/all-scroll.hlc b/Vimix-hyprcursors/hyprcursors/all-scroll.hlc new file mode 100644 index 0000000..4c592a6 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/all-scroll.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/bottom_left_corner.hlc b/Vimix-hyprcursors/hyprcursors/bottom_left_corner.hlc new file mode 100644 index 0000000..22df3ee Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/bottom_left_corner.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/bottom_right_corner.hlc b/Vimix-hyprcursors/hyprcursors/bottom_right_corner.hlc new file mode 100644 index 0000000..324d2ef Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/bottom_right_corner.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/bottom_side.hlc b/Vimix-hyprcursors/hyprcursors/bottom_side.hlc new file mode 100644 index 0000000..fd09725 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/bottom_side.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/cell.hlc b/Vimix-hyprcursors/hyprcursors/cell.hlc new file mode 100644 index 0000000..6d5afbc Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/cell.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/center_ptr.hlc b/Vimix-hyprcursors/hyprcursors/center_ptr.hlc new file mode 100644 index 0000000..4a0c020 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/center_ptr.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/col-resize.hlc b/Vimix-hyprcursors/hyprcursors/col-resize.hlc new file mode 100644 index 0000000..888ec0f Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/col-resize.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/color-picker.hlc b/Vimix-hyprcursors/hyprcursors/color-picker.hlc new file mode 100644 index 0000000..5631c76 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/color-picker.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/context-menu.hlc b/Vimix-hyprcursors/hyprcursors/context-menu.hlc new file mode 100644 index 0000000..600c84d Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/context-menu.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/copy.hlc b/Vimix-hyprcursors/hyprcursors/copy.hlc new file mode 100644 index 0000000..dcdba11 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/copy.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/crosshair.hlc b/Vimix-hyprcursors/hyprcursors/crosshair.hlc new file mode 100644 index 0000000..e4a0113 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/crosshair.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/default.hlc b/Vimix-hyprcursors/hyprcursors/default.hlc new file mode 100644 index 0000000..00b18f4 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/default.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/dnd-move.hlc b/Vimix-hyprcursors/hyprcursors/dnd-move.hlc new file mode 100644 index 0000000..58e7ef4 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/dnd-move.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/dnd-no-drop.hlc b/Vimix-hyprcursors/hyprcursors/dnd-no-drop.hlc new file mode 100644 index 0000000..fba6657 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/dnd-no-drop.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/down-arrow.hlc b/Vimix-hyprcursors/hyprcursors/down-arrow.hlc new file mode 100644 index 0000000..082d2f0 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/down-arrow.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/draft.hlc b/Vimix-hyprcursors/hyprcursors/draft.hlc new file mode 100644 index 0000000..bbeb545 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/draft.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/fleur.hlc b/Vimix-hyprcursors/hyprcursors/fleur.hlc new file mode 100644 index 0000000..fea1f30 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/fleur.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/help.hlc b/Vimix-hyprcursors/hyprcursors/help.hlc new file mode 100644 index 0000000..65adacc Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/help.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/left-arrow.hlc b/Vimix-hyprcursors/hyprcursors/left-arrow.hlc new file mode 100644 index 0000000..6f2c2ec Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/left-arrow.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/left_side.hlc b/Vimix-hyprcursors/hyprcursors/left_side.hlc new file mode 100644 index 0000000..78234ef Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/left_side.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/no-drop.hlc b/Vimix-hyprcursors/hyprcursors/no-drop.hlc new file mode 100644 index 0000000..5429b48 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/no-drop.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/not-allowed.hlc b/Vimix-hyprcursors/hyprcursors/not-allowed.hlc new file mode 100644 index 0000000..3a05688 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/not-allowed.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/openhand.hlc b/Vimix-hyprcursors/hyprcursors/openhand.hlc new file mode 100644 index 0000000..b9c9b98 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/openhand.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/pencil.hlc b/Vimix-hyprcursors/hyprcursors/pencil.hlc new file mode 100644 index 0000000..a052ea1 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/pencil.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/pirate.hlc b/Vimix-hyprcursors/hyprcursors/pirate.hlc new file mode 100644 index 0000000..e9ab8d9 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/pirate.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/pointer.hlc b/Vimix-hyprcursors/hyprcursors/pointer.hlc new file mode 100644 index 0000000..6562f8e Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/pointer.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/progress.hlc b/Vimix-hyprcursors/hyprcursors/progress.hlc new file mode 100644 index 0000000..5818a37 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/progress.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/right-arrow.hlc b/Vimix-hyprcursors/hyprcursors/right-arrow.hlc new file mode 100644 index 0000000..c998086 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/right-arrow.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/right_ptr.hlc b/Vimix-hyprcursors/hyprcursors/right_ptr.hlc new file mode 100644 index 0000000..d24ae29 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/right_ptr.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/right_side.hlc b/Vimix-hyprcursors/hyprcursors/right_side.hlc new file mode 100644 index 0000000..904cd5e Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/right_side.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/row-resize.hlc b/Vimix-hyprcursors/hyprcursors/row-resize.hlc new file mode 100644 index 0000000..2c6be18 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/row-resize.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/size_bdiag.hlc b/Vimix-hyprcursors/hyprcursors/size_bdiag.hlc new file mode 100644 index 0000000..aec8bff Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/size_bdiag.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/size_fdiag.hlc b/Vimix-hyprcursors/hyprcursors/size_fdiag.hlc new file mode 100644 index 0000000..291f2a0 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/size_fdiag.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/size_hor.hlc b/Vimix-hyprcursors/hyprcursors/size_hor.hlc new file mode 100644 index 0000000..8224cc7 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/size_hor.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/size_ver.hlc b/Vimix-hyprcursors/hyprcursors/size_ver.hlc new file mode 100644 index 0000000..6804b53 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/size_ver.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/text.hlc b/Vimix-hyprcursors/hyprcursors/text.hlc new file mode 100644 index 0000000..8dea530 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/text.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/top_left_corner.hlc b/Vimix-hyprcursors/hyprcursors/top_left_corner.hlc new file mode 100644 index 0000000..bc845a7 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/top_left_corner.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/top_right_corner.hlc b/Vimix-hyprcursors/hyprcursors/top_right_corner.hlc new file mode 100644 index 0000000..4d61184 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/top_right_corner.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/top_side.hlc b/Vimix-hyprcursors/hyprcursors/top_side.hlc new file mode 100644 index 0000000..4fb8fae Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/top_side.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/up-arrow.hlc b/Vimix-hyprcursors/hyprcursors/up-arrow.hlc new file mode 100644 index 0000000..1883dc5 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/up-arrow.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/vertical-text.hlc b/Vimix-hyprcursors/hyprcursors/vertical-text.hlc new file mode 100644 index 0000000..32a0af7 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/vertical-text.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/wait.hlc b/Vimix-hyprcursors/hyprcursors/wait.hlc new file mode 100644 index 0000000..c3fdb69 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/wait.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/wayland-cursor.hlc b/Vimix-hyprcursors/hyprcursors/wayland-cursor.hlc new file mode 100644 index 0000000..c899bef Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/wayland-cursor.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/x-cursor.hlc b/Vimix-hyprcursors/hyprcursors/x-cursor.hlc new file mode 100644 index 0000000..fb7f925 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/x-cursor.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/zoom-in.hlc b/Vimix-hyprcursors/hyprcursors/zoom-in.hlc new file mode 100644 index 0000000..d2f0f65 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/zoom-in.hlc differ diff --git a/Vimix-hyprcursors/hyprcursors/zoom-out.hlc b/Vimix-hyprcursors/hyprcursors/zoom-out.hlc new file mode 100644 index 0000000..e35a516 Binary files /dev/null and b/Vimix-hyprcursors/hyprcursors/zoom-out.hlc differ diff --git a/Vimix-hyprcursors/manifest.hl b/Vimix-hyprcursors/manifest.hl new file mode 100644 index 0000000..cfcc906 --- /dev/null +++ b/Vimix-hyprcursors/manifest.hl @@ -0,0 +1,4 @@ +name = Extracted Theme +description = Automatically extracted with hyprcursor-util +version = 0.1 +cursors_directory = hyprcursors diff --git a/alacritty/alacritty.toml b/alacritty/alacritty.toml index 4bfdeb9..0c07761 100644 --- a/alacritty/alacritty.toml +++ b/alacritty/alacritty.toml @@ -9,8 +9,8 @@ style = "Regular" opacity = 0.7 [window.padding] -x = 15 -y = 15 +x = 0 +y = 0 [selection] save_to_clipboard = true diff --git a/apps/ML4W_Dotfiles_Settings-x86_64.AppImage b/apps/ML4W_Dotfiles_Settings-x86_64.AppImage index fa0f251..eb87906 100755 Binary files a/apps/ML4W_Dotfiles_Settings-x86_64.AppImage and b/apps/ML4W_Dotfiles_Settings-x86_64.AppImage differ diff --git a/apps/ML4W_Dotfiles_Uninstaller.AppImage b/apps/ML4W_Dotfiles_Uninstaller.AppImage index 79432b7..299c164 100755 Binary files a/apps/ML4W_Dotfiles_Uninstaller.AppImage and b/apps/ML4W_Dotfiles_Uninstaller.AppImage differ diff --git a/apps/ML4W_Hyprland_Settings-x86_64.AppImage b/apps/ML4W_Hyprland_Settings-x86_64.AppImage index f8e23e3..1013ec2 100755 Binary files a/apps/ML4W_Hyprland_Settings-x86_64.AppImage and b/apps/ML4W_Hyprland_Settings-x86_64.AppImage differ diff --git a/apps/ML4W_Welcome-x86_64.AppImage b/apps/ML4W_Welcome-x86_64.AppImage index dd4fc47..5bd9c4f 100755 Binary files a/apps/ML4W_Welcome-x86_64.AppImage and b/apps/ML4W_Welcome-x86_64.AppImage differ diff --git a/apps/installer.AppImage b/apps/installer.AppImage deleted file mode 100755 index 40e33fc..0000000 Binary files a/apps/installer.AppImage and /dev/null differ diff --git a/eww/ml4w-sidebar/eww.yuck b/eww/ml4w-sidebar/eww.yuck index 551c73b..afa0a3f 100644 --- a/eww/ml4w-sidebar/eww.yuck +++ b/eww/ml4w-sidebar/eww.yuck @@ -36,7 +36,7 @@ (box :class "res_box" :orientation "v" :valign "center" :halign "center" :spacing 15 :space-evenly "false" (box :class "res_circle" :orientation "v" :valign "center" :halign "center" (circular-progress :class "res_cpu" :value CPU_USAGE :thickness 15 - (label :class "res_circle_small" :text "CPU") + (label :class "res_circle_small" :text "CPU" :show-truncated false) ) ) (label :class "res_text" :valign "end" :halign "center" :text "${CPU_USAGE}%") @@ -44,7 +44,7 @@ (box :class "res_box" :orientation "v" :valign "center" :halign "center" :spacing 15 :space-evenly "false" (box :class "res_circle" :orientation "v" :valign "center" :halign "center" (circular-progress :class "res_mem" :value MEM_USAGE :thickness 15 - (label :class "res_circle_small" :text "MEMORY") + (label :class "res_circle_small" :text "MEMORY" :show-truncated false) ) ) (label :class "res_text" :valign "end" :halign "center" :text "${MEM_USAGE}%") @@ -52,7 +52,7 @@ (box :class "res_box" :orientation "v" :valign "center" :halign "center" :spacing 15 :space-evenly "false" (box :class "res_circle" :orientation "v" :valign "center" :halign "center" (circular-progress :class "res_disk" :value DISK_USAGE :thickness 15 - (label :class "res_circle_small" :text "DISK") + (label :class "res_circle_small" :text "DISK" :show-truncated false) ) ) (label :class "res_text" :valign "end" :halign "center" :text "${DISK_USAGE}%") @@ -70,31 +70,31 @@ ;; powermenus (defwidget logout [] (box :class "winbox" - (button :tooltip "Logout" :style "background-image: url('../assets/application-exit-symbolic-rtl.svg');" :class "powericons" :valign "center" :halign "center" :onclick "../scripts/system.sh logout &") + (button :tooltip "Logout" :style "background-image: url('../assets/application-exit-symbolic-rtl.svg');" :class "powericons" :valign "center" :halign "center" :onclick "../../hypr/scripts/power.sh exit &") ) ) (defwidget suspend [] (box :class "winbox" - (button :tooltip "Suspend" :style "background-image: url('../assets/media-playback-pause-symbolic.svg');" :class "powericons" :valign "center" :halign "center" :onclick "../scripts/system.sh suspend &") + (button :tooltip "Suspend" :style "background-image: url('../assets/media-playback-pause-symbolic.svg');" :class "powericons" :valign "center" :halign "center" :onclick "../../hypr/scripts/power.sh suspend &") ) ) (defwidget lock [] (box :class "winbox" - (button :tooltip "Lock" :style "background-image: url('../assets/system-lock-screen-symbolic.svg');" :class "powericons" :valign "center" :halign "center" :onclick "../scripts/system.sh lock &") + (button :tooltip "Lock" :style "background-image: url('../assets/system-lock-screen-symbolic.svg');" :class "powericons" :valign "center" :halign "center" :onclick "../../hypr/scripts/power.sh lock &") ) ) (defwidget reboot [] (box :class "winbox" - (button :tooltip "Reboot" :style "background-image: url('../assets/system-reboot-symbolic.svg');" :class "powericons" :valign "center" :halign "center" :onclick "../scripts/system.sh reboot &") + (button :tooltip "Reboot" :style "background-image: url('../assets/system-reboot-symbolic.svg');" :class "powericons" :valign "center" :halign "center" :onclick "../../hypr/scripts/power.sh reboot &") ) ) (defwidget shutdown [] (box :class "winbox" - (button :tooltip "Shutdown" :style "background-image: url('../assets/system-shutdown-symbolic.svg');" :class "powericons" :valign "center" :halign "center" :onclick "../scripts/system.sh shutdown &") + (button :tooltip "Shutdown" :style "background-image: url('../assets/system-shutdown-symbolic.svg');" :class "powericons" :valign "center" :halign "center" :onclick "../../hypr/scripts/power.sh shutdown &") ) ) diff --git a/eww/scripts/launch_app.sh b/eww/scripts/launch_app.sh index 9285adc..5929e1a 100755 --- a/eww/scripts/launch_app.sh +++ b/eww/scripts/launch_app.sh @@ -1,11 +1,12 @@ #!/bin/bash if [[ "$1" == "--welcome" ]]; then - $HOME/dotfiles/apps/ML4W_Welcome-x86_64.AppImage + $HOME/dotfiles/apps/ML4W_Welcome-x86_64.AppImage & elif [[ "$1" == "--dotfiles" ]]; then - $HOME/dotfiles/apps/ML4W_Dotfiles_Settings-x86_64.AppImage + $HOME/dotfiles/apps/ML4W_Dotfiles_Settings-x86_64.AppImage & elif [[ "$1" == "--hyprland" ]]; then - $HOME/dotfiles/apps/ML4W_Hyprland_Settings-x86_64.AppImage + $HOME/dotfiles/apps/ML4W_Hyprland_Settings-x86_64.AppImage & else echo "ERROR: $1 not found" fi +$HOME/dotfiles/eww/ml4w-sidebar/launch.sh & \ No newline at end of file diff --git a/fastfetch/config.jsonc b/fastfetch/config.jsonc index 38a82cf..2a45a5b 100644 --- a/fastfetch/config.jsonc +++ b/fastfetch/config.jsonc @@ -1,5 +1,4 @@ // Note that you must replace the image path to an existing image to display it. - { "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", // "logo": { @@ -9,7 +8,7 @@ // "height": 12 // }, "display": { - // "separator": "  " + // "separator": "  " "separator": " " }, "modules": [ @@ -74,7 +73,6 @@ "keyColor": "green" }, "break", - { "type": "shell", "key": "╭─", @@ -85,6 +83,11 @@ "key": "├─", "keyColor": "yellow" }, + { + "type": "editor", + "key": "├─", + "keyColor": "yellow" + }, { "type": "terminalfont", "key": "├─", @@ -115,7 +118,6 @@ "key": "╰─󰀻", "keyColor": "yellow" }, - "break", { "type": "title", @@ -149,6 +151,21 @@ "key": "├─󰝚", "keyColor": "blue" }, + { + "type": "cpuusage", + "key": "├─", + "keyColor": "blue" + }, + { + "type": "loadavg", + "key": "├─", + "keyColor": "blue" + }, + { + "type": "processes", + "key": "├─", + "keyColor": "blue" + }, { "type": "localip", "key": "╰─󰩟", @@ -158,8 +175,7 @@ "break", { "type": "custom", - "format": " \u001b[90m󱓻 \u001b[31m󱓻 \u001b[32m󱓻 \u001b[33m󱓻 \u001b[34m󱓻 \u001b[35m󱓻 \u001b[36m󱓻 \u001b[37m󱓻 \u001b[38m󱓻 \u001b[39m󱓻" + "format": " \u001b[90m󱓻 \u001b[31m󱓻 \u001b[32m󱓻 \u001b[33m󱓻 \u001b[34m󱓻 \u001b[35m󱓻 \u001b[36m󱓻 \u001b[37m󱓻 \u001b[38m󱓻 \u001b[39m󱓻 " } ] } - diff --git a/hypr/conf/README.md b/hypr/conf/README.md deleted file mode 100644 index 17ca702..0000000 --- a/hypr/conf/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# Configuration Variations - -With configuration variations, you can prepare different settings and configurations for your Hyprland installation. - - - -## How to use configuration variations - -Open the ML4W dotfiles settings app via the ML4W Welcome App, the application launcher or the wheel icon in Waybar. - -You can find several variation within the three settings pages. - -- Monitor (Screen Resolutions) -- Animations -- Keybindings -- Windows -- Window Rules -- Decorations -- Environments - -Select the variation that you want to use from the corresponding drop down menu. - -Please don't edit the shipped configuration variations. These will be overwritten with every update of the ML4W dotfiles. Create your own custom variation instead. - -## Create your own variation - -Open the ML4W dotfiles settings app via the ML4W Welcome App, the application launcher or the wheel icon in Waybar. - -Select "Open Variation Folder" from the variation context menu. - - - -Copy an existing variation as a starting point and rename the new file accordingly. - - - -Edit the configuration of your new variation and save. - -Go back to the ML4W dotfiles settings app and select "Reload Variations" from the variation context menu and select your new variation. - - - -You can also modify the variation from the settings app directly. - - \ No newline at end of file diff --git a/hypr/conf/autostart.conf b/hypr/conf/autostart.conf index fd3cf8e..a88d4cb 100644 --- a/hypr/conf/autostart.conf +++ b/hypr/conf/autostart.conf @@ -16,7 +16,6 @@ exec-once = ~/dotfiles/hypr/scripts/gtk.sh # Using hypridle to start hyprlock exec-once = hypridle -# exec-once = swayidle -w timeout 600 'swaylock -f' timeout 660 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' before-sleep 'swaylock -f' # Load cliphist history exec-once = wl-paste --watch cliphist store @@ -27,10 +26,11 @@ exec-once = ~/dotfiles/hypr/scripts/init-wallpaper-engine.sh # Autostart ML4W App exec-once = ~/dotfiles/hypr/scripts/ml4w-welcome-autostart.sh -# Load configuration from ML4W Hyprland Settings App -exec-once = ~/.config/ml4w-hyprland-settings/hyprctl.sh - # Start ewww daemon exec-once = ~/dotfiles/hypr/scripts/eww.sh exec-once = pypr + + +# Start autostart cleanup +exec-once = ~/dotfiles/hypr/scripts/cleanup.sh diff --git a/hypr/conf/cursor.conf b/hypr/conf/cursor.conf index 39f83fd..519d384 100644 --- a/hypr/conf/cursor.conf +++ b/hypr/conf/cursor.conf @@ -1 +1,2 @@ -exec-once = hyprctl setcursor Vimix 24 +exec-once = hyprctl setcursor Vimix-hyprcursors 32 +env = HYPRCURSOR_THEME,Vimix-hyprcursors diff --git a/hypr/conf/decorations/custom.conf b/hypr/conf/decorations/custom.conf index bb4f1fd..a85a981 100644 --- a/hypr/conf/decorations/custom.conf +++ b/hypr/conf/decorations/custom.conf @@ -18,8 +18,14 @@ decoration { inactive_opacity = 0.8 fullscreen_opacity = 1.0 - drop_shadow = true - shadow_range = 30 - shadow_render_power = 3 - col.shadow = 0x66000000 + shadow { + enabled = true + range = 30 + render_power = 3 + color = 0x66000000 + } + #drop_shadow = true + #shadow_range = 30 + #shadow_render_power = 3 + #col.shadow = 0x66000000 } diff --git a/hypr/conf/environments/default.conf b/hypr/conf/environments/default.conf index 8f22e1b..e468bb1 100644 --- a/hypr/conf/environments/default.conf +++ b/hypr/conf/environments/default.conf @@ -3,12 +3,10 @@ # name: "Default" # ----------------------------------------------------- -env = XCURSOR_SIZE,24 -env = XDG_CURRENT_DESKTOP,Hyprland env = XDG_SESSION_TYPE,wayland env = XDG_SESSION_DESKTOP,Hyprland env = QT_QPA_PLATFORM,wayland +env = QT_QPA_PLATFORMTHEME,qt6ct env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1 env = QT_AUTO_SCREEN_SCALE_FACTOR,1 env = MOZ_ENABLE_WAYLAND,1 -env = GDK_SCALE,1 diff --git a/hypr/conf/environments/kvm.conf b/hypr/conf/environments/kvm.conf index d63d5f7..11c5870 100644 --- a/hypr/conf/environments/kvm.conf +++ b/hypr/conf/environments/kvm.conf @@ -3,8 +3,6 @@ # name: "KVM" # ----------------------------------------------------- -env = XCURSOR_SIZE,24 -env = XDG_CURRENT_DESKTOP,Hyprland env = XDG_SESSION_TYPE,wayland env = XDG_SESSION_DESKTOP,Hyprland env = QT_QPA_PLATFORM,wayland @@ -12,5 +10,5 @@ env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1 env = QT_AUTO_SCREEN_SCALE_FACTOR,1 env = MOZ_ENABLE_WAYLAND,1 env = GDK_SCALE,1 -env = WLR_NO_HARDWARE_CURSORS, 1 env = WLR_RENDERER_ALLOW_SOFTWARE, 1 +env = WLR_NO_HARDWARE_CURSORS, 1 \ No newline at end of file diff --git a/hypr/conf/environments/nvidia.conf b/hypr/conf/environments/nvidia.conf index fca9e41..34b823d 100644 --- a/hypr/conf/environments/nvidia.conf +++ b/hypr/conf/environments/nvidia.conf @@ -2,14 +2,12 @@ # Environment Variables # name: "Nvidia" # ----------------------------------------------------- - # https://wiki.hyprland.org/Nvidia/ -env = XCURSOR_SIZE,24 -env = QT_QPA_PLATFORM,wayland -env = WLR_NO_HARDWARE_CURSORS,1 + env = LIBVA_DRIVER_NAME,nvidia env = XDG_SESSION_TYPE,wayland env = GBM_BACKEND,nvidia-drm env = __GLX_VENDOR_LIBRARY_NAME,nvidia + # env = __GL_VRR_ALLOWED,1 # env = WLR_DRM_NO_ATOMIC,1 \ No newline at end of file diff --git a/hypr/conf/fcitx5.conf b/hypr/conf/fcitx5.conf index 487d3ce..70432bb 100644 --- a/hypr/conf/fcitx5.conf +++ b/hypr/conf/fcitx5.conf @@ -3,3 +3,5 @@ exec-once = fcitx5 -d --replace exec-once = fcitx5-remote -r bind=$mainMod CTRL, E, exec, pkill fcitx5 -9;sleep 1;fcitx5 -d --replace; sleep 1;fcitx5-remote -r + +env=QT_IM_MODULE,fcitx diff --git a/hypr/conf/hidpi.conf b/hypr/conf/hidpi.conf index 12ac8ca..e5368f5 100644 --- a/hypr/conf/hidpi.conf +++ b/hypr/conf/hidpi.conf @@ -3,4 +3,4 @@ xwayland { } env = GDK_SCALE,2 -env = QT_SCALE_FACTOR=2 +env = QT_AUTO_SCREEN_SCALE_FACTOR,1 diff --git a/hypr/conf/keybindings/custom.conf b/hypr/conf/keybindings/custom.conf index 602b2f6..c4c292f 100644 --- a/hypr/conf/keybindings/custom.conf +++ b/hypr/conf/keybindings/custom.conf @@ -1,7 +1,7 @@ -# ----------------------------------------------------- +# ----------------------------------------------------- # Key bindings # name: "Default" -# ----------------------------------------------------- +# ----------------------------------------------------- # SUPER KEY $mainMod = SUPER @@ -9,11 +9,14 @@ $mainMod = SUPER # Applications bind = $mainMod, RETURN, exec, ~/dotfiles/.settings/terminal.sh bind = $mainMod, B, exec, ~/dotfiles/.settings/browser.sh -bind = $mainMod, period, exec, emote +bind = $mainMod SHIFT, E, exec, emote # Windows bind = $mainMod, Q, killactive bind = $mainMod, F, fullscreen +bind = $mainMod SHIFT, F, fullscreen, 1 +bind = $mainMod CTRL SHIFT, F, fullscreen, 2 +bind = $mainMod ALT, F, fakefullscreen bind = $mainMod, E, exec, ~/dotfiles/.settings/filemanager.sh bind = $mainMod, T, togglefloating bind = $mainMod SHIFT, T, exec, ~/dotfiles/hypr/scripts/toggleallfloat.sh @@ -29,21 +32,25 @@ bind = $mainMod SHIFT, left, resizeactive, -100 0 bind = $mainMod SHIFT, up, resizeactive, 0 -100 bind = $mainMod SHIFT, down, resizeactive, 0 100 bind = $mainMod, G, togglegroup +bind = $mainMod CTRL, Tab, changegroupactive, f # Actions bind = $mainMod, PRINT, exec, ~/dotfiles/hypr/scripts/screenshot.sh bind = $mainMod CTRL, Q, exec, wlogout bind = $mainMod SHIFT, W, exec, ~/dotfiles/hypr/scripts/wallpaper.sh bind = $mainMod CTRL, W, exec, ~/dotfiles/hypr/scripts/wallpaper.sh select -bind = $mainMod CTRL, RETURN, exec, rofi -show drun -replace -i +bind = $mainMod, SPACE, exec, rofi -show drun -replace -i bind = $mainMod CTRL, H, exec, ~/dotfiles/hypr/scripts/keybindings.sh bind = $mainMod SHIFT, B, exec, ~/dotfiles/waybar/launch.sh +bind = $mainMod CTRL, B, exec, ~/dotfiles/waybar/toggle.sh bind = $mainMod SHIFT, R, exec, ~/dotfiles/hypr/scripts/loadconfig.sh -bind = $mainMod CTRL, F, exec, ~/dotfiles/scripts/filemanager.sh bind = $mainMod CTRL, C, exec, ~/dotfiles/scripts/cliphist.sh bind = $mainMod, V, exec, ~/dotfiles/scripts/cliphist.sh bind = $mainMod CTRL, T, exec, ~/dotfiles/waybar/themeswitcher.sh bind = $mainMod CTRL, S, exec, ~/dotfiles/apps/ML4W_Dotfiles_Settings-x86_64.AppImage +bind = $mainMod CTRL, P, exec, hyprpicker -a +bind = $mainMod SHIFT, S, exec, ~/dotfiles/hypr/scripts/hyprshade.sh +bind = $mainMod ALT, G, exec, ~/dotfiles/hypr/scripts/gamemode.sh # Workspaces bind = $mainMod, 1, workspace, 1 diff --git a/hypr/conf/keybindings/default.conf b/hypr/conf/keybindings/default.conf index 02f8c7d..638118c 100644 --- a/hypr/conf/keybindings/default.conf +++ b/hypr/conf/keybindings/default.conf @@ -7,87 +7,88 @@ $mainMod = SUPER # Applications -bind = $mainMod, RETURN, exec, ~/dotfiles/.settings/terminal.sh -bind = $mainMod, B, exec, ~/dotfiles/.settings/browser.sh -bind = $mainMod, period, exec, emote +bind = $mainMod, RETURN, exec, ~/dotfiles/.settings/terminal.sh # Open the terminal +bind = $mainMod, B, exec, ~/dotfiles/.settings/browser.sh # Open the browser +bind = $mainMod, E, exec, ~/dotfiles/.settings/filemanager.sh # Open the filemanager # Windows -bind = $mainMod, Q, killactive -bind = $mainMod, F, fullscreen -bind = $mainMod, E, exec, ~/dotfiles/.settings/filemanager.sh -bind = $mainMod, T, togglefloating -bind = $mainMod SHIFT, T, exec, ~/dotfiles/hypr/scripts/toggleallfloat.sh -bind = $mainMod, J, togglesplit -bind = $mainMod, left, movefocus, l -bind = $mainMod, right, movefocus, r -bind = $mainMod, up, movefocus, u -bind = $mainMod, down, movefocus, d -bindm = $mainMod, mouse:272, movewindow -bindm = $mainMod, mouse:273, resizewindow -bind = $mainMod SHIFT, right, resizeactive, 100 0 -bind = $mainMod SHIFT, left, resizeactive, -100 0 -bind = $mainMod SHIFT, up, resizeactive, 0 -100 -bind = $mainMod SHIFT, down, resizeactive, 0 100 -bind = $mainMod, G, togglegroup +bind = $mainMod, Q, killactive # Kill active window +bind = $mainMod, F, fullscreen # Set active window to fullscreen +bind = $mainMod, T, togglefloating # Toggle active windows into floating mode +bind = $mainMod SHIFT, T, exec, ~/dotfiles/hypr/scripts/toggleallfloat.sh # Toggle all windows into floating mode +bind = $mainMod, J, togglesplit # Toggle split +bind = $mainMod, left, movefocus, l # Move focus left +bind = $mainMod, right, movefocus, r # Move focus right +bind = $mainMod, up, movefocus, u # Move focus up +bind = $mainMod, down, movefocus, d # Move focus down +bindm = $mainMod, mouse:272, movewindow # Move window with the mouse +bindm = $mainMod, mouse:273, resizewindow # Resize window with the mouse +bind = $mainMod SHIFT, right, resizeactive, 100 0 # Increase window width with keyboard +bind = $mainMod SHIFT, left, resizeactive, -100 0 # Reduce window width with keyboard +bind = $mainMod SHIFT, down, resizeactive, 0 100 # Increase window height with keyboard +bind = $mainMod SHIFT, up, resizeactive, 0 -100 # Reduce window height with keyboard +bind = $mainMod, G, togglegroup # Toggle window group # Actions -bind = $mainMod SHIFT, A, exec, ~/dotfiles/hypr/scripts/toggle-animations.sh -bind = $mainMod, PRINT, exec, ~/dotfiles/hypr/scripts/screenshot.sh -bind = $mainMod CTRL, Q, exec, wlogout -bind = $mainMod SHIFT, W, exec, ~/dotfiles/hypr/scripts/wallpaper.sh -bind = $mainMod CTRL, W, exec, ~/dotfiles/hypr/scripts/wallpaper.sh select -bind = $mainMod CTRL, RETURN, exec, rofi -show drun -replace -i -bind = $mainMod CTRL, H, exec, ~/dotfiles/hypr/scripts/keybindings.sh -bind = $mainMod SHIFT, B, exec, ~/dotfiles/waybar/launch.sh -bind = $mainMod SHIFT, R, exec, ~/dotfiles/hypr/scripts/loadconfig.sh -bind = $mainMod CTRL, F, exec, ~/dotfiles/scripts/filemanager.sh -bind = $mainMod CTRL, C, exec, ~/dotfiles/scripts/cliphist.sh -bind = $mainMod, V, exec, ~/dotfiles/scripts/cliphist.sh -bind = $mainMod CTRL, T, exec, ~/dotfiles/waybar/themeswitcher.sh -bind = $mainMod CTRL, S, exec, ~/dotfiles/apps/ML4W_Dotfiles_Settings-x86_64.AppImage +bind = $mainMod SHIFT, A, exec, ~/dotfiles/hypr/scripts/toggle-animations.sh # Toggle animations +bind = $mainMod, PRINT, exec, ~/dotfiles/hypr/scripts/screenshot.sh # Take a screenshot +bind = $mainMod CTRL, Q, exec, wlogout # Start wlogout +bind = $mainMod SHIFT, W, exec, ~/dotfiles/hypr/scripts/wallpaper.sh # Change the wallpaper +bind = $mainMod CTRL, W, exec, ~/dotfiles/hypr/scripts/wallpaper.sh select # Open wallpaper selector +bind = $mainMod CTRL, RETURN, exec, rofi -show drun -replace -i # Open application launcher +bind = $mainMod CTRL, H, exec, ~/dotfiles/hypr/scripts/keybindings.sh # Show keybindings +bind = $mainMod SHIFT, B, exec, ~/dotfiles/waybar/launch.sh # Reload waybar +bind = $mainMod CTRL, B, exec, ~/dotfiles/waybar/toggle.sh # Toggle waybar +bind = $mainMod SHIFT, R, exec, ~/dotfiles/hypr/scripts/loadconfig.sh # Reload hyprland config +bind = $mainMod, V, exec, ~/dotfiles/scripts/cliphist.sh # Open clipboard manager +bind = $mainMod CTRL, T, exec, ~/dotfiles/waybar/themeswitcher.sh # Open waybar theme switcher +bind = $mainMod CTRL, S, exec, ~/dotfiles/apps/ML4W_Dotfiles_Settings-x86_64.AppImage # Open ML4W Dotfiles Settings app +bind = $mainMod SHIFT, S, exec, ~/dotfiles/hypr/scripts/hyprshade.sh # Toggle screenshader +bind = $mainMod ALT, G, exec, ~/dotfiles/hypr/scripts/gamemode.sh # Toggle game mode # Workspaces -bind = $mainMod, 1, workspace, 1 -bind = $mainMod, 2, workspace, 2 -bind = $mainMod, 3, workspace, 3 -bind = $mainMod, 4, workspace, 4 -bind = $mainMod, 5, workspace, 5 -bind = $mainMod, 6, workspace, 6 -bind = $mainMod, 7, workspace, 7 -bind = $mainMod, 8, workspace, 8 -bind = $mainMod, 9, workspace, 9 -bind = $mainMod, 0, workspace, 10 -bind = $mainMod SHIFT, 1, movetoworkspace, 1 -bind = $mainMod SHIFT, 2, movetoworkspace, 2 -bind = $mainMod SHIFT, 3, movetoworkspace, 3 -bind = $mainMod SHIFT, 4, movetoworkspace, 4 -bind = $mainMod SHIFT, 5, movetoworkspace, 5 -bind = $mainMod SHIFT, 6, movetoworkspace, 6 -bind = $mainMod SHIFT, 7, movetoworkspace, 7 -bind = $mainMod SHIFT, 8, movetoworkspace, 8 -bind = $mainMod SHIFT, 9, movetoworkspace, 9 -bind = $mainMod SHIFT, 0, movetoworkspace, 10 -bind = $mainMod, mouse_down, workspace, e+1 -bind = $mainMod, mouse_up, workspace, e-1 -bind = $mainMod CTRL, down, workspace, empty - -# Fn keys -bind = , XF86MonBrightnessUp, exec, brightnessctl -q s +10% -bind = , XF86MonBrightnessDown, exec, brightnessctl -q s 10%- -bind = , XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +5% -bind = , XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -5% -bind = , XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle -bind = , XF86AudioPlay, exec, playerctl play-pause -bind = , XF86AudioPause, exec, playerctl pause -bind = , XF86AudioNext, exec, playerctl next -bind = , XF86AudioPrev, exec, playerctl previous -bind = , XF86AudioMicMute, exec, pactl set-source-mute @DEFAULT_SOURCE@ toggle -bind = , XF86Calculator, exec, qalculate-gtk -bind = , XF86Lock, exec, hyprlock -bind = , XF86Tools, exec, alacritty --class dotfiles-floating -e ~/dotfiles/hypr/settings/settings.sh +bind = $mainMod, 1, workspace, 1 # Open workspace 1 +bind = $mainMod, 2, workspace, 2 # Open workspace 2 +bind = $mainMod, 3, workspace, 3 # Open workspace 3 +bind = $mainMod, 4, workspace, 4 # Open workspace 4 +bind = $mainMod, 5, workspace, 5 # Open workspace 5 +bind = $mainMod, 6, workspace, 6 # Open workspace 6 +bind = $mainMod, 7, workspace, 7 # Open workspace 7 +bind = $mainMod, 8, workspace, 8 # Open workspace 8 +bind = $mainMod, 9, workspace, 9 # Open workspace 9 +bind = $mainMod, 0, workspace, 10 # Open workspace 10 +bind = $mainMod SHIFT, 1, movetoworkspace, 1 # Move active window to workspace 1 +bind = $mainMod SHIFT, 2, movetoworkspace, 2 # Move active window to workspace 2 +bind = $mainMod SHIFT, 3, movetoworkspace, 3 # Move active window to workspace 3 +bind = $mainMod SHIFT, 4, movetoworkspace, 4 # Move active window to workspace 4 +bind = $mainMod SHIFT, 5, movetoworkspace, 5 # Move active window to workspace 5 +bind = $mainMod SHIFT, 6, movetoworkspace, 6 # Move active window to workspace 6 +bind = $mainMod SHIFT, 7, movetoworkspace, 7 # Move active window to workspace 7 +bind = $mainMod SHIFT, 8, movetoworkspace, 8 # Move active window to workspace 8 +bind = $mainMod SHIFT, 9, movetoworkspace, 9 # Move active window to workspace 9 +bind = $mainMod SHIFT, 0, movetoworkspace, 10 # Move active window to workspace 10 +bind = $mainMod, mouse_down, workspace, e+1 # Open next workspace +bind = $mainMod, mouse_up, workspace, e-1 # Open previous workspace +bind = $mainMod CTRL, down, workspace, empty # Open the next empty workspace # Passthrough SUPER KEY to Virtual Machine -bind = $mainMod, P, submap, passthru +bind = $mainMod, P, submap, passthru # Passthrough SUPER key to virtual machine submap = passthru -bind = SUPER, Escape, submap, reset +bind = SUPER, Escape, submap, reset # Get SUPER key back from virtual machine submap = reset + +# Fn keys +bind = , XF86MonBrightnessUp, exec, brightnessctl -q s +10% # Increase brightness by 10% +bind = , XF86MonBrightnessDown, exec, brightnessctl -q s 10%- # Reduce brightness by 10% +bind = , XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +5% # Increase volume by 5% +bind = , XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -5% # Reduce volume by 5% +bind = , XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle # Toggle mute +bind = , XF86AudioPlay, exec, playerctl play-pause # Audio play pause +bind = , XF86AudioPause, exec, playerctl pause # Audio pause +bind = , XF86AudioNext, exec, playerctl next # Audio next +bind = , XF86AudioPrev, exec, playerctl previous # Audio previous +bind = , XF86AudioMicMute, exec, pactl set-source-mute @DEFAULT_SOURCE@ toggle # Toggle microphone +bind = , XF86Calculator, exec, qalculate-gtk # Open calculator +bind = , XF86Lock, exec, hyprlock # Open screenlock +bind = , XF86Tools, exec, alacritty --class dotfiles-floating -e ~/dotfiles/apps/ML4W_Dotfiles_Settings-x86_64.AppImage # Open ML4W Dotfiles Settings app + diff --git a/hypr/conf/keyboard.conf b/hypr/conf/keyboard.conf index af4fb36..c7f5408 100644 --- a/hypr/conf/keyboard.conf +++ b/hypr/conf/keyboard.conf @@ -11,7 +11,7 @@ input { follow_mouse = 1 mouse_refocus=false touchpad { - natural_scroll = ture + natural_scroll = true disable_while_typing=true tap-to-click=true } diff --git a/hypr/conf/layout.conf b/hypr/conf/layout.conf index 3692c19..c2b5cf1 100644 --- a/hypr/conf/layout.conf +++ b/hypr/conf/layout.conf @@ -1,24 +1 @@ -# ----------------------------------------------------- -# Layouts -# ----------------------------------------------------- - -dwindle { - pseudotile = true - preserve_split = true -} - -master { - new_is_master = true -} - -gestures { - workspace_swipe=true - workspace_swipe_fingers=3 - workspace_swipe_distance=400 - workspace_swipe_invert=true - workspace_swipe_min_speed_to_force=30 - workspace_swipe_cancel_ratio=0.5 - workspace_swipe_create_new=true - workspace_swipe_forever=true -} - +source = ~/dotfiles/hypr/conf/layouts/default.conf \ No newline at end of file diff --git a/hypr/conf/layouts/default.conf b/hypr/conf/layouts/default.conf new file mode 100644 index 0000000..617cb77 --- /dev/null +++ b/hypr/conf/layouts/default.conf @@ -0,0 +1,15 @@ +# ----------------------------------------------------- +# Layouts +# ----------------------------------------------------- + +dwindle { + pseudotile = true + preserve_split = true +} + +master { +} + +gestures { + workspace_swipe = false +} diff --git a/hypr/conf/layouts/laptop.conf b/hypr/conf/layouts/laptop.conf new file mode 100644 index 0000000..f098def --- /dev/null +++ b/hypr/conf/layouts/laptop.conf @@ -0,0 +1,23 @@ +# ----------------------------------------------------- +# Layouts +# ----------------------------------------------------- + +dwindle { + pseudotile = true + preserve_split = true +} + +master { + new_is_master = true +} + +gestures { + workspace_swipe=true + workspace_swipe_fingers=3 + workspace_swipe_distance=400 + workspace_swipe_invert=true + workspace_swipe_min_speed_to_force=30 + workspace_swipe_cancel_ratio=0.5 + workspace_swipe_create_new=true + workspace_swipe_forever=true +} \ No newline at end of file diff --git a/hypr/conf/misc.conf b/hypr/conf/misc.conf index 50b28d5..9bebf30 100644 --- a/hypr/conf/misc.conf +++ b/hypr/conf/misc.conf @@ -5,4 +5,7 @@ misc { disable_hyprland_logo = true disable_splash_rendering = true + enable_swallow = true + swallow_regex = ^(Alacritty|kitty|thunar)$ + font_family = FiraCode Nerd Font } diff --git a/hypr/conf/ml4w.conf b/hypr/conf/ml4w.conf index 5ed75dc..8c90684 100644 --- a/hypr/conf/ml4w.conf +++ b/hypr/conf/ml4w.conf @@ -2,6 +2,10 @@ # ML4W configurations # ----------------------------------------------------- +windowrulev2 = float,class:(.*chat.openai.com.*) +windowrulev2 = size 500 50%,class:(.*chat.openai.com.*) +windowrulev2 = move 20 70,class:(.*chat.openai.com.*) + windowrulev2 = float,class:(com.ml4w.welcome) windowrulev2 = size 700 600,class:(com.ml4w.welcome) windowrulev2 = center,class:(com.ml4w.welcome) @@ -18,9 +22,9 @@ windowrulev2 = float,class:(ml4w-dotfiles-settings.py) windowrulev2 = size 400 500,class:(ml4w-dotfiles-settings.py) windowrulev2 = move 10% 20%,class:(ml4w-dotfiles-settings.py) -windowrulev2 = float,class:(com.ml4w.hyprlandsettings) -windowrulev2 = size 700 600,class:(com.ml4w.hyprlandsettings) -windowrulev2 = center,class:(com.ml4w.hyprlandsettings) +windowrulev2 = float,class:(com.ml4w.hyprland.settings) +windowrulev2 = size 700 600,class:(com.ml4w.hyprland.settings) +windowrulev2 = center,class:(com.ml4w.hyprland.settings) windowrulev2 = float,class:(ml4w-hyprland-settings.py) windowrulev2 = size 700 600,class:(ml4w-hyprland-settings.py) @@ -31,4 +35,5 @@ windowrulev2 = size 1000 800,class:(dotfiles-floating) windowrulev2 = center,class:(dotfiles-floating) env = APPIMAGELAUNCHER_DISABLE,1 - +env = XCURSOR_SIZE,24 +env = XDG_CURRENT_DESKTOP,Hyprland diff --git a/hypr/conf/windowrules/custom.conf b/hypr/conf/windowrules/custom.conf index e3ccca5..9875991 100644 --- a/hypr/conf/windowrules/custom.conf +++ b/hypr/conf/windowrules/custom.conf @@ -1,6 +1,6 @@ -# ----------------------------------------------------- +# ----------------------------------------------------- # Window rules -# ----------------------------------------------------- +# ----------------------------------------------------- windowrule = tile,^(Microsoft-edge)$ windowrule = tile,^(Brave-browser)$ @@ -14,6 +14,11 @@ windowrule = pin,^(showmethekey-gtk)$ layerrule = blur, gtk-layer-shell layerrule = blur, logout_dialog -windowrule = float,title=^(Mathematica)$ +windowrule = float,title:^(Mathematica)$ windowrule = opacity 0.75, ^(Code)$ +windowrule = opacity 0.75, ^(code-oss)$ +windowrule = opacity 0.75, ^(code-url-handler)$ windowrule = float,^(QQ)$ +windowrule = float,^(wechat)$ +windowrule = float,^(fdm)$ +windowrule = float,^(xdg-desktop-portal-gtk)$ diff --git a/hypr/conf/windows/default.conf b/hypr/conf/windows/default.conf index b880c5d..2ae9a3e 100644 --- a/hypr/conf/windows/default.conf +++ b/hypr/conf/windows/default.conf @@ -11,3 +11,12 @@ general { col.inactive_border = rgba(ffffffff) layout = dwindle } + +group { + col.border_active = $color11 + col.border_inactive = rgba(ffffffff) + groupbar { + col.active = $color11 + col.inactive = $color13 + } +} diff --git a/hypr/effects/wallpaper/blackwhite b/hypr/effects/wallpaper/blackwhite new file mode 100644 index 0000000..0f985b3 --- /dev/null +++ b/hypr/effects/wallpaper/blackwhite @@ -0,0 +1 @@ +magick $wallpaper -set colorspace Gray -separate -average $used_wallpaper \ No newline at end of file diff --git a/hypr/effects/wallpaper/blackwhite-blur b/hypr/effects/wallpaper/blackwhite-blur new file mode 100644 index 0000000..85a5a51 --- /dev/null +++ b/hypr/effects/wallpaper/blackwhite-blur @@ -0,0 +1,2 @@ +magick $wallpaper -set colorspace Gray -separate -average $used_wallpaper +magick $used_wallpaper -blur "50x30" $used_wallpaper \ No newline at end of file diff --git a/hypr/effects/wallpaper/blackwhite-brightness80 b/hypr/effects/wallpaper/blackwhite-brightness80 new file mode 100644 index 0000000..67bb0ce --- /dev/null +++ b/hypr/effects/wallpaper/blackwhite-brightness80 @@ -0,0 +1,2 @@ +magick $wallpaper -set colorspace Gray -separate -average $used_wallpaper +magick $used_wallpaper -brightness-contrast -20% $used_wallpaper \ No newline at end of file diff --git a/hypr/effects/wallpaper/blur1 b/hypr/effects/wallpaper/blur1 new file mode 100644 index 0000000..f401e1a --- /dev/null +++ b/hypr/effects/wallpaper/blur1 @@ -0,0 +1 @@ +magick $wallpaper -blur "50x30" $used_wallpaper \ No newline at end of file diff --git a/hypr/effects/wallpaper/blur1-brightness80 b/hypr/effects/wallpaper/blur1-brightness80 new file mode 100644 index 0000000..c1984aa --- /dev/null +++ b/hypr/effects/wallpaper/blur1-brightness80 @@ -0,0 +1,2 @@ +magick $wallpaper -blur "50x30" $used_wallpaper +magick $used_wallpaper -brightness-contrast -20% $used_wallpaper \ No newline at end of file diff --git a/hypr/effects/wallpaper/blur2 b/hypr/effects/wallpaper/blur2 new file mode 100644 index 0000000..cb13630 --- /dev/null +++ b/hypr/effects/wallpaper/blur2 @@ -0,0 +1 @@ +magick $wallpaper -blur "10x30" $used_wallpaper \ No newline at end of file diff --git a/hypr/effects/wallpaper/negate b/hypr/effects/wallpaper/negate new file mode 100644 index 0000000..971c7aa --- /dev/null +++ b/hypr/effects/wallpaper/negate @@ -0,0 +1 @@ +magick $wallpaper -negate $used_wallpaper \ No newline at end of file diff --git a/hypr/effects/wallpaper/negate-brightness80 b/hypr/effects/wallpaper/negate-brightness80 new file mode 100644 index 0000000..2d342c1 --- /dev/null +++ b/hypr/effects/wallpaper/negate-brightness80 @@ -0,0 +1,2 @@ +magick $wallpaper -negate $used_wallpaper +magick $used_wallpaper -brightness-contrast -20% $used_wallpaper diff --git a/hypr/hyprland.conf b/hypr/hyprland.conf index 45ae6ff..7f89b3e 100644 --- a/hypr/hyprland.conf +++ b/hypr/hyprland.conf @@ -1,48 +1,48 @@ -# _ _ _ _ -# | | | |_ _ _ __ _ __| | __ _ _ __ __| | -# | |_| | | | | '_ \| '__| |/ _` | '_ \ / _` | -# | _ | |_| | |_) | | | | (_| | | | | (_| | -# |_| |_|\__, | .__/|_| |_|\__,_|_| |_|\__,_| -# |___/|_| -# -# ----------------------------------------------------- +# _ _ _ _ +# | | | |_ _ _ __ _ __| | __ _ _ __ __| | +# | |_| | | | | '_ \| '__| |/ _` | '_ \ / _` | +# | _ | |_| | |_) | | | | (_| | | | | (_| | +# |_| |_|\__, | .__/|_| |_|\__,_|_| |_|\__,_| +# |___/|_| +# +# ----------------------------------------------------- # IMPORTANT: Don't overwrite ML4W configuration. # Create your own custom configuration variation instead. # https://gitlab.com/stephan-raabe/dotfiles#hyprland-configuration-variations -# ----------------------------------------------------- +# ----------------------------------------------------- # Monitor -# ----------------------------------------------------- +# ----------------------------------------------------- source = ~/dotfiles/hypr/conf/monitor.conf -# ----------------------------------------------------- +# ----------------------------------------------------- # Autostart -# ----------------------------------------------------- +# ----------------------------------------------------- source = ~/dotfiles/hypr/conf/autostart.conf -# ----------------------------------------------------- +# ----------------------------------------------------- # Cursor -# ----------------------------------------------------- +# ----------------------------------------------------- source = ~/dotfiles/hypr/conf/cursor.conf -# ----------------------------------------------------- +# ----------------------------------------------------- # Environment -# ----------------------------------------------------- +# ----------------------------------------------------- source = ~/dotfiles/hypr/conf/environment.conf -# ----------------------------------------------------- +# ----------------------------------------------------- # Keyboard -# ----------------------------------------------------- +# ----------------------------------------------------- source = ~/dotfiles/hypr/conf/keyboard.conf -# ----------------------------------------------------- +# ----------------------------------------------------- # Load pywal color file -# ----------------------------------------------------- +# ----------------------------------------------------- source = ~/.cache/wal/colors-hyprland.conf -# ----------------------------------------------------- +# ----------------------------------------------------- # Load configuration files -# ----------------------------------------------------- +# ----------------------------------------------------- source = ~/dotfiles/hypr/conf/window.conf source = ~/dotfiles/hypr/conf/decoration.conf source = ~/dotfiles/hypr/conf/layout.conf @@ -50,22 +50,22 @@ source = ~/dotfiles/hypr/conf/misc.conf source = ~/dotfiles/hypr/conf/keybinding.conf source = ~/dotfiles/hypr/conf/windowrule.conf -# ----------------------------------------------------- +# ----------------------------------------------------- # Animation -# ----------------------------------------------------- +# ----------------------------------------------------- source = ~/dotfiles/hypr/conf/animation.conf -# ----------------------------------------------------- +# ----------------------------------------------------- # Custom -# ----------------------------------------------------- +# ----------------------------------------------------- source = ~/dotfiles/hypr/conf/custom.conf -# ----------------------------------------------------- +# ----------------------------------------------------- # ML4W Configuration -# ----------------------------------------------------- +# ----------------------------------------------------- source = ~/dotfiles/hypr/conf/ml4w.conf -# ----------------------------------------------------- +# ----------------------------------------------------- # Environment for xdg-desktop-portal-hyprland -# ----------------------------------------------------- -exec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP \ No newline at end of file +# ----------------------------------------------------- +exec-once=dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP diff --git a/hypr/pyprland.toml b/hypr/pyprland.toml index 2ab74e8..b342481 100644 --- a/hypr/pyprland.toml +++ b/hypr/pyprland.toml @@ -7,6 +7,6 @@ plugins = [ [scratchpads.term] animation = "fromTop" -command = "kitty --class kitty-dropterm" -class = "kitty-dropterm" +command = "alacritty --class alacritty-dropterm" +class = "alacritty-dropterm" size = "75% 60%" diff --git a/hypr/scripts/cleanup.sh b/hypr/scripts/cleanup.sh new file mode 100755 index 0000000..51589da --- /dev/null +++ b/hypr/scripts/cleanup.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Remove gamemode flag +if [ -f ~/.cache/gamemode ] ;then + rm ~/.cache/gamemode + echo ":: ~/.cache/gamemode removed" +fi \ No newline at end of file diff --git a/scripts/diagnosis.sh b/hypr/scripts/diagnosis.sh similarity index 73% rename from scripts/diagnosis.sh rename to hypr/scripts/diagnosis.sh index d9b33c8..a91a668 100755 --- a/scripts/diagnosis.sh +++ b/hypr/scripts/diagnosis.sh @@ -1,4 +1,12 @@ #!/bin/bash +# ____ _ _ +# | _ \(_) __ _ __ _ _ __ ___ ___(_)___ +# | | | | |/ _` |/ _` | '_ \ / _ \/ __| / __| +# | |_| | | (_| | (_| | | | | (_) \__ \ \__ \ +# |____/|_|\__,_|\__, |_| |_|\___/|___/_|___/ +# |___/ +# + clear sleep 0.5 figlet "Diagnosis" @@ -36,8 +44,8 @@ _commandExists "gum" "gum" _commandExists "wlogout" "wlogout" _commandExists "swww" "swww" _commandExists "eww" "eww" -_commandExists "magick2" "imagemagick" -_commandExists "figlet2" "figlet" +_commandExists "magick" "imagemagick" +_commandExists "figlet" "figlet" echo echo "Press return to exit" diff --git a/hypr/scripts/disabledm.sh b/hypr/scripts/disabledm.sh index fff026f..02b6718 100755 --- a/hypr/scripts/disabledm.sh +++ b/hypr/scripts/disabledm.sh @@ -1,6 +1,5 @@ #!/bin/bash clear - cat <<"EOF" ____ _ _ _ ____ __ __ | _ \(_)___ __ _| |__ | | ___| _ \| \/ | diff --git a/hypr/scripts/eww.sh b/hypr/scripts/eww.sh index ef4c3af..7df4512 100755 --- a/hypr/scripts/eww.sh +++ b/hypr/scripts/eww.sh @@ -1,4 +1,9 @@ #!/bin/bash +# _____ ____ __ +# / _ \ \ /\ / /\ \ /\ / / +# | __/\ V V / \ V V / +# \___| \_/\_/ \_/\_/ +# EWW=`which eww` if [[ ! `pidof eww` ]]; then ${EWW} daemon diff --git a/hypr/scripts/exit.sh b/hypr/scripts/exit.sh deleted file mode 100755 index c3e8a7a..0000000 --- a/hypr/scripts/exit.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -sleep 0.5 -killall -9 Hyprland sleep 2 \ No newline at end of file diff --git a/hypr/scripts/gamemode.sh b/hypr/scripts/gamemode.sh new file mode 100755 index 0000000..815a780 --- /dev/null +++ b/hypr/scripts/gamemode.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# ____ _ +# / ___| __ _ _ __ ___ ___ _ __ ___ ___ __| | ___ +# | | _ / _` | '_ ` _ \ / _ \ '_ ` _ \ / _ \ / _` |/ _ \ +# | |_| | (_| | | | | | | __/ | | | | | (_) | (_| | __/ +# \____|\__,_|_| |_| |_|\___|_| |_| |_|\___/ \__,_|\___| +# + +if [ -f ~/.cache/gamemode ] ;then + hyprctl reload + rm ~/.cache/gamemode + notify-send "Gamemode deactivated" "Animations and blur enabled" +else + hyprctl --batch "\ + keyword animations:enabled 0;\ + keyword decoration:drop_shadow 0;\ + keyword decoration:blur:enabled 0;\ + keyword general:gaps_in 0;\ + keyword general:gaps_out 0;\ + keyword general:border_size 1;\ + keyword decoration:rounding 0" + touch ~/.cache/gamemode + notify-send "Gamemode activated" "Animations and blur disabled" +fi diff --git a/hypr/scripts/gtk.sh b/hypr/scripts/gtk.sh index 5b19731..4e56ba7 100755 --- a/hypr/scripts/gtk.sh +++ b/hypr/scripts/gtk.sh @@ -1,4 +1,10 @@ #!/bin/bash +# ____ _____ _ __ +# / ___|_ _| |/ / +# | | _ | | | ' / +# | |_| | | | | . \ +# \____| |_| |_|\_\ +# # Source: https://github.com/swaywm/sway/wiki/GTK-3-settings-on-Wayland config="$HOME/.config/gtk-3.0/settings.ini" @@ -23,7 +29,7 @@ gsettings set "$gnome_schema" cursor-theme "$cursor_theme" gsettings set "$gnome_schema" font-name "$font_name" gsettings set "$gnome_schema" color-scheme "prefer-dark" -if [ -f ~/dotfiles/hypr/conf/cursor.conf ] ;then - echo "exec-once = hyprctl setcursor $cursor_theme $cursor_size" > ~/dotfiles/hypr/conf/cursor.conf - hyprctl setcursor $cursor_theme $cursor_size -fi \ No newline at end of file +# if [ -f ~/dotfiles/hypr/conf/cursor.conf ] ;then +# echo "exec-once = hyprctl setcursor $cursor_theme $cursor_size" > ~/dotfiles/hypr/conf/cursor.conf +# hyprctl setcursor $cursor_theme $cursor_size +# fi \ No newline at end of file diff --git a/hypr/scripts/hypridle.sh b/hypr/scripts/hypridle.sh new file mode 100755 index 0000000..e710b41 --- /dev/null +++ b/hypr/scripts/hypridle.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# _ _ _ _ _ +# | | | |_ _ _ __ _ __(_) __| | | ___ +# | |_| | | | | '_ \| '__| |/ _` | |/ _ \ +# | _ | |_| | |_) | | | | (_| | | __/ +# |_| |_|\__, | .__/|_| |_|\__,_|_|\___| +# |___/|_| +# + +SERVICE="hypridle" +if [[ "$1" == "status" ]]; then + sleep 1 + if pgrep -x "$SERVICE" >/dev/null ;then + echo '{"text": "RUNNING", "class": "active", "tooltip": "Screen locking active"}' + else + echo '{"text": "NOT RUNNING", "class": "notactive", "tooltip": "Screen locking deactivated"}' + fi +fi +if [[ "$1" == "toggle" ]]; then + if pgrep -x "$SERVICE" >/dev/null ;then + killall hypridle + else + hypridle + fi +fi diff --git a/hypr/scripts/hyprshade.sh b/hypr/scripts/hyprshade.sh new file mode 100755 index 0000000..ccb9b7f --- /dev/null +++ b/hypr/scripts/hyprshade.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# _ _ _ _ +# | | | |_ _ _ __ _ __ ___| |__ __ _ __| | ___ +# | |_| | | | | '_ \| '__/ __| '_ \ / _` |/ _` |/ _ \ +# | _ | |_| | |_) | | \__ \ | | | (_| | (_| | __/ +# |_| |_|\__, | .__/|_| |___/_| |_|\__,_|\__,_|\___| +# |___/|_| +# + +if [[ "$1" == "rofi" ]]; then + + # Open rofi to select the Hyprshade filter for toggle + options="$(hyprshade ls)\noff" + + # Open rofi + choice=$(echo -e "$options" | rofi -dmenu -replace -config ~/dotfiles/rofi/config-hyprshade.rasi -i -no-show-icons -l 4 -width 30 -p "Hyprshade") + if [ ! -z $choice ] ;then + echo "hyprshade_filter=\"$choice\"" > ~/dotfiles/.settings/hyprshade.sh + dunstify "Changing Hyprshade to $choice" "Toggle shader with SUPER+SHIFT+S" + fi + +else + + # Toggle Hyprshade based on the selected filter + hyprshade_filter="blue-light-filter" + + # Check if hyprshade.sh settings file exists and load + if [ -f ~/dotfiles/.settings/hyprshade.sh ] ;then + source ~/dotfiles/.settings/hyprshade.sh + fi + + # Toggle Hyprshade + if [ "$hyprshade_filter" != "off" ] ;then + if [ -z $(hyprshade current) ] ;then + echo ":: hyprshade is not running" + hyprshade on $hyprshade_filter + notify-send "Hyprshade activated" "with $(hyprshade current)" + echo ":: hyprshade started with $(hyprshade current)" + else + notify-send "Hyprshade deactivated" + echo ":: Current hyprshade $(hyprshade current)" + echo ":: Switching hyprshade off" + hyprshade off + fi + else + if [ -z $(hyprshade current) ] ;then + hyprshade off + fi + echo ":: hyprshade turned off" + fi + +fi diff --git a/hypr/scripts/init-wallpaper-engine.sh b/hypr/scripts/init-wallpaper-engine.sh index bfe31c1..afedd12 100755 --- a/hypr/scripts/init-wallpaper-engine.sh +++ b/hypr/scripts/init-wallpaper-engine.sh @@ -1,4 +1,12 @@ #!/bin/bash +# __ ______ _____ _ +# \ \ / / _ \ | ____|_ __ __ _(_)_ __ ___ +# \ \ /\ / /| |_) | | _| | '_ \ / _` | | '_ \ / _ \ +# \ V V / | __/ | |___| | | | (_| | | | | | __/ +# \_/\_/ |_| |_____|_| |_|\__, |_|_| |_|\___| +# |___/ +# + wallpaper_engine=$(cat $HOME/dotfiles/.settings/wallpaper-engine.sh) if [ "$wallpaper_engine" == "swww" ] ;then # swww diff --git a/hypr/scripts/keybindings.sh b/hypr/scripts/keybindings.sh index c66afb6..d4edd07 100755 --- a/hypr/scripts/keybindings.sh +++ b/hypr/scripts/keybindings.sh @@ -21,14 +21,29 @@ config_file=${config_file/source=~/} config_file="/home/$USER$config_file" echo "Reading from: $config_file" -# ----------------------------------------------------- -# Parse keybindings -# ----------------------------------------------------- -keybinds=$(grep -oP '(?<=bind = ).*' $config_file) -keybinds=$(echo "$keybinds" | sed 's/$mainMod/SUPER/g'| sed 's/,\([^,]*\)$/ = \1/' | sed 's/, exec//g' | sed 's/^,//g') +keybinds="" + +# Detect Start String +while read -r line +do + if [[ "$line" == "bind"* ]]; then + + line="$(echo "$line" | sed 's/$mainMod/SUPER/g')" + line="$(echo "$line" | sed 's/bind = //g')" + line="$(echo "$line" | sed 's/bindm = //g')" + + IFS='#' + read -a strarr <<<"$line" + kb_str=${strarr[0]} + cm_str=${strarr[1]} + + IFS=',' + read -a kbarr <<<"$kb_str" + + item="${kbarr[0]} + ${kbarr[1]}"$'\r'"${cm_str:1}" + keybinds=$keybinds$item$'\n' + fi +done < "$config_file" -# ----------------------------------------------------- -# Show keybindings in rofi -# ----------------------------------------------------- sleep 0.2 -rofi -dmenu -i -replace -p "Keybinds" -config ~/dotfiles/rofi/config-compact.rasi <<< "$keybinds" \ No newline at end of file +rofi -dmenu -i -markup -eh 2 -replace -p "Keybinds" -config ~/dotfiles/rofi/config-compact.rasi <<< "$keybinds" \ No newline at end of file diff --git a/hypr/scripts/lock.sh b/hypr/scripts/lock.sh deleted file mode 100755 index bc13b07..0000000 --- a/hypr/scripts/lock.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -sleep 0.5 -hyprlock \ No newline at end of file diff --git a/hypr/scripts/ml4w-launcher.sh b/hypr/scripts/ml4w-launcher.sh deleted file mode 100755 index 4ae1a57..0000000 --- a/hypr/scripts/ml4w-launcher.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# __ __ _ _ ___ __ _ _ -# | \/ | | | || \ \ / / | | __ _ _ _ _ __ ___| |__ ___ _ __ -# | |\/| | | | || |\ \ /\ / / | | / _` | | | | '_ \ / __| '_ \ / _ \ '__| -# | | | | |__|__ _\ V V / | |__| (_| | |_| | | | | (__| | | | __/ | -# |_| |_|_____| |_| \_/\_/ |_____\__,_|\__,_|_| |_|\___|_| |_|\___|_| -# - -option1="ML4W Dotfiles Settings" -option2="Hyprland Settings" -option3="Change Wallpaper" -option4="Change Waybar Theme" -option5="ML4W Welcome App" - -options="$option1\n" -options="$options$option2\n" -options="$options$option3\n" -options="$options$option4\n$option5" - -choice=$(echo -e "$options" | rofi -dmenu -replace -config ~/dotfiles/rofi/config-ml4w-launcher.rasi -l 5) - -case $choice in - $option1) - $HOME/dotfiles/apps/ML4W_Dotfiles_Settings-x86_64.AppImage ;; - $option2) - $HOME/dotfiles/apps/ML4W_Hyprland_Settings-x86_64.AppImage ;; - $option3) - $HOME/dotfiles/hypr/scripts/wallpaper.sh select ;; - $option4) - $HOME/dotfiles/waybar/themeswitcher.sh ;; - $option5) - $HOME/dotfiles/apps/ML4W_Welcome-x86_64.AppImage ;; -esac \ No newline at end of file diff --git a/hypr/scripts/ml4w-welcome-autostart.sh b/hypr/scripts/ml4w-welcome-autostart.sh index c607c70..4856cee 100755 --- a/hypr/scripts/ml4w-welcome-autostart.sh +++ b/hypr/scripts/ml4w-welcome-autostart.sh @@ -1,14 +1,14 @@ #!/bin/bash if [ ! -f $HOME/.cache/ml4w-welcome-autostart ] ;then - echo "Autostart of ML4W Welcome App enabled." + echo ":: Autostart of ML4W Welcome App enabled." if [ -f $HOME/dotfiles/apps/ML4W_Welcome-x86_64.AppImage ] ;then - echo "Starting ML4W Welcome App ..." + echo ":: Starting ML4W Welcome App ..." sleep 2 $HOME/dotfiles/apps/ML4W_Welcome-x86_64.AppImage else - echo "ML4W Welcome App not found." + echo ":: ML4W Welcome App not found." fi else - echo "Autostart of ML4W Welcome App disabled." + echo ":: Autostart of ML4W Welcome App disabled." fi \ No newline at end of file diff --git a/hypr/scripts/power.sh b/hypr/scripts/power.sh new file mode 100755 index 0000000..7b9e6e4 --- /dev/null +++ b/hypr/scripts/power.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# ____ +# | _ \ _____ _____ _ __ +# | |_) / _ \ \ /\ / / _ \ '__| +# | __/ (_) \ V V / __/ | +# |_| \___/ \_/\_/ \___|_| +# + +if [[ "$1" == "exit" ]]; then + echo ":: Exit" + sleep 0.5 + killall -9 Hyprland sleep 2 +fi + +if [[ "$1" == "lock" ]]; then + echo ":: Lock" + sleep 0.5 + hyprlock +fi + +if [[ "$1" == "reboot" ]]; then + echo ":: Reboot" + sleep 0.5 + systemctl reboot +fi + +if [[ "$1" == "shutdown" ]]; then + echo ":: Shutdown" + sleep 0.5 + systemctl poweroff +fi + +if [[ "$1" == "suspend" ]]; then + echo ":: Suspend" + sleep 0.5 + systemctl suspend +fi + +if [[ "$1" == "hibernate" ]]; then + echo ":: Hibernate" + sleep 1; + systemctl hibernate +fi \ No newline at end of file diff --git a/hypr/scripts/reboot.sh b/hypr/scripts/reboot.sh deleted file mode 100755 index 2ddff75..0000000 --- a/hypr/scripts/reboot.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -sleep 0.5 -systemctl reboot diff --git a/hypr/scripts/shutdown.sh b/hypr/scripts/shutdown.sh deleted file mode 100755 index 48c8296..0000000 --- a/hypr/scripts/shutdown.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -sleep 0.5 -systemctl poweroff diff --git a/hypr/scripts/suspend.sh b/hypr/scripts/suspend.sh deleted file mode 100755 index 440d34b..0000000 --- a/hypr/scripts/suspend.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -sleep 0.5 -systemctl suspend \ No newline at end of file diff --git a/hypr/scripts/wallpaper-effects.sh b/hypr/scripts/wallpaper-effects.sh new file mode 100755 index 0000000..fb1d020 --- /dev/null +++ b/hypr/scripts/wallpaper-effects.sh @@ -0,0 +1,12 @@ + #!/bin/bash + + # Open rofi to select the Hyprshade filter for toggle + options="$(ls ~/dotfiles/hypr/effects/wallpaper/)\noff" + + # Open rofi + choice=$(echo -e "$options" | rofi -dmenu -replace -config ~/dotfiles/rofi/config-themes.rasi -i -no-show-icons -l 5 -width 30 -p "Hyprshade") + if [ ! -z $choice ] ;then + echo "$choice" > ~/dotfiles/.settings/wallpaper-effect.sh + dunstify "Changing Wallpaper Effect to " "$choice" + ~/dotfiles/hypr/scripts/wallpaper.sh init + fi \ No newline at end of file diff --git a/hypr/scripts/wallpaper.sh b/hypr/scripts/wallpaper.sh index 3c20993..9226e9e 100755 --- a/hypr/scripts/wallpaper.sh +++ b/hypr/scripts/wallpaper.sh @@ -6,10 +6,15 @@ # \_/\_/ \__,_|_|_| .__/ \__,_| .__/ \___|_| # |_| |_| # -# by Stephan Raabe (2023) +# by Stephan Raabe (2024) # ----------------------------------------------------- # Cache file for holding the current wallpaper +wallpaper_folder="$HOME/wallpaper" +if [ -f ~/dotfiles/.settings/wallpaper-folder.sh ] ;then + source ~/dotfiles/.settings/wallpaper-folder.sh +fi +used_wallpaper="$HOME/.cache/used_wallpaper" cache_file="$HOME/.cache/current_wallpaper" blurred="$HOME/.cache/blurred_wallpaper.png" square="$HOME/.cache/square_wallpaper.png" @@ -22,13 +27,13 @@ blur=$(cat $blur_file) # Create cache file if not exists if [ ! -f $cache_file ] ;then touch $cache_file - echo "$HOME/wallpaper/default.jpg" > "$cache_file" + echo "$wallpaper_folder/default.jpg" > "$cache_file" fi # Create rasi file if not exists if [ ! -f $rasi_file ] ;then touch $rasi_file - echo "* { current-image: url(\"$HOME/wallpaper/default.jpg\", height); }" > "$rasi_file" + echo "* { current-image: url(\"$wallpaper_folder/default.jpg\", height); }" > "$rasi_file" fi current_wallpaper=$(cat "$cache_file") @@ -41,27 +46,27 @@ case $1 in if [ -f $cache_file ]; then wal -q -i $current_wallpaper else - wal -q -i ~/wallpaper/ + wal -q -i $wallpaper_folder/ fi ;; # Select wallpaper with rofi "select") sleep 0.2 - selected=$( find "$HOME/wallpaper" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) -exec basename {} \; | sort -R | while read rfile + selected=$( find "$wallpaper_folder" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) -exec basename {} \; | sort -R | while read rfile do - echo -en "$rfile\x00icon\x1f$HOME/wallpaper/${rfile}\n" + echo -en "$rfile\x00icon\x1f$wallpaper_folder/${rfile}\n" done | rofi -dmenu -i -replace -config ~/dotfiles/rofi/config-wallpaper.rasi) if [ ! "$selected" ]; then echo "No wallpaper selected" exit fi - wal -q -i ~/wallpaper/$selected + wal -q -i $wallpaper_folder/$selected ;; # Randomly select wallpaper *) - wal -q -i ~/wallpaper/ + wal -q -i $wallpaper_folder/ ;; esac @@ -70,12 +75,11 @@ esac # Load current pywal color scheme # ----------------------------------------------------- source "$HOME/.cache/wal/colors.sh" -echo ":: Wallpaper: $wallpaper" # ----------------------------------------------------- # get wallpaper image name # ----------------------------------------------------- -newwall=$(echo $wallpaper | sed "s|$HOME/wallpaper/||g") +newwall=$(echo $wallpaper | sed "s|$wallpaper_folder/||g") # ----------------------------------------------------- # Reload waybar with new colors @@ -89,11 +93,27 @@ transition_type="wipe" # transition_type="outer" # transition_type="random" +cp $wallpaper $HOME/.cache/ +mv $HOME/.cache/$newwall $used_wallpaper + +# Load Wallpaper Effect +if [ -f $HOME/dotfiles/.settings/wallpaper-effect.sh ] ;then + effect=$(cat $HOME/dotfiles/.settings/wallpaper-effect.sh) + if [ ! "$effect" == "off" ] ;then + if [ "$1" == "init" ] ;then + echo ":: Init" + else + dunstify "Using wallpaper effect $effect..." "with image $newwall" -h int:value:10 -h string:x-dunst-stack-tag:wallpaper + fi + source $HOME/dotfiles/hypr/effects/wallpaper/$effect + fi +fi + wallpaper_engine=$(cat $HOME/dotfiles/.settings/wallpaper-engine.sh) if [ "$wallpaper_engine" == "swww" ] ;then # swww echo ":: Using swww" - swww img $wallpaper \ + swww img $used_wallpaper \ --transition-bezier .43,1.19,1,.4 \ --transition-fps=60 \ --transition-type=$transition_type \ @@ -104,7 +124,7 @@ elif [ "$wallpaper_engine" == "hyprpaper" ] ;then echo ":: Using hyprpaper" killall hyprpaper wal_tpl=$(cat $HOME/dotfiles/.settings/hyprpaper.tpl) - output=${wal_tpl//WALLPAPER/$wallpaper} + output=${wal_tpl//WALLPAPER/$used_wallpaper} echo "$output" > $HOME/dotfiles/hypr/hyprpaper.conf hyprpaper & else @@ -132,7 +152,7 @@ else dunstify "Creating blurred version ..." "with image $newwall" -h int:value:50 -h string:x-dunst-stack-tag:wallpaper fi -magick $wallpaper -resize 75% $blurred +magick $used_wallpaper -resize 75% $blurred echo ":: Resized to 75%" if [ ! "$blur" == "0x0" ] ;then magick $blurred -blur $blur $blurred diff --git a/hypr/scripts/xdg.sh b/hypr/scripts/xdg.sh index 80691e4..cc8790e 100755 --- a/hypr/scripts/xdg.sh +++ b/hypr/scripts/xdg.sh @@ -9,12 +9,12 @@ sleep 1 # kill all possible running xdg-desktop-portals -killall xdg-desktop-portal-hyprland -killall xdg-desktop-portal-gnome -killall xdg-desktop-portal-kde -killall xdg-desktop-portal-lxqt -killall xdg-desktop-portal-wlr -killall xdg-desktop-portal-gtk +killall -e xdg-desktop-portal-hyprland +killall -e xdg-desktop-portal-gnome +killall -e xdg-desktop-portal-kde +killall -e xdg-desktop-portal-lxqt +killall -e xdg-desktop-portal-wlr +killall -e xdg-desktop-portal-gtk killall xdg-desktop-portal sleep 1 diff --git a/hypr/shaders/invert-colors.glsl b/hypr/shaders/invert-colors.glsl new file mode 100644 index 0000000..a504901 --- /dev/null +++ b/hypr/shaders/invert-colors.glsl @@ -0,0 +1,8 @@ +precision highp float; +varying vec2 v_texcoord; +uniform sampler2D tex; + +void main() { + vec4 pixColor = texture2D(tex, v_texcoord); + gl_FragColor = vec4(1.0 - pixColor.r, 1.0 - pixColor.g, 1.0 - pixColor.b, pixColor.a); +} diff --git a/install.sh b/install.sh index 3ba7100..e093804 100755 --- a/install.sh +++ b/install.sh @@ -27,14 +27,15 @@ echo "Version: $version" echo "by Stephan Raabe 2024" echo "" if [ -d ~/dotfiles ] ;then - echo "A ML4W Dotfiles installation has been detected." - echo "This script will guide you through the update process of the ML4W Dotfiles." + echo ":: An existing ML4W Dotfiles installation has been detected." + echo ":: This script will guide you through the update process of the ML4W Dotfiles." else - echo "This script will guide you through the installation process of the ML4W dotfiles." + echo ":: This script will guide you through the installation process of the ML4W dotfiles." fi echo "" source .install/required.sh source .install/confirm-start.sh +source .install/paralleldownloads.sh source .install/yay.sh source .install/updatesystem.sh source .install/backup.sh @@ -65,8 +66,8 @@ source .install/hidpi.sh source .install/displaymanager.sh source .install/issue.sh source .install/restore.sh -source .install/neovim.sh source .install/keyboard.sh +source .install/neovim.sh source .install/hook.sh source .install/vm.sh source .install/copy.sh @@ -77,6 +78,7 @@ fi if [[ $profile == *"Qtile"* ]]; then source .install/qtile-dotfiles.sh fi +source .install/zshfish.sh source .install/settings.sh source .install/apps.sh source .install/gtk.sh diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 595bc91..5cb1918 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -1,6 +1,6 @@ -font_family Fira Code Nerd Font -font_size 14.0 -bold_font auto +font_family Fira Code Nerd Font +font_size 16.0 +bold_font auto italic_font auto bold_italic_font auto @@ -8,7 +8,18 @@ background_opacity 0.7 confirm_os_window_close 0 -enable_audio_bell no - selection_foreground #000000 selection_background #F5FBFF + +detect_urls yes +copy_on_select clipboard +strip_trailing_spaces smart +rectangle_select_modifiers ctrl+alt +terminal_select_modifiers shift + +enable_audio_bell no + +remember_window_size no +window_padding_width 5 + +map ctrl+super+enter launch --cwd=current diff --git a/nvim/.github/ISSUE_TEMPLATE/bug_report.yml b/nvim/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..4906f93 --- /dev/null +++ b/nvim/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,121 @@ +name: Bug Report +description: File a bug report +labels: [bug] +body: + - type: markdown + attributes: + value: | + _Before reporting:_ Search [existing issues](https://github.com/ayamir/nvimdots/issues) and check the [FAQ](https://github.com/ayamir/nvimdots/wiki/Issues). Thank you for helping us improve! + > [!IMPORTANT] + > The `0.11` branch is intended for nightly Neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + - type: checkboxes + id: is-latest-commit + attributes: + label: "Version confirmation" + description: "The local configuration is up-to-date in the current branch and this issue _persists_." + options: + - label: "Confirm" + required: true + - type: checkboxes + id: prerequisites-done + attributes: + label: "Following prerequisites" + description: "I've checked everything mentioned in [Wiki: Prerequisites](https://github.com/ayamir/nvimdots/wiki/Prerequisites)." + options: + - label: "Confirm" + required: true + - type: checkboxes + id: not-user-config-issue + attributes: + label: "Not a user config issue" + description: "This issue _persists_ after removing ALL user configs. If this is not the case, you should open a [Custom (User) Config Issue](https://github.com/ayamir/nvimdots/issues/new?assignees=&labels=usage&projects=&template=custom_config.yml) instead." + options: + - label: "Confirm" + required: true + + - type: input + id: nvim-version + attributes: + label: "Neovim version" + description: "Paste the output of `nvim --version` here" + placeholder: "NVIM v0.11.0-dev-194+g6c7677e5d" + validations: + required: true + - type: input + id: system-version + attributes: + label: "Operating system/version" + placeholder: "macOS 12.6.1" + validations: + required: true + - type: input + id: terminal-version + attributes: + label: "Terminal name/version" + placeholder: "iTerm2 Build 3.4.17" + validations: + required: true + - type: input + id: term-env + attributes: + label: "$TERM environment variable" + placeholder: "xterm-256color" + validations: + required: false + - type: dropdown + id: branch + attributes: + label: "Branch info" + description: "Which branch are you currently on? If you are not sure, check the output of `git rev-parse --abbrev-ref HEAD`" + options: + - main (Default/Latest) + - 0.9 (Legacy) + - 0.8 (Deprecated) + - 0.11 (Nightly) + validations: + required: true + - type: dropdown + id: fetch-pref + attributes: + label: "Fetch Preferences" + description: "In what way do you fetch resources? If you are not sure, check the value of `use_ssh` in `lua/user/settings.lua`" + options: + - SSH (use_ssh = true) + - HTTPS (use_ssh = false) + validations: + required: true + + - type: textarea + id: repro-steps + attributes: + label: "How to reproduce the issue" + description: "Note: Issues without any information will be closed directly" + placeholder: | + Steps to reproduce the behavior: + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true + + - type: textarea + id: expected-behavior + attributes: + label: "Expected behavior" + description: "Describe the behavior you expect" + validations: + required: true + - type: textarea + id: actual-behavior + attributes: + label: "Actual behavior" + validations: + required: false + - type: textarea + id: extras + attributes: + label: Additional information + description: If applicable, you may include logs, images, or videos to help explain your problem + validations: + required: false diff --git a/nvim/.github/ISSUE_TEMPLATE/config.yml b/nvim/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..1c7e924 --- /dev/null +++ b/nvim/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: GitHub Discussions + url: https://github.com/ayamir/nvimdots/discussions/new/choose + about: Any issue that does not fall into the above categories shall go here + - name: GitHub Wiki + url: https://github.com/ayamir/nvimdots/wiki + about: Make sure you have checked our documentation first. To be explicit, the "Issues" section \ No newline at end of file diff --git a/nvim/.github/ISSUE_TEMPLATE/custom_config.yml b/nvim/.github/ISSUE_TEMPLATE/custom_config.yml new file mode 100644 index 0000000..6a95d39 --- /dev/null +++ b/nvim/.github/ISSUE_TEMPLATE/custom_config.yml @@ -0,0 +1,111 @@ +name: Custom (User) Config Issue +description: Problems when trying to implement your custom config +labels: [usage] +body: + - type: markdown + attributes: + value: | + _Before requesting:_ Make sure you've read through our [Wiki: Usage](https://github.com/ayamir/nvimdots/wiki/Usage) before you start to add things to nvimdots! + > [!IMPORTANT] + > The `0.11` branch is intended for nightly Neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + - type: checkboxes + id: is-latest-commit + attributes: + label: "Version confirmation" + description: "The local configuration is up-to-date in the current branch and this issue _persists_." + options: + - label: "Confirm" + required: true + - type: checkboxes + id: prerequisites-done + attributes: + label: "Following prerequisites" + description: "I've checked everything mentioned in [Wiki: Prerequisites](https://github.com/ayamir/nvimdots/wiki/Prerequisites)." + options: + - label: "Confirm" + required: true + + - type: input + id: nvim-version + attributes: + label: "Neovim version" + description: "Paste the output of `nvim --version` here" + placeholder: "NVIM v0.11.0-dev-194+g6c7677e5d" + validations: + required: true + - type: dropdown + id: branch-info + attributes: + label: "Branch info" + description: "This issue template mainly targets `main` branch. Check the output of `git rev-parse --abbrev-ref HEAD` if you're not sure." + options: + - main (Default/Latest) + - 0.9 (Legacy) + - 0.8 (Deprecated) + - 0.11 (Nightly) + validations: + required: true + + - type: textarea + id: folder-structure-ta + attributes: + label: "Minimal (user) folder structure required to reproduce the issue" + description: "Note: You only need to describe where the *new/modified files* are. This section will be automatically formatted." + render: console + placeholder: | + └── lua/ + ├── core/ + ├── keymap/ default keymaps + ├── modules/ default plugins and plugin configs + └── user custom configs root directory + ├── configs/ custom plugin config folder + │ ├── dap-clients/ custom dap client config folder + │ ├── lsp-servers/ custom lsp server config folder + │ └── your-config.lua your plugin configs (if applicable) + ├── keymap/ custom keymap folder + │ └── your-config.lua your keymap overrides (if applicable) + ├── plugins/ custom plugin folder + │ └── your-config.lua your plugins (if applicable) + ├── event.lua custom `core/events.lua` overrides + ├── options.lua custom `core/options.lua` overrides + └── settings.lua custom `core/settings.lua` overrides + validations: + required: true + + - type: textarea + id: repro-steps + attributes: + label: "Minimal config with steps on how to reproduce the issue" + description: "Note: Issues without any information will be closed directly" + placeholder: | + This is my custom config (`specs.lua`): + ```lua + return { + popup = { + delay_ms = 20, + } + } + ``` + + Steps to reproduce the behavior: + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true + + - type: textarea + id: expected-behavior + attributes: + label: "Expected behavior" + description: "Describe the behavior you expect" + validations: + required: true + - type: textarea + id: extras + attributes: + label: Additional information + description: If applicable, you may include logs, images, or videos to help explain your problem + validations: + required: false diff --git a/nvim/.github/ISSUE_TEMPLATE/feature_request.yml b/nvim/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..47fc1ae --- /dev/null +++ b/nvim/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,22 @@ +name: Feature Request +description: Request an enhancement for this project +labels: [enhancement] +body: + - type: markdown + attributes: + value: | + _Before requesting:_ Search [existing issues](https://github.com/ayamir/nvimdots/labels/enhancement) and check the [FAQ](https://github.com/ayamir/nvimdots/wiki/Issues). Thank you for helping us improve! + + - type: textarea + id: feat-desc + attributes: + label: "Feature description" + validations: + required: true + - type: textarea + id: extras + attributes: + label: "Additional information" + description: "If applicable, you may include images or videos to help explain your request" + validations: + required: false diff --git a/nvim/.github/ISSUE_TEMPLATE/lsp_issue_report.yml b/nvim/.github/ISSUE_TEMPLATE/lsp_issue_report.yml new file mode 100644 index 0000000..0997861 --- /dev/null +++ b/nvim/.github/ISSUE_TEMPLATE/lsp_issue_report.yml @@ -0,0 +1,148 @@ +name: LSP Issue +description: File a bug report related to LSPs +labels: [bug, lsp] +body: + - type: markdown + attributes: + value: | + _Before reporting:_ Search [existing issues](https://github.com/ayamir/nvimdots/issues) and check the [FAQ](https://github.com/ayamir/nvimdots/wiki/Issues). Thank you for helping us improve! + > [!IMPORTANT] + > The `0.11` branch is intended for nightly Neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + - type: checkboxes + id: is-latest-commit + attributes: + label: "Version confirmation" + description: "The local configuration is up-to-date in the current branch and this issue _persists_." + options: + - label: "Confirm" + required: true + - type: checkboxes + id: prerequisites-done + attributes: + label: "Following prerequisites" + description: "I've checked everything mentioned in [Wiki: Prerequisites](https://github.com/ayamir/nvimdots/wiki/Prerequisites)." + options: + - label: "Confirm" + required: true + - type: checkboxes + id: not-user-config-issue + attributes: + label: "Not a user config issue" + description: "This issue _persists_ after removing ALL user configs. If this is not the case, you should open a [Custom (User) Config Issue](https://github.com/ayamir/nvimdots/issues/new?assignees=&labels=usage&projects=&template=custom_config.yml) instead." + options: + - label: "Confirm" + required: true + + - type: input + id: nvim-version + attributes: + label: "Neovim version" + description: "Paste the output of `nvim --version` here" + placeholder: "NVIM v0.11.0-dev-194+g6c7677e5d" + validations: + required: true + - type: input + id: system-version + attributes: + label: "Operating system/version" + placeholder: "macOS 12.6.1" + validations: + required: true + - type: input + id: terminal-version + attributes: + label: "Terminal name/version" + placeholder: "iTerm2 Build 3.4.17" + validations: + required: true + - type: input + id: term-env + attributes: + label: "$TERM environment variable" + placeholder: "xterm-256color" + validations: + required: false + - type: dropdown + id: branch + attributes: + label: "Branch info" + description: "Which branch are you currently on? If you are not sure, check the output of `git rev-parse --abbrev-ref HEAD`" + options: + - main (Default/Latest) + - 0.9 (Legacy) + - 0.8 (Deprecated) + - 0.11 (Nightly) + validations: + required: true + - type: dropdown + id: fetch-pref + attributes: + label: "Fetch Preferences" + description: "In what way do you fetch resources? If you are not sure, check the value of `use_ssh` in `lua/user/settings.lua`" + options: + - SSH (use_ssh = true) + - HTTPS (use_ssh = false) + validations: + required: true + - type: input + id: servers + attributes: + label: "Affected language servers" + description: "If this issue is specific to one or more language servers, list them here. If not, write `any`" + placeholder: "lua-language-server, clangd" + validations: + required: true + + - type: textarea + id: repro-steps + attributes: + label: "How to reproduce the issue" + description: "Note: Issues without any information will be closed directly" + placeholder: | + Steps to reproduce the behavior: + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true + + - type: textarea + id: actual-behavior + attributes: + label: "Actual behavior" + description: "Briefly describe what you've observed" + validations: + required: true + - type: textarea + id: expected-behavior + attributes: + label: "Expected behavior" + description: "Describe the behavior you expect" + validations: + required: false + - type: textarea + id: support-info + attributes: + label: "Support info" + description: "Plase include information (screenshots) from `:LspInfo` and `:Mason`" + placeholder: | + :LspInfo + :Mason + validations: + required: true + - type: textarea + id: lsp-logs + attributes: + label: "Logs" + description: "Please copy and paste any relevant log output (e.g., `${HOME}/.local/state/nvim/lsp.log` and `${HOME}/.cache/nvim/lsp.log`). This section will be automatically formatted" + render: console + validations: + required: false + - type: textarea + id: extras + attributes: + label: "Additional information" + description: "If applicable, you may include images or videos to help explain your problem" + validations: + required: false diff --git a/nvim/.github/workflows/lint_code.yml b/nvim/.github/workflows/lint_code.yml new file mode 100644 index 0000000..71d11c5 --- /dev/null +++ b/nvim/.github/workflows/lint_code.yml @@ -0,0 +1,11 @@ +name: lint code +on: [push, pull_request] + +jobs: + luacheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: lunarmodules/luacheck@v1 + with: + args: . --std luajit --globals vim _debugging _command_panel _flash_esc_or_noh _telescope_collections _toggle_lazygit --max-line-length 150 --no-config diff --git a/nvim/.github/workflows/style_check.yml b/nvim/.github/workflows/style_check.yml new file mode 100644 index 0000000..3c7936d --- /dev/null +++ b/nvim/.github/workflows/style_check.yml @@ -0,0 +1,13 @@ +name: style check +on: [push, pull_request] + +jobs: + stylua: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: JohnnyMorganz/stylua-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check --config-path=stylua.toml . diff --git a/nvim/.github/workflows/update_flake.yml b/nvim/.github/workflows/update_flake.yml new file mode 100644 index 0000000..9d9e31c --- /dev/null +++ b/nvim/.github/workflows/update_flake.yml @@ -0,0 +1,26 @@ +name: update flake.lock +on: + # Scheduled update (1st of every month) + schedule: [{ cron: "30 02 1 * *" }] + +jobs: + update-lockfile: + if: github.repository_owner == 'ayamir' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v26 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Run flake-update + run: | + nix flake update + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "chore(lockfile): auto update flake.lock" + commit_user_name: "github-actions[bot]" + commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com" + commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" + file_pattern: "flake.lock" diff --git a/nvim/.github/workflows/update_lockfile.yml b/nvim/.github/workflows/update_lockfile.yml new file mode 100644 index 0000000..200e019 --- /dev/null +++ b/nvim/.github/workflows/update_lockfile.yml @@ -0,0 +1,41 @@ +name: update lockfile +on: + # Scheduled update (each day) + schedule: [{ cron: "30 01 * * *" }] + +jobs: + update-lockfile: + if: github.repository_owner == 'ayamir' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required to count the commits + - uses: andstor/file-existence-action@v3 + id: check_lockfile + with: + files: "lazy-lock.json" + - name: Run count-new-commits + run: | + echo "NEW_COMMIT_COUNT=$(git log --oneline --since '24 hours ago' --perl-regexp --author='^((?!github-actions).*)$' | wc -l)" >> "$GITHUB_ENV" + - uses: rhysd/action-setup-vim@v1 + if: ${{ steps.check_lockfile.outputs.files_exists == 'true' && env.NEW_COMMIT_COUNT > 0 }} + with: + neovim: true + - name: Run lockfile-autoupdate + if: ${{ steps.check_lockfile.outputs.files_exists == 'true' && env.NEW_COMMIT_COUNT > 0 }} + timeout-minutes: 5 + run: | + ./scripts/install.sh + nvim --headless "+Lazy! update" +qa + cp -pv "${HOME}/.config/nvim/lazy-lock.json" . + - uses: stefanzweifel/git-auto-commit-action@v5 + if: ${{ steps.check_lockfile.outputs.files_exists == 'true' && env.NEW_COMMIT_COUNT > 0 }} + with: + commit_message: "chore(lockfile): auto update lazy-lock.json" + commit_user_name: "github-actions[bot]" + commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com" + commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" + file_pattern: "lazy-lock.json" diff --git a/nvim/.gitignore b/nvim/.gitignore new file mode 100644 index 0000000..51c6018 --- /dev/null +++ b/nvim/.gitignore @@ -0,0 +1,4 @@ +lua/modules/plugins/custom.lua +lua/modules/configs/custom +lua/user +result diff --git a/nvim/.nixd.json b/nvim/.nixd.json new file mode 100644 index 0000000..f8bee3e --- /dev/null +++ b/nvim/.nixd.json @@ -0,0 +1,7 @@ +{ + "formatting": { + "command": [ + "nixpkgs-fmt" + ] + } +} diff --git a/nvim/LICENSE b/nvim/LICENSE new file mode 100644 index 0000000..33895b6 --- /dev/null +++ b/nvim/LICENSE @@ -0,0 +1,30 @@ +BSD 3-Clause License + +Copyright (c) 2021 ayamir +Copyright (c) 2022 Jint-lzxy, CharlesChiuGit +Copyright (c) 2023 aarnphm, misumisumi + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/nvim/README.md b/nvim/README.md new file mode 100644 index 0000000..f4af58f --- /dev/null +++ b/nvim/README.md @@ -0,0 +1,216 @@ +

+ nvimdots +
+ + Neovim Version Capability + + + Release + +

+ +

+ + Stars + + + Issues + + + Contributors + + Code Size +

+ +## 🪷 Introduction + +This repo hosts our [Neovim](https://neovim.io/) configuration for Linux [(with NixOS support)](#nixos-support), macOS, and Windows. `init.lua` is the config entry point. + +Branch info: + +
+ +| Branch | Supported Neovim version | +| :----: | :----------------------: | +| main | nvim 0.10 stable | +| 0.11 | nvim 0.11 nightly | +| 0.9 | nvim 0.9 | +| 0.8 | nvim 0.8 | + +
+ +> [!IMPORTANT] +> The `0.11` branch is intended for nightly Neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + +We currently manage plugins using [lazy.nvim](https://github.com/folke/lazy.nvim). + +Chinese introduction is [here](https://zhuanlan.zhihu.com/p/382092667). + +### 🎐 Features + +- **Fast.** Less than **50ms** to start (Depends on SSD and CPU, tested on Zephyrus G14 2022 version). +- **Simple.** Runs out of the box. +- **Modern.** Pure `lua` config. +- **Modular.** Easy to customize. +- **Powerful.** Full functionality to code. + +## 🏗 How to Install + +Simply run the following interactive bootstrap command, and you should be all set 👍 + +- **Windows** _(Note: This script REQUIRES `pwsh` > `v7.1`)_ + +```pwsh +Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.ps1')) +``` + +- **\*nix** + +```sh +if command -v curl >/dev/null 2>&1; then + bash -c "$(curl -fsSL https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.sh)" +else + bash -c "$(wget -O- https://raw.githubusercontent.com/ayamir/nvimdots/HEAD/scripts/install.sh)" +fi +``` + +It's strongly recommended to read [Wiki: Prerequisites](https://github.com/ayamir/nvimdots/wiki/Prerequisites) before starting, especially for \*nix users. + +## ⚙️ Configuration & Usage + +

+ 🗺️ Keybindings +

+

See Wiki: Keybindings for details

+
+ +

+ 🔌 Plugins & Deps +

+

See Wiki: Plugins for details
(You can also find a deps diagram there!)

+
+ +

+ 🔧 Usage & Customization +

+

See Wiki: Usage for details

+
+ +

+ ❄️ NixOS Support +

+

See Wiki: NixOS Support for details

+
+ +

+ 🤔 FAQ +

+

See Wiki: FAQ for details

+ +## ✨ Features + +

+ ⏱️ Startup Time +

+ +

+ StartupTime +

+ +

+ Vim-StartupTime +

+ +> Tested with [rhysd/vim-startuptime](https://github.com/rhysd/vim-startuptime) + +

+ 📸 Screenshots +

+ +

+ Dashboard + Dashboard +

+
+ +

+ Telescope + Telescope +

+
+ +

+ Coding + Coding +

+
+ +

+ Code Action + Code Action +

+
+ +

+ Debugging + Debugging +

+
+ +

+ Lazygit + Lazygit with built-in Terminal +

+
+ +

+ Command quickref + Command quickref +

+ +## 👐 Contributing + +- If you find anything that needs improving, do not hesitate to point it out or create a PR. +- If you come across an issue, you can first use `:checkhealth` command provided by nvim to trouble-shoot yourself. + - If you still have such problems, feel free to open a new issue! + +## ❤️ Thanks to + +- [ayamir](https://github.com/ayamir) +- [Jint-lzxy](https://github.com/Jint-lzxy) +- [CharlesChiuGit](https://github.com/CharlesChiuGit) +- [aarnphm](https://github.com/aarnphm) +- [misumisumi](https://github.com/misumisumi) + +## 🎉 Acknowledgement + +- [glepnir/nvim](https://github.com/glepnir/nvim) + +## 📜 License + +This Neovim configuration is released under the BSD 3-Clause license, which grants the following permissions: + +- Commercial use +- Distribution +- Modification +- Private use + +For more convoluted language, see the [LICENSE](https://github.com/ayamir/nvimdots/blob/main/LICENSE). diff --git a/nvim/flake.lock b/nvim/flake.lock new file mode 100644 index 0000000..c62dd92 --- /dev/null +++ b/nvim/flake.lock @@ -0,0 +1,148 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1717408969, + "narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=", + "owner": "numtide", + "repo": "devshell", + "rev": "1ebbe68d57457c8cae98145410b164b5477761f4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1719745305, + "narHash": "sha256-xwgjVUpqSviudEkpQnioeez1Uo2wzrsMaJKJClh+Bls=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c3c5ecc05edc7dafba779c6c1a61cd08ac6583e9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719677234, + "narHash": "sha256-qO9WZsj/0E6zcK4Ht1y/iJ8XfwbBzq7xdqhBh44OP/M=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "36317d4d38887f7629876b0e43c8d9593c5cc48d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1704161960, + "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1717284937, + "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1719468428, + "narHash": "sha256-vN5xJAZ4UGREEglh3lfbbkIj+MPEYMuqewMn4atZFaQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1e3deb3d8a86a870d925760db1a5adecc64d329d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-parts": "flake-parts", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nvim/flake.nix b/nvim/flake.nix new file mode 100644 index 0000000..9dd3840 --- /dev/null +++ b/nvim/flake.nix @@ -0,0 +1,105 @@ +{ + # This provides only NixOS module + # As of 2023/08/19, you need to depend on nixpkgs-unstable. + # because "doq" is not included in the stable version. + description = "Provide nixosModules for ayamir/nvimdots"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + devshell.url = "github:numtide/devshell"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = inputs @ { self, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } + { + imports = [ + inputs.devshell.flakeModule + ]; + flake = { + homeManagerModules = { + nvimdots = ./nixos; + }; + }; + systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + perSystem = { pkgs, system, ... }: { + packages = { + testEnv = (import ./nixos/testEnv.nix { inherit inputs pkgs; }).activationPackage; + check-linker = pkgs.writeShellApplication { + name = "check-linker"; + text = + let + ldd_cmd = if pkgs.stdenv.isDarwin then "xcrun otool -L" else "${pkgs.glibc.bin}/bin/ldd"; + in + '' + #shellcheck disable=SC1090 + source <(sed -ne :1 -e 'N;1,1b1' -e 'P;D' "${self.packages.${system}.testEnv}/home-path/bin/nvim") + echo "Checking files under ''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin..." + find "''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin" -type l | while read -r link; do + "${ldd_cmd}" "$(readlink -f "$link")" > /dev/zero 2>&1 || continue + linkers=$("${ldd_cmd}" "$(readlink -f "$link")" | tail -n+2) + echo "$linkers" | while read -r line; do + [ -z "$line" ] && continue + echo "$line" | grep -q "/nix/store" || printf '%s: %s does not link to /nix/store \n' "$(basename "$link")" "$line" + done + done + echo "*** Done ***" + ''; + }; + }; + devshells.default = { + commands = [ + { + help = "neovim linked to testEnv."; + name = "nvim"; + command = '' + ${self.packages.${system}.testEnv}/home-path/bin/nvim + ''; + } + { + help = "check-linker"; + package = self.packages.${system}.check-linker; + } + ]; + devshell = { + motd = '' + {202}🔨 Welcome to devshell{reset} + Symlink configs to "''${XDG_CONFIG_HOME}"/nvimdots! + And NVIM_APPNAME=nvimdots is already configured, so neovim will put files under "\$XDG_xxx_HOME"/nvimdots. + To uninstall, remove "\$XDG_xxx_HOME"/nvimdots. + + $(type -p menu &>/dev/null && menu) + ''; + startup = { + mkNvimDir = { + text = '' + mkdir -p "''${XDG_CONFIG_HOME}"/nvimdots + for path in lazy-lock.json init.lua lua snips tutor; do + ln -sf "''${PWD}/''${path}" "''${XDG_CONFIG_HOME}"/nvimdots/ + done + ''; + }; + }; + }; + env = [ + { + name = "NVIM_APPNAME"; + value = "nvimdots"; + } + { + name = "PATH"; + prefix = "${self.packages.${system}.testEnv}/home-path/bin"; + } + ]; + packages = with pkgs; [ + nixd + nixpkgs-fmt + ]; + }; + }; + }; +} diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..1544509 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,3 @@ +if not vim.g.vscode then + require("core") +end diff --git a/nvim/init.vim b/nvim/init.vim deleted file mode 100644 index 79c22b5..0000000 --- a/nvim/init.vim +++ /dev/null @@ -1,33 +0,0 @@ -" _ _ _ -" | \ | | ___ _____ _(_)_ __ ___ -" | \| |/ _ \/ _ \ \ / / | '_ ` _ \ -" | |\ | __/ (_) \ V /| | | | | | | -" |_| \_|\___|\___/ \_/ |_|_| |_| |_| -" -" by Stephan Raabe (2023) -" ----------------------------------------------------- - -set nocompatible " disable compatibility to old-time vi -set showmatch " show matching -set ignorecase " case insensitive -set mouse=v " middle-click paste with -set hlsearch " highlight search -set incsearch " incremental search -set tabstop=4 " number of columns occupied by a tab -set softtabstop=4 " see multiple spaces as tabstops so does the right thing -set expandtab " converts tabs to white space -set shiftwidth=4 " width for autoindents -set autoindent " indent a new line the same amount as the line just typed -set number " add line numbers -set wildmode=longest,list " get bash-like tab completions -" set cc=80 " set an 80 column border for good coding style -filetype plugin indent on "allow auto-indenting depending on file type -syntax on " syntax highlighting -set mouse=a " enable mouse click -set clipboard=unnamedplus " using system clipboard -filetype plugin on -" set cursorline " highlight current cursorline -set ttyfast " Speed up scrolling in Vim -" set spell " enable spell check (may need to download language package) -" set noswapfile " disable creating swap file -" set backupdir=~/.cache/vim " Directory to store backup files. diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 0000000..861dfdb --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,100 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" }, + "advanced-git-search.nvim": { "branch": "main", "commit": "198cc402af1790ab26830fdbf24a28c336a20ba6" }, + "aerial.nvim": { "branch": "master", "commit": "4e77964569ef47a70f9bb76c668dcfea2d089d5a" }, + "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, + "autoclose.nvim": { "branch": "main", "commit": "dc42806540dcf448ecb2bad6b67204410cfbe629" }, + "bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" }, + "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" }, + "catppuccin": { "branch": "refactor/syntax-highlighting", "commit": "87ef3315b10ddee9e82e5ec7d21bf5f24db1a20f" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-latex-symbols": { "branch": "main", "commit": "165fb66afdbd016eaa1570e41672c4c557b57124" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-spell": { "branch": "master", "commit": "694a4e50809d6d645c1ea29015dad0c293f019d6" }, + "cmp-tmux": { "branch": "main", "commit": "95b1b921802e6f60627b3e76afb9380fddd87f9a" }, + "cmp-treesitter": { "branch": "master", "commit": "c8e3a74b51597d69d240085a258636972ce98e15" }, + "cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" }, + "copilot.lua": { "branch": "master", "commit": "86537b286f18783f8b67bccd78a4ef4345679625" }, + "crates.nvim": { "branch": "main", "commit": "c3fd47391de6999f4c939af89494d08443f71916" }, + "csv.vim": { "branch": "master", "commit": "4d5255829afe3b6badb0c8a040116704c0d3213c" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "dropbar.nvim": { "branch": "master", "commit": "cab5e0226bc4f90a28cadcb0dc7341d550f1bdf0" }, + "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, + "flash.nvim": { "branch": "main", "commit": "25ba3f4d1e0b080213b39518ebcfbb693a23c957" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "fzf": { "branch": "master", "commit": "50fa90dfb8eab7f03a7602ea9c098b01ff7236e8" }, + "fzy-lua-native": { "branch": "master", "commit": "820f745b7c442176bcc243e8f38ef4b985febfaf" }, + "gitsigns.nvim": { "branch": "main", "commit": "f4928ba14eb6c667786ac7d69927f6aee6719f1e" }, + "glance.nvim": { "branch": "master", "commit": "51059bcf21016387b6233c89eed220cf47fca752" }, + "go.nvim": { "branch": "master", "commit": "033344ddfa3cd5cfd55037903264b2bb86691619" }, + "guihua.lua": { "branch": "master", "commit": "225db770e36aae6a1e9e3a65578095c8eb4038d3" }, + "hop.nvim": { "branch": "master", "commit": "036462a345792279c58f2f6445756efab706f04a" }, + "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" }, + "lazy.nvim": { "branch": "main", "commit": "9a374a0fb4d3ac42dac4a129d4bead7252473c77" }, + "local-highlight.nvim": { "branch": "master", "commit": "ae3ada3a332128b1036c84c8587b9069891c63da" }, + "lsp-format-modifications.nvim": { "branch": "main", "commit": "006d4cd88f4f09fdc4375fcb75dd5b7d981a723b" }, + "lsp_signature.nvim": { "branch": "master", "commit": "e6d225e27770db81346c2f2aa6c30d0e249f9e7f" }, + "lspsaga.nvim": { "branch": "main", "commit": "6f920cfabddb9b7de5a3a4d0b7cd4f0774ae23e2" }, + "lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "58bc9119ca273c0ce5a66fad1927ef0f617bd81b" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "4ba55f9755ebe8297d92c419b90a946123292ae6" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.align": { "branch": "main", "commit": "b54d88b16bfac62ca6b3d699566135639a3ca4fa" }, + "neoconf.nvim": { "branch": "main", "commit": "57422353819051a67582d268d1557ed56d03d3a3" }, + "neodim": { "branch": "master", "commit": "0543414f1205d8937d8e703a73ae1f9948940b14" }, + "neoscroll.nvim": { "branch": "master", "commit": "a7f5953dbfbe7069568f2d0ed23a9709a56725ab" }, + "none-ls.nvim": { "branch": "main", "commit": "2cde745aadc2c36f6860a77a556494870675771a" }, + "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, + "nvim-bufdel": { "branch": "main", "commit": "523d58e94e7212fff3e05c247b962dc8f93bcfde" }, + "nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" }, + "nvim-dap": { "branch": "master", "commit": "bc03b83c94d0375145ff5ac6a6dcf28c1241e06f" }, + "nvim-dap-ui": { "branch": "master", "commit": "a5606bc5958db86f8d92803bea7400ee26a8d7e4" }, + "nvim-highlight-colors": { "branch": "main", "commit": "a8f6952cb1ff7bde864a34c502f1a42c360a6662" }, + "nvim-lspconfig": { "branch": "master", "commit": "e26da408cf955afa8e9ddbadd510e84ea8976cd7" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, + "nvim-scrollview": { "branch": "main", "commit": "afc67708a5a5585553dee132ffbc4761bb135faf" }, + "nvim-spectre": { "branch": "master", "commit": "9a28f926d3371b7ef02243cbbb653a0478d06e31" }, + "nvim-tree.lua": { "branch": "master", "commit": "f9ff00bc06d7cb70548a3847d7a2a05e928bc988" }, + "nvim-treehopper": { "branch": "master", "commit": "13559079e33665a310d9ccf0e43f4e9bb9f337e2" }, + "nvim-treesitter": { "branch": "master", "commit": "b3c54c31887b05d91be41a41392c811876807fd8" }, + "nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, + "nvim-ts-autotag": { "branch": "main", "commit": "1624866a1379fc1861797f0ed05899a9c1d2ff61" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" }, + "nvim-web-devicons": { "branch": "master", "commit": "e612de3d3a41a6b7be47f51e956dddabcbf419d9" }, + "paint.nvim": { "branch": "main", "commit": "d738db9211ef73182ffa9b92a2a5661411267123" }, + "persisted.nvim": { "branch": "main", "commit": "4df3f8a03690add1bc2f9a79b31e1c43f5e0dd05" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "b29da4a6061a88270e875b38367d82c04c856128" }, + "rustaceanvim": { "branch": "master", "commit": "047f9c9d8cd2861745eb9de6c1570ee0875aa795" }, + "search.nvim": { "branch": "main", "commit": "7b8f2315d031be73e14bc2d82386dfac15952614" }, + "smart-splits.nvim": { "branch": "master", "commit": "44145a4b37217348293fe457992cc38cf3b19f33" }, + "smartyank.nvim": { "branch": "master", "commit": "d9e078fe08d6466e37ea45ac446a9f60e6866789" }, + "sniprun": { "branch": "master", "commit": "f2302d4081914c3312456c91dc6965dfeec266b1" }, + "suda.vim": { "branch": "master", "commit": "b97fab52f9cdeabe2bbb5eb98d82356899f30829" }, + "telescope-frecency.nvim": { "branch": "master", "commit": "bb2c63ee5375ede81c1945b58638412af42b2d62" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope-live-grep-args.nvim": { "branch": "master", "commit": "8ad632f793fd437865f99af5684f78300dac93fb" }, + "telescope-undo.nvim": { "branch": "main", "commit": "51be9ae7c42fc27c0b05505e3a0162e0f05fbb6a" }, + "telescope-zoxide": { "branch": "main", "commit": "68966349aa1b8e9ade403e18479ecf79447389a7" }, + "telescope.nvim": { "branch": "master", "commit": "bfcc7d5c6f12209139f175e6123a7b7de6d9c18a" }, + "todo-comments.nvim": { "branch": "main", "commit": "96fee098a90e7c09c9811aa7df71d773ba8b9b53" }, + "toggleterm.nvim": { "branch": "main", "commit": "8ed0f52006d3207ec6c94de7db62da840937ef2a" }, + "trouble.nvim": { "branch": "main", "commit": "ad8ef38666834e9e438f84bd446657445bc2a71e" }, + "vim-cool": { "branch": "master", "commit": "662e7b11064cbeedad17c45d2fe926e78d3cd0b6" }, + "vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" }, + "vim-matchup": { "branch": "master", "commit": "1535a769d5dca851fe7d41b0be95f7c7203a4bef" }, + "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "which-key.nvim": { "branch": "main", "commit": "6e61b0904e9c038b6c511c43591ae2d811b4975e" }, + "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" } +} \ No newline at end of file diff --git a/nvim/lua/core/event.lua b/nvim/lua/core/event.lua new file mode 100644 index 0000000..b7ba778 --- /dev/null +++ b/nvim/lua/core/event.lua @@ -0,0 +1,152 @@ +-- Now use `` or `` to back to the `dotstutor`. +local autocmd = {} + +function autocmd.nvim_create_augroups(definitions) + for group_name, definition in pairs(definitions) do + -- Prepend an underscore to avoid name clashes + vim.api.nvim_command("augroup _" .. group_name) + vim.api.nvim_command("autocmd!") + for _, def in ipairs(definition) do + local command = table.concat(vim.iter({ "autocmd", def }):flatten(math.huge):totable(), " ") + vim.api.nvim_command(command) + end + vim.api.nvim_command("augroup END") + end +end + +-- Hold off on configuring anything related to the LSP until LspAttach +local mapping = require("keymap.completion") +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("LspKeymapLoader", { clear = true }), + callback = function(event) + if not _G._debugging then + -- LSP Keymaps + mapping.lsp(event.buf) + + -- LSP Inlay Hints + local inlayhints_enabled = require("core.settings").lsp_inlayhints + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.server_capabilities.inlayHintProvider ~= nil then + vim.lsp.inlay_hint.enable(inlayhints_enabled == true, { bufnr = event.buf }) + end + end + end, +}) + +-- auto close NvimTree +vim.api.nvim_create_autocmd("BufEnter", { + group = vim.api.nvim_create_augroup("NvimTreeClose", { clear = true }), + pattern = "NvimTree_*", + callback = function() + local layout = vim.api.nvim_call_function("winlayout", {}) + if + layout[1] == "leaf" + and vim.bo[vim.api.nvim_win_get_buf(layout[2])].filetype == "NvimTree" + and layout[3] == nil + then + vim.api.nvim_command([[confirm quit]]) + end + end, +}) + +-- auto close some filetype with +vim.api.nvim_create_autocmd("FileType", { + pattern = { + "qf", + "help", + "man", + "notify", + "nofile", + "lspinfo", + "terminal", + "prompt", + "toggleterm", + "copilot", + "startuptime", + "tsplayground", + "PlenaryTestPopup", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.api.nvim_buf_set_keymap(event.buf, "n", "q", "close", { silent = true }) + end, +}) + +function autocmd.load_autocmds() + local definitions = { + lazy = {}, + bufs = { + -- Reload vim config automatically + { + "BufWritePost", + [[$VIM_PATH/{*.vim,*.yaml,vimrc} nested source $MYVIMRC | redraw]], + }, + -- Reload Vim script automatically if setlocal autoread + { + "BufWritePost,FileWritePost", + "*.vim", + [[nested if &l:autoread > 0 | source | echo 'source ' . bufname('%') | endif]], + }, + { "BufWritePre", "/tmp/*", "setlocal noundofile" }, + { "BufWritePre", "COMMIT_EDITMSG", "setlocal noundofile" }, + { "BufWritePre", "MERGE_MSG", "setlocal noundofile" }, + { "BufWritePre", "*.tmp", "setlocal noundofile" }, + { "BufWritePre", "*.bak", "setlocal noundofile" }, + -- auto place to last edit + { + "BufReadPost", + "*", + [[if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g'\"" | endif]], + }, + -- Auto toggle fcitx5 + -- {"InsertLeave", "* :silent", "!fcitx5-remote -c"}, + -- {"BufCreate", "*", ":silent !fcitx5-remote -c"}, + -- {"BufEnter", "*", ":silent !fcitx5-remote -c "}, + -- {"BufLeave", "*", ":silent !fcitx5-remote -c "} + }, + wins = { + -- Highlight current line only on focused window + { + "WinEnter,BufEnter,InsertLeave", + "*", + [[if ! &cursorline && &filetype !~# '^\(dashboard\|clap_\)' && ! &pvw | setlocal cursorline | endif]], + }, + { + "WinLeave,BufLeave,InsertEnter", + "*", + [[if &cursorline && &filetype !~# '^\(dashboard\|clap_\)' && ! &pvw | setlocal nocursorline | endif]], + }, + -- Attempt to write shada when leaving nvim + { + "VimLeave", + "*", + [[if has('nvim') | wshada | else | wviminfo! | endif]], + }, + -- Check if file changed when its window is focus, more eager than 'autoread' + { "FocusGained", "* checktime" }, + -- Equalize window dimensions when resizing vim window + { "VimResized", "*", [[tabdo wincmd =]] }, + }, + ft = { + { "FileType", "*", "setlocal formatoptions-=cro" }, + { "FileType", "alpha", "setlocal showtabline=0" }, + { "FileType", "markdown", "setlocal wrap" }, + { "FileType", "dap-repl", "lua require('dap.ext.autocompl').attach()" }, + { + "FileType", + "c,cpp", + "nnoremap h :ClangdSwitchSourceHeaderVSplit", + }, + }, + yank = { + { + "TextYankPost", + "*", + [[silent! lua vim.highlight.on_yank({higroup="IncSearch", timeout=300})]], + }, + }, + } + autocmd.nvim_create_augroups(require("modules.utils").extend_config(definitions, "user.event")) +end + +autocmd.load_autocmds() diff --git a/nvim/lua/core/global.lua b/nvim/lua/core/global.lua new file mode 100644 index 0000000..0f01edc --- /dev/null +++ b/nvim/lua/core/global.lua @@ -0,0 +1,18 @@ +local global = {} +local os_name = vim.uv.os_uname().sysname + +function global:load_variables() + self.is_mac = os_name == "Darwin" + self.is_linux = os_name == "Linux" + self.is_windows = os_name == "Windows_NT" + self.is_wsl = vim.fn.has("wsl") == 1 + self.vim_path = vim.fn.stdpath("config") + self.cache_dir = vim.fn.stdpath("cache") + self.data_dir = string.format("%s/site/", vim.fn.stdpath("data")) + self.modules_dir = self.vim_path .. "/modules" + self.home = self.is_windows and os.getenv("USERPROFILE") or os.getenv("HOME") +end + +global:load_variables() + +return global diff --git a/nvim/lua/core/init.lua b/nvim/lua/core/init.lua new file mode 100644 index 0000000..a5fa328 --- /dev/null +++ b/nvim/lua/core/init.lua @@ -0,0 +1,169 @@ +local settings = require("core.settings") +local global = require("core.global") + +-- Create cache dir and data dirs +local createdir = function() + local data_dirs = { + global.cache_dir .. "/backup", + global.cache_dir .. "/session", + global.cache_dir .. "/swap", + global.cache_dir .. "/tags", + global.cache_dir .. "/undo", + } + -- Only check whether cache_dir exists, this would be enough. + if vim.fn.isdirectory(global.cache_dir) == 0 then + ---@diagnostic disable-next-line: param-type-mismatch + vim.fn.mkdir(global.cache_dir, "p") + for _, dir in pairs(data_dirs) do + if vim.fn.isdirectory(dir) == 0 then + vim.fn.mkdir(dir, "p") + end + end + end +end + +local disable_distribution_plugins = function() + -- Disable menu loading + vim.g.did_install_default_menus = 1 + vim.g.did_install_syntax_menu = 1 + + -- Comment this if you define your own filetypes in `after/ftplugin` + -- vim.g.did_load_filetypes = 1 + + -- Do not load native syntax completion + vim.g.loaded_syntax_completion = 1 + + -- Do not load spell files + vim.g.loaded_spellfile_plugin = 1 + + -- Whether to load netrw by default + -- vim.g.loaded_netrw = 1 + -- vim.g.loaded_netrwFileHandlers = 1 + -- vim.g.loaded_netrwPlugin = 1 + -- vim.g.loaded_netrwSettings = 1 + -- newtrw liststyle: https://medium.com/usevim/the-netrw-style-options-3ebe91d42456 + vim.g.netrw_liststyle = 3 + + -- Do not load tohtml.vim + vim.g.loaded_2html_plugin = 1 + + -- Do not load zipPlugin.vim, gzip.vim and tarPlugin.vim (all of these plugins are + -- related to reading files inside compressed containers) + vim.g.loaded_gzip = 1 + vim.g.loaded_tar = 1 + vim.g.loaded_tarPlugin = 1 + vim.g.loaded_vimball = 1 + vim.g.loaded_vimballPlugin = 1 + vim.g.loaded_zip = 1 + vim.g.loaded_zipPlugin = 1 + + -- Do not use builtin matchit.vim and matchparen.vim because we're using vim-matchup + vim.g.loaded_matchit = 1 + vim.g.loaded_matchparen = 1 + + -- Disable sql omni completion + vim.g.loaded_sql_completion = 1 + + -- Set this to 0 in order to disable native EditorConfig support + vim.g.editorconfig = 1 + + -- Disable remote plugins + -- NOTE: + -- > Disabling rplugin.vim will make `wilder.nvim` complain about missing rplugins during :checkhealth, + -- > but since it's config doesn't require python rtp (strictly), it's fine to ignore that for now. + -- vim.g.loaded_remote_plugins = 1 +end + +local leader_map = function() + vim.g.mapleader = " " + -- NOTE: + -- > Uncomment the following if you're using a other than , and you wish + -- > to disable advancing one character by pressing in normal/visual mode. + -- vim.api.nvim_set_keymap("n", " ", "", { noremap = true }) + -- vim.api.nvim_set_keymap("x", " ", "", { noremap = true }) +end + +local gui_config = function() + vim.api.nvim_set_option_value("guifont", settings.gui_config.font_name .. ":h" .. settings.gui_config.font_size, {}) +end + +local neovide_config = function() + for name, config in pairs(settings.neovide_config) do + vim.g["neovide_" .. name] = config + end +end + +local clipboard_config = function() + if global.is_mac then + vim.g.clipboard = { + name = "macOS-clipboard", + copy = { ["+"] = "pbcopy", ["*"] = "pbcopy" }, + paste = { ["+"] = "pbpaste", ["*"] = "pbpaste" }, + cache_enabled = 0, + } + elseif global.is_wsl then + vim.g.clipboard = { + name = "win32yank-wsl", + copy = { + ["+"] = "win32yank.exe -i --crlf", + ["*"] = "win32yank.exe -i --crlf", + }, + paste = { + ["+"] = "win32yank.exe -o --lf", + ["*"] = "win32yank.exe -o --lf", + }, + cache_enabled = 0, + } + end +end + +local shell_config = function() + if global.is_windows then + if not (vim.fn.executable("pwsh") == 1 or vim.fn.executable("powershell") == 1) then + vim.notify( + [[ +Failed to setup terminal config + +PowerShell is either not installed, missing from PATH, or not executable; +cmd.exe will be used instead for `:!` (shell bang) and toggleterm.nvim. + +You're recommended to install PowerShell for better experience.]], + vim.log.levels.WARN, + { title = "[core] Runtime Warning" } + ) + return + end + + local basecmd = "-NoLogo -MTA -ExecutionPolicy RemoteSigned" + local ctrlcmd = "-Command [console]::InputEncoding = [console]::OutputEncoding = [System.Text.Encoding]::UTF8" + local set_opts = vim.api.nvim_set_option_value + set_opts("shell", vim.fn.executable("pwsh") == 1 and "pwsh" or "powershell", {}) + set_opts("shellcmdflag", string.format("%s %s;", basecmd, ctrlcmd), {}) + set_opts("shellredir", "-RedirectStandardOutput %s -NoNewWindow -Wait", {}) + set_opts("shellpipe", "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode", {}) + set_opts("shellquote", "", {}) + set_opts("shellxquote", "", {}) + end +end + +local load_core = function() + createdir() + disable_distribution_plugins() + leader_map() + + gui_config() + neovide_config() + clipboard_config() + shell_config() + + require("core.options") + require("core.mapping") + require("core.event") + require("core.pack") + require("keymap") + + vim.api.nvim_set_option_value("background", settings.background, {}) + vim.cmd.colorscheme(settings.colorscheme) +end + +load_core() diff --git a/nvim/lua/core/mapping.lua b/nvim/lua/core/mapping.lua new file mode 100644 index 0000000..3512169 --- /dev/null +++ b/nvim/lua/core/mapping.lua @@ -0,0 +1,65 @@ +local bind = require("keymap.bind") +local map_cr = bind.map_cr +local map_cu = bind.map_cu +local map_cmd = bind.map_cmd +local map_callback = bind.map_callback + +local core_map = { + -- Suckless + ["n|"] = map_cr("normal za"):with_noremap():with_silent():with_desc("edit: Toggle code fold"), + ["n|"] = map_cu("write"):with_noremap():with_silent():with_desc("edit: Save file"), + ["n|Y"] = map_cmd("y$"):with_desc("edit: Yank text to EOL"), + ["n|D"] = map_cmd("d$"):with_desc("edit: Delete text to EOL"), + ["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("edit: Next search result"), + ["n|N"] = map_cmd("Nzzzv"):with_noremap():with_desc("edit: Prev search result"), + ["n|J"] = map_cmd("mzJ`z"):with_noremap():with_desc("edit: Join next line"), + ["n|"] = map_callback(function() + _flash_esc_or_noh() + end) + :with_noremap() + :with_silent() + :with_desc("edit: Clear search highlight"), + ["n|"] = map_cmd("h"):with_noremap():with_desc("window: Focus left"), + ["n|"] = map_cmd("l"):with_noremap():with_desc("window: Focus right"), + ["n|"] = map_cmd("j"):with_noremap():with_desc("window: Focus down"), + ["n|"] = map_cmd("k"):with_noremap():with_desc("window: Focus up"), + ["t|h"] = map_cmd("wincmd h"):with_silent():with_noremap():with_desc("window: Focus left"), + ["t|l"] = map_cmd("wincmd l"):with_silent():with_noremap():with_desc("window: Focus right"), + ["t|j"] = map_cmd("wincmd j"):with_silent():with_noremap():with_desc("window: Focus down"), + ["t|k"] = map_cmd("wincmd k"):with_silent():with_noremap():with_desc("window: Focus up"), + ["n|"] = map_cr("vertical resize -3"):with_silent():with_desc("window: Resize -3 vertically"), + ["n|"] = map_cr("vertical resize +3"):with_silent():with_desc("window: Resize +3 vertically"), + ["n|"] = map_cr("resize -3"):with_silent():with_desc("window: Resize -3 horizontally"), + ["n|"] = map_cr("resize +3"):with_silent():with_desc("window: Resize +3 horizontally"), + ["n|"] = map_cr("wq"):with_desc("edit: Save file and quit"), + ["n|"] = map_cr("q!"):with_desc("edit: Force quit"), + ["n|o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"), + ["n|bn"] = map_cu("enew"):with_noremap():with_silent():with_desc("buffer: New"), + ["n|tn"] = map_cr("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"), + ["n|tk"] = map_cr("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"), + ["n|tj"] = map_cr("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"), + ["n|to"] = map_cr("tabonly"):with_noremap():with_silent():with_desc("tab: Only keep current tab"), + -- Insert mode + ["i|"] = map_cmd("u"):with_noremap():with_desc("edit: Delete previous block"), + ["i|"] = map_cmd(""):with_noremap():with_desc("edit: Move cursor to left"), + ["i|"] = map_cmd("^i"):with_noremap():with_desc("edit: Move cursor to line start"), + ["i|"] = map_cmd(":w"):with_desc("edit: Save file"), + ["i|"] = map_cmd(":wq"):with_desc("edit: Save file and quit"), + -- Command mode + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Left"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Right"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Home"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: End"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Delete"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Backspace"), + ["c|"] = map_cmd([[=expand("%:p:h") . "/" ]]) + :with_noremap() + :with_desc("edit: Complete path of current file"), + -- Visual mode + ["v|J"] = map_cmd(":m '>+1gv=gv"):with_desc("edit: Move this line down"), + ["v|K"] = map_cmd(":m '<-2gv=gv"):with_desc("edit: Move this line up"), + ["v|<"] = map_cmd(""] = map_cmd(">gv"):with_desc("edit: Increase indent"), +} + +bind.nvim_load_mapping(core_map) diff --git a/nvim/lua/core/options.lua b/nvim/lua/core/options.lua new file mode 100644 index 0000000..d025abf --- /dev/null +++ b/nvim/lua/core/options.lua @@ -0,0 +1,128 @@ +local global = require("core.global") + +local function load_options() + local global_local = { + -- backupdir = global.cache_dir .. "/backup/", + -- directory = global.cache_dir .. "/swap/", + -- spellfile = global.cache_dir .. "/spell/en.uft-8.add", + -- viewdir = global.cache_dir .. "/view/", + autoindent = true, + autoread = true, + autowrite = true, + backspace = "indent,eol,start", + backup = false, + backupskip = "/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*,/private/var/*,.vault.vim", + breakat = [[\ \ ;:,!?]], + breakindentopt = "shift:2,min:20", + clipboard = "unnamedplus", + cmdheight = 1, -- 0, 1, 2 + cmdwinheight = 5, + complete = ".,w,b,k,kspell", + completeopt = "menuone,noselect,popup", + concealcursor = "niv", + conceallevel = 0, + cursorcolumn = true, + cursorline = true, + diffopt = "filler,iwhite,internal,linematch:60,algorithm:patience", + display = "lastline", + encoding = "utf-8", + equalalways = false, + errorbells = true, + fileformats = "unix,mac,dos", + foldenable = true, + foldlevelstart = 99, + formatoptions = "1jcroql", + grepformat = "%f:%l:%c:%m", + grepprg = "rg --hidden --vimgrep --smart-case --", + helpheight = 12, + hidden = true, + history = 2000, + ignorecase = true, + inccommand = "nosplit", + incsearch = true, + infercase = true, + jumpoptions = "stack", + laststatus = 3, + linebreak = true, + list = true, + listchars = "tab:»·,nbsp:+,trail:·,extends:→,precedes:←", + magic = true, + mousescroll = "ver:3,hor:6", + number = true, + previewheight = 12, + -- Do NOT adjust the following option (pumblend) if you're using transparent background + pumblend = 0, + pumheight = 15, + redrawtime = 1500, + relativenumber = true, + ruler = true, + scrolloff = 2, + sessionoptions = "buffers,curdir,folds,help,tabpages,winpos,winsize", + shada = "!,'500,<50,@100,s10,h", + shiftround = true, + shiftwidth = 4, + shortmess = "aoOTIcF", + showbreak = "↳ ", + showcmd = false, + showmode = false, + showtabline = 2, + sidescrolloff = 5, + signcolumn = "yes", + smartcase = true, + smarttab = true, + smoothscroll = true, + splitbelow = true, + splitkeep = "screen", + splitright = true, + startofline = false, + swapfile = false, + switchbuf = "usetab,uselast", + synmaxcol = 2500, + tabstop = 4, + termguicolors = true, + timeout = true, + timeoutlen = 300, + ttimeout = true, + ttimeoutlen = 0, + undodir = global.cache_dir .. "/undo/", + undofile = true, + -- Please do NOT set `updatetime` to above 500, otherwise most plugins may not function correctly + updatetime = 200, + viewoptions = "folds,cursor,curdir,slash,unix", + virtualedit = "block", + visualbell = true, + whichwrap = "h,l,<,>,[,],~", + wildignore = ".git,.hg,.svn,*.pyc,*.o,*.out,*.jpg,*.jpeg,*.png,*.gif,*.zip,**/tmp/**,*.DS_Store,**/node_modules/**,**/bower_modules/**", + wildignorecase = true, + -- Do NOT adjust the following option (winblend) if you're using transparent background + winblend = 0, + winminwidth = 10, + winwidth = 30, + wrap = false, + wrapscan = true, + writebackup = false, + } + + local function isempty(s) + return s == nil or s == "" + end + local function use_if_defined(val, fallback) + return val ~= nil and val or fallback + end + + -- custom python provider + local conda_prefix = os.getenv("CONDA_PREFIX") + if not isempty(conda_prefix) then + vim.g.python_host_prog = use_if_defined(vim.g.python_host_prog, conda_prefix .. "/bin/python") + vim.g.python3_host_prog = use_if_defined(vim.g.python3_host_prog, conda_prefix .. "/bin/python") + else + vim.g.python_host_prog = use_if_defined(vim.g.python_host_prog, "python") + vim.g.python3_host_prog = use_if_defined(vim.g.python3_host_prog, "python3") + end + + for name, value in pairs(require("modules.utils").extend_config(global_local, "user.options")) do + vim.api.nvim_set_option_value(name, value, {}) + end +end + +load_options() diff --git a/nvim/lua/core/pack.lua b/nvim/lua/core/pack.lua new file mode 100644 index 0000000..326bf3d --- /dev/null +++ b/nvim/lua/core/pack.lua @@ -0,0 +1,138 @@ +local fn, api = vim.fn, vim.api +local global = require("core.global") +local is_mac = global.is_mac +local vim_path = global.vim_path +local data_dir = global.data_dir +local lazy_path = data_dir .. "lazy/lazy.nvim" +local modules_dir = vim_path .. "/lua/modules" +local user_config_dir = vim_path .. "/lua/user" + +local settings = require("core.settings") +local use_ssh = settings.use_ssh + +local icons = { + kind = require("modules.utils.icons").get("kind"), + documents = require("modules.utils.icons").get("documents"), + ui = require("modules.utils.icons").get("ui"), + ui_sep = require("modules.utils.icons").get("ui", true), + misc = require("modules.utils.icons").get("misc"), +} + +local Lazy = {} + +function Lazy:load_plugins() + self.modules = {} + + local append_nativertp = function() + package.path = package.path + .. string.format( + ";%s;%s;%s", + modules_dir .. "/configs/?.lua", + modules_dir .. "/configs/?/init.lua", + user_config_dir .. "/?.lua" + ) + end + + local get_plugins_list = function() + local list = {} + local plugins_list = vim.split(fn.glob(modules_dir .. "/plugins/*.lua"), "\n") + local user_plugins_list = vim.split(fn.glob(user_config_dir .. "/plugins/*.lua"), "\n", { trimempty = true }) + vim.list_extend(plugins_list, user_plugins_list) + for _, f in ipairs(plugins_list) do + -- aggregate the plugins from `/plugins/*.lua` and `/user/plugins/*.lua` to a plugin list of a certain field for later `require` action. + -- current fields contains: completion, editor, lang, tool, ui + list[#list + 1] = f:find(modules_dir) and f:sub(#modules_dir - 6, -1) or f:sub(#user_config_dir - 3, -1) + end + return list + end + + append_nativertp() + + for _, m in ipairs(get_plugins_list()) do + -- require modules returned from `get_plugins_list()` function. + local modules = require(m:sub(0, #m - 4)) + if type(modules) == "table" then + for name, conf in pairs(modules) do + self.modules[#self.modules + 1] = vim.tbl_extend("force", { name }, conf) + end + end + end + for _, name in ipairs(settings.disabled_plugins) do + self.modules[#self.modules + 1] = { name, enabled = false } + end +end + +function Lazy:load_lazy() + if not vim.uv.fs_stat(lazy_path) then + local lazy_repo = use_ssh and "git@github.com:folke/lazy.nvim.git " or "https://github.com/folke/lazy.nvim.git " + api.nvim_command("!git clone --filter=blob:none --branch=stable " .. lazy_repo .. lazy_path) + end + self:load_plugins() + + local clone_prefix = use_ssh and "git@github.com:%s.git" or "https://github.com/%s.git" + local lazy_settings = { + root = data_dir .. "lazy", -- directory where plugins will be installed + git = { + -- log = { "-10" }, -- show the last 10 commits + timeout = 300, + url_format = clone_prefix, + }, + install = { + -- install missing plugins on startup. This doesn't increase startup time. + missing = true, + colorscheme = { settings.colorscheme }, + }, + ui = { + -- a number <1 is a percentage., >1 is a fixed size + size = { width = 0.88, height = 0.8 }, + wrap = true, -- wrap the lines in the ui + -- The border to use for the UI window. Accepts same border values as |nvim_open_win()|. + border = "rounded", + icons = { + cmd = icons.misc.Code, + config = icons.ui.Gear, + event = icons.kind.Event, + ft = icons.documents.Files, + init = icons.misc.ManUp, + import = icons.documents.Import, + keys = icons.ui.Keyboard, + loaded = icons.ui.Check, + not_loaded = icons.misc.Ghost, + plugin = icons.ui.Package, + runtime = icons.misc.Vim, + source = icons.kind.StaticMethod, + start = icons.ui.Play, + list = { + icons.ui_sep.BigCircle, + icons.ui_sep.BigUnfilledCircle, + icons.ui_sep.Square, + icons.ui_sep.ChevronRight, + }, + }, + }, + performance = { + cache = { + enabled = true, + path = vim.fn.stdpath("cache") .. "/lazy/cache", + -- Once one of the following events triggers, caching will be disabled. + -- To cache all modules, set this to `{}`, but that is not recommended. + disable_events = { "UIEnter", "BufReadPre" }, + ttl = 3600 * 24 * 2, -- keep unused modules for up to 2 days + }, + reset_packpath = true, -- reset the package path to improve startup time + rtp = { + reset = true, -- reset the runtime path to $VIMRUNTIME and the config directory + ---@type string[] + paths = {}, -- add any custom paths here that you want to include in the rtp + }, + }, + } + if is_mac then + lazy_settings.concurrency = 20 + end + + vim.opt.rtp:prepend(lazy_path) + require("lazy").setup(self.modules, lazy_settings) +end + +Lazy:load_lazy() diff --git a/nvim/lua/core/settings.lua b/nvim/lua/core/settings.lua new file mode 100644 index 0000000..1254160 --- /dev/null +++ b/nvim/lua/core/settings.lua @@ -0,0 +1,225 @@ +local settings = {} + +-- Set it to false if you want to use https to update plugins and treesitter parsers. +---@type boolean +settings["use_ssh"] = true + +-- Set it to false if you don't use copilot +---@type boolean +settings["use_copilot"] = true + +-- Set it to false if there is no need to format on save. +---@type boolean +settings["format_on_save"] = true + +-- Set format timeout here (in ms). +---@type number +settings["format_timeout"] = 1000 + +-- Set it to false if the notification after formatting is annoying. +---@type boolean +settings["format_notify"] = true + +-- Set it to true if you prefer formatting ONLY the *changed lines* as defined by your version control system. +-- NOTE: This entry will only be respected if: +-- > The buffer to be formatted is under version control (Git or Mercurial); +-- > Any of the server attached to that buffer supports |DocumentRangeFormattingProvider| server capability. +-- Otherwise Neovim would fall back to format the whole buffer, and a warning will be issued. +---@type boolean +settings["format_modifications_only"] = false + +-- Set the format disabled directories here, files under these dirs won't be formatted on save. +--- NOTE: Directories may contain regular expressions (grammar: vim). |regexp| +--- NOTE: Directories are automatically normalized. |vim.fs.normalize()| +---@type string[] +settings["format_disabled_dirs"] = { + -- Example + "~/format_disabled_dir", +} + +-- Filetypes in this list will skip lsp formatting if rhs is true. +---@type table +settings["formatter_block_list"] = { + lua = false, -- example +} + +-- Servers in this list will skip setting formatting capabilities if rhs is true. +---@type table +settings["server_formatting_block_list"] = { + lua_ls = true, + tsserver = true, + clangd = true, +} + +-- Set it to false if you want to turn off LSP Inlay Hints +---@type boolean +settings["lsp_inlayhints"] = true + +-- Set it to false if diagnostics virtual text is annoying. +-- If disabled, you may browse lsp diagnostics using trouble.nvim (press `gt` to toggle it). +---@type boolean +settings["diagnostics_virtual_text"] = true + +-- Set it to one of the values below if you want to change the visible severity level of lsp diagnostics. +-- Priority: `Error` > `Warning` > `Information` > `Hint`. +-- > e.g. if you set this option to `Warning`, only lsp warnings and errors will be shown. +-- NOTE: This entry only works when `diagnostics_virtual_text` is true. +---@type "ERROR"|"WARN"|"INFO"|"HINT" +settings["diagnostics_level"] = "HINT" + +-- Set the plugins to disable here. +-- Example: "Some-User/A-Repo" +---@type string[] +settings["disabled_plugins"] = {} + +-- Set it to false if you don't use nvim to open big files. +---@type boolean +settings["load_big_files_faster"] = true + +-- Change the colors of the global palette here. +-- Settings will complete their replacement at initialization. +-- Parameters will be automatically completed as you type. +-- Example: { sky = "#04A5E5" } +---@type palette[] +settings["palette_overwrite"] = {} + +-- Set the colorscheme to use here. +-- Available values are: `catppuccin`, `catppuccin-latte`, `catppucin-mocha`, `catppuccin-frappe`, `catppuccin-macchiato`. +---@type string +settings["colorscheme"] = "catppuccin" + +-- Set it to true if your terminal has transparent background. +---@type boolean +settings["transparent_background"] = false + +-- Set background color to use here. +-- Useful if you would like to use a colorscheme that has a light and dark variant like `edge`. +-- Valid values are: `dark`, `light`. +---@type "dark"|"light" +settings["background"] = "dark" + +-- Set the command for handling external URLs here. The executable must be available on your $PATH. +-- This entry is IGNORED on Windows and macOS, which have their default handlers builtin. +---@type string +settings["external_browser"] = "chrome-cli open" + +-- Set the language servers that will be installed during bootstrap here. +-- check the below link for all the supported LSPs: +-- https://github.com/neovim/nvim-lspconfig/tree/master/lua/lspconfig/server_configurations +---@type string[] +settings["lsp_deps"] = { + "bashls", + "clangd", + "html", + "jsonls", + "lua_ls", + "pylsp", + "gopls", +} + +-- Set the general-purpose servers that will be installed during bootstrap here. +-- Check the below link for all supported sources. +-- in `code_actions`, `completion`, `diagnostics`, `formatting`, `hover` folders: +-- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins +---@type string[] +settings["null_ls_deps"] = { + "clang_format", + "gofumpt", + "goimports", + "prettier", + "shfmt", + "stylua", + "vint", +} + +-- Set the Debug Adapter Protocol (DAP) clients that will be installed and configured during bootstrap here. +-- Check the below link for all supported DAPs: +-- https://github.com/jay-babu/mason-nvim-dap.nvim/blob/main/lua/mason-nvim-dap/mappings/source.lua +---@type string[] +settings["dap_deps"] = { + "codelldb", -- C-Family + "delve", -- Go + "python", -- Python (debugpy) +} + +-- Set the Treesitter parsers that will be installed during bootstrap here. +-- Check the below link for all supported languages: +-- https://github.com/nvim-treesitter/nvim-treesitter#supported-languages +---@type string[] +settings["treesitter_deps"] = { + "bash", + "c", + "cpp", + "css", + "go", + "gomod", + "html", + "javascript", + "json", + "jsonc", + "latex", + "lua", + "make", + "markdown", + "markdown_inline", + "python", + "rust", + "typescript", + "vimdoc", + "vue", + "yaml", +} + +-- Set the options for neovim's gui clients like `neovide` and `neovim-qt` here. +-- NOTE: Currently, only the following options related to the GUI are supported. Other entries will be IGNORED. +---@type { font_name: string, font_size: number } +settings["gui_config"] = { + font_name = "JetBrainsMono Nerd Font", + font_size = 12, +} + +-- Set the options specific to `neovide` here. +-- NOTE: You should remove the `neovide_` prefix (with trailing underscore) from all your entries below. +-- Check the below link for all supported entries: +-- https://neovide.dev/configuration.html +---@type table +settings["neovide_config"] = { + no_idle = true, + refresh_rate = 120, + cursor_vfx_mode = "railgun", + cursor_vfx_opacity = 200.0, + cursor_antialiasing = true, + cursor_trail_length = 0.05, + cursor_animation_length = 0.03, + cursor_vfx_particle_speed = 20.0, + cursor_vfx_particle_density = 5.0, + cursor_vfx_particle_lifetime = 1.2, +} + +-- Set the dashboard startup image here +-- You can generate the ascii image using: https://github.com/TheZoraiz/ascii-image-converter +-- More info: https://github.com/ayamir/nvimdots/wiki/Issues#change-dashboard-startup-image +---@type string[] +settings["dashboard_image"] = { + [[⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣡⣾⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⣿⣟⠻⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⡿⢫⣷⣿⣿⣿⣿⣿⣿⣿⣾⣯⣿⡿⢧⡚⢷⣌⣽⣿⣿⣿⣿⣿⣶⡌⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣮⣇⣘⠿⢹⣿⣿⣿⣿⣿⣻⢿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⠀⢸⣿⣿⡇⣿⣿⣿⣿⣿⣿⣿⣿⡟⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣻⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⡇⠀⣬⠏⣿⡇⢻⣿⣿⣿⣿⣿⣿⣿⣷⣼⣿⣿⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⠀⠈⠁⠀⣿⡇⠘⡟⣿⣿⣿⣿⣿⣿⣿⣿⡏⠿⣿⣟⣿⣿⣿⣿⣿⣿⣿⣿⣇⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⡏⠀⠀⠐⠀⢻⣇⠀⠀⠹⣿⣿⣿⣿⣿⣿⣩⡶⠼⠟⠻⠞⣿⡈⠻⣟⢻⣿⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⢿⠀⡆⠀⠘⢿⢻⡿⣿⣧⣷⢣⣶⡃⢀⣾⡆⡋⣧⠙⢿⣿⣿⣟⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⡥⠂⡐⠀⠁⠑⣾⣿⣿⣾⣿⣿⣿⡿⣷⣷⣿⣧⣾⣿⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⡿⣿⣍⡴⠆⠀⠀⠀⠀⠀⠀⠀⠀⣼⣄⣀⣷⡄⣙⢿⣿⣿⣿⣿⣯⣶⣿⣿⢟⣾⣿⣿⢡⣿⣿⣿⣿⣿]], + [[⣿⡏⣾⣿⣿⣿⣷⣦⠀⠀⠀⢀⡀⠀⠀⠠⣭⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⣡⣾⣿⣿⢏⣾⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⣿⣿⣿⣿⣿⡴⠀⠀⠀⠀⠀⠠⠀⠰⣿⣿⣿⣷⣿⠿⠿⣿⣿⣭⡶⣫⠔⢻⢿⢇⣾⣿⣿⣿⣿⣿⣿]], + [[⣿⣿⣿⡿⢫⣽⠟⣋⠀⠀⠀⠀⣶⣦⠀⠀⠀⠈⠻⣿⣿⣿⣾⣿⣿⣿⣿⡿⣣⣿⣿⢸⣾⣿⣿⣿⣿⣿⣿⣿]], + [[⡿⠛⣹⣶⣶⣶⣾⣿⣷⣦⣤⣤⣀⣀⠀⠀⠀⠀⠀⠀⠉⠛⠻⢿⣿⡿⠫⠾⠿⠋⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣀⡆⣠⢀⣴⣏⡀⠀⠀⠀⠉⠀⠀⢀⣠⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⠿⠛⠛⠛⠛⠛⠛⠻⢿⣿⣿⣿⣿⣯⣟⠷⢷⣿⡿⠋⠀⠀⠀⠀⣵⡀⢠⡿⠋⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], + [[⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⢿⣿⣿⠂⠀⠀⠀⠀⠀⢀⣽⣿⣿⣿⣿⣿⣿⣿⣍⠛⠿⣿⣿⣿⣿⣿⣿]], +} + +return require("modules.utils").extend_config(settings, "user.settings") diff --git a/nvim/lua/keymap/bind.lua b/nvim/lua/keymap/bind.lua new file mode 100644 index 0000000..a5c4b8d --- /dev/null +++ b/nvim/lua/keymap/bind.lua @@ -0,0 +1,169 @@ +---@class map_rhs +---@field cmd string +---@field options table +---@field options.noremap boolean +---@field options.silent boolean +---@field options.expr boolean +---@field options.nowait boolean +---@field options.callback function +---@field options.desc string +---@field buffer boolean|number +local rhs_options = {} + +function rhs_options:new() + local instance = { + cmd = "", + options = { + noremap = false, + silent = false, + expr = false, + nowait = false, + callback = nil, + desc = "", + }, + buffer = false, + } + setmetatable(instance, self) + self.__index = self + return instance +end + +---@param cmd_string string +---@return map_rhs +function rhs_options:map_cmd(cmd_string) + self.cmd = cmd_string + return self +end + +---@param cmd_string string +---@return map_rhs +function rhs_options:map_cr(cmd_string) + self.cmd = (":%s"):format(cmd_string) + return self +end + +---@param cmd_string string +---@return map_rhs +function rhs_options:map_args(cmd_string) + self.cmd = (":%s"):format(cmd_string) + return self +end + +---@param cmd_string string +---@return map_rhs +function rhs_options:map_cu(cmd_string) + -- to eliminate the automatically inserted range in visual mode + self.cmd = (":%s"):format(cmd_string) + return self +end + +---@param callback fun():nil +--- Takes a callback that will be called when the key is pressed +---@return map_rhs +function rhs_options:map_callback(callback) + self.cmd = "" + self.options.callback = callback + return self +end + +---@return map_rhs +function rhs_options:with_silent() + self.options.silent = true + return self +end + +---@param description_string string +---@return map_rhs +function rhs_options:with_desc(description_string) + self.options.desc = description_string + return self +end + +---@return map_rhs +function rhs_options:with_noremap() + self.options.noremap = true + return self +end + +---@return map_rhs +function rhs_options:with_expr() + self.options.expr = true + return self +end + +---@return map_rhs +function rhs_options:with_nowait() + self.options.nowait = true + return self +end + +---@param num number +---@return map_rhs +function rhs_options:with_buffer(num) + self.buffer = num + return self +end + +local bind = {} + +---@param cmd_string string +---@return map_rhs +function bind.map_cr(cmd_string) + local ro = rhs_options:new() + return ro:map_cr(cmd_string) +end + +---@param cmd_string string +---@return map_rhs +function bind.map_cmd(cmd_string) + local ro = rhs_options:new() + return ro:map_cmd(cmd_string) +end + +---@param cmd_string string +---@return map_rhs +function bind.map_cu(cmd_string) + local ro = rhs_options:new() + return ro:map_cu(cmd_string) +end + +---@param cmd_string string +---@return map_rhs +function bind.map_args(cmd_string) + local ro = rhs_options:new() + return ro:map_args(cmd_string) +end + +---@param callback fun():nil +---@return map_rhs +function bind.map_callback(callback) + local ro = rhs_options:new() + return ro:map_callback(callback) +end + +---@param cmd_string string +---@return string escaped_string +function bind.escape_termcode(cmd_string) + return vim.api.nvim_replace_termcodes(cmd_string, true, true, true) +end + +---@param mapping table +function bind.nvim_load_mapping(mapping) + for key, value in pairs(mapping) do + local modes, keymap = key:match("([^|]*)|?(.*)") + if type(value) == "table" then + for _, mode in ipairs(vim.split(modes, "")) do + local rhs = value.cmd + local options = value.options + local buf = value.buffer + if buf and type(buf) == "number" then + vim.api.nvim_buf_set_keymap(buf, mode, keymap, rhs, options) + else + vim.api.nvim_set_keymap(mode, keymap, rhs, options) + end + end + end + end +end + +return bind diff --git a/nvim/lua/keymap/completion.lua b/nvim/lua/keymap/completion.lua new file mode 100644 index 0000000..ae67e2a --- /dev/null +++ b/nvim/lua/keymap/completion.lua @@ -0,0 +1,74 @@ +local bind = require("keymap.bind") +local map_cr = bind.map_cr +local map_cmd = bind.map_cmd +local map_callback = bind.map_callback + +local plug_map = { + ["n|"] = map_cmd("FormatToggle"):with_noremap():with_desc("formatter: Toggle format on save"), +} +bind.nvim_load_mapping(plug_map) + +local mapping = {} + +function mapping.lsp(buf) + local map = { + -- LSP-related keymaps, ONLY effective in buffers with LSP(s) attached + ["n|li"] = map_cr("LspInfo"):with_silent():with_buffer(buf):with_desc("lsp: Info"), + ["n|lr"] = map_cr("LspRestart"):with_silent():with_buffer(buf):with_nowait():with_desc("lsp: Restart"), + ["n|go"] = map_cr("AerialToggle!"):with_silent():with_buffer(buf):with_desc("lsp: Toggle outline"), + ["n|gto"] = map_callback(function() + require("telescope").extensions.aerial.aerial() + end) + :with_silent() + :with_buffer(buf) + :with_desc("lsp: Toggle outline in Telescope"), + ["n|g["] = map_cr("Lspsaga diagnostic_jump_prev") + :with_silent() + :with_buffer(buf) + :with_desc("lsp: Prev diagnostic"), + ["n|g]"] = map_cr("Lspsaga diagnostic_jump_next") + :with_silent() + :with_buffer(buf) + :with_desc("lsp: Next diagnostic"), + ["n|lx"] = map_cr("Lspsaga show_line_diagnostics ++unfocus") + :with_silent() + :with_buffer(buf) + :with_desc("lsp: Line diagnostic"), + ["n|gs"] = map_callback(function() + vim.lsp.buf.signature_help() + end):with_desc("lsp: Signature help"), + ["n|gr"] = map_cr("Lspsaga rename"):with_silent():with_buffer(buf):with_desc("lsp: Rename in file range"), + ["n|gR"] = map_cr("Lspsaga rename ++project") + :with_silent() + :with_buffer(buf) + :with_desc("lsp: Rename in project range"), + ["n|K"] = map_cr("Lspsaga hover_doc"):with_silent():with_buffer(buf):with_desc("lsp: Show doc"), + ["nv|ga"] = map_cr("Lspsaga code_action") + :with_silent() + :with_buffer(buf) + :with_desc("lsp: Code action for cursor"), + ["n|gd"] = map_cr("Glance definitions"):with_silent():with_buffer(buf):with_desc("lsp: Preview definition"), + ["n|gD"] = map_cr("Lspsaga goto_definition"):with_silent():with_buffer(buf):with_desc("lsp: Goto definition"), + ["n|gh"] = map_cr("Glance references"):with_silent():with_buffer(buf):with_desc("lsp: Show reference"), + ["n|gm"] = map_cr("Glance implementations") + :with_silent() + :with_buffer(buf) + :with_desc("lsp: Show implementation"), + ["n|gci"] = map_cr("Lspsaga incoming_calls") + :with_silent() + :with_buffer(buf) + :with_desc("lsp: Show incoming calls"), + ["n|gco"] = map_cr("Lspsaga outgoing_calls") + :with_silent() + :with_buffer(buf) + :with_desc("lsp: Show outgoing calls"), + } + bind.nvim_load_mapping(map) + + local ok, user_mappings = pcall(require, "user.keymap.completion") + if ok and type(user_mappings.lsp) == "function" then + require("modules.utils.keymap").replace(user_mappings.lsp(buf)) + end +end + +return mapping diff --git a/nvim/lua/keymap/editor.lua b/nvim/lua/keymap/editor.lua new file mode 100644 index 0000000..9b0271c --- /dev/null +++ b/nvim/lua/keymap/editor.lua @@ -0,0 +1,109 @@ +local bind = require("keymap.bind") +local map_cr = bind.map_cr +local map_cu = bind.map_cu +local map_cmd = bind.map_cmd +local map_callback = bind.map_callback +local et = bind.escape_termcode + +local plug_map = { + -- Plugin persisted.nvim + ["n|ss"] = map_cu("SessionSave"):with_noremap():with_silent():with_desc("session: Save"), + ["n|sl"] = map_cu("SessionLoad"):with_noremap():with_silent():with_desc("session: Load current"), + ["n|sd"] = map_cu("SessionDelete"):with_noremap():with_silent():with_desc("session: Delete"), + + -- Plugin: nvim-bufdel + ["n|"] = map_cr("BufDel"):with_noremap():with_silent():with_desc("buffer: Close current"), + + -- Plugin: comment.nvim + ["n|gcc"] = map_callback(function() + return vim.v.count == 0 and et("(comment_toggle_linewise_current)") + or et("(comment_toggle_linewise_count)") + end) + :with_silent() + :with_noremap() + :with_expr() + :with_desc("edit: Toggle comment for line"), + ["n|gbc"] = map_callback(function() + return vim.v.count == 0 and et("(comment_toggle_blockwise_current)") + or et("(comment_toggle_blockwise_count)") + end) + :with_silent() + :with_noremap() + :with_expr() + :with_desc("edit: Toggle comment for block"), + ["n|gc"] = map_cmd("(comment_toggle_linewise)") + :with_silent() + :with_noremap() + :with_desc("edit: Toggle comment for line with operator"), + ["n|gb"] = map_cmd("(comment_toggle_blockwise)") + :with_silent() + :with_noremap() + :with_desc("edit: Toggle comment for block with operator"), + ["x|gc"] = map_cmd("(comment_toggle_linewise_visual)") + :with_silent() + :with_noremap() + :with_desc("edit: Toggle comment for line with selection"), + ["x|gb"] = map_cmd("(comment_toggle_blockwise_visual)") + :with_silent() + :with_noremap() + :with_desc("edit: Toggle comment for block with selection"), + + -- Plugin: diffview.nvim + ["n|gd"] = map_cr("DiffviewOpen"):with_silent():with_noremap():with_desc("git: Show diff"), + ["n|gD"] = map_cr("DiffviewClose"):with_silent():with_noremap():with_desc("git: Close diff"), + + -- Plugin: hop.nvim + ["nv|w"] = map_cmd("HopWordMW"):with_noremap():with_desc("jump: Goto word"), + ["nv|j"] = map_cmd("HopLineMW"):with_noremap():with_desc("jump: Goto line"), + ["nv|k"] = map_cmd("HopLineMW"):with_noremap():with_desc("jump: Goto line"), + ["nv|c"] = map_cmd("HopChar1MW"):with_noremap():with_desc("jump: Goto one char"), + ["nv|C"] = map_cmd("HopChar2MW"):with_noremap():with_desc("jump: Goto two chars"), + + -- Plugin: smart-splits.nvim + ["n|"] = map_cu("SmartResizeLeft"):with_silent():with_noremap():with_desc("window: Resize -3 horizontally"), + ["n|"] = map_cu("SmartResizeDown"):with_silent():with_noremap():with_desc("window: Resize -3 vertically"), + ["n|"] = map_cu("SmartResizeUp"):with_silent():with_noremap():with_desc("window: Resize +3 vertically"), + ["n|"] = map_cu("SmartResizeRight"):with_silent():with_noremap():with_desc("window: Resize +3 horizontally"), + ["n|"] = map_cu("SmartCursorMoveLeft"):with_silent():with_noremap():with_desc("window: Focus left"), + ["n|"] = map_cu("SmartCursorMoveDown"):with_silent():with_noremap():with_desc("window: Focus down"), + ["n|"] = map_cu("SmartCursorMoveUp"):with_silent():with_noremap():with_desc("window: Focus up"), + ["n|"] = map_cu("SmartCursorMoveRight"):with_silent():with_noremap():with_desc("window: Focus right"), + ["n|Wh"] = map_cu("SmartSwapLeft"):with_silent():with_noremap():with_desc("window: Move window leftward"), + ["n|Wj"] = map_cu("SmartSwapDown"):with_silent():with_noremap():with_desc("window: Move window downward"), + ["n|Wk"] = map_cu("SmartSwapUp"):with_silent():with_noremap():with_desc("window: Move window upward"), + ["n|Wl"] = map_cu("SmartSwapRight"):with_silent():with_noremap():with_desc("window: Move window rightward"), + + -- Plugin: nvim-spectre + ["n|Ss"] = map_callback(function() + require("spectre").toggle() + end) + :with_silent() + :with_noremap() + :with_desc("editn: Toggle search & replace panel"), + ["n|Sp"] = map_callback(function() + require("spectre").open_visual({ select_word = true }) + end) + :with_silent() + :with_noremap() + :with_desc("editn: search&replace current word (project)"), + ["v|Sp"] = map_callback(function() + require("spectre").open_visual() + end) + :with_silent() + :with_noremap() + :with_desc("edit: search & replace current word (project)"), + ["n|Sf"] = map_callback(function() + require("spectre").open_file_search({ select_word = true }) + end) + :with_silent() + :with_noremap() + :with_desc("editn: search & replace current word (file)"), + + -- Plugin: nvim-treehopper + ["o|m"] = map_cu("lua require('tsht').nodes()"):with_silent():with_desc("jump: Operate across syntax tree"), + + -- Plugin suda.vim + ["n|"] = map_cu("SudaWrite"):with_silent():with_noremap():with_desc("editn: Save file using sudo"), +} + +bind.nvim_load_mapping(plug_map) diff --git a/nvim/lua/keymap/helpers.lua b/nvim/lua/keymap/helpers.lua new file mode 100644 index 0000000..60d99e4 --- /dev/null +++ b/nvim/lua/keymap/helpers.lua @@ -0,0 +1,67 @@ +_G._command_panel = function() + require("telescope.builtin").keymaps({ + lhs_filter = function(lhs) + return not string.find(lhs, "Þ") + end, + layout_config = { + width = 0.6, + height = 0.6, + prompt_position = "top", + }, + }) +end + +_G._telescope_collections = function(picker_type) + local actions = require("telescope.actions") + local action_state = require("telescope.actions.state") + local conf = require("telescope.config").values + local finder = require("telescope.finders") + local pickers = require("telescope.pickers") + picker_type = picker_type or {} + + local collections = vim.tbl_keys(require("search.tabs").collections) + pickers + .new(picker_type, { + prompt_title = "Telescope Collections", + finder = finder.new_table({ results = collections }), + sorter = conf.generic_sorter(picker_type), + attach_mappings = function(bufnr) + actions.select_default:replace(function() + actions.close(bufnr) + local selection = action_state.get_selected_entry() + require("search").open({ collection = selection[1] }) + end) + + return true + end, + }) + :find() +end + +_G._flash_esc_or_noh = function() + local flash_active, state = pcall(function() + return require("flash.plugins.char").state + end) + if flash_active and state then + state:hide() + else + pcall(vim.cmd.noh) + end +end + +local _lazygit = nil +_G._toggle_lazygit = function() + if vim.fn.executable("lazygit") == 1 then + if not _lazygit then + _lazygit = require("toggleterm.terminal").Terminal:new({ + cmd = "lazygit", + direction = "float", + close_on_exit = true, + hidden = true, + }) + end + _lazygit:toggle() + else + vim.notify("Command [lazygit] not found!", vim.log.levels.ERROR, { title = "toggleterm.nvim" }) + end +end diff --git a/nvim/lua/keymap/init.lua b/nvim/lua/keymap/init.lua new file mode 100644 index 0000000..dfef620 --- /dev/null +++ b/nvim/lua/keymap/init.lua @@ -0,0 +1,35 @@ +require("keymap.helpers") +local bind = require("keymap.bind") +local map_cr = bind.map_cr +-- local map_cu = bind.map_cu +-- local map_cmd = bind.map_cmd +-- local map_callback = bind.map_callback + +local plug_map = { + -- Package manager: lazy.nvim + ["n|ph"] = map_cr("Lazy"):with_silent():with_noremap():with_nowait():with_desc("package: Show"), + ["n|ps"] = map_cr("Lazy sync"):with_silent():with_noremap():with_nowait():with_desc("package: Sync"), + ["n|pu"] = map_cr("Lazy update"):with_silent():with_noremap():with_nowait():with_desc("package: Update"), + ["n|pi"] = map_cr("Lazy install"):with_silent():with_noremap():with_nowait():with_desc("package: Install"), + ["n|pl"] = map_cr("Lazy log"):with_silent():with_noremap():with_nowait():with_desc("package: Log"), + ["n|pc"] = map_cr("Lazy check"):with_silent():with_noremap():with_nowait():with_desc("package: Check"), + ["n|pd"] = map_cr("Lazy debug"):with_silent():with_noremap():with_nowait():with_desc("package: Debug"), + ["n|pp"] = map_cr("Lazy profile"):with_silent():with_noremap():with_nowait():with_desc("package: Profile"), + ["n|pr"] = map_cr("Lazy restore"):with_silent():with_noremap():with_nowait():with_desc("package: Restore"), + ["n|px"] = map_cr("Lazy clean"):with_silent():with_noremap():with_nowait():with_desc("package: Clean"), +} + +bind.nvim_load_mapping(plug_map) + +-- Plugin keymaps +require("keymap.completion") +require("keymap.editor") +require("keymap.lang") +require("keymap.tool") +require("keymap.ui") + +-- User keymaps +local ok, mappings = pcall(require, "user.keymap.init") +if ok then + require("modules.utils.keymap").replace(mappings) +end diff --git a/nvim/lua/keymap/lang.lua b/nvim/lua/keymap/lang.lua new file mode 100644 index 0000000..46ec703 --- /dev/null +++ b/nvim/lua/keymap/lang.lua @@ -0,0 +1,12 @@ +local bind = require("keymap.bind") +local map_cr = bind.map_cr +-- local map_cu = bind.map_cu +-- local map_cmd = bind.map_cmd +-- local map_callback = bind.map_callback + +local plug_map = { + -- Plugin MarkdownPreview + ["n|"] = map_cr("MarkdownPreviewToggle"):with_noremap():with_silent():with_desc("tool: Preview markdown"), +} + +bind.nvim_load_mapping(plug_map) diff --git a/nvim/lua/keymap/tool.lua b/nvim/lua/keymap/tool.lua new file mode 100644 index 0000000..617a2d0 --- /dev/null +++ b/nvim/lua/keymap/tool.lua @@ -0,0 +1,191 @@ +local bind = require("keymap.bind") +local map_cr = bind.map_cr +local map_cu = bind.map_cu +local map_cmd = bind.map_cmd +local map_callback = bind.map_callback +require("keymap.helpers") + +local plug_map = { + -- Plugin: vim-fugitive + ["n|gps"] = map_cr("G push"):with_noremap():with_silent():with_desc("git: Push"), + ["n|gpl"] = map_cr("G pull"):with_noremap():with_silent():with_desc("git: Pull"), + ["n|gG"] = map_cu("Git"):with_noremap():with_silent():with_desc("git: Open git-fugitive"), + + -- Plugin: nvim-tree + ["n|"] = map_cr("NvimTreeToggle"):with_noremap():with_silent():with_desc("filetree: Toggle"), + ["n|nf"] = map_cr("NvimTreeFindFile"):with_noremap():with_silent():with_desc("filetree: Find file"), + ["n|nr"] = map_cr("NvimTreeRefresh"):with_noremap():with_silent():with_desc("filetree: Refresh"), + + -- Plugin: sniprun + ["v|r"] = map_cr("SnipRun"):with_noremap():with_silent():with_desc("tool: Run code by range"), + ["n|r"] = map_cu([[%SnipRun]]):with_noremap():with_silent():with_desc("tool: Run code by file"), + + -- Plugin: toggleterm + ["t|"] = map_cmd([[]]):with_noremap():with_silent(), -- switch to normal mode in terminal. + ["n|"] = map_cr("ToggleTerm direction=horizontal") + :with_noremap() + :with_silent() + :with_desc("terminal: Toggle horizontal"), + ["i|"] = map_cmd("ToggleTerm direction=horizontal") + :with_noremap() + :with_silent() + :with_desc("terminal: Toggle horizontal"), + ["t|"] = map_cmd("ToggleTerm"):with_noremap():with_silent():with_desc("terminal: Toggle horizontal"), + ["n|"] = map_cr("ToggleTerm direction=vertical") + :with_noremap() + :with_silent() + :with_desc("terminal: Toggle vertical"), + ["i|"] = map_cmd("ToggleTerm direction=vertical") + :with_noremap() + :with_silent() + :with_desc("terminal: Toggle vertical"), + ["t|"] = map_cmd("ToggleTerm"):with_noremap():with_silent():with_desc("terminal: Toggle vertical"), + ["n|"] = map_cr("ToggleTerm direction=vertical") + :with_noremap() + :with_silent() + :with_desc("terminal: Toggle vertical"), + ["i|"] = map_cmd("ToggleTerm direction=vertical") + :with_noremap() + :with_silent() + :with_desc("terminal: Toggle vertical"), + ["t|"] = map_cmd("ToggleTerm"):with_noremap():with_silent():with_desc("terminal: Toggle vertical"), + ["n|"] = map_cr("ToggleTerm direction=float"):with_noremap():with_silent():with_desc("terminal: Toggle float"), + ["i|"] = map_cmd("ToggleTerm direction=float") + :with_noremap() + :with_silent() + :with_desc("terminal: Toggle float"), + ["t|"] = map_cmd("ToggleTerm"):with_noremap():with_silent():with_desc("terminal: Toggle float"), + ["n|gg"] = map_callback(function() + _toggle_lazygit() + end) + :with_noremap() + :with_silent() + :with_desc("git: Toggle lazygit"), + + -- Plugin: trouble + ["n|gt"] = map_cr("Trouble diagnostics toggle"):with_noremap():with_silent():with_desc("lsp: Toggle trouble list"), + ["n|lw"] = map_cr("Trouble diagnostics toggle") + :with_noremap() + :with_silent() + :with_desc("lsp: Show workspace diagnostics"), + ["n|lp"] = map_cr("Trouble project_diagnostics toggle") + :with_noremap() + :with_silent() + :with_desc("lsp: Show project diagnostics"), + ["n|ld"] = map_cr("Trouble diagnostics toggle filter.buf=0") + :with_noremap() + :with_silent() + :with_desc("lsp: Show document diagnostics"), + + -- Plugin: telescope + ["n|"] = map_callback(function() + _command_panel() + end) + :with_noremap() + :with_silent() + :with_desc("tool: Toggle command panel"), + ["n|fc"] = map_callback(function() + _telescope_collections(require("telescope.themes").get_dropdown()) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Open Telescope collections"), + ["n|ff"] = map_callback(function() + require("search").open({ collection = "file" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Find files"), + ["n|fp"] = map_callback(function() + require("search").open({ collection = "pattern" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Find patterns"), + ["v|fs"] = map_cu("Telescope grep_string") + :with_noremap() + :with_silent() + :with_desc("tool: Find word under cursor"), + ["n|fg"] = map_callback(function() + require("search").open({ collection = "git" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Locate Git objects"), + ["n|fd"] = map_callback(function() + require("search").open({ collection = "dossier" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Retrieve dossiers"), + ["n|fm"] = map_callback(function() + require("search").open({ collection = "misc" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Miscellaneous"), + + -- Plugin: dap + ["n|"] = map_callback(function() + require("dap").continue() + end) + :with_noremap() + :with_silent() + :with_desc("debug: Run/Continue"), + ["n|"] = map_callback(function() + require("dap").terminate() + end) + :with_noremap() + :with_silent() + :with_desc("debug: Stop"), + ["n|"] = map_callback(function() + require("dap").toggle_breakpoint() + end) + :with_noremap() + :with_silent() + :with_desc("debug: Toggle breakpoint"), + ["n|"] = map_callback(function() + require("dap").step_into() + end) + :with_noremap() + :with_silent() + :with_desc("debug: Step into"), + ["n|"] = map_callback(function() + require("dap").step_out() + end) + :with_noremap() + :with_silent() + :with_desc("debug: Step out"), + ["n|"] = map_callback(function() + require("dap").step_over() + end) + :with_noremap() + :with_silent() + :with_desc("debug: Step over"), + ["n|db"] = map_callback(function() + require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: ")) + end) + :with_noremap() + :with_silent() + :with_desc("debug: Set breakpoint with condition"), + ["n|dc"] = map_callback(function() + require("dap").run_to_cursor() + end) + :with_noremap() + :with_silent() + :with_desc("debug: Run to cursor"), + ["n|dl"] = map_callback(function() + require("dap").run_last() + end) + :with_noremap() + :with_silent() + :with_desc("debug: Run last"), + ["n|do"] = map_callback(function() + require("dap").repl.open() + end) + :with_noremap() + :with_silent() + :with_desc("debug: Open REPL"), +} + +bind.nvim_load_mapping(plug_map) diff --git a/nvim/lua/keymap/ui.lua b/nvim/lua/keymap/ui.lua new file mode 100644 index 0000000..77df22d --- /dev/null +++ b/nvim/lua/keymap/ui.lua @@ -0,0 +1,105 @@ +local bind = require("keymap.bind") +local map_cr = bind.map_cr +-- local map_cu = bind.map_cu +-- local map_cmd = bind.map_cmd +-- local map_callback = bind.map_callback + +local plug_map = { + -- Plugin: bufferline.nvim + ["n|"] = map_cr("BufferLineCycleNext"):with_noremap():with_silent():with_desc("buffer: Switch to next"), + ["n|"] = map_cr("BufferLineCyclePrev"):with_noremap():with_silent():with_desc("buffer: Switch to prev"), + ["n|"] = map_cr("BufferLineMoveNext"):with_noremap():with_silent():with_desc("buffer: Move current to next"), + ["n|"] = map_cr("BufferLineMovePrev"):with_noremap():with_silent():with_desc("buffer: Move current to prev"), + ["n|be"] = map_cr("BufferLineSortByExtension"):with_noremap():with_desc("buffer: Sort by extension"), + ["n|bd"] = map_cr("BufferLineSortByDirectory"):with_noremap():with_desc("buffer: Sort by directory"), + ["n|"] = map_cr("BufferLineGoToBuffer 1"):with_noremap():with_silent():with_desc("buffer: Goto buffer 1"), + ["n|"] = map_cr("BufferLineGoToBuffer 2"):with_noremap():with_silent():with_desc("buffer: Goto buffer 2"), + ["n|"] = map_cr("BufferLineGoToBuffer 3"):with_noremap():with_silent():with_desc("buffer: Goto buffer 3"), + ["n|"] = map_cr("BufferLineGoToBuffer 4"):with_noremap():with_silent():with_desc("buffer: Goto buffer 4"), + ["n|"] = map_cr("BufferLineGoToBuffer 5"):with_noremap():with_silent():with_desc("buffer: Goto buffer 5"), + ["n|"] = map_cr("BufferLineGoToBuffer 6"):with_noremap():with_silent():with_desc("buffer: Goto buffer 6"), + ["n|"] = map_cr("BufferLineGoToBuffer 7"):with_noremap():with_silent():with_desc("buffer: Goto buffer 7"), + ["n|"] = map_cr("BufferLineGoToBuffer 8"):with_noremap():with_silent():with_desc("buffer: Goto buffer 8"), + ["n|"] = map_cr("BufferLineGoToBuffer 9"):with_noremap():with_silent():with_desc("buffer: Goto buffer 9"), +} + +bind.nvim_load_mapping(plug_map) + +local mapping = {} + +function mapping.gitsigns(buf) + local actions = require("gitsigns.actions") + local map = { + ["n|]g"] = bind.map_callback(function() + if vim.wo.diff then + return "]g" + end + vim.schedule(function() + actions.next_hunk() + end) + return "" + end) + :with_buffer(buf) + :with_expr() + :with_desc("git: Goto next hunk"), + ["n|[g"] = bind.map_callback(function() + if vim.wo.diff then + return "[g" + end + vim.schedule(function() + actions.prev_hunk() + end) + return "" + end) + :with_buffer(buf) + :with_expr() + :with_desc("git: Goto prev hunk"), + ["n|gs"] = bind.map_callback(function() + actions.stage_hunk() + end) + :with_buffer(buf) + :with_desc("git: Stage hunk"), + ["v|gs"] = bind.map_callback(function() + actions.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end) + :with_buffer(buf) + :with_desc("git: Stage hunk"), + ["n|gu"] = bind.map_callback(function() + actions.undo_stage_hunk() + end) + :with_buffer(buf) + :with_desc("git: Undo stage hunk"), + ["n|gr"] = bind.map_callback(function() + actions.reset_hunk() + end) + :with_buffer(buf) + :with_desc("git: Reset hunk"), + ["v|gr"] = bind.map_callback(function() + actions.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end) + :with_buffer(buf) + :with_desc("git: Reset hunk"), + ["n|gR"] = bind.map_callback(function() + actions.reset_buffer() + end) + :with_buffer(buf) + :with_desc("git: Reset buffer"), + ["n|gp"] = bind.map_callback(function() + actions.preview_hunk() + end) + :with_buffer(buf) + :with_desc("git: Preview hunk"), + ["n|gb"] = bind.map_callback(function() + actions.blame_line({ full = true }) + end) + :with_buffer(buf) + :with_desc("git: Blame line"), + -- Text objects + ["ox|ih"] = bind.map_callback(function() + actions.text_object() + end):with_buffer(buf), + } + bind.nvim_load_mapping(map) +end + +return mapping diff --git a/nvim/lua/modules/configs/completion/aerial.lua b/nvim/lua/modules/configs/completion/aerial.lua new file mode 100644 index 0000000..4c89afd --- /dev/null +++ b/nvim/lua/modules/configs/completion/aerial.lua @@ -0,0 +1,80 @@ +return function() + require("modules.utils").load_plugin("aerial", { + lazy_load = false, + close_on_select = true, + highlight_on_jump = false, + disable_max_lines = 8500, + disable_max_size = 1000000, + ignore = { filetypes = { "NvimTree", "terminal", "nofile" } }, + -- Use symbol tree for folding. Set to true or false to enable/disable + -- Set to "auto" to manage folds if your previous foldmethod was 'manual' + -- This can be a filetype map (see :help aerial-filetype-map) + manage_folds = "auto", + layout = { + -- Determines the default direction to open the aerial window. The 'prefer' + -- options will open the window in the other direction *if* there is a + -- different buffer in the way of the preferred direction + -- Enum: prefer_right, prefer_left, right, left, float + default_direction = "prefer_right", + }, + -- Keymaps in aerial window. Can be any value that `vim.keymap.set` accepts OR a table of keymap + -- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true }) + -- Additionally, if it is a string that matches "actions.", + -- it will use the mapping at require("aerial.actions"). + -- Set to `false` to remove a keymap + keymaps = { + ["?"] = "actions.show_help", + ["g?"] = "actions.show_help", + [""] = "actions.jump", + ["<2-LeftMouse>"] = "actions.jump", + [""] = "actions.jump_vsplit", + [""] = "actions.jump_split", + [""] = "actions.down_and_scroll", + [""] = "actions.up_and_scroll", + ["{"] = "actions.prev", + ["}"] = "actions.next", + ["[["] = "actions.prev_up", + ["]]"] = "actions.next_up", + ["q"] = "actions.close", + ["o"] = "actions.tree_toggle", + ["O"] = "actions.tree_toggle_recursive", + ["zr"] = "actions.tree_increase_fold_level", + ["zR"] = "actions.tree_open_all", + ["zm"] = "actions.tree_decrease_fold_level", + ["zM"] = "actions.tree_close_all", + ["zx"] = "actions.tree_sync_folds", + ["zX"] = "actions.tree_sync_folds", + }, + -- A list of all symbols to display. Set to false to display all symbols. + -- This can be a filetype map (see :help aerial-filetype-map) + -- To see all available values, see :help SymbolKind + filter_kind = { + "Array", + "Boolean", + "Class", + "Constant", + "Constructor", + "Enum", + "EnumMember", + "Event", + "Field", + "File", + "Function", + "Interface", + "Key", + "Method", + "Module", + "Namespace", + "Null", + -- "Number", + "Object", + "Operator", + "Package", + -- "Property", + -- "String", + "Struct", + -- "TypeParameter", + -- "Variable", + }, + }) +end diff --git a/nvim/lua/modules/configs/completion/cmp.lua b/nvim/lua/modules/configs/completion/cmp.lua new file mode 100644 index 0000000..f20e7b6 --- /dev/null +++ b/nvim/lua/modules/configs/completion/cmp.lua @@ -0,0 +1,199 @@ +return function() + local icons = { + kind = require("modules.utils.icons").get("kind"), + type = require("modules.utils.icons").get("type"), + cmp = require("modules.utils.icons").get("cmp"), + } + + local border = function(hl) + return { + { "┌", hl }, + { "─", hl }, + { "┐", hl }, + { "│", hl }, + { "┘", hl }, + { "─", hl }, + { "└", hl }, + { "│", hl }, + } + end + + local compare = require("cmp.config.compare") + compare.lsp_scores = function(entry1, entry2) + local diff + if entry1.completion_item.score and entry2.completion_item.score then + diff = (entry2.completion_item.score * entry2.score) - (entry1.completion_item.score * entry1.score) + else + diff = entry2.score - entry1.score + end + return (diff < 0) + end + + local use_copilot = require("core.settings").use_copilot + local comparators = use_copilot == true + and { + require("copilot_cmp.comparators").prioritize, + require("copilot_cmp.comparators").score, + -- require("cmp_tabnine.compare"), + compare.offset, -- Items closer to cursor will have lower priority + compare.exact, + -- compare.scopes, + compare.lsp_scores, + compare.sort_text, + compare.score, + compare.recently_used, + -- compare.locality, -- Items closer to cursor will have higher priority, conflicts with `offset` + require("cmp-under-comparator").under, + compare.kind, + compare.length, + compare.order, + } + or { + -- require("cmp_tabnine.compare"), + compare.offset, -- Items closer to cursor will have lower priority + compare.exact, + -- compare.scopes, + compare.lsp_scores, + compare.sort_text, + compare.score, + compare.recently_used, + -- compare.locality, -- Items closer to cursor will have higher priority, conflicts with `offset` + require("cmp-under-comparator").under, + compare.kind, + compare.length, + compare.order, + } + + local cmp = require("cmp") + require("modules.utils").load_plugin("cmp", { + preselect = cmp.PreselectMode.None, + window = { + completion = { + border = border("PmenuBorder"), + winhighlight = "Normal:Pmenu,CursorLine:PmenuSel,Search:PmenuSel", + scrollbar = false, + }, + documentation = { + border = border("CmpDocBorder"), + winhighlight = "Normal:CmpDoc", + }, + }, + sorting = { + priority_weight = 2, + comparators = comparators, + }, + formatting = { + fields = { "abbr", "kind", "menu" }, + format = function(entry, vim_item) + local lspkind_icons = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp) + -- load lspkind icons + vim_item.kind = + string.format(" %s %s", lspkind_icons[vim_item.kind] or icons.cmp.undefined, vim_item.kind or "") + + vim_item.menu = setmetatable({ + cmp_tabnine = "[TN]", + copilot = "[CPLT]", + buffer = "[BUF]", + orgmode = "[ORG]", + nvim_lsp = "[LSP]", + nvim_lua = "[LUA]", + path = "[PATH]", + tmux = "[TMUX]", + treesitter = "[TS]", + latex_symbols = "[LTEX]", + luasnip = "[SNIP]", + spell = "[SPELL]", + }, { + __index = function() + return "[BTN]" -- builtin/unknown source names + end, + })[entry.source.name] + + local label = vim_item.abbr + local truncated_label = vim.fn.strcharpart(label, 0, 80) + if truncated_label ~= label then + vim_item.abbr = truncated_label .. "..." + end + + return vim_item + end, + }, + matching = { + disallow_partial_fuzzy_matching = false, + }, + performance = { + async_budget = 1, + max_view_entries = 120, + }, + -- You can set mappings if you want + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) + elseif require("luasnip").expand_or_locally_jumpable() then + require("luasnip").expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select }) + elseif require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }), + }), + }), + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + -- You should specify your *installed* sources. + sources = { + { name = "nvim_lsp", max_item_count = 350 }, + { name = "nvim_lua" }, + { name = "luasnip" }, + { name = "path" }, + { name = "treesitter" }, + { name = "spell" }, + { name = "tmux" }, + { name = "orgmode" }, + { + name = "buffer", + option = { + get_bufnrs = function() + return vim.api.nvim_buf_line_count(0) < 7500 and vim.api.nvim_list_bufs() or {} + end, + }, + }, + { name = "latex_symbols" }, + { name = "copilot" }, + -- { name = "codeium" }, + -- { name = "cmp_tabnine" }, + }, + experimental = { + ghost_text = { + hl_group = "Whitespace", + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/completion/codeium.lua b/nvim/lua/modules/configs/completion/codeium.lua new file mode 100644 index 0000000..229eab6 --- /dev/null +++ b/nvim/lua/modules/configs/completion/codeium.lua @@ -0,0 +1,3 @@ +return function() + require("modules.utils").load_plugin("codeium", {}) +end diff --git a/nvim/lua/modules/configs/completion/copilot-cmp.lua b/nvim/lua/modules/configs/completion/copilot-cmp.lua new file mode 100644 index 0000000..26d1dad --- /dev/null +++ b/nvim/lua/modules/configs/completion/copilot-cmp.lua @@ -0,0 +1,3 @@ +return function() + require("modules.utils").load_plugin("copilot_cmp", {}) +end diff --git a/nvim/lua/modules/configs/completion/copilot.lua b/nvim/lua/modules/configs/completion/copilot.lua new file mode 100644 index 0000000..a6ea78c --- /dev/null +++ b/nvim/lua/modules/configs/completion/copilot.lua @@ -0,0 +1,28 @@ +return function() + vim.defer_fn(function() + require("modules.utils").load_plugin("copilot", { + cmp = { + enabled = true, + method = "getCompletionsCycling", + }, + panel = { + -- if true, it can interfere with completions in copilot-cmp + enabled = false, + }, + suggestion = { + -- if true, it can interfere with completions in copilot-cmp + enabled = false, + }, + filetypes = { + ["bigfile"] = false, + ["dap-repl"] = false, + ["fugitive"] = false, + ["fugitiveblame"] = false, + ["git"] = false, + ["gitcommit"] = false, + ["log"] = false, + ["toggleterm"] = false, + }, + }) + end, 100) +end diff --git a/nvim/lua/modules/configs/completion/formatters/clang_format.lua b/nvim/lua/modules/configs/completion/formatters/clang_format.lua new file mode 100644 index 0000000..a0f81bf --- /dev/null +++ b/nvim/lua/modules/configs/completion/formatters/clang_format.lua @@ -0,0 +1 @@ +return { "-style={BasedOnStyle: LLVM, IndentWidth: 4}" } diff --git a/nvim/lua/modules/configs/completion/formatting.lua b/nvim/lua/modules/configs/completion/formatting.lua new file mode 100644 index 0000000..0368efe --- /dev/null +++ b/nvim/lua/modules/configs/completion/formatting.lua @@ -0,0 +1,198 @@ +local M = {} + +local settings = require("core.settings") +local disabled_workspaces = settings.format_disabled_dirs +local format_on_save = settings.format_on_save +local format_notify = settings.format_notify +local format_modifications_only = settings.format_modifications_only +local server_formatting_block_list = settings.server_formatting_block_list +local format_timeout = settings.format_timeout + +vim.api.nvim_create_user_command("FormatToggle", function() + M.toggle_format_on_save() +end, {}) + +local block_list = settings.formatter_block_list +vim.api.nvim_create_user_command("FormatterToggleFt", function(opts) + if block_list[opts.args] == nil then + vim.notify( + string.format("[LSP] Formatter for [%s] has been recorded in list and disabled.", opts.args), + vim.log.levels.WARN, + { title = "LSP Formatter Warning" } + ) + block_list[opts.args] = true + else + block_list[opts.args] = not block_list[opts.args] + vim.notify( + string.format( + "[LSP] Formatter for [%s] has been %s.", + opts.args, + not block_list[opts.args] and "enabled" or "disabled" + ), + not block_list[opts.args] and vim.log.levels.INFO or vim.log.levels.WARN, + { title = string.format("LSP Formatter %s", not block_list[opts.args] and "Info" or "Warning") } + ) + end +end, { nargs = 1, complete = "filetype" }) + +function M.enable_format_on_save(is_configured) + local opts = { pattern = "*", timeout = format_timeout } + vim.api.nvim_create_augroup("format_on_save", { clear = true }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = "format_on_save", + pattern = opts.pattern, + callback = function() + require("completion.formatting").format({ + timeout_ms = opts.timeout, + filter = M.format_filter, + }) + end, + }) + if not is_configured then + vim.notify( + "Successfully enabled format-on-save", + vim.log.levels.INFO, + { title = "Settings modification success" } + ) + end +end + +function M.disable_format_on_save(is_configured) + pcall(vim.api.nvim_del_augroup_by_name, "format_on_save") + if not is_configured then + vim.notify( + "Successfully disabled format-on-save", + vim.log.levels.INFO, + { title = "Settings modification success" } + ) + end +end + +function M.configure_format_on_save() + if format_on_save then + M.enable_format_on_save(true) + else + M.disable_format_on_save(true) + end +end + +function M.toggle_format_on_save() + local status = pcall(vim.api.nvim_get_autocmds, { + group = "format_on_save", + event = "BufWritePre", + }) + if not status then + M.enable_format_on_save(false) + else + M.disable_format_on_save(false) + end +end + +function M.format_filter(clients) + return vim.tbl_filter(function(client) + local status_ok, formatting_supported = pcall(function() + return client.supports_method("textDocument/formatting") + end) + if status_ok and formatting_supported and client.name == "null-ls" then + return "null-ls" + elseif not server_formatting_block_list[client.name] and status_ok and formatting_supported then + return client.name + end + end, clients) +end + +function M.format(opts) + local filedir = vim.fn.expand("%:p:h") + for i = 1, #disabled_workspaces do + if vim.regex(vim.fs.normalize(disabled_workspaces[i])):match_str(filedir) ~= nil then + vim.notify( + string.format( + "[LSP] Formatting for all files under [%s] has been disabled.", + vim.fs.normalize(disabled_workspaces[i]) + ), + vim.log.levels.WARN, + { title = "LSP Formatter Warning" } + ) + return + end + end + + local bufnr = opts.bufnr or vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients({ buffer = bufnr }) + + if opts.filter then + clients = opts.filter(clients) + elseif opts.id then + clients = vim.tbl_filter(function(client) + return client.id == opts.id + end, clients) + elseif opts.name then + clients = vim.tbl_filter(function(client) + return client.name == opts.name + end, clients) + end + + clients = vim.tbl_filter(function(client) + return client.supports_method("textDocument/formatting") + end, clients) + + if #clients == 0 then + vim.notify( + "[LSP] Format request failed, no matching language servers.", + vim.log.levels.WARN, + { title = "Formatting Failed" } + ) + end + + local timeout_ms = opts.timeout_ms + for _, client in pairs(clients) do + if block_list[vim.bo.filetype] == true then + vim.notify( + string.format( + "[LSP][%s] Formatting for [%s] has been disabled. This file is not being processed.", + client.name, + vim.bo.filetype + ), + vim.log.levels.WARN, + { title = "LSP Formatter Warning" } + ) + return + end + + if + format_modifications_only + and require("lsp-format-modifications").format_modifications(client, bufnr).success + then + if format_notify then + vim.notify( + string.format("[LSP] Format changed lines successfully with %s!", client.name), + vim.log.levels.INFO, + { title = "LSP Range Format Success" } + ) + end + return + end + + -- Fall back to format the whole buffer (even if partial formatting failed) + local params = vim.lsp.util.make_formatting_params(opts.formatting_options) + local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, bufnr) + if result and result.result then + vim.lsp.util.apply_text_edits(result.result, bufnr, client.offset_encoding) + if format_notify then + vim.notify( + string.format("[LSP] Format successfully with %s!", client.name), + vim.log.levels.INFO, + { title = "LSP Format Success" } + ) + end + elseif err then + vim.notify( + string.format("[LSP][%s] %s", client.name, err), + vim.log.levels.ERROR, + { title = "LSP Format Error" } + ) + end + end +end + +return M diff --git a/nvim/lua/modules/configs/completion/glance.lua b/nvim/lua/modules/configs/completion/glance.lua new file mode 100644 index 0000000..f2950de --- /dev/null +++ b/nvim/lua/modules/configs/completion/glance.lua @@ -0,0 +1,83 @@ +return function() + local icons = { ui = require("modules.utils.icons").get("ui", true) } + local actions = require("glance").actions + + require("modules.utils").load_plugin("glance", { + height = 20, + zindex = 50, + preview_win_opts = { + cursorline = true, + number = true, + wrap = true, + }, + border = { + enable = require("core.settings").transparent_background, + top_char = "―", + bottom_char = "―", + }, + list = { + position = "right", + width = 0.33, -- 33% width relative to the active window, min 0.1, max 0.5 + }, + folds = { + folded = true, -- Automatically fold list on startup + fold_closed = icons.ui.ArrowClosed, + fold_open = icons.ui.ArrowOpen, + }, + indent_lines = { enable = true }, + winbar = { enable = true }, + mappings = { + list = { + ["k"] = actions.previous, + ["j"] = actions.next, + [""] = actions.previous, + [""] = actions.next, + [""] = actions.previous_location, -- Bring the cursor to the previous location skipping groups in the list + [""] = actions.next_location, -- Bring the cursor to the next location skipping groups in the list + [""] = actions.preview_scroll_win(8), + [""] = actions.preview_scroll_win(-8), + [""] = actions.jump, + ["v"] = actions.jump_vsplit, + ["s"] = actions.jump_split, + ["t"] = actions.jump_tab, + ["c"] = actions.close_fold, + ["o"] = actions.open_fold, + ["[]"] = actions.enter_win("preview"), -- Focus preview window + ["q"] = actions.close, + ["Q"] = actions.close, + [""] = actions.close, + ["gq"] = actions.quickfix, + }, + preview = { + ["Q"] = actions.close, + ["q"] = actions.close, + ["o"] = actions.jump, + ["v"] = actions.jump_vsplit, + ["s"] = actions.jump_split, + ["t"] = actions.jump_tab, + [""] = actions.previous_location, + [""] = actions.next_location, + ["[]"] = actions.enter_win("list"), -- Focus list window + }, + }, + hooks = { + before_open = function(results, open, _, method) + if #results == 0 then + vim.notify( + "This method is not supported by any of the servers registered for the current buffer", + vim.log.levels.WARN, + { title = "Glance" } + ) + elseif #results == 1 and method == "references" then + vim.notify( + "The identifier under cursor is the only one found", + vim.log.levels.INFO, + { title = "Glance" } + ) + else + open(results) + end + end, + }, + }) +end diff --git a/nvim/lua/modules/configs/completion/lsp-signature.lua b/nvim/lua/modules/configs/completion/lsp-signature.lua new file mode 100644 index 0000000..aacc20c --- /dev/null +++ b/nvim/lua/modules/configs/completion/lsp-signature.lua @@ -0,0 +1,15 @@ +return function() + require("modules.utils").load_plugin("lsp_signature", { + bind = true, + -- TODO: Remove the following line when nvim-cmp#1613 gets resolved + check_completion_visible = false, + floating_window = true, + floating_window_above_cur_line = true, + hi_parameter = "Search", + hint_enable = true, + transparency = nil, -- disabled by default, allow floating win transparent value 1~100 + wrap = true, + zindex = 45, -- avoid overlap with nvim.cmp + handler_opts = { border = "single" }, + }) +end diff --git a/nvim/lua/modules/configs/completion/lsp.lua b/nvim/lua/modules/configs/completion/lsp.lua new file mode 100644 index 0000000..ba3c5a8 --- /dev/null +++ b/nvim/lua/modules/configs/completion/lsp.lua @@ -0,0 +1,23 @@ +return function() + local nvim_lsp = require("lspconfig") + require("completion.neoconf").setup() + require("completion.mason").setup() + require("completion.mason-lspconfig").setup() + + local opts = { + capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), + } + -- Setup lsps that are not supported by `mason.nvim` but supported by `nvim-lspconfig` here. + if vim.fn.executable("dart") == 1 then + local ok, _opts = pcall(require, "user.configs.lsp-servers.dartls") + if not ok then + _opts = require("completion.servers.dartls") + end + local final_opts = vim.tbl_deep_extend("keep", _opts, opts) + nvim_lsp.dartls.setup(final_opts) + end + + pcall(require, "user.configs.lsp") + + pcall(vim.cmd.LspStart) -- Start LSPs +end diff --git a/nvim/lua/modules/configs/completion/lspsaga.lua b/nvim/lua/modules/configs/completion/lspsaga.lua new file mode 100644 index 0000000..162cdda --- /dev/null +++ b/nvim/lua/modules/configs/completion/lspsaga.lua @@ -0,0 +1,183 @@ +return function() + require("modules.utils").gen_lspkind_hl() + + local icons = { + cmp = require("modules.utils.icons").get("cmp", true), + diagnostics = require("modules.utils.icons").get("diagnostics", true), + kind = require("modules.utils.icons").get("kind", true), + type = require("modules.utils.icons").get("type", true), + ui = require("modules.utils.icons").get("ui", true), + } + + local function set_sidebar_icons() + -- Set icons for sidebar + vim.diagnostic.config({ + signs = { + text = { + [vim.diagnostic.severity.ERROR] = icons.diagnostics.Error_alt, + [vim.diagnostic.severity.WARN] = icons.diagnostics.Warning_alt, + [vim.diagnostic.severity.INFO] = icons.diagnostics.Information_alt, + [vim.diagnostic.severity.HINT] = icons.diagnostics.Hint_alt, + }, + }, + }) + end + + set_sidebar_icons() + + require("modules.utils").load_plugin("lspsaga", { + -- Breadcrumbs: https://nvimdev.github.io/lspsaga/breadcrumbs/ + symbol_in_winbar = { + enable = false, + separator = " " .. icons.ui.Separator, + hide_keyword = false, + show_file = false, + folder_level = 1, + color_mode = true, + delay = 100, + }, + -- Callhierarchy: https://nvimdev.github.io/lspsaga/callhierarchy/ + callhierarchy = { + layout = "float", + keys = { + edit = "e", + vsplit = "v", + split = "s", + tabe = "t", + quit = "q", + shuttle = "[]", + toggle_or_req = "u", + close = "", + }, + }, + -- Code Action: https://nvimdev.github.io/lspsaga/codeaction/ + code_action = { + num_shortcut = true, + only_in_cursor = false, + show_server_name = true, + extend_gitsigns = false, + keys = { + quit = "q", + exec = "", + }, + }, + -- Diagnostics: https://nvimdev.github.io/lspsaga/diagnostic/ + diagnostic = { + show_code_action = true, + jump_num_shortcut = true, + max_width = 0.5, + max_height = 0.6, + text_hl_follow = true, + border_follow = true, + extend_relatedInformation = true, + show_layout = "float", + show_normal_height = 10, + max_show_width = 0.9, + max_show_height = 0.6, + diagnostic_only_current = false, + keys = { + exec_action = "r", + quit = "q", + toggle_or_jump = "", + quit_in_show = { "q", "" }, + }, + }, + -- Hover: https://nvimdev.github.io/lspsaga/hover/ + hover = { + max_width = 0.45, + max_height = 0.7, + open_link = "gl", + open_cmd = "silent !" .. require("core.settings").external_browser, + }, + -- Impl: https://nvimdev.github.io/lspsaga/implement/ + implement = { + enable = true, + sign = true, + virtual_text = false, + priority = 100, + }, + -- LightBulb: https://nvimdev.github.io/lspsaga/lightbulb/ + lightbulb = { + enable = false, + sign = true, + virtual_text = false, + debounce = 10, + sign_priority = 20, + }, + -- Rename: https://nvimdev.github.io/lspsaga/rename/ + rename = { + in_select = false, + auto_save = false, + project_max_width = 0.5, + project_max_height = 0.5, + keys = { + quit = "", + exec = "", + select = "x", + }, + }, + -- Beacon: https://nvimdev.github.io/lspsaga/misc/#beacon + beacon = { + enable = true, + frequency = 12, + }, + -- Generic UI Options: https://nvimdev.github.io/lspsaga/misc/#generic-ui-options + ui = { + border = "single", -- Can be single, double, rounded, solid, shadow. + devicon = true, + title = true, + expand = icons.ui.ArrowClosed, + collapse = icons.ui.ArrowOpen, + code_action = icons.ui.CodeAction, + actionfix = icons.ui.Spell, + lines = { "┗", "┣", "┃", "━", "┏" }, + imp_sign = icons.kind.Implementation, + kind = { + -- Kind + Class = { icons.kind.Class, "LspKindClass" }, + Constant = { icons.kind.Constant, "LspKindConstant" }, + Constructor = { icons.kind.Constructor, "LspKindConstructor" }, + Enum = { icons.kind.Enum, "LspKindEnum" }, + EnumMember = { icons.kind.EnumMember, "LspKindEnumMember" }, + Event = { icons.kind.Event, "LspKindEvent" }, + Field = { icons.kind.Field, "LspKindField" }, + File = { icons.kind.File, "LspKindFile" }, + Function = { icons.kind.Function, "LspKindFunction" }, + Interface = { icons.kind.Interface, "LspKindInterface" }, + Key = { icons.kind.Keyword, "LspKindKey" }, + Method = { icons.kind.Method, "LspKindMethod" }, + Module = { icons.kind.Module, "LspKindModule" }, + Namespace = { icons.kind.Namespace, "LspKindNamespace" }, + Operator = { icons.kind.Operator, "LspKindOperator" }, + Package = { icons.kind.Package, "LspKindPackage" }, + Property = { icons.kind.Property, "LspKindProperty" }, + Struct = { icons.kind.Struct, "LspKindStruct" }, + TypeParameter = { icons.kind.TypeParameter, "LspKindTypeParameter" }, + Variable = { icons.kind.Variable, "LspKindVariable" }, + -- Type + Array = { icons.type.Array, "LspKindArray" }, + Boolean = { icons.type.Boolean, "LspKindBoolean" }, + Null = { icons.type.Null, "LspKindNull" }, + Number = { icons.type.Number, "LspKindNumber" }, + Object = { icons.type.Object, "LspKindObject" }, + String = { icons.type.String, "LspKindString" }, + -- ccls-specific icons. + TypeAlias = { icons.kind.TypeAlias, "LspKindTypeAlias" }, + Parameter = { icons.kind.Parameter, "LspKindParameter" }, + StaticMethod = { icons.kind.StaticMethod, "LspKindStaticMethod" }, + -- Microsoft-specific icons. + Text = { icons.kind.Text, "LspKindText" }, + Snippet = { icons.kind.Snippet, "LspKindSnippet" }, + Folder = { icons.kind.Folder, "LspKindFolder" }, + Unit = { icons.kind.Unit, "LspKindUnit" }, + Value = { icons.kind.Value, "LspKindValue" }, + }, + }, + -- Scrolling Keymaps: https://nvimdev.github.io/lspsaga/misc/#scrolling-keymaps + scroll_preview = { + scroll_down = "", + scroll_up = "", + }, + request_timeout = 3000, + }) +end diff --git a/nvim/lua/modules/configs/completion/luasnip.lua b/nvim/lua/modules/configs/completion/luasnip.lua new file mode 100644 index 0000000..d4ecd2b --- /dev/null +++ b/nvim/lua/modules/configs/completion/luasnip.lua @@ -0,0 +1,15 @@ +return function() + local snippet_path = vim.fn.stdpath("config") .. "/snips/" + if not vim.tbl_contains(vim.opt.rtp:get(), snippet_path) then + vim.opt.rtp:append(snippet_path) + end + + require("modules.utils").load_plugin("luasnip", { + history = true, + update_events = "TextChanged,TextChangedI", + delete_check_events = "TextChanged,InsertLeave", + }, false, require("luasnip").config.set_config) + require("luasnip.loaders.from_lua").lazy_load() + require("luasnip.loaders.from_vscode").lazy_load() + require("luasnip.loaders.from_snipmate").lazy_load() +end diff --git a/nvim/lua/modules/configs/completion/mason-lspconfig.lua b/nvim/lua/modules/configs/completion/mason-lspconfig.lua new file mode 100644 index 0000000..567ff9f --- /dev/null +++ b/nvim/lua/modules/configs/completion/mason-lspconfig.lua @@ -0,0 +1,86 @@ +local M = {} + +M.setup = function() + local diagnostics_virtual_text = require("core.settings").diagnostics_virtual_text + local diagnostics_level = require("core.settings").diagnostics_level + + local nvim_lsp = require("lspconfig") + local mason_lspconfig = require("mason-lspconfig") + require("lspconfig.ui.windows").default_options.border = "rounded" + + require("modules.utils").load_plugin("mason-lspconfig", { + ensure_installed = require("core.settings").lsp_deps, + }) + + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + signs = true, + underline = true, + virtual_text = diagnostics_virtual_text and { + severity = { + min = vim.diagnostic.severity[diagnostics_level], + }, + } or false, + -- set update_in_insert to false because it was enabled by lspsaga + update_in_insert = false, + }) + + local opts = { + capabilities = vim.tbl_deep_extend( + "force", + vim.lsp.protocol.make_client_capabilities(), + require("cmp_nvim_lsp").default_capabilities() + ), + } + ---A handler to setup all servers defined under `completion/servers/*.lua` + ---@param lsp_name string + local function mason_lsp_handler(lsp_name) + -- rust_analyzer is configured using mrcjkb/rustaceanvim + -- warn users if they have set it up manually + if lsp_name == "rust_analyzer" then + local config_exist = pcall(require, "completion.servers." .. lsp_name) + if config_exist then + vim.notify( + [[ +`rust_analyzer` is configured independently via `mrcjkb/rustaceanvim`. To get rid of this warning, +please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` directory and configure +`rust_analyzer` using the appropriate init options provided by `rustaceanvim` instead.]], + vim.log.levels.WARN, + { title = "nvim-lspconfig" } + ) + end + return + end + + local ok, custom_handler = pcall(require, "user.configs.lsp-servers." .. lsp_name) + -- Use preset if there is no user definition + if not ok then + ok, custom_handler = pcall(require, "completion.servers." .. lsp_name) + end + if not ok then + -- Default to use factory config for server(s) that doesn't include a spec + nvim_lsp[lsp_name].setup(opts) + return + elseif type(custom_handler) == "function" then + --- Case where language server requires its own setup + --- Make sure to call require("lspconfig")[lsp_name].setup() in the function + --- See `clangd.lua` for example. + custom_handler(opts) + elseif type(custom_handler) == "table" then + nvim_lsp[lsp_name].setup(vim.tbl_deep_extend("force", opts, custom_handler)) + else + vim.notify( + string.format( + "Failed to setup [%s].\n\nServer definition under `completion/servers` must return\neither a fun(opts) or a table (got '%s' instead)", + lsp_name, + type(custom_handler) + ), + vim.log.levels.ERROR, + { title = "nvim-lspconfig" } + ) + end + end + + mason_lspconfig.setup_handlers({ mason_lsp_handler }) +end + +return M diff --git a/nvim/lua/modules/configs/completion/mason-null-ls.lua b/nvim/lua/modules/configs/completion/mason-null-ls.lua new file mode 100644 index 0000000..d077fec --- /dev/null +++ b/nvim/lua/modules/configs/completion/mason-null-ls.lua @@ -0,0 +1,12 @@ +local M = {} + +M.setup = function() + require("modules.utils").load_plugin("mason-null-ls", { + ensure_installed = require("core.settings").null_ls_deps, + automatic_installation = false, + automatic_setup = true, + handlers = {}, + }) +end + +return M diff --git a/nvim/lua/modules/configs/completion/mason.lua b/nvim/lua/modules/configs/completion/mason.lua new file mode 100644 index 0000000..4773532 --- /dev/null +++ b/nvim/lua/modules/configs/completion/mason.lua @@ -0,0 +1,94 @@ +local M = {} + +M.setup = function() + local is_windows = require("core.global").is_windows + + local mason_registry = require("mason-registry") + require("lspconfig.ui.windows").default_options.border = "rounded" + + local icons = { + ui = require("modules.utils.icons").get("ui", true), + misc = require("modules.utils.icons").get("misc", true), + } + + require("modules.utils").load_plugin("mason", { + ui = { + border = "single", + icons = { + package_pending = icons.ui.Modified_alt, + package_installed = icons.ui.Check, + package_uninstalled = icons.misc.Ghost, + }, + keymaps = { + toggle_server_expand = "", + install_server = "i", + update_server = "u", + check_server_version = "c", + update_all_servers = "U", + check_outdated_servers = "C", + uninstall_server = "X", + cancel_installation = "", + }, + }, + }) + + -- Additional plugins for pylsp + mason_registry:on( + "package:install:success", + vim.schedule_wrap(function(pkg) + if pkg.name ~= "python-lsp-server" then + return + end + + local venv = vim.fn.stdpath("data") .. "/mason/packages/python-lsp-server/venv" + local python = is_windows and venv .. "/Scripts/python.exe" or venv .. "/bin/python" + local black = is_windows and venv .. "/Scripts/black.exe" or venv .. "/bin/black" + local ruff = is_windows and venv .. "/Scripts/ruff.exe" or venv .. "/bin/ruff" + + require("plenary.job") + :new({ + command = python, + args = { + "-m", + "pip", + "install", + "-U", + "--disable-pip-version-check", + "python-lsp-black", + "python-lsp-ruff", + "pylsp-rope", + }, + cwd = venv, + env = { VIRTUAL_ENV = venv }, + on_exit = function() + if vim.fn.executable(black) == 1 and vim.fn.executable(ruff) == 1 then + vim.notify( + "Finished installing pylsp plugins", + vim.log.levels.INFO, + { title = "[lsp] Install Status" } + ) + else + vim.notify( + "Failed to install pylsp plugins. [Executable not found]", + vim.log.levels.ERROR, + { title = "[lsp] Install Failure" } + ) + end + end, + on_start = function() + vim.notify( + "Now installing pylsp plugins...", + vim.log.levels.INFO, + { title = "[lsp] Install Status", timeout = 6000 } + ) + end, + on_stderr = function(_, msg_stream) + vim.notify(msg_stream, vim.log.levels.ERROR, { title = "[lsp] Install Failure" }) + end, + }) + :start() + end) + ) +end + +return M diff --git a/nvim/lua/modules/configs/completion/neoconf.lua b/nvim/lua/modules/configs/completion/neoconf.lua new file mode 100644 index 0000000..4db9cc7 --- /dev/null +++ b/nvim/lua/modules/configs/completion/neoconf.lua @@ -0,0 +1,20 @@ +local M = {} + +M.setup = function() + require("modules.utils").load_plugin("neoconf", { + -- send new configuration to lsp clients when changing json settings + live_reload = true, + -- name of the local settings files + local_settings = ".neoconf.json", + -- name of the global settings file in your Neovim config directory + global_settings = "neoconf.json", + -- import existing settings from other plugins + import = { + vscode = true, -- local .vscode/settings.json + coc = true, -- global/local coc-settings.json + nlsp = true, -- global/local nlsp-settings.nvim json settings + }, + }) +end + +return M diff --git a/nvim/lua/modules/configs/completion/null-ls.lua b/nvim/lua/modules/configs/completion/null-ls.lua new file mode 100644 index 0000000..72982d6 --- /dev/null +++ b/nvim/lua/modules/configs/completion/null-ls.lua @@ -0,0 +1,77 @@ +return function() + local null_ls = require("null-ls") + local btns = null_ls.builtins + + ---Return formatter args required by `extra_args` + ---@param formatter_name string + ---@return table|nil + local function formatter_args(formatter_name) + local ok, args = pcall(require, "user.configs.formatters." .. formatter_name) + if not ok then + args = require("completion.formatters." .. formatter_name) + end + return args + end + + -- Please set additional flags for the supported servers here + -- Don't specify any config here if you are using the default one. + local sources = { + btns.formatting.clang_format.with({ + filetypes = { "c", "cpp", "objc", "objcpp", "cs", "java", "cuda", "proto" }, + extra_args = formatter_args("clang_format"), + }), + btns.formatting.prettier.with({ + filetypes = { + "vue", + "typescript", + "javascript", + "typescriptreact", + "javascriptreact", + "yaml", + "html", + "css", + "scss", + "sh", + "markdown", + }, + }), + } + require("modules.utils").load_plugin("null-ls", { + border = "rounded", + debug = false, + log_level = "warn", + update_in_insert = false, + sources = sources, + default_timeout = require("core.settings").format_timeout, + }) + + require("completion.mason-null-ls").setup() + + -- Setup usercmd to register/deregister available source(s) + local function _gen_completion() + local sources_cont = null_ls.get_source({ + filetype = vim.bo.filetype, + }) + local completion_items = {} + for _, server in pairs(sources_cont) do + table.insert(completion_items, server.name) + end + return completion_items + end + vim.api.nvim_create_user_command("NullLsToggle", function(opts) + if vim.tbl_contains(_gen_completion(), opts.args) then + null_ls.toggle({ name = opts.args }) + else + vim.notify( + string.format("[Null-ls] Unable to find any registered source named [%s].", opts.args), + vim.log.levels.ERROR, + { title = "Null-ls Internal Error" } + ) + end + end, { + nargs = 1, + complete = _gen_completion, + }) + + require("completion.formatting").configure_format_on_save() +end diff --git a/nvim/lua/modules/configs/completion/servers/bashls.lua b/nvim/lua/modules/configs/completion/servers/bashls.lua new file mode 100644 index 0000000..d5e470f --- /dev/null +++ b/nvim/lua/modules/configs/completion/servers/bashls.lua @@ -0,0 +1,5 @@ +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/bashls.lua +return { + cmd = { "bash-language-server", "start" }, + filetypes = { "bash", "sh" }, +} diff --git a/nvim/lua/modules/configs/completion/servers/clangd.lua b/nvim/lua/modules/configs/completion/servers/clangd.lua new file mode 100644 index 0000000..7661177 --- /dev/null +++ b/nvim/lua/modules/configs/completion/servers/clangd.lua @@ -0,0 +1,79 @@ +local function switch_source_header_splitcmd(bufnr, splitcmd) + bufnr = require("lspconfig").util.validate_bufnr(bufnr) + local clangd_client = require("lspconfig").util.get_active_client_by_name(bufnr, "clangd") + local params = { uri = vim.uri_from_bufnr(bufnr) } + if clangd_client then + clangd_client.request("textDocument/switchSourceHeader", params, function(err, result) + if err then + error(tostring(err)) + end + if not result then + vim.notify("Corresponding file can’t be determined", vim.log.levels.ERROR, { title = "LSP Error!" }) + return + end + vim.api.nvim_command(splitcmd .. " " .. vim.uri_to_fname(result)) + end) + else + vim.notify( + "Method textDocument/switchSourceHeader is not supported by any active server on this buffer", + vim.log.levels.ERROR, + { title = "LSP Error!" } + ) + end +end + +local function get_binary_path_list(binaries) + local path_list = {} + for _, binary in ipairs(binaries) do + local path = vim.fn.exepath(binary) + if path ~= "" then + table.insert(path_list, path) + end + end + return table.concat(path_list, ",") +end + +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/clangd.lua +return function(options) + require("lspconfig").clangd.setup({ + on_attach = options.on_attach, + capabilities = vim.tbl_deep_extend("keep", { offsetEncoding = { "utf-16", "utf-8" } }, options.capabilities), + single_file_support = true, + cmd = { + "clangd", + "-j=12", + "--enable-config", + "--background-index", + "--pch-storage=memory", + -- You MUST set this arg ↓ to your c/cpp compiler location (if not included)! + "--query-driver=" .. get_binary_path_list({ "clang++", "clang", "gcc", "g++" }), + "--clang-tidy", + "--all-scopes-completion", + "--completion-style=detailed", + "--header-insertion-decorators", + "--header-insertion=iwyu", + "--limit-references=3000", + "--limit-results=350", + }, + commands = { + ClangdSwitchSourceHeader = { + function() + switch_source_header_splitcmd(0, "edit") + end, + description = "Open source/header in current buffer", + }, + ClangdSwitchSourceHeaderVSplit = { + function() + switch_source_header_splitcmd(0, "vsplit") + end, + description = "Open source/header in a new vsplit", + }, + ClangdSwitchSourceHeaderSplit = { + function() + switch_source_header_splitcmd(0, "split") + end, + description = "Open source/header in a new split", + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/completion/servers/dartls.lua b/nvim/lua/modules/configs/completion/servers/dartls.lua new file mode 100644 index 0000000..5240aef --- /dev/null +++ b/nvim/lua/modules/configs/completion/servers/dartls.lua @@ -0,0 +1,12 @@ +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/dartls.lua +return { + cmd = { "dart", "language-server", "--protocol=lsp" }, + filetypes = { "dart" }, + init_options = { + closingLabels = true, + flutterOutline = true, + onlyAnalyzeProjectsWithOpenFiles = true, + outline = true, + suggestFromUnimportedLibraries = true, + }, +} diff --git a/nvim/lua/modules/configs/completion/servers/gopls.lua b/nvim/lua/modules/configs/completion/servers/gopls.lua new file mode 100644 index 0000000..c05d162 --- /dev/null +++ b/nvim/lua/modules/configs/completion/servers/gopls.lua @@ -0,0 +1,50 @@ +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/gopls.lua +return { + cmd = { "gopls", "-remote.debug=:0", "-remote=auto" }, + filetypes = { "go", "gomod", "gosum", "gotmpl", "gohtmltmpl", "gotexttmpl" }, + flags = { allow_incremental_sync = true, debounce_text_changes = 500 }, + capabilities = { + textDocument = { + completion = { + contextSupport = true, + dynamicRegistration = true, + completionItem = { + commitCharactersSupport = true, + deprecatedSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + snippetSupport = true, + documentationFormat = { "markdown", "plaintext" }, + resolveSupport = { + properties = { + "documentation", + "details", + "additionalTextEdits", + }, + }, + }, + }, + }, + }, + settings = { + gopls = { + staticcheck = true, + semanticTokens = true, + noSemanticString = true, + usePlaceholders = true, + completeUnimported = true, + symbolMatcher = "Fuzzy", + buildFlags = { "-tags", "integration" }, + codelenses = { + generate = true, + gc_details = true, + test = true, + tidy = true, + vendor = true, + regenerate_cgo = true, + upgrade_dependency = true, + }, + }, + }, +} diff --git a/nvim/lua/modules/configs/completion/servers/html.lua b/nvim/lua/modules/configs/completion/servers/html.lua new file mode 100644 index 0000000..fa8f9bd --- /dev/null +++ b/nvim/lua/modules/configs/completion/servers/html.lua @@ -0,0 +1,12 @@ +-- https://github.com/vscode-langservers/vscode-html-languageserver-bin +return { + cmd = { "html-languageserver", "--stdio" }, + filetypes = { "html" }, + init_options = { + configurationSection = { "html", "css", "javascript" }, + embeddedLanguages = { css = true, javascript = true }, + }, + settings = {}, + single_file_support = true, + flags = { debounce_text_changes = 500 }, +} diff --git a/nvim/lua/modules/configs/completion/servers/jsonls.lua b/nvim/lua/modules/configs/completion/servers/jsonls.lua new file mode 100644 index 0000000..d83198d --- /dev/null +++ b/nvim/lua/modules/configs/completion/servers/jsonls.lua @@ -0,0 +1,55 @@ +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/jsonls.lua +return { + flags = { debounce_text_changes = 500 }, + settings = { + json = { + -- Schemas https://www.schemastore.org + schemas = { + { + fileMatch = { "package.json" }, + url = "https://json.schemastore.org/package.json", + }, + { + fileMatch = { "tsconfig*.json" }, + url = "https://json.schemastore.org/tsconfig.json", + }, + { + fileMatch = { + ".prettierrc", + ".prettierrc.json", + "prettier.config.json", + }, + url = "https://json.schemastore.org/prettierrc.json", + }, + { + fileMatch = { ".eslintrc", ".eslintrc.json" }, + url = "https://json.schemastore.org/eslintrc.json", + }, + { + fileMatch = { + ".babelrc", + ".babelrc.json", + "babel.config.json", + }, + url = "https://json.schemastore.org/babelrc.json", + }, + { + fileMatch = { "lerna.json" }, + url = "https://json.schemastore.org/lerna.json", + }, + { + fileMatch = { + ".stylelintrc", + ".stylelintrc.json", + "stylelint.config.json", + }, + url = "http://json.schemastore.org/stylelintrc.json", + }, + { + fileMatch = { "/.github/workflows/*" }, + url = "https://json.schemastore.org/github-workflow.json", + }, + }, + }, + }, +} diff --git a/nvim/lua/modules/configs/completion/servers/lua_ls.lua b/nvim/lua/modules/configs/completion/servers/lua_ls.lua new file mode 100644 index 0000000..cd68c9e --- /dev/null +++ b/nvim/lua/modules/configs/completion/servers/lua_ls.lua @@ -0,0 +1,25 @@ +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/lua_ls.lua +return { + settings = { + Lua = { + runtime = { version = "LuaJIT" }, + diagnostics = { + globals = { "vim" }, + disable = { "different-requires", "undefined-field" }, + }, + workspace = { + library = { + vim.fn.expand("$VIMRUNTIME/lua"), + vim.fn.expand("$VIMRUNTIME/lua/vim/lsp"), + }, + maxPreload = 100000, + preloadFileSize = 10000, + }, + hint = { enable = true, setType = true }, + format = { enable = false }, + telemetry = { enable = false }, + -- Do not override treesitter lua highlighting with lua_ls's highlighting + semantic = { enable = false }, + }, + }, +} diff --git a/nvim/lua/modules/configs/completion/servers/pylsp.lua b/nvim/lua/modules/configs/completion/servers/pylsp.lua new file mode 100644 index 0000000..eb83ccd --- /dev/null +++ b/nvim/lua/modules/configs/completion/servers/pylsp.lua @@ -0,0 +1,46 @@ +-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/pylsp.lua +return { + cmd = { "pylsp" }, + filetypes = { "python" }, + settings = { + pylsp = { + plugins = { + -- Lint + ruff = { + enabled = true, + select = { + -- enable pycodestyle + "E", + -- enable pyflakes + "F", + }, + ignore = { + -- ignore E501 (line too long) + -- "E501", + -- ignore F401 (imported but unused) + -- "F401", + }, + extendSelect = { "I" }, + severities = { + -- Hint, Information, Warning, Error + F401 = "I", + E501 = "I", + }, + }, + flake8 = { enabled = false }, + pyflakes = { enabled = false }, + pycodestyle = { enabled = false }, + mccabe = { enabled = false }, + + -- Code refactor + rope = { enabled = true }, + + -- Formatting + black = { enabled = true }, + pyls_isort = { enabled = false }, + autopep8 = { enabled = false }, + yapf = { enabled = false }, + }, + }, + }, +} diff --git a/nvim/lua/modules/configs/completion/tabnine.lua b/nvim/lua/modules/configs/completion/tabnine.lua new file mode 100644 index 0000000..0509616 --- /dev/null +++ b/nvim/lua/modules/configs/completion/tabnine.lua @@ -0,0 +1,3 @@ +return function() + require("cmp_tabnine.config"):setup({ max_line = 1000, max_num_results = 20, sort = true }) +end diff --git a/nvim/lua/modules/configs/editor/align.lua b/nvim/lua/modules/configs/editor/align.lua new file mode 100644 index 0000000..43c50d8 --- /dev/null +++ b/nvim/lua/modules/configs/editor/align.lua @@ -0,0 +1,11 @@ +return function() + require("modules.utils").load_plugin("mini.align", { + -- Whether to disable showing non-error feedback + silent = false, + -- Module mappings. Use `''` (empty string) to disable one. + mappings = { + start = "gea", + start_with_preview = "geA", + }, + }) +end diff --git a/nvim/lua/modules/configs/editor/autoclose.lua b/nvim/lua/modules/configs/editor/autoclose.lua new file mode 100644 index 0000000..a43888f --- /dev/null +++ b/nvim/lua/modules/configs/editor/autoclose.lua @@ -0,0 +1,39 @@ +return function() + require("modules.utils").load_plugin("autoclose", { + keys = { + ["("] = { escape = false, close = true, pair = "()" }, + ["["] = { escape = false, close = true, pair = "[]" }, + ["{"] = { escape = false, close = true, pair = "{}" }, + + ["<"] = { escape = true, close = true, pair = "<>", enabled_filetypes = { "rust" } }, + [">"] = { escape = true, close = false, pair = "<>" }, + [")"] = { escape = true, close = false, pair = "()" }, + ["]"] = { escape = true, close = false, pair = "[]" }, + ["}"] = { escape = true, close = false, pair = "{}" }, + + ['"'] = { escape = true, close = true, pair = '""' }, + ["`"] = { escape = true, close = true, pair = "``" }, + ["'"] = { escape = true, close = true, pair = "''", disabled_filetypes = { "rust" } }, + }, + options = { + disable_when_touch = false, + disabled_filetypes = { + "alpha", + "bigfile", + "checkhealth", + "dap-repl", + "diff", + "help", + "log", + "notify", + "NvimTree", + "Outline", + "qf", + "TelescopePrompt", + "toggleterm", + "undotree", + "vimwiki", + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/editor/autotag.lua b/nvim/lua/modules/configs/editor/autotag.lua new file mode 100644 index 0000000..42dcd97 --- /dev/null +++ b/nvim/lua/modules/configs/editor/autotag.lua @@ -0,0 +1,9 @@ +return function() + require("modules.utils").load_plugin("nvim-ts-autotag", { + opts = { + enable_close = true, -- Auto close tags + enable_rename = true, -- Auto rename pairs of tags + enable_close_on_slash = false, -- Auto close on trailing ` + current = true, + -- for the current window, label targets closer to the cursor first + distance = true, + }, + modes = { + search = { enabled = false }, + -- options used when flash is activated through + -- `f`, `F`, `t`, `T`, `;` and `,` motions + char = { + enabled = true, + -- hide after jump when not using jump labels + autohide = false, + -- show jump labels + jump_labels = false, + -- set to `false` to use the current line only + multi_line = true, + -- When using jump labels, don't use these keys + -- This allows using those keys directly after the motion + label = { exclude = "hjkliardc" }, + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/editor/highlight-colors.lua b/nvim/lua/modules/configs/editor/highlight-colors.lua new file mode 100644 index 0000000..06a0f6a --- /dev/null +++ b/nvim/lua/modules/configs/editor/highlight-colors.lua @@ -0,0 +1,31 @@ +return function() + require("modules.utils").load_plugin("nvim-highlight-colors", { + render = "background", + enable_hex = true, + enable_short_hex = true, + enable_rgb = true, + enable_hsl = true, + enable_var_usage = true, + enable_named_colors = false, + enable_tailwind = false, + -- Exclude filetypes or buftypes from highlighting + exclude_filetypes = { + "alpha", + "bigfile", + "dap-repl", + "fugitive", + "git", + "notify", + "NvimTree", + "Outline", + "TelescopePrompt", + "toggleterm", + "undotree", + }, + exclude_buftypes = { + "nofile", + "prompt", + "terminal", + }, + }) +end diff --git a/nvim/lua/modules/configs/editor/hop.lua b/nvim/lua/modules/configs/editor/hop.lua new file mode 100644 index 0000000..d52fa5b --- /dev/null +++ b/nvim/lua/modules/configs/editor/hop.lua @@ -0,0 +1,3 @@ +return function() + require("modules.utils").load_plugin("hop", { keys = "etovxqpdygfblzhckisuran" }) +end diff --git a/nvim/lua/modules/configs/editor/local-highlight.lua b/nvim/lua/modules/configs/editor/local-highlight.lua new file mode 100644 index 0000000..f8c001f --- /dev/null +++ b/nvim/lua/modules/configs/editor/local-highlight.lua @@ -0,0 +1,6 @@ +return function() + require("modules.utils").load_plugin("local-highlight", { + hlgroup = "IlluminatedWordText", + insert_mode = false, + }) +end diff --git a/nvim/lua/modules/configs/editor/persisted.lua b/nvim/lua/modules/configs/editor/persisted.lua new file mode 100644 index 0000000..003d8cb --- /dev/null +++ b/nvim/lua/modules/configs/editor/persisted.lua @@ -0,0 +1,23 @@ +return function() + require("modules.utils").load_plugin("persisted", { + save_dir = vim.fn.expand(vim.fn.stdpath("data") .. "/sessions/"), -- directory where session files are saved + silent = false, -- silent nvim message when sourcing session file + use_git_branch = true, -- create session files based on the branch of the git enabled repository + autosave = true, -- automatically save session files when exiting Neovim + should_autosave = function() + if vim.bo.filetype == "alpha" then + return false + end + return true + end, -- function to determine if a session should be autosaved + -- Set `lazy = false` in `plugins/editor.lua` to enable this + autoload = false, -- automatically load the session for the cwd on Neovim startup + on_autoload_no_session = nil, -- function to run when `autoload = true` but there is no session to load + follow_cwd = true, -- change session file name to match current working directory if it changes + allowed_dirs = nil, -- table of dirs that the plugin will auto-save and auto-load from + ignored_dirs = nil, -- table of dirs that are ignored when auto-saving and auto-loading + telescope = { -- options for the telescope extension + reset_prompt_after_deletion = true, -- whether to reset prompt after session deleted + }, + }) +end diff --git a/nvim/lua/modules/configs/editor/rainbow_delims.lua b/nvim/lua/modules/configs/editor/rainbow_delims.lua new file mode 100644 index 0000000..d2e681d --- /dev/null +++ b/nvim/lua/modules/configs/editor/rainbow_delims.lua @@ -0,0 +1,53 @@ +return function() + ---@param threshold number @Use global strategy if nr of lines exceeds this value + local function init_strategy(threshold) + return function() + -- Disable on very large files + local line_count = vim.api.nvim_buf_line_count(0) + if line_count > 7500 then + return nil + end + + -- Disable on parser error + local errors = 200 + vim.treesitter.get_parser():for_each_tree(function(lt) + if lt:root():has_error() and errors >= 0 then + errors = errors - 1 + end + end) + if errors < 0 then + return nil + end + + return line_count > threshold and require("rainbow-delimiters").strategy["global"] + or require("rainbow-delimiters").strategy["local"] + end + end + + vim.g.rainbow_delimiters = { + strategy = { + [""] = init_strategy(500), + c = init_strategy(300), + cpp = init_strategy(300), + lua = init_strategy(500), + vimdoc = init_strategy(300), + vim = init_strategy(300), + }, + query = { + [""] = "rainbow-delimiters", + latex = "rainbow-blocks", + javascript = "rainbow-delimiters-react", + }, + highlight = { + "RainbowDelimiterRed", + "RainbowDelimiterOrange", + "RainbowDelimiterYellow", + "RainbowDelimiterGreen", + "RainbowDelimiterBlue", + "RainbowDelimiterCyan", + "RainbowDelimiterViolet", + }, + } + + require("modules.utils").load_plugin("rainbow_delimiters", nil, true) +end diff --git a/nvim/lua/modules/configs/editor/splits.lua b/nvim/lua/modules/configs/editor/splits.lua new file mode 100644 index 0000000..891d01e --- /dev/null +++ b/nvim/lua/modules/configs/editor/splits.lua @@ -0,0 +1,14 @@ +return function() + require("modules.utils").load_plugin("smart-splits", { + -- Ignored buffer types (only while resizing) + ignored_buftypes = { + "nofile", + "quickfix", + "prompt", + }, + -- Ignored filetypes (only while resizing) + ignored_filetypes = { "NvimTree" }, + -- the default number of lines/columns to resize by at a time + default_amount = 3, + }) +end diff --git a/nvim/lua/modules/configs/editor/suda.lua b/nvim/lua/modules/configs/editor/suda.lua new file mode 100644 index 0000000..d70aa61 --- /dev/null +++ b/nvim/lua/modules/configs/editor/suda.lua @@ -0,0 +1,5 @@ +return function() + vim.g["suda#prompt"] = "Enter administrator password: " + + require("modules.utils").load_plugin("suda", nil, true) +end diff --git a/nvim/lua/modules/configs/editor/treesitter.lua b/nvim/lua/modules/configs/editor/treesitter.lua new file mode 100644 index 0000000..5b25ebe --- /dev/null +++ b/nvim/lua/modules/configs/editor/treesitter.lua @@ -0,0 +1,66 @@ +return vim.schedule_wrap(function() + local use_ssh = require("core.settings").use_ssh + + vim.api.nvim_set_option_value("foldmethod", "expr", {}) + vim.api.nvim_set_option_value("foldexpr", "nvim_treesitter#foldexpr()", {}) + + require("modules.utils").load_plugin("nvim-treesitter", { + ensure_installed = require("core.settings").treesitter_deps, + highlight = { + enable = true, + disable = function(ft, bufnr) + if + vim.tbl_contains({ "gitcommit" }, ft) + or (vim.api.nvim_buf_line_count(bufnr) > 7500 and ft ~= "vimdoc") + then + return true + end + + local ok, is_large_file = pcall(vim.api.nvim_buf_get_var, bufnr, "bigfile_disable_treesitter") + return ok and is_large_file + end, + additional_vim_regex_highlighting = false, + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + move = { + enable = true, + set_jumps = true, + goto_next_start = { + ["]["] = "@function.outer", + ["]m"] = "@class.outer", + }, + goto_next_end = { + ["]]"] = "@function.outer", + ["]M"] = "@class.outer", + }, + goto_previous_start = { + ["[["] = "@function.outer", + ["[m"] = "@class.outer", + }, + goto_previous_end = { + ["[]"] = "@function.outer", + ["[M"] = "@class.outer", + }, + }, + }, + indent = { enable = true }, + matchup = { enable = true }, + }, false, require("nvim-treesitter.configs").setup) + require("nvim-treesitter.install").prefer_git = true + if use_ssh then + local parsers = require("nvim-treesitter.parsers").get_parser_configs() + for _, parser in pairs(parsers) do + parser.install_info.url = parser.install_info.url:gsub("https://github.com/", "git@github.com:") + end + end +end) diff --git a/nvim/lua/modules/configs/editor/ts-context-commentstring.lua b/nvim/lua/modules/configs/editor/ts-context-commentstring.lua new file mode 100644 index 0000000..ebefadc --- /dev/null +++ b/nvim/lua/modules/configs/editor/ts-context-commentstring.lua @@ -0,0 +1,7 @@ +return function() + vim.g.skip_ts_context_commentstring_module = true + require("modules.utils").load_plugin("ts_context_commentstring", { + -- Whether to update the `commentstring` on the `CursorHold` autocmd + enable_autocmd = false, + }) +end diff --git a/nvim/lua/modules/configs/editor/ts-context.lua b/nvim/lua/modules/configs/editor/ts-context.lua new file mode 100644 index 0000000..ba96e03 --- /dev/null +++ b/nvim/lua/modules/configs/editor/ts-context.lua @@ -0,0 +1,12 @@ +return function() + require("modules.utils").load_plugin("treesitter-context", { + enable = true, + max_lines = 3, -- How many lines the window should span. Values <= 0 mean no limit. + min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. + line_numbers = true, + multiline_threshold = 20, -- Maximum number of lines to collapse for a single context line + trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + mode = "cursor", -- Line used to calculate context. Choices: 'cursor', 'topline' + zindex = 50, -- Ensure compatibility with Glance's preview window + }) +end diff --git a/nvim/lua/modules/configs/lang/bqf.lua b/nvim/lua/modules/configs/lang/bqf.lua new file mode 100644 index 0000000..9c80bd2 --- /dev/null +++ b/nvim/lua/modules/configs/lang/bqf.lua @@ -0,0 +1,9 @@ +return function() + require("modules.utils").load_plugin("bqf", { + preview = { + border = "single", + wrap = true, + winblend = 0, + }, + }) +end diff --git a/nvim/lua/modules/configs/lang/crates-keymap.lua b/nvim/lua/modules/configs/lang/crates-keymap.lua new file mode 100644 index 0000000..cf1584c --- /dev/null +++ b/nvim/lua/modules/configs/lang/crates-keymap.lua @@ -0,0 +1,126 @@ +local bind = require("keymap.bind") +local map_callback = bind.map_callback + +local crates = require("crates") +local crates_keymap = { + ["n|ct"] = map_callback(function() + crates.toggle() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Toggle spec activities"), + ["n|cr"] = map_callback(function() + crates.reload() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Reload crate specs"), + + ["n|cs"] = map_callback(function() + crates.show_popup() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Toggle pop-up window"), + ["n|cv"] = map_callback(function() + crates.show_versions_popup() + crates.show_popup() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Select spec versions"), + ["n|cf"] = map_callback(function() + crates.show_features_popup() + crates.show_popup() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Select spec features"), + ["n|cd"] = map_callback(function() + crates.show_dependencies_popup() + crates.show_popup() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Show project dependencies"), + + ["n|cu"] = map_callback(function() + crates.update_crate() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Update current crate's spec"), + ["v|cu"] = map_callback(function() + crates.update_crates() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Update selected crate's spec"), + ["n|ca"] = map_callback(function() + crates.update_all_crates() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Update all crates' specs"), + ["n|cU"] = map_callback(function() + crates.upgrade_crate() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Upgrade current crate"), + ["v|cU"] = map_callback(function() + crates.upgrade_crates() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Upgrade selected crates"), + ["n|cA"] = map_callback(function() + crates.upgrade_all_crates() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Upgrade all crates"), + + ["n|cH"] = map_callback(function() + crates.open_homepage() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Open current crate's homepage"), + ["n|cR"] = map_callback(function() + crates.open_repository() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Open current crate's repository"), + ["n|cD"] = map_callback(function() + crates.open_documentation() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Open current crate's documentation"), + ["n|cC"] = map_callback(function() + crates.open_crates_io() + end) + :with_noremap() + :with_silent() + :with_buffer(0) + :with_desc("crates: Browse current crate on crates.io"), +} + +bind.nvim_load_mapping(crates_keymap) diff --git a/nvim/lua/modules/configs/lang/crates.lua b/nvim/lua/modules/configs/lang/crates.lua new file mode 100644 index 0000000..ee1d880 --- /dev/null +++ b/nvim/lua/modules/configs/lang/crates.lua @@ -0,0 +1,89 @@ +return function() + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics", true), + git = require("modules.utils.icons").get("git", true), + misc = require("modules.utils.icons").get("misc", true), + ui = require("modules.utils.icons").get("ui", true), + kind = require("modules.utils.icons").get("kind", true), + } + + require("modules.utils").load_plugin("crates", { + smart_insert = true, + insert_closing_quote = true, + avoid_prerelease = true, + autoload = true, + autoupdate = true, + autoupdate_throttle = 250, + loading_indicator = true, + date_format = "%Y-%m-%d", + thousands_separator = ",", + notification_title = "Crates", + curl_args = { "-sL", "--retry", "1" }, + disable_invalid_feature_diagnostic = false, + text = { + loading = " " .. icons.misc.Watch .. "Loading", + version = " " .. icons.ui.Check .. "%s", + prerelease = " " .. icons.diagnostics.Warning_alt .. "%s", + yanked = " " .. icons.diagnostics.Error .. "%s", + nomatch = " " .. icons.diagnostics.Question .. "No match", + upgrade = " " .. icons.diagnostics.Hint_alt .. "%s", + error = " " .. icons.diagnostics.Error .. "Error fetching crate", + }, + popup = { + autofocus = false, + hide_on_select = true, + copy_register = '"', + style = "minimal", + border = "rounded", + show_version_date = true, + show_dependency_version = true, + max_height = 30, + min_width = 20, + padding = 1, + text = { + title = icons.ui.Package .. "%s", + description = "%s", + created_label = icons.misc.Added .. "created" .. " ", + created = "%s", + updated_label = icons.misc.ManUp .. "updated" .. " ", + updated = "%s", + downloads_label = icons.ui.CloudDownload .. "downloads ", + downloads = "%s", + homepage_label = icons.misc.Campass .. "homepage ", + homepage = "%s", + repository_label = icons.git.Repo .. "repository ", + repository = "%s", + documentation_label = icons.diagnostics.Information_alt .. "documentation ", + documentation = "%s", + crates_io_label = icons.ui.Package .. "crates.io ", + crates_io = "%s", + categories_label = icons.kind.Class .. "categories ", + keywords_label = icons.kind.Keyword .. "keywords ", + version = " %s", + prerelease = icons.diagnostics.Warning_alt .. "%s prerelease", + yanked = icons.diagnostics.Error .. "%s yanked", + version_date = " %s", + feature = " %s", + enabled = icons.ui.Play .. "%s", + transitive = icons.ui.List .. "%s", + normal_dependencies_title = icons.kind.Interface .. "Dependencies", + build_dependencies_title = icons.misc.Gavel .. "Build dependencies", + dev_dependencies_title = icons.misc.Glass .. "Dev dependencies", + dependency = " %s", + optional = icons.ui.BigUnfilledCircle .. "%s", + dependency_version = " %s", + loading = " " .. icons.misc.Watch, + }, + }, + completion = { + insert_closing_quote = true, + text = { + prerelease = " " .. icons.diagnostics.Warning_alt .. "pre-release ", + yanked = " " .. icons.diagnostics.Error_alt .. "yanked ", + }, + }, + }) + + -- Set buffer-local keymaps + require("lang.crates-keymap") +end diff --git a/nvim/lua/modules/configs/lang/go.lua b/nvim/lua/modules/configs/lang/go.lua new file mode 100644 index 0000000..8ca7b03 --- /dev/null +++ b/nvim/lua/modules/configs/lang/go.lua @@ -0,0 +1,21 @@ +return function() + require("modules.utils").load_plugin("go", { + -- By default, we've turned off these options to prevent clashes with our gopls config + icons = false, + diagnostic = false, + lsp_cfg = false, + lsp_gofumpt = false, + lsp_keymaps = false, + lsp_codelens = false, + lsp_document_formatting = false, + lsp_inlay_hints = { enable = false }, + -- DAP-related settings are also turned off here for the same reason + dap_debug = false, + dap_debug_keymap = false, + textobjects = false, + -- Miscellaneous options to seamlessly integrate with other plugins + trouble = true, + luasnip = false, + run_in_floaterm = false, + }) +end diff --git a/nvim/lua/modules/configs/lang/rust.lua b/nvim/lua/modules/configs/lang/rust.lua new file mode 100644 index 0000000..cdcc1c7 --- /dev/null +++ b/nvim/lua/modules/configs/lang/rust.lua @@ -0,0 +1,12 @@ +return function() + vim.g.rustaceanvim = { + -- Disable automatic DAP configuration to avoid conflicts with previous user configs + dap = { + adapter = false, + configuration = false, + autoload_configurations = false, + }, + } + + require("modules.utils").load_plugin("rustaceanvim", nil, true) +end diff --git a/nvim/lua/modules/configs/tool/dap/clients/codelldb.lua b/nvim/lua/modules/configs/tool/dap/clients/codelldb.lua new file mode 100644 index 0000000..64124c6 --- /dev/null +++ b/nvim/lua/modules/configs/tool/dap/clients/codelldb.lua @@ -0,0 +1,47 @@ +-- https://github.com/mfussenegger/nvim-dap/wiki/C-C---Rust-(via--codelldb) +return function() + local dap = require("dap") + local utils = require("modules.utils.dap") + local is_windows = require("core.global").is_windows + + dap.adapters.codelldb = { + type = "server", + port = "${port}", + executable = { + command = vim.fn.exepath("codelldb"), -- Find codelldb on $PATH + args = { "--port", "${port}" }, + detached = is_windows and false or true, + }, + } + dap.configurations.c = { + { + name = "Debug", + type = "codelldb", + request = "launch", + program = utils.input_exec_path(), + cwd = "${workspaceFolder}", + stopOnEntry = false, + terminal = "integrated", + }, + { + name = "Debug (with args)", + type = "codelldb", + request = "launch", + program = utils.input_exec_path(), + args = utils.input_args(), + cwd = "${workspaceFolder}", + stopOnEntry = false, + terminal = "integrated", + }, + { + name = "Attach to a running process", + type = "codelldb", + request = "attach", + program = utils.input_exec_path(), + stopOnEntry = false, + waitFor = true, + }, + } + dap.configurations.cpp = dap.configurations.c + dap.configurations.rust = dap.configurations.c +end diff --git a/nvim/lua/modules/configs/tool/dap/clients/delve.lua b/nvim/lua/modules/configs/tool/dap/clients/delve.lua new file mode 100644 index 0000000..6f02344 --- /dev/null +++ b/nvim/lua/modules/configs/tool/dap/clients/delve.lua @@ -0,0 +1,100 @@ +-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#go +-- https://github.com/golang/vscode-go/blob/master/docs/debugging.md +return function() + local dap = require("dap") + local utils = require("modules.utils.dap") + + if not require("mason-registry").is_installed("go-debug-adapter") then + vim.notify( + "Automatically installing `go-debug-adapter` for go debugging", + vim.log.levels.INFO, + { title = "nvim-dap" } + ) + + local go_dbg = require("mason-registry").get_package("go-debug-adapter") + go_dbg:install():once( + "closed", + vim.schedule_wrap(function() + if go_dbg:is_installed() then + vim.notify("Successfully installed `go-debug-adapter`", vim.log.levels.INFO, { title = "nvim-dap" }) + end + end) + ) + end + + dap.adapters.go = { + type = "executable", + command = "node", + args = { + require("mason-registry").get_package("go-debug-adapter"):get_install_path() + .. "/extension/dist/debugAdapter.js", + }, + } + dap.configurations.go = { + { + type = "go", + name = "Debug (file)", + request = "launch", + cwd = "${workspaceFolder}", + program = utils.input_file_path(), + console = "integratedTerminal", + dlvToolPath = vim.fn.exepath("dlv"), + showLog = true, + showRegisters = true, + stopOnEntry = false, + }, + { + type = "go", + name = "Debug (file with args)", + request = "launch", + cwd = "${workspaceFolder}", + program = utils.input_file_path(), + args = utils.input_args(), + console = "integratedTerminal", + dlvToolPath = vim.fn.exepath("dlv"), + showLog = true, + showRegisters = true, + stopOnEntry = false, + }, + { + type = "go", + name = "Debug (executable)", + request = "launch", + cwd = "${workspaceFolder}", + program = utils.input_exec_path(), + args = utils.input_args(), + console = "integratedTerminal", + dlvToolPath = vim.fn.exepath("dlv"), + mode = "exec", + showLog = true, + showRegisters = true, + stopOnEntry = false, + }, + { + type = "go", + name = "Debug (test file)", + request = "launch", + cwd = "${workspaceFolder}", + program = utils.input_file_path(), + console = "integratedTerminal", + dlvToolPath = vim.fn.exepath("dlv"), + mode = "test", + showLog = true, + showRegisters = true, + stopOnEntry = false, + }, + { + type = "go", + name = "Debug (using go.mod)", + request = "launch", + cwd = "${workspaceFolder}", + program = "./${relativeFileDirname}", + console = "integratedTerminal", + dlvToolPath = vim.fn.exepath("dlv"), + mode = "test", + showLog = true, + showRegisters = true, + stopOnEntry = false, + }, + } +end diff --git a/nvim/lua/modules/configs/tool/dap/clients/lldb.lua b/nvim/lua/modules/configs/tool/dap/clients/lldb.lua new file mode 100644 index 0000000..8461c77 --- /dev/null +++ b/nvim/lua/modules/configs/tool/dap/clients/lldb.lua @@ -0,0 +1,36 @@ +-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#ccrust-via-lldb-vscode +return function() + local dap = require("dap") + local utils = require("modules.utils.dap") + + dap.adapters.lldb = { + type = "executable", + command = vim.fn.exepath("lldb-vscode"), -- Find lldb-vscode on $PATH + } + dap.configurations.c = { + { + name = "Launch", + type = "lldb", + request = "launch", + program = utils.input_exec_path(), + cwd = "${workspaceFolder}", + args = utils.input_args(), + env = utils.get_env(), + + -- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting: + -- + -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope + -- + -- Otherwise you might get the following error: + -- + -- Error on launch: Failed to attach to the target process + -- + -- But you should be aware of the implications: + -- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html + runInTerminal = false, + }, + } + + dap.configurations.cpp = dap.configurations.c + dap.configurations.rust = dap.configurations.c +end diff --git a/nvim/lua/modules/configs/tool/dap/clients/python.lua b/nvim/lua/modules/configs/tool/dap/clients/python.lua new file mode 100644 index 0000000..3ff35e5 --- /dev/null +++ b/nvim/lua/modules/configs/tool/dap/clients/python.lua @@ -0,0 +1,74 @@ +-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#python +-- https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings +return function() + local dap = require("dap") + local utils = require("modules.utils.dap") + local is_windows = require("core.global").is_windows + local debugpy_root = require("mason-registry").get_package("debugpy"):get_install_path() + + dap.adapters.python = function(callback, config) + if config.request == "attach" then + local port = (config.connect or config).port + local host = (config.connect or config).host or "127.0.0.1" + callback({ + type = "server", + port = assert(port, "`connect.port` is required for a python `attach` configuration"), + host = host, + options = { source_filetype = "python" }, + }) + else + callback({ + type = "executable", + command = is_windows and debugpy_root .. "/venv/Scripts/pythonw.exe" + or debugpy_root .. "/venv/bin/python", + args = { "-m", "debugpy.adapter" }, + options = { source_filetype = "python" }, + }) + end + end + dap.configurations.python = { + { + -- The first three options are required by nvim-dap + type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python` + request = "launch", + name = "Debug", + -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options + console = "integratedTerminal", + program = utils.input_file_path(), + pythonPath = function() + local venv = vim.env.CONDA_PREFIX + if venv then + return is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python" + else + return is_windows and "pythonw.exe" or "python3" + end + end, + }, + { + -- NOTE: This setting is for people using venv + type = "python", + request = "launch", + name = "Debug (using venv)", + -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options + console = "integratedTerminal", + program = utils.input_file_path(), + pythonPath = function() + -- Prefer the venv that is defined by the designated environment variable. + local cwd, venv = vim.fn.getcwd(), os.getenv("VIRTUAL_ENV") + local python = venv and (is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python") or "" + if vim.fn.executable(python) == 1 then + return python + end + + -- Otherwise, fall back to check if there are any local venvs available. + venv = vim.fn.isdirectory(cwd .. "/venv") == 1 and cwd .. "/venv" or cwd .. "/.venv" + python = is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python" + if vim.fn.executable(python) == 1 then + return python + else + return is_windows and "pythonw.exe" or "python3" + end + end, + }, + } +end diff --git a/nvim/lua/modules/configs/tool/dap/dap-keymap.lua b/nvim/lua/modules/configs/tool/dap/dap-keymap.lua new file mode 100644 index 0000000..bdaf08d --- /dev/null +++ b/nvim/lua/modules/configs/tool/dap/dap-keymap.lua @@ -0,0 +1,21 @@ +local M = {} + +local bind = require("keymap.bind") +local map_cmd = bind.map_cmd + +local did_load_debug_mappings = false +local debug_keymap = { + ["nv|K"] = map_cmd("lua require('dapui').eval()") + :with_noremap() + :with_nowait() + :with_desc("Evaluate expression under cursor"), +} + +function M.load_extras() + if not did_load_debug_mappings then + require("modules.utils.keymap").amend("Debugging", "_debugging", debug_keymap) + did_load_debug_mappings = true + end +end + +return M diff --git a/nvim/lua/modules/configs/tool/dap/dapui.lua b/nvim/lua/modules/configs/tool/dap/dapui.lua new file mode 100644 index 0000000..ab14dbc --- /dev/null +++ b/nvim/lua/modules/configs/tool/dap/dapui.lua @@ -0,0 +1,72 @@ +return function() + local icons = { + ui = require("modules.utils.icons").get("ui"), + dap = require("modules.utils.icons").get("dap"), + } + + require("modules.utils").load_plugin("dapui", { + force_buffers = true, + icons = { + expanded = icons.ui.ArrowOpen, + collapsed = icons.ui.ArrowClosed, + current_frame = icons.ui.Indicator, + }, + mappings = { + -- Use a table to apply multiple mappings + edit = "e", + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + repl = "r", + toggle = "t", + }, + layouts = { + { + elements = { + -- Provide as ID strings or tables with "id" and "size" keys + { + id = "scopes", + size = 0.3, -- Can be float or integer > 1 + }, + { id = "watches", size = 0.3 }, + { id = "stacks", size = 0.3 }, + { id = "breakpoints", size = 0.1 }, + }, + size = 0.3, + position = "right", + }, + { + elements = { + { id = "console", size = 0.55 }, + { id = "repl", size = 0.45 }, + }, + position = "bottom", + size = 0.25, + }, + }, + controls = { + enabled = true, + -- Display controls in this session + element = "repl", + icons = { + pause = icons.dap.Pause, + play = icons.dap.Play, + step_into = icons.dap.StepInto, + step_over = icons.dap.StepOver, + step_out = icons.dap.StepOut, + step_back = icons.dap.StepBack, + run_last = icons.dap.RunLast, + terminate = icons.dap.Terminate, + }, + }, + floating = { + max_height = nil, -- These can be integers or a float between 0 and 1. + max_width = nil, -- Floats will be treated as percentage of your screen. + border = "single", -- Border style. Can be "single", "double" or "rounded" + mappings = { + close = { "q", "" }, + }, + }, + render = { indent = 1, max_value_lines = 85 }, + }) +end diff --git a/nvim/lua/modules/configs/tool/dap/init.lua b/nvim/lua/modules/configs/tool/dap/init.lua new file mode 100644 index 0000000..f2fa42a --- /dev/null +++ b/nvim/lua/modules/configs/tool/dap/init.lua @@ -0,0 +1,84 @@ +return function() + local dap = require("dap") + local dapui = require("dapui") + local mason_dap = require("mason-nvim-dap") + + local icons = { dap = require("modules.utils.icons").get("dap") } + local colors = require("modules.utils").get_palette() + local mappings = require("tool.dap.dap-keymap") + + -- Initialize debug hooks + _G._debugging = false + local function debug_init_cb() + _G._debugging = true + mappings.load_extras() + dapui.open({ reset = true }) + end + local function debug_terminate_cb() + if _debugging then + _G._debugging = false + dapui.close() + end + end + dap.listeners.after.event_initialized["dapui_config"] = debug_init_cb + dap.listeners.before.event_terminated["dapui_config"] = debug_terminate_cb + dap.listeners.before.event_exited["dapui_config"] = debug_terminate_cb + dap.listeners.before.disconnect["dapui_config"] = debug_terminate_cb + + -- We need to override nvim-dap's default highlight groups, AFTER requiring nvim-dap for catppuccin. + vim.api.nvim_set_hl(0, "DapStopped", { fg = colors.green }) + + vim.fn.sign_define( + "DapBreakpoint", + { text = icons.dap.Breakpoint, texthl = "DapBreakpoint", linehl = "", numhl = "" } + ) + vim.fn.sign_define( + "DapBreakpointCondition", + { text = icons.dap.BreakpointCondition, texthl = "DapBreakpoint", linehl = "", numhl = "" } + ) + vim.fn.sign_define("DapStopped", { text = icons.dap.Stopped, texthl = "DapStopped", linehl = "", numhl = "" }) + vim.fn.sign_define( + "DapBreakpointRejected", + { text = icons.dap.BreakpointRejected, texthl = "DapBreakpoint", linehl = "", numhl = "" } + ) + vim.fn.sign_define("DapLogPoint", { text = icons.dap.LogPoint, texthl = "DapLogPoint", linehl = "", numhl = "" }) + + ---A handler to setup all clients defined under `tool/dap/clients/*.lua` + ---@param config table + local function mason_dap_handler(config) + local dap_name = config.name + local ok, custom_handler = pcall(require, "user.configs.dap-clients." .. dap_name) + if not ok then + -- Use preset if there is no user definition + ok, custom_handler = pcall(require, "tool.dap.clients." .. dap_name) + end + if not ok then + -- Default to use factory config for clients(s) that doesn't include a spec + mason_dap.default_setup(config) + return + elseif type(custom_handler) == "function" then + -- Case where the protocol requires its own setup + -- Make sure to set + -- * dap.adpaters. = { your config } + -- * dap.configurations. = { your config } + -- See `codelldb.lua` for a concrete example. + custom_handler(config) + else + vim.notify( + string.format( + "Failed to setup [%s].\n\nClient definition under `tool/dap/clients` must return\na fun(opts) (got '%s' instead)", + config.name, + type(custom_handler) + ), + vim.log.levels.ERROR, + { title = "nvim-dap" } + ) + end + end + + require("modules.utils").load_plugin("mason-nvim-dap", { + ensure_installed = require("core.settings").dap_deps, + automatic_installation = true, + handlers = { mason_dap_handler }, + }) +end diff --git a/nvim/lua/modules/configs/tool/dropbar.lua b/nvim/lua/modules/configs/tool/dropbar.lua new file mode 100644 index 0000000..a02dcaf --- /dev/null +++ b/nvim/lua/modules/configs/tool/dropbar.lua @@ -0,0 +1,109 @@ +return function() + local icons = { + kind = require("modules.utils.icons").get("kind", true), + type = require("modules.utils.icons").get("type", true), + misc = require("modules.utils.icons").get("misc", true), + ui = require("modules.utils.icons").get("ui", true), + } + + require("modules.utils").load_plugin("dropbar", { + bar = { + hover = false, + truncate = true, + pick = { pivots = "etovxqpdygfblzhckisuran" }, + }, + sources = { + path = { + relative_to = function() + -- Only show the leaf filename in dropbar + return vim.fn.expand("%:p:h") + end, + }, + terminal = { + name = function(buf) + local name = vim.api.nvim_buf_get_name(buf) + local term = select(2, require("toggleterm.terminal").identify(name)) + -- Trying to "snag" a display name from toggleterm + if term then + return term.display_name or term.name + else + return name + end + end, + }, + }, + icons = { + enable = true, + kinds = { + use_devicons = true, + symbols = { + -- Type + Array = icons.type.Array, + Boolean = icons.type.Boolean, + Null = icons.type.Null, + Number = icons.type.Number, + Object = icons.type.Object, + String = icons.type.String, + Text = icons.type.String, + + -- Kind + BreakStatement = icons.kind.Break, + Call = icons.kind.Call, + CaseStatement = icons.kind.Case, + Class = icons.kind.Class, + Color = icons.kind.Color, + Constant = icons.kind.Constant, + Constructor = icons.kind.Constructor, + ContinueStatement = icons.kind.Continue, + Declaration = icons.kind.Declaration, + Delete = icons.kind.Delete, + DoStatement = icons.kind.Loop, + Enum = icons.kind.Enum, + EnumMember = icons.kind.EnumMember, + Event = icons.kind.Event, + Field = icons.kind.Field, + File = icons.kind.File, + ForStatement = icons.kind.Loop, + Function = icons.kind.Function, + Identifier = icons.kind.Variable, + Interface = icons.kind.Interface, + Keyword = icons.kind.Keyword, + List = icons.kind.List, + Lsp = icons.misc.LspAvailable, + Method = icons.kind.Method, + Module = icons.kind.Module, + Namespace = icons.kind.Namespace, + Operator = icons.kind.Operator, + Package = icons.kind.Package, + Pair = icons.kind.List, + Property = icons.kind.Property, + Reference = icons.kind.Reference, + Regex = icons.kind.Regex, + Repeat = icons.kind.Loop, + Scope = icons.kind.Statement, + Snippet = icons.kind.Snippet, + Statement = icons.kind.Statement, + Struct = icons.kind.Struct, + SwitchStatement = icons.kind.Switch, + Type = icons.kind.Interface, + TypeParameter = icons.kind.TypeParameter, + Unit = icons.kind.Unit, + Value = icons.kind.Value, + Variable = icons.kind.Variable, + WhileStatement = icons.kind.Loop, + + -- Microsoft-specific icons + Folder = icons.kind.Folder, + + -- ccls-specific icons + Macro = icons.kind.Macro, + Terminal = icons.kind.Terminal, + }, + }, + ui = { + bar = { separator = "  " }, + menu = { indicator = icons.ui.ArrowClosed }, + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/tool/fcitx5.lua b/nvim/lua/modules/configs/tool/fcitx5.lua new file mode 100644 index 0000000..c8b10e1 --- /dev/null +++ b/nvim/lua/modules/configs/tool/fcitx5.lua @@ -0,0 +1,19 @@ +return function() + require("modules.utils").load_plugin("fcitx5", { + msg = nil, -- string | nil: printed when startup is completed + imname = { -- fcitx5.Imname | nil: imnames on each mode set as prior. See `:h map-table` for more in-depth information. + norm = nil, -- string | nil: imname to set in normal mode. if nil, will restore the mode on exit. + ins = nil, + cmd = nil, + vis = nil, + sel = nil, + opr = nil, + term = nil, + lang = nil, + }, + remember_prior = true, -- boolean: if true, it remembers the mode on exit and restore it when entering the mode again. + -- if false, uses what was set in config. + define_autocmd = true, -- boolean: if true, defines autocmd at `ModeChanged` to switch fcitx5 mode. + log = "warn", -- string: log level (default: warn) + }) +end diff --git a/nvim/lua/modules/configs/tool/nvim-tree.lua b/nvim/lua/modules/configs/tool/nvim-tree.lua new file mode 100644 index 0000000..fcf5288 --- /dev/null +++ b/nvim/lua/modules/configs/tool/nvim-tree.lua @@ -0,0 +1,201 @@ +return function() + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics"), + documents = require("modules.utils.icons").get("documents"), + git = require("modules.utils.icons").get("git"), + ui = require("modules.utils.icons").get("ui"), + } + + require("modules.utils").load_plugin("nvim-tree", { + auto_reload_on_write = true, + create_in_closed_folder = false, + disable_netrw = false, + hijack_cursor = true, + hijack_netrw = true, + hijack_unnamed_buffer_when_opening = true, + open_on_tab = false, + respect_buf_cwd = false, + sort_by = "name", + sync_root_with_cwd = true, + on_attach = function(bufnr) + require("nvim-tree.api").config.mappings.default_on_attach(bufnr) + vim.keymap.del("n", "", { buffer = bufnr }) + end, + view = { + adaptive_size = false, + centralize_selection = false, + width = 30, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + float = { + enable = false, + open_win_config = { + relative = "editor", + border = "rounded", + width = 30, + height = 30, + row = 1, + col = 1, + }, + }, + }, + renderer = { + add_trailing = false, + group_empty = true, + highlight_git = true, + full_name = false, + highlight_opened_files = "none", + special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md", "CMakeLists.txt" }, + symlink_destination = true, + indent_markers = { + enable = true, + icons = { + corner = "└ ", + edge = "│ ", + item = "│ ", + none = " ", + }, + }, + root_folder_label = ":.:s?.*?/..?", + icons = { + webdev_colors = true, + git_placement = "after", + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + }, + padding = " ", + symlink_arrow = " 󰁔 ", + glyphs = { + default = icons.documents.Default, -- + symlink = icons.documents.Symlink, -- + bookmark = icons.ui.Bookmark, + git = { + unstaged = icons.git.Mod_alt, + staged = icons.git.Add, --󰄬 + unmerged = icons.git.Unmerged, + renamed = icons.git.Rename, --󰁔 + untracked = icons.git.Untracked, -- "󰞋" + deleted = icons.git.Remove, -- + ignored = icons.git.Ignore, --◌ + }, + folder = { + arrow_open = icons.ui.ArrowOpen, + arrow_closed = icons.ui.ArrowClosed, + -- arrow_open = "", + -- arrow_closed = "", + default = icons.ui.Folder, + open = icons.ui.FolderOpen, + empty = icons.ui.EmptyFolder, + empty_open = icons.ui.EmptyFolderOpen, + symlink = icons.ui.SymlinkFolder, + symlink_open = icons.ui.FolderOpen, + }, + }, + }, + }, + hijack_directories = { + enable = true, + auto_open = true, + }, + update_focused_file = { + enable = true, + update_root = true, + ignore_list = {}, + }, + filters = { + dotfiles = false, + custom = { ".DS_Store" }, + exclude = {}, + }, + actions = { + use_system_clipboard = true, + change_dir = { + enable = true, + global = false, + }, + open_file = { + quit_on_open = false, + resize_window = false, + window_picker = { + enable = true, + chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", + exclude = { + buftype = { + "help", + "nofile", + "prompt", + "quickfix", + "terminal", + }, + filetype = { + "dap-repl", + "diff", + "fugitive", + "fugitiveblame", + "git", + "notify", + "NvimTree", + "Outline", + "qf", + "TelescopePrompt", + "toggleterm", + "undotree", + }, + }, + }, + }, + remove_file = { + close_window = true, + }, + }, + diagnostics = { + enable = false, + show_on_dirs = false, + debounce_delay = 50, + icons = { + hint = icons.diagnostics.Hint_alt, + info = icons.diagnostics.Information_alt, + warning = icons.diagnostics.Warning_alt, + error = icons.diagnostics.Error_alt, + }, + }, + filesystem_watchers = { + enable = true, + debounce_delay = 50, + }, + git = { + enable = true, + ignore = false, + show_on_dirs = true, + timeout = 400, + }, + trash = { + cmd = "gio trash", + require_confirm = true, + }, + live_filter = { + prefix = "[FILTER]: ", + always_show_folders = true, + }, + log = { + enable = false, + truncate = false, + types = { + all = false, + config = false, + copy_paste = false, + dev = false, + diagnostics = false, + git = false, + profile = false, + watcher = false, + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/tool/project.lua b/nvim/lua/modules/configs/tool/project.lua new file mode 100644 index 0000000..3d77ab7 --- /dev/null +++ b/nvim/lua/modules/configs/tool/project.lua @@ -0,0 +1,13 @@ +return function() + require("modules.utils").load_plugin("project_nvim", { + manual_mode = false, + detection_methods = { "lsp", "pattern" }, + patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" }, + ignore_lsp = { "null-ls", "copilot" }, + exclude_dirs = {}, + show_hidden = false, + silent_chdir = true, + scope_chdir = "global", + datapath = vim.fn.stdpath("data"), + }) +end diff --git a/nvim/lua/modules/configs/tool/search.lua b/nvim/lua/modules/configs/tool/search.lua new file mode 100644 index 0000000..ffad69c --- /dev/null +++ b/nvim/lua/modules/configs/tool/search.lua @@ -0,0 +1,141 @@ +return function() + local builtin = require("telescope.builtin") + local extensions = require("telescope").extensions + + require("modules.utils").load_plugin("search", { + collections = { + -- Search using filenames + file = { + initial_tab = 1, + tabs = { + { + name = "Files", + tele_func = function(opts) + opts = opts or {} + if vim.fn.isdirectory(".git") == 1 then + builtin.git_files(opts) + else + builtin.find_files(opts) + end + end, + }, + { + name = "Frecency", + tele_func = function() + extensions.frecency.frecency() + end, + }, + { + name = "Oldfiles", + tele_func = function() + builtin.oldfiles() + end, + }, + { + name = "Buffers", + tele_func = function() + builtin.buffers() + end, + }, + }, + }, + -- Search using patterns + pattern = { + initial_tab = 1, + tabs = { + { + name = "Word in project", + tele_func = function() + extensions.live_grep_args.live_grep_args() + end, + }, + { + name = "Word under cursor", + tele_func = function(opts) + opts = opts or {} + builtin.grep_string(opts) + end, + }, + }, + }, + -- Search Git objects (branches, commits) + git = { + initial_tab = 1, + tabs = { + { + name = "Branches", + tele_func = function() + builtin.git_branches() + end, + }, + { + name = "Commits", + tele_func = function() + builtin.git_commits() + end, + }, + { + name = "Commit content", + tele_func = function() + extensions.advanced_git_search.search_log_content() + end, + }, + { + name = "Diff current file with commit", + tele_func = function() + extensions.advanced_git_search.diff_commit_file() + end, + }, + }, + }, + -- Retrieve dossiers + dossier = { + initial_tab = 1, + tabs = { + { + name = "Sessions", + tele_func = function() + extensions.persisted.persisted() + end, + }, + { + name = "Projects", + tele_func = function() + extensions.projects.projects({}) + end, + }, + { + name = "Zoxide", + tele_func = function() + extensions.zoxide.list() + end, + }, + }, + }, + -- Miscellaneous + misc = { + initial_tab = 1, + tabs = { + { + name = "Colorschemes", + tele_func = function() + builtin.colorscheme({ enable_preview = true }) + end, + }, + { + name = "Notify", + tele_func = function() + extensions.notify.notify() + end, + }, + { + name = "Undo History", + tele_func = function() + extensions.undo.undo() + end, + }, + }, + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/tool/smartyank.lua b/nvim/lua/modules/configs/tool/smartyank.lua new file mode 100644 index 0000000..551ae6f --- /dev/null +++ b/nvim/lua/modules/configs/tool/smartyank.lua @@ -0,0 +1,24 @@ +return function() + require("modules.utils").load_plugin("smartyank", { + highlight = { + enabled = false, -- highlight yanked text + higroup = "IncSearch", -- highlight group of yanked text + timeout = 2000, -- timeout for clearing the highlight + }, + clipboard = { + enabled = true, + }, + tmux = { + enabled = true, + -- remove `-w` to disable copy to host client's clipboard + cmd = { "tmux", "set-buffer", "-w" }, + }, + osc52 = { + enabled = true, + escseq = "tmux", -- use tmux escape sequence, only enable if you're using remote tmux and have issues (see #4) + ssh_only = true, -- false to OSC52 yank also in local sessions + silent = false, -- true to disable the "n chars copied" echo + echo_hl = "Directory", -- highlight group of the OSC52 echo message + }, + }) +end diff --git a/nvim/lua/modules/configs/tool/sniprun.lua b/nvim/lua/modules/configs/tool/sniprun.lua new file mode 100644 index 0000000..78cb979 --- /dev/null +++ b/nvim/lua/modules/configs/tool/sniprun.lua @@ -0,0 +1,27 @@ +return function() + require("modules.utils").load_plugin("sniprun", { + selected_interpreters = {}, -- " use those instead of the default for the current filetype + repl_enable = {}, -- " enable REPL-like behavior for the given interpreters + repl_disable = {}, -- " disable REPL-like behavior for the given interpreters + interpreter_options = {}, -- " intepreter-specific options, consult docs / :SnipInfo + -- " you can combo different display modes as desired + display = { + "TempFloatingWindowOk", -- display ok results in the floating window + "NvimNotifyErr", -- display err results with the nvim-notify plugin + -- "Classic", -- display results in the command line" + -- "VirtualText", -- display results in virtual text" + -- "LongTempFloatingWindow", -- display results in the long floating window + -- "Terminal" -- display results in a vertical split + -- "TerminalWithCode" -- display results and code history in a vertical split + }, + display_options = { + terminal_width = 45, + notification_timeout = 5000, + }, + -- " miscellaneous compatibility/adjustement settings + inline_messages = 0, -- " inline_message (0/1) is a one-line way to display messages + -- " to workaround sniprun not being able to display anything + borders = "single", -- " display borders around floating windows + -- " possible values are 'none', 'single', 'double', or 'shadow' + }) +end diff --git a/nvim/lua/modules/configs/tool/telescope.lua b/nvim/lua/modules/configs/tool/telescope.lua new file mode 100644 index 0000000..71884d0 --- /dev/null +++ b/nvim/lua/modules/configs/tool/telescope.lua @@ -0,0 +1,102 @@ +return function() + local icons = { ui = require("modules.utils.icons").get("ui", true) } + local lga_actions = require("telescope-live-grep-args.actions") + + require("modules.utils").load_plugin("telescope", { + defaults = { + vimgrep_arguments = { + "rg", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + initial_mode = "insert", + prompt_prefix = " " .. icons.ui.Telescope .. " ", + selection_caret = icons.ui.ChevronRight, + scroll_strategy = "limit", + results_title = false, + layout_strategy = "horizontal", + path_display = { "absolute" }, + selection_strategy = "reset", + sorting_strategy = "ascending", + color_devicons = true, + file_ignore_patterns = { ".git/", ".cache", "build/", "%.class", "%.pdf", "%.mkv", "%.mp4", "%.zip" }, + layout_config = { + horizontal = { + prompt_position = "top", + preview_width = 0.55, + results_width = 0.8, + }, + vertical = { + mirror = false, + }, + width = 0.85, + height = 0.92, + preview_cutoff = 120, + }, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + file_sorter = require("telescope.sorters").get_fuzzy_file, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + }, + extensions = { + aerial = { + show_lines = false, + show_nesting = { + ["_"] = false, -- This key will be the default + lua = true, -- You can set the option for specific filetypes + }, + }, + fzf = { + fuzzy = false, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", + }, + frecency = { + show_scores = true, + show_unindexed = true, + ignore_patterns = { "*.git/*", "*/tmp/*" }, + }, + live_grep_args = { + auto_quoting = true, -- enable/disable auto-quoting + mappings = { -- extend mappings + i = { + [""] = lga_actions.quote_prompt(), + [""] = lga_actions.quote_prompt({ postfix = " --iglob " }), + }, + }, + }, + undo = { + side_by_side = true, + mappings = { + i = { + [""] = require("telescope-undo.actions").yank_additions, + [""] = require("telescope-undo.actions").yank_deletions, + [""] = require("telescope-undo.actions").restore, + }, + }, + }, + advanced_git_search = { + diff_plugin = "diffview", + git_flags = { "-c", "delta.side-by-side=true" }, + entry_default_author_or_date = "author", -- one of "author" or "date" + }, + }, + }) + + require("telescope").load_extension("frecency") + require("telescope").load_extension("fzf") + require("telescope").load_extension("live_grep_args") + require("telescope").load_extension("notify") + require("telescope").load_extension("projects") + require("telescope").load_extension("undo") + require("telescope").load_extension("zoxide") + require("telescope").load_extension("persisted") + require("telescope").load_extension("aerial") + require("telescope").load_extension("advanced_git_search") +end diff --git a/nvim/lua/modules/configs/tool/toggleterm.lua b/nvim/lua/modules/configs/tool/toggleterm.lua new file mode 100644 index 0000000..8e12a29 --- /dev/null +++ b/nvim/lua/modules/configs/tool/toggleterm.lua @@ -0,0 +1,51 @@ +return function() + require("modules.utils").load_plugin("toggleterm", { + -- size can be a number or function which is passed the current terminal + size = function(term) + if term.direction == "horizontal" then + return vim.o.lines * 0.30 + elseif term.direction == "vertical" then + return vim.o.columns * 0.40 + end + end, + on_open = function(term) + -- Prevent infinite calls from freezing neovim. + -- Only set these options specific to this terminal buffer. + vim.api.nvim_set_option_value("foldmethod", "manual", { scope = "local" }) + vim.api.nvim_set_option_value("foldexpr", "0", { scope = "local" }) + + -- Prevent horizontal terminal from obscuring `nvim-tree`. + local api = require("nvim-tree.api") + local tree = require("nvim-tree.view") + if tree.is_visible() and term.direction == "horizontal" then + local width = vim.fn.winwidth(tree.get_winnr()) + api.tree.toggle() + tree.View.width = width + api.tree.toggle(false, true) + end + end, + highlights = { + Normal = { + link = "Normal", + }, + NormalFloat = { + link = "NormalFloat", + }, + FloatBorder = { + link = "FloatBorder", + }, + }, + open_mapping = false, -- [[]], + hide_numbers = true, -- hide the number column in toggleterm buffers + shade_filetypes = {}, + shade_terminals = false, + shading_factor = "1", -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light + start_in_insert = true, + persist_mode = false, + insert_mappings = true, -- whether or not the open mapping applies in insert mode + persist_size = true, + direction = "horizontal", + close_on_exit = true, -- close the terminal window when the process exits + shell = vim.o.shell, -- change the default shell + }) +end diff --git a/nvim/lua/modules/configs/tool/trouble.lua b/nvim/lua/modules/configs/tool/trouble.lua new file mode 100644 index 0000000..6a9bbfc --- /dev/null +++ b/nvim/lua/modules/configs/tool/trouble.lua @@ -0,0 +1,38 @@ +return function() + local icons = { + ui = require("modules.utils.icons").get("ui", true), + } + + require("modules.utils").load_plugin("trouble", { + auto_open = false, + auto_close = false, + auto_jump = false, + auto_preview = true, + auto_refresh = true, + focus = false, -- do not focus the window when opened + follow = true, + restore = true, + icons = { + indent = { + fold_open = icons.ui.ArrowOpen, + fold_closed = icons.ui.ArrowClosed, + }, + folder_closed = icons.ui.Folder, + folder_open = icons.ui.FolderOpen, + }, + modes = { + project_diagnostics = { + mode = "diagnostics", + filter = { + any = { + { + function(item) + return item.filename:find(vim.fn.getcwd(), 1, true) + end, + }, + }, + }, + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/tool/which-key.lua b/nvim/lua/modules/configs/tool/which-key.lua new file mode 100644 index 0000000..c9d687e --- /dev/null +++ b/nvim/lua/modules/configs/tool/which-key.lua @@ -0,0 +1,71 @@ +return function() + local icons = { + ui = require("modules.utils.icons").get("ui"), + misc = require("modules.utils.icons").get("misc"), + git = require("modules.utils.icons").get("git", true), + cmp = require("modules.utils.icons").get("cmp", true), + } + + require("which-key").register({ + [""] = { + b = { + name = icons.ui.Buffer .. " Buffer", + }, + d = { + name = icons.ui.Bug .. " Debug", + }, + f = { + name = icons.ui.Telescope .. " Fuzzy Find", + }, + g = { + name = icons.git.Git .. "Git", + }, + l = { + name = icons.misc.LspAvailable .. " Lsp", + }, + n = { + name = icons.ui.FolderOpen .. " Nvim Tree", + }, + p = { + name = icons.ui.Package .. " Package", + }, + s = { + name = icons.cmp.tmux .. "Session", + }, + S = { + name = icons.ui.Search .. " Search", + }, + W = { + name = icons.ui.Window .. " Window", + }, + }, + }) + + require("modules.utils").load_plugin("which-key", { + plugins = { + presets = { + operators = false, + motions = false, + text_objects = false, + windows = false, + nav = false, + z = true, + g = true, + }, + }, + + icons = { + breadcrumb = icons.ui.Separator, + separator = icons.misc.Vbar, + group = "", + }, + + window = { + border = "none", + position = "bottom", + margin = { 1, 0, 1, 0 }, + padding = { 1, 1, 1, 1 }, + winblend = 0, + }, + }) +end diff --git a/nvim/lua/modules/configs/tool/wilder.lua b/nvim/lua/modules/configs/tool/wilder.lua new file mode 100644 index 0000000..45105b3 --- /dev/null +++ b/nvim/lua/modules/configs/tool/wilder.lua @@ -0,0 +1,65 @@ +return function() + local wilder = require("wilder") + local icons = { ui = require("modules.utils.icons").get("ui") } + + wilder.set_option("use_python_remote_plugin", 0) + wilder.set_option("pipeline", { + wilder.branch( + wilder.cmdline_pipeline({ use_python = 0, fuzzy = 1, fuzzy_filter = wilder.lua_fzy_filter() }), + wilder.vim_search_pipeline(), + { + wilder.check(function(_, x) + return x == "" + end), + wilder.history(), + wilder.result({ + draw = { + function(_, x) + return icons.ui.Calendar .. " " .. x + end, + }, + }), + } + ), + }) + + local popupmenu_renderer = wilder.popupmenu_renderer(wilder.popupmenu_border_theme({ + border = "rounded", + highlights = { + default = "Pmenu", + border = "PmenuBorder", -- highlight to use for the border + accent = wilder.make_hl("WilderAccent", "CmpItemAbbr", "CmpItemAbbrMatch"), + }, + empty_message = wilder.popupmenu_empty_message_with_spinner(), + highlighter = wilder.lua_fzy_highlighter(), + left = { + " ", + wilder.popupmenu_devicons(), + wilder.popupmenu_buffer_flags({ + flags = " a + ", + icons = { ["+"] = icons.ui.Pencil, a = icons.ui.Indicator, h = icons.ui.File }, + }), + }, + right = { + " ", + wilder.popupmenu_scrollbar(), + }, + })) + local wildmenu_renderer = wilder.wildmenu_renderer({ + apply_incsearch_fix = false, + highlighter = wilder.lua_fzy_highlighter(), + separator = " | ", + left = { " ", wilder.wildmenu_spinner(), " " }, + right = { " ", wilder.wildmenu_index() }, + }) + wilder.set_option( + "renderer", + wilder.renderer_mux({ + [":"] = popupmenu_renderer, + ["/"] = wildmenu_renderer, + substitute = wildmenu_renderer, + }) + ) + + require("modules.utils").load_plugin("wilder", { modes = { ":", "/", "?" } }) +end diff --git a/nvim/lua/modules/configs/ui/alpha.lua b/nvim/lua/modules/configs/ui/alpha.lua new file mode 100644 index 0000000..befcbd2 --- /dev/null +++ b/nvim/lua/modules/configs/ui/alpha.lua @@ -0,0 +1,138 @@ +return function() + local dashboard = require("alpha.themes.dashboard") + require("modules.utils").gen_alpha_hl() + + dashboard.section.header.val = require("core.settings").dashboard_image + dashboard.section.header.opts.hl = "AlphaHeader" + + local function button(sc, txt, leader_txt, keybind, keybind_opts) + local sc_after = sc:gsub("%s", ""):gsub(leader_txt, "") + + local opts = { + position = "center", + shortcut = sc, + cursor = 5, + width = 50, + align_shortcut = "right", + hl = "AlphaButtons", + hl_shortcut = "AlphaShortcut", + } + + if nil == keybind then + keybind = sc_after + end + keybind_opts = vim.F.if_nil(keybind_opts, { noremap = true, silent = true, nowait = true }) + opts.keymap = { "n", sc_after, keybind, keybind_opts } + + local function on_press() + -- local key = vim.api.nvim_replace_termcodes(keybind .. '', true, false, true) + local key = vim.api.nvim_replace_termcodes(sc_after .. "", true, false, true) + vim.api.nvim_feedkeys(key, "t", false) + end + + return { + type = "button", + val = txt, + on_press = on_press, + opts = opts, + } + end + + local leader = " " + local icons = { + documents = require("modules.utils.icons").get("documents", true), + git = require("modules.utils.icons").get("git", true), + ui = require("modules.utils.icons").get("ui", true), + misc = require("modules.utils.icons").get("misc", true), + } + + dashboard.section.buttons.val = { + button( + "space f c", + icons.misc.Neovim .. "Telescope collections", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f f", + icons.documents.FileFind .. "Find files", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f d", + icons.ui.FolderWithHeart .. "Retrieve dossiers", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f p", + icons.documents.Word .. "Find patterns", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f g", + icons.git.Git .. "Locate Git objects", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f m", + icons.misc.Ghost .. "Miscellaneous artifacts", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + } + dashboard.section.buttons.opts.hl = "AlphaButtons" + + local function footer() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return "  Have Fun with neovim" + .. " 󰀨 v" + .. vim.version().major + .. "." + .. vim.version().minor + .. "." + .. vim.version().patch + .. " 󰂖 " + .. stats.count + .. " plugins in " + .. ms + .. "ms" + end + + dashboard.section.footer.val = footer() + dashboard.section.footer.opts.hl = "AlphaFooter" + + local head_butt_padding = 2 + local occu_height = #dashboard.section.header.val + 2 * #dashboard.section.buttons.val + head_butt_padding + local header_padding = math.max(0, math.ceil((vim.fn.winheight(0) - occu_height) * 0.25)) + local foot_butt_padding = 1 + + dashboard.config.layout = { + { type = "padding", val = header_padding }, + dashboard.section.header, + { type = "padding", val = head_butt_padding }, + dashboard.section.buttons, + { type = "padding", val = foot_butt_padding }, + dashboard.section.footer, + } + + require("modules.utils").load_plugin("alpha", dashboard.opts) + + vim.api.nvim_create_autocmd("User", { + pattern = "LazyVimStarted", + callback = function() + dashboard.section.footer.val = footer() + pcall(vim.cmd.AlphaRedraw) + end, + }) +end diff --git a/nvim/lua/modules/configs/ui/bufferline.lua b/nvim/lua/modules/configs/ui/bufferline.lua new file mode 100644 index 0000000..b01200d --- /dev/null +++ b/nvim/lua/modules/configs/ui/bufferline.lua @@ -0,0 +1,73 @@ +return function() + local icons = { ui = require("modules.utils.icons").get("ui") } + + local opts = { + options = { + number = nil, + close_command = "BufDel! %d", + right_mouse_command = "BufDel! %d", + modified_icon = icons.ui.Modified, + buffer_close_icon = icons.ui.Close, + left_trunc_marker = icons.ui.Left, + right_trunc_marker = icons.ui.Right, + max_name_length = 20, + max_prefix_length = 13, + tab_size = 20, + color_icons = true, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + show_tab_indicators = true, + enforce_regular_tabs = false, + persist_buffer_sort = true, + always_show_bufferline = true, + separator_style = "thin", + diagnostics = "nvim_lsp", + diagnostics_indicator = function(count) + return "(" .. count .. ")" + end, + offsets = { + { + filetype = "NvimTree", + text = "File Explorer", + text_align = "center", + padding = 0, + }, + { + filetype = "aerial", + text = "Symbol Outline", + text_align = "center", + padding = 0, + }, + }, + }, + -- Change bufferline's highlights here! See `:h bufferline-highlights` for detailed explanation. + -- Note: If you use catppuccin then modify the colors below! + highlights = {}, + } + + if vim.g.colors_name:find("catppuccin") then + local cp = require("modules.utils").get_palette() -- Get the palette. + + local catppuccin_hl_overwrite = { + highlights = require("catppuccin.groups.integrations.bufferline").get({ + styles = { "italic", "bold" }, + custom = { + all = { + -- Hint + hint = { fg = cp.rosewater }, + hint_visible = { fg = cp.rosewater }, + hint_selected = { fg = cp.rosewater }, + hint_diagnostic = { fg = cp.rosewater }, + hint_diagnostic_visible = { fg = cp.rosewater }, + hint_diagnostic_selected = { fg = cp.rosewater }, + }, + }, + }), + } + + opts = vim.tbl_deep_extend("force", opts, catppuccin_hl_overwrite) + end + + require("modules.utils").load_plugin("bufferline", opts) +end diff --git a/nvim/lua/modules/configs/ui/catppuccin.lua b/nvim/lua/modules/configs/ui/catppuccin.lua new file mode 100644 index 0000000..c0a9048 --- /dev/null +++ b/nvim/lua/modules/configs/ui/catppuccin.lua @@ -0,0 +1,182 @@ +return function() + local transparent_background = require("core.settings").transparent_background + local clear = {} + + require("modules.utils").load_plugin("catppuccin", { + background = { light = "latte", dark = "mocha" }, -- latte, frappe, macchiato, mocha + dim_inactive = { + enabled = false, + -- Dim inactive splits/windows/buffers. + -- NOT recommended if you use old palette (a.k.a., mocha). + shade = "dark", + percentage = 0.15, + }, + transparent_background = transparent_background, + show_end_of_buffer = false, -- show the '~' characters after the end of buffers + term_colors = true, + compile_path = vim.fn.stdpath("cache") .. "/catppuccin", + styles = { + comments = { "italic" }, + functions = { "bold" }, + keywords = { "italic" }, + operators = { "bold" }, + conditionals = { "bold" }, + loops = { "bold" }, + booleans = { "bold", "italic" }, + numbers = {}, + types = {}, + strings = {}, + variables = {}, + properties = {}, + }, + integrations = { + treesitter = true, + native_lsp = { + enabled = true, + virtual_text = { + errors = { "italic" }, + hints = { "italic" }, + warnings = { "italic" }, + information = { "italic" }, + }, + underlines = { + errors = { "underline" }, + hints = { "underline" }, + warnings = { "underline" }, + information = { "underline" }, + }, + }, + aerial = true, + alpha = false, + barbar = false, + beacon = false, + cmp = true, + coc_nvim = false, + dap = true, + dap_ui = true, + dashboard = false, + dropbar = { enabled = true, color_mode = true }, + fern = false, + fidget = true, + flash = true, + gitgutter = false, + gitsigns = true, + harpoon = false, + headlines = false, + hop = true, + illuminate = true, + indent_blankline = { enabled = true, colored_indent_levels = false }, + leap = false, + lightspeed = false, + lsp_saga = true, + lsp_trouble = true, + markdown = true, + mason = true, + mini = false, + navic = { enabled = false }, + neogit = false, + neotest = false, + neotree = { enabled = false, show_root = true, transparent_panel = false }, + noice = false, + notify = true, + nvimtree = true, + overseer = false, + pounce = false, + rainbow_delimiters = true, + sandwich = false, + semantic_tokens = true, + symbols_outline = false, + telekasten = false, + telescope = { enabled = true, style = "nvchad" }, + treesitter_context = true, + ts_rainbow = false, + vim_sneak = false, + vimwiki = false, + which_key = true, + }, + color_overrides = {}, + highlight_overrides = { + ---@param cp palette + all = function(cp) + return { + -- For base configs + NormalFloat = { fg = cp.text, bg = transparent_background and cp.none or cp.mantle }, + FloatBorder = { + fg = transparent_background and cp.blue or cp.mantle, + bg = transparent_background and cp.none or cp.mantle, + }, + CursorLineNr = { fg = cp.green }, + + -- For native lsp configs + DiagnosticVirtualTextError = { bg = cp.none }, + DiagnosticVirtualTextWarn = { bg = cp.none }, + DiagnosticVirtualTextInfo = { bg = cp.none }, + DiagnosticVirtualTextHint = { bg = cp.none }, + LspInfoBorder = { link = "FloatBorder" }, + + -- For mason.nvim + MasonNormal = { link = "NormalFloat" }, + + -- For indent-blankline + IblIndent = { fg = cp.surface0 }, + IblScope = { fg = cp.surface2, style = { "bold" } }, + + -- For nvim-cmp and wilder.nvim + Pmenu = { fg = cp.overlay2, bg = transparent_background and cp.none or cp.base }, + PmenuBorder = { fg = cp.surface1, bg = transparent_background and cp.none or cp.base }, + PmenuSel = { bg = cp.green, fg = cp.base }, + CmpItemAbbr = { fg = cp.overlay2 }, + CmpItemAbbrMatch = { fg = cp.blue, style = { "bold" } }, + CmpDoc = { link = "NormalFloat" }, + CmpDocBorder = { + fg = transparent_background and cp.surface1 or cp.mantle, + bg = transparent_background and cp.none or cp.mantle, + }, + + -- For fidget + FidgetTask = { bg = cp.none, fg = cp.surface2 }, + FidgetTitle = { fg = cp.blue, style = { "bold" } }, + + -- For nvim-notify + NotifyBackground = { bg = cp.base }, + + -- For nvim-tree + NvimTreeRootFolder = { fg = cp.pink }, + NvimTreeIndentMarker = { fg = cp.surface2 }, + + -- For trouble.nvim + TroubleNormal = { bg = transparent_background and cp.none or cp.base }, + TroubleNormalNC = { bg = transparent_background and cp.none or cp.base }, + + -- For telescope.nvim + TelescopeMatching = { fg = cp.lavender }, + TelescopeResultsDiffAdd = { fg = cp.green }, + TelescopeResultsDiffChange = { fg = cp.yellow }, + TelescopeResultsDiffDelete = { fg = cp.red }, + + -- For glance.nvim + GlanceWinBarFilename = { fg = cp.subtext1, style = { "bold" } }, + GlanceWinBarFilepath = { fg = cp.subtext0, style = { "italic" } }, + GlanceWinBarTitle = { fg = cp.teal, style = { "bold" } }, + GlanceListCount = { fg = cp.lavender }, + GlanceListFilepath = { link = "Comment" }, + GlanceListFilename = { fg = cp.blue }, + GlanceListMatch = { fg = cp.lavender, style = { "bold" } }, + GlanceFoldIcon = { fg = cp.green }, + + -- For nvim-treehopper + TSNodeKey = { + fg = cp.peach, + bg = transparent_background and cp.none or cp.base, + style = { "bold", "underline" }, + }, + + -- For treesitter + ["@keyword.return"] = { fg = cp.pink, style = clear }, + ["@error.c"] = { fg = cp.none, style = clear }, + ["@error.cpp"] = { fg = cp.none, style = clear }, + } + end, + }, + }) +end diff --git a/nvim/lua/modules/configs/ui/fidget.lua b/nvim/lua/modules/configs/ui/fidget.lua new file mode 100644 index 0000000..ee920a3 --- /dev/null +++ b/nvim/lua/modules/configs/ui/fidget.lua @@ -0,0 +1,25 @@ +return function() + local icons = { + ui = require("modules.utils.icons").get("ui"), + } + + require("modules.utils").load_plugin("fidget", { + progress = { + suppress_on_insert = false, -- Suppress new messages while in insert mode + ignore_done_already = false, -- Ignore new tasks that are already complete + ignore = { "null-ls" }, -- List of LSP servers to ignore + display = { + render_limit = 5, -- How many LSP messages to show at once + done_ttl = 2, -- How long a message should persist after completion + done_icon = icons.ui.Accepted, -- Icon shown when all LSP progress tasks are complete + }, + }, + notification = { + override_vim_notify = false, -- Automatically override vim.notify() with Fidget + window = { + winblend = 0, -- Background color opacity in the notification window + zindex = 75, -- Stacking priority of the notification window + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/ui/gitsigns.lua b/nvim/lua/modules/configs/ui/gitsigns.lua new file mode 100644 index 0000000..de14cd5 --- /dev/null +++ b/nvim/lua/modules/configs/ui/gitsigns.lua @@ -0,0 +1,23 @@ +return function() + local mapping = require("keymap.ui") + require("modules.utils").load_plugin("gitsigns", { + signs = { + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, + }, + auto_attach = true, + on_attach = mapping.gitsigns, + signcolumn = true, + sign_priority = 6, + update_debounce = 100, + word_diff = false, + current_line_blame = true, + diff_opts = { internal = true }, + watch_gitdir = { follow_files = true }, + current_line_blame_opts = { delay = 1000, virt_text = true, virtual_text_pos = "eol" }, + }) +end diff --git a/nvim/lua/modules/configs/ui/indent-blankline.lua b/nvim/lua/modules/configs/ui/indent-blankline.lua new file mode 100644 index 0000000..169a56f --- /dev/null +++ b/nvim/lua/modules/configs/ui/indent-blankline.lua @@ -0,0 +1,578 @@ +return function() + -- This list delineates the per-language nodes used for guiding |ibl| in highlighting the current scope + -- It is extracted from each language's `indents.scm` file + -- NOTE: Only a subset of the supported programming languages is included + -- If your preferred language isn't listed, you can add it to the user config + local nodes = { + bibtex = { + "entry", + }, + c = { + "case_statement", + "compound_literal_expression", + "enumerator_list", + "field_declaration_list", + "initializer_list", + "init_declarator", + }, + cmake = { + "block_def", + "foreach_loop", + "function_def", + "if_condition", + "macro_def", + "normal_command", + "while_loop", + }, + cpp = { + "case_statement", + "compound_literal_expression", + "condition_clause", + "enumerator_list", + "field_declaration_list", + "field_initializer_list", + "init_declarator", + "initializer_list", + "namespace_definition", + }, + css = { + "block", + "declaration", + }, + d = { + "aggregate_body", + "block_statement", + "case_statement", + "expression_statement", + "function_body", + "parameters", + "scope_statement", + "template_parameters", + }, + dart = { + "arguments", + "class_body", + "formal_parameter", + "formal_parameter_list", + "function_body", + "function_expression_body", + "initializers", + "list_literal", + "return_statement", + "switch_block", + }, + dot = { + "block", + "attr_list", + }, + ecma = { + "arguments", + "array", + "binary_expression", + "call_expression", + "class_body", + "export_clause", + "formal_parameters", + "named_imports", + "object", + "object_pattern", + "parenthesized_expression", + "return_statement", + "switch_case", + "switch_default", + "switch_statement", + "template_substitution", + "ternary_expression", + }, + elixir = { + "arguments", + "block", + "do_block", + "list", + "map", + "tuple", + }, + firrtl = { + "memory", + }, + fortran = { + "derived_type_definition", + "do_loop_statement", + "enum", + "function", + "if_statement", + "module", + "program", + "subroutine", + "where_statement", + }, + gleam = { + "anonymous_function", + "assert", + "case", + "constant", + "external_function", + "function", + "import", + "let", + "list", + "constant", + "function", + "type_definition", + "type_alias", + "todo", + "tuple", + }, + go = { + "call_expression", + "communication_case", + "const_declaration", + "default_case", + "expression_case", + "import_declaration", + "literal_value", + "parameter_list", + "struct_type", + "type_case", + "type_declaration", + "var_declaration", + }, + html = { + "start_tag", + "self_closing_tag", + }, + java = { + "annotation_argument_list", + "annotation_type_body", + "argument_list", + "array_initializer", + "class_body", + "constructor_body", + "element_value_array_initializer", + "enum_body", + "formal_parameters", + "interface_body", + "method_invocation", + "switch_block", + }, + javascript = { + "arguments", + "array", + "binary_expression", + "call_expression", + "class_body", + "export_clause", + "formal_parameters", + "jsx_expression", + "jsx_self_closing_element", + "named_imports", + "object", + "object_pattern", + "parenthesized_expression", + "return_statement", + "switch_case", + "switch_default", + "switch_statement", + "template_substitution", + "ternary_expression", + }, + julia = { + "assignment", + "call_expression", + "compound_statement", + "comprehension_expression", + "for_binding", + "if_statement", + "matrix_expression", + "parenthesized_expression", + "struct_definition", + "tuple_expression", + "vector_expression", + }, + just = { + "external_command", + "recipe", + "string", + }, + linkerscript = { + "memory_command", + "output_section", + "phdrs_command", + "sections_command", + }, + lua = { + "arguments", + "field", + "method_index_expression", + "return_statement", + "table_constructor", + }, + matlab = { + "class_definition", + "enumeration", + "events", + "for_statement", + "if_statement", + "methods", + "properties", + "switch_statement", + "try_statement", + "while_statement", + }, + ninja = { + "build", + "pool", + "rule", + }, + ocaml = { + "application_expression", + "do_clause", + "external", + "field_expression", + "if_expression", + "list_expression", + "parenthesized_expression", + "record_declaration", + "record_expression", + "try_expression", + "type_binding", + "value_specification", + }, + pascal = { + "arrInitializer", + "block", + "declArgs", + "declClass", + "declConsts", + "declProc", + "declTypes", + "declUses", + "declVars", + "defaultValue", + "exprArgs", + "exprBrackets", + "exprParens", + "exprSubscript", + "recInitializer", + "statement", + }, + php = { + "arguments", + "array_creation_expression", + "binary_expression", + "case_statement", + "compound_statement", + "declaration_list", + "default_statement", + "enum_declaration_list", + "formal_parameters", + "match_block", + "member_call_expression", + "parenthesized_expression", + "return_statement", + "switch_block", + }, + python = { + "binary_operator", + "case_clause", + "concatenated_string", + "for_statement", + "generator_expression", + "if_statement", + "import_from_statement", + "lambda", + "list_pattern", + "match_statement", + "parenthesized_expression", + "try_statement", + "tuple_pattern", + "while_statement", + "with_statement", + }, + query = { + "list", + "predicate", + }, + r = { + "brace_list", + "call", + "paren_list", + "pipe", + "special", + }, + readline = { + "conditional_construct", + }, + ruby = { + "argument_list", + "array", + "assignment", + "begin", + "call", + "case", + "for", + "hash", + "if", + "module", + "parenthesized_statements", + "singleton_class", + "singleton_method", + "unless", + "until", + "while", + }, + rust = { + "arguments", + "array_expression", + "assignment_expression", + "call_expression", + "enum_variant_list", + "field_declaration_list", + "macro_definition", + "match_block", + "mod_item", + "ordered_field_declaration_list", + "parameters", + "struct_expression", + "struct_pattern", + "token_repetition", + "token_tree", + "trait_item", + "tuple_expression", + "tuple_pattern", + "tuple_struct_pattern", + "tuple_type", + "use_list", + "where_clause", + }, + scss = { + "block", + "declaration", + "each_statement", + "mixin_statement", + "while_statement", + }, + sql = { + "case", + "column_definitions", + "cte", + "insert", + "select", + "subquery", + "when_clause", + }, + ssh_config = { + "host_declaration", + "match_declaration", + }, + swift = { + "array_literal", + "array_type", + "assignment", + "call_expression", + "class_body", + "computed_getter", + "computed_property", + "computed_setter", + "control_transfer_statement", + "deinit_declaration", + "dictionary_literal", + "dictionary_type", + "didset_clause", + "enum_class_body", + "init_declaration", + "lambda_literal", + "protocol_body", + "subscript_declaration", + "tuple_expression", + "tuple_type", + "type_parameters", + "willset_clause", + "willset_didset_block", + }, + tablegen = { + "assert", + "value_suffix", + }, + tcl = { + "braced_word_simple", + "command", + "command_substitution", + "conditional", + "foreach", + "namespace", + "procedure", + "try", + "while", + }, + teal = { + "record_declaration", + "function_body", + "table_constructor", + "return_statement", + "while_statement", + }, + terraform = { + "block", + "function_call", + "object", + "tuple", + }, + textproto = { + "message_list", + "message_value", + "scalar_list", + }, + toml = { + "array", + "inline_table", + }, + typescript = { + "arguments", + "array", + "binary_expression", + "call_expression", + "class_body", + "enum_declaration", + "export_clause", + "formal_parameters", + "interface_declaration", + "named_imports", + "object", + "object_pattern", + "object_type", + "parenthesized_expression", + "return_statement", + "switch_case", + "switch_default", + "switch_statement", + "template_substitution", + "ternary_expression", + }, + vue = { + "start_tag", + }, + xml = { + "element", + }, + zig = { + "Block", + "ContainerDecl", + "InitList", + "SwitchExpr", + }, + } + + require("modules.utils").load_plugin("ibl", { + enabled = true, + debounce = 200, + indent = { + char = "│", + tab_char = "│", + smart_indent_cap = true, + priority = 2, + }, + whitespace = { remove_blankline_trail = true }, + -- Note: The `scope` field requires treesitter to be set up + scope = { + enabled = true, + char = "┃", + show_start = false, + show_end = false, + injected_languages = true, + priority = 1000, + include = { + node_type = { + angular = nodes.html, + arduino = nodes.cpp, + astro = nodes.html, + bibtex = nodes.bibtex, + c = nodes.c, + cmake = nodes.cmake, + cpp = nodes.cpp, + css = nodes.css, + cuda = nodes.cpp, + d = nodes.d, + dart = nodes.dart, + dot = nodes.dot, + ecma = nodes.ecma, + elixir = nodes.elixir, + firrtl = nodes.firrtl, + fortran = nodes.fortran, + glsl = nodes.c, + gleam = nodes.gleam, + go = nodes.go, + hlsl = nodes.cpp, + html = nodes.html, + java = nodes.java, + javascript = nodes.javascript, + julia = nodes.julia, + just = nodes.just, + linkerscript = nodes.linkerscript, + lua = nodes.lua, + luau = nodes.lua, + matlab = nodes.matlab, + ninja = nodes.ninja, + objc = nodes.c, + ocaml = nodes.ocaml, + ocaml_interface = nodes.ocaml, + pascal = nodes.pascal, + php = nodes.php, + python = nodes.python, + query = nodes.query, + r = nodes.r, + readline = nodes.readline, + ruby = nodes.ruby, + rust = nodes.rust, + scss = nodes.scss, + sql = nodes.sql, + ssh_config = nodes.ssh_config, + swift = nodes.swift, + tablegen = nodes.tablegen, + tcl = nodes.tcl, + teal = nodes.teal, + terraform = nodes.terraform, + textproto = nodes.textproto, + toml = nodes.toml, + typescript = nodes.typescript, + vue = nodes.vue, + xml = nodes.xml, + zig = nodes.zig, + }, + }, + }, + exclude = { + buftypes = { + "help", + "nofile", + "prompt", + "quickfix", + "terminal", + }, + filetypes = { + "", -- for all buffers without a file type + "alpha", + "bigfile", + "checkhealth", + "dap-repl", + "diff", + "fugitive", + "fugitiveblame", + "git", + "gitcommit", + "help", + "log", + "markdown", + "notify", + "NvimTree", + "Outline", + "qf", + "TelescopePrompt", + "text", + "toggleterm", + "undotree", + "vimwiki", + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/ui/lualine.lua b/nvim/lua/modules/configs/ui/lualine.lua new file mode 100644 index 0000000..39e4b89 --- /dev/null +++ b/nvim/lua/modules/configs/ui/lualine.lua @@ -0,0 +1,347 @@ +return function() + local has_catppuccin = vim.g.colors_name:find("catppuccin") ~= nil + local colors = require("modules.utils").get_palette() + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics", true), + git = require("modules.utils.icons").get("git", true), + git_nosep = require("modules.utils.icons").get("git"), + misc = require("modules.utils.icons").get("misc", true), + ui = require("modules.utils.icons").get("ui", true), + } + + local function custom_theme() + vim.api.nvim_create_autocmd("ColorScheme", { + group = vim.api.nvim_create_augroup("LualineColorScheme", { clear = true }), + pattern = "*", + callback = function() + has_catppuccin = vim.g.colors_name:find("catppuccin") ~= nil + require("lualine").setup({ options = { theme = custom_theme() } }) + end, + }) + + if has_catppuccin then + colors = require("modules.utils").get_palette() + local universal_bg = require("core.settings").transparent_background and "NONE" or colors.mantle + return { + normal = { + a = { fg = colors.lavender, bg = colors.surface0, gui = "bold" }, + b = { fg = colors.text, bg = universal_bg }, + c = { fg = colors.text, bg = universal_bg }, + }, + command = { + a = { fg = colors.peach, bg = colors.surface0, gui = "bold" }, + }, + insert = { + a = { fg = colors.green, bg = colors.surface0, gui = "bold" }, + }, + visual = { + a = { fg = colors.flamingo, bg = colors.surface0, gui = "bold" }, + }, + terminal = { + a = { fg = colors.teal, bg = colors.surface0, gui = "bold" }, + }, + replace = { + a = { fg = colors.red, bg = colors.surface0, gui = "bold" }, + }, + inactive = { + a = { fg = colors.subtext0, bg = universal_bg, gui = "bold" }, + b = { fg = colors.subtext0, bg = universal_bg }, + c = { fg = colors.subtext0, bg = universal_bg }, + }, + } + else + return "auto" + end + end + + local conditionals = { + has_enough_room = function() + return vim.o.columns > 100 + end, + has_comp_before = function() + return vim.bo.filetype ~= "" + end, + has_git = function() + local gitdir = vim.fs.find(".git", { + limit = 1, + upward = true, + type = "directory", + path = vim.fn.expand("%:p:h"), + }) + return #gitdir > 0 + end, + } + + ---@class lualine_hlgrp + ---@field fg string + ---@field bg string + ---@field gui string? + local utils = { + force_centering = function() + return "%=" + end, + abbreviate_path = function(path) + local home = require("core.global").home + if path:find(home, 1, true) == 1 then + path = "~" .. path:sub(#home + 1) + end + return path + end, + ---Generate `color` for any component + ---@param fg string @Foreground hl group + ---@param gen_bg boolean @Generate guibg from hl group |StatusLine|? + ---@param special_nobg boolean @Disable guibg for transparent backgrounds? + ---@param bg string? @Background hl group + ---@param gui string? @GUI highlight arguments + ---@return nil|fun():lualine_hlgrp + gen_hl = function(fg, gen_bg, special_nobg, bg, gui) + if has_catppuccin then + return function() + local guifg = colors[fg] + local guibg = gen_bg and require("modules.utils").hl_to_rgb("StatusLine", true, colors.mantle) + or colors[bg] + local nobg = special_nobg and require("core.settings").transparent_background + return { + fg = guifg and guifg or colors.none, + bg = (guibg and not nobg) and guibg or colors.none, + gui = gui and gui or nil, + } + end + else + -- Return `nil` if the theme is user-defined + return nil + end + end, + } + + local function diff_source() + local gitsigns = vim.b.gitsigns_status_dict + if gitsigns then + return { + added = gitsigns.added, + modified = gitsigns.changed, + removed = gitsigns.removed, + } + end + end + + local components = { + separator = { -- use as section separators + function() + return "│" + end, + padding = 0, + color = utils.gen_hl("surface1", true, true), + separator = { left = "", right = "" }, + }, + + file_status = { + function() + local function is_new_file() + local filename = vim.fn.expand("%") + return filename ~= "" and vim.bo.buftype == "" and vim.fn.filereadable(filename) == 0 + end + + local symbols = {} + if vim.bo.modified then + table.insert(symbols, "[+]") + end + if vim.bo.modifiable == false then + table.insert(symbols, "[-]") + end + if vim.bo.readonly == true then + table.insert(symbols, "[RO]") + end + if is_new_file() then + table.insert(symbols, "[New]") + end + return #symbols > 0 and table.concat(symbols, "") or "" + end, + padding = { left = -1, right = 1 }, + cond = conditionals.has_comp_before, + }, + + lsp = { + function() + local buf_ft = vim.bo.filetype + local clients = vim.lsp.get_clients({ buffer = vim.api.nvim_get_current_buf() }) + local lsp_lists = {} + local available_servers = {} + if next(clients) == nil then + return icons.misc.NoActiveLsp -- No server available + end + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + local client_name = client.name + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + -- Avoid adding servers that already exists. + if not lsp_lists[client_name] then + lsp_lists[client_name] = true + table.insert(available_servers, client_name) + end + end + end + return next(available_servers) == nil and icons.misc.NoActiveLsp + or string.format("%s[%s]", icons.misc.LspAvailable, table.concat(available_servers, ", ")) + end, + color = utils.gen_hl("blue", true, true, nil, "bold"), + cond = conditionals.has_enough_room, + }, + + python_venv = { + function() + local function env_cleanup(venv) + if string.find(venv, "/") then + local final_venv = venv + for w in venv:gmatch("([^/]+)") do + final_venv = w + end + venv = final_venv + end + return venv + end + + if vim.bo.filetype == "python" then + local venv = os.getenv("CONDA_DEFAULT_ENV") + if venv then + return icons.misc.PyEnv .. env_cleanup(venv) + end + venv = os.getenv("VIRTUAL_ENV") + if venv then + return icons.misc.PyEnv .. env_cleanup(venv) + end + end + return "" + end, + color = utils.gen_hl("green", true, true), + cond = conditionals.has_enough_room, + }, + + tabwidth = { + function() + return icons.ui.Tab .. vim.bo.tabstop + end, + padding = 1, + }, + + cwd = { + function() + return icons.ui.FolderWithHeart .. utils.abbreviate_path(vim.fs.normalize(vim.fn.getcwd())) + end, + color = utils.gen_hl("subtext0", true, true, nil, "bold"), + }, + + file_location = { + function() + local cursorline = vim.fn.line(".") + local cursorcol = vim.fn.virtcol(".") + local filelines = vim.fn.line("$") + local position + if cursorline == 1 then + position = "Top" + elseif cursorline == filelines then + position = "Bot" + else + position = string.format("%2d%%%%", math.floor(cursorline / filelines * 100)) + end + return string.format("%s · %3d:%-2d", position, cursorline, cursorcol) + end, + }, + } + + require("modules.utils").load_plugin("lualine", { + options = { + icons_enabled = true, + theme = custom_theme(), + disabled_filetypes = { statusline = { "alpha" } }, + component_separators = "", + section_separators = { left = "", right = "" }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { + { + "filetype", + colored = true, + icon_only = false, + icon = { align = "left" }, + }, + components.file_status, + vim.tbl_extend("force", components.separator, { + cond = function() + return conditionals.has_git() and conditionals.has_comp_before() + end, + }), + }, + lualine_c = { + { + "branch", + icon = icons.git_nosep.Branch, + color = utils.gen_hl("subtext0", true, true, nil, "bold"), + cond = conditionals.has_git, + }, + { + "diff", + symbols = { + added = icons.git.Add, + modified = icons.git.Mod_alt, + removed = icons.git.Remove, + }, + source = diff_source, + colored = false, + color = utils.gen_hl("subtext0", true, true), + cond = conditionals.has_git, + padding = { right = 1 }, + }, + + { utils.force_centering }, + { + "diagnostics", + sources = { "nvim_diagnostic" }, + sections = { "error", "warn", "info", "hint" }, + symbols = { + error = icons.diagnostics.Error, + warn = icons.diagnostics.Warning, + info = icons.diagnostics.Information, + hint = icons.diagnostics.Hint_alt, + }, + }, + components.lsp, + }, + lualine_x = { + { + "encoding", + fmt = string.upper, + padding = { left = 1 }, + cond = conditionals.has_enough_room, + }, + { + "fileformat", + symbols = { + unix = "LF", + dos = "CRLF", + mac = "CR", -- Legacy macOS + }, + padding = { left = 1 }, + }, + components.tabwidth, + }, + lualine_y = { + components.separator, + components.python_venv, + components.cwd, + }, + lualine_z = { components.file_location }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + extensions = {}, + }) +end diff --git a/nvim/lua/modules/configs/ui/neodim.lua b/nvim/lua/modules/configs/ui/neodim.lua new file mode 100644 index 0000000..08ee94d --- /dev/null +++ b/nvim/lua/modules/configs/ui/neodim.lua @@ -0,0 +1,37 @@ +return function() + local blend_color = require("modules.utils").gen_neodim_blend_attr() + + require("modules.utils").load_plugin("neodim", { + alpha = 0.45, + blend_color = blend_color, + refresh_delay = 75, -- time in ms to wait after typing before refreshing diagnostics + hide = { + virtual_text = true, + signs = false, + underline = false, + }, + priority = 80, + disable = { + "alpha", + "bigfile", + "checkhealth", + "dap-repl", + "diff", + "fugitive", + "fugitiveblame", + "git", + "gitcommit", + "help", + "log", + "notify", + "NvimTree", + "Outline", + "qf", + "TelescopePrompt", + "text", + "toggleterm", + "undotree", + "vimwiki", + }, + }) +end diff --git a/nvim/lua/modules/configs/ui/neoscroll.lua b/nvim/lua/modules/configs/ui/neoscroll.lua new file mode 100644 index 0000000..9b1ae90 --- /dev/null +++ b/nvim/lua/modules/configs/ui/neoscroll.lua @@ -0,0 +1,24 @@ +return function() + require("modules.utils").load_plugin("neoscroll", { + -- All these keys will be mapped to their corresponding default scrolling animation + mappings = { + "", + "", + "", + "", + "", + "", + "zt", + "zz", + "zb", + }, + hide_cursor = true, -- Hide cursor while scrolling + stop_eof = true, -- Stop at when scrolling downwards + use_local_scrolloff = false, -- Use the local scope of scrolloff instead of the global scope + respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file + cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further + easing_function = nil, -- Default easing function + pre_hook = nil, -- Function to run before the scrolling animation starts + post_hook = nil, -- Function to run after the scrolling animation ends + }) +end diff --git a/nvim/lua/modules/configs/ui/notify.lua b/nvim/lua/modules/configs/ui/notify.lua new file mode 100644 index 0000000..a3dd3b6 --- /dev/null +++ b/nvim/lua/modules/configs/ui/notify.lua @@ -0,0 +1,41 @@ +return function() + local notify = require("notify") + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics"), + ui = require("modules.utils.icons").get("ui"), + } + + require("modules.utils").load_plugin("notify", { + ---@usage Animation style one of { "fade", "slide", "fade_in_slide_out", "static" } + stages = "fade", + ---@usage Function called when a new window is opened, use for changing win settings/config + on_open = function(win) + vim.api.nvim_set_option_value("winblend", 0, { scope = "local", win = win }) + vim.api.nvim_win_set_config(win, { zindex = 90 }) + end, + ---@usage Function called when a window is closed + on_close = nil, + ---@usage timeout for notifications in ms, default 5000 + timeout = 2000, + -- @usage User render fps value + fps = 20, + -- Render function for notifications. See notify-render() + render = "default", + ---@usage highlight behind the window for stages that change opacity + background_colour = "NotifyBackground", + ---@usage minimum width for notification windows + minimum_width = 50, + ---@usage notifications with level lower than this would be ignored. [ERROR > WARN > INFO > DEBUG > TRACE] + level = "INFO", + ---@usage Icons for the different levels + icons = { + ERROR = icons.diagnostics.Error, + WARN = icons.diagnostics.Warning, + INFO = icons.diagnostics.Information, + DEBUG = icons.ui.Bug, + TRACE = icons.ui.Pencil, + }, + }) + + vim.notify = notify +end diff --git a/nvim/lua/modules/configs/ui/paint.lua b/nvim/lua/modules/configs/ui/paint.lua new file mode 100644 index 0000000..5747cc2 --- /dev/null +++ b/nvim/lua/modules/configs/ui/paint.lua @@ -0,0 +1,20 @@ +return function() + require("modules.utils").load_plugin("paint", { + ---type PaintHighlight[] + highlights = { + { + -- filter can be a table of buffer options that should match, + -- or a function called with buf as param that should return true. + -- The example below will paint @something in comments with Constant + filter = { filetype = "lua" }, + pattern = "%s*%-%-%-%s*(@%w+)", + hl = "Constant", + }, + { + filter = { filetype = "python" }, + pattern = "%s*([_%w]+:)", + hl = "Constant", + }, + }, + }) +end diff --git a/nvim/lua/modules/configs/ui/scrollview.lua b/nvim/lua/modules/configs/ui/scrollview.lua new file mode 100644 index 0000000..ef11b59 --- /dev/null +++ b/nvim/lua/modules/configs/ui/scrollview.lua @@ -0,0 +1,24 @@ +return function() + local icons = { diagnostics = require("modules.utils.icons").get("diagnostics", true) } + + require("modules.utils").load_plugin("scrollview", { + mode = "virtual", + winblend = 0, + signs_on_startup = { "diagnostics", "folds", "marks", "search", "spell" }, + diagnostics_error_symbol = icons.diagnostics.Error, + diagnostics_warn_symbol = icons.diagnostics.Warning, + diagnostics_info_symbol = icons.diagnostics.Information, + diagnostics_hint_symbol = icons.diagnostics.Hint, + excluded_filetypes = { + "alpha", + "fugitive", + "git", + "notify", + "NvimTree", + "Outline", + "TelescopePrompt", + "toggleterm", + "undotree", + }, + }) +end diff --git a/nvim/lua/modules/configs/ui/todo.lua b/nvim/lua/modules/configs/ui/todo.lua new file mode 100644 index 0000000..ebdef8e --- /dev/null +++ b/nvim/lua/modules/configs/ui/todo.lua @@ -0,0 +1,58 @@ +return function() + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics"), + ui = require("modules.utils.icons").get("ui"), + } + + require("modules.utils").load_plugin("todo-comments", { + signs = false, -- show icons in the signs column + keywords = { + FIX = { + icon = icons.ui.Bug, + color = "error", + alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, + }, + TODO = { icon = icons.ui.Accepted, color = "info" }, + -- HACK = { icon = icons.ui.Fire, color = "warning" }, + WARN = { icon = icons.diagnostics.Warning, color = "warning", alt = { "WARNING", "XXX" } }, + PERF = { icon = icons.ui.Perf, alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, + NOTE = { icon = icons.ui.Note, color = "hint", alt = { "INFO" } }, + TEST = { icon = icons.ui.Lock, color = "test", alt = { "TESTING", "PASSED", "FAILED" } }, + }, + gui_style = { + fg = "NONE", + bg = "BOLD", + }, + merge_keywords = true, + highlight = { + multiline = false, + keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. + after = "", + comments_only = true, + max_line_len = 500, + exclude = { + "alpha", + "bigfile", + "checkhealth", + "dap-repl", + "diff", + "help", + "log", + "notify", + "NvimTree", + "Outline", + "qf", + "TelescopePrompt", + "toggleterm", + "undotree", + }, + }, + colors = { + error = { "DiagnosticError", "ErrorMsg", "#DC2626" }, + warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" }, + info = { "DiagnosticInfo", "#2563EB" }, + hint = { "DiagnosticHint", "#F5C2E7" }, + default = { "Conditional", "#7C3AED" }, + }, + }) +end diff --git a/nvim/lua/modules/plugins/completion.lua b/nvim/lua/modules/plugins/completion.lua new file mode 100644 index 0000000..af694f7 --- /dev/null +++ b/nvim/lua/modules/plugins/completion.lua @@ -0,0 +1,94 @@ +local completion = {} +local use_copilot = require("core.settings").use_copilot + +completion["neovim/nvim-lspconfig"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("completion.lsp"), + dependencies = { + { "williamboman/mason.nvim" }, + { "williamboman/mason-lspconfig.nvim" }, + { "folke/neoconf.nvim" }, + { + "Jint-lzxy/lsp_signature.nvim", + config = require("completion.lsp-signature"), + }, + }, +} +completion["nvimdev/lspsaga.nvim"] = { + lazy = true, + event = "LspAttach", + config = require("completion.lspsaga"), + dependencies = { "nvim-tree/nvim-web-devicons" }, +} +completion["stevearc/aerial.nvim"] = { + lazy = true, + event = "LspAttach", + config = require("completion.aerial"), +} +completion["DNLHC/glance.nvim"] = { + lazy = true, + event = "LspAttach", + config = require("completion.glance"), +} +completion["joechrisellis/lsp-format-modifications.nvim"] = { + lazy = true, + event = "LspAttach", +} +completion["nvimtools/none-ls.nvim"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("completion.null-ls"), + dependencies = { + "nvim-lua/plenary.nvim", + "jay-babu/mason-null-ls.nvim", + }, +} +completion["hrsh7th/nvim-cmp"] = { + lazy = true, + event = "InsertEnter", + config = require("completion.cmp"), + dependencies = { + { + "L3MON4D3/LuaSnip", + build = "make install_jsregexp", + config = require("completion.luasnip"), + dependencies = { "rafamadriz/friendly-snippets" }, + }, + { "lukas-reineke/cmp-under-comparator" }, + { "saadparwaiz1/cmp_luasnip" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-nvim-lua" }, + { "andersevenrud/cmp-tmux" }, + { "hrsh7th/cmp-path" }, + { "f3fora/cmp-spell" }, + { "hrsh7th/cmp-buffer" }, + { "kdheepak/cmp-latex-symbols" }, + { "ray-x/cmp-treesitter", commit = "c8e3a74" }, + -- { "tzachar/cmp-tabnine", build = "./install.sh", config = require("completion.tabnine") }, + -- { + -- "jcdickinson/codeium.nvim", + -- dependencies = { + -- "nvim-lua/plenary.nvim", + -- "MunifTanjim/nui.nvim", + -- }, + -- config = require("completion.codeium"), + -- }, + }, +} +if use_copilot then + completion["zbirenbaum/copilot.lua"] = { + lazy = true, + cmd = "Copilot", + event = "InsertEnter", + config = require("completion.copilot"), + dependencies = { + { + "zbirenbaum/copilot-cmp", + config = require("completion.copilot-cmp"), + }, + }, + } +end + +return completion diff --git a/nvim/lua/modules/plugins/editor.lua b/nvim/lua/modules/plugins/editor.lua new file mode 100644 index 0000000..f396fc0 --- /dev/null +++ b/nvim/lua/modules/plugins/editor.lua @@ -0,0 +1,132 @@ +local editor = {} + +editor["olimorris/persisted.nvim"] = { + lazy = true, + cmd = { + "SessionToggle", + "SessionStart", + "SessionStop", + "SessionSave", + "SessionLoad", + "SessionLoadLast", + "SessionLoadFromFile", + "SessionDelete", + }, + config = require("editor.persisted"), +} +editor["m4xshen/autoclose.nvim"] = { + lazy = true, + event = "InsertEnter", + config = require("editor.autoclose"), +} +editor["LunarVim/bigfile.nvim"] = { + lazy = false, + config = require("editor.bigfile"), + cond = require("core.settings").load_big_files_faster, +} +editor["ojroques/nvim-bufdel"] = { + lazy = true, + cmd = { "BufDel", "BufDelAll", "BufDelOthers" }, +} +-- NOTE: `flash.nvim` is a powerful plugin that can be used as partial or complete replacements for: +-- > `hop.nvim`, +-- > `wilder.nvim` +-- > `nvim-treehopper` +-- Considering its steep learning curve as well as backward compatibility issues... +-- > We have no plan to remove the above plugins for the time being. +-- But as usual, you can always tweak the plugin to your liking. +editor["folke/flash.nvim"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("editor.flash"), +} +editor["numToStr/Comment.nvim"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("editor.comment"), +} +editor["sindrets/diffview.nvim"] = { + lazy = true, + cmd = { "DiffviewOpen", "DiffviewClose" }, + config = require("editor.diffview"), +} +editor["echasnovski/mini.align"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("editor.align"), +} +editor["smoka7/hop.nvim"] = { + lazy = true, + version = "*", + event = { "CursorHold", "CursorHoldI" }, + config = require("editor.hop"), +} +editor["tzachar/local-highlight.nvim"] = { + lazy = true, + event = { "BufReadPost", "BufAdd", "BufNewFile" }, + config = require("editor.local-highlight"), +} +editor["brenoprata10/nvim-highlight-colors"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("editor.highlight-colors"), +} +editor["romainl/vim-cool"] = { + lazy = true, + event = { "CursorMoved", "InsertEnter" }, +} +editor["lambdalisue/suda.vim"] = { + lazy = true, + cmd = { "SudaRead", "SudaWrite" }, + init = require("editor.suda"), +} +editor["tpope/vim-sleuth"] = { + lazy = true, + event = { "BufNewFile", "BufReadPost", "BufFilePost" }, +} +editor["nvim-pack/nvim-spectre"] = { + lazy = true, + cmd = "Spectre", +} +editor["mrjones2014/smart-splits.nvim"] = { + lazy = true, + event = { "CursorHoldI", "CursorHold" }, + config = require("editor.splits"), +} + +---------------------------------------------------------------------- +--  :treesitter related plugins -- +---------------------------------------------------------------------- +editor["nvim-treesitter/nvim-treesitter"] = { + lazy = true, + build = function() + if vim.fn.has("gui_running") == 1 then + vim.api.nvim_command([[TSUpdate]]) + end + end, + event = "BufReadPre", + config = require("editor.treesitter"), + dependencies = { + { "andymass/vim-matchup" }, + { "mfussenegger/nvim-treehopper" }, + { "nvim-treesitter/nvim-treesitter-textobjects" }, + { + "windwp/nvim-ts-autotag", + config = require("editor.autotag"), + }, + { + "hiphish/rainbow-delimiters.nvim", + config = require("editor.rainbow_delims"), + }, + { + "nvim-treesitter/nvim-treesitter-context", + config = require("editor.ts-context"), + }, + { + "JoosepAlviste/nvim-ts-context-commentstring", + config = require("editor.ts-context-commentstring"), + }, + }, +} + +return editor diff --git a/nvim/lua/modules/plugins/lang.lua b/nvim/lua/modules/plugins/lang.lua new file mode 100644 index 0000000..2cfc397 --- /dev/null +++ b/nvim/lua/modules/plugins/lang.lua @@ -0,0 +1,40 @@ +local lang = {} + +lang["kevinhwang91/nvim-bqf"] = { + lazy = true, + ft = "qf", + config = require("lang.bqf"), + dependencies = { + { "junegunn/fzf", build = ":call fzf#install()" }, + }, +} +lang["ray-x/go.nvim"] = { + lazy = true, + ft = { "go", "gomod", "gosum" }, + build = ":GoInstallBinaries", + config = require("lang.go"), + dependencies = { "ray-x/guihua.lua" }, +} +lang["mrcjkb/rustaceanvim"] = { + lazy = true, + ft = "rust", + version = "*", + init = require("lang.rust"), + dependencies = { "nvim-lua/plenary.nvim" }, +} +lang["Saecki/crates.nvim"] = { + lazy = true, + event = "BufReadPost Cargo.toml", + config = require("lang.crates"), + dependencies = { "nvim-lua/plenary.nvim" }, +} +lang["iamcco/markdown-preview.nvim"] = { + lazy = true, + ft = "markdown", + build = ":call mkdp#util#install()", +} +lang["chrisbra/csv.vim"] = { + lazy = true, + ft = "csv", +} +return lang diff --git a/nvim/lua/modules/plugins/tool.lua b/nvim/lua/modules/plugins/tool.lua new file mode 100644 index 0000000..37be1ed --- /dev/null +++ b/nvim/lua/modules/plugins/tool.lua @@ -0,0 +1,140 @@ +local tool = {} + +tool["tpope/vim-fugitive"] = { + lazy = true, + cmd = { "Git", "G" }, +} +-- This is specifically for fcitx5 users who code in languages other than English +-- tool["pysan3/fcitx5.nvim"] = { +-- lazy = true, +-- event = "BufReadPost", +-- cond = vim.fn.executable("fcitx5-remote") == 1, +-- config = require("tool.fcitx5"), +-- } +tool["Bekaboo/dropbar.nvim"] = { + lazy = false, + config = require("tool.dropbar"), + dependencies = { + "nvim-tree/nvim-web-devicons", + "nvim-telescope/telescope-fzf-native.nvim", + }, +} +tool["nvim-tree/nvim-tree.lua"] = { + lazy = true, + cmd = { + "NvimTreeToggle", + "NvimTreeOpen", + "NvimTreeFindFile", + "NvimTreeFindFileToggle", + "NvimTreeRefresh", + }, + config = require("tool.nvim-tree"), +} +tool["ibhagwan/smartyank.nvim"] = { + lazy = true, + event = "BufReadPost", + config = require("tool.smartyank"), +} +tool["michaelb/sniprun"] = { + lazy = true, + -- You need to cd to `~/.local/share/nvim/site/lazy/sniprun/` and execute `bash ./install.sh`, + -- if you encountered error about no executable sniprun found. + build = "bash ./install.sh", + cmd = { "SnipRun", "SnipReset", "SnipInfo" }, + config = require("tool.sniprun"), +} +tool["akinsho/toggleterm.nvim"] = { + lazy = true, + cmd = { + "ToggleTerm", + "ToggleTermSetName", + "ToggleTermToggleAll", + "ToggleTermSendVisualLines", + "ToggleTermSendCurrentLine", + "ToggleTermSendVisualSelection", + }, + config = require("tool.toggleterm"), +} +tool["folke/trouble.nvim"] = { + lazy = true, + cmd = { "Trouble", "TroubleToggle", "TroubleRefresh" }, + config = require("tool.trouble"), +} +tool["folke/which-key.nvim"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("tool.which-key"), +} +tool["gelguy/wilder.nvim"] = { + lazy = true, + event = "CmdlineEnter", + config = require("tool.wilder"), + dependencies = { "romgrk/fzy-lua-native" }, +} + +---------------------------------------------------------------------- +-- Telescope Plugins -- +---------------------------------------------------------------------- +tool["nvim-telescope/telescope.nvim"] = { + lazy = true, + cmd = "Telescope", + config = require("tool.telescope"), + dependencies = { + { "nvim-lua/plenary.nvim" }, + { "nvim-tree/nvim-web-devicons" }, + { "jvgrootveld/telescope-zoxide" }, + { "debugloop/telescope-undo.nvim" }, + { "nvim-telescope/telescope-frecency.nvim" }, + { "nvim-telescope/telescope-live-grep-args.nvim" }, + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { + "FabianWirth/search.nvim", + config = require("tool.search"), + }, + { + "ahmedkhalf/project.nvim", + event = { "CursorHold", "CursorHoldI" }, + config = require("tool.project"), + }, + { + "aaronhallaert/advanced-git-search.nvim", + cmd = { "AdvancedGitSearch" }, + dependencies = { + "tpope/vim-rhubarb", + "tpope/vim-fugitive", + "sindrets/diffview.nvim", + }, + }, + }, +} + +---------------------------------------------------------------------- +-- DAP Plugins -- +---------------------------------------------------------------------- +tool["mfussenegger/nvim-dap"] = { + lazy = true, + cmd = { + "DapSetLogLevel", + "DapShowLog", + "DapContinue", + "DapToggleBreakpoint", + "DapToggleRepl", + "DapStepOver", + "DapStepInto", + "DapStepOut", + "DapTerminate", + }, + config = require("tool.dap"), + dependencies = { + { + "rcarriga/nvim-dap-ui", + config = require("tool.dap.dapui"), + dependencies = { + "nvim-neotest/nvim-nio", + }, + }, + { "jay-babu/mason-nvim-dap.nvim" }, + }, +} + +return tool diff --git a/nvim/lua/modules/plugins/ui.lua b/nvim/lua/modules/plugins/ui.lua new file mode 100644 index 0000000..1a5aab4 --- /dev/null +++ b/nvim/lua/modules/plugins/ui.lua @@ -0,0 +1,71 @@ +local ui = {} + +ui["goolord/alpha-nvim"] = { + lazy = true, + event = "BufWinEnter", + config = require("ui.alpha"), +} +ui["akinsho/bufferline.nvim"] = { + lazy = true, + event = { "BufReadPost", "BufAdd", "BufNewFile" }, + config = require("ui.bufferline"), +} +ui["Jint-lzxy/nvim"] = { + lazy = false, + branch = "refactor/syntax-highlighting", + name = "catppuccin", + config = require("ui.catppuccin"), +} +ui["j-hui/fidget.nvim"] = { + lazy = true, + event = "LspAttach", + config = require("ui.fidget"), +} +ui["lewis6991/gitsigns.nvim"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("ui.gitsigns"), +} +ui["lukas-reineke/indent-blankline.nvim"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("ui.indent-blankline"), +} +ui["nvim-lualine/lualine.nvim"] = { + lazy = true, + event = { "BufReadPost", "BufAdd", "BufNewFile" }, + config = require("ui.lualine"), +} +ui["zbirenbaum/neodim"] = { + lazy = true, + event = "LspAttach", + config = require("ui.neodim"), +} +ui["karb94/neoscroll.nvim"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("ui.neoscroll"), +} +ui["rcarriga/nvim-notify"] = { + lazy = true, + event = "VeryLazy", + config = require("ui.notify"), +} +ui["folke/paint.nvim"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("ui.paint"), +} +ui["folke/todo-comments.nvim"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("ui.todo"), + dependencies = { "nvim-lua/plenary.nvim" }, +} +ui["dstein64/nvim-scrollview"] = { + lazy = true, + event = { "BufReadPost", "BufAdd", "BufNewFile" }, + config = require("ui.scrollview"), +} + +return ui diff --git a/nvim/lua/modules/utils/dap.lua b/nvim/lua/modules/utils/dap.lua new file mode 100644 index 0000000..0ea276c --- /dev/null +++ b/nvim/lua/modules/utils/dap.lua @@ -0,0 +1,32 @@ +local M = {} + +function M.input_args() + local argument_string = vim.fn.input("Program arg(s) (enter nothing to leave it null): ") + return vim.fn.split(argument_string, " ", true) +end + +function M.input_exec_path() + return vim.fn.input('Path to executable (default to "a.out"): ', vim.fn.expand("%:p:h") .. "/a.out", "file") +end + +function M.input_file_path() + return vim.fn.input("Path to debuggee (default to the current file): ", vim.fn.expand("%:p"), "file") +end + +function M.get_env() + local variables = {} + for k, v in pairs(vim.fn.environ()) do + table.insert(variables, string.format("%s=%s", k, v)) + end + return variables +end + +return setmetatable({}, { + __index = function(_, key) + return function() + return function() + return M[key]() + end + end + end, +}) diff --git a/nvim/lua/modules/utils/icons.lua b/nvim/lua/modules/utils/icons.lua new file mode 100644 index 0000000..a050401 --- /dev/null +++ b/nvim/lua/modules/utils/icons.lua @@ -0,0 +1,240 @@ +local icons = {} + +local data = { + kind = { + Break = "󰙧", + Call = "󰃷", + Case = "󰬶", + Class = "󰠱", + Color = "󰏘", + Constant = "󰏿", + Constructor = "", + Continue = "󰞘", + Declaration = "󰙠", + Delete = "󱟁", + Enum = "", + EnumMember = "", + Event = "", + Field = "󰇽", + File = "󰈙", + Folder = "󰉋", + Fragment = "", + Function = "󰊕", + Implementation = "", + Interface = "", + Keyword = "󰌋", + List = "󰅪", + Loop = "󰑖", + Method = "󰆧", + Module = "", + Namespace = "󰌗", + Operator = "󰆕", + Package = "", + Property = "󰜢", + Reference = "", + Regex = "", + Snippet = "", + Statement = "󰅩", + Struct = "", + Switch = "", + Text = "󰉿", + TypeParameter = "󰅲", + Undefined = "", + Unit = "", + Value = "󰎠", + Variable = "", + -- ccls-specific icons + Macro = "", + Parameter = "", + StaticMethod = "", + Terminal = "", + TypeAlias = "", + }, + type = { + Array = "󰅪", + Boolean = "", + Null = "󰟢", + Number = "", + Object = "󰅩", + String = "󰉿", + }, + documents = { + Default = "", + File = "", + Files = "", + FileFind = "󰈞", + FileTree = "󰙅", + Import = "", + Symlink = "", + Word = "", + }, + git = { + Add = "", + Branch = "", + Diff = "", + Git = "󰊢", + Ignore = "", + Mod = "M", + Mod_alt = "", + Remove = "", + Rename = "", + Repo = "", + Unmerged = "󰘬", + Untracked = "󰞋", + Unstaged = "", + Staged = "", + Conflict = "", + }, + ui = { + Accepted = "", + ArrowClosed = "", + ArrowOpen = "", + BigCircle = "", + BigUnfilledCircle = "", + BookMark = "󰃃", + Buffer = "󰓩", + Bug = "", + Calendar = "", + Character = "", + Check = "󰄳", + ChevronRight = "", + Circle = "", + Close = "󰅖", + Close_alt = "", + CloudDownload = "", + CodeAction = "󰌵", + Comment = "󰅺", + Dashboard = "", + DoubleSeparator = "󰄾", + Emoji = "󰱫", + EmptyFolder = "", + EmptyFolderOpen = "", + File = "󰈤", + Fire = "", + Folder = "", + FolderOpen = "", + FolderWithHeart = "󱃪", + Gear = "", + History = "󰄉", + Incoming = "󰏷", + Indicator = "", + Keyboard = "", + Left = "", + List = "", + Lock = "󰍁", + Modified = "✥", + Modified_alt = "", + NewFile = "", + Newspaper = "", + Note = "󰍨", + Outgoing = "󰏻", + Package = "", + Pencil = "󰏫", + Perf = "󰅒", + Play = "", + Project = "", + Right = "", + RootFolderOpened = "", + Search = "󰍉", + Separator = "", + SignIn = "", + SignOut = "", + Sort = "", + Spell = "󰓆", + Square = "", + Symlink = "", + SymlinkFolder = "", + Tab = "", + Table = "", + Telescope = "", + Window = "", + }, + diagnostics = { + Error = "", + Warning = "", + Information = "", + Question = "", + Hint = "󰌵", + -- Hollow version + Error_alt = "󰅚", + Warning_alt = "󰀪", + Information_alt = "", + Question_alt = "", + Hint_alt = "󰌶", + }, + misc = { + Add = "+", + Added = "", + Campass = "󰀹", + Code = "", + Gavel = "", + Ghost = "󰊠", + Glass = "󰂖", + Lego = "", + LspAvailable = "󱜙", + ManUp = "", + Neovim = "", + NoActiveLsp = "󱚧", + PyEnv = "󰢩", + Squirrel = "", + Tag = "", + Tree = "", + Vbar = "│", + Vim = "", + Watch = "", + }, + cmp = { + buffer = "󰉿", + latex_symbols = "", + luasnip = "󰃐", + nvim_lsp = "", + nvim_lua = "", + orgmode = "", + path = "", + spell = "󰓆", + tmux = "", + treesitter = "", + undefined = "", + -- Add source-specific icons here + codeium = "", + Codeium = "", + copilot = "", + copilot_alt = "", + Copilot = "", + Copilot_alt = "", + TabNine = "", + cmp_tabnine = "", + }, + dap = { + Breakpoint = "󰝥", + BreakpointCondition = "󰟃", + BreakpointRejected = "", + LogPoint = "", + Pause = "", + Play = "", + RunLast = "↻", + StepBack = "", + StepInto = "󰆹", + StepOut = "󰆸", + StepOver = "󰆷", + Stopped = "", + Terminate = "󰝤", + }, +} + +---Get a specific icon set. +---@param category "kind"|"type"|"documents"|"git"|"ui"|"diagnostics"|"misc"|"cmp"|"dap" +---@param add_space? boolean @Add trailing whitespace after the icon. +function icons.get(category, add_space) + if add_space then + return setmetatable({}, { + __index = function(_, key) + return data[category][key] .. " " + end, + }) + else + return data[category] + end +end + +return icons diff --git a/nvim/lua/modules/utils/init.lua b/nvim/lua/modules/utils/init.lua new file mode 100644 index 0000000..c2c9fd5 --- /dev/null +++ b/nvim/lua/modules/utils/init.lua @@ -0,0 +1,370 @@ +local M = {} + +---@class palette +---@field rosewater string +---@field flamingo string +---@field mauve string +---@field pink string +---@field red string +---@field maroon string +---@field peach string +---@field yellow string +---@field green string +---@field sapphire string +---@field blue string +---@field sky string +---@field teal string +---@field lavender string +---@field text string +---@field subtext1 string +---@field subtext0 string +---@field overlay2 string +---@field overlay1 string +---@field overlay0 string +---@field surface2 string +---@field surface1 string +---@field surface0 string +---@field base string +---@field mantle string +---@field crust string +---@field none "NONE" + +---@type nil|palette +local palette = nil + +-- Indicates if autocmd for refreshing the builtin palette has already been registered +---@type boolean +local _has_autocmd = false + +---Initialize the palette +---@return palette +local function init_palette() + -- Reinitialize the palette on event `ColorScheme` + if not _has_autocmd then + _has_autocmd = true + vim.api.nvim_create_autocmd("ColorScheme", { + group = vim.api.nvim_create_augroup("__builtin_palette", { clear = true }), + pattern = "*", + callback = function() + palette = nil + init_palette() + -- Also refresh hard-coded hl groups + M.gen_alpha_hl() + M.gen_lspkind_hl() + pcall(vim.cmd.AlphaRedraw) + end, + }) + end + + if not palette then + palette = vim.g.colors_name:find("catppuccin") and require("catppuccin.palettes").get_palette() + or { + rosewater = "#DC8A78", + flamingo = "#DD7878", + mauve = "#CBA6F7", + pink = "#F5C2E7", + red = "#E95678", + maroon = "#B33076", + peach = "#FF8700", + yellow = "#F7BB3B", + green = "#AFD700", + sapphire = "#36D0E0", + blue = "#61AFEF", + sky = "#04A5E5", + teal = "#B5E8E0", + lavender = "#7287FD", + + text = "#F2F2BF", + subtext1 = "#BAC2DE", + subtext0 = "#A6ADC8", + overlay2 = "#C3BAC6", + overlay1 = "#988BA2", + overlay0 = "#6E6B6B", + surface2 = "#6E6C7E", + surface1 = "#575268", + surface0 = "#302D41", + + base = "#1D1536", + mantle = "#1C1C19", + crust = "#161320", + } + + palette = vim.tbl_extend("force", { none = "NONE" }, palette, require("core.settings").palette_overwrite) + end + + return palette +end + +---@param c string @The color in hexadecimal. +local function hex_to_rgb(c) + c = string.lower(c) + return { tonumber(c:sub(2, 3), 16), tonumber(c:sub(4, 5), 16), tonumber(c:sub(6, 7), 16) } +end + +-- NOTE: If the active colorscheme isn't `catppuccin`, this function won't overwrite existing definitions +---Sets a global highlight group. +---@param name string @Highlight group name, e.g. "ErrorMsg" +---@param foreground string @The foreground color +---@param background? string @The background color +---@param italic? boolean +local function set_global_hl(name, foreground, background, italic) + vim.api.nvim_set_hl(0, name, { + fg = foreground, + bg = background, + italic = italic == true, + default = not vim.g.colors_name:find("catppuccin"), + }) +end + +---Blend foreground with background +---@param foreground string @The foreground color +---@param background string @The background color to blend with +---@param alpha number|string @Number between 0 and 1 for blending amount. +function M.blend(foreground, background, alpha) + alpha = type(alpha) == "string" and (tonumber(alpha, 16) / 0xff) or alpha + local bg = hex_to_rgb(background) + local fg = hex_to_rgb(foreground) + + local blend_channel = function(i) + local ret = (alpha * fg[i] + ((1 - alpha) * bg[i])) + return math.floor(math.min(math.max(0, ret), 255) + 0.5) + end + + return string.format("#%02x%02x%02x", blend_channel(1), blend_channel(2), blend_channel(3)) +end + +---Get RGB highlight by highlight group +---@param hl_group string @Highlight group name +---@param use_bg boolean @Returns background or not +---@param fallback_hl? string @Fallback value if the hl group is not defined +---@return string +function M.hl_to_rgb(hl_group, use_bg, fallback_hl) + local hex = fallback_hl or "#000000" + local hlexists = pcall(vim.api.nvim_get_hl, 0, { name = hl_group, link = false }) + + if hlexists then + local result = vim.api.nvim_get_hl(0, { name = hl_group, link = false }) + if use_bg then + hex = result.bg and string.format("#%06x", result.bg) or "NONE" + else + hex = result.fg and string.format("#%06x", result.fg) or "NONE" + end + end + + return hex +end + +---Extend a highlight group +---@param name string @Target highlight group name +---@param def table @Attributes to be extended +function M.extend_hl(name, def) + local hlexists = pcall(vim.api.nvim_get_hl, 0, { name = name, link = false }) + if not hlexists then + -- Do nothing if highlight group not found + return + end + local current_def = vim.api.nvim_get_hl(0, { name = name, link = false }) + local combined_def = vim.tbl_deep_extend("force", current_def, def) + + vim.api.nvim_set_hl(0, name, combined_def) +end + +---Generate universal highlight groups +---@param overwrite palette? @The color to be overwritten | highest priority +---@return palette +function M.get_palette(overwrite) + if not overwrite then + return vim.deepcopy(init_palette()) + else + return vim.tbl_extend("force", init_palette(), overwrite) + end +end + +-- Generate highlight groups for lspsaga. Existing attributes will NOT be overwritten +function M.gen_lspkind_hl() + local colors = M.get_palette() + local dat = { + Class = colors.yellow, + Constant = colors.peach, + Constructor = colors.sapphire, + Enum = colors.yellow, + EnumMember = colors.teal, + Event = colors.yellow, + Field = colors.teal, + File = colors.rosewater, + Function = colors.blue, + Interface = colors.yellow, + Key = colors.red, + Method = colors.blue, + Module = colors.blue, + Namespace = colors.blue, + Number = colors.peach, + Operator = colors.sky, + Package = colors.blue, + Property = colors.teal, + Struct = colors.yellow, + TypeParameter = colors.blue, + Variable = colors.peach, + Array = colors.peach, + Boolean = colors.peach, + Null = colors.yellow, + Object = colors.yellow, + String = colors.green, + TypeAlias = colors.green, + Parameter = colors.blue, + StaticMethod = colors.peach, + Text = colors.green, + Snippet = colors.mauve, + Folder = colors.blue, + Unit = colors.green, + Value = colors.peach, + } + + for kind, color in pairs(dat) do + set_global_hl("LspKind" .. kind, color) + end +end + +-- Generate highlight groups for alpha. Existing attributes will NOT be overwritten +function M.gen_alpha_hl() + local colors = M.get_palette() + + set_global_hl("AlphaHeader", colors.blue) + set_global_hl("AlphaButtons", colors.green) + set_global_hl("AlphaShortcut", colors.pink, nil, true) + set_global_hl("AlphaFooter", colors.yellow) +end + +-- Generate blend_color for neodim. +function M.gen_neodim_blend_attr() + local trans_bg = require("core.settings").transparent_background + local appearance = require("core.settings").background + + if trans_bg and appearance == "dark" then + return "#000000" + elseif trans_bg and appearance == "light" then + return "#FFFFFF" + else + return M.hl_to_rgb("Normal", true) + end +end + +---Convert number (0/1) to boolean +---@param value number @The value to check +---@return boolean|nil @Returns nil if failed +function M.tobool(value) + if value == 0 then + return false + elseif value == 1 then + return true + else + vim.notify( + "Attempting to convert data of type '" .. type(value) .. "' [other than 0 or 1] to boolean", + vim.log.levels.ERROR, + { title = "[utils] Runtime Error" } + ) + return nil + end +end + +--- Function to recursively merge src into dst +--- Unlike vim.tbl_deep_extend(), this function extends if the original value is a list +---@paramm dst table @Table which will be modified and appended to +---@paramm src table @Table from which values will be inserted +---@return table @Modified table +local function tbl_recursive_merge(dst, src) + for key, value in pairs(src) do + if type(dst[key]) == "table" and type(value) == "function" then + dst[key] = value(dst[key]) + elseif type(dst[key]) == "table" and vim.islist(dst[key]) and key ~= "dashboard_image" then + vim.list_extend(dst[key], value) + elseif type(dst[key]) == "table" and type(value) == "table" and not vim.islist(dst[key]) then + tbl_recursive_merge(dst[key], value) + else + dst[key] = value + end + end + return dst +end + +-- Function to extend existing core configs (settings, events, etc.) +---@param config table @The default config to be merged with +---@param user_config string @The module name used to require user config +---@return table @Extended config +function M.extend_config(config, user_config) + local ok, extras = pcall(require, user_config) + if ok and type(extras) == "table" then + config = tbl_recursive_merge(config, extras) + end + return config +end + +---@param plugin_name string @Module name of the plugin (used to setup itself) +---@param opts nil|table @The default config to be merged with +---@param vim_plugin? boolean @If this plugin is written in vimscript or not +---@param setup_callback? function @Add new callback if the plugin needs unusual setup function +function M.load_plugin(plugin_name, opts, vim_plugin, setup_callback) + vim_plugin = vim_plugin or false + + -- Get the file name of the default config + local fname = debug.getinfo(2, "S").source:match("[^@/\\]*.lua$") + local ok, user_config = pcall(require, "user.configs." .. fname:sub(0, #fname - 4)) + if ok and vim_plugin then + if user_config == false then + -- Return early if the user explicitly requires disabling plugin setup + return + elseif type(user_config) == "function" then + -- OK, setup as instructed by the user + user_config() + else + vim.notify( + string.format( + "<%s> is not a typical Lua plugin, please return a function with\nthe corresponding options defined instead (usually via `vim.g.*`)", + plugin_name + ), + vim.log.levels.ERROR, + { title = "[utils] Runtime Error (User Config)" } + ) + end + elseif not vim_plugin then + if user_config == false then + -- Return early if the user explicitly requires disabling plugin setup + return + else + setup_callback = setup_callback or require(plugin_name).setup + -- User config exists? + if ok then + -- Extend base config if the returned user config is a table + if type(user_config) == "table" then + opts = tbl_recursive_merge(opts, user_config) + setup_callback(opts) + -- Replace base config if the returned user config is a function + elseif type(user_config) == "function" then + local user_opts = user_config(opts) + if type(user_opts) == "table" then + setup_callback(user_opts) + end + else + vim.notify( + string.format( + [[ +Please return a `table` if you want to override some of the default options OR a +`function` returning a `table` if you want to replace the default options completely. + +We received a `%s` for plugin <%s>.]], + type(user_config), + plugin_name + ), + vim.log.levels.ERROR, + { title = "[utils] Runtime Error (User Config)" } + ) + end + else + -- Nothing provided... Fallback as default setup of the plugin + setup_callback(opts) + end + end + end +end + +return M diff --git a/nvim/lua/modules/utils/keymap.lua b/nvim/lua/modules/utils/keymap.lua new file mode 100644 index 0000000..e249250 --- /dev/null +++ b/nvim/lua/modules/utils/keymap.lua @@ -0,0 +1,205 @@ +local M = {} + +---Shortcut for `nvim_replace_termcodes`. +---@param keys string +---@return string +local function termcodes(keys) + return vim.api.nvim_replace_termcodes(keys, true, true, true) +end + +---Returns if two key sequence are equal or not. +---@param a string +---@param b string +---@return boolean +local function keymap_equals(a, b) + return termcodes(a) == termcodes(b) +end + +---Get map +---@param mode string +---@param lhs string +---@return table +local function get_map(mode, lhs) + for _, map in ipairs(vim.api.nvim_buf_get_keymap(0, mode)) do + if keymap_equals(map.lhs, lhs) then + vim.api.nvim_buf_del_keymap(0, mode, lhs) + return { + lhs = map.lhs, + rhs = map.rhs or "", + expr = map.expr == 1, + callback = map.callback, + noremap = map.noremap == 1, + script = map.script == 1, + silent = map.silent == 1, + nowait = map.nowait == 1, + buffer = true, + } + end + end + + for _, map in ipairs(vim.api.nvim_get_keymap(mode)) do + if keymap_equals(map.lhs, lhs) then + vim.api.nvim_del_keymap(mode, lhs) + return { + lhs = map.lhs, + rhs = map.rhs or "", + expr = map.expr == 1, + callback = map.callback, + noremap = map.noremap == 1, + script = map.script == 1, + silent = map.silent == 1, + nowait = map.nowait == 1, + buffer = false, + } + end + end + + return { + lhs = lhs, + rhs = lhs, + expr = false, + callback = nil, + noremap = true, + script = false, + silent = true, + nowait = false, + buffer = false, + } +end + +---Returns the function constructed from the passed keymap object on call of +---which the original keymapping will be executed. +---@param map table keymap object +---@return function +local function get_fallback(map) + return function() + local keys, fmode + if map.expr then + if map.callback then + keys = map.callback() + else + keys = vim.api.nvim_eval(map.rhs) + end + elseif map.callback then + map.callback() + return + else + keys = map.rhs + end + keys = termcodes(keys) + fmode = map.noremap and "in" or "im" + vim.api.nvim_feedkeys(keys, fmode, false) + end +end + +-- Amends a mapping (i.e., allows fallback when certain conditions are met) +---@param cond string +---@param mode string +---@param lhs string +---@param rhs function +---@param opts? table +local function amend(cond, mode, lhs, rhs, opts) + local map = get_map(mode, lhs) + local fallback = get_fallback(map) + local options = vim.deepcopy(opts) or {} + options.desc = table.concat({ + "[" .. cond, + (options.desc and ": " .. options.desc or ""), + "]", + (map.desc and " / " .. map.desc or ""), + }) + vim.keymap.set(mode, lhs, function() + rhs(fallback) + end, options) +end + +-- Completely replace a mapping +---@param mode string +---@param lhs string +---@param rhs string +---@param opts? table +---@param buf? boolean|number +local function replace(mode, lhs, rhs, opts, buf) + get_map(mode, lhs) + + local options = vim.deepcopy(opts) or {} + if buf and type(buf) == "number" then + vim.api.nvim_buf_set_keymap(buf, mode, lhs, rhs, options) + else + vim.api.nvim_set_keymap(mode, lhs, rhs, options) + end +end + +---Amend the existing keymap. +---@param cond string +---@param mode string | string[] +---@param lhs string +---@param rhs function +---@param opts? table +local function modes_amend(cond, mode, lhs, rhs, opts) + if type(mode) == "table" then + for _, m in ipairs(mode) do + amend(cond, m, lhs, rhs, opts) + end + else + amend(cond, mode, lhs, rhs, opts) + end +end + +---Replace the existing keymap. +---@param mode string | string[] +---@param lhs string +---@param rhs string +---@param opts? table +---@param buf? boolean|number +local function modes_replace(mode, lhs, rhs, opts, buf) + if type(mode) == "table" then + for _, m in ipairs(mode) do + replace(m, lhs, rhs, opts, buf) + end + else + replace(mode, lhs, rhs, opts, buf) + end +end + +---Amend the existing keymap. +---@param cond string +---@param global_flag string +---@param mapping table +function M.amend(cond, global_flag, mapping) + for key, value in pairs(mapping) do + local modes, keymap = key:match("([^|]*)|?(.*)") + if type(value) == "table" then + local rhs = value.cmd + local options = value.options + modes_amend(cond, vim.split(modes, ""), keymap, function(fallback) + if _G[global_flag] then + local fmode = options.noremap and "in" or "im" + vim.api.nvim_feedkeys(termcodes(rhs), fmode, false) + else + fallback() + end + end, options) + end + end +end + +---Replace the existing keymap. +---@param mapping table +function M.replace(mapping) + for key, value in pairs(mapping) do + local modes, keymap = key:match("([^|]*)|?(.*)") + if type(value) == "table" then + local rhs = value.cmd + local options = value.options + local buffer = value.buffer + modes_replace(vim.split(modes, ""), keymap, rhs, options, buffer) + elseif value == "" or value == false then + for _, m in ipairs(vim.split(modes, "")) do + get_map(m, keymap) + end + end + end +end + +return M diff --git a/nvim/lua/user_template/configs/.gitkeep b/nvim/lua/user_template/configs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/nvim/lua/user_template/configs/dap-clients/.gitkeep b/nvim/lua/user_template/configs/dap-clients/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/nvim/lua/user_template/configs/formatters/.gitkeep b/nvim/lua/user_template/configs/formatters/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/nvim/lua/user_template/configs/lsp-servers/.gitkeep b/nvim/lua/user_template/configs/lsp-servers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/nvim/lua/user_template/event.lua b/nvim/lua/user_template/event.lua new file mode 100644 index 0000000..44bee88 --- /dev/null +++ b/nvim/lua/user_template/event.lua @@ -0,0 +1,8 @@ +local definitions = { + -- Example + bufs = { + { "BufWritePre", "COMMIT_EDITMSG", "setlocal noundofile" }, + }, +} + +return definitions diff --git a/nvim/lua/user_template/keymap/completion.lua b/nvim/lua/user_template/keymap/completion.lua new file mode 100644 index 0000000..1000f15 --- /dev/null +++ b/nvim/lua/user_template/keymap/completion.lua @@ -0,0 +1,16 @@ +local mappings = {} + +-- Place global keymaps here. +mappings["plug_map"] = {} + +-- NOTE: This function is special! Keymaps defined here are ONLY effective in buffers with LSP(s) attached +-- NOTE: Make sure to include `:with_buffer(buf)` to limit the scope of your mappings. +---@param buf number @The effective bufnr +mappings["lsp"] = function(buf) + return { + -- Example + ["n|K"] = require("keymap.bind").map_cr("Lspsaga hover_doc"):with_buffer(buf):with_desc("lsp: Show doc"), + } +end + +return mappings diff --git a/nvim/lua/user_template/keymap/core.lua b/nvim/lua/user_template/keymap/core.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/nvim/lua/user_template/keymap/core.lua @@ -0,0 +1 @@ +return {} diff --git a/nvim/lua/user_template/keymap/editor.lua b/nvim/lua/user_template/keymap/editor.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/nvim/lua/user_template/keymap/editor.lua @@ -0,0 +1 @@ +return {} diff --git a/nvim/lua/user_template/keymap/init.lua b/nvim/lua/user_template/keymap/init.lua new file mode 100644 index 0000000..f4a08e2 --- /dev/null +++ b/nvim/lua/user_template/keymap/init.lua @@ -0,0 +1,9 @@ +return vim.tbl_extend( + "force", + require("user.keymap.core"), + require("user.keymap.completion").plug_map, + require("user.keymap.editor"), + require("user.keymap.lang"), + require("user.keymap.tool"), + require("user.keymap.ui") +) diff --git a/nvim/lua/user_template/keymap/lang.lua b/nvim/lua/user_template/keymap/lang.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/nvim/lua/user_template/keymap/lang.lua @@ -0,0 +1 @@ +return {} diff --git a/nvim/lua/user_template/keymap/tool.lua b/nvim/lua/user_template/keymap/tool.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/nvim/lua/user_template/keymap/tool.lua @@ -0,0 +1 @@ +return {} diff --git a/nvim/lua/user_template/keymap/ui.lua b/nvim/lua/user_template/keymap/ui.lua new file mode 100644 index 0000000..a564707 --- /dev/null +++ b/nvim/lua/user_template/keymap/ui.lua @@ -0,0 +1 @@ +return {} diff --git a/nvim/lua/user_template/options.lua b/nvim/lua/user_template/options.lua new file mode 100644 index 0000000..df03ac5 --- /dev/null +++ b/nvim/lua/user_template/options.lua @@ -0,0 +1,6 @@ +local options = { + -- Example + autoindent = true, +} + +return options diff --git a/nvim/lua/user_template/plugins/.gitkeep b/nvim/lua/user_template/plugins/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/nvim/lua/user_template/settings.lua b/nvim/lua/user_template/settings.lua new file mode 100644 index 0000000..3e11eb9 --- /dev/null +++ b/nvim/lua/user_template/settings.lua @@ -0,0 +1,9 @@ +-- Please check `lua/core/settings.lua` to view the full list of configurable settings +local settings = {} + +-- Examples +settings["use_ssh"] = true + +settings["colorscheme"] = "catppuccin" + +return settings diff --git a/nvim/nixos/default.nix b/nvim/nixos/default.nix new file mode 100644 index 0000000..c0e5e05 --- /dev/null +++ b/nvim/nixos/default.nix @@ -0,0 +1,7 @@ +# NOTE: to add more language support, make a directory under `nixos`, followed by the language name and `default.nix`. See `dotnet/default.nix` for example. +{ + imports = [ + ./dotnet + ./neovim + ]; +} diff --git a/nvim/nixos/dotnet/default.nix b/nvim/nixos/dotnet/default.nix new file mode 100644 index 0000000..af671e1 --- /dev/null +++ b/nvim/nixos/dotnet/default.nix @@ -0,0 +1,43 @@ +# This module provides DOTNET_ROOT, with a different way to install dotnet locally. +# This module is modified from the NixOS module `programs.dotnet` + +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.programs.dotnet.dev; +in +{ + options = { + programs.dotnet.dev = { + enable = mkEnableOption "" // { + description = '' + Install the DotNet runtime and set the + {env}`DOTNET_ROOT` variable. + ''; + }; + environmentVariables = mkOption { + type = with types; lazyAttrsOf (oneOf [ str path int float ]); + default = { }; + example = { DOTNET_SYSTEM_GLOBALIZATION_INVARIANT = "0"; }; + description = '' + An attribute set an environment variable for DotNET. + ''; + }; + package = mkOption { + type = types.package; + default = pkgs.dotnet-sdk_7; + defaultText = literalExpression "pkgs.dotnet-sdk_7"; + description = "DotNET package to install."; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + # Please see https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_root-dotnet_rootx86 + home.sessionVariables = { + DOTNET_ROOT = "${cfg.package}"; + } // cfg.environmentVariables; + }; +} diff --git a/nvim/nixos/neovim/default.nix b/nvim/nixos/neovim/default.nix new file mode 100644 index 0000000..420e7fa --- /dev/null +++ b/nvim/nixos/neovim/default.nix @@ -0,0 +1,232 @@ +# home-manager module of neovim setup +{ config +, lib +, pkgs +, ... +}: +let + cfg = config.programs.neovim.nvimdots; + inherit (lib) flip warn const; + inherit (lib.attrsets) optionalAttrs; + inherit (lib.lists) optionals; + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.strings) concatStringsSep versionOlder versionAtLeast; + inherit (lib.types) listOf coercedTo package functionTo; +in +{ + options = { + programs.neovim = { + nvimdots = { + enable = mkEnableOption '' + Activate "ayamir/nvimdots". + Have a look at https://github.com/ayamir/nvimdots for details + ''; + bindLazyLock = mkEnableOption '' + Bind lazy-lock.json in your repository to $XDG_CONFIG_HOME/nvim. + Very powerful in terms of keeping the environment consistent, but has the following side effects. + You cannot update it even if you run the Lazy command, because it binds read-only. + You need to remove lazy-lock.json before enabling this option if `mergeLazyLock` is set. + ''; + mergeLazyLock = mkEnableOption '' + Merges the managed lazy-lock.json with the existing one under $XDG_CONFIG_HOME/nvim if its hash has changed on activation. + Upstream package version changes have high priority. + This means changes to lazy-lock.json in the config directory (likely due to installing package) will be preserved. + In other words, it achieves environment consistency while remaining adaptable to changes. + You need to unlink lazy-lock.json before enabling this option if `bindLazyLock` is set. + Please refer to the wiki for details on the behavior. + ''; + setBuildEnv = mkEnableOption '' + Sets environment variables that resolve build dependencies as required by `mason.nvim` and `nvim-treesitter` + Environment variables are only visible to `nvim` and have no effect on any parent sessions. + Required for NixOS. + ''; + withBuildTools = mkEnableOption '' + Include basic build tools like `gcc` and `pkg-config`. + Required for NixOS. + ''; + withHaskell = mkEnableOption '' + Enable the Haskell compiler. Set to `true` to + use Haskell plugins. + ''; + extraHaskellPackages = mkOption { + type = + let + fromType = listOf package; + in + coercedTo fromType + (flip warn const '' + Assigning a plain list to extraHaskellPackages is deprecated. + Please assign a function taking a package set as argument, so + extraHaskellPackages = [ pkgs.haskellPackages.xxx ]; + should become + extraHaskellPackages = ps: [ ps.xxx ]; + '') + (functionTo fromType); + default = _: [ ]; + defaultText = literalExpression "ps: [ ]"; + example = literalExpression "hsPkgs: with hsPkgs; [ mtl ]"; + description = '' + The extra Haskell packages required for your plugins to work. + This option accepts a function that takes a Haskell package set as an argument, + and selects the required Haskell packages from this package set. + See the example for more info. + ''; + }; + extraDependentPackages = mkOption { + type = listOf package; + default = [ ]; + example = literalExpression "[ pkgs.openssl ]"; + description = "Extra build depends to add `LIBRARY_PATH` and `CPATH`."; + }; + }; + }; + }; + config = + let + # Inspired from https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/programs/nix-ld.nix + build-dependent-pkgs = builtins.filter (package: !package.meta.unsupported) [ + # manylinux + pkgs.acl + pkgs.attr + pkgs.bzip2 + pkgs.curl + pkgs.glibc + pkgs.libsodium + pkgs.libssh + pkgs.libxml2 + pkgs.openssl + pkgs.stdenv.cc.cc + pkgs.stdenv.cc.cc.lib + pkgs.systemd + pkgs.util-linux + pkgs.xz + pkgs.zlib + pkgs.zstd + # Packages not included in `nix-ld`'s NixOSModule + pkgs.glib + pkgs.libcxx + ] + ++ cfg.extraDependentPackages; + + neovim-build-deps = pkgs.buildEnv { + name = "neovim-build-deps"; + paths = build-dependent-pkgs; + extraOutputsToInstall = [ "dev" ]; + pathsToLink = [ "/lib" "/include" ]; + ignoreCollisions = true; + }; + + buildEnv = [ + ''CPATH=''${CPATH:+''${CPATH}:}${neovim-build-deps}/include'' + ''CPLUS_INCLUDE_PATH=''${CPLUS_INCLUDE_PATH:+''${CPLUS_INCLUDE_PATH}:}:${neovim-build-deps}/include/c++/v1'' + ''LD_LIBRARY_PATH=''${LD_LIBRARY_PATH:+''${LD_LIBRARY_PATH}:}${neovim-build-deps}/lib'' + ''LIBRARY_PATH=''${LIBRARY_PATH:+''${LIBRARY_PATH}:}${neovim-build-deps}/lib'' + ''NIX_LD_LIBRARY_PATH=''${NIX_LD_LIBRARY_PATH:+''${NIX_LD_LIBRARY_PATH}:}${neovim-build-deps}/lib'' + ''PKG_CONFIG_PATH=''${PKG_CONFIG_PATH:+''${PKG_CONFIG_PATH}:}${neovim-build-deps}/include/pkgconfig'' + ]; + in + mkIf cfg.enable { + assertions = [ + { + assertion = ! (cfg.bindLazyLock && cfg.mergeLazyLock); + message = "bindLazyLock and mergeLazyLock cannot be enabled at the same time."; + } + ]; + xdg.configFile = { + "nvim/init.lua".source = ../../init.lua; + "nvim/lua".source = ../../lua; + "nvim/snips".source = ../../snips; + "nvim/tutor".source = ../../tutor; + } // optionalAttrs cfg.bindLazyLock { + "nvim/lazy-lock.json".source = ../../lazy-lock.json; + } // optionalAttrs cfg.mergeLazyLock { + "nvim/lazy-lock.fixed.json" = { + source = ../../lazy-lock.json; + onChange = '' + if [ -f ${config.xdg.configHome}/nvim/lazy-lock.json ]; then + tmp=$(mktemp) + ${pkgs.jq}/bin/jq -r -s '.[0] * .[1]' ${config.xdg.configHome}/nvim/lazy-lock.json ${config.xdg.configFile."nvim/lazy-lock.fixed.json".source} > "''${tmp}" && mv "''${tmp}" ${config.xdg.configHome}/nvim/lazy-lock.json + else + ${pkgs.rsync}/bin/rsync --chmod 644 ${config.xdg.configFile."nvim/lazy-lock.fixed.json".source} ${config.xdg.configHome}/nvim/lazy-lock.json + fi + ''; + }; + }; + home = { + packages = [ + pkgs.ripgrep + ]; + shellAliases = optionalAttrs (cfg.setBuildEnv && (versionOlder config.home.stateVersion "24.05")) { + nvim = concatStringsSep " " buildEnv + " nvim"; + }; + }; + programs.neovim = { + enable = true; + + withNodeJs = true; + withPython3 = true; + + extraPackages = [ + # Dependent packages used by default plugins + pkgs.doq + pkgs.tree-sitter + ] + ++ optionals cfg.withBuildTools [ + pkgs.cargo + pkgs.clang + pkgs.cmake + pkgs.gcc + pkgs.gnumake + pkgs.go + pkgs.lua51Packages.luarocks + pkgs.ninja + pkgs.pkg-config + pkgs.yarn + ] + ++ optionals cfg.withHaskell [ + (pkgs.writeShellApplication { + name = "stack"; + text = '' + exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${config.home.profileDirectory}/lib/nvim-depends/include" "--extra-lib-dirs=${config.home.profileDirectory}/lib/nvim-depends/lib" "$@" + ''; + }) + (pkgs.haskellPackages.ghcWithPackages (ps: cfg.extraHaskellPackages ps)) + ]; + + extraPython3Packages = ps: with ps; [ + docformatter + isort + pynvim + ]; + } + // optionalAttrs (versionAtLeast config.home.stateVersion "24.05") { + extraWrapperArgs = optionals cfg.setBuildEnv [ + "--suffix" + "CPATH" + ":" + "${neovim-build-deps}/include" + "--suffix" + "CPLUS_INCLUDE_PATH" + ":" + "${neovim-build-deps}/include/c++/v1" + "--suffix" + "LD_LIBRARY_PATH" + ":" + "${neovim-build-deps}/lib" + "--suffix" + "LIBRARY_PATH" + ":" + "${neovim-build-deps}/lib" + "--suffix" + "PKG_CONFIG_PATH" + ":" + "${neovim-build-deps}/include/pkgconfig" + "--suffix" + "NIX_LD_LIBRARY_PATH" + ":" + "${neovim-build-deps}/lib" + ]; + }; + }; +} diff --git a/nvim/nixos/testEnv.nix b/nvim/nixos/testEnv.nix new file mode 100644 index 0000000..3fed9cf --- /dev/null +++ b/nvim/nixos/testEnv.nix @@ -0,0 +1,34 @@ +{ inputs, pkgs, ... }: +let + testSettings = { config, ... }: { + warnings = [ + "home-manager version: ${config.home.version.release}" + ]; + home = { + username = "hm-user"; + homeDirectory = "/home/hm-user"; + stateVersion = config.home.version.release; + }; + xdg.enable = true; + programs = { + home-manager.enable = true; + git.enable = true; + neovim = { + enable = true; + nvimdots = { + enable = true; + setBuildEnv = true; + withBuildTools = true; + withHaskell = true; + }; + }; + }; + }; +in +inputs.home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + ./default.nix + testSettings + ]; +} diff --git a/nvim/scripts/install.ps1 b/nvim/scripts/install.ps1 new file mode 100644 index 0000000..910abc8 --- /dev/null +++ b/nvim/scripts/install.ps1 @@ -0,0 +1,416 @@ +#Requires -Version 7.1 + +# We don't need return codes for "$(command)", only stdout is needed. +# Allow `func "$(command)"`, pipes, etc. + +Set-StrictMode -Version 3.0 + +$ErrorActionPreference = "Stop" # Exit when command fails + +# global-scope vars +$USE_SSH = $True +$REQUIRED_NVIM_VERSION = [version]'0.10.0' +$REQUIRED_NVIM_VERSION_LEGACY = [version]'0.9.0' + +# package mgr vars +$choco_package_matrix = @{ "gcc" = "mingw"; "git" = "git"; "nvim" = "neovim"; "make" = "make"; "sudo" = "psutils"; "node" = "nodejs"; "pip" = "python3"; "fzf" = "fzf"; "rg" = "ripgrep"; "go" = "go"; "curl" = "curl"; "wget" = "wget"; "tree-sitter" = "tree-sitter"; "ruby" = "ruby"; "rustc" = "rust-ms" } +$scoop_package_matrix = @{ "gcc" = "mingw"; "git" = "git"; "nvim" = "neovim"; "make" = "make"; "sudo" = "psutils"; "node" = "nodejs"; "pip" = "python"; "fzf" = "fzf"; "rg" = "ripgrep"; "go" = "go"; "curl" = "curl"; "wget" = "wget"; "tree-sitter" = "tree-sitter"; "ruby" = "ruby"; "rustc" = "rust" } +$installer_pkg_matrix = @{ "NodeJS" = "npm"; "Python" = "pip"; "Ruby" = "gem" } + +# env vars +$env:XDG_CONFIG_HOME ??= $env:LOCALAPPDATA +$env:CCPACK_MGR ??= 'unknown' +$env:CCLONE_ATTR ??= 'undef' +$env:CCLONE_BRANCH ??= 'main' +$env:CCLONE_BRANCH_LEGACY ??= '0.9' +$env:CCDEST_DIR ??= "$env:XDG_CONFIG_HOME\nvim" +$env:CCBACKUP_DIR = "$env:CCDEST_DIR" + "_backup-" + (Get-Date).ToUniversalTime().ToString("yyyyMMddTHHmmss") + +function _abort ([Parameter(Mandatory = $True)] [string]$Msg,[Parameter(Mandatory = $True)] [string]$Type,[Parameter(Mandatory = $False)] [string]$ExtMsg) { + if ($ExtMsg -ne $null) { + Write-Host $ExtMsg + } + Write-Error -Message "Error: $Msg" -Category $Type + exit 1 +} + +function _chomp ([Parameter(Mandatory = $True)] [string]$Str) { + return [string]::Join("\n",([string]::Join("\r",($Str.Split("`r"))).Split("`n"))) +} + +# Check if script is run with non-interactive mode, this is not allowed +# Returns $True if validation failed (i.e., in non-interactive mode) +function test_host { + $NonInteractive = [System.Environment]::GetCommandLineArgs() | Where-Object { $_ -like '-NonI*' } + if ([System.Environment]::UserInteractive -and -not $NonInteractive) { + return $False + } else { + return $True + } +} + +function info ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$Msg) { + Write-Host "==> " -ForegroundColor Blue -NoNewline; Write-Host $(_chomp -Str $Msg); +} + +function info_ext ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$Msg) { + Write-Host " $(_chomp -Str $Msg)" +} + +function warn ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$Msg) { + Write-Host "Warning:" -ForegroundColor Yellow -NoNewline; Write-Host " $(_chomp -Str $Msg)"; +} + +function warn_ext ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$Msg) { + Write-Host " $(_chomp -Str $Msg)" +} + +function safe_execute ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [scriptblock]$WithCmd) { + try { + Invoke-Command -ErrorAction Stop -ScriptBlock $WithCmd + if (-not $?) { + throw # Also stop the script if cmd failed + } + } + catch { + _abort -Msg "Failed during: $WithCmd" -Type "InvalidResult" + } +} + +function wait_for_user { + Write-Host "" + Write-Host "Press " -NoNewline; Write-Host "RETURN" -ForegroundColor White -BackgroundColor DarkGray -NoNewline; Write-Host "/" -NoNewline; Write-Host "ENTER" -ForegroundColor White -BackgroundColor DarkGray -NoNewline; Write-Host " to continue or any other key to abort..."; + $ks = [System.Console]::ReadKey() + if ($ks.Key -ne 'Enter') { + Write-Host "" + _abort -Msg "Aborted." -Type "OperationStopped" + } +} + +function check_ssh { + info -Msg "Validating SSH connection..." + Invoke-Command -ErrorAction SilentlyContinue -ScriptBlock { ssh -T git@github.com *> $null } + if ($LastExitCode -ne 1) { + info -Msg "We'll use HTTPS to fetch and update plugins." + return $True + } else { + $_title = "Fetch Preferences" + $_message = "Do you prefer to use SSH to fetch and update plugins? (otherwise HTTPS)" + + $_opt_ssh = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Will use SSH to fetch and update plugins in the future" + $_opt_https = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Will use HTTPS to fetch and update plugins in the future" + + $USR_CHOICE = $Host.ui.PromptForChoice($_title,$_message,[System.Management.Automation.Host.ChoiceDescription[]]($_opt_ssh,$_opt_https),0) + if ($USR_CHOICE -eq 0) { + return $False + } else { + return $True + } + } +} + +function check_clone_pref { + info -Msg "Checking 'git clone' preferences..." + + $_title = "'git clone' Preferences" + $_message = "Would you like to perform a shallow clone ('--depth=1')?" + + $_opt_yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Will append '--depth=1' to 'git clone' options" + $_opt_no = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Do nothing" + + $USR_CHOICE = $Host.ui.PromptForChoice($_title,$_message,[System.Management.Automation.Host.ChoiceDescription[]]($_opt_yes,$_opt_no),0) + if ($USR_CHOICE -eq 0) { + $env:CCLONE_ATTR = '--depth=1' + } else { + $env:CCLONE_ATTR = '--progress' + } +} + +function check_in_path ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$WithName) { + if ((Get-Command $WithName -ErrorAction SilentlyContinue)) { + return $True + } else { + return $False + } +} + +function query_pack { + if ((check_in_path -WithName "scoop") -and (check_in_path -WithName "choco")) { + info -Msg " [Detected] Multiple package managers detected." + + $_title = "Package manager Preferences" + $_message = "Pick your favorite package manager" + + $_opt_scoop = New-Object System.Management.Automation.Host.ChoiceDescription "&Scoop","Will use 'scoop' to install dependencies" + $_opt_choco = New-Object System.Management.Automation.Host.ChoiceDescription "&Chocolatey","Will use 'choco' to install dependencies" + + $USR_CHOICE = $Host.ui.PromptForChoice($_title,$_message,[System.Management.Automation.Host.ChoiceDescription[]]($_opt_scoop,$_opt_choco),0) + if ($USR_CHOICE -eq 0) { + $env:CCPACK_MGR = 'scoop' + } else { + $env:CCPACK_MGR = 'choco' + } + } elseif ((check_in_path -WithName "scoop")) { + info -Msg " [Detected] We'll use 'Scoop' as the default package mgr." + $env:CCPACK_MGR = 'scoop' + } elseif ((check_in_path -WithName "choco")) { + info -Msg " [Detected] We'll use 'Chocolatey' as the default package mgr." + $env:CCPACK_MGR = 'choco' + } else { + _abort -Msg "Required executable not found." -Type "NotInstalled" -ExtMsg @' +You must install a modern package manager before installing this Nvim config. +Available choices are: + - Chocolatey + https://chocolatey.org/install#individual + ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ + - Scoop + https://scoop.sh/ + ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +[INFO] "scoop" and "choco" are both either not installed, missing from PATH, or not executable. + +'@ + } +} + +function init_pack { + info -Msg "Initializing package manager preferences..." + if ($env:CCPACK_MGR -ne 'unknown') { + info -Msg '$env:CCPACK_MGR already defined. Validating...' + if (($env:CCPACK_MGR -eq 'choco') -and (check_in_path -WithName $env:CCPACK_MGR)) { + info -Msg "We'll use 'Chocolatey' as the default package mgr." + } elseif (($env:CCPACK_MGR -eq 'scoop') -and (check_in_path -WithName $env:CCPACK_MGR)) { + info -Msg "We'll use 'Scoop' as the default package mgr." + } else { + info -Msg "Validation failed. Fallback to query." + query_pack + } + } else { + query_pack + } +} + +function _install_exe ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$WithName) { + if ($env:CCPACK_MGR -eq 'choco') { + Write-Host "Attempting to install dependency [" -NoNewline; Write-Host $WithName -ForegroundColor Green -NoNewline; Write-Host "] with Chocolatey" + $_inst_name = $choco_package_matrix[$WithName] + safe_execute -WithCmd { choco install "$_inst_name" -y } + } + elseif ($env:CCPACK_MGR -eq 'scoop') { + Write-Host "Attempting to install dependency [" -NoNewline; Write-Host $WithName -ForegroundColor Green -NoNewline; Write-Host "] with Scoop" + $_inst_name = $scoop_package_matrix[$WithName] + safe_execute -WithCmd { scoop install "$_inst_name" } + } else { + _abort -Msg 'This function is invoked incorrectly - Invalid data: $env:CCPACK_MGR' -Type "InvalidOperation" + } +} + +function _install_nodejs_deps { + safe_execute -WithCmd { npm install --global neovim tree-sitter-cli } +} + +function _install_python_deps { + safe_execute -WithCmd { python -m pip install --user wheel } + safe_execute -WithCmd { python -m pip install --user pynvim } +} + +function _install_ruby_deps { + safe_execute -WithCmd { gem install neovim } + safe_execute -WithCmd { ridk install } +} + +function check_and_fetch_exec ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$PkgName) { + $_str = "Checking dependency: '$PkgName'" + " " * 15 + Write-Host $_str.substring(0,[System.Math]::Min(40,$_str.Length)) -NoNewline + + if (-not (check_in_path -WithName $PkgName)) { + Start-Sleep -Milliseconds 350 + Write-Host "Failed" -ForegroundColor Red + _install_exe -WithName $PkgName + } else { + Start-Sleep -Milliseconds 350 + Write-Host "Success" -ForegroundColor Green + } +} + +function confirm_dep_inst ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$PkgName) { + $_inst_name = $installer_pkg_matrix[$PkgName] + if (-not (check_in_path -WithName "$_inst_name")) { + _abort -Msg "This function is invoked incorrectly - The '$_inst_name' executable not found" -Type "InvalidOperation" + } else { + $_title = "Dependencies Installation" + $_message = "Would you like to check & install $PkgName dependencies?" + + $_opt_yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes","Will install $PkgName dependencies" + $_opt_no = New-Object System.Management.Automation.Host.ChoiceDescription "&No","Will SKIP installing $PkgName dependencies" + + $USR_CHOICE = $Host.ui.PromptForChoice($_title,$_message,[System.Management.Automation.Host.ChoiceDescription[]]($_opt_yes,$_opt_no),1) + if ($USR_CHOICE -eq 0) { + return $True + } else { + return $False + } + } +} + +function fetch_deps { + check_and_fetch_exec -PkgName "gcc" + check_and_fetch_exec -PkgName "git" + check_and_fetch_exec -PkgName "nvim" + check_and_fetch_exec -PkgName "make" + check_and_fetch_exec -PkgName "sudo" + check_and_fetch_exec -PkgName "node" + check_and_fetch_exec -PkgName "pip" + check_and_fetch_exec -PkgName "fzf" + check_and_fetch_exec -PkgName "rg" + check_and_fetch_exec -PkgName "ruby" + check_and_fetch_exec -PkgName "go" + check_and_fetch_exec -PkgName "curl" + check_and_fetch_exec -PkgName "wget" + check_and_fetch_exec -PkgName "rustc" + check_and_fetch_exec -PkgName "tree-sitter" + + # Reload PATH for future use + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") +} + +function check_nvim_version ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [version]$RequiredVersionMin) { + $nvim_version = Invoke-Command -ErrorAction SilentlyContinue -ScriptBlock { nvim --version } # First get neovim version + $nvim_version = $nvim_version.Split([System.Environment]::NewLine) | Select-Object -First 1 # Then do head -n1 + $nvim_version = $nvim_version.Split('-') | Select-Object -First 1 # Special for dev branches + $nvim_version = $nvim_version -replace '[^(\d+(\.\d+)*)]','' # Then do regex replacement similar to sed + + $nvim_version = [version]$nvim_version + return ($nvim_version -ge $RequiredVersionMin) +} + +function clone_repo ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$WithURL) { + if ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION)) { + safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH" "$env:CCLONE_ATTR" $WithURL "$env:CCDEST_DIR" } + } elseif ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION_LEGACY)) { + warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION)." + info -Msg "Automatically redirecting you to the latest compatible version..." + safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH_LEGACY" "$env:CCLONE_ATTR" $WithURL "$env:CCDEST_DIR" } + } else { + warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION_LEGACY)." + _abort -Msg "This Neovim distribution is no longer supported." -Type "NotImplemented" -ExtMsg @" +You have a legacy Neovim distribution installed. +Please make sure you have nvim v$REQUIRED_NVIM_VERSION_LEGACY installed at the very least. + +"@ + } +} + +function ring_bell { + [System.Console]::beep() +} + +function _main { + if (-not $IsWindows) { + _abort -Msg "This install script can only execute on Windows." -Type "DeviceError" + } + + if ((test_host)) { + _abort -Msg "This script cannot proceed in non-interactive mode." -Type "NotImplemented" + } + + info -Msg "Checking dependencies..." + + init_pack + fetch_deps + + if ((confirm_dep_inst -PkgName "NodeJS")) { + _install_nodejs_deps + } + if ((confirm_dep_inst -PkgName "Python")) { + _install_python_deps + } + if ((confirm_dep_inst -PkgName "Ruby")) { + _install_ruby_deps + } + + # Check dependencies + if (-not (check_in_path -WithName "nvim")) { + _abort -Msg "Required executable not found." -Type "NotInstalled" -ExtMsg @' +You must install Neovim before installing this Nvim config. See: + https://github.com/neovim/neovim/wiki/Installing-Neovim + ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +[INFO] "nvim" is either not installed, missing from PATH, or not executable. + +'@ + } + + if (-not (check_in_path -WithName "git")) { + _abort -Msg "Required executable not found." -Type "NotInstalled" -ExtMsg @' +You must install Git before installing this Nvim config. See: + https://git-scm.com/ + ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +[INFO] "git" is either not installed, missing from PATH, or not executable. + +'@ + } + + info -Msg "This script will install ayamir/nvimdots to:" + Write-Host $env:CCDEST_DIR + + if ((Test-Path $env:CCDEST_DIR)) { + warn -Msg "The destination folder: `"$env:CCDEST_DIR`" already exists." + warn_ext -Msg "We will make a backup for you at `"$env:CCBACKUP_DIR`"." + } + + ring_bell + wait_for_user + if ((check_ssh)) { + $USE_SSH = $False + } + check_clone_pref + + if ((Test-Path $env:CCDEST_DIR)) { + safe_execute -WithCmd { Move-Item -Path "$env:CCDEST_DIR" -Destination "$env:CCBACKUP_DIR" -Force } + } + + info -Msg "Fetching in progress..." + + if ($USE_SSH) { + clone_repo -WithURL 'git@github.com:ayamir/nvimdots.git' + } else { + clone_repo -WithURL 'https://github.com/ayamir/nvimdots.git' + } + + safe_execute -WithCmd { Set-Location -Path "$env:CCDEST_DIR" } + safe_execute -WithCmd { Copy-Item -Path "$env:CCDEST_DIR\lua\user_template\" -Destination "$env:CCDEST_DIR\lua\user" -Recurse -Force } + + if (-not $USE_SSH) { + info -Msg "Changing default fetching method to HTTPS..." + safe_execute -WithCmd { + (Get-Content "$env:CCDEST_DIR\lua\user\settings.lua") | + ForEach-Object { $_ -replace '\["use_ssh"\] = true','["use_ssh"] = false' } | + Set-Content "$env:CCDEST_DIR\lua\user\settings.lua" + } + } + + info -Msg "Spawning Neovim and fetching plugins... (You'll be redirected shortly)" + info -Msg 'Please make sure you have a Rust Toolchain installed via `rustup`! Otherwise, unexpected things may' + info_ext -Msg 'happen. See: https://www.rust-lang.org/tools/install.¯¯¯¯¯¯¯¯¯¯¯¯' + info_ext -Msg ' ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯' + info -Msg 'If lazy.nvim failed to fetch any plugin(s), maunally execute `:Lazy sync` until everything is up-to-date.' + Write-Host @' + +Thank you for using this set of configuration! +- Project Homepage: + https://github.com/ayamir/nvimdots + ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +- Further documentation (including executables you |must| install for full functionality): + https://github.com/ayamir/nvimdots/wiki/Prerequisites + ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +'@ + + ring_bell + wait_for_user + + safe_execute -WithCmd { nvim } + + # Exit the script + exit +} + +_main diff --git a/nvim/scripts/install.sh b/nvim/scripts/install.sh new file mode 100755 index 0000000..0d1e113 --- /dev/null +++ b/nvim/scripts/install.sh @@ -0,0 +1,304 @@ +#!/usr/bin/env bash + +# We don't need return codes for "$(command)", only stdout is needed. +# Allow `[[ -n "$(command)" ]]`, `func "$(command)"`, pipes, etc. +# shellcheck disable=SC2312 + +set -uo pipefail + +# global-scope vars +REQUIRED_NVIM_VERSION=0.10.0 +REQUIRED_NVIM_VERSION_LEGACY=0.9.0 +USE_SSH=1 +CLONE_ATTR=("--progress") +DEST_DIR="${HOME}/.config/nvim" +BACKUP_DIR="${DEST_DIR}_backup-$(date +%Y%m%dT%H%M%S)" + +abort() { + printf "%s\n" "$@" >&2 + exit 1 +} + +# Fail fast with a concise message when not using bash +# Single brackets are needed here for POSIX compatibility +# shellcheck disable=SC2292 +if [ -z "${BASH_VERSION:-}" ]; then + abort "Bash is required to interpret this script." +fi + +# Check if script is run with force-interactive mode in CI +if [[ -n "${CI-}" && -n "${INTERACTIVE-}" ]]; then + abort "Cannot run force-interactive mode in CI." +fi + +# String formatters +if [[ -t 1 ]]; then + tty_escape() { printf "\033[%sm" "$1"; } +else + tty_escape() { :; } +fi + +tty_mkbold() { tty_escape "1;$1"; } +tty_underline="$(tty_escape "4;39")" +tty_yellow="$(tty_escape "0;33")" +tty_blue="$(tty_mkbold 34)" +tty_red="$(tty_mkbold 31)" +tty_bold="$(tty_mkbold 39)" +tty_reset="$(tty_escape 0)" + +shell_join() { + local arg + printf "%s" "$1" + shift + for arg in "$@"; do + printf " " + printf "%s" "${arg// /\ }" + done +} + +execute() { + if ! "$@"; then + abort "$(printf "Failed during: %s" "$(shell_join "$@")")" + fi +} + +major_minor() { + echo "${1%%.*}.$( + x="${1#*.}" + echo "${x%%.*}" + )" +} + +chomp() { + printf "%s" "${1/"$'\n'"/}" +} + +info() { + printf "${tty_blue}==>${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")" +} + +info_ext() { + printf "${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")" +} + +warn() { + printf "${tty_yellow}Warning:${tty_reset} %s\n" "$(chomp "$1")" +} + +warn_ext() { + printf " %s\n" "$(chomp "$1")" +} + +getc() { + local save_state + save_state="$(/bin/stty -g)" + /bin/stty raw -echo + IFS='' read -r -n 1 -d '' "$@" + /bin/stty "${save_state}" +} + +ring_bell() { + # Use the shell's audible bell + if [[ -t 1 ]]; then + printf "\a" + fi +} + +wait_for_user() { + local c + printf "\n" + echo "Press ${tty_bold}RETURN${tty_reset}/${tty_bold}ENTER${tty_reset} to continue or any other key to abort..." + getc c + # we test for \r and \n because some stuff does \r instead + if ! [[ "$c" == $'\r' || "$c" == $'\n' ]]; then + abort "${tty_red}Aborted.${tty_reset}" + fi +} + +version_ge() { + [[ "${1%.*}" -gt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -ge "${2#*.}" ]] +} + +prompt_confirm() { + local choice + while true; do + read -r -p "$1 [Y/n]: " choice + case "$choice" in + [yY][eE][sS] | [yY]) + return 1 + ;; + [nN][oO] | [nN]) + return 0 + ;; + *) + if [[ -z "$choice" ]]; then + return 1 + fi + printf "${tty_red}%s\n\n${tty_reset}" "Input invalid! Please enter one of the following: '[y/yes]' or '[n/no]'." + ;; + esac + done +} + +check_ssh() { + info "Validating SSH connection..." + ssh -T git@github.com &>/dev/null + if ! [ $? -eq 1 ]; then + info "We'll use HTTPS to fetch and update plugins." + return 0 + else + prompt_confirm "Do you prefer to use SSH to fetch and update plugins? (otherwise HTTPS)" + return $? + fi +} + +clone_pref() { + info "Checking 'git clone' preferences..." + if ! prompt_confirm "Would you like to perform a shallow clone ('--depth=1')?"; then + CLONE_ATTR+=("--depth=1") + fi +} + +check_nvim_version() { + local nvim_version + nvim_version="$(nvim --version | head -n1 | sed -e 's|^[^0-9]*||' -e 's| .*||')" + if version_ge "$(major_minor "${nvim_version##* }")" "$(major_minor "$1")"; then + return 0 + else + return 1 + fi +} + +clone_repo() { + if check_nvim_version "${REQUIRED_NVIM_VERSION}"; then + execute "git" "clone" "-b" "main" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}" + elif check_nvim_version "${REQUIRED_NVIM_VERSION_LEGACY}"; then + warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION})." + info "Automatically redirecting you to the latest compatible version..." + execute "git" "clone" "-b" "0.9" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}" + else + warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION_LEGACY})." + abort "$( + cat </dev/null; then + abort "$( + cat </dev/null; then + abort "$( + cat </dev/null; then + abort "$( + cat <", + "", + "using namespace std;", + "", + "class Solution", + "{", + "public:", + "\t$1 $2($3) {", + "\t\t$4", + "\t}", + "};", + "", + "int main(int argc, char *argv[]) {", + "\tSolution s;", + "\treturn 0;", + "}" + ], + "description": "leetcode template" + }, + "hdef": { + "prefix": "hdef", + "body": [ + "#ifndef $1", + "#define $1", + "", + "#endif // $1" + ], + "description": "header file definitions" + } +} diff --git a/nvim/snips/snippets/go.json b/nvim/snips/snippets/go.json new file mode 100644 index 0000000..ec8bd55 --- /dev/null +++ b/nvim/snips/snippets/go.json @@ -0,0 +1,17 @@ +{ + "map declaration": { + "prefix": "map", + "body": "map[${1:type}]${2:type}", + "description": "Snippet for a map" + }, + "goroutine anonymous function": { + "prefix": "go", + "body": "go func($1) {\n\t$0\n}($2)", + "description": "Snippet for anonymous goroutine declaration" + }, + "goroutine function": { + "prefix": "gf", + "body": "go ${1:func}($0)", + "description": "Snippet for goroutine declaration" + } +} diff --git a/nvim/stylua.toml b/nvim/stylua.toml new file mode 100644 index 0000000..b1aeb38 --- /dev/null +++ b/nvim/stylua.toml @@ -0,0 +1,6 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Tabs" +indent_width = 4 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" diff --git a/nvim/tutor/dots.tutor b/nvim/tutor/dots.tutor new file mode 100644 index 0000000..c4232b1 --- /dev/null +++ b/nvim/tutor/dots.tutor @@ -0,0 +1,157 @@ +# Welcome to the nvimdots Tutor + +Nvimdots is a [Neovim](https://neovim.io/) config suite designed for extensibility, performance, and ease +of use. It provides the ability to work with text files yet feels like you are +working within an IDE environment. + +This tutor will walk you through how to utilize our configuration to use neovim as a +powerful code editor. + +As a modern neovim config, it provides all the features you need: code completion, +(partial) code testing, tree-sitter, DAP, fuzzy find, and more. It comes with state- +of-the-art (SOTA) neovim plugins from the community to provide the best user +experience. + +The default []() key is ``{normal}. + +The approximate time required to complete the tutorial is 5 minutes, although the +exact duration may vary depending on the amount of time spent experimenting. + +# Lesson 1.1: EXPLANATION OF THE UI + +The opened buffers are shown at the top; you can use ``{normal} and ``{normal} to switch +between them. Also, ``{normal} (with `n`{normal} being any number between 1-9) can be used to +switch to the desired buffer directly. + +NOTE: macOS users may need to remap their `