From 6520ecd782a402f59c6eed23026b07dfa59acfd2 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Mon, 19 Sep 2022 12:13:33 +0100 Subject: [PATCH 01/16] qutebrowser: bind qute-pass unfiltered to `za?l` --- qutebrowser/config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qutebrowser/config.py b/qutebrowser/config.py index cbb8310..2a94a26 100644 --- a/qutebrowser/config.py +++ b/qutebrowser/config.py @@ -1931,6 +1931,10 @@ config.bind('zl', 'spawn --userscript qute-pass') config.bind('zul', 'spawn --userscript qute-pass --username-only') config.bind('zpl', 'spawn --userscript qute-pass --password-only') config.bind('zol', 'spawn --userscript qute-pass --otp-only') +config.bind('zal', 'spawn --userscript qute-pass --unfiltered') +config.bind('zaul', 'spawn --userscript qute-pass --unfiltered --username-only') +config.bind('zapl', 'spawn --userscript qute-pass --unfiltered --password-only') +config.bind('zaol', 'spawn --userscript qute-pass --unfiltered --otp-only') # config.bind('{{', 'navigate prev -t') # config.bind('}}', 'navigate next -t') -- 2.49.0 From f65351a4282b68f599c318a86bb51952a31f17ce Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 20 Sep 2022 14:54:42 +0100 Subject: [PATCH 02/16] mpv: select bestvideo even if it contains audio too --- mpv/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpv/config b/mpv/config index df8f4b3..f0ccb00 100644 --- a/mpv/config +++ b/mpv/config @@ -1,5 +1,5 @@ # default ytdl -ytdl-format=bestvideo[height<=720]+bestaudio/best[height<=720] +ytdl-format=bestvideo*[height<=720]+bestaudio/best[height<=720] cache=auto no-sub -- 2.49.0 From 367a240534f2e939fbb15baed6a34736b7360637 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Mon, 26 Sep 2022 17:11:32 +0100 Subject: [PATCH 03/16] xprofile: separate xprofile from xinit When using a display manager xinitrc is not sourced, however xprofile still is. --- Makefile | 7 ++++++- xinitrc | 9 +-------- xprofile | 10 ++++++++++ {xinit/xprofile.d => xprofile.d}/00-pulse.sh | 0 {xinit/xprofile.d => xprofile.d}/00-xrandr.sh | 0 {xinit/xprofile.d => xprofile.d}/01-redshift.sh | 0 {xinit/xprofile.d => xprofile.d}/10-screensaver.sh | 0 {xinit/xprofile.d => xprofile.d}/10-xkb.sh | 0 {xinit/xprofile.d => xprofile.d}/99-applications.sh | 0 9 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 xprofile rename {xinit/xprofile.d => xprofile.d}/00-pulse.sh (100%) rename {xinit/xprofile.d => xprofile.d}/00-xrandr.sh (100%) rename {xinit/xprofile.d => xprofile.d}/01-redshift.sh (100%) rename {xinit/xprofile.d => xprofile.d}/10-screensaver.sh (100%) rename {xinit/xprofile.d => xprofile.d}/10-xkb.sh (100%) rename {xinit/xprofile.d => xprofile.d}/99-applications.sh (100%) diff --git a/Makefile b/Makefile index d59f59a..07abd50 100644 --- a/Makefile +++ b/Makefile @@ -144,11 +144,16 @@ yay: $(XDG_CONFIG_HOME) ln -sfT $(APATH)/yay $(XDG_CONFIG_HOME)/yay mkdir -p $(XDG_CACHE_HOME)/yay -xinit: $(XDG_CONFIG_HOME) +xinit: $(XDG_CONFIG_HOME) xprofile ln -sfT $(APATH)/$@rc ~/.$@rc ln -sfT $(APATH)/$@ $(XDG_CONFIG_HOME)/$@ .PHONY: xinit +xprofile: $(XDG_CONFIG_HOME) + ln -sfT $(APATH)/$@ ~/.$@ + ln -sfT $(APATH)/$@.d $(XDG_CONFIG_HOME)/$@.d +.PHONY: xprofile + wakeonlan: $(XDG_CONFIG_HOME) ln -sfT $(APATH)/$@ $(XDG_CONFIG_HOME)/$@ .PHONY: wakeonlan diff --git a/xinitrc b/xinitrc index 3b0bace..7cb4e19 100644 --- a/xinitrc +++ b/xinitrc @@ -4,7 +4,7 @@ logfile=$XDG_DATA_HOME/xorg/xinit.log userresources=$XDG_CONFIG_HOME/xinit/Xresources userresources_d=$XDG_CONFIG_HOME/xinit/Xresources.d usermodmap=$HOME/.Xmodmap -userprofile_d=$XDG_CONFIG_HOME/xinit/xprofile.d +userprofile=$HOME/.xprofile sysresources=/etc/X11/xinit/.Xresources sysmodmap=/etc/X11/xinit/.Xmodmap @@ -50,13 +50,6 @@ if [ -d /etc/X11/xinit/xinitrc.d ] ; then unset f fi -if [ -d "$userprofile_d" ] ; then - for f in $userprofile_d/?*.sh ; do - [ -f "$f" ] && source "$f" - done - unset f -fi - if [ -f "$userprofile" ]; then source "$userprofile" fi diff --git a/xprofile b/xprofile new file mode 100644 index 0000000..97580b9 --- /dev/null +++ b/xprofile @@ -0,0 +1,10 @@ +#!/bin/sh + +userprofile_d=$XDG_CONFIG_HOME/xprofile.d + +if [ -d "$userprofile_d" ] ; then + for f in $userprofile_d/?*.sh ; do + [ -f "$f" ] && source "$f" + done + unset f +fi diff --git a/xinit/xprofile.d/00-pulse.sh b/xprofile.d/00-pulse.sh similarity index 100% rename from xinit/xprofile.d/00-pulse.sh rename to xprofile.d/00-pulse.sh diff --git a/xinit/xprofile.d/00-xrandr.sh b/xprofile.d/00-xrandr.sh similarity index 100% rename from xinit/xprofile.d/00-xrandr.sh rename to xprofile.d/00-xrandr.sh diff --git a/xinit/xprofile.d/01-redshift.sh b/xprofile.d/01-redshift.sh similarity index 100% rename from xinit/xprofile.d/01-redshift.sh rename to xprofile.d/01-redshift.sh diff --git a/xinit/xprofile.d/10-screensaver.sh b/xprofile.d/10-screensaver.sh similarity index 100% rename from xinit/xprofile.d/10-screensaver.sh rename to xprofile.d/10-screensaver.sh diff --git a/xinit/xprofile.d/10-xkb.sh b/xprofile.d/10-xkb.sh similarity index 100% rename from xinit/xprofile.d/10-xkb.sh rename to xprofile.d/10-xkb.sh diff --git a/xinit/xprofile.d/99-applications.sh b/xprofile.d/99-applications.sh similarity index 100% rename from xinit/xprofile.d/99-applications.sh rename to xprofile.d/99-applications.sh -- 2.49.0 From 2d171ced9365bac5a592c2a809d93946933a68d8 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Mon, 26 Sep 2022 17:13:18 +0100 Subject: [PATCH 04/16] xprofile: use xss-lock and loginctl lock-session to trigger i3lock xss-lock makes sure that i3lock is triggered when the session is locked via systemd by other means than xidlehook, i.e. LidClose events. Since there is now a handler for session locking in systemd, might as well use that on the timer as well via lock-session. --- xprofile.d/10-screensaver.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xprofile.d/10-screensaver.sh b/xprofile.d/10-screensaver.sh index 8a2368d..4e9a048 100755 --- a/xprofile.d/10-screensaver.sh +++ b/xprofile.d/10-screensaver.sh @@ -4,17 +4,17 @@ if [[ $(hostname) == "hactar" ]]; then xidlehook \ --socket=$XIDLEHOOK_SOCKET \ --not-when-fullscreen \ - --timer 300 'xset dpms force off' '' \ - --timer 300 'i3lock -c 000000' '' \ - --timer 3600 'systemctl suspend' '' \ + --timer 300 'xset dpms force off' '' \ + --timer 300 'loginctl lock-session' '' \ + --timer 3600 'systemctl suspend' '' \ & elif [[ $(hostname) == "chronos" ]]; then xidlehook \ --socket=$XIDLEHOOK_SOCKET \ --not-when-fullscreen \ - --timer 300 'xset dpms force off' '' \ - --timer 300 'i3lock -c 000000' '' \ - --timer 1800 'systemctl suspend' '' \ + --timer 300 'xset dpms force off' '' \ + --timer 300 'loginctl lock-session' '' \ + --timer 1800 'systemctl suspend' '' \ & elif [[ $(hostname) == "skull-canyon" ]]; then xidlehook \ @@ -24,3 +24,5 @@ elif [[ $(hostname) == "skull-canyon" ]]; then --timer 300 'i3lock -c 000000' '' \ & fi + +xss-lock -- i3lock --nofork --color=000000 & -- 2.49.0 From 11c851ed16b4b86bebe93ac1c4062817b1301470 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Fri, 30 Sep 2022 10:40:08 +0100 Subject: [PATCH 05/16] awesome: add svg version of background --- awesome/themes/nord/background.svg | 504 +++++++++++++++++++++++++++++ 1 file changed, 504 insertions(+) create mode 100644 awesome/themes/nord/background.svg diff --git a/awesome/themes/nord/background.svg b/awesome/themes/nord/background.svg new file mode 100644 index 0000000..c476dab --- /dev/null +++ b/awesome/themes/nord/background.svg @@ -0,0 +1,504 @@ + + + + -- 2.49.0 From 0e710e28c6a88106dde86053e9c24eaa4ef93361 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Fri, 30 Sep 2022 10:53:06 +0100 Subject: [PATCH 06/16] xkb: reformat default.xkb to avoid long lines --- xkb/default.xkb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xkb/default.xkb b/xkb/default.xkb index 07d812d..b346e25 100644 --- a/xkb/default.xkb +++ b/xkb/default.xkb @@ -2,6 +2,10 @@ xkb_keymap { xkb_keycodes { include "evdev" }; xkb_types { include "complete" }; xkb_compat { include "complete" }; - xkb_symbols { include "pc+inet(evdev)+dvorak+dvorak(kinesis)+shift(both_capslock)" }; + xkb_symbols { + include "pc+inet(evdev)+dvorak" + include "dvorak(kinesis)" + include "shift(both_capslock)" + }; xkb_geometry { include "pc(pc104)" }; }; -- 2.49.0 From 4cad86763c06ea94f86eb522395313a13e2676e7 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Wed, 28 Sep 2022 11:11:48 +0100 Subject: [PATCH 07/16] ranger: update rifle.conf Pull changes in from /usr/share/doc/ranger/config/rifle.conf --- ranger/rifle.conf | 81 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 14 deletions(-) diff --git a/ranger/rifle.conf b/ranger/rifle.conf index 1cac50c..bd4b793 100644 --- a/ranger/rifle.conf +++ b/ranger/rifle.conf @@ -26,7 +26,7 @@ # directory | $1 is a directory # number | change the number of this command to n # terminal | stdin, stderr and stdout are connected to a terminal -# X | $DISPLAY is not empty (i.e. Xorg runs) +# X | A graphical environment is available (darwin, Xorg, or Wayland) # # There are also pseudo-conditions which have a "side effect": # flag | Change how the program is run. See below. @@ -73,23 +73,25 @@ ext x?html?, has w3m, terminal = w3m "$@" # Misc #------------------------------------------- # Define the "editor" for text files as first action -mime ^text, label editor = $EDITOR -- "$@" +mime ^text, label editor = ${VISUAL:-$EDITOR} -- "$@" mime ^text, label pager = "$PAGER" -- "$@" -!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@" +!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@" !mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@" ext 1 = man "$1" ext s[wmf]c, has zsnes, X = zsnes "$1" +ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1" ext nes, has fceux, X = fceux "$1" ext exe = wine "$1" name ^[mM]akefile$ = make #-------------------------------------------- -# Code +# Scripts #------------------------------------------- ext py = python -- "$1" ext pl = perl -- "$1" ext rb = ruby -- "$1" +ext js = node -- "$1" ext sh = sh -- "$1" ext php = php -- "$1" @@ -104,22 +106,34 @@ mime ^audio|ogg$, terminal, has mpv = mpv -- "$@" mime ^video|audio, has umpv, X, flag f = umpv -- "$@" mime ^video|audio, has mpv, X, flag f = mpv -- "$@" +#-------------------------------------------- +# Video without X +#------------------------------------------- +mime ^video, terminal, !X, has mpv = mpv -- "$@" + #------------------------------------------- # Documents #------------------------------------------- ext pdf, has zathura, X, flag f = zathura -- "$@" +ext pdf, has evince, X, flag f = evince -- "$@" ext pdf, has okular, X, flag f = okular -- "$@" ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER" ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@" +ext djvu, has zathura,X, flag f = zathura -- "$@" ext djvu, has evince, X, flag f = evince -- "$@" +ext epub, has zathura, X, flag f = zathura -- "$@" + +ext cbr, has zathura, X, flag f = zathura -- "$@" +ext cbz, has zathura, X, flag f = zathura -- "$@" #------------------------------------------- -# Image Viewing: +# Images #------------------------------------------- mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@" +mime ^image/svg, has display, X, flag f = display -- "$@" mime ^image, has feh, X, flag f = feh -- "$@" mime ^image, has gimp, X, flag f = gimp -- "$@" @@ -128,15 +142,42 @@ ext xcf, X, flag f = gimp -- "$@" #------------------------------------------- # Archives #------------------------------------------- + +# avoid password prompt by providing empty password +ext 7z, has 7z = 7z -p l "$@" | "$PAGER" # This requires atool -ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has als = als -- "$@" | "$PAGER" -ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has als = als -- "$@" | "$PAGER" -ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has aunpack = aunpack -- "$@" -ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has aunpack = aunpack -- "$@" +ext ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --list --each -- "$@" | "$PAGER" +ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --list --each -- "$@" | "$PAGER" +ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has atool = atool --extract --each -- "$@" +ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has atool = atool --extract --each -- "$@" + +# Listing and extracting archives without atool: +ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | "$PAGER" +ext tar|gz|bz2|xz, has tar = for file in "$@"; do tar vvxf "$file"; done +ext bz2, has bzip2 = for file in "$@"; do bzip2 -dk "$file"; done +ext zip, has unzip = unzip -l "$1" | less +ext zip, has unzip = for file in "$@"; do unzip -d "${file%.*}" "$file"; done +ext ace, has unace = unace l "$1" | less +ext ace, has unace = for file in "$@"; do unace e "$file"; done +ext rar, has unrar = unrar l "$1" | less +ext rar, has unrar = for file in "$@"; do unrar x "$file"; done -# Fallback: -ext tar|gz, has tar = tar vvtf "$@" | "$PAGER" -ext tar|gz, has tar = tar vvxf "$@" +#------------------------------------------- +# Fonts +#------------------------------------------- +mime ^font, has fontforge, X, flag f = fontforge "$@" + +#------------------------------------------- +# Flag t fallback terminals +#------------------------------------------- +# Rarely installed terminal emulators get higher priority; It is assumed that +# if you install a rare terminal emulator, you probably use it. +# gnome-terminal/konsole/xterm on the other hand are often installed as part of +# a desktop environment or as fallback terminal emulators. +mime ^ranger/x-terminal-emulator, has kitty = kitty -- "$@" +mime ^ranger/x-terminal-emulator, has alacritty = alacritty -e "$@" +mime ^ranger/x-terminal-emulator, has urxvt = urxvt -e "$@" +mime ^ranger/x-terminal-emulator, has xterm = xterm -e "$@" #------------------------------------------- # Misc @@ -146,10 +187,22 @@ label wallpaper, number 12, mime ^image, has feh, X = feh --bg-tile "$1" label wallpaper, number 13, mime ^image, has feh, X = feh --bg-center "$1" label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1" +#------------------------------------------- +# Generic file openers +#------------------------------------------- +label open, has xdg-open = xdg-open -- "$@" +label open, has open = open -- "$@" + # Define the editor for non-text files + pager as last action !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask -label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@" +label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@" label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@" -# The very last action, so that it's never triggered accidentally, is to execute a program: + +###################################################################### +# The actions below are left so low down in this file on purpose, so # +# they are never triggered accidentally. # +###################################################################### + +# Execute a file as program/script. mime application/x-executable = "$1" -- 2.49.0 From 4e57fdd2f310f5d85ccf37ca2f661f2bde589735 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Sat, 22 Oct 2022 16:07:49 +0100 Subject: [PATCH 08/16] zsh: when using hist_expire_dups_first, HISTSIZE > SAVEHIST --- zsh/lib/history.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh/lib/history.zsh b/zsh/lib/history.zsh index 3650bb7..c2c2441 100644 --- a/zsh/lib/history.zsh +++ b/zsh/lib/history.zsh @@ -1,6 +1,6 @@ ## Command history configuration HISTFILE=$ZSH_DATA/histfile -HISTSIZE=100000 +HISTSIZE=120000 # should be larger than SAVEHIST, see HIST_EXPIRE_DUPS_FIRST in zshall(1) SAVEHIST=100000 setopt extended_history -- 2.49.0 From be9749becef0e21833ff99fb7205162112088db6 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Sat, 22 Oct 2022 16:08:48 +0100 Subject: [PATCH 09/16] zsh: reduce blanks in history --- zsh/lib/history.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/zsh/lib/history.zsh b/zsh/lib/history.zsh index c2c2441..4fcfa83 100644 --- a/zsh/lib/history.zsh +++ b/zsh/lib/history.zsh @@ -7,6 +7,7 @@ setopt extended_history setopt hist_expire_dups_first setopt hist_ignore_dups # ignore duplication command history list setopt hist_ignore_space +setopt hist_reduce_blanks setopt hist_verify setopt share_history # share command history data -- 2.49.0 From 17e5120d929d5ce3ff4e3e4b70138982eb6e9aa3 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 25 Oct 2022 17:24:23 +0100 Subject: [PATCH 10/16] mutt: add google client_id --- mutt/mutt_oauth2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mutt/mutt_oauth2.py b/mutt/mutt_oauth2.py index 1c6ec37..3c657c7 100755 --- a/mutt/mutt_oauth2.py +++ b/mutt/mutt_oauth2.py @@ -58,8 +58,8 @@ registrations = { 'smtp_endpoint': 'smtp.gmail.com', 'sasl_method': 'OAUTHBEARER', 'scope': 'https://mail.google.com/', - 'client_id': '', - 'client_secret': '', + 'client_id': '406964657835-aq8lmia8j95dhl1a2bvharmfk3t1hgqj.apps.googleusercontent.com', + 'client_secret': 'kSmqreRr0qwBWJgbf5Y-PjSU', }, 'microsoft': { 'authorize_endpoint': 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize', -- 2.49.0 From 98d0f37914ad98af9b0af7b33513fbc1f0393c99 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 25 Oct 2022 13:01:49 +0100 Subject: [PATCH 11/16] vim: upgrade plug.vim --- vim/autoload/plug.vim | 560 +++++++++++++++++++++++++++++++----------- 1 file changed, 423 insertions(+), 137 deletions(-) diff --git a/vim/autoload/plug.vim b/vim/autoload/plug.vim index 4e05630..652caa8 100644 --- a/vim/autoload/plug.vim +++ b/vim/autoload/plug.vim @@ -25,7 +25,7 @@ " Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " Plug 'tpope/vim-fireplace', { 'for': 'clojure' } " -" " Using a non-master branch +" " Using a non-default branch " Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } " " " Using a tagged release; wildcard allowed (requires git 1.9.2 or above) @@ -99,8 +99,14 @@ let s:mac_gui = has('gui_macvim') && has('gui_running') let s:is_win = has('win32') let s:nvim = has('nvim-0.2') || (has('nvim') && exists('*jobwait') && !s:is_win) let s:vim8 = has('patch-8.0.0039') && exists('*job_start') -let s:me = resolve(expand(':p')) -let s:base_spec = { 'branch': 'master', 'frozen': 0 } +if s:is_win && &shellslash + set noshellslash + let s:me = resolve(expand(':p')) + set shellslash +else + let s:me = resolve(expand(':p')) +endif +let s:base_spec = { 'branch': '', 'frozen': 0 } let s:TYPE = { \ 'string': type(''), \ 'list': type([]), @@ -110,18 +116,140 @@ let s:TYPE = { let s:loaded = get(s:, 'loaded', {}) let s:triggers = get(s:, 'triggers', {}) +function! s:is_powershell(shell) + return a:shell =~# 'powershell\(\.exe\)\?$' || a:shell =~# 'pwsh\(\.exe\)\?$' +endfunction + +function! s:isabsolute(dir) abort + return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)') +endfunction + +function! s:git_dir(dir) abort + let gitdir = s:trim(a:dir) . '/.git' + if isdirectory(gitdir) + return gitdir + endif + if !filereadable(gitdir) + return '' + endif + let gitdir = matchstr(get(readfile(gitdir), 0, ''), '^gitdir: \zs.*') + if len(gitdir) && !s:isabsolute(gitdir) + let gitdir = a:dir . '/' . gitdir + endif + return isdirectory(gitdir) ? gitdir : '' +endfunction + +function! s:git_origin_url(dir) abort + let gitdir = s:git_dir(a:dir) + let config = gitdir . '/config' + if empty(gitdir) || !filereadable(config) + return '' + endif + return matchstr(join(readfile(config)), '\[remote "origin"\].\{-}url\s*=\s*\zs\S*\ze') +endfunction + +function! s:git_revision(dir) abort + let gitdir = s:git_dir(a:dir) + let head = gitdir . '/HEAD' + if empty(gitdir) || !filereadable(head) + return '' + endif + + let line = get(readfile(head), 0, '') + let ref = matchstr(line, '^ref: \zs.*') + if empty(ref) + return line + endif + + if filereadable(gitdir . '/' . ref) + return get(readfile(gitdir . '/' . ref), 0, '') + endif + + if filereadable(gitdir . '/packed-refs') + for line in readfile(gitdir . '/packed-refs') + if line =~# ' ' . ref + return matchstr(line, '^[0-9a-f]*') + endif + endfor + endif + + return '' +endfunction + +function! s:git_local_branch(dir) abort + let gitdir = s:git_dir(a:dir) + let head = gitdir . '/HEAD' + if empty(gitdir) || !filereadable(head) + return '' + endif + let branch = matchstr(get(readfile(head), 0, ''), '^ref: refs/heads/\zs.*') + return len(branch) ? branch : 'HEAD' +endfunction + +function! s:git_origin_branch(spec) + if len(a:spec.branch) + return a:spec.branch + endif + + " The file may not be present if this is a local repository + let gitdir = s:git_dir(a:spec.dir) + let origin_head = gitdir.'/refs/remotes/origin/HEAD' + if len(gitdir) && filereadable(origin_head) + return matchstr(get(readfile(origin_head), 0, ''), + \ '^ref: refs/remotes/origin/\zs.*') + endif + + " The command may not return the name of a branch in detached HEAD state + let result = s:lines(s:system('git symbolic-ref --short HEAD', a:spec.dir)) + return v:shell_error ? '' : result[-1] +endfunction + +if s:is_win + function! s:plug_call(fn, ...) + let shellslash = &shellslash + try + set noshellslash + return call(a:fn, a:000) + finally + let &shellslash = shellslash + endtry + endfunction +else + function! s:plug_call(fn, ...) + return call(a:fn, a:000) + endfunction +endif + +function! s:plug_getcwd() + return s:plug_call('getcwd') +endfunction + +function! s:plug_fnamemodify(fname, mods) + return s:plug_call('fnamemodify', a:fname, a:mods) +endfunction + +function! s:plug_expand(fmt) + return s:plug_call('expand', a:fmt, 1) +endfunction + +function! s:plug_tempname() + return s:plug_call('tempname') +endfunction + function! plug#begin(...) if a:0 > 0 let s:plug_home_org = a:1 - let home = s:path(fnamemodify(expand(a:1), ':p')) + let home = s:path(s:plug_fnamemodify(s:plug_expand(a:1), ':p')) elseif exists('g:plug_home') let home = s:path(g:plug_home) + elseif has('nvim') + let home = stdpath('data') . '/plugged' elseif !empty(&rtp) let home = s:path(split(&rtp, ',')[0]) . '/plugged' else return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.') endif - if fnamemodify(home, ':t') ==# 'plugin' && fnamemodify(home, ':h') ==# s:first_rtp + if s:plug_fnamemodify(home, ':t') ==# 'plugin' && s:plug_fnamemodify(home, ':h') ==# s:first_rtp return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.') endif @@ -139,6 +267,16 @@ function! s:define_commands() if !executable('git') return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') endif + if has('win32') + \ && &shellslash + \ && (&shell =~# 'cmd\(\.exe\)\?$' || s:is_powershell(&shell)) + return s:err('vim-plug does not support shell, ' . &shell . ', when shellslash is set.') + endif + if !has('nvim') + \ && (has('win32') || has('win32unix')) + \ && !has('multi_byte') + return s:err('Vim needs +multi_byte feature on Windows to run shell commands. Enable +iconv for best results.') + endif command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(0, []) command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(0, []) command! -nargs=0 -bar -bang PlugClean call s:clean(0) @@ -203,7 +341,7 @@ endfunction function! plug#end() if !exists('g:plugs') - return s:err('Call plug#begin() first') + return s:err('plug#end() called without calling plug#begin() first') endif if exists('#PlugLOD') @@ -214,7 +352,7 @@ function! plug#end() endif let lod = { 'ft': {}, 'map': {}, 'cmd': {} } - if exists('g:did_load_filetypes') + if get(g:, 'did_load_filetypes', 0) filetype off endif for name in g:plugs_order @@ -269,7 +407,7 @@ function! plug#end() for [map, names] in items(lod.map) for [mode, map_prefix, key_prefix] in - \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] + \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] execute printf( \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")', \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix) @@ -324,7 +462,7 @@ endfunction function! s:git_version_requirement(...) if !exists('s:git_version') - let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)') + let s:git_version = map(split(split(s:system(['git', '--version']))[2], '\.'), 'str2nr(v:val)') endif return s:version_requirement(s:git_version, a:000) endfunction @@ -334,11 +472,11 @@ function! s:progress_opt(base) \ s:git_version_requirement(1, 7, 1) ? '--progress' : '' endfunction -if s:is_win - function! s:rtp(spec) - return s:path(a:spec.dir . get(a:spec, 'rtp', '')) - endfunction +function! s:rtp(spec) + return s:path(a:spec.dir . get(a:spec, 'rtp', '')) +endfunction +if s:is_win function! s:path(path) return s:trim(substitute(a:path, '/', '\', 'g')) endfunction @@ -350,11 +488,33 @@ if s:is_win function! s:is_local_plug(repo) return a:repo =~? '^[a-z]:\|^[%~]' endfunction -else - function! s:rtp(spec) - return s:dirpath(a:spec.dir . get(a:spec, 'rtp', '')) + + " Copied from fzf + function! s:wrap_cmds(cmds) + let cmds = [ + \ '@echo off', + \ 'setlocal enabledelayedexpansion'] + \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) + \ + ['endlocal'] + if has('iconv') + if !exists('s:codepage') + let s:codepage = libcallnr('kernel32.dll', 'GetACP', 0) + endif + return map(cmds, printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage)) + endif + return map(cmds, 'v:val."\r"') endfunction + function! s:batchfile(cmd) + let batchfile = s:plug_tempname().'.bat' + call writefile(s:wrap_cmds(a:cmd), batchfile) + let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0}) + if s:is_powershell(&shell) + let cmd = '& ' . cmd + endif + return [batchfile, cmd] + endfunction +else function! s:path(path) return s:trim(a:path) endfunction @@ -434,8 +594,8 @@ endfunction function! s:dobufread(names) for name in a:names - let path = s:rtp(g:plugs[name]).'/**' - for dir in ['ftdetect', 'ftplugin'] + let path = s:rtp(g:plugs[name]) + for dir in ['ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin'] if len(finddir(dir, path)) if exists('#BufRead') doautocmd BufRead @@ -554,7 +714,7 @@ function! plug#(repo, ...) try let repo = s:trim(a:repo) let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec - let name = get(opts, 'as', fnamemodify(repo, ':t:s?\.git$??')) + let name = get(opts, 'as', s:plug_fnamemodify(repo, ':t:s?\.git$??')) let spec = extend(s:infer_properties(name, repo), opts) if !has_key(g:plugs, name) call add(g:plugs_order, name) @@ -562,19 +722,41 @@ function! plug#(repo, ...) let g:plugs[name] = spec let s:loaded[name] = get(s:loaded, name, 0) catch - return s:err(v:exception) + return s:err(repo . ' ' . v:exception) endtry endfunction function! s:parse_options(arg) let opts = copy(s:base_spec) let type = type(a:arg) + let opt_errfmt = 'Invalid argument for "%s" option of :Plug (expected: %s)' if type == s:TYPE.string + if empty(a:arg) + throw printf(opt_errfmt, 'tag', 'string') + endif let opts.tag = a:arg elseif type == s:TYPE.dict + for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as'] + if has_key(a:arg, opt) + \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt])) + throw printf(opt_errfmt, opt, 'string') + endif + endfor + for opt in ['on', 'for'] + if has_key(a:arg, opt) + \ && type(a:arg[opt]) != s:TYPE.list + \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt])) + throw printf(opt_errfmt, opt, 'string or list') + endif + endfor + if has_key(a:arg, 'do') + \ && type(a:arg.do) != s:TYPE.funcref + \ && (type(a:arg.do) != s:TYPE.string || empty(a:arg.do)) + throw printf(opt_errfmt, 'do', 'string or funcref') + endif call extend(opts, a:arg) if has_key(opts, 'dir') - let opts.dir = s:dirpath(expand(opts.dir)) + let opts.dir = s:dirpath(s:plug_expand(opts.dir)) endif else throw 'Invalid argument type (expected: string or dictionary)' @@ -585,7 +767,7 @@ endfunction function! s:infer_properties(name, repo) let repo = a:repo if s:is_local_plug(repo) - return { 'dir': s:dirpath(expand(repo)) } + return { 'dir': s:dirpath(s:plug_expand(repo)) } else if repo =~ ':' let uri = repo @@ -628,7 +810,7 @@ function! s:syntax() syn match plugNumber /[0-9]\+[0-9.]*/ contained syn match plugBracket /[[\]]/ contained syn match plugX /x/ contained - syn match plugDash /^-/ + syn match plugDash /^-\{1}\ / syn match plugPlus /^+/ syn match plugStar /^*/ syn match plugMessage /\(^- \)\@<=.*/ @@ -646,6 +828,7 @@ function! s:syntax() syn match plugError /^x.*/ syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/ syn match plugH2 /^.*:\n-\+$/ + syn match plugH2 /^-\{2,}/ syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean hi def link plug1 Title hi def link plug2 Repeat @@ -738,7 +921,7 @@ function! s:finish_bindings() endfunction function! s:prepare(...) - if empty(getcwd()) + if empty(s:plug_getcwd()) throw 'Invalid current working directory. Cannot proceed.' endif @@ -758,7 +941,7 @@ function! s:prepare(...) call s:new_window() endif - nnoremap q :if b:plug_preview==1pcendifbd + nnoremap q :call close_pane() if a:0 == 0 call s:finish_bindings() endif @@ -780,6 +963,15 @@ function! s:prepare(...) endif endfunction +function! s:close_pane() + if b:plug_preview == 1 + pc + let b:plug_preview = -1 + else + bd + endif +endfunction + function! s:assign_name() " Assign buffer name let prefix = '[Plugins]' @@ -794,31 +986,35 @@ endfunction function! s:chsh(swap) let prev = [&shell, &shellcmdflag, &shellredir] - if s:is_win - set shell=cmd.exe shellcmdflag=/c shellredir=>%s\ 2>&1 - elseif a:swap - set shell=sh shellredir=>%s\ 2>&1 + if !s:is_win + set shell=sh + endif + if a:swap + if s:is_powershell(&shell) + let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s' + elseif &shell =~# 'sh' || &shell =~# 'cmd\(\.exe\)\?$' + set shellredir=>%s\ 2>&1 + endif endif return prev endfunction function! s:bang(cmd, ...) + let batchfile = '' try let [sh, shellcmdflag, shrd] = s:chsh(a:0) " FIXME: Escaping is incomplete. We could use shellescape with eval, " but it won't work on Windows. let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd if s:is_win - let batchfile = tempname().'.bat' - call writefile(["@echo off\r", cmd . "\r"], batchfile) - let cmd = batchfile + let [batchfile, cmd] = s:batchfile(cmd) endif let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%') execute "normal! :execute g:_plug_bang\\" finally unlet g:_plug_bang let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] - if s:is_win + if s:is_win && filereadable(batchfile) call delete(batchfile) endif endtry @@ -831,7 +1027,7 @@ function! s:regress_bar() endfunction function! s:is_updated(dir) - return !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"', a:dir)) + return !empty(s:system_chomp(['git', 'log', '--pretty=format:%h', 'HEAD...HEAD@{1}'], a:dir)) endfunction function! s:do(pull, force, todo) @@ -868,6 +1064,7 @@ function! s:do(pull, force, todo) endif elseif type == s:TYPE.funcref try + call s:load_plugin(spec) let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') call spec.do({ 'name': name, 'status': status, 'force': a:force }) catch @@ -894,10 +1091,11 @@ endfunction function! s:checkout(spec) let sha = a:spec.commit - let output = s:system('git rev-parse HEAD', a:spec.dir) - if !v:shell_error && !s:hash_match(sha, s:lines(output)[0]) + let output = s:git_revision(a:spec.dir) + if !empty(output) && !s:hash_match(sha, s:lines(output)[0]) + let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : '' let output = s:system( - \ 'git fetch --depth 999999 && git checkout '.s:esc(sha).' --', a:spec.dir) + \ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir) endif return output endfunction @@ -1012,11 +1210,17 @@ function! s:update_impl(pull, force, args) abort normal! 2G silent! redraw - let s:clone_opt = get(g:, 'plug_shallow', 1) ? - \ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : '' + " Set remote name, overriding a possible user git config's clone.defaultRemoteName + let s:clone_opt = ['--origin', 'origin'] + if get(g:, 'plug_shallow', 1) + call extend(s:clone_opt, ['--depth', '1']) + if s:git_version_requirement(1, 7, 10) + call add(s:clone_opt, '--no-single-branch') + endif + endif - if has('win32unix') - let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input' + if has('win32unix') || has('wsl') + call extend(s:clone_opt, ['-c', 'core.eol=lf', '-c', 'core.autocrlf=input']) endif let s:submodule_opt = s:git_version_requirement(2, 8) ? ' --jobs='.threads : '' @@ -1094,7 +1298,7 @@ function! s:update_finish() elseif has_key(spec, 'tag') let tag = spec.tag if tag =~ '\*' - let tags = s:lines(s:system('git tag --list '.s:shellesc(tag).' --sort -version:refname 2>&1', spec.dir)) + let tags = s:lines(s:system('git tag --list '.plug#shellescape(tag).' --sort -version:refname 2>&1', spec.dir)) if !v:shell_error && !empty(tags) let tag = tags[0] call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag)) @@ -1102,12 +1306,12 @@ function! s:update_finish() endif endif call s:log4(name, 'Checking out '.tag) - let out = s:system('git checkout -q '.s:esc(tag).' -- 2>&1', spec.dir) + let out = s:system('git checkout -q '.plug#shellescape(tag).' -- 2>&1', spec.dir) else - let branch = s:esc(get(spec, 'branch', 'master')) - call s:log4(name, 'Merging origin/'.branch) - let out = s:system('git checkout -q '.branch.' -- 2>&1' - \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only origin/'.branch.' 2>&1')), spec.dir) + let branch = s:git_origin_branch(spec) + call s:log4(name, 'Merging origin/'.s:esc(branch)) + let out = s:system('git checkout -q '.plug#shellescape(branch).' -- 2>&1' + \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only '.plug#shellescape('origin/'.branch).' 2>&1')), spec.dir) endif if !v:shell_error && filereadable(spec.dir.'/.gitmodules') && \ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir)) @@ -1151,7 +1355,7 @@ function! s:job_abort() silent! call job_stop(j.jobid) endif if j.new - call s:system('rm -rf ' . s:shellesc(g:plugs[name].dir)) + call s:rm_rf(g:plugs[name].dir) endif endfor let s:jobs = {} @@ -1197,29 +1401,27 @@ function! s:job_cb(fn, job, ch, data) endfunction function! s:nvim_cb(job_id, data, event) dict abort - return a:event == 'stdout' ? + return (a:event == 'stdout' || a:event == 'stderr') ? \ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) : \ s:job_cb('s:job_exit_cb', self, 0, a:data) endfunction function! s:spawn(name, cmd, opts) let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''], - \ 'batchfile': (s:is_win && (s:nvim || s:vim8)) ? tempname().'.bat' : '', \ 'new': get(a:opts, 'new', 0) } let s:jobs[a:name] = job - let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd - if !empty(job.batchfile) - call writefile(["@echo off\r", cmd . "\r"], job.batchfile) - let cmd = job.batchfile - endif - let argv = add(s:is_win ? ['cmd', '/c'] : ['sh', '-c'], cmd) if s:nvim + if has_key(a:opts, 'dir') + let job.cwd = a:opts.dir + endif + let argv = a:cmd call extend(job, { \ 'on_stdout': function('s:nvim_cb'), + \ 'on_stderr': function('s:nvim_cb'), \ 'on_exit': function('s:nvim_cb'), \ }) - let jid = jobstart(argv, job) + let jid = s:plug_call('jobstart', argv, job) if jid > 0 let job.jobid = jid else @@ -1229,9 +1431,16 @@ function! s:spawn(name, cmd, opts) \ 'Invalid arguments (or job table is full)'] endif elseif s:vim8 + let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"script": 0})')) + if has_key(a:opts, 'dir') + let cmd = s:with_cd(cmd, a:opts.dir, 0) + endif + let argv = s:is_win ? ['cmd', '/s', '/c', '"'.cmd.'"'] : ['sh', '-c', cmd] let jid = job_start(s:is_win ? join(argv, ' ') : argv, { \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'err_cb': function('s:job_cb', ['s:job_out_cb', job]), \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]), + \ 'err_mode': 'raw', \ 'out_mode': 'raw' \}) if job_status(jid) == 'run' @@ -1242,7 +1451,7 @@ function! s:spawn(name, cmd, opts) let job.lines = ['Failed to start job'] endif else - let job.lines = s:lines(call('s:system', [cmd])) + let job.lines = s:lines(call('s:system', has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd])) let job.error = v:shell_error != 0 let job.running = 0 endif @@ -1262,9 +1471,6 @@ function! s:reap(name) call s:log(bullet, a:name, empty(result) ? 'OK' : result) call s:bar() - if has_key(job, 'batchfile') && !empty(job.batchfile) - call delete(job.batchfile) - endif call remove(s:jobs, a:name) endfunction @@ -1279,9 +1485,10 @@ function! s:bar() endfunction function! s:logpos(name) - for i in range(4, line('$')) + let max = line('$') + for i in range(4, max > 4 ? max : 4) if getline(i) =~# '^[-+x*] '.a:name.':' - for j in range(i + 1, line('$')) + for j in range(i + 1, max > 5 ? max : 5) if getline(j) !~ '^ ' return [i, j - 1] endif @@ -1341,8 +1548,14 @@ while 1 " Without TCO, Vim stack is bound to explode let [error, _] = s:git_validate(spec, 0) if empty(error) if pull - let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : '' - call s:spawn(name, printf('git fetch %s %s 2>&1', fetch_opt, prog), { 'dir': spec.dir }) + let cmd = s:git_version_requirement(2) ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch'] + if has_tag && !empty(globpath(spec.dir, '.git/shallow')) + call extend(cmd, ['--depth', '99999999']) + endif + if !empty(prog) + call add(cmd, prog) + endif + call s:spawn(name, cmd, { 'dir': spec.dir }) else let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 } endif @@ -1350,12 +1563,14 @@ while 1 " Without TCO, Vim stack is bound to explode let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 } endif else - call s:spawn(name, - \ printf('git clone %s %s %s %s 2>&1', - \ has_tag ? '' : s:clone_opt, - \ prog, - \ s:shellesc(spec.uri), - \ s:shellesc(s:trim(spec.dir))), { 'new': 1 }) + let cmd = ['git', 'clone'] + if !has_tag + call extend(cmd, s:clone_opt) + endif + if !empty(prog) + call add(cmd, prog) + endif + call s:spawn(name, extend(cmd, [spec.uri, s:trim(spec.dir)]), { 'new': 1 }) endif if !s:jobs[name].running @@ -1392,7 +1607,7 @@ G_NVIM = vim.eval("has('nvim')") == '1' G_PULL = vim.eval('s:update.pull') == '1' G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1 G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)')) -G_CLONE_OPT = vim.eval('s:clone_opt') +G_CLONE_OPT = ' '.join(vim.eval('s:clone_opt')) G_PROGRESS = vim.eval('s:progress_opt(1)') G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads')) G_STOP = thr.Event() @@ -1929,7 +2144,7 @@ function! s:update_ruby() end } if VIM::evaluate('s:mac_gui') == 1 - clone_opt = VIM::evaluate('s:clone_opt') + clone_opt = VIM::evaluate('s:clone_opt').join(' ') progress = VIM::evaluate('s:progress_opt(1)') nthr.times do mtx.synchronize do @@ -1982,19 +2197,45 @@ function! s:update_ruby() EOF endfunction -function! s:shellesc_cmd(arg) - let escaped = substitute(a:arg, '[&|<>()@^]', '^&', 'g') - let escaped = substitute(escaped, '%', '%%', 'g') - let escaped = substitute(escaped, '"', '\\^&', 'g') - let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g') - return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"' +function! s:shellesc_cmd(arg, script) + let escaped = substitute('"'.a:arg.'"', '[&|<>()@^!"]', '^&', 'g') + return substitute(escaped, '%', (a:script ? '%' : '^') . '&', 'g') +endfunction + +function! s:shellesc_ps1(arg) + return "'".substitute(escape(a:arg, '\"'), "'", "''", 'g')."'" +endfunction + +function! s:shellesc_sh(arg) + return "'".substitute(a:arg, "'", "'\\\\''", 'g')."'" endfunction -function! s:shellesc(arg) - if &shell =~# 'cmd.exe$' - return s:shellesc_cmd(a:arg) +" Escape the shell argument based on the shell. +" Vim and Neovim's shellescape() are insufficient. +" 1. shellslash determines whether to use single/double quotes. +" Double-quote escaping is fragile for cmd.exe. +" 2. It does not work for powershell. +" 3. It does not work for *sh shells if the command is executed +" via cmd.exe (ie. cmd.exe /c sh -c command command_args) +" 4. It does not support batchfile syntax. +" +" Accepts an optional dictionary with the following keys: +" - shell: same as Vim/Neovim 'shell' option. +" If unset, fallback to 'cmd.exe' on Windows or 'sh'. +" - script: If truthy and shell is cmd.exe, escape for batchfile syntax. +function! plug#shellescape(arg, ...) + if a:arg =~# '^[A-Za-z0-9_/:.-]\+$' + return a:arg endif - return shellescape(a:arg) + let opts = a:0 > 0 && type(a:1) == s:TYPE.dict ? a:1 : {} + let shell = get(opts, 'shell', s:is_win ? 'cmd.exe' : 'sh') + let script = get(opts, 'script', 1) + if shell =~# 'cmd\(\.exe\)\?$' + return s:shellesc_cmd(a:arg, script) + elseif s:is_powershell(shell) + return s:shellesc_ps1(a:arg) + endif + return s:shellesc_sh(a:arg) endfunction function! s:glob_dir(path) @@ -2026,23 +2267,39 @@ function! s:format_message(bullet, name, message) endif endfunction -function! s:with_cd(cmd, dir) - return printf('cd%s %s && %s', s:is_win ? ' /d' : '', s:shellesc(a:dir), a:cmd) +function! s:with_cd(cmd, dir, ...) + let script = a:0 > 0 ? a:1 : 1 + return printf('cd%s %s && %s', s:is_win ? ' /d' : '', plug#shellescape(a:dir, {'script': script}), a:cmd) endfunction function! s:system(cmd, ...) + let batchfile = '' try let [sh, shellcmdflag, shrd] = s:chsh(1) - let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd - if s:is_win - let batchfile = tempname().'.bat' - call writefile(["@echo off\r", cmd . "\r"], batchfile) - let cmd = batchfile + if type(a:cmd) == s:TYPE.list + " Neovim's system() supports list argument to bypass the shell + " but it cannot set the working directory for the command. + " Assume that the command does not rely on the shell. + if has('nvim') && a:0 == 0 + return system(a:cmd) + endif + let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"shell": &shell, "script": 0})')) + if s:is_powershell(&shell) + let cmd = '& ' . cmd + endif + else + let cmd = a:cmd + endif + if a:0 > 0 + let cmd = s:with_cd(cmd, a:1, type(a:cmd) != s:TYPE.list) endif - return system(s:is_win ? '('.cmd.')' : cmd) + if s:is_win && type(a:cmd) != s:TYPE.list + let [batchfile, cmd] = s:batchfile(cmd) + endif + return system(cmd) finally let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] - if s:is_win + if s:is_win && filereadable(batchfile) call delete(batchfile) endif endtry @@ -2056,18 +2313,17 @@ endfunction function! s:git_validate(spec, check_branch) let err = '' if isdirectory(a:spec.dir) - let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir)) + let result = [s:git_local_branch(a:spec.dir), s:git_origin_url(a:spec.dir)] let remote = result[-1] - if v:shell_error + if empty(remote) let err = join([remote, 'PlugClean required.'], "\n") elseif !s:compare_git_uri(remote, a:spec.uri) let err = join(['Invalid URI: '.remote, \ 'Expected: '.a:spec.uri, \ 'PlugClean required.'], "\n") elseif a:check_branch && has_key(a:spec, 'commit') - let result = s:lines(s:system('git rev-parse HEAD 2>&1', a:spec.dir)) - let sha = result[-1] - if v:shell_error + let sha = s:git_revision(a:spec.dir) + if empty(sha) let err = join(add(result, 'PlugClean required.'), "\n") elseif !s:hash_match(sha, a:spec.commit) let err = join([printf('Invalid HEAD (expected: %s, actual: %s)', @@ -2075,8 +2331,9 @@ function! s:git_validate(spec, check_branch) \ 'PlugUpdate required.'], "\n") endif elseif a:check_branch - let branch = result[0] + let current_branch = result[0] " Check tag + let origin_branch = s:git_origin_branch(a:spec) if has_key(a:spec, 'tag') let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) if a:spec.tag !=# tag && a:spec.tag !~ '\*' @@ -2084,25 +2341,26 @@ function! s:git_validate(spec, check_branch) \ (empty(tag) ? 'N/A' : tag), a:spec.tag) endif " Check branch - elseif a:spec.branch !=# branch + elseif origin_branch !=# current_branch let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.', - \ branch, a:spec.branch) + \ current_branch, origin_branch) endif if empty(err) - let [ahead, behind] = split(s:lastline(s:system(printf( - \ 'git rev-list --count --left-right HEAD...origin/%s', - \ a:spec.branch), a:spec.dir)), '\t') + let [ahead, behind] = split(s:lastline(s:system([ + \ 'git', 'rev-list', '--count', '--left-right', + \ printf('HEAD...origin/%s', origin_branch) + \ ], a:spec.dir)), '\t') if !v:shell_error && ahead if behind " Only mention PlugClean if diverged, otherwise it's likely to be " pushable (and probably not that messed up). let err = printf( \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" - \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind) + \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', origin_branch, ahead, behind) else let err = printf("Ahead of origin/%s by %d commit(s).\n" \ .'Cannot update until local changes are pushed.', - \ a:spec.branch, ahead) + \ origin_branch, ahead) endif endif endif @@ -2115,7 +2373,9 @@ endfunction function! s:rm_rf(dir) if isdirectory(a:dir) - call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(a:dir)) + return s:system(s:is_win + \ ? 'rmdir /S /Q '.plug#shellescape(a:dir) + \ : ['rm', '-rf', a:dir]) endif endfunction @@ -2147,7 +2407,7 @@ function! s:clean(force) let allowed = {} for dir in dirs - let allowed[s:dirpath(fnamemodify(dir, ':h:h'))] = 1 + let allowed[s:dirpath(s:plug_fnamemodify(dir, ':h:h'))] = 1 let allowed[dir] = 1 for child in s:glob_dir(dir) let allowed[child] = 1 @@ -2197,6 +2457,7 @@ endfunction function! s:delete(range, force) let [l1, l2] = a:range let force = a:force + let err_count = 0 while l1 <= l2 let line = getline(l1) if line =~ '^- ' && isdirectory(line[2:]) @@ -2205,11 +2466,22 @@ function! s:delete(range, force) let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1) let force = force || answer > 1 if answer - call s:rm_rf(line[2:]) + let err = s:rm_rf(line[2:]) setlocal modifiable - call setline(l1, '~'.line[1:]) - let s:clean_count += 1 - call setline(4, printf('Removed %d directories.', s:clean_count)) + if empty(err) + call setline(l1, '~'.line[1:]) + let s:clean_count += 1 + else + delete _ + call append(l1 - 1, s:format_message('x', line[1:], err)) + let l2 += len(s:lines(err)) + let err_count += 1 + endif + let msg = printf('Removed %d directories.', s:clean_count) + if err_count > 0 + let msg .= printf(' Failed to remove %d directories.', err_count) + endif + call setline(4, msg) setlocal nomodifiable endif endif @@ -2220,11 +2492,11 @@ endfunction function! s:upgrade() echo 'Downloading the latest version of vim-plug' redraw - let tmp = tempname() + let tmp = s:plug_tempname() let new = tmp . '/plug.vim' try - let out = s:system(printf('git clone --depth 1 %s %s', s:plug_src, tmp)) + let out = s:system(['git', 'clone', '--depth', '1', s:plug_src, tmp]) if v:shell_error return s:err('Error upgrading vim-plug: '. out) endif @@ -2349,34 +2621,41 @@ function! s:preview_commit() let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}') if empty(sha) - return + let name = matchstr(getline('.'), '^- \zs[^:]*\ze:$') + if empty(name) + return + endif + let title = 'HEAD@{1}..' + let command = 'git diff --no-color HEAD@{1}' + else + let title = sha + let command = 'git show --no-color --pretty=medium '.sha + let name = s:find_name(line('.')) endif - let name = s:find_name(line('.')) if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir) return endif if exists('g:plug_pwindow') && !s:is_preview_window_open() execute g:plug_pwindow - execute 'e' sha + execute 'e' title else - execute 'pedit' sha + execute 'pedit' title wincmd P endif - setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable + setlocal previewwindow filetype=git buftype=nofile bufhidden=wipe nobuflisted modifiable + let batchfile = '' try let [sh, shellcmdflag, shrd] = s:chsh(1) - let cmd = 'cd '.s:shellesc(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha + let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && '.command if s:is_win - let batchfile = tempname().'.bat' - call writefile(["@echo off\r", cmd . "\r"], batchfile) - let cmd = batchfile + let [batchfile, cmd] = s:batchfile(cmd) endif execute 'silent %!' cmd finally let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] - if s:is_win + if s:is_win && filereadable(batchfile) call delete(batchfile) endif endtry @@ -2419,16 +2698,23 @@ function! s:diff() endif call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:') for [k, v] in plugs - let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..' - let cmd = 'git log --graph --color=never '.join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 's:shellesc(v:val)')) - if has_key(v, 'rtp') - let cmd .= ' -- '.s:shellesc(v.rtp) - endif - let diff = s:system_chomp(cmd, v.dir) - if !empty(diff) - let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : '' - call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)'))) - let cnts[origin] += 1 + let branch = s:git_origin_branch(v) + if len(branch) + let range = origin ? '..origin/'.branch : 'HEAD@{1}..' + let cmd = ['git', 'log', '--graph', '--color=never'] + if s:git_version_requirement(2, 10, 0) + call add(cmd, '--no-show-signature') + endif + call extend(cmd, ['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range]) + if has_key(v, 'rtp') + call extend(cmd, ['--', v.rtp]) + endif + let diff = s:system_chomp(cmd, v.dir) + if !empty(diff) + let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : '' + call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)'))) + let cnts[origin] += 1 + endif endif let bar .= '=' call s:progress_bar(2, bar, len(total)) @@ -2470,7 +2756,7 @@ function! s:revert() return endif - call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch).' --', g:plugs[name].dir) + call s:system('git reset --hard HEAD@{1} && git checkout '.plug#shellescape(g:plugs[name].branch).' --', g:plugs[name].dir) setlocal modifiable normal! "_dap setlocal nomodifiable @@ -2488,9 +2774,9 @@ function! s:snapshot(force, ...) abort 1 let anchor = line('$') - 3 let names = sort(keys(filter(copy(g:plugs), - \'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)'))) + \'has_key(v:val, "uri") && isdirectory(v:val.dir)'))) for name in reverse(names) - let sha = s:system_chomp('git rev-parse --short HEAD', g:plugs[name].dir) + let sha = has_key(g:plugs[name], 'commit') ? g:plugs[name].commit : s:git_revision(g:plugs[name].dir) if !empty(sha) call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha)) redraw @@ -2498,7 +2784,7 @@ function! s:snapshot(force, ...) abort endfor if a:0 > 0 - let fn = expand(a:1) + let fn = s:plug_expand(a:1) if filereadable(fn) && !(a:force || s:ask(a:1.' already exists. Overwrite?')) return endif -- 2.49.0 From 35d57a17b287dd8badc454b835347c4b825c60a8 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 1 Nov 2022 14:09:33 +0000 Subject: [PATCH 12/16] git: replace wio with fpp conditional settings This reverts commit 0cb9c5b0aaa4f2fb22eb202050fdcc451c8a760c. --- git/config | 4 ++-- git/fpp.config | 6 ++++++ git/wio.config | 7 ------- 3 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 git/fpp.config delete mode 100644 git/wio.config diff --git a/git/config b/git/config index af16e93..a759c2e 100644 --- a/git/config +++ b/git/config @@ -54,5 +54,5 @@ process = git-lfs filter-process required = true -[includeIf "gitdir:~/src/wio/**"] - path = ~/.config/git/wio.config +[includeIf "gitdir:~/src/fpp/**"] + path = ~/.config/git/fpp.config diff --git a/git/fpp.config b/git/fpp.config new file mode 100644 index 0000000..e5b6e82 --- /dev/null +++ b/git/fpp.config @@ -0,0 +1,6 @@ +[user] + name = Samir Benmendil + email = samir@fppnt.com + +[core] + hooksPath = ~/src/fpp/githooks diff --git a/git/wio.config b/git/wio.config deleted file mode 100644 index 2b99b4a..0000000 --- a/git/wio.config +++ /dev/null @@ -1,7 +0,0 @@ -[user] - name = Samir Benmendil - email = sbenmendil@witekio.com - -[core] - # hooksPath = ~/src/wio/githooks - sshCommand = ssh -i ~/.ssh/id_ed25519_wio -- 2.49.0 From 6fdfc2e429376d851aad73a2107cb250ae5fa712 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 1 Nov 2022 14:27:11 +0000 Subject: [PATCH 13/16] xkb: add skull-canyon keyboard This is not a kinesis anymore. --- xkb/skull-canyon.xkb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 xkb/skull-canyon.xkb diff --git a/xkb/skull-canyon.xkb b/xkb/skull-canyon.xkb new file mode 100644 index 0000000..bc87a95 --- /dev/null +++ b/xkb/skull-canyon.xkb @@ -0,0 +1,11 @@ +xkb_keymap { + xkb_keycodes { include "evdev" }; + xkb_types { include "complete" }; + xkb_compat { include "complete" }; + xkb_symbols { + include "pc+inet(evdev)+dvorak" + include "altwin(swap_alt_win)" + include "level3(menu_switch)" + }; + xkb_geometry { include "pc(pc104)" }; +}; -- 2.49.0 From f6e399d142fff8f7f044d8b5e5bb30360223fdb8 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 1 Nov 2022 14:32:31 +0000 Subject: [PATCH 14/16] weechat: upgrade wee-slack --- weechat/python/wee-slack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weechat/python/wee-slack b/weechat/python/wee-slack index 4b946d8..3aa2c79 160000 --- a/weechat/python/wee-slack +++ b/weechat/python/wee-slack @@ -1 +1 @@ -Subproject commit 4b946d8bfa4173113a2bad0f402ff4fd4490919f +Subproject commit 3aa2c79d80e17ed1ca02e7698e68218d57bfb47b -- 2.49.0 From 9121d01f620b33672a13a6c930564146cde87961 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 1 Nov 2022 14:31:41 +0000 Subject: [PATCH 15/16] weechat: connect to fpp slack --- weechat/plugins.conf | 2 +- weechat/sec.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/weechat/plugins.conf b/weechat/plugins.conf index 727ee82..324ca62 100644 --- a/weechat/plugins.conf +++ b/weechat/plugins.conf @@ -124,7 +124,7 @@ python.slack.shared_name_prefix = "%" python.slack.short_buffer_names = "true" python.slack.show_buflist_presence = "true" python.slack.show_reaction_nicks = "0" -python.slack.slack_api_token = "${sec.data.slack_token_wio}" +python.slack.slack_api_token = "${sec.data.slack_token_fpp}" python.slack.slack_timeout = "20000" python.slack.switch_buffer_on_join = "1" python.slack.thread_broadcast_prefix = "+ " diff --git a/weechat/sec.conf b/weechat/sec.conf index 0205ebf..852b989 100644 --- a/weechat/sec.conf +++ b/weechat/sec.conf @@ -17,4 +17,4 @@ salt = on [data] __passphrase__ = on -slack_token_wio = "28791B5E14A0C1856434471A48C3FA77C89DE88193C72EE85BF92FF8F42B6BBFCF44DC7005DB0995E2DE2E9330E417FD79A2B53A6B09CF3E34D7B6663BD9EA4C4E9F4BFAC97BC47507185A516FA20A731DA233E35C484CBFAA91C3E26F2790D6512DF6CB328E8B35616364A5D075729F468AE2F685F9CCCEB03D4F9374375E38BECB9642278F47B913D26921EEB29980896BB34B94FEE674A759E2CA2CA2132BABDCBF3EC9447FFE033DA289AFA7D282F13FAED21A7161EEE1C98EC791D209982FAC199790E6DDFB8B9FDECF63DC26823483653A5F158AAF160DEBAD4ED72EA729297C55CD74C7438132D9B53D5DC8C6D5919705B47133E59E99A3DCD742F53C16D1E7ECADAE3B3AF5DEEE782DF4F50DCCF307ECF43EA5A109B4B66564CD59AD77852BB8DF023C8DF71436D20CBCE9747F1D1E0090DF8AACF76075FB15174F4C9A9FBACC68EFA15AA07FA0755317747B19A1DF94D3F20F50C3ED6EE45566" +slack_token_fpp = "46334F65EACFD8F4A73E1878F03768DD5C840856977F5ACB4CC9945FD79119355CA8B45E8B0F66F1E79FA1BD018BE6001DAD45A04FB40D5223FEBD44C3D476F964514855F8FCDB15A60C4B80FE4E52F3FCC27A79E8230EBD1B69E3E4832832A7665472A653C60E4915812AA1614B2C968D07FCB1B315B766E0A05A3D5FBD875FEDF75F2AD952F6EFCFE34F639A263FB5184765EC172A5A46DC91BF8C0F2C55954CC978D33F3F3EE253A78A694523029DBB5DF6AE85F09374DE44A46AC3B0CE51B7DDA89EA9ED3AB9D7D344AA8DA1B68B89AE43C396263E8E677E39EBEE628E97CFF4E1161F1B9121824C8BF33B2C997C9F8283F4A7DF1ECAAEC093E352BCB78919CAC1B2E931075346C6C853C7C7251D14254EFE0F7FA7AB12F23894144381B65A876DC7E9F23319D0A37CC8C7B9E55C337EBDC2E213D8C703D6B56AB09A49247FBEB1D886C3FFD94F4E9FBC6452900866584DF97D1920783D3EEB92" -- 2.49.0 From a3fa0999eba83b3ff4d3934828b6e71e7cf2cfc0 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Tue, 1 Nov 2022 14:39:15 +0000 Subject: [PATCH 16/16] weechat: update configs --- weechat/buffer_autoset.conf | 2 +- weechat/logger.conf | 3 +++ weechat/trigger.conf | 1 + weechat/weechat.conf | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/weechat/buffer_autoset.conf b/weechat/buffer_autoset.conf index 19eddc4..b6ae37e 100644 --- a/weechat/buffer_autoset.conf +++ b/weechat/buffer_autoset.conf @@ -6,7 +6,7 @@ # # Use commands like /set or /fset to change settings in WeeChat. # -# For more info, see: https://weechat.org/doc/quickstart +# For more info, see: https://weechat.org/doc/quickstart/ # [look] diff --git a/weechat/logger.conf b/weechat/logger.conf index 92f7ac7..7a44f5b 100644 --- a/weechat/logger.conf +++ b/weechat/logger.conf @@ -29,6 +29,9 @@ nick_prefix = "" nick_suffix = "" path = "~/.cache/weechat/logs/" replacement_char = "_" +rotation_compression_level = 20 +rotation_compression_type = none +rotation_size_max = "0" time_format = "%Y-%m-%d %H:%M:%S" [level] diff --git a/weechat/trigger.conf b/weechat/trigger.conf index f8f4a50..30bdbc3 100644 --- a/weechat/trigger.conf +++ b/weechat/trigger.conf @@ -19,6 +19,7 @@ flag_conditions = yellow flag_post_action = lightblue flag_regex = lightcyan flag_return_code = lightmagenta +identifier = cyan regex = white replace = cyan trigger = green diff --git a/weechat/weechat.conf b/weechat/weechat.conf index 15814a7..70a79c8 100644 --- a/weechat/weechat.conf +++ b/weechat/weechat.conf @@ -56,6 +56,7 @@ day_change_message_2dates = "-- %%a, %%d %%b %%Y (%a, %d %b %Y) --" eat_newline_glitch = off emphasized_attributes = "" highlight = "@channel" +highlight_disable_regex = "" highlight_regex = ".*Ram-Z.*" highlight_tags = "" hotlist_add_conditions = "${away} || ${buffer.num_displayed} == 0" @@ -376,6 +377,8 @@ title.size = 1 title.size_max = 1 title.type = window +[custom_bar_item] + [layout] normal.buffer = "core;weechat;1" normal.buffer = "irc;server.freenode;1" -- 2.49.0