From 02b503c15e9cf157071ec245e869b564a32c135a Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 19 Aug 2021 22:04:04 +0200 Subject: [PATCH 001/188] Fix package name (nvim -> neovim) --- packages.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages.yaml b/packages.yaml index 3add816..b106d5d 100644 --- a/packages.yaml +++ b/packages.yaml @@ -2,7 +2,7 @@ pacman: # Common - base-devel # Necessary for building AUR and yay install - git - - nvim + - neovim - sudo - networkmanager - net-tools From ee5e3a5fd1d99b37a444c4503a2c35ca9c15bf8c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 19 Aug 2021 23:26:06 +0200 Subject: [PATCH 002/188] Add cfxprofile aliase --- home/.config/shell/aliases | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 9db8d44..02b983c 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -70,6 +70,7 @@ alias cfenv='cfenvironment' alias cfhandlers='vim ~/.config/shell/handlers' alias cfprompt='vim ~/.config/shell/prompt' alias cfkeybinds='vim ~/.config/shell/keybinds' +alias cfxprofile='vim ~/.config/x11/xprofile' alias cfxmonad='vim ~/.config/xmonad/xmonad.hs && xmonad --recompile && xmonad --restart' alias cfxmobar='vim ~/.config/xmobar/xmobarrc.hs && ~/.config/xmobar/multi_mon.sh 2' alias cftodo='vim ~/Personal/todo' @@ -150,6 +151,7 @@ alias cpu-stress='for i in $(seq $(getconf _NPROCESSORS_ONLN)); do yes > /dev/nu alias nvidia='__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia' # Run app with nvidia (on hybrid mode with optimus) alias swapout='sudo swapoff -a; sudo swapon -a' # Reset swap (move everything to RAM) alias mount-ram='mount -t tmpfs tmpfs' # Mount RAM disk for fast filesystem +alias screenlock='xset s activate' # Use DPMS to trigger xss-lock and handle screen locking # System info alias meminfo='free -m -l -t' From 897e6268f498b03b770c8ae22955e0291810ff66 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 20 Aug 2021 12:58:39 +0200 Subject: [PATCH 003/188] Add hyperfine --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index b106d5d..aaa2900 100644 --- a/packages.yaml +++ b/packages.yaml @@ -12,6 +12,7 @@ pacman: # CLI/TUI - pacman-contrib # Contains many useful scripts for pacman, such as paccache - exa # Modern ls replacement + - hyperfine # Speed benchmark for given commands - ncdu # Show folder sizes in a neat CLI graphical way - cron # Scheduling program - pkgfile # Pacman metadata explorer From b37e158eb6cf4ed02ca43ddc174273c66dd21780 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 20 Aug 2021 16:41:01 +0200 Subject: [PATCH 004/188] Add ffmpegthumbnailer --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index aaa2900..8c16f13 100644 --- a/packages.yaml +++ b/packages.yaml @@ -82,6 +82,7 @@ pacman: - mpv # Video player, alternatively there's kde default dragon - nomacs # Photo viewer, alternatively there's kde default gwenview - ffmpegthumbs # FFmpeg based thumbnail creator for videos + - ffmpegthumbnailer # Ffmpeg based thumbnail creator for file mgrs - alacritty # very fast terminal emulator - pcmanfm # File manager - discord # Popular chat app From 59ea70aef406bf531224b3cf315ee5efa035c1ad Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 20 Aug 2021 20:11:41 +0200 Subject: [PATCH 005/188] Show datetime on xsecurelock --- home/.config/shell/environment | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/shell/environment b/home/.config/shell/environment index 74c9b58..0caff6b 100755 --- a/home/.config/shell/environment +++ b/home/.config/shell/environment @@ -58,5 +58,6 @@ fi export SUDO_ASKPASS="$HOME/.local/bin/scripts/dmenu/dmenupass" export PIPENV_VENV_IN_PROJECT=1 # Force pipenv to create new environments within projects ./.venv export XSECURELOCK_SHOW_HOSTNAME=0 # Don't show hostname in xsecurelock +export XSECURELOCK_SHOW_DATETIME=1 # Show current date and time in xsecurelock #export QT_QPA_PLATFORMTHEME="gtk2" # Have QT use gtk2 theme. From 026040b442094ee4bf6471aad445c61afabcf98c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 20 Aug 2021 20:11:52 +0200 Subject: [PATCH 006/188] Add abduco session multiplexer --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index 8c16f13..fb9165c 100644 --- a/packages.yaml +++ b/packages.yaml @@ -27,6 +27,7 @@ pacman: - mlocate # A tool for quick system file searching by building an index - httpie # Add comman for obtaining http info from webpages - calcurse # Terminal calendar and event planner + - abduco # Terminal session manager #- figlet # generate ascii text banners in terminal # ZSH + Plugins - zsh # shell From a3c5e04c674ed0d0eeee8b052d92346c6da4f0e9 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 20 Aug 2021 21:18:00 +0200 Subject: [PATCH 007/188] Use opensourced code-oss with ms vscode marketplace --- packages.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages.yaml b/packages.yaml index fb9165c..4185318 100644 --- a/packages.yaml +++ b/packages.yaml @@ -96,7 +96,7 @@ pacman: - krita # Image editing software (gimp alternative) - ueberzug # Tool for displaying images within a terminal - network-manager-applet # NetworkManager trayer icon - #- code # Open sourced version of vscode (doesn't support many extensions) + - code # Open sourced version of vscode (code-oss) # Fonts - libxft @@ -128,7 +128,7 @@ aur: - picom-git # Git version of picom compositor - spotify # Online music player - onlyoffice-bin # Full office suite (MS Office alternative) - - visual-studio-code-bin # Official vVsual Studio Code text editor for programmers + - code-marketplace # Enable the offical MS vscode marketplace for 'code' (code-oss) - exodus # Software cryptocurrency wallet - notion-app # Online text manipulation tool with databases and very rich interface #- mailspring-libre # Beautiful and fast mail client, without tracking of default mailspring From b34dd5086722c5e72eb7e135d474204884d0ab7b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 23 Aug 2021 01:17:39 +0200 Subject: [PATCH 008/188] Add multiple packages --- packages.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages.yaml b/packages.yaml index fb9165c..f7d8927 100644 --- a/packages.yaml +++ b/packages.yaml @@ -27,6 +27,8 @@ pacman: - mlocate # A tool for quick system file searching by building an index - httpie # Add comman for obtaining http info from webpages - calcurse # Terminal calendar and event planner + - imagemagick # Terminal image manipulation + - mediainfo # Show info about media files (videos/photos) - abduco # Terminal session manager #- figlet # generate ascii text banners in terminal # ZSH + Plugins @@ -72,9 +74,11 @@ pacman: - xmonad - xmonad-contrib - xmobar + - xwallpaper - xss-lock - xsecurelock - numlockx + - papirus-icon-theme # Breeze inspired icon theme # GUI - trayer # System tray @@ -105,6 +109,7 @@ pacman: - noto-fonts - noto-fonts-cjk - noto-fonts-emoji + - ttf-font-awesome # Printer - cups # Daemon for printing @@ -119,6 +124,7 @@ aur: # CLI/TUI - lf # Terminal ranger-like file manager - ngrok # Forward your localhost without ip recovery + - pixterm # A tool for converting images to ANSI colored blocks # ZSH Extensions - z.lua # Quick jump tool (z [directory]) # Security From a30429a52d7c800c27b91390e782582f401f3941 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 23 Aug 2021 02:10:28 +0200 Subject: [PATCH 009/188] Categorize packages and remove unneeded ones --- packages.yaml | 226 ++++++++++++++++++++++++-------------------------- 1 file changed, 109 insertions(+), 117 deletions(-) diff --git a/packages.yaml b/packages.yaml index f7d8927..13af5e2 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1,106 +1,92 @@ pacman: # Common - - base-devel # Necessary for building AUR and yay install - - git - - neovim - - sudo - - networkmanager - - net-tools - - man-db - - rsync + - base-devel # A set of tools needed for building pkgs + - git # Version control system + - neovim # Text editor (modern version of VIM) + - sudo # Execute commands as root from unprivilledged user + - networkmanager # Easy way to manage network connections, especially for WiFi + - man-db # A utility for reading manpages + - rsync # Fast tool for copying/syncing files + - cronie # Run programs at specified time + - zsh # Modern system shell + + # CLI + - exa # Colored LS + - bat # Colored cat with tons of cool options + - hyperfine # Command benchmark + - abduco # Terminal session manager + - mlocate # System indexing and quick file searching + - pkgfile # Pacman metadata explorer + - pacman-contrib # Includes multiple additional tools related to pacman + - lshw # List hardware components and their attributes + - trash-cli # Trash interraction (rather than permanent removal) + #- figlet # generate ascii text banners in terminal + + # TUI + - ncdu # Find largest folders (size) + - calcurse # Terminal calendar with todo + - bpytop # Modern system resource monitor + - links # Terminal text-only web browser + + # Networking/Internet + - httpie # Obtaining http info from webpages + - dnsutils # Tools for managing DNS + - net-tools # Configuration tools for linux networking + + # Media + - imagemagick # Terminal image manipulation + - mediainfo # Show info about media files (videos/photos) + - youtube-dl # Tool for easy downloading of youtube videos + - ffmpegthumbs # FFmpeg based thumbnail creator for videos + - ffmpegthumbnailer # Ffmpeg based thumbnail creator for file mgrs - # CLI/TUI - - pacman-contrib # Contains many useful scripts for pacman, such as paccache - - exa # Modern ls replacement - - hyperfine # Speed benchmark for given commands - - ncdu # Show folder sizes in a neat CLI graphical way - - cron # Scheduling program - - pkgfile # Pacman metadata explorer - - xsel # CLI tool for get/set contents of X11 clipboard (alternatively there's xclip) - - trash-cli # CLI tool to interract with trash (for example trash-put instead of rm will mv file to trash) - - youtube-dl # Tool for easy downloading of youtube videos - - ranger # Simple, vim-like file manager - - rmlint # Tool for finding and removing duplicate files quickly - - links # Terminal text-only web browser - - lshw # List hardware components and their attributes - - bat # Colored cat with tons of cool options - - mlocate # A tool for quick system file searching by building an index - - httpie # Add comman for obtaining http info from webpages - - calcurse # Terminal calendar and event planner - - imagemagick # Terminal image manipulation - - mediainfo # Show info about media files (videos/photos) - - abduco # Terminal session manager - #- figlet # generate ascii text banners in terminal - # ZSH + Plugins - - zsh # shell - - zsh-syntax-highlighting # colored zsh - - zsh-autosuggestions # Suggestions from previous commands - # KVM Virtualization - # For installation, you'll also have to enable service `libvirtd` and make a new bridge interface - # You'll also want to create a new bridge. Use a config file `br10.xml` - # This file is already located in `home/.config/network-bridge/br10.xml` if you use dotfiles installation - # Then you can define bridge with `virsh net-def br10.xml` and start it `virsh net-start br10` - # We will also want to autostart this interface with `virsh net-autostart br10` - # If further instructions are necessary, check `https://youtu.be/itZf5FpDcV0` for video tutorial - #- virt-manager # Frontend GUI for KVM - #- qemu # Base emulator and virtualizer - #- qemu-arch-extra # Virtualization for foregin architectures - #- ovmf # UEFI virtual machines (without it, only BIOS is possible) - #- vde2 # Networking tool - #- ebtables # Ethernet bridge filtering utilities - #- dnsmasq # Easy to configure DNS forwarder and DHCP server - #- bridge-utils # Ethernet bridge configuration (VMs should be using this bridge, not real interface) - #- openbsd-netcat # OpenBSD variant of netcat - #- virt-viewer # A viewer for virtualized machines, virt-manager alone doesn't support copy-paste # Security - - macchanger # Tool for changing MAC address - - dnsutils # Tools for managing DNS - - arch-audit # Similar to pkg-audit (AUR), based on Arch CVE Monitoring Team data - - apparmor # Mandantoy Access Control using Linux Security Module - # You'll want to also enable apparmor on boot with grub: - # Go to `/etc/default/grub` and append `apparmor=1 security=apparmor` to `GRUB_CMDLINE_LINUX_DEFAULT` variable, then run `grub-mkconfig -o /boot/grub/grub.cfg` - - audit # Framework for CAPP-compliant (Controlled Access Protection Profile) auditing system, that collects info about any relevant event on system, needed for apparmor profile generation (`auditd` service has to be enabled, and a boot param of audit=1 should be added - same process as above) - - lynis # Security and System auditing tool - - firejail # Sandboxing isolation tool - - clamav # Anti-virus toolkit - - rkhunter # Check for the presence of rootkits and other unwanted tools. - - step-cli - #- ufw # Uncomplicated firewall, a simple way of defining firewall (disabled, because opensnitch FW is more detailed and better) + - arch-audit # Find installed packgaes with vulnerabilities (Similar to pkg-audit) + - firejail # Sandboxing isolation tool + - lynis # Security and System auditing tool + - rkhunter # Check for the presence of rootkits and other unwanted tools. + - apparmor # Mandantoy Access Control using Linux Security Module + - audit # Collect system info about given events (requires audit=1 boot param) + #- ufw # Uncomplicated firewall (I prefer application level FW like opensnitch) + #- clamav # Anti-virus for Linux (usually only needed for servers) # WM/Xorg - - xorg-server - - xorg-xinit - - xorg-xrandr - - xmonad - - xmonad-contrib - - xmobar - - xwallpaper - - xss-lock - - xsecurelock - - numlockx - - papirus-icon-theme # Breeze inspired icon theme + - xorg-server # Xorg server implementation + - xorg-xinit # Simple way to start X + - xorg-xrandr # Manage multiple monitors in X + - xmonad # Window Manager written in haskell + - xmonad-contrib # Additional tools for xmonad + - xmobar # Panel built for xmonad + - trayer # System tray standalone panel + - xsel # X11 clipboard manager (alternatively there's xclip) + - xsecurelock # Secure lockscreen + - xss-lock # Using external locker as X screensaver + - xwallpaper # Setting wallpaper in X + - numlockx # Enabling numlock from terminal (used in xprofile) + - dunst # Notification daemon + - papirus-icon-theme # Breeze inspired icon theme + + # Audio + - alsa-lib # Implementation of Linux sound support + - alsa-utils # Utilities for alsa audio + - pulseaudio # General purpose sound server + - pulseaudio-alsa # ALSA configuration for PulseAudio + - pulsemixer # CLI and curses mixer for PulseAudio # GUI - - trayer # System tray - - alsa-utils # Utilities for alsa audio - - lxappearance # GTK theme config app - - mpv # Video player, alternatively there's kde default dragon - - nomacs # Photo viewer, alternatively there's kde default gwenview - - ffmpegthumbs # FFmpeg based thumbnail creator for videos - - ffmpegthumbnailer # Ffmpeg based thumbnail creator for file mgrs - - alacritty # very fast terminal emulator - - pcmanfm # File manager - - discord # Popular chat app - - flameshot # Screenshot taking tool - - dunst # Notification daemon - - peek # Gif/mp3 screen recording tool - - qalculate-gtk-nognome # Calculator with thousands of features, there's also less powerful kde default's kcalc - - filelight # Disk usage monitoring - - firefox # Browser - - krita # Image editing software (gimp alternative) - - ueberzug # Tool for displaying images within a terminal - - network-manager-applet # NetworkManager trayer icon - #- code # Open sourced version of vscode (doesn't support many extensions) + - alacritty # Terminal Emulator + - mpv # Video player + - nomacs # Photo viewer + - pcmanfm # File manager + - firefox # Browser + - flameshot # Screenshot taking tool + - obs-studio # Advanced video recording tool + - lxappearance # GTK configuration + - ueberzug # Embed images within a terminal + - krita # Image editor (gimp alternative) + - discord # Popular chat app + - network-manager-applet # NetworkManager trayer icon + #- code # Open sourced version of vscode (doesn't support many extensions) # Fonts - libxft @@ -112,31 +98,37 @@ pacman: - ttf-font-awesome # Printer - - cups # Daemon for printing - - hplip # Tool to set-up HP printers - - print-manager # KDE utility for managing printers - -git: - - https://aur.archlinux.org/yay-git.git # Yay tool, for AUR installation - + - cups # Daemon for printing + - hplip # Tool to set-up HP printers + - xsane # Scanning aur: - - mkinitcpio-numlock # Enable numlock in initramfs (before asking for encryption key) - # CLI/TUI - - lf # Terminal ranger-like file manager - - ngrok # Forward your localhost without ip recovery - - pixterm # A tool for converting images to ANSI colored blocks - # ZSH Extensions - - z.lua # Quick jump tool (z [directory]) + # System + - mkinitcpio-numlock # Enable numlock in initramfs (before asking for encryption key) + + # CLI + - pixterm # Convert images to ANSI colored blocks + + # TUI + - lf # Terminal file manager (ranger-like) + + # Networking/Internet + - ngrok # Forward your localhost without ip recovery + # Security - - opensnitch # Application level firewall, with full traffic monitoring, slower than kernel level iptables, but the advantages are worth it, alternatively there's also portmaster, but it's currently in early development stages, but it may be worth looking into later: `https://github.com/safing/portmaster` + - opensnitch # Application level firewall with traffic monitoring (Alternatively, there's portmaster) + + # WM/Xorg + - picom-git # Git version of picom compositor # GUI - - picom-git # Git version of picom compositor - - spotify # Online music player - - onlyoffice-bin # Full office suite (MS Office alternative) - - visual-studio-code-bin # Official vVsual Studio Code text editor for programmers - - exodus # Software cryptocurrency wallet - - notion-app # Online text manipulation tool with databases and very rich interface - #- mailspring-libre # Beautiful and fast mail client, without tracking of default mailspring + - spotify # Online music player + - visual-studio-code-bin # Official vVsual Studio Code text editor for programmers + - exodus # Software cryptocurrency wallet + - qalculate-gtk-nognome # Calculator with thousands of features, there's also less powerful kde default's kcalc + #- mailspring-libre # Beautiful and fast mail client without tracking + # Fonts - nerd-fonts-complete +git: + - https://aur.archlinux.org/yay-git.git # Pacman wrapper and AUR helper + From 1746b23375616a9a6e5acbf11fca458828c75f19 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 23 Aug 2021 02:10:44 +0200 Subject: [PATCH 010/188] Add flameshot config --- home/.config/flameshot/flameshot.ini | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 home/.config/flameshot/flameshot.ini diff --git a/home/.config/flameshot/flameshot.ini b/home/.config/flameshot/flameshot.ini new file mode 100644 index 0000000..fd0170c --- /dev/null +++ b/home/.config/flameshot/flameshot.ini @@ -0,0 +1,44 @@ +[General] +contrastOpacity=188 +disabledTrayIcon=true +drawColor=#ad00ff +drawThickness=1 +filenamePattern=Screenshot_%Y-%m-%d_%H-%M-%S +savePath=/home/itsdrike/Pictures/Screenshots +savePathFixed=false +setSaveAsFileExtension=Portable Network Graphic file (PNG) (*.png) +showStartupLaunchMessage=true +startupLaunch=true + +[Shortcuts] +TYPE_ARROW=A +TYPE_CIRCLE=C +TYPE_CIRCLECOUNT= +TYPE_COMMIT_CURRENT_TOOL=Ctrl+Return +TYPE_COPY=Ctrl+C +TYPE_DELETE_CURRENT_TOOL=Del +TYPE_DRAWER=D +TYPE_EXIT=Ctrl+Q +TYPE_MARKER=M +TYPE_MOVESELECTION=Ctrl+M +TYPE_MOVE_DOWN=Down +TYPE_MOVE_LEFT=Left +TYPE_MOVE_RIGHT=Right +TYPE_MOVE_UP=Up +TYPE_OPEN_APP=Ctrl+O +TYPE_PENCIL=P +TYPE_PIN= +TYPE_PIXELATE=B +TYPE_RECTANGLE=R +TYPE_REDO=Ctrl+Shift+Z +TYPE_RESIZE_DOWN=Shift+Down +TYPE_RESIZE_LEFT=Shift+Left +TYPE_RESIZE_RIGHT=Shift+Right +TYPE_RESIZE_UP=Shift+Up +TYPE_SAVE=Ctrl+S +TYPE_SELECTION=S +TYPE_SELECTIONINDICATOR= +TYPE_SELECT_ALL=Ctrl+A +TYPE_TEXT=T +TYPE_TOGGLE_PANEL=Space +TYPE_UNDO=Ctrl+Z From f27836e5d14dd4e2221baebaaa1f1d79b33f8249 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 24 Aug 2021 02:31:30 +0200 Subject: [PATCH 011/188] Add video zooming keybinds --- home/.config/mpv/input.conf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/home/.config/mpv/input.conf b/home/.config/mpv/input.conf index d614b15..fbd0df8 100644 --- a/home/.config/mpv/input.conf +++ b/home/.config/mpv/input.conf @@ -3,3 +3,13 @@ h seek -5 j seek -60 k seek 60 S cycle sub + +- add video-zoom -.25 ++ add video-zoom .25 + +kp8 add video-pan-y .05 +kp6 add video-pan-x -.05 +kp2 add video-pan-y -.05 +kp4 add video-pan-x .05 + +kp5 set video-pan-x 0; set video-pan-y 0; set video-zoom 0 From 742f8f6382069d43f39541058fb775baf2d15e6e Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 24 Aug 2021 15:40:24 +0200 Subject: [PATCH 012/188] Fix autostarting desktop apps with spaces --- home/.config/xmonad/scripts/autostart.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/home/.config/xmonad/scripts/autostart.sh b/home/.config/xmonad/scripts/autostart.sh index e3c515b..6849535 100755 --- a/home/.config/xmonad/scripts/autostart.sh +++ b/home/.config/xmonad/scripts/autostart.sh @@ -3,5 +3,4 @@ # Automatically start the applications in $HOME/.config/autostart AUTOSTART_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/autostart" - -find $AUTOSTART_DIR -name '*.desktop' -exec ~/.local/bin/scripts/deskopen {} + +find "$AUTOSTART_DIR" -name '*.desktop' -exec ~/.local/bin/scripts/deskopen "{}" \; From ac3fd001aa40a142718d0c97ee5ff0fce4fd1986 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 24 Aug 2021 17:25:09 +0200 Subject: [PATCH 013/188] Add bitcoin widget --- home/.config/xmobar/xmobarrc.hs | 31 +++++++++++++++++++------------ home/.config/xmobar/xmobarrc0 | 31 ++++++++++++++++++++----------- home/.config/xmobar/xmobarrc1 | 31 ++++++++++++++++++++----------- home/.local/bin/scripts/bitcoin | 7 +++++++ 4 files changed, 66 insertions(+), 34 deletions(-) create mode 100755 home/.local/bin/scripts/bitcoin diff --git a/home/.config/xmobar/xmobarrc.hs b/home/.config/xmobar/xmobarrc.hs index 5f27462..8fa4d71 100644 --- a/home/.config/xmobar/xmobarrc.hs +++ b/home/.config/xmobar/xmobarrc.hs @@ -44,16 +44,16 @@ commands = [ -- Battery information. This is likely to require some customization -- based upon your specific hardware. Or, for a desktop you may want -- to just remove this section entirely. - Run Battery [ - "-t", "\xf240 % - ", - "--", - "-i", "AC", - "-O", "AC", - "-o", "AUX", - "-L", "12", - "-h", "green", - "-l", "red" - ] 10, + --Run Battery [ + --"-t", "\xf240 % - ", + --"--", + --"-i", "AC", + --"-O", "AC", + --"-o", "AUX", + --"-L", "12", + --"-h", "green", + --"-l", "red" + --] 10, -- Time and date Run Date "\xf017 %H:%M %b %d %Y" "date" 50, @@ -68,6 +68,9 @@ commands = [ -- Get kernel version from uname -r Run Com "uname" ["-r"] "" 3600, + -- Get bitcoin price from a custom script + Run Com "/home/itsdrike/.local/bin/scripts/bitcoin" [] "bitcoin" 300, + -- Add dynamic invisible XPM icon that resizes to accomodate trayer -- this needs to be an absolute string path, env vars or relpaths aren't accepted -- this should only be on 1 monitor (single file), so ignore this comment on others @@ -93,14 +96,18 @@ template = "\ \ \ \| %UnsafeStdinReader% }{ \ \|  %uname% \ - \| %battery% \ \| %cpu% \ \| %memory% \ \| %disku% \ + \|  %bitcoin% \ \| %wlp2s0% \ \| %date% \ \| %trayerpad%\ \ " } - +-- Abandoned template strings +-- Network Ethernet: +-- \| %enp3s0% \ +-- Battery: +-- \| %battery% \ diff --git a/home/.config/xmobar/xmobarrc0 b/home/.config/xmobar/xmobarrc0 index a197158..8fa4d71 100644 --- a/home/.config/xmobar/xmobarrc0 +++ b/home/.config/xmobar/xmobarrc0 @@ -44,16 +44,16 @@ commands = [ -- Battery information. This is likely to require some customization -- based upon your specific hardware. Or, for a desktop you may want -- to just remove this section entirely. - Run Battery [ - "-t", "\xf240 % - ", - "--", - "-i", "AC", - "-O", "AC", - "-o", "AUX", - "-L", "12", - "-h", "green", - "-l", "red" - ] 10, + --Run Battery [ + --"-t", "\xf240 % - ", + --"--", + --"-i", "AC", + --"-O", "AC", + --"-o", "AUX", + --"-L", "12", + --"-h", "green", + --"-l", "red" + --] 10, -- Time and date Run Date "\xf017 %H:%M %b %d %Y" "date" 50, @@ -68,6 +68,9 @@ commands = [ -- Get kernel version from uname -r Run Com "uname" ["-r"] "" 3600, + -- Get bitcoin price from a custom script + Run Com "/home/itsdrike/.local/bin/scripts/bitcoin" [] "bitcoin" 300, + -- Add dynamic invisible XPM icon that resizes to accomodate trayer -- this needs to be an absolute string path, env vars or relpaths aren't accepted -- this should only be on 1 monitor (single file), so ignore this comment on others @@ -93,12 +96,18 @@ template = "\ \ \ \| %UnsafeStdinReader% }{ \ \|  %uname% \ - \| %battery% \ \| %cpu% \ \| %memory% \ \| %disku% \ + \|  %bitcoin% \ \| %wlp2s0% \ \| %date% \ \| %trayerpad%\ \ " } + +-- Abandoned template strings +-- Network Ethernet: +-- \| %enp3s0% \ +-- Battery: +-- \| %battery% \ diff --git a/home/.config/xmobar/xmobarrc1 b/home/.config/xmobar/xmobarrc1 index 1928835..d9d7a09 100644 --- a/home/.config/xmobar/xmobarrc1 +++ b/home/.config/xmobar/xmobarrc1 @@ -44,16 +44,16 @@ commands = [ -- Battery information. This is likely to require some customization -- based upon your specific hardware. Or, for a desktop you may want -- to just remove this section entirely. - Run Battery [ - "-t", "\xf240 % - ", - "--", - "-i", "AC", - "-O", "AC", - "-o", "AUX", - "-L", "12", - "-h", "green", - "-l", "red" - ] 10, + --Run Battery [ + --"-t", "\xf240 % - ", + --"--", + --"-i", "AC", + --"-O", "AC", + --"-o", "AUX", + --"-L", "12", + --"-h", "green", + --"-l", "red" + --] 10, -- Time and date Run Date "\xf017 %H:%M %b %d %Y" "date" 50, @@ -68,6 +68,9 @@ commands = [ -- Get kernel version from uname -r Run Com "uname" ["-r"] "" 3600, + -- Get bitcoin price from a custom script + Run Com "/home/itsdrike/.local/bin/scripts/bitcoin" [] "bitcoin" 300, + -- Add dynamic invisible XPM icon that resizes to accomodate trayer -- this needs to be an absolute string path, env vars or relpaths aren't accepted -- this should only be on 1 monitor (single file), so ignore this comment on others @@ -92,11 +95,17 @@ template = "\ \ \ \| %UnsafeStdinReader% }{ \ \|  %uname% \ - \| %battery% \ \| %cpu% \ \| %memory% \ \| %disku% \ + \|  %bitcoin% \ \| %wlp2s0% \ \| %date% \ \ " } + +-- Abandoned template strings +-- Network Ethernet: +-- \| %enp3s0% \ +-- Battery: +-- \| %battery% \ diff --git a/home/.local/bin/scripts/bitcoin b/home/.local/bin/scripts/bitcoin new file mode 100755 index 0000000..d1ea4ef --- /dev/null +++ b/home/.local/bin/scripts/bitcoin @@ -0,0 +1,7 @@ +#!/bin/sh + +BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null) +BTC_PRICE=$(echo $BTC_DATA | jq -r ".bpi.USD.rate_float") +BTC_PRICE=$(printf "%.2f" "$BTC_PRICE") + +echo \$"$BTC_PRICE" From fcc40600fb26b86354f8ae53756667bc49d362d6 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 31 Aug 2021 03:04:46 +0200 Subject: [PATCH 014/188] Update mpv input config --- home/.config/mpv/input.conf | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/home/.config/mpv/input.conf b/home/.config/mpv/input.conf index fbd0df8..d1279e7 100644 --- a/home/.config/mpv/input.conf +++ b/home/.config/mpv/input.conf @@ -1,15 +1,22 @@ +# Vim keys seeking l seek 5 h seek -5 j seek -60 k seek 60 -S cycle sub +# Set A-B Loop key to g, since l was rebound +g ab-loop + +# Swap i and I, use lowercase for toggle +i script-binding stats/display-stats-toggle +I script-binding stats/display-stats + +# Zooming - add video-zoom -.25 + add video-zoom .25 - +# Moving/panning video kp8 add video-pan-y .05 kp6 add video-pan-x -.05 kp2 add video-pan-y -.05 kp4 add video-pan-x .05 - kp5 set video-pan-x 0; set video-pan-y 0; set video-zoom 0 From 36fe6799d716b48118ce6a7d08e88f1db9f18199 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 31 Aug 2021 03:05:05 +0200 Subject: [PATCH 015/188] Add dust (readable du) --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index 64f6397..ca94f49 100644 --- a/packages.yaml +++ b/packages.yaml @@ -13,6 +13,7 @@ pacman: # CLI - exa # Colored LS - bat # Colored cat with tons of cool options + - dust # User readable du to find biggest dirs/files - hyperfine # Command benchmark - abduco # Terminal session manager - mlocate # System indexing and quick file searching From 57ee2783ebb6b8421b481e62bb2424930c9387c2 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 31 Aug 2021 03:22:21 +0200 Subject: [PATCH 016/188] Disable airline in nerdtree --- home/.config/nvim/rc/plugins.d/airline.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/home/.config/nvim/rc/plugins.d/airline.vim b/home/.config/nvim/rc/plugins.d/airline.vim index c355d1b..4a61840 100644 --- a/home/.config/nvim/rc/plugins.d/airline.vim +++ b/home/.config/nvim/rc/plugins.d/airline.vim @@ -11,3 +11,14 @@ if empty($DISPLAY) " Use ASCII-only if we're in TTY let g:airline_symbols_ascii = 1 endif +" Disable airline in nerdtree buffer +augroup filetype_nerdtree + au! + au FileType nerdtree call s:disable_airline_on_nerdtree() + au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree() +augroup END + +fu s:disable_airline_on_nerdtree() abort + let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1 + call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')}) +endfu From f2de0dcd13a7280c0e01ac33189cefcec26e95cd Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 31 Aug 2021 04:05:49 +0200 Subject: [PATCH 017/188] Blacklist pcspkr module (motherboard speaker) --- root/etc/modprobe.d/blacklist.conf | 1 + 1 file changed, 1 insertion(+) create mode 100644 root/etc/modprobe.d/blacklist.conf diff --git a/root/etc/modprobe.d/blacklist.conf b/root/etc/modprobe.d/blacklist.conf new file mode 100644 index 0000000..b46792e --- /dev/null +++ b/root/etc/modprobe.d/blacklist.conf @@ -0,0 +1 @@ +blacklist pcspkr From 36b3bd57cad20fc57b99752c585afaeb6b655b08 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 31 Aug 2021 04:13:18 +0200 Subject: [PATCH 018/188] Add default input.conf mpv config --- home/.config/mpv/input.conf.default | 180 ++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 home/.config/mpv/input.conf.default diff --git a/home/.config/mpv/input.conf.default b/home/.config/mpv/input.conf.default new file mode 100644 index 0000000..38adf14 --- /dev/null +++ b/home/.config/mpv/input.conf.default @@ -0,0 +1,180 @@ +# mpv keybindings +# +# Location of user-defined bindings: ~/.config/mpv/input.conf +# +# Lines starting with # are comments. Use SHARP to assign the # key. +# Copy this file and uncomment and edit the bindings you want to change. +# +# List of commands and further details: DOCS/man/input.rst +# List of special keys: --input-keylist +# Keybindings testing mode: mpv --input-test --force-window --idle +# +# Use 'ignore' to unbind a key fully (e.g. 'ctrl+a ignore'). +# +# Strings need to be quoted and escaped: +# KEY show-text "This is a single backslash: \\ and a quote: \" !" +# +# You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with +# the modifiers Shift, Ctrl, Alt and Meta (may not work on the terminal). +# +# The default keybindings are hardcoded into the mpv binary. +# You can disable them completely with: --no-input-default-bindings + +# Developer note: +# On compilation, this file is baked into the mpv binary, and all lines are +# uncommented (unless '#' is followed by a space) - thus this file defines the +# default key bindings. + +# If this is enabled, treat all the following bindings as default. +#default-bindings start + +#MBTN_LEFT ignore # don't do anything +#MBTN_LEFT_DBL cycle fullscreen # toggle fullscreen +#MBTN_RIGHT cycle pause # toggle pause/playback mode +#MBTN_BACK playlist-prev # skip to the previous file +#MBTN_FORWARD playlist-next # skip to the next file + +# Mouse wheels, touchpad or other input devices that have axes +# if the input devices supports precise scrolling it will also scale the +# numeric value accordingly +#WHEEL_UP seek 10 # seek 10 seconds forward +#WHEEL_DOWN seek -10 # seek 10 seconds backward +#WHEEL_LEFT add volume -2 # lower the volume +#WHEEL_RIGHT add volume 2 # raise the volume + +## Seek units are in seconds, but note that these are limited by keyframes +#RIGHT seek 5 # seek 5 seconds forward +#LEFT seek -5 # seek 5 seconds backward +#UP seek 60 # seek 1 minute forward +#DOWN seek -60 # seek 1 minute backward +# Do smaller, always exact (non-keyframe-limited), seeks with shift. +# Don't show them on the OSD (no-osd). +#Shift+RIGHT no-osd seek 1 exact # seek exactly 1 second forward +#Shift+LEFT no-osd seek -1 exact # seek exactly 1 second backward +#Shift+UP no-osd seek 5 exact # seek exactly 5 seconds forward +#Shift+DOWN no-osd seek -5 exact # seek exactly 5 seconds backward +#Ctrl+LEFT no-osd sub-seek -1 # seek to the previous subtitle +#Ctrl+RIGHT no-osd sub-seek 1 # seek to the next subtitle +#Ctrl+Shift+LEFT sub-step -1 # change subtitle timing such that the previous subtitle is displayed +#Ctrl+Shift+RIGHT sub-step 1 # change subtitle timing such that the next subtitle is displayed +#Alt+left add video-pan-x 0.1 # move the video right +#Alt+right add video-pan-x -0.1 # move the video left +#Alt+up add video-pan-y 0.1 # move the video down +#Alt+down add video-pan-y -0.1 # move the video up +#Alt++ add video-zoom 0.1 # zoom in +#Alt+- add video-zoom -0.1 # zoom out +#Alt+BS set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0 # reset zoom and pan settings +#PGUP add chapter 1 # seek to the next chapter +#PGDWN add chapter -1 # seek to the previous chapter +#Shift+PGUP seek 600 # seek 10 minutes forward +#Shift+PGDWN seek -600 # seek 10 minutes backward +#[ multiply speed 1/1.1 # decrease the playback speed +#] multiply speed 1.1 # increase the playback speed +#{ multiply speed 0.5 # halve the playback speed +#} multiply speed 2.0 # double the playback speed +#BS set speed 1.0 # reset the speed to normal +#Shift+BS revert-seek # undo the previous (or marked) seek +#Shift+Ctrl+BS revert-seek mark # mark the position for revert-seek +#q quit # exit +#Q quit-watch-later # exit and remember the playback position +#q {encode} quit 4 # exit +#ESC set fullscreen no # leave fullscreen +#ESC {encode} quit 4 # exit +#p cycle pause # toggle pause/playback mode +#. frame-step # advance one frame and pause +#, frame-back-step # go back by one frame and pause +#SPACE cycle pause # toggle pause/playback mode +#> playlist-next # skip to the next file +#ENTER playlist-next # skip to the next file +#< playlist-prev # skip to the previous file +#O no-osd cycle-values osd-level 3 1 # toggle displaying the OSD on user interaction or always +#o show-progress # show playback progress +#P show-progress # show playback progress +#i script-binding stats/display-stats # display information and statistics +#I script-binding stats/display-stats-toggle # toggle displaying information and statistics +#` script-binding console/enable # open the console +#z add sub-delay -0.1 # shift subtitles 100 ms earlier +#Z add sub-delay +0.1 # delay subtitles by 100 ms +#x add sub-delay +0.1 # delay subtitles by 100 ms +#ctrl++ add audio-delay 0.100 # change audio/video sync by delaying the audio +#ctrl+- add audio-delay -0.100 # change audio/video sync by shifting the audio earlier +#Shift+g add sub-scale +0.1 # increase the subtitle font size +#Shift+f add sub-scale -0.1 # decrease the subtitle font size +#9 add volume -2 # lower the volume +#/ add volume -2 # lower the volume +#0 add volume 2 # raise the volume +#* add volume 2 # raise the volume +#m cycle mute # toggle mute +#1 add contrast -1 # decrease the contrast +#2 add contrast 1 # increase the contrast +#3 add brightness -1 # decrease the brightness +#4 add brightness 1 # increase the brightness +#5 add gamma -1 # decrease the gamma +#6 add gamma 1 # increase the gamma +#7 add saturation -1 # decrease the saturation +#8 add saturation 1 # increase the saturation +#Alt+0 set current-window-scale 0.5 # halve the window size +#Alt+1 set current-window-scale 1.0 # reset the window size +#Alt+2 set current-window-scale 2.0 # double the window size +#d cycle deinterlace # toggle the deinterlacing filter +#r add sub-pos -1 # move subtitles up +#R add sub-pos +1 # move subtitles down +#t add sub-pos +1 # move subtitles down +#v cycle sub-visibility # hide or show the subtitles +#Alt+v cycle secondary-sub-visibility # hide or show the secondary subtitles +#V cycle sub-ass-vsfilter-aspect-compat # toggle stretching SSA/ASS subtitles with anamorphic videos to match the historical renderer +#u cycle-values sub-ass-override "force" "no" # toggle overriding SSA/ASS subtitle styles with the normal styles +#j cycle sub # switch subtitle track +#J cycle sub down # switch subtitle track backwards +#SHARP cycle audio # switch audio track +#_ cycle video # switch video track +#T cycle ontop # toggle placing the video on top of other windows +#f cycle fullscreen # toggle fullscreen +#s screenshot # take a screenshot of the video in its original resolution with subtitles +#S screenshot video # take a screenshot of the video in its original resolution without subtitles +#Ctrl+s screenshot window # take a screenshot of the window with OSD and subtitles +#Alt+s screenshot each-frame # automatically screenshot every frame; issue this command again to stop taking screenshots +#w add panscan -0.1 # decrease panscan +#W add panscan +0.1 # shrink black bars by cropping the video +#e add panscan +0.1 # shrink black bars by cropping the video +#A cycle-values video-aspect-override "16:9" "4:3" "2.35:1" "-1" # cycle the video aspect ratio ("-1" is the container aspect) +#POWER quit # exit +#PLAY cycle pause # toggle pause/playback mode +#PAUSE cycle pause # toggle pause/playback mode +#PLAYPAUSE cycle pause # toggle pause/playback mode +#PLAYONLY set pause no # unpause +#PAUSEONLY set pause yes # pause +#STOP quit # exit +#FORWARD seek 60 # seek 1 minute forward +#REWIND seek -60 # seek 1 minute backward +#NEXT playlist-next # skip to the next file +#PREV playlist-prev # skip to the previous file +#VOLUME_UP add volume 2 # raise the volume +#VOLUME_DOWN add volume -2 # lower the volume +#MUTE cycle mute # toggle mute +#CLOSE_WIN quit # exit +#CLOSE_WIN {encode} quit 4 # exit +#ctrl+w quit # exit +#E cycle edition # switch edition +#l ab-loop # set/clear A-B loop points +#L cycle-values loop-file "inf" "no" # toggle infinite looping +#ctrl+c quit 4 # exit +#DEL script-binding osc/visibility # cycle OSC visibility between never, auto (mouse-move) and always +#ctrl+h cycle-values hwdec "auto" "no" # toggle hardware decoding +#F8 show-text ${playlist} # show the playlist +#F9 show-text ${track-list} # show the list of video, audio and sub tracks + +# +# Legacy bindings (may or may not be removed in the future) +# +#! add chapter -1 # seek to the previous chapter +#@ add chapter 1 # seek to the next chapter + +# +# Not assigned by default +# (not an exhaustive list of unbound commands) +# + +# ? cycle sub-forced-only # toggle DVD forced subs +# ? stop # stop playback (quit or enter idle mode) + From fa7370a74571caeca077c311b2eeacbcfa275f9c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 31 Aug 2021 04:24:28 +0200 Subject: [PATCH 019/188] Add some nerd tree autocmds Co-authored-by: jpie726 <53590846+jpie726@users.noreply.github.com> --- home/.config/nvim/rc/plugins.d/nerdtree.vim | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/home/.config/nvim/rc/plugins.d/nerdtree.vim b/home/.config/nvim/rc/plugins.d/nerdtree.vim index d789901..eab8fe4 100644 --- a/home/.config/nvim/rc/plugins.d/nerdtree.vim +++ b/home/.config/nvim/rc/plugins.d/nerdtree.vim @@ -5,8 +5,23 @@ let g:NERDTreeDirArrowCollapsible = '▼' let NERDTreeShowLineNumbers=1 let NERDTreeShowHidden=1 let NERDTreeMinimalUI = 1 -let g:NERDTreeWinSize=38 +let g:NERDTreeWinSize=25 if empty($DISPLAY) " Disable devicons for nerdtree in TTY let g:webdevicons_enable_nerdtree = 0 endif +"Start NerdTree. If a file is specified, move the cursor to its window. +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | + \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | + \ endif +autocmd VimEnter * if argc() > 0 && !isdirectory(argv()[0]) || exists("s:std_in") | + \ execute 'NERDTree' fnamemodify(argv()[0], ':p:h') | wincmd p | endif + +" Exit Vim if NerdTree is the only window left. +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | + \ quit | endif + +" If another buffer tries to replace NerdTree, put it in another window, and bring back NerdTree. +autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | + \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif From ed9e7e031dc3e5f3c3dca26cf7c74c0db9f7f6a6 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 2 Sep 2021 17:17:57 +0200 Subject: [PATCH 020/188] Add newsboat pkg --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index ca94f49..f440e38 100644 --- a/packages.yaml +++ b/packages.yaml @@ -28,6 +28,7 @@ pacman: - calcurse # Terminal calendar with todo - bpytop # Modern system resource monitor - links # Terminal text-only web browser + - newsboat # Terminal RSS feed reader # Networking/Internet - httpie # Obtaining http info from webpages From d17caa2bdfb3877263c7aa36936f8a10f5ab86b2 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 2 Sep 2021 17:18:52 +0200 Subject: [PATCH 021/188] Add newsboat config files --- home/.config/newsboat/config | 42 ++++++++++++++++++++++++++++++++++++ home/.config/newsboat/urls | 2 ++ 2 files changed, 44 insertions(+) create mode 100644 home/.config/newsboat/config create mode 100644 home/.config/newsboat/urls diff --git a/home/.config/newsboat/config b/home/.config/newsboat/config new file mode 100644 index 0000000..5a75f23 --- /dev/null +++ b/home/.config/newsboat/config @@ -0,0 +1,42 @@ +unbind-key j +unbind-key k +unbind-key h +unbind-key H +unbind-key L +unbind-key c +unbind-key , + +# Feed settings +prepopulate-query-feeds yes +refresh-on-startup yes + +# bind keys +bind-key ; macro-prefix +bind-key BACKSPACE quit +bind-key h quit +bind-key j down +bind-key k up +bind-key l open +bind-key H prev-feed +bind-key L next-feed +bind-key c toggle-show-read-feeds + +color background default default +color listnormal default default +color listnormal_unread default default +color listfocus color16 cyan +color listfocus_unread color16 cyan +color info default black +color article default default + +highlight article "(^Feed:.*|^Title:.*|^Author:.*)" cyan default bold +highlight article "(^Link:.*|^Date:.*)" default default +highlight article "https?://[^ ]+" green default + +highlight article "^(Title):.*$" blue default +highlight article "\\[[0-9][0-9]*\\]" magenta default bold +highlight article "\\[image\\ [0-9]+\\]" green default bold +highlight article "\\[embedded flash: [0-9][0-9]*\\]" green default bold +highlight article ":.*\\(link\\)$" cyan default +highlight article ":.*\\(image\\)$" blue default +highlight article ":.*\\(embedded flash\\)$" magenta default diff --git a/home/.config/newsboat/urls b/home/.config/newsboat/urls new file mode 100644 index 0000000..94349e0 --- /dev/null +++ b/home/.config/newsboat/urls @@ -0,0 +1,2 @@ +https://itsdrike.com/posts/index.xml +https://archlinux.org/feeds/news From 8f5b8129f61b611b93621c342659d26fc286b211 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 2 Sep 2021 17:33:04 +0200 Subject: [PATCH 022/188] Add newsboat macros --- home/.config/newsboat/config | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/home/.config/newsboat/config b/home/.config/newsboat/config index 5a75f23..6ed60a4 100644 --- a/home/.config/newsboat/config +++ b/home/.config/newsboat/config @@ -5,11 +5,16 @@ unbind-key H unbind-key L unbind-key c unbind-key , +browser "xdg-open %u" # Feed settings prepopulate-query-feeds yes refresh-on-startup yes +# Macros +macro w set browser "mpv %u" ; open-in-browser ; set browser "xdg-open %u" +macro r set browser "links %u" ; open-in-browser ; set browser "xdg-open %u" + # bind keys bind-key ; macro-prefix bind-key BACKSPACE quit From a26a3c4c78a34ea91ab72091b2e7861a7c780a20 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 2 Sep 2021 17:38:48 +0200 Subject: [PATCH 023/188] Fix autostart --- home/.config/xmonad/scripts/autostart.sh | 3 ++- home/.local/bin/scripts/deskopen | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/home/.config/xmonad/scripts/autostart.sh b/home/.config/xmonad/scripts/autostart.sh index 6849535..2098b8a 100755 --- a/home/.config/xmonad/scripts/autostart.sh +++ b/home/.config/xmonad/scripts/autostart.sh @@ -3,4 +3,5 @@ # Automatically start the applications in $HOME/.config/autostart AUTOSTART_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/autostart" -find "$AUTOSTART_DIR" -name '*.desktop' -exec ~/.local/bin/scripts/deskopen "{}" \; + +find $AUTOSTART_DIR -name "*.desktop" | xargs -I {} sh -c "~/.local/bin/scripts/deskopen {} &" diff --git a/home/.local/bin/scripts/deskopen b/home/.local/bin/scripts/deskopen index 426928b..98d8280 100755 --- a/home/.local/bin/scripts/deskopen +++ b/home/.local/bin/scripts/deskopen @@ -7,5 +7,5 @@ exec_line=$(grep '^Exec' "$1" | tail -1) cmd=$(echo $exec_line | sed 's/^Exec=//' | sed 's/%.//') # Remove "" around command (if present) cmd=$(echo $cmd | sed 's/^"//g' | sed 's/" *$//g') -# Run the exec line of the application in the background -$($cmd) & +# Run the exec line of the application using /bin/sh +/bin/sh -c "$cmd" From 482f5f0213941a9b968dbabd4cf794c6572ce765 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 2 Sep 2021 17:46:02 +0200 Subject: [PATCH 024/188] Replace links with w3m --- home/.config/newsboat/config | 2 +- packages.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/home/.config/newsboat/config b/home/.config/newsboat/config index 6ed60a4..52bdcfc 100644 --- a/home/.config/newsboat/config +++ b/home/.config/newsboat/config @@ -13,7 +13,7 @@ refresh-on-startup yes # Macros macro w set browser "mpv %u" ; open-in-browser ; set browser "xdg-open %u" -macro r set browser "links %u" ; open-in-browser ; set browser "xdg-open %u" +macro r set browser "w3m %u" ; open-in-browser ; set browser "xdg-open %u" # bind keys bind-key ; macro-prefix diff --git a/packages.yaml b/packages.yaml index f440e38..4ca920f 100644 --- a/packages.yaml +++ b/packages.yaml @@ -27,7 +27,7 @@ pacman: - ncdu # Find largest folders (size) - calcurse # Terminal calendar with todo - bpytop # Modern system resource monitor - - links # Terminal text-only web browser + - w3m # Terminal text-only web browser - newsboat # Terminal RSS feed reader # Networking/Internet From fcafb84e21a37510eb0d56d9de1110fea0186b7a Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Sep 2021 04:15:54 +0200 Subject: [PATCH 025/188] Remove old dmenu folder --- root/usr/src/dmenu | 1 - 1 file changed, 1 deletion(-) delete mode 160000 root/usr/src/dmenu diff --git a/root/usr/src/dmenu b/root/usr/src/dmenu deleted file mode 160000 index 8e6bb7b..0000000 --- a/root/usr/src/dmenu +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8e6bb7b92f421489aef49d98985bb8aaf0ddc0ce From 83a2c679b514827723359162ee400c51c9fe64f9 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Sep 2021 04:16:21 +0200 Subject: [PATCH 026/188] Update dunst config --- home/.config/dunst/dunstrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/home/.config/dunst/dunstrc b/home/.config/dunst/dunstrc index 02f908a..4da77a3 100644 --- a/home/.config/dunst/dunstrc +++ b/home/.config/dunst/dunstrc @@ -25,7 +25,7 @@ # positive x is measured from the left, negative from right # Y is measured from the top and bottom respectively. # width can be negative, making it the screen width - width - geometry = "300x5-30+30" + geometry = "300x0-30+30" # Show how many messages are currently hidden (because of geometry) indicate_hidden = yes @@ -153,7 +153,7 @@ max_icon_size = 32 # Paths to default icons - icon_path = /usr/share/icons/hicolor/16x16/status/:/usr/share/icons/hicolor/16x16/devices/:/usr/share/icons/hicolor/16x16/apps/:/usr/share/icons/Adwaita/16x16/status/:/usr/share/icons/Adwaita/16x16/devices/:/usr/share/icons/Adwaita/16x16/apps/ + icon_path = /usr/share/icons/hicolor/16x16/status/:/usr/share/icons/hicolor/16x16/devices/:/usr/share/icons/hicolor/16x16/apps/ ### History ### @@ -218,7 +218,7 @@ # Close all notifications. close_all = ctrl+shift+space # Redisplay last message(s) - history = ctrl+grave + history = ctrl+shift+grave # Context menu context = ctrl+shift+period @@ -226,7 +226,7 @@ background = "#35383b" foreground = "#fcf7e2" frame_color = "#27292c" - timeout = 3 + timeout = 5 # Icon for notifications with low urgency, uncomment to enable #icon = /path/to/icon From 0128ab129c393795fc639e5ec61c0e7aa372f7d3 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Sep 2021 04:57:27 +0200 Subject: [PATCH 027/188] Add autostart directory --- home/.config/autostart/discord.desktop | 10 ++++++++++ home/.config/autostart/element.desktop | 10 ++++++++++ home/.config/autostart/opensnitch_ui.desktop | 16 ++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 home/.config/autostart/discord.desktop create mode 100644 home/.config/autostart/element.desktop create mode 100644 home/.config/autostart/opensnitch_ui.desktop diff --git a/home/.config/autostart/discord.desktop b/home/.config/autostart/discord.desktop new file mode 100644 index 0000000..054a26d --- /dev/null +++ b/home/.config/autostart/discord.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Discord +StartupWMClass=discord +Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone. +GenericName=Internet Messenger +Exec=/opt/discord/Discord +Icon=discord +Type=Application +Categories=Network;InstantMessaging; +Path=/usr/bin diff --git a/home/.config/autostart/element.desktop b/home/.config/autostart/element.desktop new file mode 100644 index 0000000..443d9f1 --- /dev/null +++ b/home/.config/autostart/element.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Element +StartupWMClass=element +Comment=Chat client for matrix protocl +GenericName=Internet Messenger +Exec=/usr/bin/element-desktop +Icon=element +Type=Application +Categories=Network;InstantMessaging; +Path=/usr/bin diff --git a/home/.config/autostart/opensnitch_ui.desktop b/home/.config/autostart/opensnitch_ui.desktop new file mode 100644 index 0000000..4aff5d4 --- /dev/null +++ b/home/.config/autostart/opensnitch_ui.desktop @@ -0,0 +1,16 @@ +[Desktop Entry] +Type=Application +Name=OpenSnitch +Exec=/bin/sh -c 'pkill -15 opensnitch-ui; opensnitch-ui' +Icon=opensnitch-ui +GenericName=OpenSnitch Firewall +GenericName[hu]=OpenSnitch-tűzfal +Comment=Application firewall +Comment[es]=Firewall de aplicaciones +Comment[hu]=Alkalmazási tűzfal +Terminal=false +NoDisplay=false +Categories=System;Filesystem;Network; +Keywords=system;firewall;policies;security;polkit;policykit; +X-GNOME-Autostart-Delay=3 +X-GNOME-Autostart-enabled=true From 181f8129bebb2de655b20cad21c5b4b061531725 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Sep 2021 05:01:26 +0200 Subject: [PATCH 028/188] Add udiskie for simple device mounting --- home/.config/x11/xprofile | 11 +++++++---- packages.yaml | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/home/.config/x11/xprofile b/home/.config/x11/xprofile index 80d93a8..8e75b3a 100644 --- a/home/.config/x11/xprofile +++ b/home/.config/x11/xprofile @@ -6,13 +6,13 @@ # Set monitor order xrandr --output HDMI-1 --auto --output eDP-1 --right-of HDMI-1 --auto & -# Set X11 lockscreen delays (DPMS) -xset s on & -xset s 600 5 & # 10 minutes, 5s for dimmer - # XSS lock with xsecurelock xss-lock -n /usr/lib/xsecurelock/dimmer -l -- xsecurelock & +# Set X11 lockscreen delays (DPMS) +xset s on & +xset s 600 10 & # 10 minutes, 5s for dimmer + # Set the background with a custom `setbg` script setbg & @@ -41,6 +41,9 @@ aa-notify -p & # Enable numlock with numlockx numlockx & +# Udiskie for simple mounting and notifications, no automount for security reasons +udiskie -A -s + # Run emacs daemon #emacs --daemon & diff --git a/packages.yaml b/packages.yaml index 4ca920f..72aa3b0 100644 --- a/packages.yaml +++ b/packages.yaml @@ -90,6 +90,10 @@ pacman: - network-manager-applet # NetworkManager trayer icon #- code # Open sourced version of vscode (doesn't support many extensions) + # Device mounting + - udisks2 + - udiskie + # Fonts - libxft - ttf-hack From 7016282d619975d33366ff48764390589e247cdc Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Sep 2021 19:31:49 +0200 Subject: [PATCH 029/188] Run udiskie detached --- home/.config/x11/xprofile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/x11/xprofile b/home/.config/x11/xprofile index 8e75b3a..d323b18 100644 --- a/home/.config/x11/xprofile +++ b/home/.config/x11/xprofile @@ -42,7 +42,7 @@ aa-notify -p & numlockx & # Udiskie for simple mounting and notifications, no automount for security reasons -udiskie -A -s +udiskie -A -s & # Run emacs daemon #emacs --daemon & From dc877c89fab68f7a2fea7bb1d82036ff7185d232 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 7 Sep 2021 00:23:02 +0200 Subject: [PATCH 030/188] Add gvfs --- packages.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages.yaml b/packages.yaml index 72aa3b0..aa2f7ce 100644 --- a/packages.yaml +++ b/packages.yaml @@ -91,8 +91,9 @@ pacman: #- code # Open sourced version of vscode (doesn't support many extensions) # Device mounting - - udisks2 - - udiskie + - udisks2 # Allows users to mount devices without root + - udiskie # Auto-mounter using udisks2 + - gvfm # Allows using sftp:// in file managers like PcManFM # Fonts - libxft From f28aaea22a8644dbfe0aa5a7ede5da8505b0ac3f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 7 Sep 2021 17:36:06 +0200 Subject: [PATCH 031/188] Fix package name (gvfm -> gvfs) --- packages.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages.yaml b/packages.yaml index aa2f7ce..be5d07b 100644 --- a/packages.yaml +++ b/packages.yaml @@ -93,7 +93,7 @@ pacman: # Device mounting - udisks2 # Allows users to mount devices without root - udiskie # Auto-mounter using udisks2 - - gvfm # Allows using sftp:// in file managers like PcManFM + - gvfs # Allows using sftp:// in file managers like PcManFM # Fonts - libxft From 8e16e3f16219c71df8f5a225407b685c69531a60 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 8 Sep 2021 12:16:59 +0200 Subject: [PATCH 032/188] Enable touchpad tapping --- root/etc/X11/xorg.conf.d/40-libinput.conf | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 root/etc/X11/xorg.conf.d/40-libinput.conf diff --git a/root/etc/X11/xorg.conf.d/40-libinput.conf b/root/etc/X11/xorg.conf.d/40-libinput.conf new file mode 100644 index 0000000..79e4aa7 --- /dev/null +++ b/root/etc/X11/xorg.conf.d/40-libinput.conf @@ -0,0 +1,7 @@ +Section "InputClass" + Identifier "libinput touchpad catchall" + MatchIsTouchpad "on" + MatchDevicePath "/dev/input/event*" + Driver "libinput" + Option "Tapping" "on" +EndSection From d35a9d3e83ed6d39f06c907c3bd5fa647b549619 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 15 Sep 2021 18:46:29 +0200 Subject: [PATCH 033/188] Fix tab expansion keybindings --- home/.config/nvim/rc/mappings.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/.config/nvim/rc/mappings.vim b/home/.config/nvim/rc/mappings.vim index 1dd1e43..4931752 100644 --- a/home/.config/nvim/rc/mappings.vim +++ b/home/.config/nvim/rc/mappings.vim @@ -38,8 +38,8 @@ nnoremap k nnoremap l " Make adjusting split sizes a bit more friendly -noremap :vertical resize +3 -noremap :vertical resize -3 +noremap :vertical resize +3 +noremap :vertical resize -3 noremap :resize +3 noremap :resize -3 From f601d345f9185eb669bf3845940763a3f7eb3375 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 15 Sep 2021 18:47:58 +0200 Subject: [PATCH 034/188] Use coc for language IntelliSense completions --- home/.config/nvim/rc/coc.vim | 1 + home/.config/nvim/rc/plugins.d/coc.vim | 1 + home/.config/nvim/rc/plugins.d/python.vim | 12 ------------ home/.config/nvim/rc/plugins.vim | 8 +++----- 4 files changed, 5 insertions(+), 17 deletions(-) create mode 100644 home/.config/nvim/rc/coc.vim create mode 100644 home/.config/nvim/rc/plugins.d/coc.vim delete mode 100644 home/.config/nvim/rc/plugins.d/python.vim diff --git a/home/.config/nvim/rc/coc.vim b/home/.config/nvim/rc/coc.vim new file mode 100644 index 0000000..6d306f9 --- /dev/null +++ b/home/.config/nvim/rc/coc.vim @@ -0,0 +1 @@ +let g:coc_global_extensions = ['coc-python', 'coc-json', 'coc-git', 'coc-html', 'coc-css', 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml', 'coc-yaml', 'coc-omnisharp'] diff --git a/home/.config/nvim/rc/plugins.d/coc.vim b/home/.config/nvim/rc/plugins.d/coc.vim new file mode 100644 index 0000000..8378ff3 --- /dev/null +++ b/home/.config/nvim/rc/plugins.d/coc.vim @@ -0,0 +1 @@ +let g:coc_global_extensions = ['coc-python', 'coc-json', 'coc-git', 'coc-html', 'coc-css'] diff --git a/home/.config/nvim/rc/plugins.d/python.vim b/home/.config/nvim/rc/plugins.d/python.vim deleted file mode 100644 index 0df3054..0000000 --- a/home/.config/nvim/rc/plugins.d/python.vim +++ /dev/null @@ -1,12 +0,0 @@ -" Define python-specific neomake config -" Neomake is python syntax checker, in this case, we use flake8 -" Requires: pip install flake8 -let g:neomake_python_enabled_makers = ['flake8'] -let g:neomake_python_flake8_maker = {'args': ['--ignore=E501', '--format=default']} -call neomake#configure#automake('nrwi', 500) - -" Enable deoplete on startup -" Deoplete provides autosuggestions from python standard library -" Requires: pip install pynvim -let g:deoplete#enable_at_startup = 1 - diff --git a/home/.config/nvim/rc/plugins.vim b/home/.config/nvim/rc/plugins.vim index 87175e0..b31205f 100644 --- a/home/.config/nvim/rc/plugins.vim +++ b/home/.config/nvim/rc/plugins.vim @@ -14,16 +14,13 @@ endif call plug#begin(config_dir."/plugged") " Code completion -Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } +Plug 'neoclide/coc.nvim', {'branch': 'release'} " Themes Plug 'tomasiser/vim-code-dark' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'ryanoasis/vim-devicons' Plug 'airblade/vim-gitgutter' -" Python -Plug 'neomake/neomake' -Plug 'zchee/deoplete-jedi' " Misc Plug 'dhruvasagar/vim-table-mode' Plug 'vimwiki/vimwiki' @@ -40,4 +37,5 @@ let plugins_rc_dir = rc_dir."/plugins.d" execute "source ".plugins_rc_dir."/airline.vim" execute "source ".plugins_rc_dir."/nerdtree.vim" execute "source ".plugins_rc_dir."/vimwiki.vim" -execute "source ".plugins_rc_dir."/python.vim" +execute "source ".plugins_rc_dir."/coc.vim" +"execute "source ".plugins_rc_dir."/python.vim" From 216369feb1c1da2015fc71bd7fa8a7d0b33dec67 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 16 Sep 2021 22:23:48 +0200 Subject: [PATCH 035/188] Auto-wrap markdown text at 119 characters --- home/.config/nvim/rc/autocmd.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/.config/nvim/rc/autocmd.vim b/home/.config/nvim/rc/autocmd.vim index 1d69361..a7902d3 100644 --- a/home/.config/nvim/rc/autocmd.vim +++ b/home/.config/nvim/rc/autocmd.vim @@ -13,3 +13,5 @@ autocmd BufWritePre * %s/\s\+$//e " Enable spellcheck for certain file types autocmd FileType tex,latex,markdown,gitcommit setlocal spell spelllang=en_us +" Use automatic text wrapping at 119 characters for certain file types +autocmd FileType markdown setlocal textwidth=119 From d60ec191bc948a1d3681945e86b1ed1c5e877381 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 16 Sep 2021 22:24:11 +0200 Subject: [PATCH 036/188] Add commented sshuttle pkg --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index be5d07b..22267f0 100644 --- a/packages.yaml +++ b/packages.yaml @@ -34,6 +34,7 @@ pacman: - httpie # Obtaining http info from webpages - dnsutils # Tools for managing DNS - net-tools # Configuration tools for linux networking + #- sshuttle # Transparent proxy server that forwards all TCP packets over SSH # Media - imagemagick # Terminal image manipulation From 61d1e1269b3d0b57753e40f1fd40c31d89c3ed61 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 16 Sep 2021 23:20:20 +0200 Subject: [PATCH 037/188] Start discord and element in the background --- home/.config/autostart/discord.desktop | 2 +- home/.config/autostart/element.desktop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/home/.config/autostart/discord.desktop b/home/.config/autostart/discord.desktop index 054a26d..618ba5a 100644 --- a/home/.config/autostart/discord.desktop +++ b/home/.config/autostart/discord.desktop @@ -3,7 +3,7 @@ Name=Discord StartupWMClass=discord Comment=All-in-one voice and text chat for gamers that's free, secure, and works on both your desktop and phone. GenericName=Internet Messenger -Exec=/opt/discord/Discord +Exec=/opt/discord/Discord --start-minimized Icon=discord Type=Application Categories=Network;InstantMessaging; diff --git a/home/.config/autostart/element.desktop b/home/.config/autostart/element.desktop index 443d9f1..01e9c92 100644 --- a/home/.config/autostart/element.desktop +++ b/home/.config/autostart/element.desktop @@ -3,7 +3,7 @@ Name=Element StartupWMClass=element Comment=Chat client for matrix protocl GenericName=Internet Messenger -Exec=/usr/bin/element-desktop +Exec=/usr/bin/element-desktop --hidden Icon=element Type=Application Categories=Network;InstantMessaging; From a348ebe90dc19f40592ca94cbfd00ab0623cd538 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Sep 2021 12:32:04 +0000 Subject: [PATCH 038/188] Remove last traces of the deploy scripts --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e435b12..969ee82 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Dotfiles -These are my personal dotfiles. This also include an automated installer for certain packages (Arch Linux specific) and for putting the dotfiles in place. -Source code for this automated script is in `src` directory, and the dotfiles are located in `home` and `root` directories respectively. +These are my personal dotfiles. They're split into `home/` and `root/` folders where the home folder holds all files that should be put directly into your `$HOME` directory, while all of the files in the root folder can be put directly into `/` You are highly adviced to first go through these dotfiles yourself and adjust them to your liking. @@ -31,7 +30,7 @@ You are highly adviced to first go through these dotfiles yourself and adjust th - XDG paths configuration to avoid too much cluttering in home directory - Colorful man pages using LESS_TERMCAP, or if `bat` is installed, using it as MANPAGER - [Automatic handlers](home/.config/shell/handlers) which override default command not found behavior to show the package to which given command belongs (requires pkgfile on Arch Linux) -- Automated package installation for Arch Linux, which includes many handy packages. You should certainly take a look at which packages will be installed and adjust [`packages.yaml`](packages.yaml) before you run it. +- List of useful packages that I often install on most of my systems. (These are the package names for arch linux, but you should be able to find these for any distro, perhaps with a bit different name) located in [`packages.yaml`](packages.yaml) - [Opensnitch firewall rules](root/etc/opensnitchd/rules), which block most unauthorized traffic and only allow needed things. This also blocks spotify ads. - Automatic logout for TTY sessions or for root logins after 10 minutes of inactivity - NetworkManager configuration which assigns new mac for each network From b0060162f0d178083d1018a1311cf96fc9a46f89 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 22 Sep 2021 22:26:19 +0200 Subject: [PATCH 039/188] Update git signing key and email --- home/.config/git/config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/.config/git/config b/home/.config/git/config index 35b9e8e..9476b66 100644 --- a/home/.config/git/config +++ b/home/.config/git/config @@ -1,8 +1,8 @@ # This is Git's per-user configuration file. [user] name = ItsDrike - email = itsdrikeofficial@gmail.com - signingkey = B5F6B41F708C3ADD + email = itsdrike@protonmail.com + signingkey = FB8CA11A2CF3A843 [credential] helper = store --file ~/.config/git/git-credentials [alias] From cf79be321698d75709eb08206935aa4a2b782a86 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 25 Sep 2021 02:41:56 +0200 Subject: [PATCH 040/188] Add further coc settings --- home/.config/nvim/coc-settings.json | 14 ++++ home/.config/nvim/rc/plugins.d/coc.vim | 89 +++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 home/.config/nvim/coc-settings.json diff --git a/home/.config/nvim/coc-settings.json b/home/.config/nvim/coc-settings.json new file mode 100644 index 0000000..38ed7e2 --- /dev/null +++ b/home/.config/nvim/coc-settings.json @@ -0,0 +1,14 @@ +{ + "pairs.enableCharacters": [ + "(", + "[", + "{", + "'", + "\"", + "`" + ], + "diagnostic.checkCurrentLine": true, + "coc.preferences.formatOnSaveFiletypes": [ + "json" + ] +} diff --git a/home/.config/nvim/rc/plugins.d/coc.vim b/home/.config/nvim/rc/plugins.d/coc.vim index 8378ff3..f9d4d00 100644 --- a/home/.config/nvim/rc/plugins.d/coc.vim +++ b/home/.config/nvim/rc/plugins.d/coc.vim @@ -1 +1,88 @@ -let g:coc_global_extensions = ['coc-python', 'coc-json', 'coc-git', 'coc-html', 'coc-css'] +let g:coc_global_extensions = [ + \ 'coc-python', 'coc-json', 'coc-git', 'coc-html', 'coc-css', + \ 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml', + \ 'coc-yaml', 'coc-omnisharp', 'coc-markdownlint', 'coc-pairs' + \ ] + +" Use tab for trigger completion with characters ahead and navigate. +" Use command ':verbose imap ' to make sure tab is not mapped by other plugin. +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to trigger completion. +inoremap coc#refresh() + +" Use to confirm completion, `u` means break undo chain at current position. +" Coc only does snippet and additional edit on confirm. +inoremap pumvisible() ? "\" : "\u\" +" Or use `complete_info` if your vim support it, like: +" inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" + +" Use `[g` and `]g` to navigate diagnostics +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +" Remap keys for gotos +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + else + call CocAction('doHover') + endif +endfunction + +" Remap for rename current word +nmap (coc-rename) + +" Remap for format selected region +xmap f (coc-format-selected) +nmap f (coc-format-selected) + +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s). + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Remap for do codeAction of selected region, ex: `aap` for current paragraph +xmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) + +" Remap for do codeAction of current line +nmap ac (coc-codeaction) +" Fix autofix problem of current line +nmap qf (coc-fix-current) + +" Create mappings for function text object, requires document symbols feature of languageserver. +xmap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap if (coc-funcobj-i) +omap af (coc-funcobj-a) + +" Use `:Format` to format current buffer +command! -nargs=0 Format :call CocAction('format') + +" Use `:Fold` to fold current buffer +command! -nargs=? Fold :call CocAction('fold', ) + +" use `:OR` for organize import of current buffer +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + +" Add status line support, for integration with other plugin, checkout `:h coc-status` +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} From ddc758b6e152ce4bde92fc2cc1ab4c7823bcc74f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 25 Sep 2021 02:42:36 +0200 Subject: [PATCH 041/188] Add default folding settings --- home/.config/nvim/rc/base.vim | 7 +++++++ home/.config/nvim/rc/mappings.vim | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/home/.config/nvim/rc/base.vim b/home/.config/nvim/rc/base.vim index 070021f..799789e 100644 --- a/home/.config/nvim/rc/base.vim +++ b/home/.config/nvim/rc/base.vim @@ -17,6 +17,13 @@ set path+=** " Search down into subfolders with tab completio set wildmode=longest,list,full " Enable autocompletion set wildmenu " Display all matching files when we tab complete +" Folding +set foldmethod=indent " Use indent to determine the fold levels +set foldnestmax=8 " Only fold up to given amount of levels +set foldlevel=2 " Set initial fold level +set nofoldenable " Hide all folds by default + + " Misc set autoindent " Enable autoindent set autoread " Reload files on change diff --git a/home/.config/nvim/rc/mappings.vim b/home/.config/nvim/rc/mappings.vim index 4931752..6ecbf83 100644 --- a/home/.config/nvim/rc/mappings.vim +++ b/home/.config/nvim/rc/mappings.vim @@ -14,6 +14,10 @@ vnoremap "+p " Start spell-check map s :setlocal spell! spelllang=en_us +" Use space for folding/unfolding sections +nnoremap za +vnoremap zf + " Use shift to move 10 lines up/down quickly noremap K 10k noremap J 10j @@ -58,3 +62,4 @@ nnoremap :w \| !comp % " Shell check nnoremap p :!shellcheck % + From 8dedca10d2dcd2a847ec7a3b88f93de215286f87 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 25 Sep 2021 02:43:22 +0200 Subject: [PATCH 042/188] Add a plugin for proper python folding --- home/.config/nvim/rc/plugins.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/home/.config/nvim/rc/plugins.vim b/home/.config/nvim/rc/plugins.vim index b31205f..87a4012 100644 --- a/home/.config/nvim/rc/plugins.vim +++ b/home/.config/nvim/rc/plugins.vim @@ -4,10 +4,10 @@ " Install plugins automatically if ! filereadable(config_dir."/autoload/plug.vim") - echo "Downloading junegunn/vim-plug to manage plugins..." + echo "Downloading junegunn/vim-plug to manage plugins..." let x = system('mkdir -p '.config_dir.'/autoload') let x = system('curl https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim > '.config_dir.'/autoload/plug.vim') - autocmd VimEnter * PlugInstall + autocmd VimEnter * PlugInstall endif " Plug.vim plugin list @@ -21,13 +21,14 @@ Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'ryanoasis/vim-devicons' Plug 'airblade/vim-gitgutter' +Plug 'tiagofumo/vim-nerdtree-syntax-highlight' " Misc Plug 'dhruvasagar/vim-table-mode' Plug 'vimwiki/vimwiki' Plug 'wakatime/vim-wakatime' Plug 'preservim/nerdcommenter' Plug 'preservim/nerdtree' -Plug 'tiagofumo/vim-nerdtree-syntax-highlight' +Plug 'tmhedberg/SimpylFold' call plug#end() From b5354fbf4c76ec86d4e917c01f957bd23138aa04 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 25 Sep 2021 02:44:24 +0200 Subject: [PATCH 043/188] Improve NERDTree settings --- home/.config/nvim/rc/plugins.d/airline.vim | 20 ++++++++++---------- home/.config/nvim/rc/plugins.d/nerdtree.vim | 10 ++++++---- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/home/.config/nvim/rc/plugins.d/airline.vim b/home/.config/nvim/rc/plugins.d/airline.vim index 4a61840..47c7c88 100644 --- a/home/.config/nvim/rc/plugins.d/airline.vim +++ b/home/.config/nvim/rc/plugins.d/airline.vim @@ -12,13 +12,13 @@ if empty($DISPLAY) " Use ASCII-only if we're in TTY endif " Disable airline in nerdtree buffer -augroup filetype_nerdtree - au! - au FileType nerdtree call s:disable_airline_on_nerdtree() - au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree() -augroup END - -fu s:disable_airline_on_nerdtree() abort - let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1 - call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')}) -endfu +"augroup filetype_nerdtree +" au! +" au FileType nerdtree call s:disable_airline_on_nerdtree() +" au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree() +"augroup END +" +"fu s:disable_airline_on_nerdtree() abort +" let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1 +" call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')}) +"endfu diff --git a/home/.config/nvim/rc/plugins.d/nerdtree.vim b/home/.config/nvim/rc/plugins.d/nerdtree.vim index eab8fe4..a619ec8 100644 --- a/home/.config/nvim/rc/plugins.d/nerdtree.vim +++ b/home/.config/nvim/rc/plugins.d/nerdtree.vim @@ -10,15 +10,17 @@ if empty($DISPLAY) " Disable devicons for nerdtree in TTY let g:webdevicons_enable_nerdtree = 0 endif -"Start NerdTree. If a file is specified, move the cursor to its window. +" If a directory is specified, start NERDTree and move the cursor to its window. autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | \ endif -autocmd VimEnter * if argc() > 0 && !isdirectory(argv()[0]) || exists("s:std_in") | - \ execute 'NERDTree' fnamemodify(argv()[0], ':p:h') | wincmd p | endif -" Exit Vim if NerdTree is the only window left. +" If a file is specified, start NERDTree and keep the cursor in file window. +"autocmd VimEnter * if argc() > 0 && !isdirectory(argv()[0]) || exists("s:std_in") | +" \ execute 'NERDTree' fnamemodify(argv()[0], ':p:h') | wincmd p | endif + +" Exit Vim if NERDTree is the only window left. autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | \ quit | endif From 46f2adfd8b5b2819d3e4c132c8a518b98f2db693 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 2 Oct 2021 02:28:37 +0200 Subject: [PATCH 044/188] Add bluetooth packages --- packages.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages.yaml b/packages.yaml index 22267f0..239e849 100644 --- a/packages.yaml +++ b/packages.yaml @@ -109,6 +109,12 @@ pacman: - cups # Daemon for printing - hplip # Tool to set-up HP printers - xsane # Scanning + + # Bluetooth + - bluez # Daemon for bluetooth protocol + - bluz-utils # CLI utility for managing bluetooth connections + - blueman # Graphical utility for managing bluetooth connections + - pulseaudio-bluetooth # Bluetooth speaker/headphone support for PulseAudio aur: # System - mkinitcpio-numlock # Enable numlock in initramfs (before asking for encryption key) From 76967ee3e4edd07e81f397ba5c5a6204011ab945 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 2 Oct 2021 21:14:51 +0200 Subject: [PATCH 045/188] Remove coc.vim from rc/ (there's one in plugins.d/) --- home/.config/nvim/rc/coc.vim | 1 - 1 file changed, 1 deletion(-) delete mode 100644 home/.config/nvim/rc/coc.vim diff --git a/home/.config/nvim/rc/coc.vim b/home/.config/nvim/rc/coc.vim deleted file mode 100644 index 6d306f9..0000000 --- a/home/.config/nvim/rc/coc.vim +++ /dev/null @@ -1 +0,0 @@ -let g:coc_global_extensions = ['coc-python', 'coc-json', 'coc-git', 'coc-html', 'coc-css', 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml', 'coc-yaml', 'coc-omnisharp'] From fd245c77582ccf758c71ab0612b3710a74d28a8a Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 3 Oct 2021 01:01:59 +0200 Subject: [PATCH 046/188] Add a script for easy linking to articles on my page --- home/.local/bin/scripts/dmenu/website-link | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 home/.local/bin/scripts/dmenu/website-link diff --git a/home/.local/bin/scripts/dmenu/website-link b/home/.local/bin/scripts/dmenu/website-link new file mode 100755 index 0000000..c7a525f --- /dev/null +++ b/home/.local/bin/scripts/dmenu/website-link @@ -0,0 +1,23 @@ +#!/usr/bin/env python +import feedparser +import subprocess + + +URL = "https://itsdrike.com/posts/index.xml" + + +def main(): + feed = feedparser.parse(URL) + titles = {entry['title']: entry['link'] for entry in feed['entries']} + + selected_page = subprocess.check_output( + ["dmenu", "-i", "-p", "Post"], + input="\n".join(titles.keys()), universal_newlines=True + ) + link = titles[selected_page.strip()] + + subprocess.check_output(["xsel", "-bi"], input=link, universal_newlines=True) + + +if __name__ == '__main__': + main() From cfe07183ee68a407589942c7beec57eeba795118 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 3 Oct 2021 10:10:13 +0200 Subject: [PATCH 047/188] Follow XDG base dir specs for nerdtree bookmarks --- home/.config/nvim/rc/plugins.d/nerdtree.vim | 10 ++++++++++ home/.config/shell/environment | 1 + 2 files changed, 11 insertions(+) diff --git a/home/.config/nvim/rc/plugins.d/nerdtree.vim b/home/.config/nvim/rc/plugins.d/nerdtree.vim index a619ec8..910a9c0 100644 --- a/home/.config/nvim/rc/plugins.d/nerdtree.vim +++ b/home/.config/nvim/rc/plugins.d/nerdtree.vim @@ -27,3 +27,13 @@ autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTr " If another buffer tries to replace NerdTree, put it in another window, and bring back NerdTree. autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif + +" Use $NERDTREE_BOOKMARKS environment variable for the location of .NERDTreeBookmarks file +if ! empty($NERDTREE_BOOKMARKS) + if ! filereadable($NERDTREE_BOOKMARKS) + let dir = system('dirname $NERDTREE_BOOKMARKS') + let x = system('mkdir -p ' . dir) + let x = system('touch $NERDTREE_BOOKMARKS') + endif + let g:NERDTreeBookmarksFile = $NERDTREE_BOOKMARKS +endif diff --git a/home/.config/shell/environment b/home/.config/shell/environment index 0caff6b..4ce3e40 100755 --- a/home/.config/shell/environment +++ b/home/.config/shell/environment @@ -35,6 +35,7 @@ export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history" export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime" export GOPATH="$XDG_DATA_HOME/go" export IPYTHONDIR="$XDG_CONFIG_HOME/ipython" +export NERDTREE_BOOKMARKS="$XDG_CONFIG_HOME/NERDTreeBookmarks" #export PYLINTHOME="$XDG_CACHE_HOME/pylint" #export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" #export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" From e8987435038337a14bf1e32438ae84a207048db5 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 3 Oct 2021 10:10:40 +0200 Subject: [PATCH 048/188] Add some further XDG env variables --- home/.config/shell/environment | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/.config/shell/environment b/home/.config/shell/environment index 4ce3e40..bdb0d73 100755 --- a/home/.config/shell/environment +++ b/home/.config/shell/environment @@ -35,6 +35,7 @@ export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history" export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime" export GOPATH="$XDG_DATA_HOME/go" export IPYTHONDIR="$XDG_CONFIG_HOME/ipython" +export ABDUCO_SOCKET_DIR="$XDG_RUNTIME_DIR" export NERDTREE_BOOKMARKS="$XDG_CONFIG_HOME/NERDTreeBookmarks" #export PYLINTHOME="$XDG_CACHE_HOME/pylint" #export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" @@ -60,5 +61,6 @@ export SUDO_ASKPASS="$HOME/.local/bin/scripts/dmenu/dmenupass" export PIPENV_VENV_IN_PROJECT=1 # Force pipenv to create new environments within projects ./.venv export XSECURELOCK_SHOW_HOSTNAME=0 # Don't show hostname in xsecurelock export XSECURELOCK_SHOW_DATETIME=1 # Show current date and time in xsecurelock +export QT_QPA_PLATFORMTHEME=qt5ct # Have QT use the theme from qt5ct #export QT_QPA_PLATFORMTHEME="gtk2" # Have QT use gtk2 theme. From b97d537b86a4bcda042bf40f93fc7c08cc4ab937 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 3 Oct 2021 18:56:15 +0200 Subject: [PATCH 049/188] Improve vim plugins categories --- home/.config/nvim/rc/plugins.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/home/.config/nvim/rc/plugins.vim b/home/.config/nvim/rc/plugins.vim index 87a4012..bc2bc14 100644 --- a/home/.config/nvim/rc/plugins.vim +++ b/home/.config/nvim/rc/plugins.vim @@ -13,22 +13,22 @@ endif " Plug.vim plugin list call plug#begin(config_dir."/plugged") -" Code completion +" Code helpers Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'airblade/vim-gitgutter' +Plug 'dhruvasagar/vim-table-mode' +Plug 'preservim/nerdcommenter' +Plug 'tmhedberg/SimpylFold' " Themes Plug 'tomasiser/vim-code-dark' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'ryanoasis/vim-devicons' -Plug 'airblade/vim-gitgutter' Plug 'tiagofumo/vim-nerdtree-syntax-highlight' " Misc -Plug 'dhruvasagar/vim-table-mode' Plug 'vimwiki/vimwiki' Plug 'wakatime/vim-wakatime' -Plug 'preservim/nerdcommenter' Plug 'preservim/nerdtree' -Plug 'tmhedberg/SimpylFold' call plug#end() From 32a22db8a8cb3a161ffebc4096749e2ad833d122 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 3 Oct 2021 18:56:33 +0200 Subject: [PATCH 050/188] Add vim-startify vim startpage --- home/.config/nvim/rc/plugins.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/nvim/rc/plugins.vim b/home/.config/nvim/rc/plugins.vim index bc2bc14..a019397 100644 --- a/home/.config/nvim/rc/plugins.vim +++ b/home/.config/nvim/rc/plugins.vim @@ -29,6 +29,7 @@ Plug 'tiagofumo/vim-nerdtree-syntax-highlight' Plug 'vimwiki/vimwiki' Plug 'wakatime/vim-wakatime' Plug 'preservim/nerdtree' +Plug 'mhinz/vim-startify' call plug#end() From b09912c42c42ab2ad0550731839357cad4b27580 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 11 Oct 2021 13:43:11 +0200 Subject: [PATCH 051/188] Use esc to stop vim search highlight --- home/.config/nvim/rc/mappings.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/home/.config/nvim/rc/mappings.vim b/home/.config/nvim/rc/mappings.vim index 6ecbf83..4b3bf35 100644 --- a/home/.config/nvim/rc/mappings.vim +++ b/home/.config/nvim/rc/mappings.vim @@ -4,8 +4,8 @@ nnoremap nnoremap nnoremap -" Stop search highlight on Ctrl+l (until next search) -map :noh +" Stop search highlight with Esc in normal mode (until next search) +nnoremap :noh " System clipboard interactions map "+y @@ -63,3 +63,10 @@ nnoremap :w \| !comp % " Shell check nnoremap p :!shellcheck % +" Redefine the incredibely annoying mappings that trigger +" dynamic SQL completion with dbext and keeps on freezing +" vim whenever pressed with a message saying that +" dbext plugin isn't installed... +" See :h ft-sql.txt +let g:omni_sql_no_default_maps = 1 + From 88de83d7d92661305124cd2d68179f70c7c69b2b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 11 Oct 2021 13:43:31 +0200 Subject: [PATCH 052/188] Add xdotool --- packages.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages.yaml b/packages.yaml index 239e849..566b81c 100644 --- a/packages.yaml +++ b/packages.yaml @@ -60,6 +60,7 @@ pacman: - xmonad # Window Manager written in haskell - xmonad-contrib # Additional tools for xmonad - xmobar # Panel built for xmonad + - xdotool # X11 automation tool - trayer # System tray standalone panel - xsel # X11 clipboard manager (alternatively there's xclip) - xsecurelock # Secure lockscreen @@ -142,6 +143,9 @@ aur: #- mailspring-libre # Beautiful and fast mail client without tracking #- code-marketplace # Enable the offical MS vscode marketplace for 'code' (code-oss) + # Misc + #- scrcpy # A way of seeing and controlling phone through a pc + # Fonts - nerd-fonts-complete git: From a8f1442b436398bacae22d8ea6b5f0965cf797a7 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 11 Oct 2021 20:03:37 +0200 Subject: [PATCH 053/188] Handle BTC value not available --- home/.local/bin/scripts/bitcoin | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/home/.local/bin/scripts/bitcoin b/home/.local/bin/scripts/bitcoin index d1ea4ef..78316b5 100755 --- a/home/.local/bin/scripts/bitcoin +++ b/home/.local/bin/scripts/bitcoin @@ -1,7 +1,12 @@ #!/bin/sh -BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null) -BTC_PRICE=$(echo $BTC_DATA | jq -r ".bpi.USD.rate_float") -BTC_PRICE=$(printf "%.2f" "$BTC_PRICE") +BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null | echo 'ERR') + +if [ "$BTC_DATA" != "ERR" ]; then + BTC_PRICE=$(echo $BTC_DATA | jq -r ".bpi.USD.rate_float") + BTC_PRICE=$(printf "%.2f" "$BTC_PRICE") + echo \$"$BTC_PRICE" +else + echo "N/A" +fi -echo \$"$BTC_PRICE" From 685b7fa387f54557818beec71df3b6fa07a00921 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 15 Oct 2021 20:11:11 +0200 Subject: [PATCH 054/188] Improve xmobar design from xmonad log hook --- home/.config/xmonad/xmonad.hs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/home/.config/xmonad/xmonad.hs b/home/.config/xmonad/xmonad.hs index 393a9e9..2134950 100644 --- a/home/.config/xmonad/xmonad.hs +++ b/home/.config/xmonad/xmonad.hs @@ -82,7 +82,7 @@ myFocusedBorderColor :: String myFocusedBorderColor = "#bc96da" -- Default workspaces. Number of workspaces is determined by the list length. -myWorkspaces = ["dev", "www", "sys", "chat", "mus", "vid", "doc", "virt", "etc"] +myWorkspaces = [" dev ", " www ", " sys ", " chat ", " mus ", " vid ", " doc ", " virt ", " etc "] myWorkspaceIndices = M.fromList $ zipWith (,) myWorkspaces [1..] -- (,) == \x y -> (x,y) -- Make the workspaces clickable @@ -347,15 +347,18 @@ myLogHook :: Handle -> Handle -> X () myLogHook xmproc0 xmproc1 = dynamicLogWithPP $ xmobarPP { ppOutput = \x -> hPutStrLn xmproc0 x -- xmobar on monitor 1 >> hPutStrLn xmproc1 x -- xmobar on monitor 2 - , ppCurrent = xmobarColor "#98be65" "" . wrap " [" "] " -- Current workspace - , ppVisible = xmobarColor "#98be65" "" . wrap " " " " . clickable -- Visible but not current workspace - , ppHidden = xmobarColor "#82AAFF" "" . wrap " *" " " . clickable -- Hidden workspaces - , ppHiddenNoWindows = xmobarColor "#c792ea" "" . wrap " " " " . clickable -- Hidden workspaces (no windows) - , ppTitle = xmobarColor "#b3afc2" "" . shorten 60 -- Title of active window - , ppSep = " | " -- Separator character - , ppUrgent = xmobarColor "#C45500" "" . wrap " !" "! " -- Urgent workspace - , ppExtras = [windowCount] -- # of windows current workspace - , ppOrder = \(ws:l:t:ex) -> [ws,l]++ex++[t] -- order of things in xmobar + + , ppCurrent = xmobarColor "#98be65" "" -- Current workspace + . wrap "" "" . clickable + , ppVisible = xmobarColor "#98be65" "" .clickable -- Visible but not current workspace + , ppHidden = xmobarColor "#82aaff" "" . clickable -- Hidden workspaces + , ppHiddenNoWindows = xmobarColor "#c792ea" "" . clickable -- Hidden workspaces (no windows) + + , ppTitle = xmobarColor "#b3afc2" "" . shorten 60 -- Title of active window + , ppSep = " | " -- Separator character + , ppUrgent = xmobarColor "#c45500" "" . wrap "!" "!" -- Urgent workspace + , ppExtras = [windowCount] -- # of windows current workspace + , ppOrder = \(ws:l:t:ex) -> [ws,l]++ex++[t] -- order of things in xmobar } From 27df041884594be6712a21a75492659a608b61f5 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 15 Oct 2021 20:13:10 +0200 Subject: [PATCH 055/188] Adjust xmonad window management shortcuts --- home/.config/xmonad/xmonad.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/home/.config/xmonad/xmonad.hs b/home/.config/xmonad/xmonad.hs index 2134950..d050ca7 100644 --- a/home/.config/xmonad/xmonad.hs +++ b/home/.config/xmonad/xmonad.hs @@ -141,12 +141,13 @@ myKeys = , ("M-.", nextScreen) -- Switch focus to next monitor , ("M-,", prevScreen) -- Switch focus to prev monitor , ("M-S-", shiftTo Next nonNSP >> moveTo Next nonNSP) -- Shifts focused window to next ws - , ("M-S-", shiftTo Prev nonNSP >> moveTo Prev nonNSP) -- Shifts focused window to prev ws + , ("M-S-", shiftTo Prev nonNSP >> moveTo Prev nonNSP) -- Shifts focused window to prev ws -- Floating windows - , ("M-f", sendMessage (T.Toggle "floats")) -- Toggles 'floats' layout + , ("M-f", withFocused $ float) -- Make window float , ("M-t", withFocused $ windows . W.sink) -- Push floating window back to tile , ("M-S-t", sinkAll) -- Push all floating windows to tile + , ("M-S-f", sendMessage (T.Toggle "floats")) -- Toggles 'floats' layout -- Increase/decrease spacing (gaps) , ("C-M1-j", decWindowSpacing 4) -- Decrease window spacing From 93f1bd30f06596b16351e657cf074a37bc532fd1 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 15 Oct 2021 20:13:29 +0200 Subject: [PATCH 056/188] Use xsecurelock directly instead of DPMS trigger --- home/.config/xmonad/xmonad.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home/.config/xmonad/xmonad.hs b/home/.config/xmonad/xmonad.hs index d050ca7..f1971c1 100644 --- a/home/.config/xmonad/xmonad.hs +++ b/home/.config/xmonad/xmonad.hs @@ -105,7 +105,8 @@ myKeys = , ("M-S-q", io exitSuccess) -- Quits xmonad -- Lock screen - , ("C-M-l", spawn "xset s activate") -- Send DPMS trigger for lockscreen + , ("C-M-l", spawn "xsecurelock") -- XSecureLock lockscreen + --, ("C-M-l", spawn "xset s activate") -- Send DPMS trigger for lockscreen -- Programs , ("M-b", spawn (myBrowser)) From 900f5f270627aa12bac7ca71937711df8d1a8bc5 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 15 Oct 2021 20:14:11 +0200 Subject: [PATCH 057/188] Add some app-specific xmonad settings --- home/.config/xmonad/xmonad.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/.config/xmonad/xmonad.hs b/home/.config/xmonad/xmonad.hs index f1971c1..9de8c41 100644 --- a/home/.config/xmonad/xmonad.hs +++ b/home/.config/xmonad/xmonad.hs @@ -317,9 +317,11 @@ myManageHook = composeAll , className =? "splash" --> doFloat , className =? "toolbar" --> doFloat , className =? "Qalculate-gtk" --> doFloat + , className =? "udiskie" --> doFloat , isFullscreen --> doFullFloat -- auto-shift applications to their respecitve workspaces , className =? "discord" --> doShift ( myWorkspaces !! 3 ) + , className =? "Element" --> doShift ( myWorkspaces !! 3 ) , className =? "Code" --> doShift ( myWorkspaces !! 0 ) , className =? "Stremio" --> doShift ( myWorkspaces !! 5 ) , title =? "Mozilla Firefox" --> doShift ( myWorkspaces !! 1 ) From c01d292933ca80c319c81fa9ab6d7f24e0419f8a Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 22 Oct 2021 13:19:06 +0200 Subject: [PATCH 058/188] Fix bitcoin price script --- home/.local/bin/scripts/bitcoin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.local/bin/scripts/bitcoin b/home/.local/bin/scripts/bitcoin index 78316b5..c0dfad2 100755 --- a/home/.local/bin/scripts/bitcoin +++ b/home/.local/bin/scripts/bitcoin @@ -1,6 +1,6 @@ #!/bin/sh -BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null | echo 'ERR') +BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null || echo 'ERR') if [ "$BTC_DATA" != "ERR" ]; then BTC_PRICE=$(echo $BTC_DATA | jq -r ".bpi.USD.rate_float") From 4bc99d46b59a48bc0d90cb0ad3f1453a7f50ed2b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 22 Oct 2021 13:19:20 +0200 Subject: [PATCH 059/188] Fix ip-show alias --- home/.config/shell/aliases | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 02b983c..0b38dca 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -117,7 +117,7 @@ alias grep_mac='grep -E `reg_mac`' alias massgrep='grep -RHIni' # Network -alias ip-show='curl https://api.ipify.org' # Get global IP address +alias ip-show='curl https://ifconfig.co' # Get global IP address alias ips="ifconfig -a | grep -oE \"inet6? (addr:)?s?\`reg_ip\`\" | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'" alias lan-device-scan='nmap -T5 -sP 192.168.0.0-255' alias lan-vuln-scan='nmap -sT -O --script vuln 192.168.0.0-255' From 2446789d25234634e058b3a382751d7536558f81 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 14 Nov 2021 20:54:15 +0100 Subject: [PATCH 060/188] Add support for terminal window swallowing --- home/.config/lf/lfrc | 2 +- home/.config/shell/aliases | 7 +++++++ packages.yaml | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/home/.config/lf/lfrc b/home/.config/lf/lfrc index 572914e..8857c5e 100644 --- a/home/.config/lf/lfrc +++ b/home/.config/lf/lfrc @@ -12,7 +12,7 @@ set scrolloff 5 cmd open ${{ case $(file --mime-type "$f" -bL) in text/*|application/json) $EDITOR "$f";; - *) xdg-open "$f" ;; + *) devour xdg-open "$f" ;; esac }} diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 02b983c..da5dbae 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -103,6 +103,13 @@ alias mergepdf='gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.p alias encrypt='gpg -c --no-symkey-cache --cipher-algo AES256' # Encrypt file with AES256 symetric encryption alias decrypt='gpg' # For the sake of completeness, include decrypt command to the above, though it's only just gpg alias +# Terminal window swallowing for blocking programs (devour) +alias xdg-open='devour xdg-open' +alias mpv='devour mpv' +alias nomacs='devour nomacs' +alias pcmanfm='devour pcmanfm' +alias spotify='devour spotify' + # Regular expressions alias reg_email='echo "[a-Z0-9._%-]+@[a-Z0-9.-]+\.[a-Z]{2,10}"' alias reg_mac='echo "([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}"' diff --git a/packages.yaml b/packages.yaml index 566b81c..e2c199c 100644 --- a/packages.yaml +++ b/packages.yaml @@ -134,6 +134,7 @@ aur: # WM/Xorg - picom-git # Git version of picom compositor + - devour # WM agnostic window swallowing for terminals # GUI - spotify # Online music player From 82f60713d4c82f7a0d3f14b63d3c7d72fb3321e2 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 14 Nov 2021 20:54:54 +0100 Subject: [PATCH 061/188] Add vim-like exist aliases --- home/.config/shell/aliases | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index da5dbae..7afa8ae 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -220,6 +220,12 @@ alias yta-best='youtube-dl --extract-audio --audio-format best' alias yta-mp3='youtube-dl --extract-audio --audio-format mp3' alias yta-wav='youtube-dl --extract-audio --audio-format wav' +# Terminal vim-like exits, in case I think the terminal is vim +alias :q='exit' +alias :q!='exit' +alias :wq='exit' +alias :wq!='exit' + # Shell aliases alias reload="exec \$SHELL" # Reload the shell (i.e. invoke as a login shell) alias path='echo -e ${PATH//:/\\n}' # Print each PATH entry on a separate line From 6d85a4bc403d6eb81b0e6f5b941569cf9cd47962 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 14 Nov 2021 20:57:43 +0100 Subject: [PATCH 062/188] Fix cftodo alias --- home/.config/shell/aliases | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 7afa8ae..dbeac96 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -73,7 +73,7 @@ alias cfkeybinds='vim ~/.config/shell/keybinds' alias cfxprofile='vim ~/.config/x11/xprofile' alias cfxmonad='vim ~/.config/xmonad/xmonad.hs && xmonad --recompile && xmonad --restart' alias cfxmobar='vim ~/.config/xmobar/xmobarrc.hs && ~/.config/xmobar/multi_mon.sh 2' -alias cftodo='vim ~/Personal/todo' +alias cftodo='vim ~/Personal/vimwiki/todo.md' # Python alias py3='python3' From 9166b4c051f99b3151bf43d7e69a2ce3a7db3351 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 14 Nov 2021 20:58:43 +0100 Subject: [PATCH 063/188] Update directory aliases --- home/.config/shell/aliases | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index dbeac96..5f1ca58 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -8,6 +8,14 @@ alias souce='source' alias suod='sudo ' alias sduo='sudo ' +# Replacements (adding flags) +alias cp='cp -iv' # Ask before overwriting, verbose +alias mv='mv -iv' # Ask before overwriting, verbose +alias rm='trash-put' # Use trash-cli instead of true removal +alias rmr='\rm -v' # True rm, verbose (asking here is too annoying) +alias wget='wget -c' # Resume wget by default +alias df='df -H' # Show sizes as powers of 1000 + # Directory changing alias ..='cd ..' alias ...='cd ../../' @@ -17,29 +25,16 @@ alias .2='cd ../../' alias .3='cd ../../../' alias .4='cd ../../../../' alias .5='cd ../../../../../' -# z.lua script -alias j='z' # for the sake of autojump old habits -alias zz='z -c' # restrict matches to subdirs of $PWD -alias zb='z -b' # restrict matches to parent directories -alias zi='z -I' # cd with interactive fzf selection -alias zbi='z -b -I' # pick parent directory to cd into with fzf # Files/Directories utilities alias mkdir='mkdir -p' alias md='mkdir' alias fhere='find . -name' -alias rr='rm -r' -alias rf='rm -f' -alias rrf='rm -rf' +alias rr='rmr -r' +alias rf='rmr -f' +alias rrf='rmr -rf' alias vimdiff='nvim -d' -# Replacements (adding flags) -alias cp='cp -iv' # Ask before overwriting, verbose -alias mv='mv -iv' # Ask before overwriting, verbose -alias rm='rm -v' # Verbose (asking here is too annoying) -alias wget='wget -c' # Resume wget by default -alias df='df -H' # Show sizes as powers of 1000 - # Directory listing aliases, defaults to exa, if aviable if command -v exa > /dev/null; then alias ls='exa' @@ -75,6 +70,13 @@ alias cfxmonad='vim ~/.config/xmonad/xmonad.hs && xmonad --recompile && xmonad - alias cfxmobar='vim ~/.config/xmobar/xmobarrc.hs && ~/.config/xmobar/multi_mon.sh 2' alias cftodo='vim ~/Personal/vimwiki/todo.md' +# z.lua shortcuts +alias j='z' # for the sake of autojump old habits +alias zz='z -c' # restrict matches to subdirs of $PWD +alias zb='z -b' # restrict matches to parent directories +alias zi='z -I' # cd with interactive fzf selection +alias zbi='z -b -I' # pick parent directory to cd into with fzf + # Python alias py3='python3' alias py2='python2' From efea92558327835a9128b2a0e5b01cb4e2e5bfef Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 15 Nov 2021 00:59:18 +0100 Subject: [PATCH 064/188] Add attributions readme section --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 969ee82..201e76b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ You are highly adviced to first go through these dotfiles yourself and adjust th - oh-my-zsh configuration is also supported, but it is off by default, adjust [`.zshrc`](home/.config/zsh/.zshrc) to enable it - Even though enabling it is an option, it is not a necessary thing to do, oh-my-zsh has a lot of code that is mostly irrelevant and unused, these dotfiles give you the ability to completely avoid it, if you desire to do so - Custom [prompt](home/.config/shell/theme), both for oh-my-zsh configuration or for standalone usage -- Custom [VIM configuration](home/.config/nvim) +- Custom [VIM configuration](home/.config/nvim) - When you open nvim for the first time, it will automatically try to install addons using VimPlug - It is complatible with TTY usage, in which case the color support is downgraded and use of special fonts is disabled. - There isn't a single huge configuration file, but rather multiple config files that are being sourced by the main init.vim, this is done to avoid clutter with comments in the main file and it also provides a very easy way to disable parts of configuration, by simply not sourcing that file. @@ -42,7 +42,7 @@ You are highly adviced to first go through these dotfiles yourself and adjust th - [`brightness`](home/.local/bin/scripts/brightness): Script to quickly change screen brightness, you may need to adjust the BRIGHTNESS_FILE, this can be different from machine to machine - [`setbg`](home/.local/bin/scripts/setbg): Quick way to set desktop background to specific image, or random image, or previously used image - Many smaller dmenu scripts to make life easier - + ## Requirements @@ -57,3 +57,18 @@ If you don't want to install git (running straight from newly installed os), you `$ curl -LJO https://github.com/ItsDrike/dotfiles/tarball/master`
And extract from `.tar.gz` archive: `$ tar xvf [archive name]` + +## Attribution + +The open-source community has an incredible amount of resources that people have offered to others free of charge and +we all depend on many of these sources. This project is no different and there were many open-source projects that were +utilized in some parts of this project. For that reason, I'd like tho thank all of these projects and their +contributors for keeping their content open and available to everyone. This is the list of projects that helped me +build this repository to the stage it's in now. Many of the aliases, config files and other resources aren't my +original creations, but rather just small improvements and adjustments to get everything set in the way I like. Below +is the list of all projects which helped the existence of this repository: +- [Lukesmith's dotfiles/voidrice](https://github.com/LukeSmithxyz/voidrice) +- [BrodieRobertson's dotfiles](https://github.com/BrodieRobertson/dotfiles) +- [BrodieRobertson's scripts](https://github.com/BrodieRobertson/scripts) +- [Derek Taylor's dotfiles](https://gitlab.com/dwt1/dotfiles) + From d4dbe6451590851ae638a469ddf252288ecff53c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 15 Nov 2021 01:09:56 +0100 Subject: [PATCH 065/188] Improve readme formatting --- README.md | 58 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 201e76b..27b692c 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ # Dotfiles -These are my personal dotfiles. They're split into `home/` and `root/` folders where the home folder holds all files that should be put directly into your `$HOME` directory, while all of the files in the root folder can be put directly into `/` +These are my personal dotfiles. They're split into `home/` and `root/` folders where the home folder holds all files +that should be put directly into your `$HOME` directory, while all of the files in the root folder can be put directly +into `/` -You are highly adviced to first go through these dotfiles yourself and adjust them to your liking. +You are highly advised to first go through these dotfiles yourself and adjust them to your liking. ## Sample images -- Custom prompt (defined [here](home/.config/shell/theme). +- Custom prompt (defined [here](home/.config/shell/theme)). - Colorscheme showcase: ![image](https://user-images.githubusercontent.com/20902250/117699472-69ab5d80-b1b4-11eb-85a8-2b039bc1599a.png) - Command timing showcase: ![image](https://user-images.githubusercontent.com/20902250/129356038-f1373183-ee50-4cc9-a602-a1215b5d1e5f.png) - Neovim configuration (defined [`here`](home/.config/nvim/)) ![image](https://user-images.githubusercontent.com/20902250/129356722-9eb1e813-62c4-4ad1-ad49-114f69700f80.png) @@ -17,43 +19,55 @@ You are highly adviced to first go through these dotfiles yourself and adjust th ## Features - Full fledged ZSH configuration without the need to rely on oh-my-zsh - - oh-my-zsh configuration is also supported, but it is off by default, adjust [`.zshrc`](home/.config/zsh/.zshrc) to enable it - - Even though enabling it is an option, it is not a necessary thing to do, oh-my-zsh has a lot of code that is mostly irrelevant and unused, these dotfiles give you the ability to completely avoid it, if you desire to do so + - oh-my-zsh configuration is also supported, but it is off by default, adjust [`.zshrc`](home/.config/zsh/.zshrc) to + enable it + - Even though enabling it is an option, it is not a necessary thing to do, oh-my-zsh has a lot of code that is mostly + irrelevant and unused, these dotfiles give you the ability to completely avoid it, if you desire to do so - Custom [prompt](home/.config/shell/theme), both for oh-my-zsh configuration or for standalone usage - Custom [VIM configuration](home/.config/nvim) - When you open nvim for the first time, it will automatically try to install addons using VimPlug - - It is complatible with TTY usage, in which case the color support is downgraded and use of special fonts is disabled. - - There isn't a single huge configuration file, but rather multiple config files that are being sourced by the main init.vim, this is done to avoid clutter with comments in the main file and it also provides a very easy way to disable parts of configuration, by simply not sourcing that file. - - NOTE: This configuration is mostly designed for neovim, not regular vim, however it should work with some adjustments -- Many handy [aliases](home/.config/shell/aliases) and [functions](home/.config/shell/functions) (likely too many, you should adjust that to your needs) + - It is compatible with TTY usage, in which case the color support is downgraded and use of special fonts is + disabled. + - There isn't a single huge configuration file, but rather multiple config files that are being sourced by the main + init.vim, this is done to avoid clutter with comments in the main file and it also provides a very easy way to + disable parts of configuration, by simply not sourcing that file. + - NOTE: This configuration is mostly designed for neovim, not regular vim, however it should work with some + adjustments +- Many handy [aliases](home/.config/shell/aliases) and [functions](home/.config/shell/functions) (likely too many, you + should adjust that to your needs) - [Many pre-defined environmental variables](home/.config/shell/environ), these include - XDG paths configuration to avoid too much cluttering in home directory - Colorful man pages using LESS_TERMCAP, or if `bat` is installed, using it as MANPAGER -- [Automatic handlers](home/.config/shell/handlers) which override default command not found behavior to show the package to which given command belongs (requires pkgfile on Arch Linux) -- List of useful packages that I often install on most of my systems. (These are the package names for arch linux, but you should be able to find these for any distro, perhaps with a bit different name) located in [`packages.yaml`](packages.yaml) -- [Opensnitch firewall rules](root/etc/opensnitchd/rules), which block most unauthorized traffic and only allow needed things. This also blocks spotify ads. +- [Automatic handlers](home/.config/shell/handlers) which override default command not found behavior to show the + package to which given command belongs (requires pkgfile on Arch Linux) +- List of useful packages that I often install on most of my systems. (These are the package names for arch linux, but + you should be able to find these for any distro, perhaps with a bit different name) located in + [`packages.yaml`](packages.yaml) +- [Opensnitch firewall rules](root/etc/opensnitchd/rules), which block most unauthorized traffic and only allow needed + things. This also blocks spotify ads. - Automatic logout for TTY sessions or for root logins after 10 minutes of inactivity - NetworkManager configuration which assigns new mac for each network - `lf` file manager configuration with support for ueberzug image previews within the terminal - Tons of handy scripts for automating common tasks - - [`incremental-backup`](root/usr/local/bin/incremental-backup): Easy way to utilize rsync for all backups, without the need for external software - - [`auto-chroot`](root/usr/local/bin/auto-chroot): Quick way to chroot into any other linux system, without typing the very repetetive mount and umount commands - - [`tamper-check`](root/usr/local/bin/tamper-check): Script that uses checksums to verify that given files weren't adjusted in any way. - - [`brightness`](home/.local/bin/scripts/brightness): Script to quickly change screen brightness, you may need to adjust the BRIGHTNESS_FILE, this can be different from machine to machine - - [`setbg`](home/.local/bin/scripts/setbg): Quick way to set desktop background to specific image, or random image, or previously used image + - [`incremental-backup`](root/usr/local/bin/incremental-backup): Easy way to utilize rsync for all backups, without + the need for external software + - [`auto-chroot`](root/usr/local/bin/auto-chroot): Quick way to chroot into any other linux system, without typing + the very repetitive mount and umount commands + - [`tamper-check`](root/usr/local/bin/tamper-check): Script that uses checksums to verify that given files weren't + adjusted in any way. + - [`brightness`](home/.local/bin/scripts/brightness): Script to quickly change screen brightness, you may need to + adjust the BRIGHTNESS_FILE, this can be different from machine to machine + - [`setbg`](home/.local/bin/scripts/setbg): Quick way to set desktop background to specific image, or random image, + or previously used image - Many smaller dmenu scripts to make life easier -## Requirements - -`curl` and `tar`, or `git` to clone the repository itself. ## Installation - Clone this repository anywhere you like `$ git clone https://github.com/ItsDrike/dotfiles` -If you don't want to install git (running straight from newly installed os), you can use `curl`:
+If you don't want to install git (running straight from newly installed OS), you can use `curl`:
`$ curl -LJO https://github.com/ItsDrike/dotfiles/tarball/master`
And extract from `.tar.gz` archive: `$ tar xvf [archive name]` From 0619e887a30d45025cf2d30407c8f2c9d18418cc Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 21 Nov 2021 23:54:42 +0100 Subject: [PATCH 066/188] Add lockscreen management script --- home/.config/x11/xprofile | 16 ++--------- home/.config/xmonad/xmonad.hs | 8 ++---- home/.local/bin/scripts/lockscreen | 44 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 18 deletions(-) create mode 100755 home/.local/bin/scripts/lockscreen diff --git a/home/.config/x11/xprofile b/home/.config/x11/xprofile index d323b18..f3c3b4b 100644 --- a/home/.config/x11/xprofile +++ b/home/.config/x11/xprofile @@ -6,18 +6,14 @@ # Set monitor order xrandr --output HDMI-1 --auto --output eDP-1 --right-of HDMI-1 --auto & -# XSS lock with xsecurelock -xss-lock -n /usr/lib/xsecurelock/dimmer -l -- xsecurelock & - -# Set X11 lockscreen delays (DPMS) -xset s on & -xset s 600 10 & # 10 minutes, 5s for dimmer +# Start xsecurelock lockscreen with xss-lock +~/.local/bin/scripts/lockscreen start & # Set the background with a custom `setbg` script setbg & # Use xresources file in ~/.config/x11 -xrdb ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources +xrdb ${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources & # Start compositor manager to allow transparency picom -b --experimental-backends & @@ -44,12 +40,6 @@ numlockx & # Udiskie for simple mounting and notifications, no automount for security reasons udiskie -A -s & -# Run emacs daemon -#emacs --daemon & - -# Run urxvt daemon -#urxvtd -q -o -f & - # Enable running applications from chroot xhost +local: diff --git a/home/.config/xmonad/xmonad.hs b/home/.config/xmonad/xmonad.hs index 9de8c41..fb648b1 100644 --- a/home/.config/xmonad/xmonad.hs +++ b/home/.config/xmonad/xmonad.hs @@ -104,10 +104,6 @@ myKeys = [ ("M-S-r", spawn "xmonad --recompile; xmonad --restart") -- Recompiles xmonad , ("M-S-q", io exitSuccess) -- Quits xmonad - -- Lock screen - , ("C-M-l", spawn "xsecurelock") -- XSecureLock lockscreen - --, ("C-M-l", spawn "xset s activate") -- Send DPMS trigger for lockscreen - -- Programs , ("M-b", spawn (myBrowser)) , ("M-", spawn (myTerminal)) @@ -128,7 +124,9 @@ myKeys = -- Script shortcuts , ("M-S-p", spawn "setbg ~/Pictures/Wallpapers/Active") -- Set random background - , ("M-S-d", spawn "displayselect") + , ("M-S-d", spawn "displayselect") -- Set display configurations + , ("M-C-l", spawn "lockscreen lock") -- Lock the screen + , ("M-C-S-l", spawn "lockscreen toggle") -- Toggle automatic locking -- Kill windows , ("M-w", kill1) -- Kill the currently focused client diff --git a/home/.local/bin/scripts/lockscreen b/home/.local/bin/scripts/lockscreen new file mode 100755 index 0000000..170c722 --- /dev/null +++ b/home/.local/bin/scripts/lockscreen @@ -0,0 +1,44 @@ +#!/bin/sh + +if [ "$1" = "start" ]; then + MODE="start" +elif [ "$1" = "stop" ]; then + MODE="stop" +elif [ "$1" = "toggle" ]; then + if pidof -s xss-lock > /dev/null 2>&1; then + MODE="stop" + else + MODE="start" + fi +elif [ "$1" = "lock" ]; then + MODE="lock" +else + echo "Invalid command usage, use: lockscreen [start/stop/toggle/lock]" + exit 1 +fi + +if [ "$MODE" = "start" ]; then + echo "Starting xss-lock" + # Set X11 lockscreen delays (DPMS) + xset s on + xset s 600 10 # Dim screen after 10 minutes, lock 10s later + + # XSS lock with xsecurelock + xss-lock -n /usr/lib/xsecurelock/dimmer -l -- xsecurelock & +elif [ "$MODE" = "stop" ]; then + echo "Stopping xss-lock" + # Remove X11 lockscreen delays (DPMS) + xset s off + # Stop XSS lock + killall xss-lock +elif [ "$MODE" = "lock" ]; then + # Send a DPMS trigger if xss-lock is running to inform it + # about the lockstate, if it's not running, run xsecurelock directly + if pidof -s xss-lock > /dev/null 2>&1; then + echo "Locking screen - using DPMS (xss-lock active)" + xset s activate + else + echo "Locking screen - running xsecurelock directly (xss-lock isn't running)" + xsecurelock + fi +fi From 38d7d27e1fb37d0202c92b772359859ac4bb177c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 23 Nov 2021 19:42:34 +0100 Subject: [PATCH 067/188] Add opt-in vnstat package --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index e2c199c..f2cd163 100644 --- a/packages.yaml +++ b/packages.yaml @@ -35,6 +35,7 @@ pacman: - dnsutils # Tools for managing DNS - net-tools # Configuration tools for linux networking #- sshuttle # Transparent proxy server that forwards all TCP packets over SSH + #- vnstat # Tool for monitoring network traffic (speed and total data transfered) # Media - imagemagick # Terminal image manipulation From caef6a84c5b9edd1fbb275ac1db59a875848ad17 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 23 Nov 2021 21:26:02 +0100 Subject: [PATCH 068/188] Add opt-in kexec-tools package --- packages.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages.yaml b/packages.yaml index f2cd163..8a61cc7 100644 --- a/packages.yaml +++ b/packages.yaml @@ -10,6 +10,9 @@ pacman: - cronie # Run programs at specified time - zsh # Modern system shell + # System + #- kexec-tools # Kexec allows directly booting into a new kernel + # CLI - exa # Colored LS - bat # Colored cat with tons of cool options From 4929c281d2cf9a04042d17188ac05cbc5c28e7cb Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 24 Nov 2021 00:04:32 +0100 Subject: [PATCH 069/188] Add initcpio script to autodetect external luks root key --- root/etc/initcpio/hooks/lukskeyfile | 27 +++++++++++++++++++++++++++ root/etc/initcpio/install/lukskeyfile | 27 +++++++++++++++++++++++++++ root/etc/mkinitcpio.conf | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 root/etc/initcpio/hooks/lukskeyfile create mode 100644 root/etc/initcpio/install/lukskeyfile diff --git a/root/etc/initcpio/hooks/lukskeyfile b/root/etc/initcpio/hooks/lukskeyfile new file mode 100644 index 0000000..fce69a5 --- /dev/null +++ b/root/etc/initcpio/hooks/lukskeyfile @@ -0,0 +1,27 @@ +#!/bin/ash + +run_hook() { + if [ -n "$lukskeyfile" ]; then + # This is a needed kernel parameter for this hook + modprobe -a -q loop dm-crypt >/dev/null 2>&1 + # Refer to help from `mkinitcpio -H lukskeyfile`. + IFS=: read rootKeyDev rootKey cryptkeyLoc </dev/null 2>&1; then + cat "/mnt/${rootKey}" > "${cryptkeyLoc}" + else + echo "Failed to mount ${rootKeyDev} on /mnt" + /bin/sh + fi + else + echo "Failed to find ${rootKeyDev} containing LUKS root key." + fi + fi +} diff --git a/root/etc/initcpio/install/lukskeyfile b/root/etc/initcpio/install/lukskeyfile new file mode 100644 index 0000000..5e78430 --- /dev/null +++ b/root/etc/initcpio/install/lukskeyfile @@ -0,0 +1,27 @@ +#!/bin/bash + +build() { + add_dir "/mnt" + add_module loop + add_module dm-crypt + add_runscript +} + +help() { + cat < Date: Wed, 24 Nov 2021 00:07:35 +0100 Subject: [PATCH 070/188] Add default grub configuration --- root/etc/default/grub | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 root/etc/default/grub diff --git a/root/etc/default/grub b/root/etc/default/grub new file mode 100644 index 0000000..f35e20c --- /dev/null +++ b/root/etc/default/grub @@ -0,0 +1,62 @@ +# GRUB boot loader configuration + +GRUB_DEFAULT=0 +GRUB_TIMEOUT=5 +GRUB_DISTRIBUTOR="Arch" +GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet" +GRUB_CMDLINE_LINUX="cryptdevice=UUID=9a400ce4-df98-43eb-b88c-009a359873a5:cryptroot:allow-discards lukskeyfile=UUID=80c09daa-c562-4242-90a9-8258f6442bec:/root-key" +# Grub should automatically detect the root UUID after decryption and set +# that as root, we could also use root=/dev/mapper/cryptroot cmdline arg, +# however that could lead to problems, since GRUB defines the root anyway, +# so we'd have 2 root definitions, we could also use the UUID manually by using +# root=7173b256-9d90-41f5-beac-4d01b3b5bbd5 + +# Preload both GPT and MBR modules so that they are not missed +GRUB_PRELOAD_MODULES="part_gpt part_msdos" + +# Uncomment to enable booting with LUKS encrypted /boot drive +#GRUB_ENABLE_CRYPTODISK=y + +# Set to 'countdown' or 'hidden' to change timeout behavior, +# press ESC key to display menu. +GRUB_TIMEOUT_STYLE=menu + +# Uncomment to use basic console +GRUB_TERMINAL_INPUT=console + +# Uncomment to disable graphical terminal +#GRUB_TERMINAL_OUTPUT=console + +# The resolution used on graphical terminal +# note that you can use only modes which your graphic card supports via VBE +# you can see them in real GRUB with the command `vbeinfo' +GRUB_GFXMODE=auto + +# Uncomment to allow the kernel use the same resolution used by grub +GRUB_GFXPAYLOAD_LINUX=keep + +# Uncomment if you want GRUB to pass to the Linux kernel the old parameter +# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx" +#GRUB_DISABLE_LINUX_UUID=true + +# Uncomment to disable generation of recovery mode menu entries +GRUB_DISABLE_RECOVERY=true + +# Uncomment and set to the desired menu colors. Used by normal and wallpaper +# modes only. Entries specified as foreground/background. +#GRUB_COLOR_NORMAL="light-blue/black" +#GRUB_COLOR_HIGHLIGHT="light-cyan/blue" + +# Uncomment one of them for the gfx desired, a image background or a gfxtheme +#GRUB_BACKGROUND="/path/to/wallpaper" +#GRUB_THEME="/path/to/gfxtheme" + +# Uncomment to get a beep at GRUB start +#GRUB_INIT_TUNE="480 440 1" + +# Uncomment to make GRUB remember the last selection. This requires +# setting 'GRUB_DEFAULT=saved' above. +#GRUB_SAVEDEFAULT=true + +# Uncomment to disable submenus in boot menu +#GRUB_DISABLE_SUBMENU=y From 000a960006773f4b1751448ca6f66863a5a9c392 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 25 Nov 2021 21:11:01 +0100 Subject: [PATCH 071/188] Fix default 'X'-shaped cursor --- home/.config/x11/xprofile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/home/.config/x11/xprofile b/home/.config/x11/xprofile index f3c3b4b..2fab89e 100644 --- a/home/.config/x11/xprofile +++ b/home/.config/x11/xprofile @@ -43,3 +43,6 @@ udiskie -A -s & # Enable running applications from chroot xhost +local: +# Change x shaped default cursor (fonts are located in /usr/include/X11/cursorfont.h) +xsetroot -cursor_name left_ptr + From 2264da5a035ffac668cb161ee48458a984541362 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 25 Nov 2021 21:12:04 +0100 Subject: [PATCH 072/188] Remove trailing newline --- home/.config/x11/xprofile | 1 - 1 file changed, 1 deletion(-) diff --git a/home/.config/x11/xprofile b/home/.config/x11/xprofile index 2fab89e..a44b93f 100644 --- a/home/.config/x11/xprofile +++ b/home/.config/x11/xprofile @@ -45,4 +45,3 @@ xhost +local: # Change x shaped default cursor (fonts are located in /usr/include/X11/cursorfont.h) xsetroot -cursor_name left_ptr - From 46f80b190be8ae6b71dedd056b9099e22ad84e75 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 25 Nov 2021 21:13:36 +0100 Subject: [PATCH 073/188] Add shortcut for pcmanfm and lf --- home/.config/xmonad/xmonad.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/home/.config/xmonad/xmonad.hs b/home/.config/xmonad/xmonad.hs index fb648b1..5be8f3c 100644 --- a/home/.config/xmonad/xmonad.hs +++ b/home/.config/xmonad/xmonad.hs @@ -64,6 +64,8 @@ myModMask = mod4Mask -- Preferred programs myTerminal = "alacritty" myBrowser = "firefox" +myFileManager = "pcmanfm" +myCliFileManager = "lf" -- Preferred font myFont :: String @@ -105,8 +107,10 @@ myKeys = , ("M-S-q", io exitSuccess) -- Quits xmonad -- Programs - , ("M-b", spawn (myBrowser)) , ("M-", spawn (myTerminal)) + , ("M-b", spawn (myBrowser)) + , ("M-v", spawn (myFileManager)) + , ("M-M1-v", spawn (myTerminal ++ " -e " ++ myCliFileManager)) , ("M-M1-h", spawn (myTerminal ++ " -e htop")) , ("M-M1-b", spawn (myTerminal ++ " -e bpytop")) , ("M-M1-p", spawn (myTerminal ++ " -e ipython")) From 365de49061633cabe2718e22617067e3743c9f3a Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 25 Nov 2021 21:15:39 +0100 Subject: [PATCH 074/188] Add xsetroot package --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index 8a61cc7..3781157 100644 --- a/packages.yaml +++ b/packages.yaml @@ -61,6 +61,7 @@ pacman: - xorg-server # Xorg server implementation - xorg-xinit # Simple way to start X - xorg-xrandr # Manage multiple monitors in X + - xorg-xsetroot # Customize appearance of X root - xmonad # Window Manager written in haskell - xmonad-contrib # Additional tools for xmonad - xmobar # Panel built for xmonad From 65529ffd1d2b6dcdd3b29513a4689e3f5b77e4c4 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 26 Nov 2021 19:06:51 +0100 Subject: [PATCH 075/188] Add find and show merge commit aliases --- home/.config/git/config | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/home/.config/git/config b/home/.config/git/config index 9476b66..2400e83 100644 --- a/home/.config/git/config +++ b/home/.config/git/config @@ -6,9 +6,12 @@ [credential] helper = store --file ~/.config/git/git-credentials [alias] - l = log --oneline --decorate --all --graph - lol = log --pretty=oneline --abbrev-commit --graph - lg = log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- + l = "log --oneline --decorate --all --graph" + lol = "log --pretty=oneline --abbrev-commit --graph" + lg = "log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --" + find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'" + show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'" + [merge] tool = meld [mergetool] From b2d1153f47731c7aa780134dcc076d62ae7a0f54 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 28 Nov 2021 19:12:59 +0100 Subject: [PATCH 076/188] Add breeze cursor theme --- packages.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages.yaml b/packages.yaml index 3781157..3c66431 100644 --- a/packages.yaml +++ b/packages.yaml @@ -138,8 +138,9 @@ aur: - opensnitch # Application level firewall with traffic monitoring (Alternatively, there's portmaster) # WM/Xorg - - picom-git # Git version of picom compositor - - devour # WM agnostic window swallowing for terminals + - picom-git # Git version of picom compositor + - devour # WM agnostic window swallowing for terminals + - xcursor-simp1e-breeze-snow # Breeze cursor theme # GUI - spotify # Online music player From 6bb055d42f282ed5e986d9ca066d41260361e311 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 28 Nov 2021 19:40:52 +0100 Subject: [PATCH 077/188] Add and reorder nvim mappings --- home/.config/nvim/rc/mappings.vim | 70 ++++++++++++++++++------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/home/.config/nvim/rc/mappings.vim b/home/.config/nvim/rc/mappings.vim index 4b3bf35..65e1935 100644 --- a/home/.config/nvim/rc/mappings.vim +++ b/home/.config/nvim/rc/mappings.vim @@ -4,13 +4,46 @@ nnoremap nnoremap nnoremap -" Stop search highlight with Esc in normal mode (until next search) -nnoremap :noh +" Tab navigation +nnoremap gt +nnoremap gT +nnoremap :tabnew +nnoremap :tabmove + +nnoremap :tabmove - +nnoremap :tabp +nnoremap :tabn + +" Splits navigation to just ALT + hjkl +nnoremap h +nnoremap j +nnoremap k +nnoremap l + +" Make adjusting split sizes a bit more friendly +noremap :vertical resize +3 +noremap :vertical resize -3 +noremap :resize +3 +noremap :resize -3 " System clipboard interactions map "+y vnoremap "+p +" Use more common Undo/Redo shortcuts +nnoremap :undo +nnoremap :redo + +" Use more common save shortcut +nnoremap :w + +" Terminal +nnoremap :vnew term://zshi +nnoremap :split term://zshi +nnoremap :tabnew term://zshi + +" Alias replace all +nnoremap :%s//gI + " Start spell-check map s :setlocal spell! spelllang=en_us @@ -22,37 +55,16 @@ vnoremap zf noremap K 10k noremap J 10j +" Save file as sudo when no write permissions +cmap w!! w !sudo tee > /dev/null % + +" Stop search highlight with Esc in normal mode (until next search) +nnoremap :noh + " Enable/Disable auto comment map c :setlocal formatoptions-=cro map C :setlocal formatoptions=cro -" Tab navigation -nnoremap gt -nnoremap gT -nnoremap :tabnew -nnoremap :tabmove + -nnoremap :tabmove - -nnoremap :tabp -nnoremap :tabn - -" Remap splits navigation to just CTRL + hjkl -nnoremap h -nnoremap j -nnoremap k -nnoremap l - -" Make adjusting split sizes a bit more friendly -noremap :vertical resize +3 -noremap :vertical resize -3 -noremap :resize +3 -noremap :resize -3 - -" Alias replace all -nnoremap :%s//gI - -" Save file as sudo when no write permissions -cmap w!! w !sudo tee > /dev/null % - " Don't leave visual mode after indenting vmap < >gv From c75c6fbd87f4094fd670f2237d0684cc32565676 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 28 Nov 2021 19:52:25 +0100 Subject: [PATCH 078/188] Remove python config source comment --- home/.config/nvim/rc/plugins.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/home/.config/nvim/rc/plugins.vim b/home/.config/nvim/rc/plugins.vim index a019397..fc1499f 100644 --- a/home/.config/nvim/rc/plugins.vim +++ b/home/.config/nvim/rc/plugins.vim @@ -40,4 +40,3 @@ execute "source ".plugins_rc_dir."/airline.vim" execute "source ".plugins_rc_dir."/nerdtree.vim" execute "source ".plugins_rc_dir."/vimwiki.vim" execute "source ".plugins_rc_dir."/coc.vim" -"execute "source ".plugins_rc_dir."/python.vim" From f0385c4961a9ba41cb67201b9d18d3f6681c95d0 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 30 Nov 2021 10:22:20 +0100 Subject: [PATCH 079/188] Indent with spaces, not tabs --- home/.config/git/config | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/home/.config/git/config b/home/.config/git/config index 2400e83..1b8e87a 100644 --- a/home/.config/git/config +++ b/home/.config/git/config @@ -1,25 +1,25 @@ # This is Git's per-user configuration file. [user] - name = ItsDrike - email = itsdrike@protonmail.com - signingkey = FB8CA11A2CF3A843 + name = ItsDrike + email = itsdrike@protonmail.com + signingkey = FB8CA11A2CF3A843 [credential] - helper = store --file ~/.config/git/git-credentials + helper = store --file ~/.config/git/git-credentials [alias] - l = "log --oneline --decorate --all --graph" - lol = "log --pretty=oneline --abbrev-commit --graph" - lg = "log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --" + l = "log --oneline --decorate --all --graph" + lol = "log --pretty=oneline --abbrev-commit --graph" + lg = "log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --" find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'" show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'" [merge] - tool = meld + tool = meld [mergetool] - keepbackup = false - keeptemporaries = false + keepbackup = false + keeptemporaries = false [diff] - tool = meld + tool = meld [commit] - gpgsign = true + gpgsign = true [gpg] - program = /usr/bin/gpg + program = /usr/bin/gpg From bb7a2af9f9368081726bdf4303086a5d65d82975 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 30 Nov 2021 20:22:51 +0100 Subject: [PATCH 080/188] Switch vim config to lua (Full rewrite) --- home/.config/nvim/init.lua | 7 ++ home/.config/nvim/init.vim | 14 --- home/.config/nvim/lua/abbreviations.lua | 45 +++++++ home/.config/nvim/lua/autocmd.lua | 21 ++++ home/.config/nvim/lua/base.lua | 44 +++++++ home/.config/nvim/lua/mappings.lua | 112 ++++++++++++++++++ home/.config/nvim/lua/plugins.d/airline.lua | 42 +++++++ .../nvim/{rc => lua}/plugins.d/coc.vim | 17 ++- .../.config/nvim/lua/plugins.d/commentary.lua | 9 ++ home/.config/nvim/lua/plugins.d/fzf.vim | 22 ++++ home/.config/nvim/lua/plugins.d/nerdtree.lua | 65 ++++++++++ .../nvim/lua/plugins.d/vim-code-dark.lua | 12 ++ home/.config/nvim/lua/plugins.d/vimwiki.lua | 14 +++ home/.config/nvim/lua/plugins.lua | 56 +++++++++ home/.config/nvim/lua/theme.lua | 27 +++++ home/.config/nvim/lua/vim.lua | 7 ++ home/.config/nvim/rc/abbreviations.vim | 11 -- home/.config/nvim/rc/autocmd.vim | 17 --- home/.config/nvim/rc/base.vim | 35 ------ home/.config/nvim/rc/mappings.vim | 84 ------------- home/.config/nvim/rc/plugins.d/airline.vim | 24 ---- home/.config/nvim/rc/plugins.d/nerdtree.vim | 39 ------ home/.config/nvim/rc/plugins.d/vimwiki.vim | 8 -- home/.config/nvim/rc/plugins.vim | 42 ------- home/.config/nvim/rc/theme.vim | 26 ---- 25 files changed, 497 insertions(+), 303 deletions(-) create mode 100644 home/.config/nvim/init.lua delete mode 100644 home/.config/nvim/init.vim create mode 100644 home/.config/nvim/lua/abbreviations.lua create mode 100644 home/.config/nvim/lua/autocmd.lua create mode 100644 home/.config/nvim/lua/base.lua create mode 100644 home/.config/nvim/lua/mappings.lua create mode 100644 home/.config/nvim/lua/plugins.d/airline.lua rename home/.config/nvim/{rc => lua}/plugins.d/coc.vim (82%) create mode 100644 home/.config/nvim/lua/plugins.d/commentary.lua create mode 100644 home/.config/nvim/lua/plugins.d/fzf.vim create mode 100644 home/.config/nvim/lua/plugins.d/nerdtree.lua create mode 100644 home/.config/nvim/lua/plugins.d/vim-code-dark.lua create mode 100644 home/.config/nvim/lua/plugins.d/vimwiki.lua create mode 100644 home/.config/nvim/lua/plugins.lua create mode 100644 home/.config/nvim/lua/theme.lua create mode 100644 home/.config/nvim/lua/vim.lua delete mode 100644 home/.config/nvim/rc/abbreviations.vim delete mode 100644 home/.config/nvim/rc/autocmd.vim delete mode 100644 home/.config/nvim/rc/base.vim delete mode 100644 home/.config/nvim/rc/mappings.vim delete mode 100644 home/.config/nvim/rc/plugins.d/airline.vim delete mode 100644 home/.config/nvim/rc/plugins.d/nerdtree.vim delete mode 100644 home/.config/nvim/rc/plugins.d/vimwiki.vim delete mode 100644 home/.config/nvim/rc/plugins.vim delete mode 100644 home/.config/nvim/rc/theme.vim diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua new file mode 100644 index 0000000..20ec5ab --- /dev/null +++ b/home/.config/nvim/init.lua @@ -0,0 +1,7 @@ +require "base" +require "theme" +require "mappings" +require "abbreviations" +require "autocmd" +require "plugins" + diff --git a/home/.config/nvim/init.vim b/home/.config/nvim/init.vim deleted file mode 100644 index a3eb04a..0000000 --- a/home/.config/nvim/init.vim +++ /dev/null @@ -1,14 +0,0 @@ -" Let init.vim handle sourcing other more specific -" vim configuration files, rather than keeping everything -" in a single huge config file - -let config_dir = system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim"') -let rc_dir = config_dir.'/rc' -execute 'source '.rc_dir.'/base.vim' -execute 'source '.rc_dir.'/mappings.vim' -execute 'source '.rc_dir.'/abbreviations.vim' -execute 'source '.rc_dir.'/autocmd.vim' -execute 'source '.rc_dir.'/plugins.vim' -" Needs to be below plugins for colorscheme -execute 'source '.rc_dir.'/theme.vim' - diff --git a/home/.config/nvim/lua/abbreviations.lua b/home/.config/nvim/lua/abbreviations.lua new file mode 100644 index 0000000..2438046 --- /dev/null +++ b/home/.config/nvim/lua/abbreviations.lua @@ -0,0 +1,45 @@ +local vim = require("vim") +local cmd = vim.cmd + +-- I'm not aware of abbreviations having direct lua support like mappings, +-- though I'm not certain on that and may be completely wrong, if there is +-- a better way, this is opened to pull requests. +-- TODO: Check direct abbrev lua support + +-- Make these function definitions global as they could be reused +-- in plugin specific scripts or in other places. +function abbrev(mode, input, result, reabbrev) + -- Assume noreabbrev unless specified otherwise + reabbrev = reabbrev or false + local command + if reabbrev then + command = mode .. "abbrev" + else + command = mode .. "noreabbrev" + end + cmd(command .. " " .. input .. " " .. result) +end + +function cabbrev(input, result, reabbrev) + abbrev("c", input, result, reabbrev) +end + +-- Invalid case abbreviations +cabbrev("Wq", "wq") +cabbrev("wQ", "wq") +cabbrev("WQ", "wq") +cabbrev("Wa", "wa") +cabbrev("W", "w") +cabbrev("Q", "q") +cabbrev("Qall", "qall") +cabbrev("W!", "w!") +cabbrev("Q!", "q!") +cabbrev("Qall!", "qall!") + +-- Save file with sudo +cabbrev("w!!", "w !sudo tee > /dev/null %") + +-- Reload lua configuration +-- TODO: Get the path dynamically +cabbrev("reload", "luafile ~/.config/nvim/init.lua") + diff --git a/home/.config/nvim/lua/autocmd.lua b/home/.config/nvim/lua/autocmd.lua new file mode 100644 index 0000000..f98eefb --- /dev/null +++ b/home/.config/nvim/lua/autocmd.lua @@ -0,0 +1,21 @@ +local vim = require("vim") +local cmd = vim.cmd + +-- Disable automatic commenting on newlines +cmd[[autocmd FileType * setlocal formatoptions-=cro]] + +-- Have vim jump to last position when reopening a file +cmd[[autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif]] + +-- Automatically delete all trailing whitespace on save +cmd[[autocmd BufWritePre * %s/\s\+$//e]] + +-- Enable spellcheck for certain file types +cmd[[autocmd FileType tex,latex,markdown,gitcommit setlocal spell spelllang=en_us]] + +-- Use auto-wrap for certain file types at 119 chars +cmd[[autocmd FileType markdown setlocal textwidth=119]] + +-- Don't show line numbers in terminal +cmd[[autocmd BufEnter term://* setlocal nonumber | setlocal norelativenumber]] + diff --git a/home/.config/nvim/lua/base.lua b/home/.config/nvim/lua/base.lua new file mode 100644 index 0000000..5b831c7 --- /dev/null +++ b/home/.config/nvim/lua/base.lua @@ -0,0 +1,44 @@ +local vim = require("vim") +local cmd = vim.cmd +local o = vim.opt + +cmd[[filetype plugin on]] + +-- Tab settings +o.expandtab = true -- Expand tabs to spaces +o.tabstop = 4 -- Tab size +o.shiftwidth = 4 -- Indentation size +o.softtabstop = 4 -- Tabs/Spaces interlop +o.tabpagemax = 50 -- More tabs + +-- Folding +o.foldmethod = "indent" -- Use indent to determine the fold levels +o.foldnestmax = 8 -- Only fold up to given amount of levels +o.foldlevel = 2 -- Set initial fold level +o.foldenable = false -- Hide all folds by default + +-- Split order +o.splitbelow = true -- Put new windows below current +o.splitright = true -- Put new vertical splits to right + +-- In-file search (/) +o.ignorecase = true -- Use case insensitive matching +o.incsearch = true -- Show partial matches for search phrase +o.hlsearch = true -- Highlight search matches + +-- Show trailing whitespace +o.list = true -- Enable showing characters like , , ... +o.listchars = "trail:·" -- Only show trailing whitespaces + +-- Command-mode search +o.wildmode = {"longest", "list", "full"} -- Enable autocompletion +o.wildmenu = true -- Display all matching files when we tab complete +table.insert(o.path, "**") -- Search down into subfolders with tab completion + +-- Misc +o.mouse = "a" -- Enable mouse mode +o.encoding = "utf-8" -- Use UTF-8 encoding +o.autoindent = true -- Enable autoindent +o.autoread = true -- Automatically reload files on change +o.undolevels = 999 -- Lots of these +o.history = 1000 -- More history diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua new file mode 100644 index 0000000..346e91a --- /dev/null +++ b/home/.config/nvim/lua/mappings.lua @@ -0,0 +1,112 @@ +local vim = require("vim") + +-- Make these function definitions global as they could be reused +-- in plugin specific scripts or in other places. +function keymap(mode, shortcut, command, options) + -- Assume silent, noremap unless specified otherwise + local opts = {noremap=true, silent=true} + if options then opts = vim.tbl_extend("force", opts, options) end + -- Perform the actual remap + vim.api.nvim_set_keymap(mode, shortcut, command, opts) +end + +-- This is a bit silly, but I don't like passing the mode argument +-- to every keymap definition and this makes things a lot easier +-- and a bit more vimscript-like +function nmap(shortcut, command, options) + keymap("n", shortcut, command, options) +end + +function imap(shortcut, command, options) + keymap("i", shortcut, command, options) +end + +function vmap(shortcut, command, options) + keymap("v", shortcut, command, options) +end + +function tmap(shortcut, command, options) + keymap("t", shortcut, command, options) +end + +-- Unmap arrow keys in normal mode to remove bad habits +nmap("", "") +nmap("", "") +nmap("", "") +nmap("", "") + +-- Tab navigation +nmap("", "gt") +nmap("", "gT") +nmap("", ":tabnew") +nmap("", ":tabmove +") +nmap("", ":tabmove -") +nmap("", ":tabp") +nmap("", ":tabn") + +-- Set splits navigation to just ALT + hjkl +nmap("", "h") +nmap("", "j") +nmap("", "k") +nmap("", "l") + +-- Split size adjusting +nmap("", ":verical resize +3") +nmap("", ":vertical resize -3") +nmap("", ":resize +3") +nmap("", ":resize -3") + +-- Define some common shortcuts +nmap("", ":w") +nmap("", ":undo") +nmap("", ":redo") + +-- Terminal +nmap("", ":split term://zshi") +nmap("", ":vnew term://zshi") +nmap("", ":tabnew term://zshi") +tmap("", "") + +-- Use space for folding/unfolding sections +nmap("", "za") +vmap("", "zf") + +-- Use shift to quickly move 10 lines up/down +nmap("K", "10k") +nmap("J", "10j") + +-- Enable/Disable auto commenting +nmap("c", ":setlocal formatoptions-=cro") +nmap("C", ":setlocal formatoptions+=cro") + +-- Don't leave visual mode after indenting +vmap("<", "", ">gv") + +-- System clipboard copying +vmap("", '"+y') + +-- Alias replace all +nmap("", ":%s//gI", {silent=false}) + +-- Stop search highlight with Esc +nmap("", ":noh") + +-- Start spell-check +nmap("s", ":setlocal spell! spelllang=en_us") + +-- Run shell check +nmap("p", ":!shellckeck %") + +-- Compile opened file (using custom script) +nmap("", ":w | !comp %") + +-- Close all opened buffers +nmap("Q", ":bufdo bdelete") + +-- Don't set the incredibely annoying mappings that trigger dynamic SQL +-- completion with dbext and keeps on freezing vim whenever pressed with +-- a message saying that dbext plugin isn't installed +-- See :h ft-sql.txt +vim.g.omni_sql_no_default_maps = 1 + diff --git a/home/.config/nvim/lua/plugins.d/airline.lua b/home/.config/nvim/lua/plugins.d/airline.lua new file mode 100644 index 0000000..8c3ef46 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/airline.lua @@ -0,0 +1,42 @@ +local vim = require("vim") +local g = vim.g +local cmd = vim.cmd + +cmd[[ +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +]] + +-- Airline specific theming settings +g.airline_theme = 'codedark' -- Use codedark theme from vim-airline-themes +g.airline_right_sep = "" -- Don't use special separators (<) +g.airline_left_sep = "" -- Don't use special separators (>) + +-- Tabline setup +-- TODO: Figure out how to set # separated variables in lua (open for PRs) +cmd[[let g:airline#extensions#tabline#enabled = 1]] -- Enable tabline (top line) +cmd[[let g:airline#tabline#formatter = 'unique_tail']] -- Tabline filename formatter + +-- Special symbols +g.webdevicons_enable_airline_statusline = 0 -- Use special icons from vim-devicons (requires nerdfonts) +g.airline_powerline_fonts = 1 -- Use special symbols from poweline fonts (line no, col no) +if not os.getenv("DISPLAY") then -- Use ASCII-only if we're in TTY + g.airline_symbols_ascii = 1 +end + +-- Disable airline in nerdtree buffer +-- TODO; For some reason, this fails even though it works in regular vimscript +--[[ +cmd[[ +augroup filetype_nerdtree + au! + au FileType nerdtree call s:disable_airline_on_nerdtree() + au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree() +augroup END + +fu s:disable_airline_on_nerdtree() abort + let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1 + call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')}) +endfu +]] +--]] diff --git a/home/.config/nvim/rc/plugins.d/coc.vim b/home/.config/nvim/lua/plugins.d/coc.vim similarity index 82% rename from home/.config/nvim/rc/plugins.d/coc.vim rename to home/.config/nvim/lua/plugins.d/coc.vim index f9d4d00..752a957 100644 --- a/home/.config/nvim/rc/plugins.d/coc.vim +++ b/home/.config/nvim/lua/plugins.d/coc.vim @@ -1,7 +1,18 @@ +" Converting these settings into lua isn't easy since we utilize +" which needs to be in a vim script context, making it impossible +" to replicate with simple vim.cmd call. It also contains a lot of function +" definitions taken from the coc github page without provided lua alternatives +" this makes it quite complicated to replicate this in pure lua, +" however if anyone knows how to completely reproduce everything here in lua, +" this is open to pull requests + +Plug 'neoclide/coc.nvim', {'branch': 'release'} + let g:coc_global_extensions = [ - \ 'coc-python', 'coc-json', 'coc-git', 'coc-html', 'coc-css', + \ 'coc-pyright', 'coc-json', 'coc-git', 'coc-html', 'coc-css', \ 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml', - \ 'coc-yaml', 'coc-omnisharp', 'coc-markdownlint', 'coc-pairs' + \ 'coc-yaml', 'coc-omnisharp', 'coc-markdownlint', 'coc-pairs', + \ 'coc-lua' \ ] " Use tab for trigger completion with characters ahead and navigate. @@ -46,7 +57,7 @@ function! s:show_documentation() endfunction " Remap for rename current word -nmap (coc-rename) +nmap rn (coc-rename) " Remap for format selected region xmap f (coc-format-selected) diff --git a/home/.config/nvim/lua/plugins.d/commentary.lua b/home/.config/nvim/lua/plugins.d/commentary.lua new file mode 100644 index 0000000..e20acac --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/commentary.lua @@ -0,0 +1,9 @@ +local vim = require("vim") +local cmd = vim.cmd + +cmd[[Plug 'tpope/vim-commentary']] + +nmap("", ":Commentary") +vmap("", ":Commentary") + +cmd[[autocmd FileType apache setlocal commentstring=#\ %s]] diff --git a/home/.config/nvim/lua/plugins.d/fzf.vim b/home/.config/nvim/lua/plugins.d/fzf.vim new file mode 100644 index 0000000..575e211 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/fzf.vim @@ -0,0 +1,22 @@ +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' +Plug 'stsewd/fzf-checkout.vim' + +let g:fzf_layout = { 'up': '~90%', 'window': { 'width': 0.8, 'height': 0.8, 'yoffset':0.5, 'xoffset': 0.5 } } +let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline' + +" Customise the Files command to use ripgrep which respects .gitignore files +command! -bang -nargs=? -complete=dir Files + \ call fzf#run(fzf#wrap('files', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden' }), 0)) + +" Add an AllFiles variation that shows ignored files too +command! -bang -nargs=? -complete=dir AllFiles + \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore' }), 0)) + +nmap f :Files +nmap F :AllFiles +nmap b :Buffers +nmap h :History +nmap r :Rg +nmap R :Rg +nmap gb :GBranches diff --git a/home/.config/nvim/lua/plugins.d/nerdtree.lua b/home/.config/nvim/lua/plugins.d/nerdtree.lua new file mode 100644 index 0000000..bc83d36 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/nerdtree.lua @@ -0,0 +1,65 @@ +local vim = require("vim") +local g = vim.g +local fn = vim.fn +local cmd = vim.cmd + +cmd[[ +Plug 'preservim/nerdtree' +Plug 'Xuyuanp/nerdtree-git-plugin' +Plug 'tiagofumo/vim-nerdtree-syntax-highlight' +]] + +-- Implement manual NERDTreeToggle, but use NERDTreeFind for openning. +-- This makes NERDTree open with the current file pre-selected +nmap("", "g:NERDTree.IsOpen() ? ':NERDTreeClose' : @% == '' ? ':NERDTree' : ':NERDTreeFind'", {expr=true}) + +g.NERDTreeShowHidden = 1 +g.NERDTreeMinimalUI = 1 +g.NERDTreeShowLineNumbers = 0 +g.NERDTreeWinSize = 25 + +g.NERDTreeDirArrowExpandable = '►' +g.NERDTreeDirArrowCollapsible = '▼' + +-- Disable devicons for nerdtree in TTY +if not os.getenv("DISPLAY") then + g.webdevicons_enable_nerdtree = 0 +else + g.DevIconsEnableFoldersOpenClose = 1 +end + +-- If a directory is specified, start NERDTree +cmd[[ +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | + \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | + \ endif +]] + +-- Exit Vim if NERDTree is the only window left. +cmd[[ +autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | + \ quit | endif +]] + +-- If another buffer tries to replace NerdTree, put it in another window, and bring back NerdTree. +cmd[[ +autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | + \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif +]] + +-- Use $NERDTREE_BOOKMARKS environment variable for the location of .NERDTreeBookmarks file +local bookmark_loc = os.getenv("NERDTREE_BOOKMARKS") +if bookmark_loc then + -- Check if file exists (lua doesn't have a built-in function for this) + local file_exists = os.rename(bookmark_loc, bookmark_loc) and true or false + + if not file_exists then + -- While this is possible with os.execute in lua, we would need to do some hacky + -- things to capture output from os.execute and it's simpler to just use vimscript + local dir = fn.system("dirname $NERDTREE_BOOKMARKS") + fn.system({"mkdir", "-p", dir}) + fn.system("touch $NERDTREE_BOOKMARKS") + end + g.NERDTreeBookmarksFile = bookmark_loc +end diff --git a/home/.config/nvim/lua/plugins.d/vim-code-dark.lua b/home/.config/nvim/lua/plugins.d/vim-code-dark.lua new file mode 100644 index 0000000..de7fc35 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/vim-code-dark.lua @@ -0,0 +1,12 @@ +local vim = require("vim") +local cmd = vim.cmd + +cmd[[Plug 'tomasiser/vim-code-dark']] + +-- Set vim-code-dark as colortheme after plugin loading was finished +cmd[[ +augroup VimCodeDark + autocmd! + autocmd User PlugLoaded ++nested colorscheme codedark +augroup end +]] diff --git a/home/.config/nvim/lua/plugins.d/vimwiki.lua b/home/.config/nvim/lua/plugins.d/vimwiki.lua new file mode 100644 index 0000000..8f266e5 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/vimwiki.lua @@ -0,0 +1,14 @@ +local vim = require("vim") +local cmd = vim.cmd +local g = vim.g + +cmd[[Plug 'vimwiki/vimwiki']] + +local wiki_conf = {} +wiki_conf["path"] = "~/Personal/vimwiki" +wiki_conf["path_html"] = "~/Personal/vimwiki-html" +wiki_conf["html_template"] = "~/Personal/vimwiki-html/template.tpl" +wiki_conf["syntax"] = "markdown" +wiki_conf["ext"] = ".md" +g.vimwiki_list = {wiki_conf} + diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..79ff1e7 --- /dev/null +++ b/home/.config/nvim/lua/plugins.lua @@ -0,0 +1,56 @@ +local vim = require("vim") +local cmd = vim.cmd +local fn = vim.fn + +local config_dir = fn.stdpath("config") -- Config directory (usually: ~/.config/nvim) +local plugvim_plugins_dir = config_dir .. "/plugged" -- Dir with all plugins installed by Plug.vim +local plugin_files_dir = config_dir .. "/lua/plugins.d" -- Dir with plugin config files including Plug call(s) + +-- Automatically download vimplug and run PlugInstall +local autoload_dir = config_dir .. "/autoload" +local plug_install_path = autoload_dir .. "/plug.vim" +local plug_download_url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" + +if fn.empty(fn.glob(plug_install_path)) > 0 then + print("Downloading vim-plug, there may be initial errors...") + fn.system({"mkdir", "-p", autoload_dir}) + fn.system("curl " .. plug_download_url .. " > " .. plug_install_path) + cmd[[autocmd VimEnter * PlugInstall]] +end + +-- Load a .vim or .lua file containing Plug call(s) and plugin settings +local function load_plugin_file(plugin_file) + local extension = plugin_file:match("^.+(%..+)$") + local plugin_path = plugin_files_dir .. "/" .. plugin_file + local run_cmd + if (extension == ".vim") then run_cmd = "source" else run_cmd = "luafile" end + fn.execute(run_cmd .. " " .. plugin_path) +end + +-- Load a single given plugin using a Plug call +local function load_plugin(plugin) + cmd("Plug '" .. plugin .. "'") +end + +-- Begin Plug.vim loading process +cmd("call plug#begin('" .. plugvim_plugins_dir .. "')") + +load_plugin('airblade/vim-gitgutter') +load_plugin('dhruvasagar/vim-table-mode') +load_plugin('tmhedberg/SimpylFold') +load_plugin('wakatime/vim-wakatime') +load_plugin('mhinz/vim-startify') +load_plugin('ryanoasis/vim-devicons') +load_plugin_file("vim-code-dark.lua") +load_plugin_file("commentary.lua") +load_plugin_file("coc.vim") +load_plugin_file("vimwiki.lua") +load_plugin_file("nerdtree.lua") +load_plugin_file("airline.lua") +load_plugin_file("fzf.vim") + +-- End Plug.vim loading process +cmd[[call plug#end()]] + +-- Run autocmds defined in the plugin files after plugin loading has finished +cmd[[doautocmd User PlugLoaded]] diff --git a/home/.config/nvim/lua/theme.lua b/home/.config/nvim/lua/theme.lua new file mode 100644 index 0000000..7cfa568 --- /dev/null +++ b/home/.config/nvim/lua/theme.lua @@ -0,0 +1,27 @@ +local vim = require("vim") +local cmd = vim.cmd +local o = vim.opt + +cmd[[syntax on]] -- Turn on syntax highlighting + +o.cursorline = true -- Highlight cursor line +o.laststatus = 2 -- Always show status line +o.number = true -- Show line numbers +o.relativenumber = true -- Use relative line numbers +o.showmatch = true -- Show matching bracket +o.scrolloff = 5 -- Keep 5 lines horizontal scrolloff +o.sidescrolloff = 5 -- Keep 5 chars vertical scrolloff + +-- I wasn't able to find a way to set guioptions directly in lua +cmd[[ +set guioptions-=m " Remove menubar +set guioptions-=T " Remove toolbar +set guioptions-=r " Remove right-hand scrollbar +set guioptions-=L " Remove left-hand scrollbar +]] + +-- Use more noticable cursor line color +cmd[[highlight CursorLine guibg=#2b2b2b]] + +-- Don't use true colors in TTY +o.termguicolors = os.getenv("DISPLAY") and true or false diff --git a/home/.config/nvim/lua/vim.lua b/home/.config/nvim/lua/vim.lua new file mode 100644 index 0000000..2bfb110 --- /dev/null +++ b/home/.config/nvim/lua/vim.lua @@ -0,0 +1,7 @@ +-- This file is here to allow running `local vim = require("vim")`, which +-- avoids the hassle of having to ignore vim as undefined-global for lua +-- language server diagnostics. Another advantage is that it actually allows +-- us to detect the attributes of vim so we will get suggestions. + +---@diagnostic disable-next-line:undefined-global +return vim diff --git a/home/.config/nvim/rc/abbreviations.vim b/home/.config/nvim/rc/abbreviations.vim deleted file mode 100644 index 69019a6..0000000 --- a/home/.config/nvim/rc/abbreviations.vim +++ /dev/null @@ -1,11 +0,0 @@ -cnoreabbrev Wq wq -cnoreabbrev wQ wq -cnoreabbrev WQ wq -cnoreabbrev Wa wa -cnoreabbrev W w -cnoreabbrev Q q -cnoreabbrev Qall qall -cnoreabbrev W! w! -cnoreabbrev Q! q! -cnoreabbrev Qall! qall! - diff --git a/home/.config/nvim/rc/autocmd.vim b/home/.config/nvim/rc/autocmd.vim deleted file mode 100644 index a7902d3..0000000 --- a/home/.config/nvim/rc/autocmd.vim +++ /dev/null @@ -1,17 +0,0 @@ -" Move ~/.viminfo to XDG_CACHE_HOME -"set viminfofile=$XDG_CACHE_HOME/vim/viminfo - -" Disable automatic commenting on newline -autocmd FileType * setlocal formatoptions-=cro - -" Have Vim jump to the last position when reopening a file -autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif - -" Automatically deletes all trailing whitespace on save -autocmd BufWritePre * %s/\s\+$//e - -" Enable spellcheck for certain file types -autocmd FileType tex,latex,markdown,gitcommit setlocal spell spelllang=en_us - -" Use automatic text wrapping at 119 characters for certain file types -autocmd FileType markdown setlocal textwidth=119 diff --git a/home/.config/nvim/rc/base.vim b/home/.config/nvim/rc/base.vim deleted file mode 100644 index 799789e..0000000 --- a/home/.config/nvim/rc/base.vim +++ /dev/null @@ -1,35 +0,0 @@ -filetype plugin on " Enable filetype detection - -" Tab settings -set expandtab " Expand tabs to spaces -set tabstop=4 " Tab size -set shiftwidth=4 " Indentation size -set softtabstop=4 " Tabs/Spaces interrop -set tabpagemax=50 " More tabs - -" In-file Search (/) -set ignorecase " Do case insensitive matching -set incsearch " Show partial matches for a search phrase -set hlsearch " Highlight Search - -" Command-mode search -set path+=** " Search down into subfolders with tab completion -set wildmode=longest,list,full " Enable autocompletion -set wildmenu " Display all matching files when we tab complete - -" Folding -set foldmethod=indent " Use indent to determine the fold levels -set foldnestmax=8 " Only fold up to given amount of levels -set foldlevel=2 " Set initial fold level -set nofoldenable " Hide all folds by default - - -" Misc -set autoindent " Enable autoindent -set autoread " Reload files on change -set undolevels=999 " Lots of these -set history=1000 " More history -set encoding=utf-8 " Use UTF-8 encoding -set mouse=a " Enable mouse mode -set splitbelow splitright " Split in more natural way - diff --git a/home/.config/nvim/rc/mappings.vim b/home/.config/nvim/rc/mappings.vim deleted file mode 100644 index 65e1935..0000000 --- a/home/.config/nvim/rc/mappings.vim +++ /dev/null @@ -1,84 +0,0 @@ -" Unmap arrow keys in normal mode to remove bad habits -nnoremap -nnoremap -nnoremap -nnoremap - -" Tab navigation -nnoremap gt -nnoremap gT -nnoremap :tabnew -nnoremap :tabmove + -nnoremap :tabmove - -nnoremap :tabp -nnoremap :tabn - -" Splits navigation to just ALT + hjkl -nnoremap h -nnoremap j -nnoremap k -nnoremap l - -" Make adjusting split sizes a bit more friendly -noremap :vertical resize +3 -noremap :vertical resize -3 -noremap :resize +3 -noremap :resize -3 - -" System clipboard interactions -map "+y -vnoremap "+p - -" Use more common Undo/Redo shortcuts -nnoremap :undo -nnoremap :redo - -" Use more common save shortcut -nnoremap :w - -" Terminal -nnoremap :vnew term://zshi -nnoremap :split term://zshi -nnoremap :tabnew term://zshi - -" Alias replace all -nnoremap :%s//gI - -" Start spell-check -map s :setlocal spell! spelllang=en_us - -" Use space for folding/unfolding sections -nnoremap za -vnoremap zf - -" Use shift to move 10 lines up/down quickly -noremap K 10k -noremap J 10j - -" Save file as sudo when no write permissions -cmap w!! w !sudo tee > /dev/null % - -" Stop search highlight with Esc in normal mode (until next search) -nnoremap :noh - -" Enable/Disable auto comment -map c :setlocal formatoptions-=cro -map C :setlocal formatoptions=cro - -" Don't leave visual mode after indenting -vmap < >gv - -" Compile opened file (using custom comp script) -nnoremap :w \| !comp % - -" Shell check -nnoremap p :!shellcheck % - -" Redefine the incredibely annoying mappings that trigger -" dynamic SQL completion with dbext and keeps on freezing -" vim whenever pressed with a message saying that -" dbext plugin isn't installed... -" See :h ft-sql.txt -let g:omni_sql_no_default_maps = 1 - diff --git a/home/.config/nvim/rc/plugins.d/airline.vim b/home/.config/nvim/rc/plugins.d/airline.vim deleted file mode 100644 index 47c7c88..0000000 --- a/home/.config/nvim/rc/plugins.d/airline.vim +++ /dev/null @@ -1,24 +0,0 @@ -" Airline specific theming settings -let g:airline_theme='codedark' " Use codedark theme from vim-ariline-themes -let g:airline_right_sep = "" " Don't use special separators (<) -let g:airline_left_sep = "" " Don't use special separators (>) -let g:airline#extensions#tabline#enabled = 1 " Enable tabline (top line) -let g:airline#tabline#formatter = 'unique_tail' " Tabline filename formatter -let g:webdevicons_enable_airline_statusline = 0 " Use special icons from vim-devicons (requires nerdfonts) -let g:airline_powerline_fonts = 1 " Use special symbols from powerline fonts (line no, col no) - -if empty($DISPLAY) " Use ASCII-only if we're in TTY - let g:airline_symbols_ascii = 1 -endif - -" Disable airline in nerdtree buffer -"augroup filetype_nerdtree -" au! -" au FileType nerdtree call s:disable_airline_on_nerdtree() -" au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree() -"augroup END -" -"fu s:disable_airline_on_nerdtree() abort -" let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1 -" call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')}) -"endfu diff --git a/home/.config/nvim/rc/plugins.d/nerdtree.vim b/home/.config/nvim/rc/plugins.d/nerdtree.vim deleted file mode 100644 index 910a9c0..0000000 --- a/home/.config/nvim/rc/plugins.d/nerdtree.vim +++ /dev/null @@ -1,39 +0,0 @@ -" NERDTree config -map :NERDTreeToggle -let g:NERDTreeDirArrowExpandable = '►' -let g:NERDTreeDirArrowCollapsible = '▼' -let NERDTreeShowLineNumbers=1 -let NERDTreeShowHidden=1 -let NERDTreeMinimalUI = 1 -let g:NERDTreeWinSize=25 -if empty($DISPLAY) " Disable devicons for nerdtree in TTY - let g:webdevicons_enable_nerdtree = 0 -endif - -" If a directory is specified, start NERDTree and move the cursor to its window. -autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | - \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | - \ endif - -" If a file is specified, start NERDTree and keep the cursor in file window. -"autocmd VimEnter * if argc() > 0 && !isdirectory(argv()[0]) || exists("s:std_in") | -" \ execute 'NERDTree' fnamemodify(argv()[0], ':p:h') | wincmd p | endif - -" Exit Vim if NERDTree is the only window left. -autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | - \ quit | endif - -" If another buffer tries to replace NerdTree, put it in another window, and bring back NerdTree. -autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | - \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif - -" Use $NERDTREE_BOOKMARKS environment variable for the location of .NERDTreeBookmarks file -if ! empty($NERDTREE_BOOKMARKS) - if ! filereadable($NERDTREE_BOOKMARKS) - let dir = system('dirname $NERDTREE_BOOKMARKS') - let x = system('mkdir -p ' . dir) - let x = system('touch $NERDTREE_BOOKMARKS') - endif - let g:NERDTreeBookmarksFile = $NERDTREE_BOOKMARKS -endif diff --git a/home/.config/nvim/rc/plugins.d/vimwiki.vim b/home/.config/nvim/rc/plugins.d/vimwiki.vim deleted file mode 100644 index 2bc51a1..0000000 --- a/home/.config/nvim/rc/plugins.d/vimwiki.vim +++ /dev/null @@ -1,8 +0,0 @@ -let wiki_conf = {} -let wiki_conf.path = '~/Personal/vimwiki' -let wiki_conf.path_html = '~/Personal/vimwiki-html' -let wiki_conf.html_template = '~/Personal/vimwiki-html/template.tpl' -let wiki_conf.syntax = 'markdown' -let wiki_conf.ext = '.md' - -let g:vimwiki_list = [wiki_conf] diff --git a/home/.config/nvim/rc/plugins.vim b/home/.config/nvim/rc/plugins.vim deleted file mode 100644 index fc1499f..0000000 --- a/home/.config/nvim/rc/plugins.vim +++ /dev/null @@ -1,42 +0,0 @@ -" This file handles plugin management with plug.vim -" It contains an automatic first-time installer for plug.vim and plugins -" It also sources plugin specific config files - -" Install plugins automatically -if ! filereadable(config_dir."/autoload/plug.vim") - echo "Downloading junegunn/vim-plug to manage plugins..." - let x = system('mkdir -p '.config_dir.'/autoload') - let x = system('curl https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim > '.config_dir.'/autoload/plug.vim') - autocmd VimEnter * PlugInstall -endif - -" Plug.vim plugin list -call plug#begin(config_dir."/plugged") - -" Code helpers -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'airblade/vim-gitgutter' -Plug 'dhruvasagar/vim-table-mode' -Plug 'preservim/nerdcommenter' -Plug 'tmhedberg/SimpylFold' -" Themes -Plug 'tomasiser/vim-code-dark' -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -Plug 'ryanoasis/vim-devicons' -Plug 'tiagofumo/vim-nerdtree-syntax-highlight' -" Misc -Plug 'vimwiki/vimwiki' -Plug 'wakatime/vim-wakatime' -Plug 'preservim/nerdtree' -Plug 'mhinz/vim-startify' - -call plug#end() - - -" Source more plugin-specific configuration files from here -let plugins_rc_dir = rc_dir."/plugins.d" -execute "source ".plugins_rc_dir."/airline.vim" -execute "source ".plugins_rc_dir."/nerdtree.vim" -execute "source ".plugins_rc_dir."/vimwiki.vim" -execute "source ".plugins_rc_dir."/coc.vim" diff --git a/home/.config/nvim/rc/theme.vim b/home/.config/nvim/rc/theme.vim deleted file mode 100644 index be6fcbf..0000000 --- a/home/.config/nvim/rc/theme.vim +++ /dev/null @@ -1,26 +0,0 @@ -" General colorscheme settings -syntax on " Turn syntax highlighting on -colorscheme codedark " Requires vim-code-dark plugin - -set cursorline " Highlight cursor line -set laststatus=2 " Always show status line -set number relativenumber " Show relative line numbers -set showmatch " Show matching brackets -set scrolloff=5 " Keep 5 lines horizonal scrolloff -set sidescrolloff=5 " Keep 5 characters vertical scrolloff - -set guioptions-=m " Remove menubar -set guioptions-=T " Remove toolbar -set guioptions-=r " Remove right-hand scrollbar -set guioptions-=L " Remove left-hand scrollbar - -" Use more noticable cursor line color -highlight CursorLine guibg=#2b2b2b - -" Don't use true colors in TTY -if empty($DISPLAY) - set notermguicolors -else - set termguicolors -endif - From b267b97c45e67a5cc8954022e93605e70c6d9059 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 1 Dec 2021 19:58:56 +0100 Subject: [PATCH 081/188] Add more git aliases --- home/.config/git/config | 71 +++++++++++++++++++++++++++++++------- home/.config/shell/aliases | 30 +++++++--------- 2 files changed, 72 insertions(+), 29 deletions(-) diff --git a/home/.config/git/config b/home/.config/git/config index 1b8e87a..9176abb 100644 --- a/home/.config/git/config +++ b/home/.config/git/config @@ -1,25 +1,72 @@ -# This is Git's per-user configuration file. [user] name = ItsDrike email = itsdrike@protonmail.com signingkey = FB8CA11A2CF3A843 -[credential] - helper = store --file ~/.config/git/git-credentials [alias] + m = "merge" + p = "push" + pl = "pull" + f = "fetch" + + s = "status --short --branch" + ss = "status" + + ch = "checkout" + chb = "checkout -b" + + undo = "reset --soft HEAD~" + redo = "reset HEAD@{1}" + unstage = "restore --staged" + + c = "commit" + ca = "commit --ammend" + ci = "commit --interactive" + cm = "commit --message" + cv = "commit --verbose" + + a = "add" + aa = "add --all" + ap = "add --patch" + au = "add --update" + + d = "diff" + dc = "diff --cached" + ds = "diff --staged" + dw = "diff --word-diff" + + b = "branch" + ba = "branch --all" + bd = "branch --delete" + bD = "branch --delete --force" + bm = "branch --move" + bM = "branch --move --force" + l = "log --oneline --decorate --all --graph" - lol = "log --pretty=oneline --abbrev-commit --graph" + lp = "log --patch" + lo = "log --pretty=oneline --abbrev-commit --graph" lg = "log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --" + + set-upstream = "!git branch --set-upstream-to=origin`git symbolic-ref --short HEAD`" + find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'" show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'" - +[credential] + helper = store --file ~/.config/git/git-credentials +[core] + excludefile = ~/.config/git/global_gitignore + editor = vim + pager = delta +[interactive] + diffFilter = delta --color-only +[delta] + line-numbers = true [merge] - tool = meld -[mergetool] - keepbackup = false - keeptemporaries = false + conflictstyle = diff3 [diff] - tool = meld + tool = vimdiff +[fetch] + prune = true [commit] gpgsign = true -[gpg] - program = /usr/bin/gpg +[init] + defaultBranch = main diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 8e49ca7..ea7574a 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -195,26 +195,22 @@ alias cleanup='clean-trash && clean-down && clean-journal && clean-pacman' # Git aliases alias g='git' -alias gs='git status' +alias gp='git push' +alias gpl='git pull' +alias gf='git fetch' +alias gs='git status --short --branch' +alias gss='git status' +alias ga='git add' +alias gap='git add --patch' +alias gc='git commit' +alias gcm='git commit --message' +alias gb='git branch' +alias gch='git checkout' +alias gchb='git checkout --branch' alias gd='git diff' alias gdc='git diff --cached' -alias gm='git merge' -alias ga='git add' -alias gaa='git add all' -alias gc='git commit' -alias gcm='git commit -m' && alias commit='git commit -m' -alias gp='git push' && alias push='git push' -alias gpl='git pull' && alias pull='git pull' -alias gf='git fetch' && alias fetch='git fetch' -alias gb='git branch' && alias branch='git branch' -alias gch='git checkout' && alias checkout='git checkout' -alias gau='git add -u' && alias addup='git add -u' -alias gchb='git checkout -b' -alias gcda='git diff --cached' # Diff any files staged for commit -alias glog='git log --oneline --decorate --graph' -alias gundo='git reset HEAD~' +alias gundo='git reset --soft HEAD~' alias gredo="git reset 'HEAD@{1}'" -alias gundopush="git push -f origin HEAD^:master" # Youtube-dl aliases alias ytv-best='youtube-dl -f bestvideo+bestaudio' From 0c8ef04e62ea8e60b3e9ce1e6481dd65795bc4a5 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 1 Dec 2021 20:03:27 +0100 Subject: [PATCH 082/188] Add git-delta package, reorder --- packages.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages.yaml b/packages.yaml index 3c66431..c938966 100644 --- a/packages.yaml +++ b/packages.yaml @@ -95,7 +95,6 @@ pacman: - krita # Image editor (gimp alternative) - discord # Popular chat app - network-manager-applet # NetworkManager trayer icon - #- code # Open sourced version of vscode (doesn't support many extensions) # Device mounting - udisks2 # Allows users to mount devices without root @@ -121,6 +120,11 @@ pacman: - bluz-utils # CLI utility for managing bluetooth connections - blueman # Graphical utility for managing bluetooth connections - pulseaudio-bluetooth # Bluetooth speaker/headphone support for PulseAudio + + # Development + - git-delta # Neat tool for showing git diffs and resolving merges + #- code # Open sourced version of vscode (doesn't have good extensions support) + aur: # System - mkinitcpio-numlock # Enable numlock in initramfs (before asking for encryption key) @@ -144,17 +148,19 @@ aur: # GUI - spotify # Online music player - - visual-studio-code-bin # Official vVsual Studio Code text editor for programmers - exodus # Software cryptocurrency wallet - qalculate-gtk-nognome # Calculator with thousands of features, there's also less powerful kde default's kcalc #- mailspring-libre # Beautiful and fast mail client without tracking - #- code-marketplace # Enable the offical MS vscode marketplace for 'code' (code-oss) # Misc #- scrcpy # A way of seeing and controlling phone through a pc # Fonts - nerd-fonts-complete + + # Development + - visual-studio-code-bin # Official vVsual Studio Code text editor for programmers + #- code-marketplace # Enable the offical MS vscode marketplace for 'code' (code-oss) git: - https://aur.archlinux.org/yay-git.git # Pacman wrapper and AUR helper From f8540e0b707899d830090c86da6876ea7ff3b2fa Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 2 Dec 2021 17:31:04 +0100 Subject: [PATCH 083/188] Add quickclone git alias --- home/.config/git/config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/.config/git/config b/home/.config/git/config index 9176abb..cfd0ac3 100644 --- a/home/.config/git/config +++ b/home/.config/git/config @@ -3,6 +3,8 @@ email = itsdrike@protonmail.com signingkey = FB8CA11A2CF3A843 [alias] + quickclone = "clone --single-branch --depth=1" + m = "merge" p = "push" pl = "pull" From 69db7bb4d257a99185eb155c00d1660d8c912fab Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 00:37:09 +0100 Subject: [PATCH 084/188] Add unused semshi plugin config --- .../nvim/lua/plugins.d/deprecated/semshi.lua | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 home/.config/nvim/lua/plugins.d/deprecated/semshi.lua diff --git a/home/.config/nvim/lua/plugins.d/deprecated/semshi.lua b/home/.config/nvim/lua/plugins.d/deprecated/semshi.lua new file mode 100644 index 0000000..e37aea8 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/deprecated/semshi.lua @@ -0,0 +1,31 @@ +local vim = require("vim") +local cmd = vim.cmd +local fn = vim.fn + +-- Unused because the extension significantly slows down the opening time for vim. +-- Also, while the semantic highlighting in it is neat, for me, it isn't worth in. +-- +-- The extension default colorscheme makes the code look like unicorn vommit. +-- I'd prefer a simpler extension that only really distinguishes between classes, +-- functions and perhaps unused variables. I don't need to see a different color +-- when I access something as an attribute, but it would be neat to see what that +-- attribute actually holds, is it a class or a fucntion. But from my searching, +-- I wasn't able to find anything like this. This is open to pull requests. +cmd[[Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' }]] + +if (fn.has("python3")) then + fn.system({"pip", "install", "nvim", "--upgrade"}) +end + +cmd[[ +function MyCustomHighlights() + hi semshiParameter ctermfg=117 guifg=#93CCED + hi semshiParameterUnused ctermfg=117 guifg=#5e8193 cterm=underline gui=underline + hi semshiBuiltin ctermfg=29 guifg=#48bda5 + hi semshiAttribute ctermfg=254 guifg=#d1d1d1 + hi semshiImported ctermfg=214 guifg=#f8c466 cterm=bold gui=bold + hi semshiLocal ctermfg=209 guifg=#ff875f +endfunction + +autocmd FileType python call MyCustomHighlights() +]] From 16e9c61abdbdf1deb4ac96f265272ab9322b4dfb Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 14:40:29 +0100 Subject: [PATCH 085/188] Split load_plugin_file into 2 functions --- home/.config/nvim/lua/plugins.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 79ff1e7..aff900a 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -18,13 +18,18 @@ if fn.empty(fn.glob(plug_install_path)) > 0 then cmd[[autocmd VimEnter * PlugInstall]] end --- Load a .vim or .lua file containing Plug call(s) and plugin settings -local function load_plugin_file(plugin_file) - local extension = plugin_file:match("^.+(%..+)$") - local plugin_path = plugin_files_dir .. "/" .. plugin_file +-- Load an arbitrary .vim or .lua file +local function load_file(file_path) + local extension = file_path:match("^.+(%..+)$") local run_cmd if (extension == ".vim") then run_cmd = "source" else run_cmd = "luafile" end - fn.execute(run_cmd .. " " .. plugin_path) + fn.execute(run_cmd .. " " .. file_path) +end + +-- Load a file containing Plug call(s) and plugin settings +local function load_plugin_file(plugin_file) + local plugin_path = plugin_files_dir .. "/" .. plugin_file + load_file(plugin_path) end -- Load a single given plugin using a Plug call From cc7c8db10b656da6a8d3e90a8e8c9252c4d6e55f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 14:41:16 +0100 Subject: [PATCH 086/188] Run UpdateRemotePlugins after auto-installing plug --- home/.config/nvim/lua/plugins.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index aff900a..eec5f2a 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -16,6 +16,7 @@ if fn.empty(fn.glob(plug_install_path)) > 0 then fn.system({"mkdir", "-p", autoload_dir}) fn.system("curl " .. plug_download_url .. " > " .. plug_install_path) cmd[[autocmd VimEnter * PlugInstall]] + cmd[[autocmd VimEnter * UpdateRemotePlugins]] end -- Load an arbitrary .vim or .lua file From ac438d148096d6634e6f169c10730d5e21ad31a4 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 14:42:27 +0100 Subject: [PATCH 087/188] Add coc-fzf plugin --- home/.config/nvim/lua/plugins.d/coc.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/home/.config/nvim/lua/plugins.d/coc.vim b/home/.config/nvim/lua/plugins.d/coc.vim index 752a957..d8171ce 100644 --- a/home/.config/nvim/lua/plugins.d/coc.vim +++ b/home/.config/nvim/lua/plugins.d/coc.vim @@ -7,6 +7,7 @@ " this is open to pull requests Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'antoinemadec/coc-fzf' let g:coc_global_extensions = [ \ 'coc-pyright', 'coc-json', 'coc-git', 'coc-html', 'coc-css', @@ -15,6 +16,8 @@ let g:coc_global_extensions = [ \ 'coc-lua' \ ] +nmap l :CocFzfList + " Use tab for trigger completion with characters ahead and navigate. " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. inoremap @@ -63,7 +66,7 @@ nmap rn (coc-rename) xmap f (coc-format-selected) nmap f (coc-format-selected) -augroup mygroup +augroup CocGroup autocmd! " Setup formatexpr specified filetype(s). autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') From eb2d3ca2bd84026e5fa4e5980b13d1621f1792d4 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 14:45:55 +0100 Subject: [PATCH 088/188] Enable flake8 linting for coc-pyright --- home/.config/nvim/coc-settings.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/home/.config/nvim/coc-settings.json b/home/.config/nvim/coc-settings.json index 38ed7e2..c774237 100644 --- a/home/.config/nvim/coc-settings.json +++ b/home/.config/nvim/coc-settings.json @@ -10,5 +10,9 @@ "diagnostic.checkCurrentLine": true, "coc.preferences.formatOnSaveFiletypes": [ "json" + ], + "python.linting.flake8Enabled": true, + "python.linting.flake8Args": [ + "--ignore=ANN204,ANN101,ANN102,ANN002,ANN003" ] } From 13c47143af04dcc101a2f86383027a6b56903c6d Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 14:49:02 +0100 Subject: [PATCH 089/188] Add auth-log alias --- home/.config/shell/aliases | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index ea7574a..60d4f2f 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -156,6 +156,7 @@ alias sv='systemctl' alias backup="rsync -avHAXS --delete --filter='dir-merge /.rsync-filter'" # Make full rsync backup, respecting .rsync-filter files for exclusions alias upload='curl -F "f:1=<-" ix.io' alias upload-journal='sudo journalctl -b -1 | upload' # Upload journalctl from last boot to ix.io +alias auth-log='journalctl SYSLOG_FACILITY=10 -r' alias cpu-stress='for i in $(seq $(getconf _NPROCESSORS_ONLN)); do yes > /dev/null & done' # Run `yes > /dev/null` on all cores as stress test alias nvidia='__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia' # Run app with nvidia (on hybrid mode with optimus) alias swapout='sudo swapoff -a; sudo swapon -a' # Reset swap (move everything to RAM) From ea6dc6594a8cb29407321e67e9ccd0462db5b93e Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 17:33:49 +0100 Subject: [PATCH 090/188] Add polyglot --- home/.config/nvim/lua/plugins.d/polyglot.lua | 11 +++++++++++ home/.config/nvim/lua/plugins.lua | 1 + 2 files changed, 12 insertions(+) create mode 100644 home/.config/nvim/lua/plugins.d/polyglot.lua diff --git a/home/.config/nvim/lua/plugins.d/polyglot.lua b/home/.config/nvim/lua/plugins.d/polyglot.lua new file mode 100644 index 0000000..91d3eff --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/polyglot.lua @@ -0,0 +1,11 @@ +local vim = require("vim") +local cmd = vim.cmd +local g = vim.g + +cmd[[Plug 'sheerun/vim-polyglot']] + +-- Disable polyglot's "sensible" settings, while there are some nice things it +-- does, I set these manually in my default config and I don't like depending +-- on single plugin for so many things, doing it manually doing it manually is +-- also more explicit making it obvious what's happening +g.polyglot_disabled = {'sensible'} diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index eec5f2a..02f2967 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -47,6 +47,7 @@ load_plugin('tmhedberg/SimpylFold') load_plugin('wakatime/vim-wakatime') load_plugin('mhinz/vim-startify') load_plugin('ryanoasis/vim-devicons') +load_plugin_file("polyglot.lua") load_plugin_file("vim-code-dark.lua") load_plugin_file("commentary.lua") load_plugin_file("coc.vim") From 35e213aa39da87a71371bcfafaa82e16c7d15f5a Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 18:58:42 +0100 Subject: [PATCH 091/188] Use nvim as editor, not vim --- home/.config/git/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/git/config b/home/.config/git/config index cfd0ac3..a22f815 100644 --- a/home/.config/git/config +++ b/home/.config/git/config @@ -56,7 +56,7 @@ helper = store --file ~/.config/git/git-credentials [core] excludefile = ~/.config/git/global_gitignore - editor = vim + editor = nvim pager = delta [interactive] diffFilter = delta --color-only From 32fa0f518dbe0951e87d1dd2a6227a1c3c93d3a6 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 19:00:47 +0100 Subject: [PATCH 092/188] Add blank line for nicer formatting --- home/.config/nvim/lua/plugins.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 02f2967..38389e1 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -38,6 +38,7 @@ local function load_plugin(plugin) cmd("Plug '" .. plugin .. "'") end + -- Begin Plug.vim loading process cmd("call plug#begin('" .. plugvim_plugins_dir .. "')") From 325c74be916bae23ffddbc92e60667bf49593d8b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 23:09:28 +0100 Subject: [PATCH 093/188] Small xmobar redesign --- home/.config/xmobar/xmobarrc.hs | 21 +++++++++++++++------ home/.config/xmobar/xmobarrc0 | 21 +++++++++++++++------ home/.config/xmobar/xmobarrc1 | 21 +++++++++++++++------ 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/home/.config/xmobar/xmobarrc.hs b/home/.config/xmobar/xmobarrc.hs index 8fa4d71..85f6d93 100644 --- a/home/.config/xmobar/xmobarrc.hs +++ b/home/.config/xmobar/xmobarrc.hs @@ -33,13 +33,13 @@ commands = [ -- Gather and format CPU usage information -- if it's above 50%, we consider it high and make it red Run Cpu [ - "-t", "\xf108 cpu: %", + "-t", "\xf2db %", "-H","50", "--high","red" ] 20, -- Ram used number and percent - Run Memory ["-t", "\xf233 mem: M (%)"] 20, + Run Memory ["-t", "\xf538 M (%)"] 20, -- Battery information. This is likely to require some customization -- based upon your specific hardware. Or, for a desktop you may want @@ -59,15 +59,21 @@ commands = [ Run Date "\xf017 %H:%M %b %d %Y" "date" 50, -- Network up and down - Run Network "wlp2s0" ["-t", "\xf0ab kb \xf0aa kb"] 20, + --Run Network "wlp4s0" ["-t", "\xf0ab kb \xf0aa kb"] 20, --Run Network "enp3s0" ["-t", "\xf0ab kb \xf0aa kb"] 20, + -- Uptime + Run Uptime ["-t", "\xf011 d h"] 360, + -- Show free disk space on / - Run DiskU [("/", "\xf0c7 hdd: ")] [] 60, + Run DiskU [("/", "\xf0c7 ")] [] 60, -- Get kernel version from uname -r Run Com "uname" ["-r"] "" 3600, + -- Volume info + Run Volume "default" "Master" ["-t", "\xf028 %"] 5, + -- Get bitcoin price from a custom script Run Com "/home/itsdrike/.local/bin/scripts/bitcoin" [] "bitcoin" 300, @@ -96,17 +102,20 @@ template = "\ \ \ \| %UnsafeStdinReader% }{ \ \|  %uname% \ - \| %cpu% \ \| %memory% \ \| %disku% \ + \| %cpu% \ + \| %default:Master% \ + \| %uptime% \ \|  %bitcoin% \ - \| %wlp2s0% \ \| %date% \ \| %trayerpad%\ \ " } -- Abandoned template strings +-- Network Wifi: +-- \| %wlp4s0% \ -- Network Ethernet: -- \| %enp3s0% \ -- Battery: diff --git a/home/.config/xmobar/xmobarrc0 b/home/.config/xmobar/xmobarrc0 index 8fa4d71..85f6d93 100644 --- a/home/.config/xmobar/xmobarrc0 +++ b/home/.config/xmobar/xmobarrc0 @@ -33,13 +33,13 @@ commands = [ -- Gather and format CPU usage information -- if it's above 50%, we consider it high and make it red Run Cpu [ - "-t", "\xf108 cpu: %", + "-t", "\xf2db %", "-H","50", "--high","red" ] 20, -- Ram used number and percent - Run Memory ["-t", "\xf233 mem: M (%)"] 20, + Run Memory ["-t", "\xf538 M (%)"] 20, -- Battery information. This is likely to require some customization -- based upon your specific hardware. Or, for a desktop you may want @@ -59,15 +59,21 @@ commands = [ Run Date "\xf017 %H:%M %b %d %Y" "date" 50, -- Network up and down - Run Network "wlp2s0" ["-t", "\xf0ab kb \xf0aa kb"] 20, + --Run Network "wlp4s0" ["-t", "\xf0ab kb \xf0aa kb"] 20, --Run Network "enp3s0" ["-t", "\xf0ab kb \xf0aa kb"] 20, + -- Uptime + Run Uptime ["-t", "\xf011 d h"] 360, + -- Show free disk space on / - Run DiskU [("/", "\xf0c7 hdd: ")] [] 60, + Run DiskU [("/", "\xf0c7 ")] [] 60, -- Get kernel version from uname -r Run Com "uname" ["-r"] "" 3600, + -- Volume info + Run Volume "default" "Master" ["-t", "\xf028 %"] 5, + -- Get bitcoin price from a custom script Run Com "/home/itsdrike/.local/bin/scripts/bitcoin" [] "bitcoin" 300, @@ -96,17 +102,20 @@ template = "\ \ \ \| %UnsafeStdinReader% }{ \ \|  %uname% \ - \| %cpu% \ \| %memory% \ \| %disku% \ + \| %cpu% \ + \| %default:Master% \ + \| %uptime% \ \|  %bitcoin% \ - \| %wlp2s0% \ \| %date% \ \| %trayerpad%\ \ " } -- Abandoned template strings +-- Network Wifi: +-- \| %wlp4s0% \ -- Network Ethernet: -- \| %enp3s0% \ -- Battery: diff --git a/home/.config/xmobar/xmobarrc1 b/home/.config/xmobar/xmobarrc1 index d9d7a09..21bb706 100644 --- a/home/.config/xmobar/xmobarrc1 +++ b/home/.config/xmobar/xmobarrc1 @@ -33,13 +33,13 @@ commands = [ -- Gather and format CPU usage information -- if it's above 50%, we consider it high and make it red Run Cpu [ - "-t", "\xf108 cpu: %", + "-t", "\xf2db %", "-H","50", "--high","red" ] 20, -- Ram used number and percent - Run Memory ["-t", "\xf233 mem: M (%)"] 20, + Run Memory ["-t", "\xf538 M (%)"] 20, -- Battery information. This is likely to require some customization -- based upon your specific hardware. Or, for a desktop you may want @@ -59,15 +59,21 @@ commands = [ Run Date "\xf017 %H:%M %b %d %Y" "date" 50, -- Network up and down - Run Network "wlp2s0" ["-t", "\xf0ab kb \xf0aa kb"] 20, + --Run Network "wlp4s0" ["-t", "\xf0ab kb \xf0aa kb"] 20, --Run Network "enp3s0" ["-t", "\xf0ab kb \xf0aa kb"] 20, + -- Uptime + Run Uptime ["-t", "\xf011 d h"] 360, + -- Show free disk space on / - Run DiskU [("/", "\xf0c7 hdd: ")] [] 60, + Run DiskU [("/", "\xf0c7 ")] [] 60, -- Get kernel version from uname -r Run Com "uname" ["-r"] "" 3600, + -- Volume info + Run Volume "default" "Master" ["-t", "\xf028 %"] 5, + -- Get bitcoin price from a custom script Run Com "/home/itsdrike/.local/bin/scripts/bitcoin" [] "bitcoin" 300, @@ -95,16 +101,19 @@ template = "\ \ \ \| %UnsafeStdinReader% }{ \ \|  %uname% \ - \| %cpu% \ \| %memory% \ \| %disku% \ + \| %cpu% \ + \| %default:Master% \ + \| %uptime% \ \|  %bitcoin% \ - \| %wlp2s0% \ \| %date% \ \ " } -- Abandoned template strings +-- Network Wifi: +-- \| %wlp4s0% \ -- Network Ethernet: -- \| %enp3s0% \ -- Battery: From 682a63b9d15ea347495e7622804c203615c07250 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 23:37:44 +0100 Subject: [PATCH 094/188] Automatically resize the terminal split --- home/.config/nvim/lua/mappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 346e91a..4d98f5c 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -62,7 +62,7 @@ nmap("", ":undo") nmap("", ":redo") -- Terminal -nmap("", ":split term://zshi") +nmap("", ":split term://zsh:resize -7i") nmap("", ":vnew term://zshi") nmap("", ":tabnew term://zshi") tmap("", "") From 1682cfd4eaaf2b8ee324c32fb1b3b07baaa3d207 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 3 Dec 2021 23:37:56 +0100 Subject: [PATCH 095/188] Add xmap function --- home/.config/nvim/lua/mappings.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 4d98f5c..d35b58b 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -29,6 +29,10 @@ function tmap(shortcut, command, options) keymap("t", shortcut, command, options) end +function xmap(shortcut, command, options) + keymap("x", shortcut, command, options) +end + -- Unmap arrow keys in normal mode to remove bad habits nmap("", "") nmap("", "") @@ -109,4 +113,3 @@ nmap("Q", ":bufdo bdelete") -- a message saying that dbext plugin isn't installed -- See :h ft-sql.txt vim.g.omni_sql_no_default_maps = 1 - From 0257190209b193c5d4c4d5ee7cc970120afed06f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 4 Dec 2021 00:43:05 +0100 Subject: [PATCH 096/188] Support save mapping from insert mode --- home/.config/nvim/lua/mappings.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index d35b58b..0a4d1c3 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -62,6 +62,7 @@ nmap("", ":resize -3") -- Define some common shortcuts nmap("", ":w") +imap("", ":wi") nmap("", ":undo") nmap("", ":redo") From f1e9b37e24c242949a630063966bc8c11ca9a938 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 4 Dec 2021 02:40:44 +0100 Subject: [PATCH 097/188] Fix set-upstream alias --- home/.config/git/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/git/config b/home/.config/git/config index a22f815..80ba740 100644 --- a/home/.config/git/config +++ b/home/.config/git/config @@ -48,7 +48,7 @@ lo = "log --pretty=oneline --abbrev-commit --graph" lg = "log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --" - set-upstream = "!git branch --set-upstream-to=origin`git symbolic-ref --short HEAD`" + set-upstream = "!git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`" find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'" show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'" From 5edd892f48c2c0a251248a1506ce5e71dbca48ce Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 4 Dec 2021 16:57:25 +0100 Subject: [PATCH 098/188] Add prompt for external keyfile in initcpio --- root/etc/initcpio/hooks/lukskeyfile | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/root/etc/initcpio/hooks/lukskeyfile b/root/etc/initcpio/hooks/lukskeyfile index fce69a5..4189ede 100644 --- a/root/etc/initcpio/hooks/lukskeyfile +++ b/root/etc/initcpio/hooks/lukskeyfile @@ -1,8 +1,8 @@ #!/bin/ash run_hook() { + # This is a needed kernel parameter for this hook if [ -n "$lukskeyfile" ]; then - # This is a needed kernel parameter for this hook modprobe -a -q loop dm-crypt >/dev/null 2>&1 # Refer to help from `mkinitcpio -H lukskeyfile`. IFS=: read rootKeyDev rootKey cryptkeyLoc </dev/null 2>&1; then + # Copy the keyfile present in the device into the + # ramfs filesystem to be read by dm-crypt cat "/mnt/${rootKey}" > "${cryptkeyLoc}" else echo "Failed to mount ${rootKeyDev} on /mnt" From 11baef383b2d3363389012c36587dbb3d75cfe34 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 5 Dec 2021 20:09:52 +0100 Subject: [PATCH 099/188] Override colorscheme's cursor line number color --- home/.config/nvim/lua/theme.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/home/.config/nvim/lua/theme.lua b/home/.config/nvim/lua/theme.lua index 7cfa568..c838be9 100644 --- a/home/.config/nvim/lua/theme.lua +++ b/home/.config/nvim/lua/theme.lua @@ -20,8 +20,15 @@ set guioptions-=r " Remove right-hand scrollbar set guioptions-=L " Remove left-hand scrollbar ]] --- Use more noticable cursor line color -cmd[[highlight CursorLine guibg=#2b2b2b]] +-- Override some colorscheme colors +-- * Use more noticable cursor line color +cmd[[ +augroup coloroverride + autocmd! + autocmd ColorScheme * highlight CursorLine guibg=#2b2b2b + autocmd ColorScheme * highlight CursorLineNr guifg=#1F85DE ctermfg=LightBlue +augroup END +]] -- Don't use true colors in TTY o.termguicolors = os.getenv("DISPLAY") and true or false From e8fb4e3614b08d8a578288eb0d298e1bbc3f6d6b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 5 Dec 2021 22:33:23 +0100 Subject: [PATCH 100/188] Move global functions to init.lua --- home/.config/nvim/init.lua | 26 +++- home/.config/nvim/lua/mappings.lua | 116 +++++++----------- .../.config/nvim/lua/plugins.d/commentary.lua | 4 +- home/.config/nvim/lua/plugins.d/nerdtree.lua | 2 +- home/.config/nvim/lua/plugins.lua | 10 +- 5 files changed, 73 insertions(+), 85 deletions(-) diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua index 20ec5ab..31ccea0 100644 --- a/home/.config/nvim/init.lua +++ b/home/.config/nvim/init.lua @@ -1,7 +1,31 @@ +local vim = require("vim") +local fn = vim.fn + +-- Define some global functions which can then be called +-- in the other required scripts + +-- Load an arbitrary .vim or .lua file +function LoadFile(file_path) + local extension = file_path:match("^.+(%..+)$") + local run_cmd + if (extension == ".vim") then run_cmd = "source" else run_cmd = "luafile" end + fn.execute(run_cmd .. " " .. file_path) +end + +-- Define a key mapping +function Keymap(mode, shortcut, command, options) + -- Assume silent, noremap unless specified otherwise + local opts = {noremap=true, silent=true} + + if options then opts = vim.tbl_extend("force", opts, options) end + vim.api.nvim_set_keymap(mode, shortcut, command, opts) +end + +-- Require additional scripts which contain individual configurations + require "base" require "theme" require "mappings" require "abbreviations" require "autocmd" require "plugins" - diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 0a4d1c3..60e881a 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -1,113 +1,85 @@ local vim = require("vim") +local g = vim.g --- Make these function definitions global as they could be reused --- in plugin specific scripts or in other places. -function keymap(mode, shortcut, command, options) - -- Assume silent, noremap unless specified otherwise - local opts = {noremap=true, silent=true} - if options then opts = vim.tbl_extend("force", opts, options) end - -- Perform the actual remap - vim.api.nvim_set_keymap(mode, shortcut, command, opts) -end -- This is a bit silly, but I don't like passing the mode argument --- to every keymap definition and this makes things a lot easier --- and a bit more vimscript-like -function nmap(shortcut, command, options) - keymap("n", shortcut, command, options) -end - -function imap(shortcut, command, options) - keymap("i", shortcut, command, options) -end - -function vmap(shortcut, command, options) - keymap("v", shortcut, command, options) -end - -function tmap(shortcut, command, options) - keymap("t", shortcut, command, options) -end - -function xmap(shortcut, command, options) - keymap("x", shortcut, command, options) -end +g.mapleader = "\\" -- Unmap arrow keys in normal mode to remove bad habits -nmap("", "") -nmap("", "") -nmap("", "") -nmap("", "") +Keymap("n", "", "") +Keymap("n", "", "") +Keymap("n", "", "") +Keymap("n", "", "") -- Tab navigation -nmap("", "gt") -nmap("", "gT") -nmap("", ":tabnew") -nmap("", ":tabmove +") -nmap("", ":tabmove -") -nmap("", ":tabp") -nmap("", ":tabn") +Keymap("n", "", "gt") +Keymap("n", "", "gT") +Keymap("n", "", ":tabnew") +Keymap("n", "", ":tabmove +") +Keymap("n", "", ":tabmove -") +Keymap("n", "", ":tabp") +Keymap("n", "", ":tabn") -- Set splits navigation to just ALT + hjkl -nmap("", "h") -nmap("", "j") -nmap("", "k") -nmap("", "l") +Keymap("n", "", "h") +Keymap("n", "", "j") +Keymap("n", "", "k") +Keymap("n", "", "l") -- Split size adjusting -nmap("", ":verical resize +3") -nmap("", ":vertical resize -3") -nmap("", ":resize +3") -nmap("", ":resize -3") +Keymap("n", "", ":vertical resize +3") +Keymap("n", "", ":vertical resize -3") +Keymap("n", "", ":resize +3") +Keymap("n", "", ":resize -3") -- Define some common shortcuts -nmap("", ":w") -imap("", ":wi") -nmap("", ":undo") -nmap("", ":redo") +Keymap("n", "", ":w") +Keymap("i", "", ":wi") +Keymap("n", "", ":undo") +Keymap("n", "", ":redo") -- Terminal -nmap("", ":split term://zsh:resize -7i") -nmap("", ":vnew term://zshi") -nmap("", ":tabnew term://zshi") -tmap("", "") +Keymap("n", "", ":split term://zsh:resize -7i") +Keymap("n", "", ":vnew term://zshi") +Keymap("n", "", ":tabnew term://zshi") +Keymap("t", "", "") -- Use space for folding/unfolding sections -nmap("", "za") -vmap("", "zf") +Keymap("n", "", "za") +Keymap("v", "", "zf") -- Use shift to quickly move 10 lines up/down -nmap("K", "10k") -nmap("J", "10j") +Keymap("n", "K", "10k") +Keymap("n", "J", "10j") -- Enable/Disable auto commenting -nmap("c", ":setlocal formatoptions-=cro") -nmap("C", ":setlocal formatoptions+=cro") +Keymap("n", "c", ":setlocal formatoptions-=cro") +Keymap("n", "C", ":setlocal formatoptions+=cro") -- Don't leave visual mode after indenting -vmap("<", "", ">gv") +Keymap("v", "<", "", ">gv") -- System clipboard copying -vmap("", '"+y') +Keymap("v", "", '"+y') -- Alias replace all -nmap("", ":%s//gI", {silent=false}) +Keymap("n", "", ":%s//gI", {silent=false}) -- Stop search highlight with Esc -nmap("", ":noh") +Keymap("n", "", ":noh") -- Start spell-check -nmap("s", ":setlocal spell! spelllang=en_us") +Keymap("n", "s", ":setlocal spell! spelllang=en_us") -- Run shell check -nmap("p", ":!shellckeck %") +Keymap("n", "p", ":!shellckeck %") -- Compile opened file (using custom script) -nmap("", ":w | !comp %") +Keymap("n", "", ":w | !comp %") -- Close all opened buffers -nmap("Q", ":bufdo bdelete") +Keymap("n", "Q", ":bufdo bdelete") -- Don't set the incredibely annoying mappings that trigger dynamic SQL -- completion with dbext and keeps on freezing vim whenever pressed with diff --git a/home/.config/nvim/lua/plugins.d/commentary.lua b/home/.config/nvim/lua/plugins.d/commentary.lua index e20acac..804de99 100644 --- a/home/.config/nvim/lua/plugins.d/commentary.lua +++ b/home/.config/nvim/lua/plugins.d/commentary.lua @@ -3,7 +3,7 @@ local cmd = vim.cmd cmd[[Plug 'tpope/vim-commentary']] -nmap("", ":Commentary") -vmap("", ":Commentary") +Keymap("n", "", ":Commentary") +Keymap("v", "", ":Commentary") cmd[[autocmd FileType apache setlocal commentstring=#\ %s]] diff --git a/home/.config/nvim/lua/plugins.d/nerdtree.lua b/home/.config/nvim/lua/plugins.d/nerdtree.lua index bc83d36..a4fbca2 100644 --- a/home/.config/nvim/lua/plugins.d/nerdtree.lua +++ b/home/.config/nvim/lua/plugins.d/nerdtree.lua @@ -11,7 +11,7 @@ Plug 'tiagofumo/vim-nerdtree-syntax-highlight' -- Implement manual NERDTreeToggle, but use NERDTreeFind for openning. -- This makes NERDTree open with the current file pre-selected -nmap("", "g:NERDTree.IsOpen() ? ':NERDTreeClose' : @% == '' ? ':NERDTree' : ':NERDTreeFind'", {expr=true}) +Keymap("n", "", "g:NERDTree.IsOpen() ? ':NERDTreeClose' : @% == '' ? ':NERDTree' : ':NERDTreeFind'", {expr=true}) g.NERDTreeShowHidden = 1 g.NERDTreeMinimalUI = 1 diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 38389e1..ed43964 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -19,18 +19,10 @@ if fn.empty(fn.glob(plug_install_path)) > 0 then cmd[[autocmd VimEnter * UpdateRemotePlugins]] end --- Load an arbitrary .vim or .lua file -local function load_file(file_path) - local extension = file_path:match("^.+(%..+)$") - local run_cmd - if (extension == ".vim") then run_cmd = "source" else run_cmd = "luafile" end - fn.execute(run_cmd .. " " .. file_path) -end - -- Load a file containing Plug call(s) and plugin settings local function load_plugin_file(plugin_file) local plugin_path = plugin_files_dir .. "/" .. plugin_file - load_file(plugin_path) + LoadFile(plugin_path) end -- Load a single given plugin using a Plug call From 9aeb79262848b217f6386bb1ff22a6a5bc5ce94c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 12:44:42 +0100 Subject: [PATCH 101/188] Convert fzf.vim to fzf.lua --- home/.config/nvim/lua/plugins.d/fzf.lua | 39 +++++++++++++++++++++++++ home/.config/nvim/lua/plugins.d/fzf.vim | 22 -------------- home/.config/nvim/lua/plugins.lua | 2 +- 3 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 home/.config/nvim/lua/plugins.d/fzf.lua delete mode 100644 home/.config/nvim/lua/plugins.d/fzf.vim diff --git a/home/.config/nvim/lua/plugins.d/fzf.lua b/home/.config/nvim/lua/plugins.d/fzf.lua new file mode 100644 index 0000000..9fb1452 --- /dev/null +++ b/home/.config/nvim/lua/plugins.d/fzf.lua @@ -0,0 +1,39 @@ +local vim = require("vim") +local cmd = vim.cmd +local g = vim.g + +cmd[[Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }]] +cmd[[Plug 'junegunn/fzf.vim']] +cmd[[Plug 'stsewd/fzf-checkout.vim']] + +g.fzf_layout = { + up = '~90%', + window = { + width = 0.8, + height = 0.8, + yoffset = 0.5, + offset = 0.5 + } +} + +cmd[[let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline']] + +-- Customize the Files command to use ripgrep which respects .gitignore files +cmd[[ +command! -bang -nargs=? -complete=dir Files + \ call fzf#run(fzf#wrap('files', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden' }), 0)) +]] + +-- Add an AllFiles variation that shows ignored files too +cmd[[ +command! -bang -nargs=? -complete=dir AllFiles + \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore' }), 0)) +]] + +Keymap("n", "f", ":Files") +Keymap("n", "F", ":AllFiles") +Keymap("n", "b", ":Buffers") +Keymap("n", "h", ":History") +Keymap("n", "r", ":Rg") +Keymap("n", "R", ":Rg", { silent = false }) +Keymap("n", "gb", ":GBranches") diff --git a/home/.config/nvim/lua/plugins.d/fzf.vim b/home/.config/nvim/lua/plugins.d/fzf.vim deleted file mode 100644 index 575e211..0000000 --- a/home/.config/nvim/lua/plugins.d/fzf.vim +++ /dev/null @@ -1,22 +0,0 @@ -Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } -Plug 'junegunn/fzf.vim' -Plug 'stsewd/fzf-checkout.vim' - -let g:fzf_layout = { 'up': '~90%', 'window': { 'width': 0.8, 'height': 0.8, 'yoffset':0.5, 'xoffset': 0.5 } } -let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline' - -" Customise the Files command to use ripgrep which respects .gitignore files -command! -bang -nargs=? -complete=dir Files - \ call fzf#run(fzf#wrap('files', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden' }), 0)) - -" Add an AllFiles variation that shows ignored files too -command! -bang -nargs=? -complete=dir AllFiles - \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore' }), 0)) - -nmap f :Files -nmap F :AllFiles -nmap b :Buffers -nmap h :History -nmap r :Rg -nmap R :Rg -nmap gb :GBranches diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index ed43964..3380b4a 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -47,7 +47,7 @@ load_plugin_file("coc.vim") load_plugin_file("vimwiki.lua") load_plugin_file("nerdtree.lua") load_plugin_file("airline.lua") -load_plugin_file("fzf.vim") +load_plugin_file("fzf.lua") -- End Plug.vim loading process cmd[[call plug#end()]] From c5baadf07fcf40e68f95d92da2417aecca347178 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:15:32 +0100 Subject: [PATCH 102/188] Rename plugins.d/ to pluginconf/ --- home/.config/nvim/lua/{plugins.d => pluginconf}/airline.lua | 0 home/.config/nvim/lua/{plugins.d => pluginconf}/coc.vim | 0 .../nvim/lua/{plugins.d => pluginconf}/commentary.lua | 0 .../lua/{plugins.d => pluginconf}/deprecated/semshi.lua | 0 home/.config/nvim/lua/{plugins.d => pluginconf}/fzf.lua | 0 .../.config/nvim/lua/{plugins.d => pluginconf}/nerdtree.lua | 0 .../.config/nvim/lua/{plugins.d => pluginconf}/polyglot.lua | 0 .../nvim/lua/{plugins.d => pluginconf}/vim-code-dark.lua | 0 home/.config/nvim/lua/{plugins.d => pluginconf}/vimwiki.lua | 0 home/.config/nvim/lua/plugins.lua | 6 +++--- 10 files changed, 3 insertions(+), 3 deletions(-) rename home/.config/nvim/lua/{plugins.d => pluginconf}/airline.lua (100%) rename home/.config/nvim/lua/{plugins.d => pluginconf}/coc.vim (100%) rename home/.config/nvim/lua/{plugins.d => pluginconf}/commentary.lua (100%) rename home/.config/nvim/lua/{plugins.d => pluginconf}/deprecated/semshi.lua (100%) rename home/.config/nvim/lua/{plugins.d => pluginconf}/fzf.lua (100%) rename home/.config/nvim/lua/{plugins.d => pluginconf}/nerdtree.lua (100%) rename home/.config/nvim/lua/{plugins.d => pluginconf}/polyglot.lua (100%) rename home/.config/nvim/lua/{plugins.d => pluginconf}/vim-code-dark.lua (100%) rename home/.config/nvim/lua/{plugins.d => pluginconf}/vimwiki.lua (100%) diff --git a/home/.config/nvim/lua/plugins.d/airline.lua b/home/.config/nvim/lua/pluginconf/airline.lua similarity index 100% rename from home/.config/nvim/lua/plugins.d/airline.lua rename to home/.config/nvim/lua/pluginconf/airline.lua diff --git a/home/.config/nvim/lua/plugins.d/coc.vim b/home/.config/nvim/lua/pluginconf/coc.vim similarity index 100% rename from home/.config/nvim/lua/plugins.d/coc.vim rename to home/.config/nvim/lua/pluginconf/coc.vim diff --git a/home/.config/nvim/lua/plugins.d/commentary.lua b/home/.config/nvim/lua/pluginconf/commentary.lua similarity index 100% rename from home/.config/nvim/lua/plugins.d/commentary.lua rename to home/.config/nvim/lua/pluginconf/commentary.lua diff --git a/home/.config/nvim/lua/plugins.d/deprecated/semshi.lua b/home/.config/nvim/lua/pluginconf/deprecated/semshi.lua similarity index 100% rename from home/.config/nvim/lua/plugins.d/deprecated/semshi.lua rename to home/.config/nvim/lua/pluginconf/deprecated/semshi.lua diff --git a/home/.config/nvim/lua/plugins.d/fzf.lua b/home/.config/nvim/lua/pluginconf/fzf.lua similarity index 100% rename from home/.config/nvim/lua/plugins.d/fzf.lua rename to home/.config/nvim/lua/pluginconf/fzf.lua diff --git a/home/.config/nvim/lua/plugins.d/nerdtree.lua b/home/.config/nvim/lua/pluginconf/nerdtree.lua similarity index 100% rename from home/.config/nvim/lua/plugins.d/nerdtree.lua rename to home/.config/nvim/lua/pluginconf/nerdtree.lua diff --git a/home/.config/nvim/lua/plugins.d/polyglot.lua b/home/.config/nvim/lua/pluginconf/polyglot.lua similarity index 100% rename from home/.config/nvim/lua/plugins.d/polyglot.lua rename to home/.config/nvim/lua/pluginconf/polyglot.lua diff --git a/home/.config/nvim/lua/plugins.d/vim-code-dark.lua b/home/.config/nvim/lua/pluginconf/vim-code-dark.lua similarity index 100% rename from home/.config/nvim/lua/plugins.d/vim-code-dark.lua rename to home/.config/nvim/lua/pluginconf/vim-code-dark.lua diff --git a/home/.config/nvim/lua/plugins.d/vimwiki.lua b/home/.config/nvim/lua/pluginconf/vimwiki.lua similarity index 100% rename from home/.config/nvim/lua/plugins.d/vimwiki.lua rename to home/.config/nvim/lua/pluginconf/vimwiki.lua diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 3380b4a..3584fb0 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -2,9 +2,9 @@ local vim = require("vim") local cmd = vim.cmd local fn = vim.fn -local config_dir = fn.stdpath("config") -- Config directory (usually: ~/.config/nvim) -local plugvim_plugins_dir = config_dir .. "/plugged" -- Dir with all plugins installed by Plug.vim -local plugin_files_dir = config_dir .. "/lua/plugins.d" -- Dir with plugin config files including Plug call(s) +local config_dir = fn.stdpath("config") -- Config directory (usually: ~/.config/nvim) +local plugvim_plugins_dir = config_dir .. "/plugged" -- Dir with all plugins installed by Plug.vim +local plugin_files_dir = config_dir .. "/lua/pluginconf" -- Dir with plugin config files including Plug call(s) -- Automatically download vimplug and run PlugInstall local autoload_dir = config_dir .. "/autoload" From dce7dd58d0bece10bb1c43c89fb83cd7daba66d2 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:18:36 +0100 Subject: [PATCH 103/188] Switch package manager to packer --- home/.config/nvim/lua/pluginconf/airline.lua | 12 +- home/.config/nvim/lua/pluginconf/coc.vim | 3 - .../nvim/lua/pluginconf/commentary.lua | 4 +- .../nvim/lua/pluginconf/deprecated/semshi.lua | 2 +- home/.config/nvim/lua/pluginconf/fzf.lua | 4 - home/.config/nvim/lua/pluginconf/nerdtree.lua | 6 - home/.config/nvim/lua/pluginconf/polyglot.lua | 2 - .../nvim/lua/pluginconf/vim-code-dark.lua | 10 +- home/.config/nvim/lua/pluginconf/vimwiki.lua | 2 - home/.config/nvim/lua/plugins.lua | 155 ++++++++++++------ 10 files changed, 116 insertions(+), 84 deletions(-) diff --git a/home/.config/nvim/lua/pluginconf/airline.lua b/home/.config/nvim/lua/pluginconf/airline.lua index 8c3ef46..7184da5 100644 --- a/home/.config/nvim/lua/pluginconf/airline.lua +++ b/home/.config/nvim/lua/pluginconf/airline.lua @@ -2,15 +2,9 @@ local vim = require("vim") local g = vim.g local cmd = vim.cmd -cmd[[ -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -]] - --- Airline specific theming settings -g.airline_theme = 'codedark' -- Use codedark theme from vim-airline-themes -g.airline_right_sep = "" -- Don't use special separators (<) -g.airline_left_sep = "" -- Don't use special separators (>) +-- Don't use special separators +g.airline_right_sep = "" -- (default: <) +g.airline_left_sep = "" -- (default: >) -- Tabline setup -- TODO: Figure out how to set # separated variables in lua (open for PRs) diff --git a/home/.config/nvim/lua/pluginconf/coc.vim b/home/.config/nvim/lua/pluginconf/coc.vim index d8171ce..11be2ae 100644 --- a/home/.config/nvim/lua/pluginconf/coc.vim +++ b/home/.config/nvim/lua/pluginconf/coc.vim @@ -6,9 +6,6 @@ " however if anyone knows how to completely reproduce everything here in lua, " this is open to pull requests -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'antoinemadec/coc-fzf' - let g:coc_global_extensions = [ \ 'coc-pyright', 'coc-json', 'coc-git', 'coc-html', 'coc-css', \ 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml', diff --git a/home/.config/nvim/lua/pluginconf/commentary.lua b/home/.config/nvim/lua/pluginconf/commentary.lua index 804de99..69e80f8 100644 --- a/home/.config/nvim/lua/pluginconf/commentary.lua +++ b/home/.config/nvim/lua/pluginconf/commentary.lua @@ -1,9 +1,9 @@ local vim = require("vim") local cmd = vim.cmd -cmd[[Plug 'tpope/vim-commentary']] - +-- Set up shortcuts to quickly comment some code Keymap("n", "", ":Commentary") Keymap("v", "", ":Commentary") +-- Set up comments for unhandled file types cmd[[autocmd FileType apache setlocal commentstring=#\ %s]] diff --git a/home/.config/nvim/lua/pluginconf/deprecated/semshi.lua b/home/.config/nvim/lua/pluginconf/deprecated/semshi.lua index e37aea8..a2479e6 100644 --- a/home/.config/nvim/lua/pluginconf/deprecated/semshi.lua +++ b/home/.config/nvim/lua/pluginconf/deprecated/semshi.lua @@ -11,7 +11,7 @@ local fn = vim.fn -- when I access something as an attribute, but it would be neat to see what that -- attribute actually holds, is it a class or a fucntion. But from my searching, -- I wasn't able to find anything like this. This is open to pull requests. -cmd[[Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' }]] +-- Plugin: numirias/semshi if (fn.has("python3")) then fn.system({"pip", "install", "nvim", "--upgrade"}) diff --git a/home/.config/nvim/lua/pluginconf/fzf.lua b/home/.config/nvim/lua/pluginconf/fzf.lua index 9fb1452..e520c6e 100644 --- a/home/.config/nvim/lua/pluginconf/fzf.lua +++ b/home/.config/nvim/lua/pluginconf/fzf.lua @@ -2,10 +2,6 @@ local vim = require("vim") local cmd = vim.cmd local g = vim.g -cmd[[Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }]] -cmd[[Plug 'junegunn/fzf.vim']] -cmd[[Plug 'stsewd/fzf-checkout.vim']] - g.fzf_layout = { up = '~90%', window = { diff --git a/home/.config/nvim/lua/pluginconf/nerdtree.lua b/home/.config/nvim/lua/pluginconf/nerdtree.lua index a4fbca2..47e7183 100644 --- a/home/.config/nvim/lua/pluginconf/nerdtree.lua +++ b/home/.config/nvim/lua/pluginconf/nerdtree.lua @@ -3,12 +3,6 @@ local g = vim.g local fn = vim.fn local cmd = vim.cmd -cmd[[ -Plug 'preservim/nerdtree' -Plug 'Xuyuanp/nerdtree-git-plugin' -Plug 'tiagofumo/vim-nerdtree-syntax-highlight' -]] - -- Implement manual NERDTreeToggle, but use NERDTreeFind for openning. -- This makes NERDTree open with the current file pre-selected Keymap("n", "", "g:NERDTree.IsOpen() ? ':NERDTreeClose' : @% == '' ? ':NERDTree' : ':NERDTreeFind'", {expr=true}) diff --git a/home/.config/nvim/lua/pluginconf/polyglot.lua b/home/.config/nvim/lua/pluginconf/polyglot.lua index 91d3eff..b9b9187 100644 --- a/home/.config/nvim/lua/pluginconf/polyglot.lua +++ b/home/.config/nvim/lua/pluginconf/polyglot.lua @@ -2,8 +2,6 @@ local vim = require("vim") local cmd = vim.cmd local g = vim.g -cmd[[Plug 'sheerun/vim-polyglot']] - -- Disable polyglot's "sensible" settings, while there are some nice things it -- does, I set these manually in my default config and I don't like depending -- on single plugin for so many things, doing it manually doing it manually is diff --git a/home/.config/nvim/lua/pluginconf/vim-code-dark.lua b/home/.config/nvim/lua/pluginconf/vim-code-dark.lua index de7fc35..6690b7f 100644 --- a/home/.config/nvim/lua/pluginconf/vim-code-dark.lua +++ b/home/.config/nvim/lua/pluginconf/vim-code-dark.lua @@ -1,12 +1,4 @@ local vim = require("vim") local cmd = vim.cmd -cmd[[Plug 'tomasiser/vim-code-dark']] - --- Set vim-code-dark as colortheme after plugin loading was finished -cmd[[ -augroup VimCodeDark - autocmd! - autocmd User PlugLoaded ++nested colorscheme codedark -augroup end -]] +cmd[[colorscheme codedark]] diff --git a/home/.config/nvim/lua/pluginconf/vimwiki.lua b/home/.config/nvim/lua/pluginconf/vimwiki.lua index 8f266e5..80a10cc 100644 --- a/home/.config/nvim/lua/pluginconf/vimwiki.lua +++ b/home/.config/nvim/lua/pluginconf/vimwiki.lua @@ -2,8 +2,6 @@ local vim = require("vim") local cmd = vim.cmd local g = vim.g -cmd[[Plug 'vimwiki/vimwiki']] - local wiki_conf = {} wiki_conf["path"] = "~/Personal/vimwiki" wiki_conf["path_html"] = "~/Personal/vimwiki-html" diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 3584fb0..06e0e06 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -1,56 +1,119 @@ local vim = require("vim") local cmd = vim.cmd +local api = vim.api local fn = vim.fn -local config_dir = fn.stdpath("config") -- Config directory (usually: ~/.config/nvim) -local plugvim_plugins_dir = config_dir .. "/plugged" -- Dir with all plugins installed by Plug.vim -local plugin_files_dir = config_dir .. "/lua/pluginconf" -- Dir with plugin config files including Plug call(s) - --- Automatically download vimplug and run PlugInstall -local autoload_dir = config_dir .. "/autoload" -local plug_install_path = autoload_dir .. "/plug.vim" -local plug_download_url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" - -if fn.empty(fn.glob(plug_install_path)) > 0 then - print("Downloading vim-plug, there may be initial errors...") - fn.system({"mkdir", "-p", autoload_dir}) - fn.system("curl " .. plug_download_url .. " > " .. plug_install_path) - cmd[[autocmd VimEnter * PlugInstall]] - cmd[[autocmd VimEnter * UpdateRemotePlugins]] +-- Automatically download (bootstrap) packer plugin manager +-- if it's not already installed +local packer_install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" +local packer_bootstrap +if fn.empty(fn.glob(packer_install_path)) > 0 then + print("Installing packer plugin manager, please wait...") + packer_bootstrap = fn.system({ + 'git', 'clone', '--depth', '1', + 'https://github.com/wbthomason/packer.nvim', + packer_install_path + }) + print("Packer installed, reload vim to install plugins") end --- Load a file containing Plug call(s) and plugin settings -local function load_plugin_file(plugin_file) - local plugin_path = plugin_files_dir .. "/" .. plugin_file - LoadFile(plugin_path) +-- Automatically run :PackerCompile if plugins.lua is updated +cmd[[ +augroup packer_user_config + autocmd! + autocmd BufWritePost ~/.config/nvim/lua/plugins.lua source | PackerCompile +augroup end +]] + +-- Returns the line to be executed after plugin is loaded, this +-- is useful for the `config` parameter of packer's use to +-- source `.vim` files or require `.lua` files +-- Expects a file path from pluginconf/ folder +local function get_plugin_file(pluginconf_file) + local filename, extension = pluginconf_file:match("^(.+)(%..+)$") + if (extension == ".vim") then + -- Source wants absolute path + local pluginconf_path = fn.stdpath("config") .. "lua/pluginconf" + local source_line = string.format('source "%s/%s"', pluginconf_path, pluginconf_file) + return string.format("vim.fn.execute('%s')", source_line) + else + -- Require wants relative path from lua/ + local pluginconf_path = "pluginconf" + return string.format('require("%s/%s")', pluginconf_path, filename) + end end --- Load a single given plugin using a Plug call -local function load_plugin(plugin) - cmd("Plug '" .. plugin .. "'") -end +-- Make sure to add packer here, even if it's opt +api.nvim_command("packadd packer.nvim") +-- Define packer plugins +return require("packer").startup({ + function(use) + use("wbthomason/packer.nvim") + use('airblade/vim-gitgutter') + use('dhruvasagar/vim-table-mode') + use('tmhedberg/SimpylFold') + use('wakatime/vim-wakatime') + use('mhinz/vim-startify') + use('ryanoasis/vim-devicons') + use({ + "tomasiser/vim-code-dark", + config = get_plugin_file("vim-code-dark.lua"), + }) + use({ + "vim-airline/vim-airline", + config = get_plugin_file("airline.lua"), + requires = { "vim-airline/vim-airline-themes", opt = true }, + }) + use({ + "preservim/nerdtree", + config = get_plugin_file("nerdtree.lua"), + requires = { + { "Xuyuanp/nerdtree-git-plugin", opt = true }, + { "tiagofumo/vim-nerdtree-syntax-highlight", opt = true }, + }, + }) + use({ + "vimwiki/vimwiki", + config = get_plugin_file("vimwiki.lua") + }) + use({ + "sheerun/vim-polyglot", + setup = get_plugin_file("polyglot.lua") + }) + use({ + "tpope/vim-commentary", + config = get_plugin_file("commentary.lua") + }) + use({ + "junegunn/fzf", + run = function() fn['fzf#install']() end, + }) + use({ + "junegunn/fzf.vim", + config = get_plugin_file("fzf.lua"), + after = "fzf", + requires = { "stsewd/fzf-checkout.vim", opt = true }, + }) + use({ + "neoclide/coc.nvim", + branch = "release", + config = get_plugin_file("coc.vim"), + requires = { "antoinemadec/coc-fzf", opt = true }, + }) --- Begin Plug.vim loading process -cmd("call plug#begin('" .. plugvim_plugins_dir .. "')") - -load_plugin('airblade/vim-gitgutter') -load_plugin('dhruvasagar/vim-table-mode') -load_plugin('tmhedberg/SimpylFold') -load_plugin('wakatime/vim-wakatime') -load_plugin('mhinz/vim-startify') -load_plugin('ryanoasis/vim-devicons') -load_plugin_file("polyglot.lua") -load_plugin_file("vim-code-dark.lua") -load_plugin_file("commentary.lua") -load_plugin_file("coc.vim") -load_plugin_file("vimwiki.lua") -load_plugin_file("nerdtree.lua") -load_plugin_file("airline.lua") -load_plugin_file("fzf.lua") - --- End Plug.vim loading process -cmd[[call plug#end()]] - --- Run autocmds defined in the plugin files after plugin loading has finished -cmd[[doautocmd User PlugLoaded]] + -- Run sync if we've just bootstrapped packer + if packer_bootstrap then + require("packer").sync() + end + end, + config = { + display = { + open_fn = require('packer.util').float, + }, + profile = { + enable = true, + threshold = 1, -- the amount in ms that a plugins load time must be over for it to be included in the profile + }, + } +}) From a4ad2c7026be9f5faa0471c9f91fca2c3e76c35e Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:19:16 +0100 Subject: [PATCH 104/188] Add nvim-dap --- home/.config/nvim/lua/pluginconf/nvim-dap.lua | 24 +++++++++++++++++++ home/.config/nvim/lua/plugins.lua | 5 ++++ 2 files changed, 29 insertions(+) create mode 100644 home/.config/nvim/lua/pluginconf/nvim-dap.lua diff --git a/home/.config/nvim/lua/pluginconf/nvim-dap.lua b/home/.config/nvim/lua/pluginconf/nvim-dap.lua new file mode 100644 index 0000000..84f8167 --- /dev/null +++ b/home/.config/nvim/lua/pluginconf/nvim-dap.lua @@ -0,0 +1,24 @@ +local vim = require("vim") +local cmd = vim.cmd + +-- Define dap mappings (:help dap-mapping) +local prefix = ":lua require('dap')." +Keymap("n", "", prefix .. "continue()") +Keymap("n", "", prefix .. "step_over()") +Keymap("n", "", prefix .. "step_into()") +Keymap("n", "", prefix .. "step_out()") +Keymap("n", "", prefix .. "toggle_breakpoint()") +Keymap("n", "", prefix .. "set_breakpoint(vim.fn.input('Breakpoint condition: '))") +Keymap("n", "", prefix .. "set_breakpoint(nil, nil, vim.fn.input('Log point message: '))") +Keymap("n", "di", prefix .. "repl.open()") +Keymap("n", "dl", prefix .. "run_last()") + +-- Setup dap for python (requires nvim-dap-python plugin) +require('dap-python').setup('/usr/bin/python') -- Path to python with `debugpy` library installed +require('dap-python').test_runner = 'pytest' -- Use pytest to run unit tests + +-- Python mappings +local pyprefix = ":lua require('dap-python')." +Keymap("n", "dptm", pyprefix .. "test_method()") +Keymap("n", "dptc", pyprefix .. "test_class()") +Keymap("v", "ds", "" .. pyprefix .. "debug_selection()") diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index 06e0e06..db505b3 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -85,6 +85,11 @@ return require("packer").startup({ "tpope/vim-commentary", config = get_plugin_file("commentary.lua") }) + use({ + "mfussenegger/nvim-dap", + config = get_plugin_file("nvim-dap.lua"), + requires = { "mfussenegger/nvim-dap-python", opt = true }, + }) use({ "junegunn/fzf", run = function() fn['fzf#install']() end, From b06ced95b8d1bbef13b7103dd3d8e9749062a8ee Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:50:41 +0100 Subject: [PATCH 105/188] Rename base.lua to options.lua --- home/.config/nvim/init.lua | 2 +- home/.config/nvim/lua/{base.lua => options.lua} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename home/.config/nvim/lua/{base.lua => options.lua} (100%) diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua index 31ccea0..2af840f 100644 --- a/home/.config/nvim/init.lua +++ b/home/.config/nvim/init.lua @@ -23,7 +23,7 @@ end -- Require additional scripts which contain individual configurations -require "base" +require "options" require "theme" require "mappings" require "abbreviations" diff --git a/home/.config/nvim/lua/base.lua b/home/.config/nvim/lua/options.lua similarity index 100% rename from home/.config/nvim/lua/base.lua rename to home/.config/nvim/lua/options.lua From ea9a73f21aed79270d33916372d3272a402462cc Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:52:51 +0100 Subject: [PATCH 106/188] Improve comments --- home/.config/nvim/lua/options.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index 5b831c7..8a5dda6 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -1,12 +1,13 @@ local vim = require("vim") local cmd = vim.cmd local o = vim.opt +local g = vim.g cmd[[filetype plugin on]] --- Tab settings +-- Tab/Indent settings o.expandtab = true -- Expand tabs to spaces -o.tabstop = 4 -- Tab size +o.tabstop = 4 -- Tab size in spaces o.shiftwidth = 4 -- Indentation size o.softtabstop = 4 -- Tabs/Spaces interlop o.tabpagemax = 50 -- More tabs @@ -23,7 +24,7 @@ o.splitright = true -- Put new vertical splits to right -- In-file search (/) o.ignorecase = true -- Use case insensitive matching -o.incsearch = true -- Show partial matches for search phrase +o.incsearch = true -- Show partial matches while typing o.hlsearch = true -- Highlight search matches -- Show trailing whitespace From fbe51f22eff38b1f994c4d3758c52b6c9863ede3 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:53:03 +0100 Subject: [PATCH 107/188] Show tabs properly --- home/.config/nvim/lua/options.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index 8a5dda6..b87195c 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -27,9 +27,9 @@ o.ignorecase = true -- Use case insensitive matching o.incsearch = true -- Show partial matches while typing o.hlsearch = true -- Highlight search matches --- Show trailing whitespace -o.list = true -- Enable showing characters like , , ... -o.listchars = "trail:·" -- Only show trailing whitespaces +-- Show whitespace +o.list = true -- Enable showing characters like , , ... +o.listchars = {tab = " ", trail = "·"} -- Specify which characters to show -- Command-mode search o.wildmode = {"longest", "list", "full"} -- Enable autocompletion From 88891bb2a4e775839e1de8f0f61f388d32b2762c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:53:32 +0100 Subject: [PATCH 108/188] Don't show current mode --- home/.config/nvim/lua/options.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index b87195c..d8e510c 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -43,3 +43,4 @@ o.autoindent = true -- Enable autoindent o.autoread = true -- Automatically reload files on change o.undolevels = 999 -- Lots of these o.history = 1000 -- More history +o.showmode = false -- Don't display mode (it's on status line anyway) From afa4c250c5dcc436e50852eb5f8952a9e840261f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:54:55 +0100 Subject: [PATCH 109/188] Move autoindent to indent settings --- home/.config/nvim/lua/options.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index d8e510c..4b0c9ec 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -6,6 +6,7 @@ local g = vim.g cmd[[filetype plugin on]] -- Tab/Indent settings +o.autoindent = true -- Enable autoindent o.expandtab = true -- Expand tabs to spaces o.tabstop = 4 -- Tab size in spaces o.shiftwidth = 4 -- Indentation size @@ -39,7 +40,6 @@ table.insert(o.path, "**") -- Search down into subfolders with -- Misc o.mouse = "a" -- Enable mouse mode o.encoding = "utf-8" -- Use UTF-8 encoding -o.autoindent = true -- Enable autoindent o.autoread = true -- Automatically reload files on change o.undolevels = 999 -- Lots of these o.history = 1000 -- More history From 3dfb695eafc6580d61b7764e2d3fc6331cc971e8 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:56:48 +0100 Subject: [PATCH 110/188] Split some settings to files section --- home/.config/nvim/lua/options.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index 4b0c9ec..7d0bce2 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -37,10 +37,12 @@ o.wildmode = {"longest", "list", "full"} -- Enable autocompletion o.wildmenu = true -- Display all matching files when we tab complete table.insert(o.path, "**") -- Search down into subfolders with tab completion --- Misc -o.mouse = "a" -- Enable mouse mode +-- Files o.encoding = "utf-8" -- Use UTF-8 encoding o.autoread = true -- Automatically reload files on change + +-- Misc +o.mouse = "a" -- Enable mouse mode o.undolevels = 999 -- Lots of these o.history = 1000 -- More history o.showmode = false -- Don't display mode (it's on status line anyway) From 328adaec753bd664284affdd498ce4c927828a12 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:59:10 +0100 Subject: [PATCH 111/188] Enable shiftround --- home/.config/nvim/lua/options.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index 7d0bce2..e92472c 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -12,6 +12,7 @@ o.tabstop = 4 -- Tab size in spaces o.shiftwidth = 4 -- Indentation size o.softtabstop = 4 -- Tabs/Spaces interlop o.tabpagemax = 50 -- More tabs +o.shiftround = true -- Always round indent to multiple of shiftwidth -- Folding o.foldmethod = "indent" -- Use indent to determine the fold levels From 510928605467ad48cd848e2a8e5674f2517871ba Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 14:05:00 +0100 Subject: [PATCH 112/188] Move showmode option to theme.lua --- home/.config/nvim/lua/options.lua | 1 - home/.config/nvim/lua/theme.lua | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index e92472c..3e79a02 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -46,4 +46,3 @@ o.autoread = true -- Automatically reload files on change o.mouse = "a" -- Enable mouse mode o.undolevels = 999 -- Lots of these o.history = 1000 -- More history -o.showmode = false -- Don't display mode (it's on status line anyway) diff --git a/home/.config/nvim/lua/theme.lua b/home/.config/nvim/lua/theme.lua index c838be9..5d4c050 100644 --- a/home/.config/nvim/lua/theme.lua +++ b/home/.config/nvim/lua/theme.lua @@ -11,6 +11,7 @@ o.relativenumber = true -- Use relative line numbers o.showmatch = true -- Show matching bracket o.scrolloff = 5 -- Keep 5 lines horizontal scrolloff o.sidescrolloff = 5 -- Keep 5 chars vertical scrolloff +o.showmode = false -- Don't display mode (it's on status line anyway) -- I wasn't able to find a way to set guioptions directly in lua cmd[[ From 03431e5bc4d55ca2a1dd557f8e460c13178936db Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 14:08:11 +0100 Subject: [PATCH 113/188] Remove unused g local variable definition --- home/.config/nvim/lua/options.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/options.lua index 3e79a02..58a7be8 100644 --- a/home/.config/nvim/lua/options.lua +++ b/home/.config/nvim/lua/options.lua @@ -1,7 +1,6 @@ local vim = require("vim") local cmd = vim.cmd local o = vim.opt -local g = vim.g cmd[[filetype plugin on]] From 9625f2b951c2f2b689645a62d519f9867f55ff55 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 14:08:36 +0100 Subject: [PATCH 114/188] Use proper syntax highlighting in fenced codeblocks --- home/.config/nvim/lua/theme.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/home/.config/nvim/lua/theme.lua b/home/.config/nvim/lua/theme.lua index 5d4c050..1ef4283 100644 --- a/home/.config/nvim/lua/theme.lua +++ b/home/.config/nvim/lua/theme.lua @@ -1,5 +1,6 @@ local vim = require("vim") local cmd = vim.cmd +local g = vim.g local o = vim.opt cmd[[syntax on]] -- Turn on syntax highlighting @@ -33,3 +34,6 @@ augroup END -- Don't use true colors in TTY o.termguicolors = os.getenv("DISPLAY") and true or false + +-- Use proper syntax highlighting in fenced codeblocks +g.markdown_fenced_languages = {"html", "javascript", "typescript", "css", "scss", "lua", "vim", "python"} From d9fdf91b8b40b92385578ea2fe6beae499d2b40d Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 13:38:04 +0000 Subject: [PATCH 115/188] Update neovim config details and image --- README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 27b692c..734fefd 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ You are highly advised to first go through these dotfiles yourself and adjust th - Custom prompt (defined [here](home/.config/shell/theme)). - Colorscheme showcase: ![image](https://user-images.githubusercontent.com/20902250/117699472-69ab5d80-b1b4-11eb-85a8-2b039bc1599a.png) - Command timing showcase: ![image](https://user-images.githubusercontent.com/20902250/129356038-f1373183-ee50-4cc9-a602-a1215b5d1e5f.png) -- Neovim configuration (defined [`here`](home/.config/nvim/)) ![image](https://user-images.githubusercontent.com/20902250/129356722-9eb1e813-62c4-4ad1-ad49-114f69700f80.png) -- Automatic unknown command package handler ![image](https://user-images.githubusercontent.com/20902250/129359888-629a4f28-64bd-4c90-8e87-de75a9b8997d.png) -- `lf` file manager previews with ueberzug ![image](https://user-images.githubusercontent.com/20902250/129359042-b0594788-bc14-4294-bba2-8cba8e30cd94.png) +- Neovim configuration written in lua: ![Screenshot_2021-12-06_14-31-37](https://user-images.githubusercontent.com/20902250/144854879-f35de259-cea1-4415-9a3b-b093fe008836.png) +- Automatic unknown command package handler: ![image](https://user-images.githubusercontent.com/20902250/129359888-629a4f28-64bd-4c90-8e87-de75a9b8997d.png) +- `lf` file manager previews with ueberzug: ![image](https://user-images.githubusercontent.com/20902250/129359042-b0594788-bc14-4294-bba2-8cba8e30cd94.png) ## Features @@ -24,15 +24,14 @@ You are highly advised to first go through these dotfiles yourself and adjust th - Even though enabling it is an option, it is not a necessary thing to do, oh-my-zsh has a lot of code that is mostly irrelevant and unused, these dotfiles give you the ability to completely avoid it, if you desire to do so - Custom [prompt](home/.config/shell/theme), both for oh-my-zsh configuration or for standalone usage -- Custom [VIM configuration](home/.config/nvim) - - When you open nvim for the first time, it will automatically try to install addons using VimPlug +- Custom [NVIM configuration](home/.config/nvim) + - When you open nvim for the first time, it will automatically try to install Packer plugin manager - It is compatible with TTY usage, in which case the color support is downgraded and use of special fonts is disabled. - - There isn't a single huge configuration file, but rather multiple config files that are being sourced by the main - init.vim, this is done to avoid clutter with comments in the main file and it also provides a very easy way to - disable parts of configuration, by simply not sourcing that file. - - NOTE: This configuration is mostly designed for neovim, not regular vim, however it should work with some - adjustments + - The configuration is split into multiple smaller files to keep everything clearn and avoid clutter in the main + configuration file (`init.lua`). It also allows for us to quickly disable certain parts of the config. + - The whole configuration is written in lua rather than vimscript. This allows us to do some nicer things, however + it also means that this config will NOT work for regular vim, it's only meant to be used for neovim. - Many handy [aliases](home/.config/shell/aliases) and [functions](home/.config/shell/functions) (likely too many, you should adjust that to your needs) - [Many pre-defined environmental variables](home/.config/shell/environ), these include From cd932f2040bf5451db5f7b436f0a3a0f07102d76 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 14:29:40 +0000 Subject: [PATCH 116/188] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 734fefd..c0c7af6 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ And extract from `.tar.gz` archive: The open-source community has an incredible amount of resources that people have offered to others free of charge and we all depend on many of these sources. This project is no different and there were many open-source projects that were -utilized in some parts of this project. For that reason, I'd like tho thank all of these projects and their +utilized in some parts of this project. For that reason, I'd like to thank all of these projects and their contributors for keeping their content open and available to everyone. This is the list of projects that helped me build this repository to the stage it's in now. Many of the aliases, config files and other resources aren't my original creations, but rather just small improvements and adjustments to get everything set in the way I like. Below From b0b6a12b238ce2f28c55d61fb9b8f6673ffe2a0e Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 15:14:02 +0100 Subject: [PATCH 117/188] Rewrite picom config --- home/.config/picom.conf | 302 ++++++++++++++++++++++++++++++++++++---- packages.yaml | 3 +- 2 files changed, 275 insertions(+), 30 deletions(-) diff --git a/home/.config/picom.conf b/home/.config/picom.conf index 25e3b2c..4e2c19f 100644 --- a/home/.config/picom.conf +++ b/home/.config/picom.conf @@ -1,16 +1,175 @@ -# Apply blur to terminals +# NOTE 1: This configuration when used as-is, requires --experimental-backends +# command line option to be used, in order to enable the usage of the +# dual-kawase blur method. + +# NOTE 2: With the picom from standard repositories, currently using experimental +# backends will disable the support for rounded corners. If you want to use both +# the dual-kawase blur method and rounded corners, you will need to use a fork. +# However it is not mandantory. If you will use the standard version, you will just +# see a warning in picom's logs each time it's started, you can disable rounded +# corners completely to prevent this. If you do want to use a fork, I recommend this: +# (picom-jonaburg-git on AUR). + +# NOTE 3: The shadows are currently disabled, the reason for this are the issues +# that occur with combining rounded corners and shadows, for more info, check: +# + + +# General settings +################### + +# Daemonize process. Fork to background after initialization. +# Causes issues with certain (badly-written) drivers. +daemon = false + +# Specify the backend to use: `xrender`, `glx`, or `xr_glx_hybrid`. +# `xrender` is the default one. +# We use GLX since it's generally a lot faster than xrender. +# There usually aren't anny issues with this, but if you do experience some +# try falling back to xrender. +backend = "glx"; + +# To properly use the GLX backend, we need to enable experimental backends +experimental-backends = true; + +# Enable/Disable VSync. +vsync = true; + +# Enable remote control via D-Bus. +dbus = false; + +# Try to detect WM windows (a non-override-redirect window with no +# child that has 'WM_STATE') and mark them as active. +mark-wmwin-focused = true; + +# Mark override-redirect windows that doesn't have a child window +# with 'WM_STATE' focused. +mark-ovredir-focused = true; + +# Try to detect windows with rounded corners and don't consider them +# shaped windows. The accuracy is not very high, unfortunately. +detect-rounded-corners = true; + +# Detect '_NET_WM_OPACITY' on client windows, useful for window managers +# not passing '_NET_WM_OPACITY' of client windows to frame windows. +detect-client-opacity = true; + +# Specify refresh rate of the screen. If not specified or 0, picom will +# try detecting this with X RandR extension. +refresh-rate = 0; + +# GLX backend: Avoid using stencil buffer, useful if you don't have a stencil buffer. +# Might cause incorrect opacity when rendering transparent content (but never +# practically happened) and may not work with blur-background. +# My tests show a 15% performance boost. Recommended. +glx-no-stencil = true; + +# GLX backend: Avoid rebinding pixmap on window damage. +# Probably could improve performance on rapid window content changes, +# but is known to break things on some drivers (LLVMpipe, xf86-video-intel, etc.). +# Recommended if it works. +glx-no-rebind-pixmap = true; + +# Disable/Enable the use of damage information. +# Disabling cause the whole screen to be redrawn everytime, instead of the part +# of the screen has actually changed. Potentially degrades the performance, +# but might fix some artifacts. It is recommended to keep this enabled. +# The opposing option is no-use-damage +use-damage = true + +# Window type settings +# +# 'WINDOW_TYPE' is one of the 15 window types defined in EWMH standard: +# "unknown", "desktop", "dock", "toolbar", "menu", "utility", +# "splash", "dialog", "normal", "dropdown_menu", "popup_menu", +# "tooltip", "notification", "combo", and "dnd". +# +# Following per window-type options are available: :: +# +# fade, shadow::: +# Controls window-type-specific shadow and fade settings. +# +# opacity::: +# Controls default opacity of the window type. +# +# focus::: +# Controls whether the window of this type is to be always considered focused. +# (By default, all window types except "normal" and "dialog" has this on.) +# +# full-shadow::: +# Controls whether shadow is drawn under the parts of the window that you +# normally won't be able to see. Useful when the window has parts of it +# transparent, and you want shadows in those areas. +# +# redir-ignore::: +# Controls whether this type of windows should cause screen to become +# redirected again after been unredirected. If you have unredir-if-possible +# set, and doesn't want certain window to cause unnecessary screen redirection, +# you can set this to `true`. +# +wintypes: +{ + normal = { full-shadow = true; blur-background = true; }; + splash = { blur-background = false; }; + menu = { full-shadow = true; }; + tooltip = { fade = true; shadow = false; focus = true;}; + dock = { shadow = false; }; + dnd = { shadow = false; }; + popup_menu = { full-shadow = true; }; + utility = { full-shadow = true; }; + toolbar = { full-shadow = true; }; + notification = { opacity = 1; } +}; + + +# Transparency / Opacity +######################### + +# Specify a list of opacity rules. # format: "[Opacity level]:[xprop info name] = '[xprop value]'" -# class_g reffers to class in position #0, -# class_i reffers to class in position #1 +# - class_g reffers to class in position #0, +# - class_i reffers to class in position #1 +# Note we don't make any guarantee about possible conflicts with other +# programs that set '_NET_WM_WINDOW_OPACITY' on frame or client windows. + +# Apply blur to terminals opacity-rule = [ - "90:class_g = 'Alacritty'", - "90:class_g = 'st-256color'", - "90:class_g = 'URxvt'", - "90:class_g = 'kitty'", - "90:class_g = 'tabbed'" + "100:name = 'Dunst'", + # Opacities with enabled shadows (shadows allow for higher alpha - lower number) + #"70:class_g = 'Alacritty'", + #"70:class_g = 'st-256color'", + #"70:class_g = 'URxvt'", + #"70:class_g = 'kitty'", + #"82:class_g = 'Spotify'" + # Opacities without shadows + "80:class_g = 'Alacritty'", + "80:class_g = 'st-256color'", + "80:class_g = 'URxvt'", + "80:class_g = 'kitty'", + "92:class_g = 'Spotify'" ]; -# Blur +# Default opacity for active windows. (0.0 - 1.0, defaults to 1.0) +active-opacity = 1; +# Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0) +inactive-opacity = 1; +# Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default) +frame-opacity = 1.0; +# Default opacity for dropdown menus and popup menus. (0.0 - 1.0, defaults to 1.0) +opacity = 1.0 +# Let inactive opacity set by -i override the '_NET_WM_OPACITY' values of windows. +inactive-opacity-override = false +# Dim inactive windows. (0.0 - 1.0, defaults to 0.0) +inactive-dim = 0.0 +# Use fixed inactive dim value, instead of adjusting according to window opacity. +inactive-dim-fixed = 1.0 +# Specify a list of conditions of windows that should always be considered focused. +focus-exclude = [] + + +# Background blurring +######################## + blur: { # dual_kawase blur method requires GLX as backend @@ -18,28 +177,113 @@ blur: # dual_kawase allows for multi-threaded bluring that's # very fast. method = "dual_kawase"; - strength = 1; + #method = "kernel"; + #kernel = "11x11gaussian"; + strength = 4; + deviation = 1.0; + # When true, blur background of semi-transparent / ARGB window. + background = false; + # When true, the background of windows when the window frame + # is not opaque is blurred, implies background=true + background-frame = false; + # Whe true, use fixeed blur strength rather than adjusing + # according to window opacity + background-fixed = false; + # Specify the blur convolution kernel + kern = "3x3box" } -wintypes: -{ - normal = { blur-background = true }; - splash = { blur-background = false }; -}; +# Exclude conditions for background blur +blur-background-exclude = [ + # Prevents picom from blurring the background + # when taking selection screenshot with `maim` + "class_g = 'slop'", + "_GTK_FRAME_EXTENTS@:c" +]; -# Fading + +# Shadows +################ + +# Enabled client-side shadows on windows. Note desktop windows +# (windows with '_NET_WM_WINDOW_TYPE_DESKTOP') never get shadow, +# unless explicitly requested using the wintypes option. +shadow = false; + +# The blur radius for shadows, in pixels. (defaults to 12) +shadow-radius = 12; +# The opacity of shadows. (0.0 - 1.0, defaults to 0.75) +shadow-opacity = 0.75; +# The left offset for shadows, in pixels. (defaults to -15) +shadow-offset-x = -15; +# The top offset for shadows, in pixels. (defaults to -15) +shadow-offset-y = -15; +# Red color value of shadow (0.0 - 1.0, defaults to 0). +shadow-red = 0 +# Green color value of shadow (0.0 - 1.0, defaults to 0). +shadow-green = 0 +# Blue color value of shadow (0.0 - 1.0, defaults to 0). +shadow-blue = 0 +# Crop shadow of a window fully on a particular Xinerama screen to the screen. +xinerama-shadow-crop = false + +# Specify a list of conditions of windows that should have no shadow. +shadow-exclude = [ + "name = 'Notification'", + "class_g = 'Conky'", + "class_g ?= 'Notify-osd'", + "class_g = 'Cairo-clock'", + "class_g = 'slop'", + "class_g = 'Polybar'", + "_GTK_FRAME_EXTENTS@:c" +]; + + +# Window Fading +################ + +# Fade windows in/out when opening/closing and when opacity changes, +# unless no-fading-openclose is used. fading = false; -fade-in-step = 0.07; -fade-out-step = 0.07; -fade-exclude = [ ]; -# GLX backend -# Use GLX as a backend instead of default xrender. -# GLX will generally be a lot faster than xrender. -# There shouldn't be any issues with this, but if you -# do experience any, you should try falling back to xrender. -backend = "glx"; -glx-no-stencil = true; -glx-copy-from-front = false; -use-damage = true -glx-no-rebind-pixmap = true; +# Opacity change between steps while fading in. (0.01 - 1.0, defaults to 0.028) +fade-in-step = 0.07; +# Opacity change between steps while fading out. (0.01 - 1.0, defaults to 0.03) +fade-out-step = 0.1; +# The time between steps in fade step, in milliseconds. (> 0, defaults to 10) +fade-delta = 10 +# Do not fade on window open/close. +no-fading-openclose = false +# Do not fade destroyed ARGB windows with WM frame. Workaround of bugs in Openbox, +# Fluxbox, etc. +no-fading-destroyed-argb = false + +# Specify a list of conditions of windows that should not be faded. +# don't need this, we disable fading for all normal windows with wintypes: {} +fade-exclude = [ + "class_g = 'slop'" # maim +] + + +# Corners +################ + +# Sets the radius of rounded window corners. When > 0, the compositor will +# round the corners of windows. +corner-radius = 12; +rounded-corners-exclude = [ + "class_g = 'Rofi'", + "class_g = 'dmenu'", + "name = 'Notification area'", + "name = 'Dunst'" +] + +# Rounded corners alone only changes the window, but the borders +# around it still remain rectangular, round-borders option allows +# the borders to also be round. +round-borders = 1; +# Specify a list of border width rules. +# format: "[pixels]:[xprop info name] = '[xprop value]'" +# Note this doesn't have any guarantee about not conflicting with the +# border width set by the window manager. +round-borders-rule = []; diff --git a/packages.yaml b/packages.yaml index c938966..3197d77 100644 --- a/packages.yaml +++ b/packages.yaml @@ -142,7 +142,8 @@ aur: - opensnitch # Application level firewall with traffic monitoring (Alternatively, there's portmaster) # WM/Xorg - - picom-git # Git version of picom compositor + #- picom-git # Git version of picom compositor + - picom-ibhagwan-git # Forked picom version with support for both rounded corner and dual_kawase blur - devour # WM agnostic window swallowing for terminals - xcursor-simp1e-breeze-snow # Breeze cursor theme From 61f619566a3c60be5477bef767702de811737315 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 20:54:36 +0100 Subject: [PATCH 118/188] Add buffer navigation mappings --- home/.config/nvim/lua/mappings.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index 60e881a..cba2b62 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -19,6 +19,12 @@ Keymap("n", "", ":tabmove +") Keymap("n", "", ":tabmove -") Keymap("n", "", ":tabp") Keymap("n", "", ":tabn") +Keymap("n", "", ":tabc") + +-- Buffer navigation +Keymap("n", "", ":bn") +Keymap("n", "", ":bp") +Keymap("n", "", ":bd") -- Set splits navigation to just ALT + hjkl Keymap("n", "", "h") From 950d19e1a0afef164dff34adb1c3b61df691ed4e Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 22:28:32 +0100 Subject: [PATCH 119/188] Rewrite plugin management configuration --- home/.config/nvim/lua/plugins.lua | 159 +++++++--------------- home/.config/nvim/lua/utility/plugins.lua | 122 +++++++++++++++++ 2 files changed, 174 insertions(+), 107 deletions(-) create mode 100644 home/.config/nvim/lua/utility/plugins.lua diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua index db505b3..4acce21 100644 --- a/home/.config/nvim/lua/plugins.lua +++ b/home/.config/nvim/lua/plugins.lua @@ -1,22 +1,8 @@ +local plugins = require("utility.plugins") local vim = require("vim") local cmd = vim.cmd -local api = vim.api local fn = vim.fn --- Automatically download (bootstrap) packer plugin manager --- if it's not already installed -local packer_install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" -local packer_bootstrap -if fn.empty(fn.glob(packer_install_path)) > 0 then - print("Installing packer plugin manager, please wait...") - packer_bootstrap = fn.system({ - 'git', 'clone', '--depth', '1', - 'https://github.com/wbthomason/packer.nvim', - packer_install_path - }) - print("Packer installed, reload vim to install plugins") -end - -- Automatically run :PackerCompile if plugins.lua is updated cmd[[ augroup packer_user_config @@ -25,100 +11,59 @@ augroup packer_user_config augroup end ]] --- Returns the line to be executed after plugin is loaded, this --- is useful for the `config` parameter of packer's use to --- source `.vim` files or require `.lua` files --- Expects a file path from pluginconf/ folder -local function get_plugin_file(pluginconf_file) - local filename, extension = pluginconf_file:match("^(.+)(%..+)$") - if (extension == ".vim") then - -- Source wants absolute path - local pluginconf_path = fn.stdpath("config") .. "lua/pluginconf" - local source_line = string.format('source "%s/%s"', pluginconf_path, pluginconf_file) - return string.format("vim.fn.execute('%s')", source_line) - else - -- Require wants relative path from lua/ - local pluginconf_path = "pluginconf" - return string.format('require("%s/%s")', pluginconf_path, filename) - end + +-- Extend plugins.get_plugin_file function and automatically pass a plugin_directory +-- into it. Expects a relative path to the plugin file settings from this directory +local function plug_cfg(plugin_file) + local plugin_directory = fn.stdpath("config") .. "lua/pluginconf" + plugins.get_plugin_file(plugin_file, plugin_directory) end --- Make sure to add packer here, even if it's opt -api.nvim_command("packadd packer.nvim") -- Define packer plugins -return require("packer").startup({ - function(use) - use("wbthomason/packer.nvim") - use('airblade/vim-gitgutter') - use('dhruvasagar/vim-table-mode') - use('tmhedberg/SimpylFold') - use('wakatime/vim-wakatime') - use('mhinz/vim-startify') - use('ryanoasis/vim-devicons') - use({ - "tomasiser/vim-code-dark", - config = get_plugin_file("vim-code-dark.lua"), - }) - use({ - "vim-airline/vim-airline", - config = get_plugin_file("airline.lua"), - requires = { "vim-airline/vim-airline-themes", opt = true }, - }) - use({ - "preservim/nerdtree", - config = get_plugin_file("nerdtree.lua"), - requires = { - { "Xuyuanp/nerdtree-git-plugin", opt = true }, - { "tiagofumo/vim-nerdtree-syntax-highlight", opt = true }, - }, - }) - use({ - "vimwiki/vimwiki", - config = get_plugin_file("vimwiki.lua") - }) - use({ - "sheerun/vim-polyglot", - setup = get_plugin_file("polyglot.lua") - }) - use({ - "tpope/vim-commentary", - config = get_plugin_file("commentary.lua") - }) - use({ - "mfussenegger/nvim-dap", - config = get_plugin_file("nvim-dap.lua"), - requires = { "mfussenegger/nvim-dap-python", opt = true }, - }) - use({ - "junegunn/fzf", - run = function() fn['fzf#install']() end, - }) - use({ - "junegunn/fzf.vim", - config = get_plugin_file("fzf.lua"), - after = "fzf", - requires = { "stsewd/fzf-checkout.vim", opt = true }, - }) - use({ - "neoclide/coc.nvim", - branch = "release", - config = get_plugin_file("coc.vim"), - requires = { "antoinemadec/coc-fzf", opt = true }, - }) +local plugin_configs = { + { "airblade/vim-gitgutter" }, + { "dhruvasagar/vim-table-mode" }, + { "tmhedberg/SimpylFold" }, + { "wakatime/vim-wakatime" }, + { "mhinz/vim-startify" }, + { "ryanoasis/vim-devicons" }, + { "vimwiki/vimwiki", config = plug_cfg("vimwiki.lua") }, + { "sheerun/vim-polyglot", setup = plug_cfg("polyglot.lua") }, + { "tpope/vim-commentary", config = plug_cfg("commentary.lua") }, + { "junegunn/fzf", run = function() fn['fzf#install']() end }, + { "tomasiser/vim-code-dark", config = plug_cfg("vim-code-dark.lua") }, + { + "vim-airline/vim-airline", + config = plug_cfg("airline.lua"), + requires = { "vim-airline/vim-airline-themes", opt = true }, + }, + { + "preservim/nerdtree", + config = plug_cfg("nerdtree.lua"), + requires = { + { "Xuyuanp/nerdtree-git-plugin", opt = true }, + { "tiagofumo/vim-nerdtree-syntax-highlight", opt = true }, + }, + }, + { + "mfussenegger/nvim-dap", + config = plug_cfg("nvim-dap.lua"), + requires = { "mfussenegger/nvim-dap-python", opt = true }, + }, + { + "junegunn/fzf.vim", + config = plug_cfg("fzf.lua"), + after = "fzf", + requires = { "stsewd/fzf-checkout.vim", opt = true }, + }, + { + "neoclide/coc.nvim", + branch = "release", + config = plug_cfg("coc.vim"), + requires = { "antoinemadec/coc-fzf", opt = true }, + }, +} - -- Run sync if we've just bootstrapped packer - if packer_bootstrap then - require("packer").sync() - end - end, - config = { - display = { - open_fn = require('packer.util').float, - }, - profile = { - enable = true, - threshold = 1, -- the amount in ms that a plugins load time must be over for it to be included in the profile - }, - } -}) +-- Set up packer and use given plugins +plugins.packer_setup(plugin_configs) diff --git a/home/.config/nvim/lua/utility/plugins.lua b/home/.config/nvim/lua/utility/plugins.lua new file mode 100644 index 0000000..62e5de3 --- /dev/null +++ b/home/.config/nvim/lua/utility/plugins.lua @@ -0,0 +1,122 @@ +local vim = require("vim") +local cmd = vim.cmd +local api = vim.api +local fn = vim.fn + +-- This module contains several functions regarding packer plugin manager +-- Most notably the get_plugin_file and packer_setup fucntions +local M = {} + +-- Drectory containing the individual plugin configuration files. +-- File to hold the compiled packer binary +M.packer_compiled_path = fn.stdpath("config") .. "plugin/packer_compiled.lua" + +-- Return the line (string) to be executed with lua that loads in given plugin file. +-- This is useful for the `config` or `setup` parameters of packer's use to either +-- source `.vim` files, or require `.lua` files. +-- Expects a `plugin_file` which is a relative path from the `plugin_directory` folder. +function M.get_plugin_file(plugin_file, plugin_directory) + local filename, extension = plugin_file:match("^(.+)(%..+)$") + if (extension == ".vim") then + local source_line = string.format('source "%s/%s"', plugin_directory, plugin_file) + return string.format("vim.fn.execute('%s')", source_line) + else + return string.format('require("%s/%s")', plugin_directory, filename) + end +end + +-- Download packer plugin manager in case it isn't already installed +function M.packer_bootstrap() + local first_install = false + local present, packer = pcall(require, "packer") + if not present then + local packer_install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" + print("Clonning pakcer plugin manager, please wait...") + -- First remove the directory in case it already exists but packer isn't present + fn.delete(packer_install_path, "rf") + fn.system({ + "git", "clone", "--depth", "1", + "https://github.com/wbthomason/packer.nvim", + packer_install_path + }) + + -- Make sure packer was installed properly + cmd("packadd packer.nvim") + present, packer = pcall(require, "packer") + + if present then + print("Packer clonned successfully.") + first_install = true + else + print("Couldn't clone packer! Packer path: " .. packer_install_path .. "\n" .. packer) + end + end + + return { present = present, first_install = first_install, packer = packer } +end + +-- Initialize packer with our desired configuration +-- If packer isn't instaleld, this also performs the installation +function M.packer_init() + local details = M.packer_bootstrap() + -- Only continue if we actually managed to install packer + if not details.present then + return details + end + + details.packer.init({ + display = { + open_fn = function() + return require('packer.util').float({ border = "rounded" }) + end, + prompt_border = "rounded", + }, + git = { + -- Timeout for git clones in seconds + clone_timeout = 600, + }, + profile = { + enable = true, + -- The time that a pluign's load time must surpass for it to be included + -- in the profile (in miliseconds) + threshold = 1, + }, + compile_path = M.packer_compiled_path, + }) + + return details +end + +-- Run packer's setup function and define all of the used plugins +-- Expects table/list of tables holding the individual plugin settings +function M.packer_setup(plugin_configs) + local details = M.packer_init() + if not details.present then + return false + end + + local packer = details.packer + local use = packer.use + local first_install = details.first_install + + -- Make sure to add packer here, even if it's opt + api.nvim_command("packadd packer.nvim") + + return packer.startup(function() + -- We always want to let packer manage itself + use("wbthomason/packer.nvim") + + -- Load the obtained plugins (in any) + if plugin_configs and not vim.tbl_isempty(plugin_configs) then + for _, plugin in pairs(plugin_configs) do + use(plugin) + end + end + + if first_install then + packer.sync() + end + end) +end + +return M From 768764a899b7a2f96b5bf943eb0a0691ff0ceed1 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 6 Dec 2021 22:49:03 +0100 Subject: [PATCH 120/188] Use utility module for keymap/abbrev functions --- home/.config/nvim/init.lua | 23 ----- home/.config/nvim/lua/abbreviations.lua | 31 ++----- home/.config/nvim/lua/mappings.lua | 93 ++++++++++--------- .../nvim/lua/pluginconf/commentary.lua | 5 +- home/.config/nvim/lua/pluginconf/fzf.lua | 15 +-- home/.config/nvim/lua/pluginconf/nerdtree.lua | 5 +- home/.config/nvim/lua/pluginconf/nvim-dap.lua | 25 ++--- home/.config/nvim/lua/utility/mappings.lua | 29 ++++++ 8 files changed, 110 insertions(+), 116 deletions(-) create mode 100644 home/.config/nvim/lua/utility/mappings.lua diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua index 2af840f..e254098 100644 --- a/home/.config/nvim/init.lua +++ b/home/.config/nvim/init.lua @@ -1,26 +1,3 @@ -local vim = require("vim") -local fn = vim.fn - --- Define some global functions which can then be called --- in the other required scripts - --- Load an arbitrary .vim or .lua file -function LoadFile(file_path) - local extension = file_path:match("^.+(%..+)$") - local run_cmd - if (extension == ".vim") then run_cmd = "source" else run_cmd = "luafile" end - fn.execute(run_cmd .. " " .. file_path) -end - --- Define a key mapping -function Keymap(mode, shortcut, command, options) - -- Assume silent, noremap unless specified otherwise - local opts = {noremap=true, silent=true} - - if options then opts = vim.tbl_extend("force", opts, options) end - vim.api.nvim_set_keymap(mode, shortcut, command, opts) -end - -- Require additional scripts which contain individual configurations require "options" diff --git a/home/.config/nvim/lua/abbreviations.lua b/home/.config/nvim/lua/abbreviations.lua index 2438046..95cb0e1 100644 --- a/home/.config/nvim/lua/abbreviations.lua +++ b/home/.config/nvim/lua/abbreviations.lua @@ -1,27 +1,9 @@ local vim = require("vim") -local cmd = vim.cmd +local fn = vim.fn +local m = require("utility.mappings") --- I'm not aware of abbreviations having direct lua support like mappings, --- though I'm not certain on that and may be completely wrong, if there is --- a better way, this is opened to pull requests. --- TODO: Check direct abbrev lua support - --- Make these function definitions global as they could be reused --- in plugin specific scripts or in other places. -function abbrev(mode, input, result, reabbrev) - -- Assume noreabbrev unless specified otherwise - reabbrev = reabbrev or false - local command - if reabbrev then - command = mode .. "abbrev" - else - command = mode .. "noreabbrev" - end - cmd(command .. " " .. input .. " " .. result) -end - -function cabbrev(input, result, reabbrev) - abbrev("c", input, result, reabbrev) +local function cabbrev(input, result, reabbrev) + m.abbrev("c", input, result, reabbrev) end -- Invalid case abbreviations @@ -40,6 +22,5 @@ cabbrev("Qall!", "qall!") cabbrev("w!!", "w !sudo tee > /dev/null %") -- Reload lua configuration --- TODO: Get the path dynamically -cabbrev("reload", "luafile ~/.config/nvim/init.lua") - +local initlua = fn.stdpath("config") .. "init.lua" +cabbrev("reload", "luafile " .. initlua) diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/mappings.lua index cba2b62..a35c434 100644 --- a/home/.config/nvim/lua/mappings.lua +++ b/home/.config/nvim/lua/mappings.lua @@ -1,3 +1,4 @@ +local m = require("utility.mappings") local vim = require("vim") local g = vim.g @@ -6,86 +7,86 @@ local g = vim.g g.mapleader = "\\" -- Unmap arrow keys in normal mode to remove bad habits -Keymap("n", "", "") -Keymap("n", "", "") -Keymap("n", "", "") -Keymap("n", "", "") +m.keymap("n", "", "") +m.keymap("n", "", "") +m.keymap("n", "", "") +m.keymap("n", "", "") -- Tab navigation -Keymap("n", "", "gt") -Keymap("n", "", "gT") -Keymap("n", "", ":tabnew") -Keymap("n", "", ":tabmove +") -Keymap("n", "", ":tabmove -") -Keymap("n", "", ":tabp") -Keymap("n", "", ":tabn") -Keymap("n", "", ":tabc") +m.keymap("n", "", "gt") +m.keymap("n", "", "gT") +m.keymap("n", "", ":tabnew") +m.keymap("n", "", ":tabmove +") +m.keymap("n", "", ":tabmove -") +m.keymap("n", "", ":tabp") +m.keymap("n", "", ":tabn") +m.keymap("n", "", ":tabc") -- Buffer navigation -Keymap("n", "", ":bn") -Keymap("n", "", ":bp") -Keymap("n", "", ":bd") +m.keymap("n", "", ":bn") +m.keymap("n", "", ":bp") +m.keymap("n", "", ":bd") -- Set splits navigation to just ALT + hjkl -Keymap("n", "", "h") -Keymap("n", "", "j") -Keymap("n", "", "k") -Keymap("n", "", "l") +m.keymap("n", "", "h") +m.keymap("n", "", "j") +m.keymap("n", "", "k") +m.keymap("n", "", "l") -- Split size adjusting -Keymap("n", "", ":vertical resize +3") -Keymap("n", "", ":vertical resize -3") -Keymap("n", "", ":resize +3") -Keymap("n", "", ":resize -3") +m.keymap("n", "", ":vertical resize +3") +m.keymap("n", "", ":vertical resize -3") +m.keymap("n", "", ":resize +3") +m.keymap("n", "", ":resize -3") -- Define some common shortcuts -Keymap("n", "", ":w") -Keymap("i", "", ":wi") -Keymap("n", "", ":undo") -Keymap("n", "", ":redo") +m.keymap("n", "", ":w") +m.keymap("i", "", ":wi") +m.keymap("n", "", ":undo") +m.keymap("n", "", ":redo") -- Terminal -Keymap("n", "", ":split term://zsh:resize -7i") -Keymap("n", "", ":vnew term://zshi") -Keymap("n", "", ":tabnew term://zshi") -Keymap("t", "", "") +m.keymap("n", "", ":split term://zsh:resize -7i") +m.keymap("n", "", ":vnew term://zshi") +m.keymap("n", "", ":tabnew term://zshi") +m.keymap("t", "", "") -- Use space for folding/unfolding sections -Keymap("n", "", "za") -Keymap("v", "", "zf") +m.keymap("n", "", "za") +m.keymap("v", "", "zf") -- Use shift to quickly move 10 lines up/down -Keymap("n", "K", "10k") -Keymap("n", "J", "10j") +m.keymap("n", "K", "10k") +m.keymap("n", "J", "10j") -- Enable/Disable auto commenting -Keymap("n", "c", ":setlocal formatoptions-=cro") -Keymap("n", "C", ":setlocal formatoptions+=cro") +m.keymap("n", "c", ":setlocal formatoptions-=cro") +m.keymap("n", "C", ":setlocal formatoptions+=cro") -- Don't leave visual mode after indenting -Keymap("v", "<", "", ">gv") +m.keymap("v", "<", "", ">gv") -- System clipboard copying -Keymap("v", "", '"+y') +m.keymap("v", "", '"+y') -- Alias replace all -Keymap("n", "", ":%s//gI", {silent=false}) +m.keymap("n", "", ":%s//gI", {silent=false}) -- Stop search highlight with Esc -Keymap("n", "", ":noh") +m.keymap("n", "", ":noh") -- Start spell-check -Keymap("n", "s", ":setlocal spell! spelllang=en_us") +m.keymap("n", "s", ":setlocal spell! spelllang=en_us") -- Run shell check -Keymap("n", "p", ":!shellckeck %") +m.keymap("n", "p", ":!shellckeck %") -- Compile opened file (using custom script) -Keymap("n", "", ":w | !comp %") +m.keymap("n", "", ":w | !comp %") -- Close all opened buffers -Keymap("n", "Q", ":bufdo bdelete") +m.keymap("n", "Q", ":bufdo bdelete") -- Don't set the incredibely annoying mappings that trigger dynamic SQL -- completion with dbext and keeps on freezing vim whenever pressed with diff --git a/home/.config/nvim/lua/pluginconf/commentary.lua b/home/.config/nvim/lua/pluginconf/commentary.lua index 69e80f8..6a1f92e 100644 --- a/home/.config/nvim/lua/pluginconf/commentary.lua +++ b/home/.config/nvim/lua/pluginconf/commentary.lua @@ -1,9 +1,10 @@ +local m = require("utility.mappings") local vim = require("vim") local cmd = vim.cmd -- Set up shortcuts to quickly comment some code -Keymap("n", "", ":Commentary") -Keymap("v", "", ":Commentary") +m.keymap("n", "", ":Commentary") +m.keymap("v", "", ":Commentary") -- Set up comments for unhandled file types cmd[[autocmd FileType apache setlocal commentstring=#\ %s]] diff --git a/home/.config/nvim/lua/pluginconf/fzf.lua b/home/.config/nvim/lua/pluginconf/fzf.lua index e520c6e..5cd78d0 100644 --- a/home/.config/nvim/lua/pluginconf/fzf.lua +++ b/home/.config/nvim/lua/pluginconf/fzf.lua @@ -1,3 +1,4 @@ +local m = require("utility.mappings") local vim = require("vim") local cmd = vim.cmd local g = vim.g @@ -26,10 +27,10 @@ command! -bang -nargs=? -complete=dir AllFiles \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore' }), 0)) ]] -Keymap("n", "f", ":Files") -Keymap("n", "F", ":AllFiles") -Keymap("n", "b", ":Buffers") -Keymap("n", "h", ":History") -Keymap("n", "r", ":Rg") -Keymap("n", "R", ":Rg", { silent = false }) -Keymap("n", "gb", ":GBranches") +m.keymap("n", "f", ":Files") +m.keymap("n", "F", ":AllFiles") +m.keymap("n", "b", ":Buffers") +m.keymap("n", "h", ":History") +m.keymap("n", "r", ":Rg") +m.keymap("n", "R", ":Rg", { silent = false }) +m.keymap("n", "gb", ":GBranches") diff --git a/home/.config/nvim/lua/pluginconf/nerdtree.lua b/home/.config/nvim/lua/pluginconf/nerdtree.lua index 47e7183..5ea4d21 100644 --- a/home/.config/nvim/lua/pluginconf/nerdtree.lua +++ b/home/.config/nvim/lua/pluginconf/nerdtree.lua @@ -1,3 +1,4 @@ +local m = require("utility.mappings") local vim = require("vim") local g = vim.g local fn = vim.fn @@ -5,7 +6,7 @@ local cmd = vim.cmd -- Implement manual NERDTreeToggle, but use NERDTreeFind for openning. -- This makes NERDTree open with the current file pre-selected -Keymap("n", "", "g:NERDTree.IsOpen() ? ':NERDTreeClose' : @% == '' ? ':NERDTree' : ':NERDTreeFind'", {expr=true}) +m.keymap("n", "", "g:NERDTree.IsOpen() ? ':NERDTreeClose' : @% == '' ? ':NERDTree' : ':NERDTreeFind'", {expr=true}) g.NERDTreeShowHidden = 1 g.NERDTreeMinimalUI = 1 @@ -31,6 +32,8 @@ autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in ]] -- Exit Vim if NERDTree is the only window left. +-- WARNING: This causes issues when closing buffers +--[[ cmd[[ autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | \ quit | endif diff --git a/home/.config/nvim/lua/pluginconf/nvim-dap.lua b/home/.config/nvim/lua/pluginconf/nvim-dap.lua index 84f8167..ef597ff 100644 --- a/home/.config/nvim/lua/pluginconf/nvim-dap.lua +++ b/home/.config/nvim/lua/pluginconf/nvim-dap.lua @@ -1,17 +1,18 @@ +local m = require("utility.mappings") local vim = require("vim") local cmd = vim.cmd -- Define dap mappings (:help dap-mapping) local prefix = ":lua require('dap')." -Keymap("n", "", prefix .. "continue()") -Keymap("n", "", prefix .. "step_over()") -Keymap("n", "", prefix .. "step_into()") -Keymap("n", "", prefix .. "step_out()") -Keymap("n", "", prefix .. "toggle_breakpoint()") -Keymap("n", "", prefix .. "set_breakpoint(vim.fn.input('Breakpoint condition: '))") -Keymap("n", "", prefix .. "set_breakpoint(nil, nil, vim.fn.input('Log point message: '))") -Keymap("n", "di", prefix .. "repl.open()") -Keymap("n", "dl", prefix .. "run_last()") +m.keymap("n", "", prefix .. "continue()") +m.keymap("n", "", prefix .. "step_over()") +m.keymap("n", "", prefix .. "step_into()") +m.keymap("n", "", prefix .. "step_out()") +m.keymap("n", "", prefix .. "toggle_breakpoint()") +m.keymap("n", "", prefix .. "set_breakpoint(vim.fn.input('Breakpoint condition: '))") +m.keymap("n", "", prefix .. "set_breakpoint(nil, nil, vim.fn.input('Log point message: '))") +m.keymap("n", "di", prefix .. "repl.open()") +m.keymap("n", "dl", prefix .. "run_last()") -- Setup dap for python (requires nvim-dap-python plugin) require('dap-python').setup('/usr/bin/python') -- Path to python with `debugpy` library installed @@ -19,6 +20,6 @@ require('dap-python').test_runner = 'pytest' -- Use pytest to run unit tests -- Python mappings local pyprefix = ":lua require('dap-python')." -Keymap("n", "dptm", pyprefix .. "test_method()") -Keymap("n", "dptc", pyprefix .. "test_class()") -Keymap("v", "ds", "" .. pyprefix .. "debug_selection()") +m.keymap("n", "dptm", pyprefix .. "test_method()") +m.keymap("n", "dptc", pyprefix .. "test_class()") +m.keymap("v", "ds", "" .. pyprefix .. "debug_selection()") diff --git a/home/.config/nvim/lua/utility/mappings.lua b/home/.config/nvim/lua/utility/mappings.lua new file mode 100644 index 0000000..6d18a7e --- /dev/null +++ b/home/.config/nvim/lua/utility/mappings.lua @@ -0,0 +1,29 @@ +local vim = require("vim") +local api = vim.api +local cmd = vim.cmd + +local M = {} + +-- Define a keymap +function M.keymap(mode, shortcut, command, options) + -- Assume silent, noremap unless specified otherwise + local opts = {noremap=true, silent=true} + + if options then opts = vim.tbl_extend("force", opts, options) end + api.nvim_set_keymap(mode, shortcut, command, opts) +end + +-- Define an abbreviation +function M.abbrev(mode, input, result, reabbrev) + -- Assume noreabbrev unless specified otherwise + reabbrev = reabbrev or false + local command + if reabbrev then + command = mode .. "abbrev" + else + command = mode .. "noreabbrev" + end + cmd(command .. " " .. input .. " " .. result) +end + +return M From 9c8191bfa76dcb9116494366034618f071447810 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 7 Dec 2021 22:13:22 +0100 Subject: [PATCH 121/188] Move non-plugin settings to core/ --- home/.config/nvim/init.lua | 17 +++++++++++------ .../nvim/lua/{ => core}/abbreviations.lua | 0 home/.config/nvim/lua/{ => core}/autocmd.lua | 0 home/.config/nvim/lua/core/init.lua | 7 +++++++ home/.config/nvim/lua/{ => core}/mappings.lua | 0 home/.config/nvim/lua/{ => core}/options.lua | 0 home/.config/nvim/lua/{ => core}/theme.lua | 0 7 files changed, 18 insertions(+), 6 deletions(-) rename home/.config/nvim/lua/{ => core}/abbreviations.lua (100%) rename home/.config/nvim/lua/{ => core}/autocmd.lua (100%) create mode 100644 home/.config/nvim/lua/core/init.lua rename home/.config/nvim/lua/{ => core}/mappings.lua (100%) rename home/.config/nvim/lua/{ => core}/options.lua (100%) rename home/.config/nvim/lua/{ => core}/theme.lua (100%) diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua index e254098..e562985 100644 --- a/home/.config/nvim/init.lua +++ b/home/.config/nvim/init.lua @@ -1,8 +1,13 @@ --- Require additional scripts which contain individual configurations +-- The configuration is scattered across multiple files in the lua/ folder +-- We can require the individual configurations from here -require "options" -require "theme" -require "mappings" -require "abbreviations" -require "autocmd" + +-- This loads in the basic nvim configuration that doesn't rely on any +-- plugins. it provides default keymaps, options, theming, autocmds, ... +require "core" + +-- This loads packer plugin manager which manages our plugins +-- NOTE: Removing this will NOT disable the plugins, but it will disable +-- automatic packer installation, allowing for the plugins to be deleted +-- manually (from ~/.local/share/nvim/site/pack/packer). require "plugins" diff --git a/home/.config/nvim/lua/abbreviations.lua b/home/.config/nvim/lua/core/abbreviations.lua similarity index 100% rename from home/.config/nvim/lua/abbreviations.lua rename to home/.config/nvim/lua/core/abbreviations.lua diff --git a/home/.config/nvim/lua/autocmd.lua b/home/.config/nvim/lua/core/autocmd.lua similarity index 100% rename from home/.config/nvim/lua/autocmd.lua rename to home/.config/nvim/lua/core/autocmd.lua diff --git a/home/.config/nvim/lua/core/init.lua b/home/.config/nvim/lua/core/init.lua new file mode 100644 index 0000000..2eba0e8 --- /dev/null +++ b/home/.config/nvim/lua/core/init.lua @@ -0,0 +1,7 @@ +-- Require additional scripts which contain individual configurations + +require "core.options" +require "core.theme" +require "core.mappings" +require "core.abbreviations" +require "core.autocmd" diff --git a/home/.config/nvim/lua/mappings.lua b/home/.config/nvim/lua/core/mappings.lua similarity index 100% rename from home/.config/nvim/lua/mappings.lua rename to home/.config/nvim/lua/core/mappings.lua diff --git a/home/.config/nvim/lua/options.lua b/home/.config/nvim/lua/core/options.lua similarity index 100% rename from home/.config/nvim/lua/options.lua rename to home/.config/nvim/lua/core/options.lua diff --git a/home/.config/nvim/lua/theme.lua b/home/.config/nvim/lua/core/theme.lua similarity index 100% rename from home/.config/nvim/lua/theme.lua rename to home/.config/nvim/lua/core/theme.lua From 7bfad9cb091303fe540f138f533463aeacefa270 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 7 Dec 2021 22:13:59 +0100 Subject: [PATCH 122/188] Set the colorscheme to default in theme - We want to do this to activate the autocommands which modify certain highlight styles. This colorscheme will be set to the proper one from the plugin configuration anyway, which will override this, but in case that plugin is no longer desired, we want to have some default there. --- home/.config/nvim/lua/core/theme.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/home/.config/nvim/lua/core/theme.lua b/home/.config/nvim/lua/core/theme.lua index 1ef4283..b2628c5 100644 --- a/home/.config/nvim/lua/core/theme.lua +++ b/home/.config/nvim/lua/core/theme.lua @@ -32,6 +32,10 @@ augroup coloroverride augroup END ]] +-- Set the colorscheme to default to trigger the above autocmds +-- This can be overridden from plugin definitions as this file is ran before those +cmd[[colorscheme default]] + -- Don't use true colors in TTY o.termguicolors = os.getenv("DISPLAY") and true or false From b2214eb7af29085dddbd27f1dc3b5b5da6d90862 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 7 Dec 2021 22:16:00 +0100 Subject: [PATCH 123/188] Remove unused local --- home/.config/nvim/lua/pluginconf/polyglot.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/home/.config/nvim/lua/pluginconf/polyglot.lua b/home/.config/nvim/lua/pluginconf/polyglot.lua index b9b9187..53cb6c3 100644 --- a/home/.config/nvim/lua/pluginconf/polyglot.lua +++ b/home/.config/nvim/lua/pluginconf/polyglot.lua @@ -1,5 +1,4 @@ local vim = require("vim") -local cmd = vim.cmd local g = vim.g -- Disable polyglot's "sensible" settings, while there are some nice things it From 8350dc7926b23b57bfcac7803b5454e5de8c393f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 7 Dec 2021 22:17:56 +0100 Subject: [PATCH 124/188] Rewrite entire plugin management system - This encapsulates all plugin related functionalities into the plugins/ folder (and pluginconfig/) instead of relying on utility file. - It also renames utility/plugins.lua to a more sensible plugins/packer.lua as it actually only applies for packer plugin manager. - The plugins.lua file is now split into 2 files, first holding the list of all plugins plugins/plugin_list.lua and second one holding the logic of bootstrapping and running startup on packer. --- home/.config/nvim/lua/plugins.lua | 69 ---------- home/.config/nvim/lua/plugins/init.lua | 36 ++++++ home/.config/nvim/lua/plugins/packer.lua | 114 ++++++++++++++++ home/.config/nvim/lua/plugins/plugin_list.lua | 62 +++++++++ home/.config/nvim/lua/utility/plugins.lua | 122 ------------------ 5 files changed, 212 insertions(+), 191 deletions(-) delete mode 100644 home/.config/nvim/lua/plugins.lua create mode 100644 home/.config/nvim/lua/plugins/init.lua create mode 100644 home/.config/nvim/lua/plugins/packer.lua create mode 100644 home/.config/nvim/lua/plugins/plugin_list.lua delete mode 100644 home/.config/nvim/lua/utility/plugins.lua diff --git a/home/.config/nvim/lua/plugins.lua b/home/.config/nvim/lua/plugins.lua deleted file mode 100644 index 4acce21..0000000 --- a/home/.config/nvim/lua/plugins.lua +++ /dev/null @@ -1,69 +0,0 @@ -local plugins = require("utility.plugins") -local vim = require("vim") -local cmd = vim.cmd -local fn = vim.fn - --- Automatically run :PackerCompile if plugins.lua is updated -cmd[[ -augroup packer_user_config - autocmd! - autocmd BufWritePost ~/.config/nvim/lua/plugins.lua source | PackerCompile -augroup end -]] - - --- Extend plugins.get_plugin_file function and automatically pass a plugin_directory --- into it. Expects a relative path to the plugin file settings from this directory -local function plug_cfg(plugin_file) - local plugin_directory = fn.stdpath("config") .. "lua/pluginconf" - plugins.get_plugin_file(plugin_file, plugin_directory) -end - - --- Define packer plugins -local plugin_configs = { - { "airblade/vim-gitgutter" }, - { "dhruvasagar/vim-table-mode" }, - { "tmhedberg/SimpylFold" }, - { "wakatime/vim-wakatime" }, - { "mhinz/vim-startify" }, - { "ryanoasis/vim-devicons" }, - { "vimwiki/vimwiki", config = plug_cfg("vimwiki.lua") }, - { "sheerun/vim-polyglot", setup = plug_cfg("polyglot.lua") }, - { "tpope/vim-commentary", config = plug_cfg("commentary.lua") }, - { "junegunn/fzf", run = function() fn['fzf#install']() end }, - { "tomasiser/vim-code-dark", config = plug_cfg("vim-code-dark.lua") }, - { - "vim-airline/vim-airline", - config = plug_cfg("airline.lua"), - requires = { "vim-airline/vim-airline-themes", opt = true }, - }, - { - "preservim/nerdtree", - config = plug_cfg("nerdtree.lua"), - requires = { - { "Xuyuanp/nerdtree-git-plugin", opt = true }, - { "tiagofumo/vim-nerdtree-syntax-highlight", opt = true }, - }, - }, - { - "mfussenegger/nvim-dap", - config = plug_cfg("nvim-dap.lua"), - requires = { "mfussenegger/nvim-dap-python", opt = true }, - }, - { - "junegunn/fzf.vim", - config = plug_cfg("fzf.lua"), - after = "fzf", - requires = { "stsewd/fzf-checkout.vim", opt = true }, - }, - { - "neoclide/coc.nvim", - branch = "release", - config = plug_cfg("coc.vim"), - requires = { "antoinemadec/coc-fzf", opt = true }, - }, -} - --- Set up packer and use given plugins -plugins.packer_setup(plugin_configs) diff --git a/home/.config/nvim/lua/plugins/init.lua b/home/.config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..d93a202 --- /dev/null +++ b/home/.config/nvim/lua/plugins/init.lua @@ -0,0 +1,36 @@ +local vim = require("vim") +local packer_m = require("plugins.packer") + +-- Require packer_compiled to lazy-load all of the plugins and their settings +-- automatically. If this fails, it means we probably didn't yet compile +-- packer. This file is generated upon running :PackerCompile, so if we didn't +-- find it, we inform the user to run it. We can't run it here directly, +-- because packer may not yet be installed, bootstrapping happens only after +-- this to allow this lazy loadning behavior. If we required packer before +-- this, the lazy-loading would have no effect. +local packer_compiled_ok, _ = pcall(require, "compiled.packer_compiled") +if not packer_compiled_ok then + vim.notify( + "Run :PackerCompile or :PackerSync", + vim.log.levels.WARN, + { title = "Notification" } + ) +end + +-- If packer isn't present, install it automatically it +local present, packer = pcall(require, "packer") + +local first_install = false +if not present then + first_install = packer_m.bootstrap_packer() + if first_install then + -- We know this will work now that packer was bootstrapped + -- Otherwise we'd receive false in first_install + ---@diagnostic disable-next-line:different-requires + packer = require("packer") + end +end + +-- Obtain the plugins defined in plugin_list.ua +local plugin_list = require("plugins.plugin_list") +packer_m.startup(packer, plugin_list, first_install) diff --git a/home/.config/nvim/lua/plugins/packer.lua b/home/.config/nvim/lua/plugins/packer.lua new file mode 100644 index 0000000..624b663 --- /dev/null +++ b/home/.config/nvim/lua/plugins/packer.lua @@ -0,0 +1,114 @@ +local vim = require("vim") +local cmd = vim.cmd +local fn = vim.fn + +local M = {} + +-- Define some paths used in the functions +M.packer_install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" +M.packer_compile_path = fn.stdpath("config") .. "/lua/compiled/packer_compiled.lua" + +-- Define basic default settings for packer +M.packer_settings = { + display = { + open_fn = function() + return require('packer.util').float({ border = "rounded" }) + end, + prompt_border = "rounded", + }, + git = { + -- Timeout for git clones in seconds + clone_timeout = 600, + }, + profile = { + enable = true, + -- The time that a pluign's load time must surpass for it to be included + -- in the profile (in miliseconds) + threshold = 1, + }, + compile_path = M.packer_compile_path, + auto_clean = true, + compile_on_sync = true +} + +-- Define default plugins which should always be used +M.default_plugin_list = { + -- Let packer manager itself, so that it gets updates + { "wbthomason/packer.nvim" }, + + -- Add plugin for speeding up `require` in lua by caching + --{ "lewis6991/impatient.nvim" }, + + -- Replaces default filetype.vim sourced on startup, which includes + -- 800+ autocommands setting the filetype based on the filename. This + -- is very slow and this plugin merges them into single autocommand, + -- which is 175x faster, improving startup time + --{ "nathom/filetype.nvim" }, +} + +-- Download and load packer plugin manager +function M.bootstrap_packer() + print("Clonning pakcer plugin manager, please wait...") + -- First remove the directory in case it already exists but packer isn't present + fn.delete(M.packer_install_path, "rf") + fn.system({ + "git", "clone", "--depth", "1", + "https://github.com/wbthomason/packer.nvim", + M.packer_install_path + }) + + -- Add packer plugin via nvim's internal plugin system + -- and make sure that we can now require it. + cmd("packadd packer.nvim") + local present, packer = pcall(require, "packer") + if present then + print("Packer clonned successfully.") + return true + else + print("Couldn't clone packer! Packer path: " .. M.packer_install_path .. "\n" .. packer) + return false + end +end + +-- Run packer startup with the default config and given plugin settings +-- Expects: `packer`, `plugin_list`, `run_sync`, `settings_override` +function M.startup(packer, plugin_list, run_sync, settings_override) + -- Initialize packer with default settings extended by + -- the given settings override + local settings = M.packer_settings + if settings_override then + settings = vim.tbl_extend("foce", settings, settings_override) + end + packer.reset() + packer.init(settings) + + -- Run packer startup and use all given plugins with their settings + -- including the default plugins + local use = packer.use + return packer.startup(function() + -- Use the default plugins (should be first) + for _, plugin_settings in pairs(M.default_plugin_list) do + use(plugin_settings) + end + + -- Use the obtained plugins + if plugin_list and not vim.tbl_isempty(plugin_list) then + for _, plugin_settings in pairs(plugin_list) do + use(plugin_settings) + end + end + + -- We can also automatically run sync to install all specified plugins + -- immediately, this is useful if we've just bootstrapped packer. + if run_sync then + vim.notify( + "Make sure to restart after packer sync!", + vim.log.levels.WARN, + { title = "Notification" } + ) + packer.sync() + end + end) +end + +return M diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua new file mode 100644 index 0000000..046eab0 --- /dev/null +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -0,0 +1,62 @@ +local vim = require("vim") +local fn = vim.fn + +local plugin_directory = fn.stdpath("config") .. "/lua/pluginconf" + +-- Return the line (string) to be executed with lua that loads in given plugin file. +-- This is useful for the `config` or `setup` parameters of packer's use to source +-- both `.vim` and `.lua` files. +-- Expects a `plugin_file` which is a relative path from the `plugin_directory` folder. +local function get_plugin_file(plugin_file) + local source_line = string.format('source %s/%s', plugin_directory, plugin_file) + return string.format("vim.fn.execute('%s')", source_line) +end + + +-- Define packer plugins +-- The individual tables will get passed into the packer's use function +local plugin_list = { + { "airblade/vim-gitgutter" }, + { "dhruvasagar/vim-table-mode" }, + { "tmhedberg/SimpylFold" }, + { "wakatime/vim-wakatime" }, + { "mhinz/vim-startify" }, + { "ryanoasis/vim-devicons" }, + { "sheerun/vim-polyglot", setup = get_plugin_file("polyglot.lua") }, + { "vimwiki/vimwiki", config = get_plugin_file("vimwiki.lua") }, + { "tpope/vim-commentary", config = get_plugin_file("commentary.lua") }, + { "junegunn/fzf", run = function() fn['fzf#install']() end }, + { "tomasiser/vim-code-dark", config = get_plugin_file("vim-code-dark.lua") }, + { + "vim-airline/vim-airline", + config = get_plugin_file("airline.lua"), + requires = { "vim-airline/vim-airline-themes", opt = true }, + }, + { + "preservim/nerdtree", + config = get_plugin_file("nerdtree.lua"), + requires = { + { "Xuyuanp/nerdtree-git-plugin", opt = true }, + { "tiagofumo/vim-nerdtree-syntax-highlight", opt = true }, + }, + }, + { + "mfussenegger/nvim-dap", + config = get_plugin_file("nvim-dap.lua"), + requires = { "mfussenegger/nvim-dap-python", opt = true }, + }, + { + "junegunn/fzf.vim", + config = get_plugin_file("fzf.lua"), + after = "fzf", + requires = { "stsewd/fzf-checkout.vim", opt = true }, + }, + { + "neoclide/coc.nvim", + branch = "release", + config = get_plugin_file("coc.vim"), + requires = { "antoinemadec/coc-fzf", opt = true }, + }, +} + +return plugin_list diff --git a/home/.config/nvim/lua/utility/plugins.lua b/home/.config/nvim/lua/utility/plugins.lua deleted file mode 100644 index 62e5de3..0000000 --- a/home/.config/nvim/lua/utility/plugins.lua +++ /dev/null @@ -1,122 +0,0 @@ -local vim = require("vim") -local cmd = vim.cmd -local api = vim.api -local fn = vim.fn - --- This module contains several functions regarding packer plugin manager --- Most notably the get_plugin_file and packer_setup fucntions -local M = {} - --- Drectory containing the individual plugin configuration files. --- File to hold the compiled packer binary -M.packer_compiled_path = fn.stdpath("config") .. "plugin/packer_compiled.lua" - --- Return the line (string) to be executed with lua that loads in given plugin file. --- This is useful for the `config` or `setup` parameters of packer's use to either --- source `.vim` files, or require `.lua` files. --- Expects a `plugin_file` which is a relative path from the `plugin_directory` folder. -function M.get_plugin_file(plugin_file, plugin_directory) - local filename, extension = plugin_file:match("^(.+)(%..+)$") - if (extension == ".vim") then - local source_line = string.format('source "%s/%s"', plugin_directory, plugin_file) - return string.format("vim.fn.execute('%s')", source_line) - else - return string.format('require("%s/%s")', plugin_directory, filename) - end -end - --- Download packer plugin manager in case it isn't already installed -function M.packer_bootstrap() - local first_install = false - local present, packer = pcall(require, "packer") - if not present then - local packer_install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" - print("Clonning pakcer plugin manager, please wait...") - -- First remove the directory in case it already exists but packer isn't present - fn.delete(packer_install_path, "rf") - fn.system({ - "git", "clone", "--depth", "1", - "https://github.com/wbthomason/packer.nvim", - packer_install_path - }) - - -- Make sure packer was installed properly - cmd("packadd packer.nvim") - present, packer = pcall(require, "packer") - - if present then - print("Packer clonned successfully.") - first_install = true - else - print("Couldn't clone packer! Packer path: " .. packer_install_path .. "\n" .. packer) - end - end - - return { present = present, first_install = first_install, packer = packer } -end - --- Initialize packer with our desired configuration --- If packer isn't instaleld, this also performs the installation -function M.packer_init() - local details = M.packer_bootstrap() - -- Only continue if we actually managed to install packer - if not details.present then - return details - end - - details.packer.init({ - display = { - open_fn = function() - return require('packer.util').float({ border = "rounded" }) - end, - prompt_border = "rounded", - }, - git = { - -- Timeout for git clones in seconds - clone_timeout = 600, - }, - profile = { - enable = true, - -- The time that a pluign's load time must surpass for it to be included - -- in the profile (in miliseconds) - threshold = 1, - }, - compile_path = M.packer_compiled_path, - }) - - return details -end - --- Run packer's setup function and define all of the used plugins --- Expects table/list of tables holding the individual plugin settings -function M.packer_setup(plugin_configs) - local details = M.packer_init() - if not details.present then - return false - end - - local packer = details.packer - local use = packer.use - local first_install = details.first_install - - -- Make sure to add packer here, even if it's opt - api.nvim_command("packadd packer.nvim") - - return packer.startup(function() - -- We always want to let packer manage itself - use("wbthomason/packer.nvim") - - -- Load the obtained plugins (in any) - if plugin_configs and not vim.tbl_isempty(plugin_configs) then - for _, plugin in pairs(plugin_configs) do - use(plugin) - end - end - - if first_install then - packer.sync() - end - end) -end - -return M From 5627b96fff553830768e20d67732846877ade344 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 7 Dec 2021 22:23:55 +0100 Subject: [PATCH 125/188] Rename pluginconf/ to plugins/settings/ --- home/.config/nvim/lua/plugins/plugin_list.lua | 17 ++++++++++++++++- .../settings}/airline.lua | 0 .../{pluginconf => plugins/settings}/coc.vim | 0 .../settings}/commentary.lua | 0 .../settings}/deprecated/semshi.lua | 0 .../{pluginconf => plugins/settings}/fzf.lua | 0 .../settings}/nerdtree.lua | 0 .../settings}/nvim-dap.lua | 0 .../settings}/polyglot.lua | 0 .../settings}/vim-code-dark.lua | 0 .../settings}/vimwiki.lua | 0 11 files changed, 16 insertions(+), 1 deletion(-) rename home/.config/nvim/lua/{pluginconf => plugins/settings}/airline.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins/settings}/coc.vim (100%) rename home/.config/nvim/lua/{pluginconf => plugins/settings}/commentary.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins/settings}/deprecated/semshi.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins/settings}/fzf.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins/settings}/nerdtree.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins/settings}/nvim-dap.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins/settings}/polyglot.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins/settings}/vim-code-dark.lua (100%) rename home/.config/nvim/lua/{pluginconf => plugins/settings}/vimwiki.lua (100%) diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index 046eab0..2c2f10f 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -1,7 +1,7 @@ local vim = require("vim") local fn = vim.fn -local plugin_directory = fn.stdpath("config") .. "/lua/pluginconf" +local plugin_directory = fn.stdpath("config") .. "/lua/plugins/settings" -- Return the line (string) to be executed with lua that loads in given plugin file. -- This is useful for the `config` or `setup` parameters of packer's use to source @@ -51,6 +51,21 @@ local plugin_list = { after = "fzf", requires = { "stsewd/fzf-checkout.vim", opt = true }, }, + -- { + -- "neovim/nvim-lspconfig", + -- "williamboman/nvim-lsp-installer", + -- config = get_plugin_file("lspconfig.lua") + -- }, + --{ + -- "nvim-telescope/telescope.nvim", + -- --config = get_plugin_file("telescope.lua") + -- module = "telescope", + -- cmd = "Telescope", + -- requires = { + -- { "nvim-lua/popup.nvim" }, + -- { "nvim-lua/plenary.nvim" }, + -- } + --}, { "neoclide/coc.nvim", branch = "release", diff --git a/home/.config/nvim/lua/pluginconf/airline.lua b/home/.config/nvim/lua/plugins/settings/airline.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/airline.lua rename to home/.config/nvim/lua/plugins/settings/airline.lua diff --git a/home/.config/nvim/lua/pluginconf/coc.vim b/home/.config/nvim/lua/plugins/settings/coc.vim similarity index 100% rename from home/.config/nvim/lua/pluginconf/coc.vim rename to home/.config/nvim/lua/plugins/settings/coc.vim diff --git a/home/.config/nvim/lua/pluginconf/commentary.lua b/home/.config/nvim/lua/plugins/settings/commentary.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/commentary.lua rename to home/.config/nvim/lua/plugins/settings/commentary.lua diff --git a/home/.config/nvim/lua/pluginconf/deprecated/semshi.lua b/home/.config/nvim/lua/plugins/settings/deprecated/semshi.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/deprecated/semshi.lua rename to home/.config/nvim/lua/plugins/settings/deprecated/semshi.lua diff --git a/home/.config/nvim/lua/pluginconf/fzf.lua b/home/.config/nvim/lua/plugins/settings/fzf.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/fzf.lua rename to home/.config/nvim/lua/plugins/settings/fzf.lua diff --git a/home/.config/nvim/lua/pluginconf/nerdtree.lua b/home/.config/nvim/lua/plugins/settings/nerdtree.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/nerdtree.lua rename to home/.config/nvim/lua/plugins/settings/nerdtree.lua diff --git a/home/.config/nvim/lua/pluginconf/nvim-dap.lua b/home/.config/nvim/lua/plugins/settings/nvim-dap.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/nvim-dap.lua rename to home/.config/nvim/lua/plugins/settings/nvim-dap.lua diff --git a/home/.config/nvim/lua/pluginconf/polyglot.lua b/home/.config/nvim/lua/plugins/settings/polyglot.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/polyglot.lua rename to home/.config/nvim/lua/plugins/settings/polyglot.lua diff --git a/home/.config/nvim/lua/pluginconf/vim-code-dark.lua b/home/.config/nvim/lua/plugins/settings/vim-code-dark.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/vim-code-dark.lua rename to home/.config/nvim/lua/plugins/settings/vim-code-dark.lua diff --git a/home/.config/nvim/lua/pluginconf/vimwiki.lua b/home/.config/nvim/lua/plugins/settings/vimwiki.lua similarity index 100% rename from home/.config/nvim/lua/pluginconf/vimwiki.lua rename to home/.config/nvim/lua/plugins/settings/vimwiki.lua From b9afa56d96f91f292c26d1b0439c063bab695703 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 7 Dec 2021 22:26:32 +0100 Subject: [PATCH 126/188] Remove default coc-pyright args for flake8 - Default args cause problems when we have other custom flake8 rules defined in files such as tox.ini since these project-specifc settings were simply getting ignored in favor of the default args. We should instead always rely on the project's settings --- home/.config/nvim/coc-settings.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/home/.config/nvim/coc-settings.json b/home/.config/nvim/coc-settings.json index c774237..3665990 100644 --- a/home/.config/nvim/coc-settings.json +++ b/home/.config/nvim/coc-settings.json @@ -11,8 +11,5 @@ "coc.preferences.formatOnSaveFiletypes": [ "json" ], - "python.linting.flake8Enabled": true, - "python.linting.flake8Args": [ - "--ignore=ANN204,ANN101,ANN102,ANN002,ANN003" - ] + "python.linting.flake8Enabled": true } From 1c3fc028779195fb68c9cdf17e75b3c88d9da097 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 7 Dec 2021 22:34:46 +0100 Subject: [PATCH 127/188] Attribute CosmicVim --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c0c7af6..ab2a459 100644 --- a/README.md +++ b/README.md @@ -84,4 +84,5 @@ is the list of all projects which helped the existence of this repository: - [BrodieRobertson's dotfiles](https://github.com/BrodieRobertson/dotfiles) - [BrodieRobertson's scripts](https://github.com/BrodieRobertson/scripts) - [Derek Taylor's dotfiles](https://gitlab.com/dwt1/dotfiles) +- [CosmicVim source](https://github.com/CosmicNvim/CosmicNvim) From 886b79e9a771fbff73987848852dc630b72c63e3 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 8 Dec 2021 20:10:40 +0100 Subject: [PATCH 128/188] Add treesitter AST semantic highlighting --- home/.config/nvim/lua/plugins/plugin_list.lua | 7 ++++- .../nvim/lua/plugins/settings/polyglot.lua | 8 ------ .../nvim/lua/plugins/settings/treesitter.lua | 28 +++++++++++++++++++ 3 files changed, 34 insertions(+), 9 deletions(-) delete mode 100644 home/.config/nvim/lua/plugins/settings/polyglot.lua create mode 100644 home/.config/nvim/lua/plugins/settings/treesitter.lua diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index 2c2f10f..79d86f9 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -22,11 +22,16 @@ local plugin_list = { { "wakatime/vim-wakatime" }, { "mhinz/vim-startify" }, { "ryanoasis/vim-devicons" }, - { "sheerun/vim-polyglot", setup = get_plugin_file("polyglot.lua") }, { "vimwiki/vimwiki", config = get_plugin_file("vimwiki.lua") }, { "tpope/vim-commentary", config = get_plugin_file("commentary.lua") }, { "junegunn/fzf", run = function() fn['fzf#install']() end }, { "tomasiser/vim-code-dark", config = get_plugin_file("vim-code-dark.lua") }, + { + "nvim-treesitter/nvim-treesitter", + config = get_plugin_file("treesitter.lua"), + run = ':TSUpdate', + requires = { "nvim-treesitter/playground", opt = true } + }, { "vim-airline/vim-airline", config = get_plugin_file("airline.lua"), diff --git a/home/.config/nvim/lua/plugins/settings/polyglot.lua b/home/.config/nvim/lua/plugins/settings/polyglot.lua deleted file mode 100644 index 53cb6c3..0000000 --- a/home/.config/nvim/lua/plugins/settings/polyglot.lua +++ /dev/null @@ -1,8 +0,0 @@ -local vim = require("vim") -local g = vim.g - --- Disable polyglot's "sensible" settings, while there are some nice things it --- does, I set these manually in my default config and I don't like depending --- on single plugin for so many things, doing it manually doing it manually is --- also more explicit making it obvious what's happening -g.polyglot_disabled = {'sensible'} diff --git a/home/.config/nvim/lua/plugins/settings/treesitter.lua b/home/.config/nvim/lua/plugins/settings/treesitter.lua new file mode 100644 index 0000000..7f90fe3 --- /dev/null +++ b/home/.config/nvim/lua/plugins/settings/treesitter.lua @@ -0,0 +1,28 @@ +local vim = require("vim") +local g = vim.g + +-- Enable treesitter highlight for all languages +require'nvim-treesitter.configs'.setup { + -- Always automatically install parsers for these languages + ensure_installed = { + "bash", "python", "lua", "rust", "go", "haskell", + "c", "cpp", "cmake", "c_sharp", "java", "dockerfile", + "json", "toml", "yaml", "regex", "vim", "html", "css", + "typescript", "javascript", + }, + highlight = { + enable = true, + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, +} + +-- Use git instead of curl for downloading parsers +require("nvim-treesitter.install").prefer_git = true + +-- Use treesitter for syntax-aware folding +g.foldmethod = "expr" +g.foldexpr = "nvim_treesitter#foldexpr()" From f6c0441810a0bfe13341fcf572280e18fc4e15b5 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 8 Dec 2021 20:12:49 +0100 Subject: [PATCH 129/188] Add cheat.sh-vim plugin --- home/.config/nvim/lua/plugins/plugin_list.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index 79d86f9..c7e8c28 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -22,6 +22,7 @@ local plugin_list = { { "wakatime/vim-wakatime" }, { "mhinz/vim-startify" }, { "ryanoasis/vim-devicons" }, + { "dbeniamine/cheat.sh-vim" }, { "vimwiki/vimwiki", config = get_plugin_file("vimwiki.lua") }, { "tpope/vim-commentary", config = get_plugin_file("commentary.lua") }, { "junegunn/fzf", run = function() fn['fzf#install']() end }, From 4eee9b4398cd66833965790685e000ef1cc540a9 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 8 Dec 2021 22:34:30 +0100 Subject: [PATCH 130/188] Add firenvim (nvim in browser) plugin --- home/.config/nvim/lua/plugins/plugin_list.lua | 5 ++++ .../nvim/lua/plugins/settings/firenvim.lua | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 home/.config/nvim/lua/plugins/settings/firenvim.lua diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index c7e8c28..b2eae55 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -57,6 +57,11 @@ local plugin_list = { after = "fzf", requires = { "stsewd/fzf-checkout.vim", opt = true }, }, + { + 'glacambre/firenvim', + config = get_plugin_file("firenvim.lua"), + run = function() vim.fn['firenvim#install'](0) end + }, -- { -- "neovim/nvim-lspconfig", -- "williamboman/nvim-lsp-installer", diff --git a/home/.config/nvim/lua/plugins/settings/firenvim.lua b/home/.config/nvim/lua/plugins/settings/firenvim.lua new file mode 100644 index 0000000..3aa19ce --- /dev/null +++ b/home/.config/nvim/lua/plugins/settings/firenvim.lua @@ -0,0 +1,27 @@ +local vim = require("vim") +local cmd = vim.cmd +local g = vim.g + +-- Detect filetype based on filename for certain websites +cmd[[ +autocmd BufEnter github.com_*.txt set filetype=markdown +autocmd BufEnter txti.es_*.txt set filetype=typescript +]] + +-- Define firenvim configuration +g.firenvim_config = { + globalSettings = { alt="all" }, + localSettings = { + [".*"] = { + cmdline = "neovim", + content = "text", + priority = 0, + selector = "textarea", + -- Don't automatically take over, require the shortcut + takeover = "never", + }, + -- Enable automatic takeover on certain websites where it makes sense + ["https?://github.com"] = { takeover = "always", priority=1 }, + ["https?://txti.es"] = { takeover = "always", priority = 1 }, + } +} From 46ca9189af37627e66397ea291f10312737a74f4 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 8 Dec 2021 23:10:05 +0100 Subject: [PATCH 131/188] Add suport for nvim's LSP --- home/.config/nvim/lua/lsp/autoformat.lua | 5 ++ home/.config/nvim/lua/lsp/init.lua | 31 ++++++++ home/.config/nvim/lua/lsp/keymaps.lua | 57 +++++++++++++++ home/.config/nvim/lua/lsp/rename.lua | 3 + home/.config/nvim/lua/plugins/plugin_list.lua | 22 +++--- .../.config/nvim/lua/plugins/settings/lsp.lua | 73 +++++++++++++++++++ 6 files changed, 180 insertions(+), 11 deletions(-) create mode 100644 home/.config/nvim/lua/lsp/autoformat.lua create mode 100644 home/.config/nvim/lua/lsp/init.lua create mode 100644 home/.config/nvim/lua/lsp/keymaps.lua create mode 100644 home/.config/nvim/lua/lsp/rename.lua create mode 100644 home/.config/nvim/lua/plugins/settings/lsp.lua diff --git a/home/.config/nvim/lua/lsp/autoformat.lua b/home/.config/nvim/lua/lsp/autoformat.lua new file mode 100644 index 0000000..e4363c1 --- /dev/null +++ b/home/.config/nvim/lua/lsp/autoformat.lua @@ -0,0 +1,5 @@ +local vim = require("vim") +local cmd = vim.cmd + +-- Always automatically format on write for given filenames +cmd[[autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100)]] diff --git a/home/.config/nvim/lua/lsp/init.lua b/home/.config/nvim/lua/lsp/init.lua new file mode 100644 index 0000000..1e26feb --- /dev/null +++ b/home/.config/nvim/lua/lsp/init.lua @@ -0,0 +1,31 @@ +-- Neovim has built in support for the language server protocol (LSP). For +-- which reason I decided to utilize it directly instead of relying on plugins +-- such as COC, which reimplement it completely just to support default vim +-- too, since I don't need pure vim support, utilizing this built in support +-- makes a lot more sense and will be faster. +-- +-- By default, setting up LSP doesn't technically require any plugins, however +-- I still do use the recommended neovim/nvim-lspconfig plugin, along with +-- williamboman/nvim-lsp-installer, because it makes things a lot easier to get +-- working. The lspconfig holds the default configurations for the individual +-- language servers, avoiding the need of tediously configuring them manually, +-- and the lspinstaller gives us a way to automatically install selected +-- language servers locally for nvim only, which means we won't need to look at +-- the install instructions for each language server and install it user or +-- system wide. +-- +-- However, since this configuration shouldn't be plugin dependant, as it is +-- outside of the plugins/ directory and LSP is supported by neovim directly, +-- this folder is here to provide the non-plugin dependant LSP configuration, +-- but I do not manually define the configuration for each language server, +-- since I do actually utilize those plugins, but sturcturing like this still +-- does give space for completely custom configurations written from scratch +-- without relying on any external plugins at all. If you do want to do that, +-- this would be the place to set this up. +-- +-- NOTE: With my current configuration, this file is only ran by being required +-- in the lsp plugin config file, if you don't wish to run with plugins, you'll +-- want to require this file from init.lua directly. + +require("lsp.keymaps") +require("lsp.autoformat") diff --git a/home/.config/nvim/lua/lsp/keymaps.lua b/home/.config/nvim/lua/lsp/keymaps.lua new file mode 100644 index 0000000..4a31dcf --- /dev/null +++ b/home/.config/nvim/lua/lsp/keymaps.lua @@ -0,0 +1,57 @@ +local m = require("utility.mappings") + +-- See `:help vim.lsp.*` for documentation on any of the below mapped functions + +-- Check if certain plugins are installed, if so, they should be used +-- to define some mappings +local telescope_installed, _ = pcall(require, "telescope") +local lsp_signature_installed, _ = pcall(require, "lsp_signature") + +-- Lookups +m.keymap("n", "gd", "lua vim.lsp.buf.definition()") +m.keymap('n', 'gD', 'lua vim.lsp.buf.declaration()') +m.keymap("n", "gr", "lua vim.lsp.buf.references()") +m.keymap("n", "gi", "lua vim.lsp.buf.implementation()") +m.keymap("n", "gt", "lua vim.lsp.buf.type_definition()") + +if telescope_installed then + m.keymap('n', 'gd', 'lua require("telescope.builtin").lsp_definitions()') + m.keymap('n', 'gr', 'lua require("telescope.builtin").lsp_references()') + m.keymap('n', 'gi', 'lua require("telescope.builtin").lsp_implementations()') + m.keymap('n', 'gt', 'lua require("telescope.builtin").lsp_type_definitions()') +end + +-- Formatting +m.keymap('n', 'gf', 'lua vim.lsp.buf.formatting()') +m.keymap('v', 'gf', 'lua vim.lsp.buf.range_formatting()') + +-- Hover info +m.keymap("n", "", "lua vim.lsp.buf.signature_help()") +m.keymap("n", "M", "lua vim.lsp.buf.hover()") + +if lsp_signature_installed then + m.keymap('n', '', 'lua require("lsp_signature").signature()') +end + +-- Diagnostics +m.keymap('n', '[g', 'lua vim.diagnostic.goto_prev()') +m.keymap('n', ']g', 'lua vim.diagnostic.goto_next()') +m.keymap('n', 'ge', 'lua vim.diagnostic.open_float(nil, { scope = "line", })') + +if telescope_installed then + m.keymap('n', 'ge', 'lua require("telescope.builtin").lsp_document_diagnostics()') +end + +-- LSP Workspace +m.keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()') +m.keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()') +m.keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))') + +--Actions +if telescope_installed then + m.keymap('n', 'ga', 'lua require("telescope.builtin").lsp_code_actions()') + m.keymap('v', 'ga', 'lua require("telescope.builtin").lsp_range_code_actions()') +end + +-- Use custom implementation for renaming all references +m.keymap('n', 'gn', 'lua require("lsp/rename").rename()') diff --git a/home/.config/nvim/lua/lsp/rename.lua b/home/.config/nvim/lua/lsp/rename.lua new file mode 100644 index 0000000..908724f --- /dev/null +++ b/home/.config/nvim/lua/lsp/rename.lua @@ -0,0 +1,3 @@ +-- Nvim's LSP lacks rename-all functionality which plugins like Coc provide +-- this is a manual implementation of this feature +-- TODO: Actually implement this diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index b2eae55..f8df119 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -62,11 +62,11 @@ local plugin_list = { config = get_plugin_file("firenvim.lua"), run = function() vim.fn['firenvim#install'](0) end }, - -- { - -- "neovim/nvim-lspconfig", - -- "williamboman/nvim-lsp-installer", - -- config = get_plugin_file("lspconfig.lua") - -- }, + { + "williamboman/nvim-lsp-installer", + config = get_plugin_file("lsp.lua"), + requires = { "neovim/nvim-lspconfig" }, + }, --{ -- "nvim-telescope/telescope.nvim", -- --config = get_plugin_file("telescope.lua") @@ -77,12 +77,12 @@ local plugin_list = { -- { "nvim-lua/plenary.nvim" }, -- } --}, - { - "neoclide/coc.nvim", - branch = "release", - config = get_plugin_file("coc.vim"), - requires = { "antoinemadec/coc-fzf", opt = true }, - }, + -- { + -- "neoclide/coc.nvim", + -- branch = "release", + -- config = get_plugin_file("coc.vim"), + -- requires = { "antoinemadec/coc-fzf", opt = true }, + -- }, } return plugin_list diff --git a/home/.config/nvim/lua/plugins/settings/lsp.lua b/home/.config/nvim/lua/plugins/settings/lsp.lua new file mode 100644 index 0000000..238529f --- /dev/null +++ b/home/.config/nvim/lua/plugins/settings/lsp.lua @@ -0,0 +1,73 @@ +local vim = require("vim") +local fn = vim.fn + +-- Load in our default plugin independant LSP settings. +-- These are loaded from here, because we don't need them if we aren't using +-- these plugins, which actually load in the LSP configurations and install the +-- individual language servers. However it is possible to configure nvim +-- without these plugins and so this config is separated from the plugin +-- config. for more info, check the comments in lsp/init.lua +require("lsp") + + +-- Load in the needed settigns for nvim-lsp-installer plugin. +-- This ensures automatic installation for the individual language servers. +local lsp_installer = require("nvim-lsp-installer") + +-- Define some settings for the UI and installation path for the language +-- servers. +lsp_installer.settings({ + ui = { + icons = { + server_installed = "✓", + server_pending = "➜", + server_uninstalled = "✗" + }, + keymaps = { + toggle_server_expand = "", + install_server = "i", + update_server = "u", + uninstall_server = "X", + }, + }, + install_root_dir = fn.stdpath("data") .. "/lsp_servers", +}) + +-- Define a table of requested language servers which should be automatically +-- installed. +-- +-- NOTE: pylsp requires external installaion with +-- :PylspInstall pyls-flake8 pyls-mypy pyls-isort +local requested_servers = { + "clangd", "cmake", "omnisharp", + "cssls", "dockerls", "gopls", "html", + "hls", "jsonls", "jdtls", "tsserver", + "sumneko_lua", "pyright", "pylsp", + "sqlls", "vimls", "yamlls" +} + +-- Go through the requested servers and ensure installation +-- Once the servers are ready, run setup() on them. This setup is basically +-- running the lspconfig.server.setup() which means lspconfig is needed to do +-- this. +local lsp_installer_servers = require('nvim-lsp-installer.servers') +for _, requested_server in pairs(requested_servers) do + local server_available, server = lsp_installer_servers.get_server(requested_server) + if server_available then + -- Setup the server once it will become ready + server:on_ready(function() + local opts = {} + server:setup(opts) + end) + -- If the server isn't yet installed, schedule the installation + if not server:is_installed() then + server:install() + end + else + vim.notify( + "Can't install: Language server " .. server .. " was not found - SKIPPED", + vim.log.levels.WARN, + { title = "Notification" } + ) + end +end From 50a139f0f014c62ee3138b3bffa906be0f942c81 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 00:39:13 +0100 Subject: [PATCH 132/188] Add some more mappings --- home/.config/nvim/lua/core/mappings.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/home/.config/nvim/lua/core/mappings.lua b/home/.config/nvim/lua/core/mappings.lua index a35c434..4e4afa8 100644 --- a/home/.config/nvim/lua/core/mappings.lua +++ b/home/.config/nvim/lua/core/mappings.lua @@ -59,6 +59,18 @@ m.keymap("v", "", "zf") m.keymap("n", "K", "10k") m.keymap("n", "J", "10j") +-- Moving lines around +m.keymap("v", "", ":m '>+1gv=gv") +m.keymap("v", "", ":m '<-2gv=gv") +m.keymap("i", "", ":m .+1==i") +m.keymap("i", "", ":m .-2==i") +m.keymap("n", "j", ":m .+1==") +m.keymap("n", "k", ":m .-2==") + +-- Quick word replacing (use . for next word) +m.keymap("n", "cn", "*``cgn") +m.keymap("n", "cN", "*``cgN") + -- Enable/Disable auto commenting m.keymap("n", "c", ":setlocal formatoptions-=cro") m.keymap("n", "C", ":setlocal formatoptions+=cro") @@ -67,6 +79,10 @@ m.keymap("n", "C", ":setlocal formatoptions+=cro") m.keymap("v", "<", "", ">gv") +-- Center (and unfold) after going to next/prev search item +m.keymap("n", "n", "nzzzv") +m.keymap("n", "N", "Nzzzv") + -- System clipboard copying m.keymap("v", "", '"+y') From f7516182c351d16090b8ed0384a4e520af0a3ef9 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 00:54:06 +0100 Subject: [PATCH 133/188] Support auto-completion with LSP --- home/.config/nvim/lua/plugins/plugin_list.lua | 9 ++++++++- home/.config/nvim/lua/plugins/settings/lsp.lua | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index f8df119..14253d6 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -65,7 +65,14 @@ local plugin_list = { { "williamboman/nvim-lsp-installer", config = get_plugin_file("lsp.lua"), - requires = { "neovim/nvim-lspconfig" }, + requires = { + "neovim/nvim-lspconfig", + "hrsh7th/nvim-cmp", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + }, }, --{ -- "nvim-telescope/telescope.nvim", diff --git a/home/.config/nvim/lua/plugins/settings/lsp.lua b/home/.config/nvim/lua/plugins/settings/lsp.lua index 238529f..ffa6c3c 100644 --- a/home/.config/nvim/lua/plugins/settings/lsp.lua +++ b/home/.config/nvim/lua/plugins/settings/lsp.lua @@ -10,6 +10,19 @@ local fn = vim.fn require("lsp") +-- Configure nvim-cmp to respect LSP completions. +local cmp = require("cmp") + +cmp.setup({ + sources = { + { name = "nvim_lsp" } + } +}) + +-- The nvim-cmp almost supports LSP's capabilities so you should advertise it to LSP servers +local cmp_capabilities = vim.lsp.protocol.make_client_capabilities() +cmp_capabilities = require("cmp_nvim_lsp").update_capabilities(cmp_capabilities) + -- Load in the needed settigns for nvim-lsp-installer plugin. -- This ensures automatic installation for the individual language servers. local lsp_installer = require("nvim-lsp-installer") @@ -56,7 +69,8 @@ for _, requested_server in pairs(requested_servers) do if server_available then -- Setup the server once it will become ready server:on_ready(function() - local opts = {} + -- Advertise completion capabilities by nvim-cmp + local opts = { capabilities = cmp_capabilities } server:setup(opts) end) -- If the server isn't yet installed, schedule the installation From d1ad56a69e5b83ec1ce7d486645e165da69b1d79 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 00:58:19 +0100 Subject: [PATCH 134/188] Remove simpylfold for python folding (handled by LSP) --- home/.config/nvim/lua/plugins/plugin_list.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index 14253d6..55a59a1 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -18,7 +18,6 @@ end local plugin_list = { { "airblade/vim-gitgutter" }, { "dhruvasagar/vim-table-mode" }, - { "tmhedberg/SimpylFold" }, { "wakatime/vim-wakatime" }, { "mhinz/vim-startify" }, { "ryanoasis/vim-devicons" }, From cff3a5e70ac20243a29f6210af702e0d51366e15 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 01:16:25 +0100 Subject: [PATCH 135/188] Improve docstring about foldlevel option --- home/.config/nvim/lua/core/options.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/nvim/lua/core/options.lua b/home/.config/nvim/lua/core/options.lua index 58a7be8..6f31346 100644 --- a/home/.config/nvim/lua/core/options.lua +++ b/home/.config/nvim/lua/core/options.lua @@ -16,7 +16,7 @@ o.shiftround = true -- Always round indent to multiple of shiftwidth -- Folding o.foldmethod = "indent" -- Use indent to determine the fold levels o.foldnestmax = 8 -- Only fold up to given amount of levels -o.foldlevel = 2 -- Set initial fold level +o.foldlevel = 2 -- Set initial fold level (don't fold first 2 levels) o.foldenable = false -- Hide all folds by default -- Split order From b504f10f28303cf8b76cb0f042efe0e5a2784da2 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 01:16:50 +0100 Subject: [PATCH 136/188] Ignore certain patterns in wildmenu --- home/.config/nvim/lua/core/options.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/home/.config/nvim/lua/core/options.lua b/home/.config/nvim/lua/core/options.lua index 6f31346..b2cb2d2 100644 --- a/home/.config/nvim/lua/core/options.lua +++ b/home/.config/nvim/lua/core/options.lua @@ -36,6 +36,14 @@ o.listchars = {tab = " ", trail = "·"} -- Specify which characters to sh o.wildmode = {"longest", "list", "full"} -- Enable autocompletion o.wildmenu = true -- Display all matching files when we tab complete table.insert(o.path, "**") -- Search down into subfolders with tab completion +o.wildignore = vim.tbl_extend( -- Ignore certain files/folders in wildmenu + "force", o.wildignore, { + "*.pyc", "*_build/*", + "**/coverage/*", "**/node_modules/*", + "**/android/*", "**/ios/*", + "**/.git/*", + } +) -- Files o.encoding = "utf-8" -- Use UTF-8 encoding From bd3ece59b7e943c4d9e6b3d8bbf41b3602f2098f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 01:17:25 +0100 Subject: [PATCH 137/188] Document and cleanup plugins --- home/.config/nvim/lua/plugins/plugin_list.lua | 63 +++++++++++++------ 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index 55a59a1..213f1e9 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -16,53 +16,67 @@ end -- Define packer plugins -- The individual tables will get passed into the packer's use function local plugin_list = { - { "airblade/vim-gitgutter" }, - { "dhruvasagar/vim-table-mode" }, - { "wakatime/vim-wakatime" }, - { "mhinz/vim-startify" }, - { "ryanoasis/vim-devicons" }, - { "dbeniamine/cheat.sh-vim" }, - { "vimwiki/vimwiki", config = get_plugin_file("vimwiki.lua") }, - { "tpope/vim-commentary", config = get_plugin_file("commentary.lua") }, - { "junegunn/fzf", run = function() fn['fzf#install']() end }, - { "tomasiser/vim-code-dark", config = get_plugin_file("vim-code-dark.lua") }, + { "airblade/vim-gitgutter" }, -- Git status in files + { "dhruvasagar/vim-table-mode" }, -- Easy way to construct markdown tables + { "wakatime/vim-wakatime" }, -- Track time spent coding + { "mhinz/vim-startify" }, -- Nice startup screen for vim when started withotu file/dir + { "dbeniamine/cheat.sh-vim" }, -- Quick interaction with cheat.sh cheatsheets { - "nvim-treesitter/nvim-treesitter", + "vimwiki/vimwiki", -- Wiki pages for vim + config = get_plugin_file("vimwiki.lua"), + }, + { + "tpope/vim-commentary", -- Adds ability to comment out sections of files + config = get_plugin_file("commentary.lua") + }, + { + "tomasiser/vim-code-dark", -- Vim theme inspired by vscode's Dark+ + config = get_plugin_file("vim-code-dark.lua") + }, + { + "nvim-treesitter/nvim-treesitter", -- AST language analysis providing semantic highlighting config = get_plugin_file("treesitter.lua"), run = ':TSUpdate', requires = { "nvim-treesitter/playground", opt = true } }, { - "vim-airline/vim-airline", + "vim-airline/vim-airline", -- Status line config = get_plugin_file("airline.lua"), - requires = { "vim-airline/vim-airline-themes", opt = true }, + requires = { + { "vim-airline/vim-airline-themes", opt = true }, + { "ryanoasis/vim-devicons", opt = true }, + }, }, { - "preservim/nerdtree", + "preservim/nerdtree", -- File tree config = get_plugin_file("nerdtree.lua"), requires = { { "Xuyuanp/nerdtree-git-plugin", opt = true }, { "tiagofumo/vim-nerdtree-syntax-highlight", opt = true }, + { "ryanoasis/vim-devicons", opt = true }, }, }, { - "mfussenegger/nvim-dap", + "mfussenegger/nvim-dap", -- Support for the debugging within vim config = get_plugin_file("nvim-dap.lua"), requires = { "mfussenegger/nvim-dap-python", opt = true }, }, { - "junegunn/fzf.vim", + "junegunn/fzf.vim", -- Fuzzy finder (TODO: consider replacing with telescope) + run = function() fn['fzf#install']() end, config = get_plugin_file("fzf.lua"), - after = "fzf", - requires = { "stsewd/fzf-checkout.vim", opt = true }, + requires = { + { "junegunn/fzf", opt = false }, + { "stsewd/fzf-checkout.vim", opt = true }, + } }, { - 'glacambre/firenvim', + 'glacambre/firenvim', -- Integrates neovim into the browser config = get_plugin_file("firenvim.lua"), run = function() vim.fn['firenvim#install'](0) end }, { - "williamboman/nvim-lsp-installer", + "williamboman/nvim-lsp-installer", -- LSP protocol configurations, autocomplete, autoinstaller config = get_plugin_file("lsp.lua"), requires = { "neovim/nvim-lspconfig", @@ -73,6 +87,10 @@ local plugin_list = { "hrsh7th/cmp-cmdline", }, }, + + -- TODO: Consider testing out telescope as an alternative to FZF, I've heard a lot of + -- positive feedback about it, but I haven't yet got the chance to meaningfully test + -- it and configure it. --{ -- "nvim-telescope/telescope.nvim", -- --config = get_plugin_file("telescope.lua") @@ -83,6 +101,11 @@ local plugin_list = { -- { "nvim-lua/plenary.nvim" }, -- } --}, + + -- Coc is disabled because we're using LSP. It implements support from language servers from + -- scratch, which is slower than neovim's built-in LSP and since this configuration won't work + -- with pure vim, we can rely on nvim-only thigns. I left it here because LSP can sometimes + -- cause issues and Coc is a lot more friendly to setup. -- { -- "neoclide/coc.nvim", -- branch = "release", From f0fbf261ecf1584abc599008acc8f12fd32abce0 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 17:34:42 +0100 Subject: [PATCH 138/188] Manually implement auto mass-renaming using LSP --- home/.config/nvim/lua/lsp/rename.lua | 159 ++++++++++++++++++++++++++- 1 file changed, 158 insertions(+), 1 deletion(-) diff --git a/home/.config/nvim/lua/lsp/rename.lua b/home/.config/nvim/lua/lsp/rename.lua index 908724f..c07654a 100644 --- a/home/.config/nvim/lua/lsp/rename.lua +++ b/home/.config/nvim/lua/lsp/rename.lua @@ -1,3 +1,160 @@ -- Nvim's LSP lacks rename-all functionality which plugins like Coc provide -- this is a manual implementation of this feature --- TODO: Actually implement this +local vim = require("vim") +local api = vim.api +local cmd = vim.cmd +local lsp = vim.lsp +local fn = vim.fn + +local M = {} + +-- Unique name for the rename window, so we can access it +-- from close_rename_win function. +local unique_name = "lsp-rename-win" + +-- File require string. Neede because we will be defining keymaps +-- applied only to the rename window buffer which will refer to +-- functions within this file, for that, they need to call require +local file_require_string = "lsp.rename" + +-- Check whether LSP is actually active. +local function check_lsp_active() + local active_clients = lsp.get_active_clients() + if next(active_clients) == nil then + return false + end + return true +end + +-- Once in the rename window buffer, apply specific mappings to confirm or +-- cancel renaming, and define a specific autocmd to close the window if +-- we leave it. +local function apply_actions() + local prefix = string.format("lua require('%s')", file_require_string) + local close_win_s = prefix .. ".close_rename_win()" + local do_rename_s = prefix .. ".do_rename()" + -- Automatically close the window if it's escaped + api.nvim_command("autocmd QuitPre ++nested ++once :silent " .. close_win_s) + -- Define confirm and exit buffer-specific keymaps + api.nvim_command("inoremap " .. do_rename_s .. "") + api.nvim_command("nnoremap q " .. close_win_s .. "") +end + +-- Closes the rename window (identified by the `unique_name`) +function M.close_rename_win() + if fn.mode() == "1" then + cmd[[stopinsert]] + end + + local exists, winid = pcall(api.nvim_win_get_var, 0, unique_name) + if exists then + api.nvim_win_close(winid, true) + end +end + +local function dump(o) + if type(o) == 'table' then + local s = '{ ' + for k,v in pairs(o) do + if type(k) ~= 'number' then k = '"'..k..'"' end + s = s .. '['..k..'] = ' .. dump(v) .. ',' + end + return s .. '} ' + else + return tostring(o) + end +end + + +-- Trigger renaming +function M.do_rename() + local new_name = vim.trim(fn.getline('.')) + M.close_rename_win() + local current_name = fn.expand("") + + if not new_name or #new_name == 0 or new_name == current_name then + return + end + + local params = lsp.util.make_position_params() + params.newName = new_name + lsp.buf_request(0, "textDocument/rename", params, function(_, result, _, _) + if not result then + -- If the server returns an empty result, don't do anything + return + end + + -- The result contains all places we need to update the name + -- of the identifier, so we apply those edits. + lsp.util.apply_workspace_edit(result) + + if not result.changes then + return + end + + local total_files = 0 + local total_renames = 0 + for _, renames in pairs(result.changes) do + total_files = total_files + 1 + for _ in pairs(renames) do + total_renames = total_renames + 1 + end + end + + -- Once the changes were applied, these files won't be saved + -- automatically, let's remind ourselves to save those... + print(string.format( + "Changed %s file%s (%s rename%s). To save %s, run ':w%s'", + total_files, + total_files > 1 and "s" or "", + total_renames, + total_renames > 1 and "s" or "", + total_files > 1 and "them" or "it", + total_files > 1 and "a" or "" + )) + end) +end + +-- Create the rename window +function M.rename() + if not check_lsp_active() then + print("No LSP client available, can't rename!") + return + end + + -- In case there already is another rename window opened, close it + M.close_rename_win() + + + -- Read the current name here, before we're in the rename window + local current_name = fn.expand('') + + -- Create a window within our buffer with our `unique_name` so that it + -- can be found from the close fucntion and automatically enter it + local win_opts = { + relative = 'cursor', + row = 0, + col = 0, + width = 30, + height = 1, + style = 'minimal', + border = 'single' + } + local buf = api.nvim_create_buf(false, true) + local win = api.nvim_open_win(buf, true, win_opts) + api.nvim_win_set_var(0, unique_name, win) + + -- Automatically enter insert mode + cmd[[startinsert]] + + -- Pre-write the current name of given object into the rename window + -- and set cursor behind it + api.nvim_buf_set_lines(buf, 0, -1, false, {current_name}) + api.nvim_win_set_cursor(win, {1, #current_name}) + + -- Set actions for auto-closing the window and buffer-specific mappings + -- to confirm or close rename + apply_actions() +end + +return M From 2fc82d8f37f6b3ca6a3f3866b8359fbea363882d Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 17:35:07 +0100 Subject: [PATCH 139/188] Use '.' instead of '/' in require --- home/.config/nvim/lua/lsp/keymaps.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/nvim/lua/lsp/keymaps.lua b/home/.config/nvim/lua/lsp/keymaps.lua index 4a31dcf..e3c9b9a 100644 --- a/home/.config/nvim/lua/lsp/keymaps.lua +++ b/home/.config/nvim/lua/lsp/keymaps.lua @@ -54,4 +54,4 @@ if telescope_installed then end -- Use custom implementation for renaming all references -m.keymap('n', 'gn', 'lua require("lsp/rename").rename()') +m.keymap('n', 'gn', 'lua require("lsp.rename").rename()') From c899a05c34292b146b06ca0211e0202296d7435f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 17:38:28 +0100 Subject: [PATCH 140/188] Remove unused function for debugging --- home/.config/nvim/lua/lsp/rename.lua | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/home/.config/nvim/lua/lsp/rename.lua b/home/.config/nvim/lua/lsp/rename.lua index c07654a..639ce3d 100644 --- a/home/.config/nvim/lua/lsp/rename.lua +++ b/home/.config/nvim/lua/lsp/rename.lua @@ -52,20 +52,6 @@ function M.close_rename_win() end end -local function dump(o) - if type(o) == 'table' then - local s = '{ ' - for k,v in pairs(o) do - if type(k) ~= 'number' then k = '"'..k..'"' end - s = s .. '['..k..'] = ' .. dump(v) .. ',' - end - return s .. '} ' - else - return tostring(o) - end -end - - -- Trigger renaming function M.do_rename() local new_name = vim.trim(fn.getline('.')) From 656f29b3339cb41a857652efd9d67913c852147a Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 17:39:03 +0100 Subject: [PATCH 141/188] Add comment --- home/.config/nvim/lua/lsp/rename.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/nvim/lua/lsp/rename.lua b/home/.config/nvim/lua/lsp/rename.lua index 639ce3d..6ce4cc6 100644 --- a/home/.config/nvim/lua/lsp/rename.lua +++ b/home/.config/nvim/lua/lsp/rename.lua @@ -78,6 +78,7 @@ function M.do_rename() return end + -- Collect amounts of affected files and total renames. local total_files = 0 local total_renames = 0 for _, renames in pairs(result.changes) do From 7d3eb5ae69f3cab267d5646aebedc7762426a735 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 9 Dec 2021 19:05:19 +0100 Subject: [PATCH 142/188] Add cheat.sh script --- home/.local/bin/scripts/cheat.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 home/.local/bin/scripts/cheat.sh diff --git a/home/.local/bin/scripts/cheat.sh b/home/.local/bin/scripts/cheat.sh new file mode 100755 index 0000000..104ab67 --- /dev/null +++ b/home/.local/bin/scripts/cheat.sh @@ -0,0 +1,16 @@ +#!/bin/sh +languages=`echo "python rust golang lua cpp c typescript nodejs javascript js" | tr ' ' '\n'` +core_utils=`echo "xargs find sed awk" | tr ' ' '\n'` + +selected=`printf "$languages\n$core_utils" | fzf` +read -p "query: " query +query=`echo "$query" | tr ' ' '+'` + + +if printf "$languages" | grep -qs "$selected"; then + url="cheat.sh/$selected/$query" +else + url="cheat.sh/$selected~$query" +fi + +curl "$url" From 8b1d872d376b226acc7fbb5ef33c9f87c62da048 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 10 Dec 2021 00:53:08 +0100 Subject: [PATCH 143/188] Add git blame line nvim plugin --- home/.config/nvim/lua/plugins/plugin_list.lua | 4 ++++ .../nvim/lua/plugins/settings/blame_line.lua | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 home/.config/nvim/lua/plugins/settings/blame_line.lua diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index 213f1e9..1eb3743 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -21,6 +21,10 @@ local plugin_list = { { "wakatime/vim-wakatime" }, -- Track time spent coding { "mhinz/vim-startify" }, -- Nice startup screen for vim when started withotu file/dir { "dbeniamine/cheat.sh-vim" }, -- Quick interaction with cheat.sh cheatsheets + { + "tveskag/nvim-blame-line", -- Show commit affecting cursor line + config = get_plugin_file("blame_line.lua") + }, { "vimwiki/vimwiki", -- Wiki pages for vim config = get_plugin_file("vimwiki.lua"), diff --git a/home/.config/nvim/lua/plugins/settings/blame_line.lua b/home/.config/nvim/lua/plugins/settings/blame_line.lua new file mode 100644 index 0000000..8165577 --- /dev/null +++ b/home/.config/nvim/lua/plugins/settings/blame_line.lua @@ -0,0 +1,14 @@ +local vim = require("vim") +local m = require("utility.mappings") + +m.keymap("n", "", ":ToggleBlameLine") + +-- Enable blame line automatically +--vim.cmd[[autocmd BufEnter * EnableBlameLine]] + +-- Specify the highlight group used for the virtual text ('Comment' by default) +vim.g.blameLineVirtualTextHighlight = 'Question' + +-- Don't show a blame line when it isn't yet commited +-- there's no reason to show "Not yet commited" since we have git gutter +vim.g.blameLineMessageWhenNotYetCommited = '' From 2418031d0c5f163ea6dcc67e955e41bed6e5cea6 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 10 Dec 2021 00:55:07 +0100 Subject: [PATCH 144/188] Don't use opt=true where it doesn't make sense --- home/.config/nvim/lua/plugins/plugin_list.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index 1eb3743..c270d5b 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -47,31 +47,31 @@ local plugin_list = { "vim-airline/vim-airline", -- Status line config = get_plugin_file("airline.lua"), requires = { - { "vim-airline/vim-airline-themes", opt = true }, - { "ryanoasis/vim-devicons", opt = true }, + { "vim-airline/vim-airline-themes" }, + { "ryanoasis/vim-devicons" }, }, }, { "preservim/nerdtree", -- File tree config = get_plugin_file("nerdtree.lua"), requires = { - { "Xuyuanp/nerdtree-git-plugin", opt = true }, - { "tiagofumo/vim-nerdtree-syntax-highlight", opt = true }, - { "ryanoasis/vim-devicons", opt = true }, + { "Xuyuanp/nerdtree-git-plugin" }, + { "tiagofumo/vim-nerdtree-syntax-highlight" }, + { "ryanoasis/vim-devicons" }, }, }, { "mfussenegger/nvim-dap", -- Support for the debugging within vim config = get_plugin_file("nvim-dap.lua"), - requires = { "mfussenegger/nvim-dap-python", opt = true }, + requires = { "mfussenegger/nvim-dap-python" }, }, { "junegunn/fzf.vim", -- Fuzzy finder (TODO: consider replacing with telescope) run = function() fn['fzf#install']() end, config = get_plugin_file("fzf.lua"), requires = { - { "junegunn/fzf", opt = false }, - { "stsewd/fzf-checkout.vim", opt = true }, + { "junegunn/fzf" }, + { "stsewd/fzf-checkout.vim" }, } }, { From 4b92916fd367448fc8b7e23b4e2471593855e6a8 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 10 Dec 2021 00:55:40 +0100 Subject: [PATCH 145/188] Add more comments - Moooooreeee! --- home/.config/nvim/lua/plugins/plugin_list.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua index c270d5b..de4a4ce 100644 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ b/home/.config/nvim/lua/plugins/plugin_list.lua @@ -51,6 +51,7 @@ local plugin_list = { { "ryanoasis/vim-devicons" }, }, }, + -- TODO: Consider changing this to nvim-tree { "preservim/nerdtree", -- File tree config = get_plugin_file("nerdtree.lua"), @@ -80,10 +81,12 @@ local plugin_list = { run = function() vim.fn['firenvim#install'](0) end }, { - "williamboman/nvim-lsp-installer", -- LSP protocol configurations, autocomplete, autoinstaller + "williamboman/nvim-lsp-installer", -- LSP auto-installer config = get_plugin_file("lsp.lua"), requires = { + -- Predefined LSP server configurations "neovim/nvim-lspconfig", + -- Support for autocompletion "hrsh7th/nvim-cmp", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", From 52877996e4c2ec226ce9bf52cc4e84254dfa2bbb Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 10 Dec 2021 02:15:50 +0100 Subject: [PATCH 146/188] Move nvim config to it's own repo and link module --- .gitmodules | 3 + home/.config/nvim | 1 + home/.config/nvim/coc-settings.json | 15 -- home/.config/nvim/init.lua | 13 -- home/.config/nvim/lua/core/abbreviations.lua | 26 ---- home/.config/nvim/lua/core/autocmd.lua | 21 --- home/.config/nvim/lua/core/init.lua | 7 - home/.config/nvim/lua/core/mappings.lua | 111 ------------- home/.config/nvim/lua/core/options.lua | 55 ------- home/.config/nvim/lua/core/theme.lua | 43 ----- home/.config/nvim/lua/lsp/autoformat.lua | 5 - home/.config/nvim/lua/lsp/init.lua | 31 ---- home/.config/nvim/lua/lsp/keymaps.lua | 57 ------- home/.config/nvim/lua/lsp/rename.lua | 147 ------------------ home/.config/nvim/lua/plugins/init.lua | 36 ----- home/.config/nvim/lua/plugins/packer.lua | 114 -------------- home/.config/nvim/lua/plugins/plugin_list.lua | 124 --------------- .../nvim/lua/plugins/settings/airline.lua | 36 ----- .../nvim/lua/plugins/settings/blame_line.lua | 14 -- .../.config/nvim/lua/plugins/settings/coc.vim | 99 ------------ .../nvim/lua/plugins/settings/commentary.lua | 10 -- .../plugins/settings/deprecated/semshi.lua | 31 ---- .../nvim/lua/plugins/settings/firenvim.lua | 27 ---- .../.config/nvim/lua/plugins/settings/fzf.lua | 36 ----- .../.config/nvim/lua/plugins/settings/lsp.lua | 87 ----------- .../nvim/lua/plugins/settings/nerdtree.lua | 62 -------- .../nvim/lua/plugins/settings/nvim-dap.lua | 25 --- .../nvim/lua/plugins/settings/treesitter.lua | 28 ---- .../lua/plugins/settings/vim-code-dark.lua | 4 - .../nvim/lua/plugins/settings/vimwiki.lua | 12 -- home/.config/nvim/lua/utility/mappings.lua | 29 ---- home/.config/nvim/lua/vim.lua | 7 - 32 files changed, 4 insertions(+), 1312 deletions(-) create mode 160000 home/.config/nvim delete mode 100644 home/.config/nvim/coc-settings.json delete mode 100644 home/.config/nvim/init.lua delete mode 100644 home/.config/nvim/lua/core/abbreviations.lua delete mode 100644 home/.config/nvim/lua/core/autocmd.lua delete mode 100644 home/.config/nvim/lua/core/init.lua delete mode 100644 home/.config/nvim/lua/core/mappings.lua delete mode 100644 home/.config/nvim/lua/core/options.lua delete mode 100644 home/.config/nvim/lua/core/theme.lua delete mode 100644 home/.config/nvim/lua/lsp/autoformat.lua delete mode 100644 home/.config/nvim/lua/lsp/init.lua delete mode 100644 home/.config/nvim/lua/lsp/keymaps.lua delete mode 100644 home/.config/nvim/lua/lsp/rename.lua delete mode 100644 home/.config/nvim/lua/plugins/init.lua delete mode 100644 home/.config/nvim/lua/plugins/packer.lua delete mode 100644 home/.config/nvim/lua/plugins/plugin_list.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/airline.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/blame_line.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/coc.vim delete mode 100644 home/.config/nvim/lua/plugins/settings/commentary.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/deprecated/semshi.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/firenvim.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/fzf.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/lsp.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/nerdtree.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/nvim-dap.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/treesitter.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/vim-code-dark.lua delete mode 100644 home/.config/nvim/lua/plugins/settings/vimwiki.lua delete mode 100644 home/.config/nvim/lua/utility/mappings.lua delete mode 100644 home/.config/nvim/lua/vim.lua diff --git a/.gitmodules b/.gitmodules index e02eb0d..4475b2d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "root/usr/local/src/z.lua"] path = "root/usr/local/src/z.lua" url = "https://github.com/skywind3000/z.lua" +[submodule "home/.config/nvim"] + path = home/.config/nvim + url = https://github.com/ItsDrike/neovim diff --git a/home/.config/nvim b/home/.config/nvim new file mode 160000 index 0000000..5e10bd3 --- /dev/null +++ b/home/.config/nvim @@ -0,0 +1 @@ +Subproject commit 5e10bd30328a890bc2f62d8687b3c346a8032b14 diff --git a/home/.config/nvim/coc-settings.json b/home/.config/nvim/coc-settings.json deleted file mode 100644 index 3665990..0000000 --- a/home/.config/nvim/coc-settings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "pairs.enableCharacters": [ - "(", - "[", - "{", - "'", - "\"", - "`" - ], - "diagnostic.checkCurrentLine": true, - "coc.preferences.formatOnSaveFiletypes": [ - "json" - ], - "python.linting.flake8Enabled": true -} diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua deleted file mode 100644 index e562985..0000000 --- a/home/.config/nvim/init.lua +++ /dev/null @@ -1,13 +0,0 @@ --- The configuration is scattered across multiple files in the lua/ folder --- We can require the individual configurations from here - - --- This loads in the basic nvim configuration that doesn't rely on any --- plugins. it provides default keymaps, options, theming, autocmds, ... -require "core" - --- This loads packer plugin manager which manages our plugins --- NOTE: Removing this will NOT disable the plugins, but it will disable --- automatic packer installation, allowing for the plugins to be deleted --- manually (from ~/.local/share/nvim/site/pack/packer). -require "plugins" diff --git a/home/.config/nvim/lua/core/abbreviations.lua b/home/.config/nvim/lua/core/abbreviations.lua deleted file mode 100644 index 95cb0e1..0000000 --- a/home/.config/nvim/lua/core/abbreviations.lua +++ /dev/null @@ -1,26 +0,0 @@ -local vim = require("vim") -local fn = vim.fn -local m = require("utility.mappings") - -local function cabbrev(input, result, reabbrev) - m.abbrev("c", input, result, reabbrev) -end - --- Invalid case abbreviations -cabbrev("Wq", "wq") -cabbrev("wQ", "wq") -cabbrev("WQ", "wq") -cabbrev("Wa", "wa") -cabbrev("W", "w") -cabbrev("Q", "q") -cabbrev("Qall", "qall") -cabbrev("W!", "w!") -cabbrev("Q!", "q!") -cabbrev("Qall!", "qall!") - --- Save file with sudo -cabbrev("w!!", "w !sudo tee > /dev/null %") - --- Reload lua configuration -local initlua = fn.stdpath("config") .. "init.lua" -cabbrev("reload", "luafile " .. initlua) diff --git a/home/.config/nvim/lua/core/autocmd.lua b/home/.config/nvim/lua/core/autocmd.lua deleted file mode 100644 index f98eefb..0000000 --- a/home/.config/nvim/lua/core/autocmd.lua +++ /dev/null @@ -1,21 +0,0 @@ -local vim = require("vim") -local cmd = vim.cmd - --- Disable automatic commenting on newlines -cmd[[autocmd FileType * setlocal formatoptions-=cro]] - --- Have vim jump to last position when reopening a file -cmd[[autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif]] - --- Automatically delete all trailing whitespace on save -cmd[[autocmd BufWritePre * %s/\s\+$//e]] - --- Enable spellcheck for certain file types -cmd[[autocmd FileType tex,latex,markdown,gitcommit setlocal spell spelllang=en_us]] - --- Use auto-wrap for certain file types at 119 chars -cmd[[autocmd FileType markdown setlocal textwidth=119]] - --- Don't show line numbers in terminal -cmd[[autocmd BufEnter term://* setlocal nonumber | setlocal norelativenumber]] - diff --git a/home/.config/nvim/lua/core/init.lua b/home/.config/nvim/lua/core/init.lua deleted file mode 100644 index 2eba0e8..0000000 --- a/home/.config/nvim/lua/core/init.lua +++ /dev/null @@ -1,7 +0,0 @@ --- Require additional scripts which contain individual configurations - -require "core.options" -require "core.theme" -require "core.mappings" -require "core.abbreviations" -require "core.autocmd" diff --git a/home/.config/nvim/lua/core/mappings.lua b/home/.config/nvim/lua/core/mappings.lua deleted file mode 100644 index 4e4afa8..0000000 --- a/home/.config/nvim/lua/core/mappings.lua +++ /dev/null @@ -1,111 +0,0 @@ -local m = require("utility.mappings") -local vim = require("vim") -local g = vim.g - - --- This is a bit silly, but I don't like passing the mode argument -g.mapleader = "\\" - --- Unmap arrow keys in normal mode to remove bad habits -m.keymap("n", "", "") -m.keymap("n", "", "") -m.keymap("n", "", "") -m.keymap("n", "", "") - --- Tab navigation -m.keymap("n", "", "gt") -m.keymap("n", "", "gT") -m.keymap("n", "", ":tabnew") -m.keymap("n", "", ":tabmove +") -m.keymap("n", "", ":tabmove -") -m.keymap("n", "", ":tabp") -m.keymap("n", "", ":tabn") -m.keymap("n", "", ":tabc") - --- Buffer navigation -m.keymap("n", "", ":bn") -m.keymap("n", "", ":bp") -m.keymap("n", "", ":bd") - --- Set splits navigation to just ALT + hjkl -m.keymap("n", "", "h") -m.keymap("n", "", "j") -m.keymap("n", "", "k") -m.keymap("n", "", "l") - --- Split size adjusting -m.keymap("n", "", ":vertical resize +3") -m.keymap("n", "", ":vertical resize -3") -m.keymap("n", "", ":resize +3") -m.keymap("n", "", ":resize -3") - --- Define some common shortcuts -m.keymap("n", "", ":w") -m.keymap("i", "", ":wi") -m.keymap("n", "", ":undo") -m.keymap("n", "", ":redo") - --- Terminal -m.keymap("n", "", ":split term://zsh:resize -7i") -m.keymap("n", "", ":vnew term://zshi") -m.keymap("n", "", ":tabnew term://zshi") -m.keymap("t", "", "") - --- Use space for folding/unfolding sections -m.keymap("n", "", "za") -m.keymap("v", "", "zf") - --- Use shift to quickly move 10 lines up/down -m.keymap("n", "K", "10k") -m.keymap("n", "J", "10j") - --- Moving lines around -m.keymap("v", "", ":m '>+1gv=gv") -m.keymap("v", "", ":m '<-2gv=gv") -m.keymap("i", "", ":m .+1==i") -m.keymap("i", "", ":m .-2==i") -m.keymap("n", "j", ":m .+1==") -m.keymap("n", "k", ":m .-2==") - --- Quick word replacing (use . for next word) -m.keymap("n", "cn", "*``cgn") -m.keymap("n", "cN", "*``cgN") - --- Enable/Disable auto commenting -m.keymap("n", "c", ":setlocal formatoptions-=cro") -m.keymap("n", "C", ":setlocal formatoptions+=cro") - --- Don't leave visual mode after indenting -m.keymap("v", "<", "", ">gv") - --- Center (and unfold) after going to next/prev search item -m.keymap("n", "n", "nzzzv") -m.keymap("n", "N", "Nzzzv") - --- System clipboard copying -m.keymap("v", "", '"+y') - --- Alias replace all -m.keymap("n", "", ":%s//gI", {silent=false}) - --- Stop search highlight with Esc -m.keymap("n", "", ":noh") - --- Start spell-check -m.keymap("n", "s", ":setlocal spell! spelllang=en_us") - --- Run shell check -m.keymap("n", "p", ":!shellckeck %") - --- Compile opened file (using custom script) -m.keymap("n", "", ":w | !comp %") - --- Close all opened buffers -m.keymap("n", "Q", ":bufdo bdelete") - --- Don't set the incredibely annoying mappings that trigger dynamic SQL --- completion with dbext and keeps on freezing vim whenever pressed with --- a message saying that dbext plugin isn't installed --- See :h ft-sql.txt -vim.g.omni_sql_no_default_maps = 1 diff --git a/home/.config/nvim/lua/core/options.lua b/home/.config/nvim/lua/core/options.lua deleted file mode 100644 index b2cb2d2..0000000 --- a/home/.config/nvim/lua/core/options.lua +++ /dev/null @@ -1,55 +0,0 @@ -local vim = require("vim") -local cmd = vim.cmd -local o = vim.opt - -cmd[[filetype plugin on]] - --- Tab/Indent settings -o.autoindent = true -- Enable autoindent -o.expandtab = true -- Expand tabs to spaces -o.tabstop = 4 -- Tab size in spaces -o.shiftwidth = 4 -- Indentation size -o.softtabstop = 4 -- Tabs/Spaces interlop -o.tabpagemax = 50 -- More tabs -o.shiftround = true -- Always round indent to multiple of shiftwidth - --- Folding -o.foldmethod = "indent" -- Use indent to determine the fold levels -o.foldnestmax = 8 -- Only fold up to given amount of levels -o.foldlevel = 2 -- Set initial fold level (don't fold first 2 levels) -o.foldenable = false -- Hide all folds by default - --- Split order -o.splitbelow = true -- Put new windows below current -o.splitright = true -- Put new vertical splits to right - --- In-file search (/) -o.ignorecase = true -- Use case insensitive matching -o.incsearch = true -- Show partial matches while typing -o.hlsearch = true -- Highlight search matches - --- Show whitespace -o.list = true -- Enable showing characters like , , ... -o.listchars = {tab = " ", trail = "·"} -- Specify which characters to show - --- Command-mode search -o.wildmode = {"longest", "list", "full"} -- Enable autocompletion -o.wildmenu = true -- Display all matching files when we tab complete -table.insert(o.path, "**") -- Search down into subfolders with tab completion -o.wildignore = vim.tbl_extend( -- Ignore certain files/folders in wildmenu - "force", o.wildignore, { - "*.pyc", "*_build/*", - "**/coverage/*", "**/node_modules/*", - "**/android/*", "**/ios/*", - "**/.git/*", - } -) - --- Files -o.encoding = "utf-8" -- Use UTF-8 encoding -o.autoread = true -- Automatically reload files on change - --- Misc -o.mouse = "a" -- Enable mouse mode -o.undolevels = 999 -- Lots of these -o.history = 1000 -- More history diff --git a/home/.config/nvim/lua/core/theme.lua b/home/.config/nvim/lua/core/theme.lua deleted file mode 100644 index b2628c5..0000000 --- a/home/.config/nvim/lua/core/theme.lua +++ /dev/null @@ -1,43 +0,0 @@ -local vim = require("vim") -local cmd = vim.cmd -local g = vim.g -local o = vim.opt - -cmd[[syntax on]] -- Turn on syntax highlighting - -o.cursorline = true -- Highlight cursor line -o.laststatus = 2 -- Always show status line -o.number = true -- Show line numbers -o.relativenumber = true -- Use relative line numbers -o.showmatch = true -- Show matching bracket -o.scrolloff = 5 -- Keep 5 lines horizontal scrolloff -o.sidescrolloff = 5 -- Keep 5 chars vertical scrolloff -o.showmode = false -- Don't display mode (it's on status line anyway) - --- I wasn't able to find a way to set guioptions directly in lua -cmd[[ -set guioptions-=m " Remove menubar -set guioptions-=T " Remove toolbar -set guioptions-=r " Remove right-hand scrollbar -set guioptions-=L " Remove left-hand scrollbar -]] - --- Override some colorscheme colors --- * Use more noticable cursor line color -cmd[[ -augroup coloroverride - autocmd! - autocmd ColorScheme * highlight CursorLine guibg=#2b2b2b - autocmd ColorScheme * highlight CursorLineNr guifg=#1F85DE ctermfg=LightBlue -augroup END -]] - --- Set the colorscheme to default to trigger the above autocmds --- This can be overridden from plugin definitions as this file is ran before those -cmd[[colorscheme default]] - --- Don't use true colors in TTY -o.termguicolors = os.getenv("DISPLAY") and true or false - --- Use proper syntax highlighting in fenced codeblocks -g.markdown_fenced_languages = {"html", "javascript", "typescript", "css", "scss", "lua", "vim", "python"} diff --git a/home/.config/nvim/lua/lsp/autoformat.lua b/home/.config/nvim/lua/lsp/autoformat.lua deleted file mode 100644 index e4363c1..0000000 --- a/home/.config/nvim/lua/lsp/autoformat.lua +++ /dev/null @@ -1,5 +0,0 @@ -local vim = require("vim") -local cmd = vim.cmd - --- Always automatically format on write for given filenames -cmd[[autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100)]] diff --git a/home/.config/nvim/lua/lsp/init.lua b/home/.config/nvim/lua/lsp/init.lua deleted file mode 100644 index 1e26feb..0000000 --- a/home/.config/nvim/lua/lsp/init.lua +++ /dev/null @@ -1,31 +0,0 @@ --- Neovim has built in support for the language server protocol (LSP). For --- which reason I decided to utilize it directly instead of relying on plugins --- such as COC, which reimplement it completely just to support default vim --- too, since I don't need pure vim support, utilizing this built in support --- makes a lot more sense and will be faster. --- --- By default, setting up LSP doesn't technically require any plugins, however --- I still do use the recommended neovim/nvim-lspconfig plugin, along with --- williamboman/nvim-lsp-installer, because it makes things a lot easier to get --- working. The lspconfig holds the default configurations for the individual --- language servers, avoiding the need of tediously configuring them manually, --- and the lspinstaller gives us a way to automatically install selected --- language servers locally for nvim only, which means we won't need to look at --- the install instructions for each language server and install it user or --- system wide. --- --- However, since this configuration shouldn't be plugin dependant, as it is --- outside of the plugins/ directory and LSP is supported by neovim directly, --- this folder is here to provide the non-plugin dependant LSP configuration, --- but I do not manually define the configuration for each language server, --- since I do actually utilize those plugins, but sturcturing like this still --- does give space for completely custom configurations written from scratch --- without relying on any external plugins at all. If you do want to do that, --- this would be the place to set this up. --- --- NOTE: With my current configuration, this file is only ran by being required --- in the lsp plugin config file, if you don't wish to run with plugins, you'll --- want to require this file from init.lua directly. - -require("lsp.keymaps") -require("lsp.autoformat") diff --git a/home/.config/nvim/lua/lsp/keymaps.lua b/home/.config/nvim/lua/lsp/keymaps.lua deleted file mode 100644 index e3c9b9a..0000000 --- a/home/.config/nvim/lua/lsp/keymaps.lua +++ /dev/null @@ -1,57 +0,0 @@ -local m = require("utility.mappings") - --- See `:help vim.lsp.*` for documentation on any of the below mapped functions - --- Check if certain plugins are installed, if so, they should be used --- to define some mappings -local telescope_installed, _ = pcall(require, "telescope") -local lsp_signature_installed, _ = pcall(require, "lsp_signature") - --- Lookups -m.keymap("n", "gd", "lua vim.lsp.buf.definition()") -m.keymap('n', 'gD', 'lua vim.lsp.buf.declaration()') -m.keymap("n", "gr", "lua vim.lsp.buf.references()") -m.keymap("n", "gi", "lua vim.lsp.buf.implementation()") -m.keymap("n", "gt", "lua vim.lsp.buf.type_definition()") - -if telescope_installed then - m.keymap('n', 'gd', 'lua require("telescope.builtin").lsp_definitions()') - m.keymap('n', 'gr', 'lua require("telescope.builtin").lsp_references()') - m.keymap('n', 'gi', 'lua require("telescope.builtin").lsp_implementations()') - m.keymap('n', 'gt', 'lua require("telescope.builtin").lsp_type_definitions()') -end - --- Formatting -m.keymap('n', 'gf', 'lua vim.lsp.buf.formatting()') -m.keymap('v', 'gf', 'lua vim.lsp.buf.range_formatting()') - --- Hover info -m.keymap("n", "", "lua vim.lsp.buf.signature_help()") -m.keymap("n", "M", "lua vim.lsp.buf.hover()") - -if lsp_signature_installed then - m.keymap('n', '', 'lua require("lsp_signature").signature()') -end - --- Diagnostics -m.keymap('n', '[g', 'lua vim.diagnostic.goto_prev()') -m.keymap('n', ']g', 'lua vim.diagnostic.goto_next()') -m.keymap('n', 'ge', 'lua vim.diagnostic.open_float(nil, { scope = "line", })') - -if telescope_installed then - m.keymap('n', 'ge', 'lua require("telescope.builtin").lsp_document_diagnostics()') -end - --- LSP Workspace -m.keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()') -m.keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()') -m.keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))') - ---Actions -if telescope_installed then - m.keymap('n', 'ga', 'lua require("telescope.builtin").lsp_code_actions()') - m.keymap('v', 'ga', 'lua require("telescope.builtin").lsp_range_code_actions()') -end - --- Use custom implementation for renaming all references -m.keymap('n', 'gn', 'lua require("lsp.rename").rename()') diff --git a/home/.config/nvim/lua/lsp/rename.lua b/home/.config/nvim/lua/lsp/rename.lua deleted file mode 100644 index 6ce4cc6..0000000 --- a/home/.config/nvim/lua/lsp/rename.lua +++ /dev/null @@ -1,147 +0,0 @@ --- Nvim's LSP lacks rename-all functionality which plugins like Coc provide --- this is a manual implementation of this feature -local vim = require("vim") -local api = vim.api -local cmd = vim.cmd -local lsp = vim.lsp -local fn = vim.fn - -local M = {} - --- Unique name for the rename window, so we can access it --- from close_rename_win function. -local unique_name = "lsp-rename-win" - --- File require string. Neede because we will be defining keymaps --- applied only to the rename window buffer which will refer to --- functions within this file, for that, they need to call require -local file_require_string = "lsp.rename" - --- Check whether LSP is actually active. -local function check_lsp_active() - local active_clients = lsp.get_active_clients() - if next(active_clients) == nil then - return false - end - return true -end - --- Once in the rename window buffer, apply specific mappings to confirm or --- cancel renaming, and define a specific autocmd to close the window if --- we leave it. -local function apply_actions() - local prefix = string.format("lua require('%s')", file_require_string) - local close_win_s = prefix .. ".close_rename_win()" - local do_rename_s = prefix .. ".do_rename()" - -- Automatically close the window if it's escaped - api.nvim_command("autocmd QuitPre ++nested ++once :silent " .. close_win_s) - -- Define confirm and exit buffer-specific keymaps - api.nvim_command("inoremap " .. do_rename_s .. "") - api.nvim_command("nnoremap q " .. close_win_s .. "") -end - --- Closes the rename window (identified by the `unique_name`) -function M.close_rename_win() - if fn.mode() == "1" then - cmd[[stopinsert]] - end - - local exists, winid = pcall(api.nvim_win_get_var, 0, unique_name) - if exists then - api.nvim_win_close(winid, true) - end -end - --- Trigger renaming -function M.do_rename() - local new_name = vim.trim(fn.getline('.')) - M.close_rename_win() - local current_name = fn.expand("") - - if not new_name or #new_name == 0 or new_name == current_name then - return - end - - local params = lsp.util.make_position_params() - params.newName = new_name - lsp.buf_request(0, "textDocument/rename", params, function(_, result, _, _) - if not result then - -- If the server returns an empty result, don't do anything - return - end - - -- The result contains all places we need to update the name - -- of the identifier, so we apply those edits. - lsp.util.apply_workspace_edit(result) - - if not result.changes then - return - end - - -- Collect amounts of affected files and total renames. - local total_files = 0 - local total_renames = 0 - for _, renames in pairs(result.changes) do - total_files = total_files + 1 - for _ in pairs(renames) do - total_renames = total_renames + 1 - end - end - - -- Once the changes were applied, these files won't be saved - -- automatically, let's remind ourselves to save those... - print(string.format( - "Changed %s file%s (%s rename%s). To save %s, run ':w%s'", - total_files, - total_files > 1 and "s" or "", - total_renames, - total_renames > 1 and "s" or "", - total_files > 1 and "them" or "it", - total_files > 1 and "a" or "" - )) - end) -end - --- Create the rename window -function M.rename() - if not check_lsp_active() then - print("No LSP client available, can't rename!") - return - end - - -- In case there already is another rename window opened, close it - M.close_rename_win() - - - -- Read the current name here, before we're in the rename window - local current_name = fn.expand('') - - -- Create a window within our buffer with our `unique_name` so that it - -- can be found from the close fucntion and automatically enter it - local win_opts = { - relative = 'cursor', - row = 0, - col = 0, - width = 30, - height = 1, - style = 'minimal', - border = 'single' - } - local buf = api.nvim_create_buf(false, true) - local win = api.nvim_open_win(buf, true, win_opts) - api.nvim_win_set_var(0, unique_name, win) - - -- Automatically enter insert mode - cmd[[startinsert]] - - -- Pre-write the current name of given object into the rename window - -- and set cursor behind it - api.nvim_buf_set_lines(buf, 0, -1, false, {current_name}) - api.nvim_win_set_cursor(win, {1, #current_name}) - - -- Set actions for auto-closing the window and buffer-specific mappings - -- to confirm or close rename - apply_actions() -end - -return M diff --git a/home/.config/nvim/lua/plugins/init.lua b/home/.config/nvim/lua/plugins/init.lua deleted file mode 100644 index d93a202..0000000 --- a/home/.config/nvim/lua/plugins/init.lua +++ /dev/null @@ -1,36 +0,0 @@ -local vim = require("vim") -local packer_m = require("plugins.packer") - --- Require packer_compiled to lazy-load all of the plugins and their settings --- automatically. If this fails, it means we probably didn't yet compile --- packer. This file is generated upon running :PackerCompile, so if we didn't --- find it, we inform the user to run it. We can't run it here directly, --- because packer may not yet be installed, bootstrapping happens only after --- this to allow this lazy loadning behavior. If we required packer before --- this, the lazy-loading would have no effect. -local packer_compiled_ok, _ = pcall(require, "compiled.packer_compiled") -if not packer_compiled_ok then - vim.notify( - "Run :PackerCompile or :PackerSync", - vim.log.levels.WARN, - { title = "Notification" } - ) -end - --- If packer isn't present, install it automatically it -local present, packer = pcall(require, "packer") - -local first_install = false -if not present then - first_install = packer_m.bootstrap_packer() - if first_install then - -- We know this will work now that packer was bootstrapped - -- Otherwise we'd receive false in first_install - ---@diagnostic disable-next-line:different-requires - packer = require("packer") - end -end - --- Obtain the plugins defined in plugin_list.ua -local plugin_list = require("plugins.plugin_list") -packer_m.startup(packer, plugin_list, first_install) diff --git a/home/.config/nvim/lua/plugins/packer.lua b/home/.config/nvim/lua/plugins/packer.lua deleted file mode 100644 index 624b663..0000000 --- a/home/.config/nvim/lua/plugins/packer.lua +++ /dev/null @@ -1,114 +0,0 @@ -local vim = require("vim") -local cmd = vim.cmd -local fn = vim.fn - -local M = {} - --- Define some paths used in the functions -M.packer_install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" -M.packer_compile_path = fn.stdpath("config") .. "/lua/compiled/packer_compiled.lua" - --- Define basic default settings for packer -M.packer_settings = { - display = { - open_fn = function() - return require('packer.util').float({ border = "rounded" }) - end, - prompt_border = "rounded", - }, - git = { - -- Timeout for git clones in seconds - clone_timeout = 600, - }, - profile = { - enable = true, - -- The time that a pluign's load time must surpass for it to be included - -- in the profile (in miliseconds) - threshold = 1, - }, - compile_path = M.packer_compile_path, - auto_clean = true, - compile_on_sync = true -} - --- Define default plugins which should always be used -M.default_plugin_list = { - -- Let packer manager itself, so that it gets updates - { "wbthomason/packer.nvim" }, - - -- Add plugin for speeding up `require` in lua by caching - --{ "lewis6991/impatient.nvim" }, - - -- Replaces default filetype.vim sourced on startup, which includes - -- 800+ autocommands setting the filetype based on the filename. This - -- is very slow and this plugin merges them into single autocommand, - -- which is 175x faster, improving startup time - --{ "nathom/filetype.nvim" }, -} - --- Download and load packer plugin manager -function M.bootstrap_packer() - print("Clonning pakcer plugin manager, please wait...") - -- First remove the directory in case it already exists but packer isn't present - fn.delete(M.packer_install_path, "rf") - fn.system({ - "git", "clone", "--depth", "1", - "https://github.com/wbthomason/packer.nvim", - M.packer_install_path - }) - - -- Add packer plugin via nvim's internal plugin system - -- and make sure that we can now require it. - cmd("packadd packer.nvim") - local present, packer = pcall(require, "packer") - if present then - print("Packer clonned successfully.") - return true - else - print("Couldn't clone packer! Packer path: " .. M.packer_install_path .. "\n" .. packer) - return false - end -end - --- Run packer startup with the default config and given plugin settings --- Expects: `packer`, `plugin_list`, `run_sync`, `settings_override` -function M.startup(packer, plugin_list, run_sync, settings_override) - -- Initialize packer with default settings extended by - -- the given settings override - local settings = M.packer_settings - if settings_override then - settings = vim.tbl_extend("foce", settings, settings_override) - end - packer.reset() - packer.init(settings) - - -- Run packer startup and use all given plugins with their settings - -- including the default plugins - local use = packer.use - return packer.startup(function() - -- Use the default plugins (should be first) - for _, plugin_settings in pairs(M.default_plugin_list) do - use(plugin_settings) - end - - -- Use the obtained plugins - if plugin_list and not vim.tbl_isempty(plugin_list) then - for _, plugin_settings in pairs(plugin_list) do - use(plugin_settings) - end - end - - -- We can also automatically run sync to install all specified plugins - -- immediately, this is useful if we've just bootstrapped packer. - if run_sync then - vim.notify( - "Make sure to restart after packer sync!", - vim.log.levels.WARN, - { title = "Notification" } - ) - packer.sync() - end - end) -end - -return M diff --git a/home/.config/nvim/lua/plugins/plugin_list.lua b/home/.config/nvim/lua/plugins/plugin_list.lua deleted file mode 100644 index de4a4ce..0000000 --- a/home/.config/nvim/lua/plugins/plugin_list.lua +++ /dev/null @@ -1,124 +0,0 @@ -local vim = require("vim") -local fn = vim.fn - -local plugin_directory = fn.stdpath("config") .. "/lua/plugins/settings" - --- Return the line (string) to be executed with lua that loads in given plugin file. --- This is useful for the `config` or `setup` parameters of packer's use to source --- both `.vim` and `.lua` files. --- Expects a `plugin_file` which is a relative path from the `plugin_directory` folder. -local function get_plugin_file(plugin_file) - local source_line = string.format('source %s/%s', plugin_directory, plugin_file) - return string.format("vim.fn.execute('%s')", source_line) -end - - --- Define packer plugins --- The individual tables will get passed into the packer's use function -local plugin_list = { - { "airblade/vim-gitgutter" }, -- Git status in files - { "dhruvasagar/vim-table-mode" }, -- Easy way to construct markdown tables - { "wakatime/vim-wakatime" }, -- Track time spent coding - { "mhinz/vim-startify" }, -- Nice startup screen for vim when started withotu file/dir - { "dbeniamine/cheat.sh-vim" }, -- Quick interaction with cheat.sh cheatsheets - { - "tveskag/nvim-blame-line", -- Show commit affecting cursor line - config = get_plugin_file("blame_line.lua") - }, - { - "vimwiki/vimwiki", -- Wiki pages for vim - config = get_plugin_file("vimwiki.lua"), - }, - { - "tpope/vim-commentary", -- Adds ability to comment out sections of files - config = get_plugin_file("commentary.lua") - }, - { - "tomasiser/vim-code-dark", -- Vim theme inspired by vscode's Dark+ - config = get_plugin_file("vim-code-dark.lua") - }, - { - "nvim-treesitter/nvim-treesitter", -- AST language analysis providing semantic highlighting - config = get_plugin_file("treesitter.lua"), - run = ':TSUpdate', - requires = { "nvim-treesitter/playground", opt = true } - }, - { - "vim-airline/vim-airline", -- Status line - config = get_plugin_file("airline.lua"), - requires = { - { "vim-airline/vim-airline-themes" }, - { "ryanoasis/vim-devicons" }, - }, - }, - -- TODO: Consider changing this to nvim-tree - { - "preservim/nerdtree", -- File tree - config = get_plugin_file("nerdtree.lua"), - requires = { - { "Xuyuanp/nerdtree-git-plugin" }, - { "tiagofumo/vim-nerdtree-syntax-highlight" }, - { "ryanoasis/vim-devicons" }, - }, - }, - { - "mfussenegger/nvim-dap", -- Support for the debugging within vim - config = get_plugin_file("nvim-dap.lua"), - requires = { "mfussenegger/nvim-dap-python" }, - }, - { - "junegunn/fzf.vim", -- Fuzzy finder (TODO: consider replacing with telescope) - run = function() fn['fzf#install']() end, - config = get_plugin_file("fzf.lua"), - requires = { - { "junegunn/fzf" }, - { "stsewd/fzf-checkout.vim" }, - } - }, - { - 'glacambre/firenvim', -- Integrates neovim into the browser - config = get_plugin_file("firenvim.lua"), - run = function() vim.fn['firenvim#install'](0) end - }, - { - "williamboman/nvim-lsp-installer", -- LSP auto-installer - config = get_plugin_file("lsp.lua"), - requires = { - -- Predefined LSP server configurations - "neovim/nvim-lspconfig", - -- Support for autocompletion - "hrsh7th/nvim-cmp", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - }, - }, - - -- TODO: Consider testing out telescope as an alternative to FZF, I've heard a lot of - -- positive feedback about it, but I haven't yet got the chance to meaningfully test - -- it and configure it. - --{ - -- "nvim-telescope/telescope.nvim", - -- --config = get_plugin_file("telescope.lua") - -- module = "telescope", - -- cmd = "Telescope", - -- requires = { - -- { "nvim-lua/popup.nvim" }, - -- { "nvim-lua/plenary.nvim" }, - -- } - --}, - - -- Coc is disabled because we're using LSP. It implements support from language servers from - -- scratch, which is slower than neovim's built-in LSP and since this configuration won't work - -- with pure vim, we can rely on nvim-only thigns. I left it here because LSP can sometimes - -- cause issues and Coc is a lot more friendly to setup. - -- { - -- "neoclide/coc.nvim", - -- branch = "release", - -- config = get_plugin_file("coc.vim"), - -- requires = { "antoinemadec/coc-fzf", opt = true }, - -- }, -} - -return plugin_list diff --git a/home/.config/nvim/lua/plugins/settings/airline.lua b/home/.config/nvim/lua/plugins/settings/airline.lua deleted file mode 100644 index 7184da5..0000000 --- a/home/.config/nvim/lua/plugins/settings/airline.lua +++ /dev/null @@ -1,36 +0,0 @@ -local vim = require("vim") -local g = vim.g -local cmd = vim.cmd - --- Don't use special separators -g.airline_right_sep = "" -- (default: <) -g.airline_left_sep = "" -- (default: >) - --- Tabline setup --- TODO: Figure out how to set # separated variables in lua (open for PRs) -cmd[[let g:airline#extensions#tabline#enabled = 1]] -- Enable tabline (top line) -cmd[[let g:airline#tabline#formatter = 'unique_tail']] -- Tabline filename formatter - --- Special symbols -g.webdevicons_enable_airline_statusline = 0 -- Use special icons from vim-devicons (requires nerdfonts) -g.airline_powerline_fonts = 1 -- Use special symbols from poweline fonts (line no, col no) -if not os.getenv("DISPLAY") then -- Use ASCII-only if we're in TTY - g.airline_symbols_ascii = 1 -end - --- Disable airline in nerdtree buffer --- TODO; For some reason, this fails even though it works in regular vimscript ---[[ -cmd[[ -augroup filetype_nerdtree - au! - au FileType nerdtree call s:disable_airline_on_nerdtree() - au WinEnter,BufWinEnter,TabEnter * call s:disable_airline_on_nerdtree() -augroup END - -fu s:disable_airline_on_nerdtree() abort - let nerdtree_winnr = index(map(range(1, winnr('$')), {_,v -> getbufvar(winbufnr(v), '&ft')}), 'nerdtree') + 1 - call timer_start(0, {-> nerdtree_winnr && setwinvar(nerdtree_winnr, '&stl', '%#Normal#')}) -endfu -]] ---]] diff --git a/home/.config/nvim/lua/plugins/settings/blame_line.lua b/home/.config/nvim/lua/plugins/settings/blame_line.lua deleted file mode 100644 index 8165577..0000000 --- a/home/.config/nvim/lua/plugins/settings/blame_line.lua +++ /dev/null @@ -1,14 +0,0 @@ -local vim = require("vim") -local m = require("utility.mappings") - -m.keymap("n", "", ":ToggleBlameLine") - --- Enable blame line automatically ---vim.cmd[[autocmd BufEnter * EnableBlameLine]] - --- Specify the highlight group used for the virtual text ('Comment' by default) -vim.g.blameLineVirtualTextHighlight = 'Question' - --- Don't show a blame line when it isn't yet commited --- there's no reason to show "Not yet commited" since we have git gutter -vim.g.blameLineMessageWhenNotYetCommited = '' diff --git a/home/.config/nvim/lua/plugins/settings/coc.vim b/home/.config/nvim/lua/plugins/settings/coc.vim deleted file mode 100644 index 11be2ae..0000000 --- a/home/.config/nvim/lua/plugins/settings/coc.vim +++ /dev/null @@ -1,99 +0,0 @@ -" Converting these settings into lua isn't easy since we utilize -" which needs to be in a vim script context, making it impossible -" to replicate with simple vim.cmd call. It also contains a lot of function -" definitions taken from the coc github page without provided lua alternatives -" this makes it quite complicated to replicate this in pure lua, -" however if anyone knows how to completely reproduce everything here in lua, -" this is open to pull requests - -let g:coc_global_extensions = [ - \ 'coc-pyright', 'coc-json', 'coc-git', 'coc-html', 'coc-css', - \ 'coc-clangd', 'coc-cmake', 'coc-java', 'coc-sh', 'coc-toml', - \ 'coc-yaml', 'coc-omnisharp', 'coc-markdownlint', 'coc-pairs', - \ 'coc-lua' - \ ] - -nmap l :CocFzfList - -" Use tab for trigger completion with characters ahead and navigate. -" Use command ':verbose imap ' to make sure tab is not mapped by other plugin. -inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() -inoremap pumvisible() ? "\" : "\" - - -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -" Use to trigger completion. -inoremap coc#refresh() - -" Use to confirm completion, `u` means break undo chain at current position. -" Coc only does snippet and additional edit on confirm. -inoremap pumvisible() ? "\" : "\u\" -" Or use `complete_info` if your vim support it, like: -" inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" - -" Use `[g` and `]g` to navigate diagnostics -nmap [g (coc-diagnostic-prev) -nmap ]g (coc-diagnostic-next) - -" Remap keys for gotos -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) - -function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - else - call CocAction('doHover') - endif -endfunction - -" Remap for rename current word -nmap rn (coc-rename) - -" Remap for format selected region -xmap f (coc-format-selected) -nmap f (coc-format-selected) - -augroup CocGroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') -augroup end - -" Remap for do codeAction of selected region, ex: `aap` for current paragraph -xmap a (coc-codeaction-selected) -nmap a (coc-codeaction-selected) - -" Remap for do codeAction of current line -nmap ac (coc-codeaction) -" Fix autofix problem of current line -nmap qf (coc-fix-current) - -" Create mappings for function text object, requires document symbols feature of languageserver. -xmap if (coc-funcobj-i) -xmap af (coc-funcobj-a) -omap if (coc-funcobj-i) -omap af (coc-funcobj-a) - -" Use `:Format` to format current buffer -command! -nargs=0 Format :call CocAction('format') - -" Use `:Fold` to fold current buffer -command! -nargs=? Fold :call CocAction('fold', ) - -" use `:OR` for organize import of current buffer -command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') - -" Add status line support, for integration with other plugin, checkout `:h coc-status` -set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} diff --git a/home/.config/nvim/lua/plugins/settings/commentary.lua b/home/.config/nvim/lua/plugins/settings/commentary.lua deleted file mode 100644 index 6a1f92e..0000000 --- a/home/.config/nvim/lua/plugins/settings/commentary.lua +++ /dev/null @@ -1,10 +0,0 @@ -local m = require("utility.mappings") -local vim = require("vim") -local cmd = vim.cmd - --- Set up shortcuts to quickly comment some code -m.keymap("n", "", ":Commentary") -m.keymap("v", "", ":Commentary") - --- Set up comments for unhandled file types -cmd[[autocmd FileType apache setlocal commentstring=#\ %s]] diff --git a/home/.config/nvim/lua/plugins/settings/deprecated/semshi.lua b/home/.config/nvim/lua/plugins/settings/deprecated/semshi.lua deleted file mode 100644 index a2479e6..0000000 --- a/home/.config/nvim/lua/plugins/settings/deprecated/semshi.lua +++ /dev/null @@ -1,31 +0,0 @@ -local vim = require("vim") -local cmd = vim.cmd -local fn = vim.fn - --- Unused because the extension significantly slows down the opening time for vim. --- Also, while the semantic highlighting in it is neat, for me, it isn't worth in. --- --- The extension default colorscheme makes the code look like unicorn vommit. --- I'd prefer a simpler extension that only really distinguishes between classes, --- functions and perhaps unused variables. I don't need to see a different color --- when I access something as an attribute, but it would be neat to see what that --- attribute actually holds, is it a class or a fucntion. But from my searching, --- I wasn't able to find anything like this. This is open to pull requests. --- Plugin: numirias/semshi - -if (fn.has("python3")) then - fn.system({"pip", "install", "nvim", "--upgrade"}) -end - -cmd[[ -function MyCustomHighlights() - hi semshiParameter ctermfg=117 guifg=#93CCED - hi semshiParameterUnused ctermfg=117 guifg=#5e8193 cterm=underline gui=underline - hi semshiBuiltin ctermfg=29 guifg=#48bda5 - hi semshiAttribute ctermfg=254 guifg=#d1d1d1 - hi semshiImported ctermfg=214 guifg=#f8c466 cterm=bold gui=bold - hi semshiLocal ctermfg=209 guifg=#ff875f -endfunction - -autocmd FileType python call MyCustomHighlights() -]] diff --git a/home/.config/nvim/lua/plugins/settings/firenvim.lua b/home/.config/nvim/lua/plugins/settings/firenvim.lua deleted file mode 100644 index 3aa19ce..0000000 --- a/home/.config/nvim/lua/plugins/settings/firenvim.lua +++ /dev/null @@ -1,27 +0,0 @@ -local vim = require("vim") -local cmd = vim.cmd -local g = vim.g - --- Detect filetype based on filename for certain websites -cmd[[ -autocmd BufEnter github.com_*.txt set filetype=markdown -autocmd BufEnter txti.es_*.txt set filetype=typescript -]] - --- Define firenvim configuration -g.firenvim_config = { - globalSettings = { alt="all" }, - localSettings = { - [".*"] = { - cmdline = "neovim", - content = "text", - priority = 0, - selector = "textarea", - -- Don't automatically take over, require the shortcut - takeover = "never", - }, - -- Enable automatic takeover on certain websites where it makes sense - ["https?://github.com"] = { takeover = "always", priority=1 }, - ["https?://txti.es"] = { takeover = "always", priority = 1 }, - } -} diff --git a/home/.config/nvim/lua/plugins/settings/fzf.lua b/home/.config/nvim/lua/plugins/settings/fzf.lua deleted file mode 100644 index 5cd78d0..0000000 --- a/home/.config/nvim/lua/plugins/settings/fzf.lua +++ /dev/null @@ -1,36 +0,0 @@ -local m = require("utility.mappings") -local vim = require("vim") -local cmd = vim.cmd -local g = vim.g - -g.fzf_layout = { - up = '~90%', - window = { - width = 0.8, - height = 0.8, - yoffset = 0.5, - offset = 0.5 - } -} - -cmd[[let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline']] - --- Customize the Files command to use ripgrep which respects .gitignore files -cmd[[ -command! -bang -nargs=? -complete=dir Files - \ call fzf#run(fzf#wrap('files', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden' }), 0)) -]] - --- Add an AllFiles variation that shows ignored files too -cmd[[ -command! -bang -nargs=? -complete=dir AllFiles - \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({ 'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore' }), 0)) -]] - -m.keymap("n", "f", ":Files") -m.keymap("n", "F", ":AllFiles") -m.keymap("n", "b", ":Buffers") -m.keymap("n", "h", ":History") -m.keymap("n", "r", ":Rg") -m.keymap("n", "R", ":Rg", { silent = false }) -m.keymap("n", "gb", ":GBranches") diff --git a/home/.config/nvim/lua/plugins/settings/lsp.lua b/home/.config/nvim/lua/plugins/settings/lsp.lua deleted file mode 100644 index ffa6c3c..0000000 --- a/home/.config/nvim/lua/plugins/settings/lsp.lua +++ /dev/null @@ -1,87 +0,0 @@ -local vim = require("vim") -local fn = vim.fn - --- Load in our default plugin independant LSP settings. --- These are loaded from here, because we don't need them if we aren't using --- these plugins, which actually load in the LSP configurations and install the --- individual language servers. However it is possible to configure nvim --- without these plugins and so this config is separated from the plugin --- config. for more info, check the comments in lsp/init.lua -require("lsp") - - --- Configure nvim-cmp to respect LSP completions. -local cmp = require("cmp") - -cmp.setup({ - sources = { - { name = "nvim_lsp" } - } -}) - --- The nvim-cmp almost supports LSP's capabilities so you should advertise it to LSP servers -local cmp_capabilities = vim.lsp.protocol.make_client_capabilities() -cmp_capabilities = require("cmp_nvim_lsp").update_capabilities(cmp_capabilities) - --- Load in the needed settigns for nvim-lsp-installer plugin. --- This ensures automatic installation for the individual language servers. -local lsp_installer = require("nvim-lsp-installer") - --- Define some settings for the UI and installation path for the language --- servers. -lsp_installer.settings({ - ui = { - icons = { - server_installed = "✓", - server_pending = "➜", - server_uninstalled = "✗" - }, - keymaps = { - toggle_server_expand = "", - install_server = "i", - update_server = "u", - uninstall_server = "X", - }, - }, - install_root_dir = fn.stdpath("data") .. "/lsp_servers", -}) - --- Define a table of requested language servers which should be automatically --- installed. --- --- NOTE: pylsp requires external installaion with --- :PylspInstall pyls-flake8 pyls-mypy pyls-isort -local requested_servers = { - "clangd", "cmake", "omnisharp", - "cssls", "dockerls", "gopls", "html", - "hls", "jsonls", "jdtls", "tsserver", - "sumneko_lua", "pyright", "pylsp", - "sqlls", "vimls", "yamlls" -} - --- Go through the requested servers and ensure installation --- Once the servers are ready, run setup() on them. This setup is basically --- running the lspconfig.server.setup() which means lspconfig is needed to do --- this. -local lsp_installer_servers = require('nvim-lsp-installer.servers') -for _, requested_server in pairs(requested_servers) do - local server_available, server = lsp_installer_servers.get_server(requested_server) - if server_available then - -- Setup the server once it will become ready - server:on_ready(function() - -- Advertise completion capabilities by nvim-cmp - local opts = { capabilities = cmp_capabilities } - server:setup(opts) - end) - -- If the server isn't yet installed, schedule the installation - if not server:is_installed() then - server:install() - end - else - vim.notify( - "Can't install: Language server " .. server .. " was not found - SKIPPED", - vim.log.levels.WARN, - { title = "Notification" } - ) - end -end diff --git a/home/.config/nvim/lua/plugins/settings/nerdtree.lua b/home/.config/nvim/lua/plugins/settings/nerdtree.lua deleted file mode 100644 index 5ea4d21..0000000 --- a/home/.config/nvim/lua/plugins/settings/nerdtree.lua +++ /dev/null @@ -1,62 +0,0 @@ -local m = require("utility.mappings") -local vim = require("vim") -local g = vim.g -local fn = vim.fn -local cmd = vim.cmd - --- Implement manual NERDTreeToggle, but use NERDTreeFind for openning. --- This makes NERDTree open with the current file pre-selected -m.keymap("n", "", "g:NERDTree.IsOpen() ? ':NERDTreeClose' : @% == '' ? ':NERDTree' : ':NERDTreeFind'", {expr=true}) - -g.NERDTreeShowHidden = 1 -g.NERDTreeMinimalUI = 1 -g.NERDTreeShowLineNumbers = 0 -g.NERDTreeWinSize = 25 - -g.NERDTreeDirArrowExpandable = '►' -g.NERDTreeDirArrowCollapsible = '▼' - --- Disable devicons for nerdtree in TTY -if not os.getenv("DISPLAY") then - g.webdevicons_enable_nerdtree = 0 -else - g.DevIconsEnableFoldersOpenClose = 1 -end - --- If a directory is specified, start NERDTree -cmd[[ -autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | - \ execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | - \ endif -]] - --- Exit Vim if NERDTree is the only window left. --- WARNING: This causes issues when closing buffers ---[[ -cmd[[ -autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | - \ quit | endif -]] - --- If another buffer tries to replace NerdTree, put it in another window, and bring back NerdTree. -cmd[[ -autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | - \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif -]] - --- Use $NERDTREE_BOOKMARKS environment variable for the location of .NERDTreeBookmarks file -local bookmark_loc = os.getenv("NERDTREE_BOOKMARKS") -if bookmark_loc then - -- Check if file exists (lua doesn't have a built-in function for this) - local file_exists = os.rename(bookmark_loc, bookmark_loc) and true or false - - if not file_exists then - -- While this is possible with os.execute in lua, we would need to do some hacky - -- things to capture output from os.execute and it's simpler to just use vimscript - local dir = fn.system("dirname $NERDTREE_BOOKMARKS") - fn.system({"mkdir", "-p", dir}) - fn.system("touch $NERDTREE_BOOKMARKS") - end - g.NERDTreeBookmarksFile = bookmark_loc -end diff --git a/home/.config/nvim/lua/plugins/settings/nvim-dap.lua b/home/.config/nvim/lua/plugins/settings/nvim-dap.lua deleted file mode 100644 index ef597ff..0000000 --- a/home/.config/nvim/lua/plugins/settings/nvim-dap.lua +++ /dev/null @@ -1,25 +0,0 @@ -local m = require("utility.mappings") -local vim = require("vim") -local cmd = vim.cmd - --- Define dap mappings (:help dap-mapping) -local prefix = ":lua require('dap')." -m.keymap("n", "", prefix .. "continue()") -m.keymap("n", "", prefix .. "step_over()") -m.keymap("n", "", prefix .. "step_into()") -m.keymap("n", "", prefix .. "step_out()") -m.keymap("n", "", prefix .. "toggle_breakpoint()") -m.keymap("n", "", prefix .. "set_breakpoint(vim.fn.input('Breakpoint condition: '))") -m.keymap("n", "", prefix .. "set_breakpoint(nil, nil, vim.fn.input('Log point message: '))") -m.keymap("n", "di", prefix .. "repl.open()") -m.keymap("n", "dl", prefix .. "run_last()") - --- Setup dap for python (requires nvim-dap-python plugin) -require('dap-python').setup('/usr/bin/python') -- Path to python with `debugpy` library installed -require('dap-python').test_runner = 'pytest' -- Use pytest to run unit tests - --- Python mappings -local pyprefix = ":lua require('dap-python')." -m.keymap("n", "dptm", pyprefix .. "test_method()") -m.keymap("n", "dptc", pyprefix .. "test_class()") -m.keymap("v", "ds", "" .. pyprefix .. "debug_selection()") diff --git a/home/.config/nvim/lua/plugins/settings/treesitter.lua b/home/.config/nvim/lua/plugins/settings/treesitter.lua deleted file mode 100644 index 7f90fe3..0000000 --- a/home/.config/nvim/lua/plugins/settings/treesitter.lua +++ /dev/null @@ -1,28 +0,0 @@ -local vim = require("vim") -local g = vim.g - --- Enable treesitter highlight for all languages -require'nvim-treesitter.configs'.setup { - -- Always automatically install parsers for these languages - ensure_installed = { - "bash", "python", "lua", "rust", "go", "haskell", - "c", "cpp", "cmake", "c_sharp", "java", "dockerfile", - "json", "toml", "yaml", "regex", "vim", "html", "css", - "typescript", "javascript", - }, - highlight = { - enable = true, - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, -} - --- Use git instead of curl for downloading parsers -require("nvim-treesitter.install").prefer_git = true - --- Use treesitter for syntax-aware folding -g.foldmethod = "expr" -g.foldexpr = "nvim_treesitter#foldexpr()" diff --git a/home/.config/nvim/lua/plugins/settings/vim-code-dark.lua b/home/.config/nvim/lua/plugins/settings/vim-code-dark.lua deleted file mode 100644 index 6690b7f..0000000 --- a/home/.config/nvim/lua/plugins/settings/vim-code-dark.lua +++ /dev/null @@ -1,4 +0,0 @@ -local vim = require("vim") -local cmd = vim.cmd - -cmd[[colorscheme codedark]] diff --git a/home/.config/nvim/lua/plugins/settings/vimwiki.lua b/home/.config/nvim/lua/plugins/settings/vimwiki.lua deleted file mode 100644 index 80a10cc..0000000 --- a/home/.config/nvim/lua/plugins/settings/vimwiki.lua +++ /dev/null @@ -1,12 +0,0 @@ -local vim = require("vim") -local cmd = vim.cmd -local g = vim.g - -local wiki_conf = {} -wiki_conf["path"] = "~/Personal/vimwiki" -wiki_conf["path_html"] = "~/Personal/vimwiki-html" -wiki_conf["html_template"] = "~/Personal/vimwiki-html/template.tpl" -wiki_conf["syntax"] = "markdown" -wiki_conf["ext"] = ".md" -g.vimwiki_list = {wiki_conf} - diff --git a/home/.config/nvim/lua/utility/mappings.lua b/home/.config/nvim/lua/utility/mappings.lua deleted file mode 100644 index 6d18a7e..0000000 --- a/home/.config/nvim/lua/utility/mappings.lua +++ /dev/null @@ -1,29 +0,0 @@ -local vim = require("vim") -local api = vim.api -local cmd = vim.cmd - -local M = {} - --- Define a keymap -function M.keymap(mode, shortcut, command, options) - -- Assume silent, noremap unless specified otherwise - local opts = {noremap=true, silent=true} - - if options then opts = vim.tbl_extend("force", opts, options) end - api.nvim_set_keymap(mode, shortcut, command, opts) -end - --- Define an abbreviation -function M.abbrev(mode, input, result, reabbrev) - -- Assume noreabbrev unless specified otherwise - reabbrev = reabbrev or false - local command - if reabbrev then - command = mode .. "abbrev" - else - command = mode .. "noreabbrev" - end - cmd(command .. " " .. input .. " " .. result) -end - -return M diff --git a/home/.config/nvim/lua/vim.lua b/home/.config/nvim/lua/vim.lua deleted file mode 100644 index 2bfb110..0000000 --- a/home/.config/nvim/lua/vim.lua +++ /dev/null @@ -1,7 +0,0 @@ --- This file is here to allow running `local vim = require("vim")`, which --- avoids the hassle of having to ignore vim as undefined-global for lua --- language server diagnostics. Another advantage is that it actually allows --- us to detect the attributes of vim so we will get suggestions. - ----@diagnostic disable-next-line:undefined-global -return vim From 95d5adee76b9c7059ac3e38674796de8e9b90f31 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 10 Dec 2021 02:51:07 +0100 Subject: [PATCH 147/188] Remove attributions for neovim (now in it's own repo) --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ab2a459..c0c7af6 100644 --- a/README.md +++ b/README.md @@ -84,5 +84,4 @@ is the list of all projects which helped the existence of this repository: - [BrodieRobertson's dotfiles](https://github.com/BrodieRobertson/dotfiles) - [BrodieRobertson's scripts](https://github.com/BrodieRobertson/scripts) - [Derek Taylor's dotfiles](https://gitlab.com/dwt1/dotfiles) -- [CosmicVim source](https://github.com/CosmicNvim/CosmicNvim) From d2be01d6024b834e5617159b2e275b90604995f5 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 11 Dec 2021 21:37:26 +0100 Subject: [PATCH 148/188] Change nvim submodule URL --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 4475b2d..76d2d6b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -14,5 +14,5 @@ path = "root/usr/local/src/z.lua" url = "https://github.com/skywind3000/z.lua" [submodule "home/.config/nvim"] - path = home/.config/nvim - url = https://github.com/ItsDrike/neovim + path = home/.config/nvim + url = https://github.com/ItsDrike/Stellar-Nvim From 177a33cc69ec51247f9afb78b32a7882fed4a7dc Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 13 Dec 2021 17:15:48 +0100 Subject: [PATCH 149/188] Add tldr package --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index 3197d77..6627e64 100644 --- a/packages.yaml +++ b/packages.yaml @@ -17,6 +17,7 @@ pacman: - exa # Colored LS - bat # Colored cat with tons of cool options - dust # User readable du to find biggest dirs/files + - tldr # Shorter help pages, if man is too long - hyperfine # Command benchmark - abduco # Terminal session manager - mlocate # System indexing and quick file searching From 39a66f0e3060555259f4b1a5286a58e0b121c8f0 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 15 Dec 2021 22:08:01 +0100 Subject: [PATCH 150/188] Hide errors if git status fails --- home/.config/shell/prompt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/shell/prompt b/home/.config/shell/prompt index cad4982..c9bd65d 100755 --- a/home/.config/shell/prompt +++ b/home/.config/shell/prompt @@ -52,7 +52,7 @@ git_prompt() { ref=$(command git symbolic-ref HEAD 2> /dev/null) || ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 echo -n " $ORANGE${ref#refs/heads/}" - if [ ! -z "$(git status --short)" ]; then + if [ ! -z "$(git status --short 2>/dev/null)" ]; then echo "$RED+" fi } From fd57706a2f715633be59392a281e815550458f0d Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 15 Dec 2021 22:08:59 +0100 Subject: [PATCH 151/188] Minor fixes --- home/.config/shell/prompt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/.config/shell/prompt b/home/.config/shell/prompt index c9bd65d..149ca8b 100755 --- a/home/.config/shell/prompt +++ b/home/.config/shell/prompt @@ -148,10 +148,10 @@ add-zsh-hook precmd exec_time_precmd_hook # Primary Prompt [ "$EUID" -eq 0 ] && PS1="$RED%n$RESET" || PS1="$GREEN%n$RESET" # user PS1+="$(foreign_prompt)" -PS1+="$(working_directory)" +PS1+="\$(working_directory)" PS1+="\$(git_prompt)" PS1+="\$(display_cmd_time)" -PS1+=" $PURPLE%(!.#.$)$RESET " # Final symbol (# or $/») +PS1+=" $PURPLE%(!.#.$)$RESET " # Final symbol (# or $) # Next line prompt PS2="$RED\ $RESET" From bb0d435321c82a746ad3009c82f50a4b6ad61f1c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 15 Dec 2021 22:09:43 +0100 Subject: [PATCH 152/188] =?UTF-8?q?Add=20a=20note=20about=20dangers=20of?= =?UTF-8?q?=20using=20=E2=86=B5=20symbol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- home/.config/shell/prompt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/home/.config/shell/prompt b/home/.config/shell/prompt index 149ca8b..2781bfe 100755 --- a/home/.config/shell/prompt +++ b/home/.config/shell/prompt @@ -172,7 +172,15 @@ if [ $TERM = "linux" ]; then RPS1+="%(?..${RED}%? X$RESET)" else # Read comments for the section above. - #RPS+="\$(display_cmd_time)" + #RPS1+="\$(display_cmd_time)" + + # NOTE: "↵" symbol could cause issues with on some terminals/machines that + # don't handle unicode well, this issue could be very confusing to debug, + # and it would not be apparent what's wrong since the symbol itself will + # be drawn, however when it is drawn, it will also move the cursor line + # 2 places back since this symbol is made up of 3 bytes (in unicode) and + # regular ASCII characters only take up 1 byte, this means that whenever + # the right-side prompt appears (on error), the prompt would have this issue. RPS1="%(?..${RED}%? ↵$RESET)" fi From 4dd86fe4cd0eb2ce1770eba528976ffb55f69236 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 00:17:13 +0100 Subject: [PATCH 153/188] Move to jetbrains mono font for alacritty --- home/.config/alacritty/alacritty.yml | 7 +++---- packages.yaml | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/home/.config/alacritty/alacritty.yml b/home/.config/alacritty/alacritty.yml index b00716a..544211a 100644 --- a/home/.config/alacritty/alacritty.yml +++ b/home/.config/alacritty/alacritty.yml @@ -111,11 +111,10 @@ font: # - (macOS) Menlo # - (Linux/BSD) monospace # - (Windows) Consolas - family: monospace - #family: Source Code Pro + family: JetBrains Mono # The `style` can be specified to pick a specific face. - style: Regular + style: Medium # Bold font face #bold: @@ -135,7 +134,7 @@ font: # # If the italic family is not specified, it will fall back to the # value specified for the normal font. - family: monospace + #family: monospace #family: Source Code Pro # The `style` can be specified to pick a specific face. diff --git a/packages.yaml b/packages.yaml index 6627e64..5c81b16 100644 --- a/packages.yaml +++ b/packages.yaml @@ -110,6 +110,7 @@ pacman: - noto-fonts-cjk - noto-fonts-emoji - ttf-font-awesome + - ttf-jetbrains-mono # Printer - cups # Daemon for printing From 56556173e268d45c4715be1246c2d8b62a7ab2d2 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 01:37:29 +0100 Subject: [PATCH 154/188] Add custom ipython versions --- root/usr/local/bin/ipython3.6 | 6 ++++++ root/usr/local/bin/ipython3.7 | 6 ++++++ root/usr/local/bin/ipython3.8 | 6 ++++++ root/usr/local/bin/ipython3.9 | 6 ++++++ 4 files changed, 24 insertions(+) create mode 100755 root/usr/local/bin/ipython3.6 create mode 100755 root/usr/local/bin/ipython3.7 create mode 100755 root/usr/local/bin/ipython3.8 create mode 100755 root/usr/local/bin/ipython3.9 diff --git a/root/usr/local/bin/ipython3.6 b/root/usr/local/bin/ipython3.6 new file mode 100755 index 0000000..1e61262 --- /dev/null +++ b/root/usr/local/bin/ipython3.6 @@ -0,0 +1,6 @@ +#!/usr/bin/python3.6 + +if __name__ == '__main__': + from IPython import start_ipython + start_ipython() + diff --git a/root/usr/local/bin/ipython3.7 b/root/usr/local/bin/ipython3.7 new file mode 100755 index 0000000..13fdc24 --- /dev/null +++ b/root/usr/local/bin/ipython3.7 @@ -0,0 +1,6 @@ +#!/usr/bin/python3.7 + +if __name__ == '__main__': + from IPython import start_ipython + start_ipython() + diff --git a/root/usr/local/bin/ipython3.8 b/root/usr/local/bin/ipython3.8 new file mode 100755 index 0000000..67c6d64 --- /dev/null +++ b/root/usr/local/bin/ipython3.8 @@ -0,0 +1,6 @@ +#!/usr/bin/python3.8 + +if __name__ == '__main__': + from IPython import start_ipython + start_ipython() + diff --git a/root/usr/local/bin/ipython3.9 b/root/usr/local/bin/ipython3.9 new file mode 100755 index 0000000..f116e71 --- /dev/null +++ b/root/usr/local/bin/ipython3.9 @@ -0,0 +1,6 @@ +#!/usr/bin/python3.9 + +if __name__ == '__main__': + from IPython import start_ipython + start_ipython() + From a0dfc5fd09df52aca01ca173e6961029731faa08 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 03:02:02 +0100 Subject: [PATCH 155/188] Add aliases for different python versions --- home/.config/shell/aliases | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 60d4f2f..d16038d 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -78,11 +78,19 @@ alias zi='z -I' # cd with interactive fzf selection alias zbi='z -b -I' # pick parent directory to cd into with fzf # Python -alias py3='python3' -alias py2='python2' alias ipy='ipython' alias bpy='bpython' command -v ipython > /dev/null && alias py='ipython' || alias py='python' +for version in "2 3 3.6 3.7 3.8 3.9 3.10"; do # Make aliases for py3.6,py3.7,... + if ! command -v "python$version" > /dev/null; then + continue + fi + if command -v "ipython$version" > /dev/null; then + alias "py$version"="ipython$version" + else + alias "py$version"="python$version" + fi +done # Fallbacks command -v hd > /dev/null || alias hd='hexdump -C' # Cannonical hex dump; some systems have this symlinked From ac4b447bb52a1ae87d9733cca9ed536f88229ac8 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 03:02:26 +0100 Subject: [PATCH 156/188] Add aliases to quickly configure nvim --- home/.config/shell/aliases | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index d16038d..a79fafe 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -69,6 +69,8 @@ alias cfxprofile='vim ~/.config/x11/xprofile' alias cfxmonad='vim ~/.config/xmonad/xmonad.hs && xmonad --recompile && xmonad --restart' alias cfxmobar='vim ~/.config/xmobar/xmobarrc.hs && ~/.config/xmobar/multi_mon.sh 2' alias cftodo='vim ~/Personal/vimwiki/todo.md' +alias cfnvim='vim ~/.config/nvim' +alias cfvim='cfnvim' # z.lua shortcuts alias j='z' # for the sake of autojump old habits From c606650c7da28ae2083d9e207a334a062af38c24 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 03:02:39 +0100 Subject: [PATCH 157/188] Add vimtutor alias for nvim --- home/.config/shell/aliases | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index a79fafe..9ce6f67 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -100,6 +100,7 @@ command -v md5sum > /dev/null || alias md5sum='md5' # Fallback from `md5sum` to command -v sha1sum > /dev/null || alias sha1sum='shasum' # Fallback from `sha1sum` to `shasum` command -v vim > /dev/null && alias vi='vim' # Let vim take precedence over vi command -v nvim > /dev/null && alias vi='nvim' && alias vim='nvim' # Let nvim take precedence over vi/vim +command -v vimtutor > /dev/null || alias vimtutor='nvim -c Tutor' # Let vimtutor fallback to nvim's tutor # X11 clipboard (either using xclip or xsel, xsel takes precedence if both) command -v xclip > /dev/null && alias pbcopy='xclip -selection clipboard' From 54cf0d7f36aafa1238c980c81b705f0d9c2212f1 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 03:03:40 +0100 Subject: [PATCH 158/188] Add ipython3.10 --- root/usr/local/bin/ipython3.10 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 root/usr/local/bin/ipython3.10 diff --git a/root/usr/local/bin/ipython3.10 b/root/usr/local/bin/ipython3.10 new file mode 100755 index 0000000..e365af1 --- /dev/null +++ b/root/usr/local/bin/ipython3.10 @@ -0,0 +1,6 @@ +#!/usr/bin/python3.10 + +if __name__ == '__main__': + from IPython import start_ipython + start_ipython() + From 6f613a1ea59ca0214383d88b77cd246f4b4654b0 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 03:10:16 +0100 Subject: [PATCH 159/188] Fix python aliases --- home/.config/shell/aliases | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 9ce6f67..910ad36 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -83,7 +83,7 @@ alias zbi='z -b -I' # pick parent directory to cd into with fzf alias ipy='ipython' alias bpy='bpython' command -v ipython > /dev/null && alias py='ipython' || alias py='python' -for version in "2 3 3.6 3.7 3.8 3.9 3.10"; do # Make aliases for py3.6,py3.7,... +for version in 2 3 3.6 3.7 3.8 3.9 3.10; do # Make aliases for py3.6,py3.7,... if ! command -v "python$version" > /dev/null; then continue fi From 754bbcbbd66f8ba8247f44c423c69eeae3dea7b5 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 03:15:38 +0100 Subject: [PATCH 160/188] Also add ppy and ipy aliases - py alias should always preferably use ipython, however if it isn't available, it does fall back to the pure python interpreter. - This is useful for running scripts since we would prefer ipython error output, but also for debugging, etc. - However since py will use ipython, we didn't have any good way to get back to pure python unless it's typed in it's full form, which is too long. Because of this, this adds `ppy` alias, which always points to the pure python interpreter, no matter if ipython is available or not. - This also adds a more explicit `ipy` alias, to clearly mark that we want ipython. --- home/.config/shell/aliases | 3 +++ 1 file changed, 3 insertions(+) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 910ad36..5e0ed7e 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -89,8 +89,11 @@ for version in 2 3 3.6 3.7 3.8 3.9 3.10; do # Make aliases for py3.6,py3.7,... fi if command -v "ipython$version" > /dev/null; then alias "py$version"="ipython$version" + alias "ipy$version"="ipython$version" + alias "ppy$version"="python$version" else alias "py$version"="python$version" + alias "ppy$version"="python$version" fi done From d048c2a26235cca5d03df37285797aa15ea86cd4 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 03:21:23 +0100 Subject: [PATCH 161/188] Also add ppy alias for default pyhton version --- home/.config/shell/aliases | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 5e0ed7e..cc14cbd 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -80,6 +80,7 @@ alias zi='z -I' # cd with interactive fzf selection alias zbi='z -b -I' # pick parent directory to cd into with fzf # Python +alias ppy='python' alias ipy='ipython' alias bpy='bpython' command -v ipython > /dev/null && alias py='ipython' || alias py='python' From 02237fd0b11c0d0b5a21f890c772485030f255d0 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 04:46:02 +0100 Subject: [PATCH 162/188] Don't re-run work_directory function - Re-reunning work_directory every time we redraw the prompt isn't necessary, since the function is here to generate the zsh supported syntax for the prompt that will get expanded into a work directory automatically. - The function is only here to determine whether we're in TTY and use ASCII compatible symbols if we are, however it is enough to only check this once initially, since we can't leave TTY in favor of a graphical instance without reloading the rc file and neither can we leave. - However, this function also checks for `USE_SHORTENED_WORKDIR` variable and decides which prompt to show based on it. This means that it someone was setting this variable in their profile file it would now no longer be respected, however this was never the intention of that variable, if a change is desired, the variable should simply be edited in the prompt file directly. - Removing continual calls to this function each time prompt is redrawn is worth the very minor inconvenience of no longer supporting shortened workdirs from externally set variable due to the speed benefit it gives us, though not that noticeable, it is pretty significant. Not to mention that this wasn't intended/recommended usage anyway. --- home/.config/shell/prompt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/.config/shell/prompt b/home/.config/shell/prompt index 2781bfe..b41a618 100755 --- a/home/.config/shell/prompt +++ b/home/.config/shell/prompt @@ -66,7 +66,7 @@ foreign_prompt() { fi } -# Prints appropriate working directory +#nd Prints appropriate working directory working_directory() { # By default up to 5 directories will be tolerated before shortening # After we surpass that, first directory (or ~) will be printed together with last 3 @@ -148,7 +148,7 @@ add-zsh-hook precmd exec_time_precmd_hook # Primary Prompt [ "$EUID" -eq 0 ] && PS1="$RED%n$RESET" || PS1="$GREEN%n$RESET" # user PS1+="$(foreign_prompt)" -PS1+="\$(working_directory)" +PS1+="$(working_directory)" PS1+="\$(git_prompt)" PS1+="\$(display_cmd_time)" PS1+=" $PURPLE%(!.#.$)$RESET " # Final symbol (# or $) From 5432334da62521252c12514bce7b850f18b73de3 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 05:48:36 +0100 Subject: [PATCH 163/188] Simplify python alias creation --- home/.config/shell/aliases | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index cc14cbd..b7433d2 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -79,23 +79,19 @@ alias zb='z -b' # restrict matches to parent directories alias zi='z -I' # cd with interactive fzf selection alias zbi='z -b -I' # pick parent directory to cd into with fzf -# Python -alias ppy='python' -alias ipy='ipython' -alias bpy='bpython' -command -v ipython > /dev/null && alias py='ipython' || alias py='python' -for version in 2 3 3.6 3.7 3.8 3.9 3.10; do # Make aliases for py3.6,py3.7,... - if ! command -v "python$version" > /dev/null; then - continue - fi - if command -v "ipython$version" > /dev/null; then - alias "py$version"="ipython$version" - alias "ipy$version"="ipython$version" - alias "ppy$version"="python$version" - else - alias "py$version"="python$version" - alias "ppy$version"="python$version" - fi +## Make aliases for individual cpython/pypy versions +py_versions="\n2\n3\n3.6\n3.7\n3.8\n3.9\n3.10" +echo "$py_versions" | while read version; do + for python in python pypy; do + [ "$python" = "python" ] && prefix="py" || prefix="pypy" + + if command -v "$python$version" >/dev/null; then + alias "pip$version=$python$version -m pip" + alias "$prefix$version=$python$version" + alias "i$prefix$version=$python$version -c 'import IPython;IPython.start_ipython()'" + alias "b$prefix$version=$python$version -c 'from bpython.curtsies import main;import sys;sys.exit(main())'" + fi + done done # Fallbacks From 93930bdb35eb8175cafb5d8f7a72ef7621c19b2b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 05:50:16 +0100 Subject: [PATCH 164/188] Remove unneeded ipython binaries --- root/usr/local/bin/ipython3.10 | 6 ------ root/usr/local/bin/ipython3.6 | 6 ------ root/usr/local/bin/ipython3.7 | 6 ------ root/usr/local/bin/ipython3.8 | 6 ------ root/usr/local/bin/ipython3.9 | 6 ------ 5 files changed, 30 deletions(-) delete mode 100755 root/usr/local/bin/ipython3.10 delete mode 100755 root/usr/local/bin/ipython3.6 delete mode 100755 root/usr/local/bin/ipython3.7 delete mode 100755 root/usr/local/bin/ipython3.8 delete mode 100755 root/usr/local/bin/ipython3.9 diff --git a/root/usr/local/bin/ipython3.10 b/root/usr/local/bin/ipython3.10 deleted file mode 100755 index e365af1..0000000 --- a/root/usr/local/bin/ipython3.10 +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python3.10 - -if __name__ == '__main__': - from IPython import start_ipython - start_ipython() - diff --git a/root/usr/local/bin/ipython3.6 b/root/usr/local/bin/ipython3.6 deleted file mode 100755 index 1e61262..0000000 --- a/root/usr/local/bin/ipython3.6 +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python3.6 - -if __name__ == '__main__': - from IPython import start_ipython - start_ipython() - diff --git a/root/usr/local/bin/ipython3.7 b/root/usr/local/bin/ipython3.7 deleted file mode 100755 index 13fdc24..0000000 --- a/root/usr/local/bin/ipython3.7 +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python3.7 - -if __name__ == '__main__': - from IPython import start_ipython - start_ipython() - diff --git a/root/usr/local/bin/ipython3.8 b/root/usr/local/bin/ipython3.8 deleted file mode 100755 index 67c6d64..0000000 --- a/root/usr/local/bin/ipython3.8 +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python3.8 - -if __name__ == '__main__': - from IPython import start_ipython - start_ipython() - diff --git a/root/usr/local/bin/ipython3.9 b/root/usr/local/bin/ipython3.9 deleted file mode 100755 index f116e71..0000000 --- a/root/usr/local/bin/ipython3.9 +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python3.9 - -if __name__ == '__main__': - from IPython import start_ipython - start_ipython() - From 752fd36c62d00cf2724ce749e4ba7263e352e2f7 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 10:27:05 +0100 Subject: [PATCH 165/188] Fix pip aliases for cpython/pypy - We can't simply define `pip3.6`,... because the aliases support both cpython and pypy version, which means these needs to differ. For that reason, I decided to use `ppip3` for pypy and `pip3` for cpython. However there's also an option to use the full version like this: `pypy3pip` or `py3.7pip`. --- home/.config/shell/aliases | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index b7433d2..92dc382 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -86,7 +86,12 @@ echo "$py_versions" | while read version; do [ "$python" = "python" ] && prefix="py" || prefix="pypy" if command -v "$python$version" >/dev/null; then - alias "pip$version=$python$version -m pip" + if [ "$python" = "python" ]; then + alias "pip$version=$python$version -m pip" + else + alias "ppip$version=$python$version -m pip" + fi + alias "$prefix${version}pip=$python$version -m pip" alias "$prefix$version=$python$version" alias "i$prefix$version=$python$version -c 'import IPython;IPython.start_ipython()'" alias "b$prefix$version=$python$version -c 'from bpython.curtsies import main;import sys;sys.exit(main())'" From 09ce7d00a97fb51d2989939e3c800d16d95f835c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 12:04:28 +0100 Subject: [PATCH 166/188] Convert tabs to spaces --- home/.config/shell/aliases | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 92dc382..a100151 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -285,20 +285,20 @@ fi # Normalize `open` across Linux, macOS, and Windows. # This is needed to make `open` function (see below) cross-platform if [ ! $(uname -s) = 'Darwin' ]; then - if grep -q Microsoft /proc/version; then - # Ubuntu on Windows using the Linux subsystem - alias open='explorer.exe' - else - alias open='xdg-open' - fi + if grep -q Microsoft /proc/version; then + # Ubuntu on Windows using the Linux subsystem + alias open='explorer.exe' + else + alias open='xdg-open' + fi fi # Functions if [ -f ~/.config/shell/functions ]; then - source ~/.config/shell/functions + source ~/.config/shell/functions fi # Extra if [ -f ~/.config/shell/extra ]; then - source ~/.config/shell/extra + source ~/.config/shell/extra fi From b07404d669e85f3573d37ce00728911c2ca39589 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 12:04:41 +0100 Subject: [PATCH 167/188] Use POSIX-compatible sh, not zsh --- home/.config/shell/aliases | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index a100151..67d4661 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -1,4 +1,4 @@ -#!/usr/bin/env zsh +#!/bin/sh # I'm not the greatest typist alias sl='ls' From d843e90462d97fc26b1e1f2bc2577ab8fab73cea Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 18:07:47 +0100 Subject: [PATCH 168/188] Use spaces instead of tabs --- home/.config/shell/aliases | 38 +++++++------- home/.config/shell/functions | 97 ++++++++++++++++++------------------ home/.config/shell/handlers | 77 ++++++++++++++-------------- home/.config/shell/prompt | 60 +++++++++++----------- 4 files changed, 134 insertions(+), 138 deletions(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index 67d4661..ece4962 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -37,22 +37,22 @@ alias vimdiff='nvim -d' # Directory listing aliases, defaults to exa, if aviable if command -v exa > /dev/null; then - alias ls='exa' - alias l='exa -glah --classify' - alias ll='exa -glah --classify -s=size --group-directories-first -r' - alias ldir='exa -glahD' - alias tree='exa -Tlagh' - alias dotall='exa -hulad .[a-z]*' # Show both dotdirs and dotfiles - alias dotfiles='dotall | grep -v ^d' # Show all dotfiles - alias dotdirs='dotall | grep --color=never ^d' # Show all dotdirs + alias ls='exa' + alias l='exa -glah --classify' + alias ll='exa -glah --classify -s=size --group-directories-first -r' + alias ldir='exa -glahD' + alias tree='exa -Tlagh' + alias dotall='exa -hulad .[a-z]*' # Show both dotdirs and dotfiles + alias dotfiles='dotall | grep -v ^d' # Show all dotfiles + alias dotdirs='dotall | grep --color=never ^d' # Show all dotdirs else - alias ls='ls --color=auto' - alias l='ls -lahX --classify' - alias ll='ls -lahX --classify --group-directories-first' - alias ldir='ls -lahX --classify | grep --color=never ^d' - alias dotall='ls -lahXd .[a-z]*' - alias dotfiles='dotall | grep -v ^d' - alias dotdirs='dotall | grep --color=never ^d' + alias ls='ls --color=auto' + alias l='ls -lahX --classify' + alias ll='ls -lahX --classify --group-directories-first' + alias ldir='ls -lahX --classify | grep --color=never ^d' + alias dotall='ls -lahXd .[a-z]*' + alias dotfiles='dotall | grep -v ^d' + alias dotdirs='dotall | grep --color=never ^d' fi # Config access shortcuts @@ -252,16 +252,16 @@ alias rick='curl -s -L https://raw.githubusercontent.com/ItsDrike/rickrollrc/mas # If user is not root, pass all commands via sudo/doas if [ $UID -ne 0 ]; then - # Enable aliases to be sudoed/doased + # Enable aliases to be sudoed/doased # with doas having precedence over sudo if found - ## Uncomment if you are using autocompletion (is ZSH) + ## Uncomment if you are using autocompletion (is ZSH) #command -v /usr/bin/sudo > /dev/null && alias doas='nocorrect sudo ' && alias sudo='nocorrect sudo ' #command -v /usr/bin/doas > /dev/null && alias doas='nocorrect doas ' && alias sudo='nocorrect doas ' - ## if the above is uncommented, comment this + ## if the above is uncommented, comment this command -v /usr/bin/sudo > /dev/null && alias doas='sudo ' && alias sudo='sudo ' - command -v /usr/bin/doas > /dev/null && alias doas='doas ' && alias sudo='doas ' + command -v /usr/bin/doas > /dev/null && alias doas='doas ' && alias sudo='doas ' fi # enable color support diff --git a/home/.config/shell/functions b/home/.config/shell/functions index ac35195..34f14d7 100755 --- a/home/.config/shell/functions +++ b/home/.config/shell/functions @@ -2,22 +2,22 @@ # Show application listening on given port function port() { - sudo netstat -pln | grep $1 | awk '{print $NF}' + sudo netstat -pln | grep $1 | awk '{print $NF}' } # Create a new directory and enter it function mkd() { - mkdir -p "$@" && cd "$_"; + mkdir -p "$@" && cd "$_"; } # `o` with no arguments opens the current directory, otherwise opens the given # location function o() { - if [ $# -eq 0 ]; then - open .; - else - open "$@"; - fi; + if [ $# -eq 0 ]; then + open .; + else + open "$@"; + fi; } # Use bat for nicer git diffs @@ -26,30 +26,28 @@ function batdiff() { } # Determine size of a file or total size of a directory -function dir-size() { - if du -b /dev/null > /dev/null 2>&1; then - local arg=-sbh; - else - local arg=-sh; - fi - if [[ -n "$@" ]]; then - \du $arg -- "$@"; - else - \du $arg .[^.]* ./*; - fi; +function dirsize() { + if du -b /dev/null > /dev/null 2>&1; then + local arg=-sbh; + else + local arg=-sh; + fi + if [[ -n "$*" ]]; then + \du $arg -- "$@"; + else + \du $arg .[^.]* ./*; + fi; } function randmac() { - sudo ip link set dev $1 down - sudo macchanger -A $1 - sudo ip link set dev $1 up + sudo ip link set dev $1 down + sudo macchanger -A $1 + sudo ip link set dev $1 up } # Go to the root of a git tree cdgit () { - git rev-parse --is-inside-work-tree > /dev/null 2>&1 - if [ $? -eq 0 ]; then - TEMP_PWD=`pwd` + if [ "$(git rev-parse --is-inside-work-tree > /dev/null 2>&1)" -eq 0 ]; then while ! [ -d .git ]; do cd .. done @@ -161,36 +159,37 @@ fi # Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression function targz() { - local tmpFile="${@%/}.tar"; - tar -cvf "${tmpFile}" "${@}" || return 1; + # Combine given names spearated with spaces as the filename + local tmpFile="${@%/}.tar"; + tar -cvf "${tmpFile}" "${@}" || return 1; - size=$( - stat -f"%z" "${tmpFile}" 2> /dev/null; # macOS `stat` - stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat` - ); + size=$( + stat -f"%z" "${tmpFile}" 2> /dev/null; # macOS `stat` + stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat` + ); - local cmd=""; - if (( size < 52428800 )) && hash zopfli 2> /dev/null; then - # the .tar file is smaller than 50 MB and Zopfli is available; use it - cmd="zopfli"; - else - if hash pigz 2> /dev/null; then - cmd="pigz"; - else - cmd="gzip"; - fi; - fi; + local cmd=""; + if (( size < 52428800 )) && hash zopfli 2> /dev/null; then + # the .tar file is smaller than 50 MB and Zopfli is available; use it + cmd="zopfli"; + else + if hash pigz 2> /dev/null; then + cmd="pigz"; + else + cmd="gzip"; + fi; + fi; - echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`…"; - "${cmd}" -v "${tmpFile}" || return 1; - [ -f "${tmpFile}" ] && rm "${tmpFile}"; + echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`…"; + "${cmd}" -v "${tmpFile}" || return 1; + [ -f "${tmpFile}" ] && rm "${tmpFile}"; - zippedSize=$( - stat -f"%z" "${tmpFile}.gz" 2> /dev/null; # macOS `stat` - stat -c"%s" "${tmpFile}.gz" 2> /dev/null; # GNU `stat` - ); + zippedSize=$( + stat -f"%z" "${tmpFile}.gz" 2> /dev/null; # macOS `stat` + stat -c"%s" "${tmpFile}.gz" 2> /dev/null; # GNU `stat` + ); - echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully."; + echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully."; } function anonymize { diff --git a/home/.config/shell/handlers b/home/.config/shell/handlers index f2d1680..5434015 100755 --- a/home/.config/shell/handlers +++ b/home/.config/shell/handlers @@ -1,43 +1,40 @@ -#!/usr/bin/env bash +#!/bin/sh if command -v pkgfile > /dev/null; then - # Command not found hook that uses `pkgfile` package - # to search through the package index in order to find - # a package which includes given command, which was resolved - # and not found, if there are no such packages, only print - # command not found message - command_not_found_handler() { - local pkgs cmd="$1" files=() - printf 'zsh: command not found: %s' "$cmd" # print command not found asap, then search for packages - files=(${(f)"$(pkgfile ${cmd})"}) - if (( ${#files[@]} )); then - printf '\r%s may be found in the following packages:\n' "$cmd" - local res=() repo package version file - for file in "$files[@]"; do - res=("${(0)file}") - repo="$res[1]" - printf ' %s\n' "$repo" - done - else - printf '\n' - fi - return 127 - } -elif [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then - # Ubuntu handle for bash default command-not-found - # it works similarely to the above arch alternative, - # this is based on the original bash implementation - command_not_found_handler() { - # check because cmd not found could've been removed in the meantime - if [ -x /usr/lib/command-not-found ]; then - /usr/lib/command-not-found -- "$1" - return $? - elif [ -x /usr/share/command-not-found/command-not-found ]; then - /usr/share/command-not-found/command-not-found -- "$1" - return $? - else - printf "%s: command not found\n" "$1" >&2 - return 127 - fi - } + # Command not found hook that uses `pkgfile` package + # to search through the package index in order to find + # a package which includes given command, which was resolved + # and not found, if there are no such packages, only print + # command not found message + command_not_found_handler() { + cmd="$1" + printf 'zsh: command not found: %s' "$cmd" # print command not found asap, then search for packages + repos="$(pkgfile "$cmd")" + if [ -n "$repos" ]; then + printf '\r%s may be found in the following packages:\n' "$cmd" + echo "$repos" | while read -r pkg; do + printf ' %s\n' "$pkg" + done + else + printf '\n' + fi + return 127 + } +elif [ -x /usr/lib/command-not-found ] || [ -x /usr/share/command-not-found/command-not-found ]; then + # Ubuntu handle for bash default command-not-found + # it works similarely to the above arch alternative, + # this is based on the original bash implementation + command_not_found_handler() { + # check because cmd not found could've been removed in the meantime + if [ -x /usr/lib/command-not-found ]; then + /usr/lib/command-not-found -- "$1" + return $? + elif [ -x /usr/share/command-not-found/command-not-found ]; then + /usr/share/command-not-found/command-not-found -- "$1" + return $? + else + printf "%s: command not found\n" "$1" >&2 + return 127 + fi + } fi diff --git a/home/.config/shell/prompt b/home/.config/shell/prompt index b41a618..0fe1740 100755 --- a/home/.config/shell/prompt +++ b/home/.config/shell/prompt @@ -30,20 +30,20 @@ export PROMPT_EOL_MARK="" # (unless you change it in kernel), respect this and downgrade # the color scheme accordingly (it won't look best, but it's # still better than no colors) -if [ $TERM = "linux" ]; then - GREEN="%F{002}" - RED="%F{001}" - ORANGE="%F{003}" - BLUE="%F{004}" - LBLUE="%F{006}" - PURPLE="%F{005}" +if [ "$TERM" = "linux" ]; then + GREEN="%F{002}" + RED="%F{001}" + ORANGE="%F{003}" + BLUE="%F{004}" + LBLUE="%F{006}" + PURPLE="%F{005}" else - GREEN="%F{047}" - RED="%F{196}" - ORANGE="%F{214}" - BLUE="%F{027}" - LBLUE="%F{075}" - PURPLE="%F{105}" + GREEN="%F{047}" + RED="%F{196}" + ORANGE="%F{214}" + BLUE="%F{027}" + LBLUE="%F{075}" + PURPLE="%F{105}" fi RESET="%f" @@ -52,34 +52,34 @@ git_prompt() { ref=$(command git symbolic-ref HEAD 2> /dev/null) || ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 echo -n " $ORANGE${ref#refs/heads/}" - if [ ! -z "$(git status --short 2>/dev/null)" ]; then + if [ -n "$(git status --short 2>/dev/null)" ]; then echo "$RED+" fi } # Adds @chroot or @ssh foreign_prompt() { - if [ "$(awk '$5=="/" {print $1}' Date: Sat, 18 Dec 2021 18:09:25 +0100 Subject: [PATCH 169/188] POSIX compliance, shellcheck --- home/.config/shell/aliases | 15 ++-- home/.config/shell/environment | 10 ++- home/.config/shell/functions | 135 +++++++++++++++++---------------- home/.config/shell/keybinds | 17 +++-- home/.config/shell/prompt | 33 ++++---- 5 files changed, 114 insertions(+), 96 deletions(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index ece4962..aa96ff9 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -81,7 +81,8 @@ alias zbi='z -b -I' # pick parent directory to cd into with fzf ## Make aliases for individual cpython/pypy versions py_versions="\n2\n3\n3.6\n3.7\n3.8\n3.9\n3.10" -echo "$py_versions" | while read version; do +# shellcheck disable=SC2139 +echo "$py_versions" | while read -r version; do for python in python pypy; do [ "$python" = "python" ] && prefix="py" || prefix="pypy" @@ -251,7 +252,7 @@ alias tty-clock='tty-clock -Ssc' # Terminal clock screensaver alias rick='curl -s -L https://raw.githubusercontent.com/ItsDrike/rickrollrc/master/roll.sh| bash' # Terminal rickroll # If user is not root, pass all commands via sudo/doas -if [ $UID -ne 0 ]; then +if [ "$(id -u)" -ne 0 ]; then # Enable aliases to be sudoed/doased # with doas having precedence over sudo if found @@ -266,7 +267,7 @@ fi # enable color support if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + (test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)") || eval "$(dircolors -b)" alias dir='dir --color=auto' alias vdir='vdir --color=auto' @@ -284,7 +285,7 @@ fi # Normalize `open` across Linux, macOS, and Windows. # This is needed to make `open` function (see below) cross-platform -if [ ! $(uname -s) = 'Darwin' ]; then +if [ ! "$(uname -s)" = 'Darwin' ]; then if grep -q Microsoft /proc/version; then # Ubuntu on Windows using the Linux subsystem alias open='explorer.exe' @@ -295,10 +296,12 @@ fi # Functions if [ -f ~/.config/shell/functions ]; then - source ~/.config/shell/functions + # shellcheck source=/home/itsdrike/.config/shell/functions + . "$HOME/.config/shell/functions" fi # Extra if [ -f ~/.config/shell/extra ]; then - source ~/.config/shell/extra + # shellcheck source=/home/itsdrike/.config/shell/extra + . "$HOME/.config/shell/extra" fi diff --git a/home/.config/shell/environment b/home/.config/shell/environment index bdb0d73..7e05d43 100755 --- a/home/.config/shell/environment +++ b/home/.config/shell/environment @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # Environmental variable definitions. # This file is only sourced once after login, unlike .zshrc/.bashrc @@ -8,6 +8,8 @@ # which means the XDG definitions will be ignored anyway, and # defining them may break programs when root is actually logged in. +# Define some variables for POSIX compatibility +uid="$(id -u)" # Default programs export EDITOR="nvim" @@ -18,7 +20,7 @@ export TERMINAL="alacritty" export XDG_CONFIG_HOME="$HOME/.config" export XDG_CACHE_HOME="$HOME/.cache" export XDG_DATA_HOME="$HOME/.local/share" -export XDG_RUNTIME_DIR="/run/user/$UID" +export XDG_RUNTIME_DIR="/run/user/$uid" # Per-Application XDG settings export ZDOTDIR="$XDG_CONFIG_HOME/zsh" @@ -44,6 +46,7 @@ export NERDTREE_BOOKMARKS="$XDG_CONFIG_HOME/NERDTreeBookmarks" # Colorful man pages # If bat is installed, use it as manpager +# shellcheck disable=SC2155 if command -v bat > /dev/null; then export MANPAGER="sh -c 'col -bx | bat -l man -p'" else @@ -64,3 +67,6 @@ export XSECURELOCK_SHOW_DATETIME=1 # Show current date and time in xsecurelock export QT_QPA_PLATFORMTHEME=qt5ct # Have QT use the theme from qt5ct #export QT_QPA_PLATFORMTHEME="gtk2" # Have QT use gtk2 theme. +# Remove irrelevant variables added for posix compatibility +unset posix + diff --git a/home/.config/shell/functions b/home/.config/shell/functions index 34f14d7..81c8b26 100755 --- a/home/.config/shell/functions +++ b/home/.config/shell/functions @@ -1,18 +1,23 @@ -#!/usr/bin/env zsh +#!/bin/sh +# TODO: Currently, this file isn't entirely POSIX compatible, +# it will run fine with bash or zsh, however some functions may cause +# issues with pure POSIX. The fill will however run fine, the errors +# would only occur if the incompatible functions would be started. # Show application listening on given port -function port() { - sudo netstat -pln | grep $1 | awk '{print $NF}' +port() { + sudo netstat -pln | grep "$1" | awk '{print $NF}' } # Create a new directory and enter it -function mkd() { - mkdir -p "$@" && cd "$_"; +mkd() { + # shellcheck disable=SC2164 + mkdir -p "$1" && cd "$1"; } # `o` with no arguments opens the current directory, otherwise opens the given # location -function o() { +o() { if [ $# -eq 0 ]; then open .; else @@ -21,16 +26,16 @@ function o() { } # Use bat for nicer git diffs -function batdiff() { +batdiff() { git diff --name-only --diff-filter=d | xargs bat --diff } # Determine size of a file or total size of a directory -function dirsize() { +dirsize() { if du -b /dev/null > /dev/null 2>&1; then - local arg=-sbh; + arg=-sbh; else - local arg=-sh; + arg=-sh; fi if [[ -n "$*" ]]; then \du $arg -- "$@"; @@ -39,10 +44,10 @@ function dirsize() { fi; } -function randmac() { - sudo ip link set dev $1 down - sudo macchanger -A $1 - sudo ip link set dev $1 up +randmac() { + sudo ip link set dev "$1" down + sudo macchanger -A "$1" + sudo ip link set dev "$1" up } # Go to the root of a git tree @@ -59,76 +64,76 @@ cdgit () { } # Create a data URL from a file -function dataurl() { - local mimeType=$(file -b --mime-type "$1"); - if [[ $mimeType == text/* ]]; then - mimeType="${mimeType};charset=utf-8"; - fi - echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')"; +dataurl() { + mimeType="$(file -b --mime-type "$1")" + if echo "$mimeType" | grep -e "^text/.*$" >/dev/null; then + mimeType="${mimeType};charset=utf-8" + fi + echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')"; } # `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring # the `.git` directory, listing directories first. The output gets piped into # `less` with options to preserve color and line numbers, unless the output is # small enough for one screen. -function tre() { - tree -I '.git|node_modules|bower_components' --group-directories-first "$@" | less -FRNX; +tre() { + tree -I '.git|node_modules|bower_components' --group-directories-first "$@" | less -FRNX; } # Show all the names (CNs and SANs) listed in the SSL certificate # for a given domain -function getcertnames() { - if [ -z "${1}" ]; then - echo "ERROR: No domain specified."; - return 1; - fi; +getcertnames() { + if [ -z "${1}" ]; then + echo "ERROR: No domain specified."; + return 1; + fi; - local domain="${1}"; - echo "Testing ${domain}…"; - echo ""; # newline + domain="${1}"; + echo "Testing ${domain}…"; + echo ""; # newline - local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \ - | openssl s_client -connect "${domain}:443" -servername "${domain}" 2>&1); + tmp=$(echo -e "GET / HTTP/1.0\nEOT" \ + | openssl s_client -connect "${domain}:443" -servername "${domain}" 2>&1); - if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then - local certText=$(echo "${tmp}" \ - | openssl x509 -text -certopt "no_aux, no_header, no_issuer, no_pubkey, \ - no_serial, no_sigdump, no_signame, no_validity, no_version"); - echo "Common Name:"; - echo ""; # newline - echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//" | sed -e "s/\/emailAddress=.*//"; - echo ""; # newline - echo "Subject Alternative Name(s):"; - echo ""; # newline - echo "${certText}" | grep -A 1 "Subject Alternative Name:" \ - | sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2; - return 0; - else - echo "ERROR: Certificate not found."; - return 1; - fi; + if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then + certText=$(echo "${tmp}" \ + | openssl x509 -text -certopt "no_aux, no_header, no_issuer, no_pubkey, \ + no_serial, no_sigdump, no_signame, no_validity, no_version"); + echo "Common Name:"; + echo ""; # newline + echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//" | sed -e "s/\/emailAddress=.*//"; + echo ""; # newline + echo "Subject Alternative Name(s):"; + echo ""; # newline + echo "${certText}" | grep -A 1 "Subject Alternative Name:" \ + | sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2; + return 0; + else + echo "ERROR: Certificate not found."; + return 1; + fi; } # Compare original and gzipped file size -function gz-compare() { - local origsize=$(wc -c < "$1"); - local gzipsize=$(gzip -c "$1" | wc -c); - local ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l); - printf "orig: %d bytes\n" "$origsize"; - printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio"; +gz_compare() { + origsize=$(wc -c < "$1"); + gzipsize=$(gzip -c "$1" | wc -c); + ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l); + printf "orig: %d bytes\n" "$origsize"; + printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio"; } # Extract almost any archive -function extract { +extract() { if [ -z "$1" ]; then # display usage if no parameters given echo "Usage: extract ." echo " extract [path/file_name_2.ext] [path/file_name_3.ext]" return 1 else - for n in $@ + for n in "$@" do if [ -f "$n" ] ; then case "${n%,}" in @@ -158,17 +163,18 @@ fi } # Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression -function targz() { +targz() { # Combine given names spearated with spaces as the filename - local tmpFile="${@%/}.tar"; - tar -cvf "${tmpFile}" "${@}" || return 1; + tmpFile="${*%/}.tar" + + tar -cvf "${tmpFile}" "${@}" || return 1 size=$( stat -f"%z" "${tmpFile}" 2> /dev/null; # macOS `stat` stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat` ); - local cmd=""; + cmd=""; if (( size < 52428800 )) && hash zopfli 2> /dev/null; then # the .tar file is smaller than 50 MB and Zopfli is available; use it cmd="zopfli"; @@ -192,11 +198,12 @@ function targz() { echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully."; } -function anonymize { +anonymize() { # Reset the prompt on initial run to allow this script # to be ran multiple times without user having to reload # PS1 manually - source ${XDG_CONFIG_DIR:-$HOME/.config}/shell/prompt + # shellcheck source=/home/itsdrike/.config/shell/prompt + . "${XDG_CONFIG_DIR:-$HOME/.config}/shell/prompt" # Regular expression to match 0-255 numbers (color) color_int_re='^(0+)?([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])$' @@ -211,7 +218,7 @@ function anonymize { AT_COLOR="%F{004}" MACHINE_COLOR="%F{070}" - while [[ $# -gt 0 ]]; do + while [ $# -gt 0 ]; do key=$1 case $key in diff --git a/home/.config/shell/keybinds b/home/.config/shell/keybinds index 284df26..543988b 100755 --- a/home/.config/shell/keybinds +++ b/home/.config/shell/keybinds @@ -1,4 +1,5 @@ #!/usr/bin/env zsh +# shellcheck disable=SC2030,SC2031 # Set default keybindings (mostly from oh-my-zsh) # Make sure that the terminal is in application mode when zle is active, since @@ -18,30 +19,30 @@ fi bindkey -e # Start typing + [Up-Arrow] - fuzzy find history forward -if [[ -n "${terminfo[kcuu1]}" ]]; then +if [ -n "${terminfo[kcuu1]}" ]; then autoload -U up-line-or-beginning-search zle -N up-line-or-beginning-search bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search fi # Start typing + [Down-Arrow] - fuzzy find history backward -if [[ -n "${terminfo[kcud1]}" ]]; then +if [ -n "${terminfo[kcud1]}" ]; then autoload -U down-line-or-beginning-search zle -N down-line-or-beginning-search bindkey "${terminfo[kcud1]}" down-line-or-beginning-search fi # [Home] - Go to beginning of line -[[ -n "${terminfo[khome]}" ]] && bindkey "${terminfo[khome]}" beginning-of-line || bindkey "^[[H" beginning-of-line +([ -n "${terminfo[khome]}" ] && bindkey "${terminfo[khome]}" beginning-of-line) || bindkey "^[[H" beginning-of-line # [End] - Go to end of line -[[ -n "${terminfo[kend]}" ]] && bindkey "${terminfo[kend]}" end-of-line || bindkey "^[[F" end-of-line +([ -n "${terminfo[kend]}" ] && bindkey "${terminfo[kend]}" end-of-line) || bindkey "^[[F" end-of-line # [Shift-Tab] - move through the completion menu backwards -[[ -n "${terminfo[kcbt]}" ]] && bindkey "${terminfo[kcbt]}" reverse-menu-complete +[ -n "${terminfo[kcbt]}" ] && bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Backspace] - delete backward bindkey '^?' backward-delete-char # [Delete] - delete forward -[[ -n "${terminfo[kdch1]}" ]] && bindkey "${terminfo[kdch1]}" delete-char || bindkey "^[[3~" delete-char +([ -n "${terminfo[kdch1]}" ] && bindkey "${terminfo[kdch1]}" delete-char) || bindkey "^[[3~" delete-char # [Ctrl-Delete] - delete whole forward-word bindkey '^[[3;5~' kill-word @@ -53,9 +54,9 @@ bindkey '^[[1;5D' backward-word # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. bindkey '^r' history-incremental-search-backward # [PageUp] - Up a line of history -[[ -n "${terminfo[kpp]}" ]] && bindkey "${terminfo[kpp]}" up-line-or-history +[ -n "${terminfo[kpp]}" ] && bindkey "${terminfo[kpp]}" up-line-or-history # [PageDown] - Down a line of history -[[ -n "${terminfo[knp]}" ]] && bindkey "${terminfo[knp]}" down-line-or-history +[ -n "${terminfo[knp]}" ] && bindkey "${terminfo[knp]}" down-line-or-history # [Space] - do history expansion on space bindkey ' ' magic-space diff --git a/home/.config/shell/prompt b/home/.config/shell/prompt index 0fe1740..ca0aaa3 100755 --- a/home/.config/shell/prompt +++ b/home/.config/shell/prompt @@ -1,4 +1,5 @@ #!/usr/bin/env zsh +# shellcheck disable=SC2155 # Configuration variables: @@ -75,7 +76,7 @@ working_directory() { if [ $USE_SHORTENED_WORKDIR != 1 ]; then echo -n " $BLUE$~" - elif [ $TERM = "linux" ]; then + elif [ "$TERM" = "linux" ]; then echo -n " $BLUE%(5~|%-1~/.../%3~|%4~)" else echo -n " $BLUE%(5~|%-1~/…/%3~|%4~)" @@ -96,7 +97,7 @@ exec_time_preexec_hook() { exec_time_precmd_hook() { [[ $SHOW_CMD_TIME == 0 ]] && return [[ -z $PROMPT_EXEC_TIME_START ]] && return - local PROMPT_EXEC_TIME_STOP=$(date +%s.%N) + local PROMPT_EXEC_TIME_STOP="$(date +%s.%N)" PROMPT_EXEC_TIME_DURATION=$(echo "($PROMPT_EXEC_TIME_STOP - $PROMPT_EXEC_TIME_START) * 1000" | bc -l) unset PROMPT_EXEC_TIME_START } @@ -104,24 +105,24 @@ format_time() { # Do some formatting to get nice time (e.g. 2m 12s) from miliseconds # $1 is the milisecond amount (int or float) # $2 is the precision (ms/s/m/h/d) - local T=$1 - local D=$(echo "scale=0;$T/1000/60/60/24" | bc -l) - local H=$(echo "scale=0;$T/1000/60/60%24" | bc -l) - local M=$(echo "scale=0;$T/1000/60%60" | bc -l) - local S=$(echo "scale=0;$T/1000%60" | bc -l) - local MS=$(echo "scale=0;$T%1000" | bc -l) + local T="$1" + local D="$(echo "scale=0;$T/1000/60/60/24" | bc -l)" + local H="$(echo "scale=0;$T/1000/60/60%24" | bc -l)" + local M="$(echo "scale=0;$T/1000/60%60" | bc -l)" + local S="$(echo "scale=0;$T/1000%60" | bc -l)" + local MS="$(echo "scale=0;$T%1000" | bc -l)" local precision=$2 local out="" case "$precision" in - "ms") [[ $MS > 0 ]] && out="$(printf "%dms" $MS) ${out}"; precision="s" ;& - "s") [[ $S > 0 ]] && out="$(printf "%ds" $S) ${out}"; precision="m" ;& - "m") [[ $M > 0 ]] && out="$(printf "%dm" $M) ${out}"; precision="h" ;& - "h") [[ $H > 0 ]] && out="$(printf "%dh" $H) ${out}"; precision="d" ;& - "d") [[ $D > 0 ]] && out="$(printf "%dd" $D) ${out}" ;; + "ms") [[ "$MS" -gt 0 ]] && out="$(printf "%dms" "$MS") ${out}"; precision="s" ;& + "s") [[ "$S" -gt 0 ]] && out="$(printf "%ds" "$S") ${out}"; precision="m" ;& + "m") [[ "$M" -gt 0 ]] && out="$(printf "%dm" "$M") ${out}"; precision="h" ;& + "h") [[ "$H" -gt 0 ]] && out="$(printf "%dh" "$H") ${out}"; precision="d" ;& + "d") [[ "$D" -gt 0 ]] && out="$(printf "%dd" "$D") ${out}" ;; *) out="$T" ;; # Return $1 ($T) if precision wasn't specified/valid esac - printf "$out" + printf "%s" "$out" } display_cmd_time() { [[ $CMD_TIME_SHOW == 0 ]] && return @@ -134,7 +135,7 @@ display_cmd_time() { # this happens when all fields (seconds/minutes/...) are 0, # if we use milisecond precision, this will likely never happen # but with other precisions, it could - [[ "$(expr length "$time_took")" == 0 ]] && return + [ ${#time_took} -eq 0 ] && return echo -n " ${LBLUE}took ${time_took}" } @@ -158,7 +159,7 @@ PS2="$RED\ $RESET" # Right side prompt RPS1="" -if [ $TERM = "linux" ]; then +if [ "$TERM" = "linux" ]; then # Displaying cmd time here works, but often causes issues when we # resize the terminal, since right prompts can be annoying to deal # with when resizing. This would run relatively often so it makes From abac53fa9faf8629f7d4010f3714542d64fc702d Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 18:10:04 +0100 Subject: [PATCH 170/188] Update comments --- home/.config/shell/environment | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/home/.config/shell/environment b/home/.config/shell/environment index 7e05d43..3705366 100755 --- a/home/.config/shell/environment +++ b/home/.config/shell/environment @@ -61,11 +61,11 @@ fi # Other program settings export SUDO_ASKPASS="$HOME/.local/bin/scripts/dmenu/dmenupass" -export PIPENV_VENV_IN_PROJECT=1 # Force pipenv to create new environments within projects ./.venv -export XSECURELOCK_SHOW_HOSTNAME=0 # Don't show hostname in xsecurelock -export XSECURELOCK_SHOW_DATETIME=1 # Show current date and time in xsecurelock -export QT_QPA_PLATFORMTHEME=qt5ct # Have QT use the theme from qt5ct -#export QT_QPA_PLATFORMTHEME="gtk2" # Have QT use gtk2 theme. +export PIPENV_VENV_IN_PROJECT=1 # Force pipenv to create new environments within projects ./.venv +export XSECURELOCK_SHOW_HOSTNAME=0 # Don't show hostname in xsecurelock +export XSECURELOCK_SHOW_DATETIME=1 # Show current date and time in xsecurelock +export QT_QPA_PLATFORMTHEME="qt5ct" # Have QT use theme from qt5ct. +#export QT_STYLE_OVERRIDE="gtk2" # Have QT use the gtk2 theme (needs aur/qt5-styleplugins) # Remove irrelevant variables added for posix compatibility unset posix From c1af9327976f020c50d7911c9ba1f21ac6f840ec Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 18 Dec 2021 18:10:18 +0100 Subject: [PATCH 171/188] Remove unnecessary env variables --- home/.config/shell/environment | 2 -- 1 file changed, 2 deletions(-) diff --git a/home/.config/shell/environment b/home/.config/shell/environment index 3705366..8f2e34c 100755 --- a/home/.config/shell/environment +++ b/home/.config/shell/environment @@ -37,8 +37,6 @@ export SQLITE_HISTORY="$XDG_DATA_HOME/sqlite_history" export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime" export GOPATH="$XDG_DATA_HOME/go" export IPYTHONDIR="$XDG_CONFIG_HOME/ipython" -export ABDUCO_SOCKET_DIR="$XDG_RUNTIME_DIR" -export NERDTREE_BOOKMARKS="$XDG_CONFIG_HOME/NERDTreeBookmarks" #export PYLINTHOME="$XDG_CACHE_HOME/pylint" #export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" #export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" From 18ba4c4906a6dedd3c49fdfca571e72b68e1efbd Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 24 Dec 2021 02:42:04 +0100 Subject: [PATCH 172/188] Fix keybinds --- home/.config/shell/keybinds | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/home/.config/shell/keybinds b/home/.config/shell/keybinds index 543988b..f95b1cc 100755 --- a/home/.config/shell/keybinds +++ b/home/.config/shell/keybinds @@ -1,5 +1,5 @@ #!/usr/bin/env zsh -# shellcheck disable=SC2030,SC2031 +# shellcheck disable=SC2030,SC2031,SC2015 # Set default keybindings (mostly from oh-my-zsh) # Make sure that the terminal is in application mode when zle is active, since @@ -32,9 +32,9 @@ if [ -n "${terminfo[kcud1]}" ]; then fi # [Home] - Go to beginning of line -([ -n "${terminfo[khome]}" ] && bindkey "${terminfo[khome]}" beginning-of-line) || bindkey "^[[H" beginning-of-line +[ -n "${terminfo[khome]}" ] && bindkey "${terminfo[khome]}" beginning-of-line || bindkey "^[[H" beginning-of-line # [End] - Go to end of line -([ -n "${terminfo[kend]}" ] && bindkey "${terminfo[kend]}" end-of-line) || bindkey "^[[F" end-of-line +[ -n "${terminfo[kend]}" ] && bindkey "${terminfo[kend]}" end-of-line || bindkey "^[[F" end-of-line # [Shift-Tab] - move through the completion menu backwards [ -n "${terminfo[kcbt]}" ] && bindkey "${terminfo[kcbt]}" reverse-menu-complete @@ -42,7 +42,7 @@ fi # [Backspace] - delete backward bindkey '^?' backward-delete-char # [Delete] - delete forward -([ -n "${terminfo[kdch1]}" ] && bindkey "${terminfo[kdch1]}" delete-char) || bindkey "^[[3~" delete-char +[ -n "${terminfo[kdch1]}" ] && bindkey "${terminfo[kdch1]}" delete-char || bindkey "^[[3~" delete-char # [Ctrl-Delete] - delete whole forward-word bindkey '^[[3;5~' kill-word From d04842084a55dd68362cf3e646b4a573a99a520b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 24 Dec 2021 04:30:58 +0100 Subject: [PATCH 173/188] Rewrite cheat.sh script --- home/.local/bin/scripts/cheat.sh | 43 ++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/home/.local/bin/scripts/cheat.sh b/home/.local/bin/scripts/cheat.sh index 104ab67..e41de68 100755 --- a/home/.local/bin/scripts/cheat.sh +++ b/home/.local/bin/scripts/cheat.sh @@ -1,16 +1,37 @@ #!/bin/sh -languages=`echo "python rust golang lua cpp c typescript nodejs javascript js" | tr ' ' '\n'` -core_utils=`echo "xargs find sed awk" | tr ' ' '\n'` -selected=`printf "$languages\n$core_utils" | fzf` -read -p "query: " query -query=`echo "$query" | tr ' ' '+'` - - -if printf "$languages" | grep -qs "$selected"; then - url="cheat.sh/$selected/$query" +# Select the cheatsheat +SELECTABLE="$(curl -s "cheat.sh/:list")" +if [ -n "$1" ]; then + if echo "$SELECTABLE" | grep -qe "\b$1\b"; then + selected="$1" + else + echo "Invalid selection. For all selections, query cheat.sh/:list" + exit 1 + fi else - url="cheat.sh/$selected~$query" + selected=$(printf "$SELECTABLE" | fzf) + selected=$(printf "$selected" | tail -1) fi -curl "$url" +# If the cheatsheet doesn't already include a query, select a query +if echo "$selected" | grep -q "/"; then + query="" +elif [ -n "$2" ]; then + query="$2" +else + options=$(curl -s "cheat.sh/$selected/:list") + query=$(printf "\n$options" | fzf --bind=enter:print-query --prompt="cheat.sh query (can be empty): ") +fi +query="$(echo "$query" | tr ' ' '+')" + +# cheat.sh doesn't play nicely with trailing / in URLs +if [ -n "$query" ]; then + url="cheat.sh/$selected/$query" +else + url="cheat.sh/$selected" +fi + +# Print the URL and make the request +echo "$url" +curl -s "$url" From 1c73a80dfc6dd3b34c24c81549281c7b9dd51f2e Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 24 Dec 2021 04:46:48 +0100 Subject: [PATCH 174/188] Fix cheat.sh non-default query ability --- home/.local/bin/scripts/cheat.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/home/.local/bin/scripts/cheat.sh b/home/.local/bin/scripts/cheat.sh index e41de68..ac659c9 100755 --- a/home/.local/bin/scripts/cheat.sh +++ b/home/.local/bin/scripts/cheat.sh @@ -15,13 +15,18 @@ else fi # If the cheatsheet doesn't already include a query, select a query -if echo "$selected" | grep -q "/"; then +if echo "$selected" | grep -qe "[/:]"; then query="" elif [ -n "$2" ]; then query="$2" else options=$(curl -s "cheat.sh/$selected/:list") - query=$(printf "\n$options" | fzf --bind=enter:print-query --prompt="cheat.sh query (can be empty): ") + query="$(printf "\n$options" | \ + fzf --bind=alt-enter:print-query \ + --prompt="cheat.sh query>" \ + --header="use alt-enter to enter non-listed query"\ + )" + query=$(echo "$query" | tail -1) fi query="$(echo "$query" | tr ' ' '+')" From 0d0e9031d0f11fc46b81385b5b9ba2725ecec61b Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 24 Dec 2021 04:52:38 +0100 Subject: [PATCH 175/188] Fail on invalid selection --- home/.local/bin/scripts/cheat.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/home/.local/bin/scripts/cheat.sh b/home/.local/bin/scripts/cheat.sh index ac659c9..f7c8559 100755 --- a/home/.local/bin/scripts/cheat.sh +++ b/home/.local/bin/scripts/cheat.sh @@ -11,6 +11,10 @@ if [ -n "$1" ]; then fi else selected=$(printf "$SELECTABLE" | fzf) + if [ $? -ne 0 ]; then + echo "Invalid selection: '$selected'" + exit 1 + fi selected=$(printf "$selected" | tail -1) fi From ddefca9a3d5bda05a4db23d38f4f79fa00d94f81 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 24 Dec 2021 04:53:35 +0100 Subject: [PATCH 176/188] Pass non-matched fzf queries with enter too --- home/.local/bin/scripts/cheat.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.local/bin/scripts/cheat.sh b/home/.local/bin/scripts/cheat.sh index f7c8559..609a450 100755 --- a/home/.local/bin/scripts/cheat.sh +++ b/home/.local/bin/scripts/cheat.sh @@ -27,6 +27,7 @@ else options=$(curl -s "cheat.sh/$selected/:list") query="$(printf "\n$options" | \ fzf --bind=alt-enter:print-query \ + --print-query \ --prompt="cheat.sh query>" \ --header="use alt-enter to enter non-listed query"\ )" From f779fdd2734233ecc14c5da046572bb0c8258dc7 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 24 Dec 2021 04:54:01 +0100 Subject: [PATCH 177/188] Improve fzf comment for cheat.sh script --- home/.local/bin/scripts/cheat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.local/bin/scripts/cheat.sh b/home/.local/bin/scripts/cheat.sh index 609a450..23ed006 100755 --- a/home/.local/bin/scripts/cheat.sh +++ b/home/.local/bin/scripts/cheat.sh @@ -29,7 +29,7 @@ else fzf --bind=alt-enter:print-query \ --print-query \ --prompt="cheat.sh query>" \ - --header="use alt-enter to enter non-listed query"\ + --header="Use alt-enter to enter non-listed query. Empty queries are allowed."\ )" query=$(echo "$query" | tail -1) fi From 7245d1469458aa5662a2fa7b194f8f92a393d34c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Fri, 24 Dec 2021 06:35:25 +0100 Subject: [PATCH 178/188] Rewrite cheat.sh fzf helper script --- home/.local/bin/scripts/cheat.sh | 140 ++++++++++++++++++++++--------- 1 file changed, 102 insertions(+), 38 deletions(-) diff --git a/home/.local/bin/scripts/cheat.sh b/home/.local/bin/scripts/cheat.sh index 23ed006..38bbdf9 100755 --- a/home/.local/bin/scripts/cheat.sh +++ b/home/.local/bin/scripts/cheat.sh @@ -1,47 +1,111 @@ #!/bin/sh -# Select the cheatsheat -SELECTABLE="$(curl -s "cheat.sh/:list")" -if [ -n "$1" ]; then - if echo "$SELECTABLE" | grep -qe "\b$1\b"; then - selected="$1" +# rm_trailing_slashes(string) +# +# Prints a string without any trailing slashes. +# This is used because cheat.sh doesn't play nicely with multiple slashes in +# URLs. +rm_trailing_slashes() { + string="$1" + last_char="$(printf "$string" | tail -c 1)" + if [ "$last_char" = "/" ]; then + echo "$(rm_trailing_slashes "${string%?}")" else - echo "Invalid selection. For all selections, query cheat.sh/:list" - exit 1 + echo "$string" fi -else - selected=$(printf "$SELECTABLE" | fzf) - if [ $? -ne 0 ]; then - echo "Invalid selection: '$selected'" - exit 1 +} + +# pick_category(must_match, query, argument, recurse) +# +# Pick cheat.sh category. +# if must_match is 1, only allow listed options to be picked. +# if query is specified, pick sub-category of it, else pick global categories. +# if argument is specified, optionally perform must_match check and print it. +# if recurse is 1, if the selected option ends with /, run the function again. +# +# Prints the chosen category +pick_category() { + must_match="$1" + query="$(rm_trailing_slashes "$2")" + argument="$3" + recurse="$4" + + # Query all possible options + if [ -n "$query" ]; then + url="cheat.sh/$query/:list" + else + url="cheat.sh/:list" fi - selected=$(printf "$selected" | tail -1) + selectable="$(curl -s "$url")" + + # If argument is specified, print it, optionally perform must_match check. + if [ -n "$argument" ]; then + if [ "$must_match" -ne 1 ] || echo "$selectable" | grep -qe "\b$1\b"; then + selected="$argument" + else + echo "Invalid selection: '$argument'" + echo "For all selections, query $url" + exit 1 + fi + # Select the option with fzf, optionally allow other matches if must_match isn't set. + else + if [ "$must_match" -ne 1 ]; then + if [ -z "$selectable" ]; then + header="No selections found, you can use empty query to show category help, or type a custom query." + else + header="Use alt-enter to enter non-listed query. You can use empty queries to show category help." + fi + selected="$(printf "\n$selectable" | \ + fzf --bind=alt-enter:print-query \ + --print-query \ + --prompt="cheat.sh/$query query>" \ + --header="$header"\ + )" + else + selected=$(printf "$selectable" | fzf --prompt="cheat.sh/$query category>") + if [ $? -ne 0 ]; then + echo "Invalid selection: '$selected'" + echo "For all selections, query $url" + exit 1 + fi + fi + selected=$(printf "$selected" | tail -1) + fi + + + # Replace spaces with '+' (cheat.sh resolves those as spaces) + selected="$(echo "$selected" | tr ' ' '+')" + + # Prepend the original query, if we have one + # Print the selected category, or subcategory with the category + if [ -n "$query" ]; then + result="$query/$selected" + else + result="$selected" + fi + + # Recurse, if specified and the result ended with / + if [ "$recurse" -eq 1 ]; then + if [ "$(printf "$selected" | tail -c 1)" = "/" ]; then + result="$(pick_category "$must_match" "$result" "$argument" 1)" + fi + fi + + # Print the result + printf "$result" +} + +# Select the cheatsheat category (language/core-util/...) +query=$(pick_category 1 "" "$1" 0) + +# If the query isn't already complete, select a sub-category +if ! echo "$query" | grep -qe ":"; then + query="$(pick_category 0 "$query" "$2" 1)" fi -# If the cheatsheet doesn't already include a query, select a query -if echo "$selected" | grep -qe "[/:]"; then - query="" -elif [ -n "$2" ]; then - query="$2" -else - options=$(curl -s "cheat.sh/$selected/:list") - query="$(printf "\n$options" | \ - fzf --bind=alt-enter:print-query \ - --print-query \ - --prompt="cheat.sh query>" \ - --header="Use alt-enter to enter non-listed query. Empty queries are allowed."\ - )" - query=$(echo "$query" | tail -1) -fi -query="$(echo "$query" | tr ' ' '+')" - -# cheat.sh doesn't play nicely with trailing / in URLs -if [ -n "$query" ]; then - url="cheat.sh/$selected/$query" -else - url="cheat.sh/$selected" -fi - -# Print the URL and make the request +# Construct the URL from given query and print it +url="cheat.sh/$query" echo "$url" + +# Show the output of cheat.sh request curl -s "$url" From f1f89461396867242adee552d6f47dcd91d2f3d4 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 4 Jan 2022 01:03:05 +0100 Subject: [PATCH 179/188] Add alias to search pacnew files --- home/.config/shell/aliases | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index aa96ff9..da67548 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -170,6 +170,7 @@ alias kernel-configure='cd /usr/src/linux && make menuconfig' # System actions alias sv='systemctl' +alias pacnew="find / -name '*.pacnew' 2>/dev/null" # Search for all new configurations after pacman update alias backup="rsync -avHAXS --delete --filter='dir-merge /.rsync-filter'" # Make full rsync backup, respecting .rsync-filter files for exclusions alias upload='curl -F "f:1=<-" ix.io' alias upload-journal='sudo journalctl -b -1 | upload' # Upload journalctl from last boot to ix.io From 75fbd46888995fbdc9b51a7c94b6220e1564893f Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 4 Jan 2022 01:03:18 +0100 Subject: [PATCH 180/188] Fix gchb alias --- home/.config/shell/aliases | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/.config/shell/aliases b/home/.config/shell/aliases index da67548..392c711 100755 --- a/home/.config/shell/aliases +++ b/home/.config/shell/aliases @@ -225,7 +225,7 @@ alias gc='git commit' alias gcm='git commit --message' alias gb='git branch' alias gch='git checkout' -alias gchb='git checkout --branch' +alias gchb='git checkout -b' alias gd='git diff' alias gdc='git diff --cached' alias gundo='git reset --soft HEAD~' From 90ebf8b1e5c117ca398dc4116666eb0efc5133ed Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 4 Jan 2022 01:03:44 +0100 Subject: [PATCH 181/188] Add auto-recompile pacman hook for xmonad --- .../usr/share/libalpm/hooks/xmonad-recompile.hook | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 root/usr/share/libalpm/hooks/xmonad-recompile.hook diff --git a/root/usr/share/libalpm/hooks/xmonad-recompile.hook b/root/usr/share/libalpm/hooks/xmonad-recompile.hook new file mode 100644 index 0000000..a90b68a --- /dev/null +++ b/root/usr/share/libalpm/hooks/xmonad-recompile.hook @@ -0,0 +1,15 @@ +# Pacman hook to automatically recompile xmonad if it or any of it's dependencies were updated + +[Trigger] +Operation = Upgrade +Operation = Install +Type = Package +Target = xmonad* +Target = haskell* + +[Action] +Description = Recompiling Xmonad after package update... +When = PostTransaction +Depends = coreutils +Depends = xmonad +Exec = /usr/bin/bash -euc "command -v xmonad > /dev/null || exit 0; find /home -mindepth 1 -maxdepth 1 -type d -printf '%P\0' | xargs -0I'{}' su '{}' -c 'xmonad --recompile || true'" From ab1f173a2d52ca9bcd2e53f8d19f0c291b612eec Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 4 Jan 2022 01:04:16 +0100 Subject: [PATCH 182/188] Add topgrade --- home/.config/topgrade.toml | 98 ++++++++++++++++++++++++++++++++++++++ packages.yaml | 1 + 2 files changed, 99 insertions(+) create mode 100644 home/.config/topgrade.toml diff --git a/home/.config/topgrade.toml b/home/.config/topgrade.toml new file mode 100644 index 0000000..70d6b29 --- /dev/null +++ b/home/.config/topgrade.toml @@ -0,0 +1,98 @@ +# Don't ask for confirmations +#assume_yes = true + +# Disable specific steps - same options as the command line flag +#disable = ["system", "emacs"] + +# Ignore failures for these steps +#ignore_failures = ["powershell"] + +# Run specific steps - same options as the command line flag +only = ["system", "pip3", "flatpak", "node", "pipx", "rustup", "dotnet", "tldr", "vim"] + +# Do not ask to retry failed steps (default: false) +#no_retry = true + +# Run inside tmux +#run_in_tmux = true + +# List of remote machines with Topgrade installed on them +#remote_topgrades = ["toothless", "pi", "parnas"] + +# Arguments to pass SSH when upgrading remote systems +#ssh_arguments = "-o ConnectTimeout=2" + +# Path to Topgrade executable on remote machines +#remote_topgrade_path = ".cargo/bin/topgrade" + +# Arguments to pass tmux when pulling Repositories +#tmux_arguments = "-S /var/tmux.sock" + +# Do not set the terminal title +#set_title = false + +# Cleanup temporary or old files +#cleanup = true + +[git] +#max_concurrency = 5 +# Additional git repositories to pull +#repos = [ +# "~/src/*/", +# "~/.config/something" +#] + +# Don't pull the predefined git repos +#predefined_repos = false + +# Arguments to pass Git when pulling Repositories +#arguments = "--rebase --autostash" + +[composer] +#self_update = true + +# Commands to run before anything +[pre_commands] +#"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak" + +# Custom commands +[commands] +#"Python Environment" = "~/dev/.env/bin/pip install -i https://pypi.python.org/simple -U --upgrade-strategy eager jupyter" + +[brew] +#greedy_cask = true + +[linux] +# Arch Package Manager to use. Allowed values: autodetect, trizen, paru, yay, pacman. +#arch_package_manager = "pacman" +# Arguments to pass yay (or paru) when updating packages +#yay_arguments = "--nodevel" +#show_arch_news = true +#trizen_arguments = "--devel" +#enable_tlmgr = true +#emerge_sync_flags = "-q" +#emerge_update_flags = "-uDNa --with-bdeps=y world" +#redhat_distro_sync = false +#rpm_ostree = false + +[windows] +# Manually select Windows updates +#accept_all_updates = false +#open_remotes_in_new_terminal = true + +# Causes Topgrade to rename itself during the run to allow package managers +# to upgrade it. Use this only if you installed Topgrade by using a package +# manager such as Scoop to Cargo +#self_rename = true + +[npm] +# Use sudo if the NPM directory isn't owned by the current user +#use_sudo = true + +[firmware] +# Offer to update firmware; if false just check for and display available updates +#upgrade = true + +[flatpak] +# Use sudo for updating the system-wide installation +#use_sudo = true diff --git a/packages.yaml b/packages.yaml index 5c81b16..c729bb6 100644 --- a/packages.yaml +++ b/packages.yaml @@ -130,6 +130,7 @@ pacman: aur: # System - mkinitcpio-numlock # Enable numlock in initramfs (before asking for encryption key) + - topgrade # A tool to update entire system (pacman, yay, pip, npm, git, neovim, ...) # CLI - pixterm # Convert images to ANSI colored blocks From 9acadcc338a4be94564a57d95d6acfe8f67835de Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 8 Jan 2022 02:32:23 +0100 Subject: [PATCH 183/188] Add codespell --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index c729bb6..117f322 100644 --- a/packages.yaml +++ b/packages.yaml @@ -125,6 +125,7 @@ pacman: # Development - git-delta # Neat tool for showing git diffs and resolving merges + - codespell # Spell checker for code files #- code # Open sourced version of vscode (doesn't have good extensions support) aur: From b2a32d8202ae3359a7d3b3fd283734b7d76bd5d1 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 10 Jan 2022 17:44:45 +0100 Subject: [PATCH 184/188] Add git alias to clone as bare repo - This puts all of the git bare files into .bare and adds a .git file which specifies it's location. This makes for a nice and clean way to handle working with bare repositories - Bare repositories are very useful since they allow for neat workflow by using git worktrees that can basically create folders for individual branches. This means we can easily check out given brach just by entering that folder and we don't need to worry about conflicting files which we'd have to stash and then apply the stash once we're done done. --- home/.config/git/config | 1 + 1 file changed, 1 insertion(+) diff --git a/home/.config/git/config b/home/.config/git/config index 80ba740..3538bd3 100644 --- a/home/.config/git/config +++ b/home/.config/git/config @@ -4,6 +4,7 @@ signingkey = FB8CA11A2CF3A843 [alias] quickclone = "clone --single-branch --depth=1" + bareclone = "!sh -c 'git clone --bare \"$0\" \"$1\"/.bare; echo \"gitdir: ./.bare\" > \"$1/.git\"'" m = "merge" p = "push" From d0d899ce24746a035129e4314adf1fc2c58d7cd0 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Mon, 10 Jan 2022 17:49:04 +0100 Subject: [PATCH 185/188] Add ipinfo-cli package --- packages.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages.yaml b/packages.yaml index 117f322..6abbb40 100644 --- a/packages.yaml +++ b/packages.yaml @@ -141,6 +141,7 @@ aur: # Networking/Internet - ngrok # Forward your localhost without ip recovery + - ipinfo-cli # Official cli tool for ipinfo (provides geolocation and other info about given IP) # Security - opensnitch # Application level firewall with traffic monitoring (Alternatively, there's portmaster) From 0fa5db7477bd96e4fa7df7fe8f3f3806ff7bedfa Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 25 Jan 2022 19:57:02 +0100 Subject: [PATCH 186/188] Add alias for quickly stashing staged files --- home/.config/git/config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home/.config/git/config b/home/.config/git/config index 3538bd3..0eb5e4f 100644 --- a/home/.config/git/config +++ b/home/.config/git/config @@ -51,6 +51,8 @@ set-upstream = "!git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`" + stash-staged = "!sh -c 'git stash --keep-index; git stash push -m \"staged\" --keep-index; git stash pop stash@{1}'" + find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'" show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'" [credential] From 96a71669197b61012ae557c0092543b3ecf1afe2 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 25 Jan 2022 19:57:19 +0100 Subject: [PATCH 187/188] Add global gitignore file --- home/.config/git/global_gitignore | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 home/.config/git/global_gitignore diff --git a/home/.config/git/global_gitignore b/home/.config/git/global_gitignore new file mode 100644 index 0000000..366035c --- /dev/null +++ b/home/.config/git/global_gitignore @@ -0,0 +1,25 @@ +# vim: filetype=conf +# Byte-compiled / optimized / DLL Files +__pycache__/ +*.py[cod] +*$py.class + +# Virtual Environments +.venv/ + +# Editor project settings +## VSCode +.vscode/ +## PyCharm intellij +.idea/ +## repl.it +.replit +## spyder +.spyproject/ +.spyderproject/ + +# Custom attributes for folders on Mac OS +.DS_Store + +# Personal TODO files +TODO From 77be2053c96c50722a6e7a7156144b90f93a7ea8 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 25 Jan 2022 19:58:07 +0100 Subject: [PATCH 188/188] Add github cli and gh-notify addon to packages --- packages.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages.yaml b/packages.yaml index 6abbb40..54d3083 100644 --- a/packages.yaml +++ b/packages.yaml @@ -126,6 +126,7 @@ pacman: # Development - git-delta # Neat tool for showing git diffs and resolving merges - codespell # Spell checker for code files + - github-cli # Manage multiple GitHub features from terminal #- code # Open sourced version of vscode (doesn't have good extensions support) aur: @@ -169,4 +170,5 @@ aur: #- code-marketplace # Enable the offical MS vscode marketplace for 'code' (code-oss) git: - https://aur.archlinux.org/yay-git.git # Pacman wrapper and AUR helper - +github-cli: + - meiji163/gh-notify