summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-07-01 01:14:59 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-07-01 01:14:59 +0200
commite1de506156454ba1d324faf548ad15fe804aa806 (patch)
tree1ca249b22bace59d41e950b7482443440ccc8c5e /config
parentfecb6306631aaec1774497093b7da44ab5950d92 (diff)
parentb2077bbddf86dbdbf6cc63aaf2ceb8a2da614ebc (diff)
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'config')
-rwxr-xr-xconfig/X/x11/xinitrc19
-rw-r--r--config/common/newsraft/config1
-rw-r--r--config/common/newsraft/feeds1
-rw-r--r--config/essentials/git/config2
-rw-r--r--config/essentials/shell/aliases.sh70
-rw-r--r--config/essentials/shell/functions.sh5
-rw-r--r--config/essentials/vis/backup.lua48
-rw-r--r--config/essentials/vis/build.lua8
-rw-r--r--config/essentials/vis/commentary.lua441
-rw-r--r--config/essentials/vis/complete-line.lua171
-rw-r--r--config/essentials/vis/ctags.lua343
-rw-r--r--config/essentials/vis/cursors.lua6
-rw-r--r--config/essentials/vis/format.lua71
-rw-r--r--config/essentials/vis/fzf-mru.lua33
-rw-r--r--config/essentials/vis/fzf-open.lua9
-rw-r--r--config/essentials/vis/themes/nord.lua156
-rw-r--r--config/essentials/vis/title.lua30
-rw-r--r--config/essentials/vis/vis-go.lua16
-rw-r--r--config/essentials/vis/visrc.lua105
-rw-r--r--config/essentials/zsh/.gitignore2
-rw-r--r--config/essentials/zsh/.zshrc10
-rw-r--r--config/essentials/zsh/widgets.zsh11
-rw-r--r--config/home/.bashrc15
-rw-r--r--config/home/.mbsyncrc50
24 files changed, 1034 insertions, 589 deletions
diff --git a/config/X/x11/xinitrc b/config/X/x11/xinitrc
index 8b3cf2b..57d628b 100755
--- a/config/X/x11/xinitrc
+++ b/config/X/x11/xinitrc
@@ -11,11 +11,11 @@ sysmodmap=/etc/X11/xinit/.Xmodmap
[ -f "$userresources" ] && xrdb -merge "$userresources"
[ -f "$usermodmap" ] && xmodmap "$usermodmap"
-if [ -d /etc/X11/xinit/xinitrc.d ] ; then
- for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
- [ -x "$f" ] && . "$f"
- done
- unset f
+if [ -d /etc/X11/xinit/xinitrc.d ]; then
+ for f in /etc/X11/xinit/xinitrc.d/?*.sh; do
+ [ -x "$f" ] && . "$f"
+ done
+ unset f
fi
export MENUCMD="dmenu"
@@ -25,6 +25,15 @@ feh --no-fehbg --bg-scale ~/pics/wallpaper
setxkbmap colemak -option ctrl:swapcaps,altwin:menu_win
# xautolock -locker slock &
gammastep -m randr &
+which tiramisu >/dev/null 2>&1 &&
+ (
+ IFS=','
+ tiramisu -o '#summary,#body' |
+ while read -r summary body; do
+ herbe "$summary" "$body"
+ done
+ ) &
+ntfy transmission &
# dunst &
slstatus &
upds &
diff --git a/config/common/newsraft/config b/config/common/newsraft/config
new file mode 100644
index 0000000..fdfc8a8
--- /dev/null
+++ b/config/common/newsraft/config
@@ -0,0 +1 @@
+bind m exec mpv "%l"
diff --git a/config/common/newsraft/feeds b/config/common/newsraft/feeds
index 683490c..69f8d71 100644
--- a/config/common/newsraft/feeds
+++ b/config/common/newsraft/feeds
@@ -7,6 +7,7 @@ https://www.youtube.com/feeds/videos.xml?channel_id=UChIs72whgZI9w6d6FhwGGHA "Ga
@ Top
https://www.youtube.com/feeds/videos.xml?channel_id=UCaTznQhurW5AaiYPbhEA-KA "Molly Rocket"
https://www.computerenhance.com/feed "Computer, Enhance!"
+https://www.youtube.com/feeds/videos.xml?channel_id=UCrqM0Ym_NbK1fqeQG2VIohg "TsodingDaily"
https://xkcd.com/rss.xml
@ Hacking
diff --git a/config/essentials/git/config b/config/essentials/git/config
index 99cf21e..2b2b202 100644
--- a/config/essentials/git/config
+++ b/config/essentials/git/config
@@ -9,7 +9,7 @@
[pull]
rebase = false
[merge]
- ff = false
+ ff = true
[alias]
change-commits = "!f() { VAR1=$1; VAR='$'$1; OLD=$2; NEW=$3; echo \"Are you sure for replace $VAR $OLD => $NEW ?(Y/N)\";read OK;if [ \"$OK\" = 'Y' ] ; then shift 3; git filter-branch --env-filter \"if [ \\\"${VAR}\\\" = '$OLD' ]; then export $VAR1='$NEW';echo 'to $NEW'; fi\" $@; fi;}; f "
[commit]
diff --git a/config/essentials/shell/aliases.sh b/config/essentials/shell/aliases.sh
index ddc605a..291640d 100644
--- a/config/essentials/shell/aliases.sh
+++ b/config/essentials/shell/aliases.sh
@@ -3,12 +3,11 @@
# The most important one
alias vi='vis'
-which z > /dev/null 2>&1 &&
- alias cd='z'
+which z >/dev/null 2>&1 &&
+ alias cd='z'
# Zsh specific aliases
-if [ $SHELL = "/bin/zsh" ]
-then
+if [ $SHELL = "/bin/zsh" ]; then
# googoo aliases
alias o~='o $HOME'
alias o/='o /'
@@ -22,10 +21,8 @@ then
alias calc='bc <<<'
- if [ -z "$WAYLAND_DISPLAY" ]
- then
- if which devour > /dev/null 2>&1
- then
+ if [ -z "$WAYLAND_DISPLAY" ]; then
+ if which devour >/dev/null 2>&1; then
alias mpv='devour mpv'
alias zathura='devour zathura'
fi
@@ -38,9 +35,7 @@ then
alias -g hl='--help |& less -r'
fi
-
-if grep -qi "debian\|ubuntu" /etc/os-release 2> /dev/null
-then
+if grep -qi "debian\|ubuntu" /etc/os-release 2>/dev/null; then
alias aptup='apt update && apt upgrade -y'
alias ufwd='while echo y | ufw delete "$(ufw status numbered | tail -n +5 | fzf | cut -f2 -d'\''['\'' | cut -f1 -d'\'']'\'')" > /dev/null 2>&1 && >&2 echo "deleted."; do :; done'
fi
@@ -54,23 +49,22 @@ alias pf='profanity'
alias f='fg'
-which gurk > /dev/null 2>&1 &&
- alias gurk='pgrep gurk > /dev/null && printf "Already Running.\n" || gurk'
+which gurk >/dev/null 2>&1 &&
+ alias gurk='pgrep gurk > /dev/null && printf "Already Running.\n" || gurk'
alias arduino-cli='arduino-cli --config-file $XDG_CONFIG_HOME/arduino15/arduino-cli.yaml'
-if [ -x /usr/bin/dircolors ] || [ -x $HOME/../usr/bin/dircolors ]
-then
- test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
- # alias ls='ls -h --color --group-directories-first'
- #alias dir='dir --color=auto'
- #alias vdir='vdir --color=auto'
-
- alias grep='grep --color=auto'
- alias fgrep='fgrep --color=auto'
- alias egrep='egrep --color=auto'
- alias ip='ip -color=auto'
- alias ipa='ip -br a'
+if [ -x /usr/bin/dircolors ] || [ -x $HOME/../usr/bin/dircolors ]; then
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+ # alias ls='ls -h --color --group-directories-first'
+ #alias dir='dir --color=auto'
+ #alias vdir='vdir --color=auto'
+
+ alias grep='grep --color=auto'
+ alias fgrep='fgrep --color=auto'
+ alias egrep='egrep --color=auto'
+ alias ip='ip -color=auto'
+ alias ipa='ip -br a'
fi
alias l='ls -l'
@@ -104,7 +98,7 @@ alias doprm='dopac -Rns'
alias mpkg='makepkg -si'
-which pikaur > /dev/null 2>&1 && alias yay='MAKEFLAGS="-j $(nproc)" pikaur'
+which pikaur >/dev/null 2>&1 && alias yay='MAKEFLAGS="-j $(nproc)" pikaur'
alias yup='yay -Syu'
alias ysi='yay -Si'
alias yss='yay -Ss'
@@ -128,11 +122,11 @@ alias vimp="vim '+PlugInstall'"
alias nvimp="nvim '+PackerSync'"
alias nvg='git status > /dev/null 2>&1 && nvim "+Git"'
alias nvn='nvim "+Telekasten panel"'
-
+
alias xrandr-rpgmaker='xrandr --auto --output VGA-1 --mode 1024x768 --left-of HDMI-1 && ~/.fehbg'
alias xrandr-default='xrandr --auto --output VGA-1 --mode 1920x1080 --left-of HDMI-1 --output HDMI-1 --mode 1920x1080 && ~/.fehbg'
alias xrhdmi='xrandr --auto --output HDMI-4 --left-of DP-1-2'
-
+
alias d='du -d 0 -h'
alias dud='du .* * -d 0 -h 2>/dev/null | sort -h'
alias df='df -h'
@@ -147,7 +141,6 @@ alias mdb='mariadb -u admin -ppass admindb'
alias mdbw='mariadb -h 0.0.0.0 -u padmin -pbulbizarre padmindb'
alias mdbwa='mariadb -h 10.3.50.5 -u padmin -pbulbizarre padmindb'
alias tmux='pgrep tmux && tmux attach || tmux new-session'
-alias wd='dict'
# ssh
alias sha='ssh-add'
@@ -169,12 +162,11 @@ alias npi="npm init --yes"
# Python
-if which uv > /dev/null 2>&1
-then
- alias penv='uv venv env'
- alias pip='uv pip'
+if which uv >/dev/null 2>&1; then
+ alias penv='uv venv env'
+ alias pip='uv pip'
else
- alias penv='python3 -m venv env'
+ alias penv='python3 -m venv env'
fi
alias phttp='python3 -m http.server'
alias pipreq='pip install -r requirements.txt'
@@ -184,7 +176,7 @@ alias kll='killall'
alias pi='ping 9.9.9.9 -c4'
alias sba='source env/bin/activate || source bin/activate'
-alias zsr='source ${ZDOTDIR:-~}/.zshrc && rehash'
+alias zsr='exec zsh'
alias rh='rehash'
alias wf='doas wipefs -a'
alias dmci="doas make clean install"
@@ -250,7 +242,8 @@ alias ehyb='vi ~/.config/hypr/binds.conf'
alias ewbj='vi ~/.config/waybar/config.jsonc'
alias ewbs='vi ~/.config/waybar/style.css'
alias cfd='vi config.def.h'
-# /# quick cd jV}k:!sort -t "'" -k 2
+alias dump='vi ~/notes/dump.md'
+# /# quick cd jV}k:!sort -t "'" -k 2
alias cdl='cd ~/dl'
alias cdoc='cd ~/docs'
alias czk='cd ~/docs/zk'
@@ -333,15 +326,14 @@ alias dorm='docker container rm $(docker container ls -a | tail -n +2 | fzf -m |
alias dostop='docker container stop $(docker container ls -a | tail -n +2 | fzf -m | awk '\''{print $1}'\'')'
alias doirm='docker image rm $(docker image ls | tail -n +2 | fzf -m | awk '\''{print $3}'\'')'
-alias -g skip='tail -n +2'
alias ddeps='pactree -r -d 1'
alias update-mirrors='reflector -p https | rankmirrors -n 10 -p -w - | doas tee /etc/pacman.d/mirrorlist'
alias tmpd='cd $(mktemp -d)'
alias tmpf='$EDITOR $(mktemp)'
alias brs='$BROWSER'
-which bat > /dev/null 2>&1 &&
- alias cat="bat -p"
+which bat >/dev/null 2>&1 &&
+ alias cat="bat -p"
alias glf='git pull --ff'
alias glnf='git pull --no-ff'
diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh
index 27eb33e..18d75ec 100644
--- a/config/essentials/shell/functions.sh
+++ b/config/essentials/shell/functions.sh
@@ -70,7 +70,10 @@ rln() { ln -s "$(readlink -f "$1")" "$2"; }
getgit() { git clone git@db:"$1"; }
esc() { eval "$EDITOR '$(which $1)'"; }
-compdef esc="which"
+if [ $SHELL = "/bin/zsh" ]
+then
+ compdef esc="which"
+fi
delfile() { curl -s "${2:-https://upfast.cronyakatsuki.xyz/delete/$1}"; }
upfile() { curl -s -F "file=@\"$1\"" "${2:-https://0x0.st}"; }
diff --git a/config/essentials/vis/backup.lua b/config/essentials/vis/backup.lua
index f48895f..7c44c60 100644
--- a/config/essentials/vis/backup.lua
+++ b/config/essentials/vis/backup.lua
@@ -1,36 +1,48 @@
+--[[
+Based on https://github.com/roguh/vis-backup
+Changes made:
+- stylua
+- file path
+--]]
+
local backup = {}
-- Return the backup path concatenated with the filename, replace / with %
-backup.entire_path_with_double_percentage_signs =
- function(backup_dir, path)
- return backup_dir .. "/" .. string.gsub(path, "/", "%%")
- end
+backup.entire_path_with_double_percentage_signs = function(backup_dir, path)
+ return backup_dir .. "/" .. string.gsub(path, "/", "%%")
+end
-- Return the backup path concatenated with the filename, replace / with %
-- and append the current time using time_format
-backup.entire_path_with_double_percentage_signs_and_timestamp = function(
- backup_dir, path)
- return backup_dir .. "/" .. os.date(backup.time_format) ..
- string.gsub(path, "/", "%%")
+backup.entire_path_with_double_percentage_signs_and_timestamp = function(backup_dir, path)
+ return backup_dir .. "/" .. os.date(backup.time_format) .. string.gsub(path, "/", "%%")
end
-- Before saving the file, copy the current contents of the file to a backup file
vis.events.subscribe(vis.events.FILE_SAVE_PRE, function(file, path)
- if file.size > backup.byte_limit then return end
+ if file.size > backup.byte_limit then
+ return
+ end
- -- E.g. when editing stdin as an interactive filter
- -- `vis -`
- if path == nil then return end
+ -- E.g. when editing stdin as an interactive filter
+ -- `vis -`
+ if path == nil then
+ return
+ end
- local backup_path = backup.get_fname(backup.directory, path)
+ local backup_path = backup.get_fname(backup.directory, path)
- local backup_file = io.open(backup_path, "w")
- local current_file = io.open(path)
- if backup_file == nil or current_file == nil then return end
+ local backup_file = io.open(backup_path, "w")
+ local current_file = io.open(path)
+ if backup_file == nil or current_file == nil then
+ return
+ end
- for line in current_file:lines() do backup_file:write(line .. "\n") end
+ for line in current_file:lines() do
+ backup_file:write(line .. "\n")
+ end
- backup_file:close()
+ backup_file:close()
end)
-- Set defaults
diff --git a/config/essentials/vis/build.lua b/config/essentials/vis/build.lua
index 8a062cd..90dd905 100644
--- a/config/essentials/vis/build.lua
+++ b/config/essentials/vis/build.lua
@@ -1,3 +1,11 @@
+--[[
+Based on https://gitlab.com/muhq/vis-build
+Changes made:
+- stylua format
+- print build messages on success
+--]]
+
+
-- Copyright (c) 2024 Florian Fischer. All rights reserved.
--
-- vis-build is free software: you can redistribute it and/or modify it under
diff --git a/config/essentials/vis/commentary.lua b/config/essentials/vis/commentary.lua
index 26d06b5..742d2df 100644
--- a/config/essentials/vis/commentary.lua
+++ b/config/essentials/vis/commentary.lua
@@ -1,251 +1,284 @@
+--[[
+Based on https://github.com/lutobler/vis-commentary
+Changes made:
+- stylua
+--]]
+
--
-- vis-commentary
--
local comment_string = {
- actionscript = '//',
- ada = '--',
- ansi_c = '/*|*/',
- antlr = '//',
- apdl = '!',
- apl = '#',
- applescript = '--',
- asp = '\'',
- autoit = ';',
- awk = '#',
- b_lang = '//',
- bash = '#',
- batch = ':',
- bibtex = '%',
- boo = '#',
- chuck = '//',
- cmake = '#',
- coffeescript = '#',
- context = '%',
- cpp = '//',
- crystal = '#',
- csharp = '//',
- css = '/*|*/',
- cuda = '//',
- dart = '//',
- desktop = '#',
- django = '{#|#}',
- dmd = '//',
- dockerfile = '#',
- dot = '//',
- eiffel = '--',
- elixir = '#',
- erlang = '%',
- faust = '//',
- fennel = ';;',
- fish = '#',
- forth = '|\\',
- fortran = '!',
- fsharp = '//',
- gap = '#',
- gettext = '#',
- gherkin = '#',
- glsl = '//',
- gnuplot = '#',
- go = '//',
- groovy = '//',
- gtkrc = '#',
- haskell = '--',
- html = '<!--|-->',
- icon = '#',
- idl = '//',
- inform = '!',
- ini = '#',
- Io = '#',
- java = '//',
- javascript = '//',
- json = '/*|*/',
- jsp = '//',
- latex = '%',
- ledger = '#',
- less = '//',
- lilypond = '%',
- lisp = ';',
- logtalk = '%',
- lua = '--',
- makefile = '#',
- markdown = '<!--|-->',
- matlab = '#',
- moonscript = '--',
- myrddin = '//',
- nemerle = '//',
- nsis = '#',
- objective_c = '//',
- pascal = '//',
- perl = '#',
- php = '//',
- pico8 = '//',
- pike = '//',
- pkgbuild = '#',
- prolog = '%',
- props = '#',
- protobuf = '//',
- ps = '%',
- pure = '//',
- python = '#',
- rails = '#',
- rc = '#',
- rebol = ';',
- rest = '.. ',
- rexx = '--',
- rhtml = '<!--|-->',
- rstats = '#',
- ruby = '#',
- rust = '//',
- sass = '//',
- scala = '//',
- scheme = ';',
- smalltalk = '"|"',
- sml = '(*)',
- snobol4 = '#',
- sql = '#',
- tcl = '#',
- tex = '%',
- text = '',
- toml = '#',
- vala = '//',
- vb = '\'',
- vbscript = '\'',
- verilog = '//',
- vhdl = '--',
- wsf = '<!--|-->',
- xml = '<!--|-->',
- yaml = '#',
- zig = '//',
- nim = '#',
- julia = '#',
- rpmspec = '#'
+ actionscript = "//",
+ ada = "--",
+ ansi_c = "/*|*/",
+ antlr = "//",
+ apdl = "!",
+ apl = "#",
+ applescript = "--",
+ asp = "'",
+ autoit = ";",
+ awk = "#",
+ b_lang = "//",
+ bash = "#",
+ batch = ":",
+ bibtex = "%",
+ boo = "#",
+ chuck = "//",
+ cmake = "#",
+ coffeescript = "#",
+ context = "%",
+ cpp = "//",
+ crystal = "#",
+ csharp = "//",
+ css = "/*|*/",
+ cuda = "//",
+ dart = "//",
+ desktop = "#",
+ django = "{#|#}",
+ dmd = "//",
+ dockerfile = "#",
+ dot = "//",
+ eiffel = "--",
+ elixir = "#",
+ erlang = "%",
+ faust = "//",
+ fennel = ";;",
+ fish = "#",
+ forth = "|\\",
+ fortran = "!",
+ fsharp = "//",
+ gap = "#",
+ gettext = "#",
+ gherkin = "#",
+ glsl = "//",
+ gnuplot = "#",
+ go = "//",
+ groovy = "//",
+ gtkrc = "#",
+ haskell = "--",
+ html = "<!--|-->",
+ icon = "#",
+ idl = "//",
+ inform = "!",
+ ini = "#",
+ Io = "#",
+ java = "//",
+ javascript = "//",
+ json = "/*|*/",
+ jsp = "//",
+ latex = "%",
+ ledger = "#",
+ less = "//",
+ lilypond = "%",
+ lisp = ";",
+ logtalk = "%",
+ lua = "--",
+ makefile = "#",
+ markdown = "<!--|-->",
+ matlab = "#",
+ moonscript = "--",
+ myrddin = "//",
+ nemerle = "//",
+ nsis = "#",
+ objective_c = "//",
+ pascal = "//",
+ perl = "#",
+ php = "//",
+ pico8 = "//",
+ pike = "//",
+ pkgbuild = "#",
+ prolog = "%",
+ props = "#",
+ protobuf = "//",
+ ps = "%",
+ pure = "//",
+ python = "#",
+ rails = "#",
+ rc = "#",
+ rebol = ";",
+ rest = ".. ",
+ rexx = "--",
+ rhtml = "<!--|-->",
+ rstats = "#",
+ ruby = "#",
+ rust = "//",
+ sass = "//",
+ scala = "//",
+ scheme = ";",
+ smalltalk = '"|"',
+ sml = "(*)",
+ snobol4 = "#",
+ sql = "#",
+ tcl = "#",
+ tex = "%",
+ text = "",
+ toml = "#",
+ vala = "//",
+ vb = "'",
+ vbscript = "'",
+ verilog = "//",
+ vhdl = "--",
+ wsf = "<!--|-->",
+ xml = "<!--|-->",
+ yaml = "#",
+ zig = "//",
+ nim = "#",
+ julia = "#",
+ rpmspec = "#",
}
-- escape all magic characters with a '%'
local function esc(str)
- if not str then return "" end
- return (str:gsub('%%', '%%%%'):gsub('^%^', '%%^'):gsub('%$$', '%%$'):gsub(
- '%(', '%%('):gsub('%)', '%%)'):gsub('%.', '%%.')
- :gsub('%[', '%%['):gsub('%]', '%%]'):gsub('%*', '%%*')
- :gsub('%+', '%%+'):gsub('%-', '%%-'):gsub('%?', '%%?'))
+ if not str then
+ return ""
+ end
+ return (
+ str:gsub("%%", "%%%%")
+ :gsub("^%^", "%%^")
+ :gsub("%$$", "%%$")
+ :gsub("%(", "%%(")
+ :gsub("%)", "%%)")
+ :gsub("%.", "%%.")
+ :gsub("%[", "%%[")
+ :gsub("%]", "%%]")
+ :gsub("%*", "%%*")
+ :gsub("%+", "%%+")
+ :gsub("%-", "%%-")
+ :gsub("%?", "%%?")
+ )
end
-- escape '%'
local function pesc(str)
- if not str then return "" end
- return str:gsub('%%', '%%%%')
+ if not str then
+ return ""
+ end
+ return str:gsub("%%", "%%%%")
end
local function rtrim(s)
- local n = #s
- while n > 0 and s:find("^%s", n) do n = n - 1 end
- return s:sub(1, n)
+ local n = #s
+ while n > 0 and s:find("^%s", n) do
+ n = n - 1
+ end
+ return s:sub(1, n)
end
local function comment_line(lines, lnum, prefix, suffix)
- if suffix ~= "" then suffix = " " .. suffix end
- lines[lnum] = string.gsub(lines[lnum], "(%s*)(.*)",
- "%1" .. pesc(prefix) .. " %2" .. pesc(suffix))
+ if suffix ~= "" then
+ suffix = " " .. suffix
+ end
+ lines[lnum] = string.gsub(lines[lnum], "(%s*)(.*)", "%1" .. pesc(prefix) .. " %2" .. pesc(suffix))
end
local function uncomment_line(lines, lnum, prefix, suffix)
- local match_str = "^(%s*)" .. esc(prefix) .. "%s?(.*)" .. esc(suffix)
- local m = table.pack(lines[lnum]:match(match_str))
- lines[lnum] = m[1] .. rtrim(m[2])
+ local match_str = "^(%s*)" .. esc(prefix) .. "%s?(.*)" .. esc(suffix)
+ local m = table.pack(lines[lnum]:match(match_str))
+ lines[lnum] = m[1] .. rtrim(m[2])
end
local function is_comment(line, prefix)
- return (line:match("^%s*(.+)"):sub(0, #prefix) == prefix)
+ return (line:match("^%s*(.+)"):sub(0, #prefix) == prefix)
end
local function toggle_line_comment(lines, lnum, prefix, suffix)
- if not lines or not lines[lnum] then return end
- if not lines[lnum]:match("^%s*(.+)") then return end -- ignore empty lines
- if is_comment(lines[lnum], prefix) then
- uncomment_line(lines, lnum, prefix, suffix)
- else
- comment_line(lines, lnum, prefix, suffix)
- end
+ if not lines or not lines[lnum] then
+ return
+ end
+ if not lines[lnum]:match("^%s*(.+)") then
+ return
+ end -- ignore empty lines
+ if is_comment(lines[lnum], prefix) then
+ uncomment_line(lines, lnum, prefix, suffix)
+ else
+ comment_line(lines, lnum, prefix, suffix)
+ end
end
-- if one line inside the block is not a comment, comment the block.
-- only uncomment, if every single line is comment.
local function block_comment(lines, a, b, prefix, suffix)
- local uncomment = true
- for i = a, b do
- if lines[i]:match("^%s*(.+)") and not is_comment(lines[i], prefix) then
- uncomment = false
- end
- end
-
- if uncomment then
- for i = a, b do
- if lines[i]:match("^%s*(.+)") then
- uncomment_line(lines, i, prefix, suffix)
- end
- end
- else
- for i = a, b do
- if lines[i]:match("^%s*(.+)") then
- comment_line(lines, i, prefix, suffix)
- end
- end
- end
+ local uncomment = true
+ for i = a, b do
+ if lines[i]:match("^%s*(.+)") and not is_comment(lines[i], prefix) then
+ uncomment = false
+ end
+ end
+
+ if uncomment then
+ for i = a, b do
+ if lines[i]:match("^%s*(.+)") then
+ uncomment_line(lines, i, prefix, suffix)
+ end
+ end
+ else
+ for i = a, b do
+ if lines[i]:match("^%s*(.+)") then
+ comment_line(lines, i, prefix, suffix)
+ end
+ end
+ end
end
vis:map(vis.modes.NORMAL, "gcc", function()
- local win = vis.win
- local lines = win.file.lines
- local comment = comment_string[win.syntax]
- if not comment then return end
- local prefix, suffix = comment:match('^([^|]+)|?([^|]*)$')
- if not prefix then return end
-
- for sel in win:selections_iterator() do
- local lnum = sel.line
- local col = sel.col
-
- toggle_line_comment(lines, lnum, prefix, suffix)
- sel:to(lnum, col) -- restore cursor position
- end
-
- win:draw()
+ local win = vis.win
+ local lines = win.file.lines
+ local comment = comment_string[win.syntax]
+ if not comment then
+ return
+ end
+ local prefix, suffix = comment:match("^([^|]+)|?([^|]*)$")
+ if not prefix then
+ return
+ end
+
+ for sel in win:selections_iterator() do
+ local lnum = sel.line
+ local col = sel.col
+
+ toggle_line_comment(lines, lnum, prefix, suffix)
+ sel:to(lnum, col) -- restore cursor position
+ end
+
+ win:draw()
end, "Toggle comment on a the current line")
local function visual_f(i)
- return function()
- local win = vis.win
- local lines = win.file.lines
+ return function()
+ local win = vis.win
+ local lines = win.file.lines
- local comment = comment_string[win.syntax]
- if not comment then return end
+ local comment = comment_string[win.syntax]
+ if not comment then
+ return
+ end
- local prefix, suffix = comment:match('^([^|]+)|?([^|]*)$')
- if not prefix then return end
+ local prefix, suffix = comment:match("^([^|]+)|?([^|]*)$")
+ if not prefix then
+ return
+ end
- for sel in win:selections_iterator() do
- local r = sel.range
- local lnum = sel.line -- line number of cursor
- local col = sel.col -- column of cursor
+ for sel in win:selections_iterator() do
+ local r = sel.range
+ local lnum = sel.line -- line number of cursor
+ local col = sel.col -- column of cursor
- if sel.anchored and r then
- sel.pos = r.start
- local a = sel.line
- sel.pos = r.finish
- local b = sel.line - i
+ if sel.anchored and r then
+ sel.pos = r.start
+ local a = sel.line
+ sel.pos = r.finish
+ local b = sel.line - i
- block_comment(lines, a, b, prefix, suffix)
+ block_comment(lines, a, b, prefix, suffix)
- sel:to(lnum, col) -- restore cursor position
- end
- end
+ sel:to(lnum, col) -- restore cursor position
+ end
+ end
- win:draw()
- vis.mode = vis.modes.NORMAL -- go to normal mode
- end
+ win:draw()
+ vis.mode = vis.modes.NORMAL -- go to normal mode
+ end
end
-vis:map(vis.modes.VISUAL_LINE, "gc", visual_f(1),
- "Toggle comment on the selected lines")
-vis:map(vis.modes.VISUAL, "gc", visual_f(0),
- "Toggle comment on the selected lines")
+vis:map(vis.modes.VISUAL_LINE, "gc", visual_f(1), "Toggle comment on the selected lines")
+vis:map(vis.modes.VISUAL, "gc", visual_f(0), "Toggle comment on the selected lines")
diff --git a/config/essentials/vis/complete-line.lua b/config/essentials/vis/complete-line.lua
index 93728a3..98515a9 100644
--- a/config/essentials/vis/complete-line.lua
+++ b/config/essentials/vis/complete-line.lua
@@ -1,141 +1,56 @@
+--[[
+Based on https://repo.or.cz/vis-complete-line.git
+Changes made:
+- stylua
+- removed <C-x><C-e>, <C-x><C-y> and related functions and variables
+--]]
+
-- SPDX-License-Identifier: GPL-3.0-or-later
-- © 2020 Georgi Kirilov
local progname = ...
-local lpeg = require("lpeg")
-local R, C, Cmt = lpeg.R, lpeg.C, lpeg.Cmt
-
--- copied from vis.h
-local VIS_MOVE_NOP = 64
-
-local cont = R("\128\191")
-
-local charpattern = R("\0\127") + R("\194\223") * cont + R("\224\239") * cont *
- cont + R("\240\244") * cont * cont * cont
-
local function concat_keys(tbl)
- local keys = {}
- for k in pairs(tbl) do table.insert(keys, k) end
- return table.concat(keys, "\n"), #keys
+ local keys = {}
+ for k in pairs(tbl) do
+ table.insert(keys, k)
+ end
+ return table.concat(keys, "\n"), #keys
end
local function line_complete()
- local file = vis.win.file
- local sel = vis.win.selection
- local cur_line = file.lines[sel.line]
- local indent_patt = "^[ \t\v\f]+"
- local prefix = cur_line:sub(1, sel.col - 1):gsub(indent_patt, "")
- local candidates = {}
- for l in file:lines_iterator() do
- local unindented = l:gsub(indent_patt, "")
- local start, finish = unindented:find(prefix, 1, true)
- if start == 1 and finish < #unindented then
- candidates[unindented] = true
- end
- end
- local candidates_str, n = concat_keys(candidates)
- if n < 2 then
- if n == 1 then vis:insert(candidates_str:sub(#prefix + 1)) end
- return
- end
- -- XXX: with too many candidates this command will become longer that the shell can handle:
- local command = string.format("vis-menu -l %d <<'EOF'\n%s\nEOF\n",
- math.min(n, math.ceil(vis.win.height / 2)),
- candidates_str)
- local status, output = vis:pipe(nil, nil, command)
- if n > 0 and status == 0 then
- vis:insert(output:sub(#prefix + 1):gsub("\n$", ""))
- end
-end
-
-local function selection_by_pos(pos)
- for s in vis.win:selections_iterator() do
- if s.pos == pos then return s end
- end
-end
-
-local function charwidth(cells_so_far, char)
- if char == "\t" then
- local tw = vis.tabwidth or 8
- local trail = cells_so_far % tw
- return tw - trail
- else
- return 1
- end
-end
-
-local function virtcol(line, col)
- local ncells = 0
- local nchars = 0
- local function upto(_, _, char)
- if nchars < col - 1 then
- ncells = ncells + charwidth(ncells, char)
- nchars = nchars + 1
- return true
- end
- end
- (Cmt(C(charpattern), upto) ^ 0):match(line)
- return ncells + 1
-end
-
-local function neighbor(lines, ln, col, direction)
- local line = ln + direction > 0 and lines[ln + direction]
- if not line then return end
- local column = virtcol(lines[ln], col)
- local ncells = 0
- local function upto(_, _, char)
- ncells = ncells + charwidth(ncells, char)
- return ncells < column
- end
- return
- (Cmt(C(charpattern), upto) ^ (-column + 1) / 0 * C(charpattern)):match(
- line)
-end
-
-local function dup_neighbor(direction)
- return function(file, _, pos)
- local sel = selection_by_pos(pos)
- local char = neighbor(file.lines, sel.line, sel.col, direction)
- if not char then return pos end
- file:insert(pos, char)
- return pos + #char
- end
-end
-
-local function dup_neighbor_feedkeys(direction)
- local sel = vis.win.selection
- local file = vis.win.file
- local char = neighbor(file.lines, sel.line, sel.col, direction)
- if not char then return end
- vis:feedkeys(char)
-end
-
-local function operator(handler)
- local id = vis:operator_register(handler)
- return id >= 0 and function()
- vis:operator(id)
- vis:motion(VIS_MOVE_NOP)
- end
+ local file = vis.win.file
+ local sel = vis.win.selection
+ local cur_line = file.lines[sel.line]
+ local indent_patt = "^[ \t\v\f]+"
+ local prefix = cur_line:sub(1, sel.col - 1):gsub(indent_patt, "")
+ local candidates = {}
+ for l in file:lines_iterator() do
+ local unindented = l:gsub(indent_patt, "")
+ local start, finish = unindented:find(prefix, 1, true)
+ if start == 1 and finish < #unindented then
+ candidates[unindented] = true
+ end
+ end
+ local candidates_str, n = concat_keys(candidates)
+ if n < 2 then
+ if n == 1 then
+ vis:insert(candidates_str:sub(#prefix + 1))
+ end
+ return
+ end
+ -- XXX: with too many candidates this command will become longer that the shell can handle:
+ local command =
+ string.format("vis-menu -l %d <<'EOF'\n%s\nEOF\n", math.min(n, math.ceil(vis.win.height / 2)), candidates_str)
+ local status, output = vis:pipe(nil, nil, command)
+ if n > 0 and status == 0 then
+ vis:insert(output:sub(#prefix + 1):gsub("\n$", ""))
+ end
end
vis.events.subscribe(vis.events.INIT, function()
- local function h(msg) return string.format("|@%s| %s", progname, msg) end
-
- local function column_complete(direction)
- local binding = operator(dup_neighbor(direction))
- return function()
- if #vis.win.selections == 1 then
- dup_neighbor_feedkeys(direction)
- else
- return binding()
- end
- end
- end
+ local function h(msg)
+ return string.format("|@%s| %s", progname, msg)
+ end
- vis:map(vis.modes.INSERT, "<C-y>", column_complete(-1),
- h "Insert the character which is above the cursor")
- vis:map(vis.modes.INSERT, "<C-e>", column_complete(1),
- h "Insert the character which is below the cursor")
- vis:map(vis.modes.INSERT, "<C-x><C-l>", line_complete,
- h "Complete the current line")
+ vis:map(vis.modes.INSERT, "<C-x><C-l>", line_complete, h("Complete the current line"))
end)
diff --git a/config/essentials/vis/ctags.lua b/config/essentials/vis/ctags.lua
new file mode 100644
index 0000000..40d4aef
--- /dev/null
+++ b/config/essentials/vis/ctags.lua
@@ -0,0 +1,343 @@
+--[[
+Based on https://github.com/kupospelov/vis-ctags
+Changes made:
+- stylua
+--]]
+
+require("vis")
+
+local positions = {}
+local tags = { "tags" }
+local ctags = { actions = {} }
+
+local function abs_path(prefix, path)
+ if string.find(path, "^/") ~= nil then
+ return path, path
+ end
+
+ if string.find(path, "^./") ~= nil then
+ path = path:sub(3)
+ end
+
+ return prefix .. path, path
+end
+
+local function is_directory(path)
+ local dir = io.open(path .. "/", "r")
+ if dir then
+ dir:close()
+ return true
+ else
+ return false
+ end
+end
+
+local function find_tags(path)
+ for i = #path, 1, -1 do
+ if path:sub(i, i) == "/" then
+ local prefix = path:sub(1, i)
+ for j = 1, #tags do
+ local tagfile = tags[j]
+ local filename
+ if tagfile:sub(1, 1) == "/" then
+ filename = tagfile
+ else
+ filename = prefix .. tagfile
+ end
+ if not is_directory(filename) then
+ local file = io.open(filename, "r")
+
+ if file ~= nil then
+ return file, prefix
+ end
+ end
+ end
+ end
+ end
+end
+
+local function bsearch(file, word)
+ local buffer_size = 8096
+ local format = '\n(.-)\t(.-)\t(.-);"\t'
+
+ local from = 0
+ local to = file:seek("end")
+ local startpos = nil
+
+ while from <= to do
+ local mid = from + math.floor((to - from) / 2)
+ file:seek("set", mid)
+
+ local content = file:read(buffer_size, "*line")
+ if content ~= nil then
+ local key, _, _ = string.match(content, format)
+ if key == nil then
+ break
+ end
+
+ if key == word then
+ startpos = mid
+ end
+
+ if key >= word then
+ to = mid - 1
+ else
+ from = mid + 1
+ end
+ else
+ to = mid - 1
+ end
+ end
+
+ if startpos ~= nil then
+ file:seek("set", startpos)
+
+ local result = {}
+ while true do
+ local content = file:read(buffer_size, "*line")
+ if content == nil then
+ break
+ end
+
+ for key, filename, excmd in string.gmatch(content, format) do
+ if key == word then
+ result[#result + 1] = { name = filename, excmd = excmd }
+ else
+ return result
+ end
+ end
+ end
+
+ return result
+ end
+end
+
+local function get_query()
+ local line = vis.win.selection.line
+ local pos = vis.win.selection.col
+ local str = vis.win.file.lines[line]
+
+ local from, to = 0, 0
+ while pos > to do
+ from, to = str:find("[%a_]+[%a%d_]*", to + 1)
+ if from == nil or from > pos then
+ return nil
+ end
+ end
+
+ return string.sub(str, from, to)
+end
+
+local function get_matches(word, path)
+ local file, prefix = find_tags(path)
+
+ if file ~= nil then
+ local results = bsearch(file, word)
+ file:close()
+
+ if results ~= nil then
+ local matches = {}
+ for i = 1, #results do
+ local result = results[i]
+ local abspath, name = abs_path(prefix, result.name)
+ local desc = string.format("%s%s", name, tonumber(result.excmd) and ":" .. result.excmd or "")
+
+ matches[#matches + 1] = { desc = desc, path = abspath, excmd = result.excmd }
+ end
+
+ return matches
+ end
+ end
+end
+
+local function get_match(word, path)
+ local matches = get_matches(word, path)
+ if matches ~= nil then
+ for i = 1, #matches do
+ if matches[i].path == path then
+ return matches[i]
+ end
+ end
+
+ return matches[1]
+ end
+end
+
+local function escape(text)
+ return text:gsub("[][)(}{|+?*.]", "\\%0")
+ :gsub("%^", "\\^")
+ :gsub("^/\\%^", "/^")
+ :gsub("%$", "\\$")
+ :gsub("\\%$/$", "$/")
+ :gsub("\\\\%$%$/$", "\\$$")
+end
+
+--[[
+- Can't test vis:command() as it will still return true if the edit command fails.
+- Can't test File.modified as the edit command can succeed if the current file is
+ modified but open in another window and this behavior is useful.
+- Instead just check the path again after trying the edit command.
+]]
+local function goto_pos(pos, force)
+ if pos.path ~= vis.win.file.path then
+ vis:command(string.format(force and 'e! "%s"' or 'e "%s"', pos.path))
+ if pos.path ~= vis.win.file.path then
+ return false
+ end
+ end
+ if tonumber(pos.excmd) then
+ vis.win.selection:to(pos.excmd, pos.col)
+ else
+ vis.win.selection:to(1, 1)
+ vis:command(escape(pos.excmd))
+ vis.win.selection.pos = vis.win.selection.range.start
+ vis.mode = vis.modes.NORMAL
+ end
+ return true
+end
+
+local function goto_tag(path, excmd, force)
+ local old = {
+ path = vis.win.file.path,
+ excmd = vis.win.selection.line,
+ col = vis.win.selection.col,
+ }
+
+ local last_search = vis.registers["/"]
+ if goto_pos({ path = path, excmd = excmd, col = 1 }, force) then
+ positions[#positions + 1] = old
+ vis.registers["/"] = last_search
+ end
+end
+
+local function pop_pos(force)
+ if #positions < 1 then
+ return
+ end
+ if goto_pos(positions[#positions], force) then
+ table.remove(positions, #positions)
+ end
+end
+
+local function win_path()
+ if vis.win.file.path == nil then
+ return os.getenv("PWD") .. "/"
+ end
+ return vis.win.file.path
+end
+
+local function tag_cmd(tag, force)
+ local match = get_match(tag, win_path())
+ if match == nil then
+ vis:info(string.format("Tag not found: %s", tag))
+ else
+ goto_tag(match.path, match.excmd, force)
+ end
+end
+
+local function gen_vis_menu(matches)
+ local width = 0
+ for _, match in ipairs(matches) do
+ width = math.max(width, match.desc:len())
+ end
+ -- limit max width of desc field (filename) in menu
+ width = math.min(width, 40)
+ local fmt = "%" .. #tostring(#matches) .. "d %-" .. width .. "s %s"
+
+ local lines = {}
+ for i, match in ipairs(matches) do
+ local desc = match.desc
+ if desc:len() > width then
+ desc = "..." .. desc:sub(desc:len() - width + 4)
+ end
+
+ -- work around bug displaying tabs in vis-menu and
+ -- provide a clearer context
+ local excmd = match.excmd:gsub("%s+", " ")
+ excmd = excmd:gsub("^/^", "")
+ excmd = excmd:gsub("$/$", "")
+ table.insert(lines, fmt:format(i, desc, excmd))
+ end
+
+ -- limit vis-menu height to ~1/4 the window height
+ -- +1 gives an empty line at bottom to signify
+ -- that there are no more lines to scroll through
+ local nlines = math.min(math.floor(vis.win.height / 4), #lines)
+ if nlines == #lines then
+ nlines = nlines + 1
+ end
+ return "vis-menu -l " .. nlines .. " -p 'Choose tag:' << 'EOF'\n" .. table.concat(lines, "\n") .. "\n" .. "EOF"
+end
+
+local function tselect_cmd(tag, force)
+ local matches = get_matches(tag, win_path())
+ if matches == nil then
+ vis:info(string.format("Tag not found: %s", tag))
+ else
+ local status, output = vis:pipe(vis.win.file, { start = 0, finish = 0 }, gen_vis_menu(matches))
+
+ if status ~= 0 then
+ vis:info("Command failed")
+ return
+ end
+
+ local choice = tonumber(string.match(output, "%d+"))
+ if choice == nil or choice < 1 or choice > #matches then
+ vis:info("Invalid choice")
+ return
+ end
+ goto_tag(matches[choice].path, matches[choice].excmd, force)
+ end
+end
+
+vis:command_register("tag", function(argv, force)
+ if #argv == 1 then
+ tag_cmd(argv[1], force)
+ end
+end)
+
+vis:command_register("tselect", function(argv, force)
+ if #argv == 1 then
+ tselect_cmd(argv[1], force)
+ end
+end)
+
+vis:command_register("pop", function(_, force)
+ pop_pos(force)
+end)
+
+vis:option_register("tags", "string", function(value)
+ tags = {}
+ for str in value:gmatch("([^%s]+)") do
+ table.insert(tags, str)
+ end
+end, "Paths to search for tags (separated by spaces)")
+
+ctags.actions.tag = function()
+ local query = get_query()
+ local force = false
+ if query ~= nil then
+ tag_cmd(query, force)
+ end
+ return 0
+end
+
+ctags.actions.tselect = function()
+ local query = get_query()
+ local force = false
+ if query ~= nil then
+ tselect_cmd(query, force)
+ end
+ return 0
+end
+
+ctags.actions.pop = function()
+ pop_pos()
+ return 0
+end
+
+vis:map(vis.modes.NORMAL, "<C-]>", ctags.actions.tag)
+vis:map(vis.modes.NORMAL, "g<C-]>", ctags.actions.tselect)
+vis:map(vis.modes.NORMAL, "<C-t>", ctags.actions.pop)
+
+return ctags
diff --git a/config/essentials/vis/cursors.lua b/config/essentials/vis/cursors.lua
index 5b3d43b..01c1ede 100644
--- a/config/essentials/vis/cursors.lua
+++ b/config/essentials/vis/cursors.lua
@@ -1,3 +1,9 @@
+--[[
+Based on https://github.com/erf/vis-cursors
+Changes made:
+- stylua
+--]]
+
local M = {}
local cursors = {}
local files = {}
diff --git a/config/essentials/vis/format.lua b/config/essentials/vis/format.lua
index e39320e..67613a6 100644
--- a/config/essentials/vis/format.lua
+++ b/config/essentials/vis/format.lua
@@ -1,6 +1,16 @@
-local global_options = { check_same = true }
+--[[
+Based on https://github.com/milhnl/vis-format
+Changes made:
+- stylua
+- restore position after format
+- use local M to return the module
+--]]
-local function stdio_formatter(cmd, options)
+local M = {}
+M.check_same = true
+M.wrapwidth = 90
+
+M.stdio_formatter = function(cmd, options)
local function apply(win, range, pos)
local size = win.file.size
local all = { start = 0, finish = size }
@@ -8,7 +18,7 @@ local function stdio_formatter(cmd, options)
range = all
end
local command = type(cmd) == "function" and cmd(win, range, pos) or cmd
- local check_same = (options and options.check_same ~= nil) and options.check_same or global_options.check_same
+ local check_same = (options and options.check_same ~= nil) and options.check_same or M.check_same
local check = check_same == true or (type(check_same) == "number" and check_same >= size)
local status, out, err = vis:pipe(win.file, all, command)
if status ~= 0 then
@@ -28,7 +38,7 @@ local function stdio_formatter(cmd, options)
}
end
-local function with_filename(win, option)
+M.with_filename = function(win, option)
if win.file.path then
return option .. "'" .. win.file.path:gsub("'", "\\'") .. "'"
else
@@ -36,13 +46,12 @@ local function with_filename(win, option)
end
end
-local formatters = {}
-formatters = {
- bash = stdio_formatter(function(win)
- return "shfmt " .. with_filename(win, "--filename ") .. " -"
+M.formatters = {
+ bash = M.stdio_formatter(function(win)
+ return "shfmt " .. M.with_filename(win, "--filename ") .. " -"
end),
- csharp = stdio_formatter("dotnet csharpier"),
- go = stdio_formatter("gofmt"),
+ csharp = M.stdio_formatter("dotnet csharpier"),
+ go = M.stdio_formatter("gofmt"),
lua = {
pick = function(win)
local _, out = vis:pipe(
@@ -50,41 +59,41 @@ formatters = {
{ start = 0, finish = win.file.size },
"test -e .lua-format && echo luaformatter || echo stylua"
)
- return formatters[out:gsub("\n$", "")]
+ return M.formatters[out:gsub("\n$", "")]
end,
},
- luaformatter = stdio_formatter("lua-format"),
- markdown = stdio_formatter(function(win)
- if win.options and win.options.colorcolumn ~= 0 then
+ luaformatter = M.stdio_formatter("lua-format"),
+ markdown = M.stdio_formatter(function(win)
+ if win.options and M.wrapwidth ~= 0 then
return "prettier --parser markdown --prose-wrap always "
- .. ("--print-width " .. (win.options.colorcolumn - 1) .. " ")
- .. with_filename(win, "--stdin-filepath ")
+ .. ("--print-width " .. (M.wrapwidth - 1) .. " ")
+ .. M.with_filename(win, "--stdin-filepath ")
else
- return "prettier --parser markdown " .. with_filename(win, "--stdin-filepath ")
+ return "prettier --parser markdown " .. M.with_filename(win, "--stdin-filepath ")
end
end, { ranged = false }),
- powershell = stdio_formatter([[
+ powershell = M.stdio_formatter([[
"$( (command -v powershell.exe || command -v pwsh) 2>/dev/null )" -c '
Invoke-Formatter -ScriptDefinition `
([IO.StreamReader]::new([Console]::OpenStandardInput()).ReadToEnd())
' | sed -e :a -e '/^[\r\n]*$/{$d;N;};/\n$/ba'
]]),
- rust = stdio_formatter("rustfmt"),
- stylua = stdio_formatter(function(win, range)
+ rust = M.stdio_formatter("rustfmt"),
+ stylua = M.stdio_formatter(function(win, range)
if range and (range.start ~= 0 or range.finish ~= win.file.size) then
return "stylua -s --range-start "
.. range.start
.. " --range-end "
.. range.finish
- .. with_filename(win, " --stdin-filepath ")
+ .. M.with_filename(win, " --stdin-filepath ")
.. " -"
else
- return "stylua -s " .. with_filename(win, "--stdin-filepath ") .. " -"
+ return "stylua -s " .. M.with_filename(win, "--stdin-filepath ") .. " -"
end
end),
- text = stdio_formatter(function(win)
- if win.options and win.options.colorcolumn ~= 0 then
- return "fmt -w " .. (win.options.colorcolumn - 1)
+ text = M.stdio_formatter(function(win)
+ if win.options and M.wrapwidth ~= 0 then
+ return "fmt -w " .. (M.wrapwidth - 1)
else
return "fmt"
end
@@ -99,7 +108,7 @@ local function getwinforfile(file)
end
end
-local function apply(file_or_keys, range, pos)
+M.apply = function(file_or_keys, range, pos)
local win = type(file_or_keys) ~= "string" and getwinforfile(file_or_keys) or vis.win
local ret = type(file_or_keys) ~= "string" and function()
return pos
@@ -107,7 +116,7 @@ local function apply(file_or_keys, range, pos)
return 0
end
pos = pos or win.selection.pos
- local formatter = formatters[win.syntax]
+ local formatter = M.formatters[win.syntax]
if formatter and formatter.pick then
formatter = formatter.pick(win)
end
@@ -125,10 +134,4 @@ local function apply(file_or_keys, range, pos)
return ret()
end
-return {
- formatters = formatters,
- options = global_options,
- apply = apply,
- stdio_formatter = stdio_formatter,
- with_filename = with_filename,
-}
+return M
diff --git a/config/essentials/vis/fzf-mru.lua b/config/essentials/vis/fzf-mru.lua
index 6c2510d..455d083 100644
--- a/config/essentials/vis/fzf-mru.lua
+++ b/config/essentials/vis/fzf-mru.lua
@@ -1,12 +1,23 @@
-local module = {}
-module.fzfmru_filepath = os.getenv("XDG_CACHE_HOME") .. "/vis-fzf-mru"
-module.fzfmru_path = "fzf"
-module.fzfmru_args = "--height=40%"
-module.fzfmru_history = 20
+--[[
+Based on https://github.com/peaceant/vis-fzf-mru
+Changes made:
+- stylua
+- renamed module to M
+- renamed fzfmru to fzf
+- height to 40%
+- use XDG_CACHE_HOME
+- ignore exit code 130
+--]]
+
+local M = {}
+M.fzf_filepath = os.getenv("XDG_CACHE_HOME") .. "/vis-fzf-mru"
+M.fzf_path = "fzf"
+M.fzf_args = "--height=40%"
+M.fzf_history = 20
local function read_mru()
local mru = {}
- local f = io.open(module.fzfmru_filepath)
+ local f = io.open(M.fzf_filepath)
if f == nil then return end
for line in f:lines() do table.insert(mru, line) end
f:close()
@@ -25,13 +36,13 @@ local function write_mru(win)
-- check duplicate
if file_path == mru[1] then return end
- local f = io.open(module.fzfmru_filepath, "w+")
+ local f = io.open(M.fzf_filepath, "w+")
if f == nil then return end
table.insert(mru, 1, file_path)
for i, k in ipairs(mru) do
- if i > module.fzfmru_history then break end
+ if i > M.fzf_history then break end
if i == 1 or k ~= file_path then
f:write(string.format("%s\n", k))
end
@@ -43,8 +54,8 @@ end
vis.events.subscribe(vis.events.WIN_OPEN, write_mru)
vis:command_register("fzfmru", function(argv)
- local command = "cat " .. module.fzfmru_filepath .. " | " ..
- module.fzfmru_path .. " " .. module.fzfmru_args .. " " ..
+ local command = "cat " .. M.fzf_filepath .. " | " ..
+ M.fzf_path .. " " .. M.fzf_args .. " " ..
table.concat(argv, " ")
local file = io.popen(command)
@@ -72,4 +83,4 @@ vis:command_register("fzfmru", function(argv)
return true
end)
-return module
+return M
diff --git a/config/essentials/vis/fzf-open.lua b/config/essentials/vis/fzf-open.lua
index 1c9d1e6..ff4f694 100644
--- a/config/essentials/vis/fzf-open.lua
+++ b/config/essentials/vis/fzf-open.lua
@@ -1,3 +1,12 @@
+--[[
+Based on https://git.cepl.eu/cgit/vis/vis-fzf-open
+Changes made:
+- stylua
+- height argument
+- module renamed to M
+- ignore exit code 130
+--]]
+
-- Copyright (C) 2017 Guillaume Chérel
-- Copyright (C) 2023 Matěj Cepl
--
diff --git a/config/essentials/vis/themes/nord.lua b/config/essentials/vis/themes/nord.lua
index 71635cf..b43a1d3 100644
--- a/config/essentials/vis/themes/nord.lua
+++ b/config/essentials/vis/themes/nord.lua
@@ -4,80 +4,80 @@
local lexers = vis.lexers
local colors = {
- ['bg'] = '#2E3440',
- ['black'] = '#3B4252',
- ['light_black'] = '#434C5E',
- ['dark_gray'] = '#4C566A',
- ['gray'] = '#D8DEE9',
- ['light_gray'] = '#616E88',
- ['fg'] = '#E5E9F0',
- ['white'] = '#ECEFF4',
- ['turquoise'] = '#8FBCBB',
- ['light_cyan'] = '#88C0D0',
- ['cyan'] = '#81A1C1',
- ['blue'] = '#5E81AC',
- ['red'] = '#BF616A',
- ['orange'] = '#D08770',
- ['yellow'] = '#EBCB8B',
- ['green'] = '#A3BE8C',
- ['magenta'] = '#B48EAD'
+ ["bg"] = "#2E3440",
+ ["black"] = "#3B4252",
+ ["light_black"] = "#434C5E",
+ ["dark_gray"] = "#4C566A",
+ ["gray"] = "#D8DEE9",
+ ["light_gray"] = "#616E88",
+ ["fg"] = "#E5E9F0",
+ ["white"] = "#ECEFF4",
+ ["turquoise"] = "#8FBCBB",
+ ["light_cyan"] = "#88C0D0",
+ ["cyan"] = "#81A1C1",
+ ["blue"] = "#5E81AC",
+ ["red"] = "#BF616A",
+ ["orange"] = "#D08770",
+ ["yellow"] = "#EBCB8B",
+ ["green"] = "#A3BE8C",
+ ["magenta"] = "#B48EAD",
}
lexers.colors = colors
-local fg = 'fore:' .. colors.fg
-local bg = 'back:' .. colors.bg
+local fg = "fore:" .. colors.fg
+local bg = "back:" .. colors.bg
-lexers.STYLE_DEFAULT = bg .. ',' .. fg
+lexers.STYLE_DEFAULT = bg .. "," .. fg
lexers.STYLE_NOTHING = bg
-lexers.STYLE_CLASS = 'fore:' .. colors.blue
-lexers.STYLE_COMMENT = 'fore:' .. colors.light_gray .. ',italics'
-lexers.STYLE_CONSTANT = 'fore:' .. colors.cyan
-lexers.STYLE_DEFINITION = 'fore:' .. colors.green
-lexers.STYLE_ERROR = 'fore:' .. colors.light_cyan .. ',italics'
-lexers.STYLE_FUNCTION = 'fore:' .. colors.light_cyan .. ',bold'
-lexers.STYLE_HEADING = 'fore:' .. colors.bg .. ',back:' .. colors.yellow
-lexers.STYLE_KEYWORD = 'fore:' .. colors.cyan .. ',bold'
-lexers.STYLE_LABEL = 'fore:' .. colors.blue
-lexers.STYLE_NUMBER = 'fore:' .. colors.magenta
-lexers.STYLE_OPERATOR = 'fore:' .. colors.light_cyan
-lexers.STYLE_REGEX = 'fore:' .. colors.orange
-lexers.STYLE_STRING = 'fore:' .. colors.green
-lexers.STYLE_PREPROCESSOR = 'fore:' .. colors.blue
-lexers.STYLE_TAG = 'fore:' .. colors.blue
-lexers.STYLE_TYPE = 'fore:' .. colors.cyan
-lexers.STYLE_VARIABLE = 'fore:' .. colors.cyan .. ',bold'
-lexers.STYLE_WHITESPACE = 'fore:' .. colors.light_black
-lexers.STYLE_EMBEDDED = 'fore:' .. colors.magenta
-lexers.STYLE_IDENTIFIER = fg .. ',bold'
-
-lexers.STYLE_LINENUMBER = 'fore:' .. colors.light_black .. ',back:' .. colors.bg
-lexers.STYLE_CURSOR = 'fore:' .. colors.bg .. ',back:' .. colors.fg
-lexers.STYLE_CURSOR_PRIMARY = 'fore:' .. colors.bg .. ',back:' .. colors.fg
-lexers.STYLE_CURSOR_LINE = 'back:' .. colors.black
-lexers.STYLE_COLOR_COLUMN = 'back:' .. colors.black
-lexers.STYLE_SELECTION = 'back:' .. colors.light_black
-lexers.STYLE_STATUS = 'fore:' .. colors.gray .. ',back:' .. colors.black
-lexers.STYLE_STATUS_FOCUSED = 'fore:' .. colors.cyan .. ',back:' .. colors.black
+lexers.STYLE_CLASS = "fore:" .. colors.blue
+lexers.STYLE_COMMENT = "fore:" .. colors.light_gray .. ",italics"
+lexers.STYLE_CONSTANT = "fore:" .. colors.cyan
+lexers.STYLE_DEFINITION = "fore:" .. colors.green
+lexers.STYLE_ERROR = "fore:" .. colors.light_cyan .. ",italics"
+lexers.STYLE_FUNCTION = "fore:" .. colors.light_cyan .. ",bold"
+lexers.STYLE_HEADING = "fore:" .. colors.bg .. ",back:" .. colors.yellow
+lexers.STYLE_KEYWORD = "fore:" .. colors.cyan .. ",bold"
+lexers.STYLE_LABEL = "fore:" .. colors.blue
+lexers.STYLE_NUMBER = "fore:" .. colors.magenta
+lexers.STYLE_OPERATOR = "fore:" .. colors.light_cyan
+lexers.STYLE_REGEX = "fore:" .. colors.orange
+lexers.STYLE_STRING = "fore:" .. colors.green
+lexers.STYLE_PREPROCESSOR = "fore:" .. colors.blue
+lexers.STYLE_TAG = "fore:" .. colors.blue
+lexers.STYLE_TYPE = "fore:" .. colors.cyan
+lexers.STYLE_VARIABLE = "fore:" .. colors.cyan .. ",bold"
+lexers.STYLE_WHITESPACE = "fore:" .. colors.light_black
+lexers.STYLE_EMBEDDED = "fore:" .. colors.magenta
+lexers.STYLE_IDENTIFIER = fg .. ",bold"
+
+lexers.STYLE_LINENUMBER = "fore:" .. colors.light_black .. ",back:" .. colors.bg
+lexers.STYLE_CURSOR = "fore:" .. colors.bg .. ",back:" .. colors.fg
+lexers.STYLE_CURSOR_PRIMARY = "fore:" .. colors.bg .. ",back:" .. colors.fg
+lexers.STYLE_CURSOR_LINE = "back:" .. colors.black
+lexers.STYLE_COLOR_COLUMN = "back:" .. colors.black
+lexers.STYLE_SELECTION = "back:" .. colors.light_black
+lexers.STYLE_STATUS = "fore:" .. colors.gray .. ",back:" .. colors.black
+lexers.STYLE_STATUS_FOCUSED = "fore:" .. colors.cyan .. ",back:" .. colors.black
lexers.STYLE_SEPARATOR = lexers.STYLE_DEFAULT
-lexers.STYLE_INFO = 'fore:default,back:default,bold'
-lexers.STYLE_EOF = ''
+lexers.STYLE_INFO = "fore:default,back:default,bold"
+lexers.STYLE_EOF = ""
-- lexer specific styles
-- Diff
-lexers.STYLE_ADDITION = 'back:' .. colors.green .. ',fore:' .. colors.bg
-lexers.STYLE_DELETION = 'back:' .. colors.red .. ',fore:' .. colors.bg
-lexers.STYLE_CHANGE = 'back:' .. colors.yellow .. ',fore:' .. colors.bg
+lexers.STYLE_ADDITION = "back:" .. colors.green .. ",fore:" .. colors.bg
+lexers.STYLE_DELETION = "back:" .. colors.red .. ",fore:" .. colors.bg
+lexers.STYLE_CHANGE = "back:" .. colors.yellow .. ",fore:" .. colors.bg
-- CSS
lexers.STYLE_PROPERTY = lexers.STYLE_ATTRIBUTE
-lexers.STYLE_PSEUDOCLASS = ''
-lexers.STYLE_PSEUDOELEMENT = ''
+lexers.STYLE_PSEUDOCLASS = ""
+lexers.STYLE_PSEUDOELEMENT = ""
-- HTML
-lexers.STYLE_TAG_UNKNOWN = lexers.STYLE_TAG .. ',italics'
-lexers.STYLE_ATTRIBUTE_UNKNOWN = lexers.STYLE_ATTRIBUTE .. ',italics'
+lexers.STYLE_TAG_UNKNOWN = lexers.STYLE_TAG .. ",italics"
+lexers.STYLE_ATTRIBUTE_UNKNOWN = lexers.STYLE_ATTRIBUTE .. ",italics"
-- Latex, TeX, and Texinfo
lexers.STYLE_COMMAND = lexers.STYLE_KEYWORD
@@ -86,38 +86,38 @@ lexers.STYLE_ENVIRONMENT = lexers.STYLE_TYPE
lexers.STYLE_ENVIRONMENT_MATH = lexers.STYLE_NUMBER
-- Makefile
-lexers.STYLE_TARGET = ''
+lexers.STYLE_TARGET = ""
-- Markdown
-lexers.STYLE_HR = ''
-lexers.STYLE_HEADING_H1 = 'fore:' .. colors.orange .. ',bold'
-lexers.STYLE_HEADING_H2 = 'fore:' .. colors.red .. ',bold'
+lexers.STYLE_HR = ""
+lexers.STYLE_HEADING_H1 = "fore:" .. colors.orange .. ",bold"
+lexers.STYLE_HEADING_H2 = "fore:" .. colors.red .. ",bold"
for i = 3, 6 do
- lexers['STYLE_HEADING_H' .. i] = 'fore:' .. colors.magenta .. ',bold'
+ lexers["STYLE_HEADING_H" .. i] = "fore:" .. colors.magenta .. ",bold"
end
-lexers.STYLE_BOLD = 'bold'
-lexers.STYLE_ITALIC = 'italics'
+lexers.STYLE_BOLD = "bold"
+lexers.STYLE_ITALIC = "italics"
lexers.STYLE_LIST = lexers.STYLE_KEYWORD
-lexers.STYLE_LINK = 'fore:' .. colors.yellow .. ',italics'
-lexers.STYLE_REFERENCE = 'fore:' .. colors.blue
-lexers.STYLE_CODE = 'back:' .. colors.black .. ',fore:' .. colors.turquoise
+lexers.STYLE_LINK = "fore:" .. colors.yellow .. ",italics"
+lexers.STYLE_REFERENCE = "fore:" .. colors.blue
+lexers.STYLE_CODE = "back:" .. colors.black .. ",fore:" .. colors.turquoise
-- Output
-lexers.STYE_FILENAME = 'bold'
-lexers.STYLE_LINE = 'fore:' .. colors.green
-lexers.STYLE_COLUMN = 'underline'
-lexers.STYLE_MESSAGE = ''
+lexers.STYE_FILENAME = "bold"
+lexers.STYLE_LINE = "fore:" .. colors.green
+lexers.STYLE_COLUMN = "underline"
+lexers.STYLE_MESSAGE = ""
-- Python
-lexers.STYLE_KEYWORD_SOFT = ''
+lexers.STYLE_KEYWORD_SOFT = ""
-- YAML
-lexers.STYLE_ERROR_INDENT = 'back:' .. colors.red
+lexers.STYLE_ERROR_INDENT = "back:" .. colors.red
-- GO
-lexers.STYLE_CONSTANT_BUILTIN = 'fore:' .. colors.yellow
-lexers.STYLE_FUNCTION_METHOD = 'fore:' .. colors.light_cyan
-lexers.STYLE_FUNCTION_BUILTIN = 'fore:' .. colors.light_cyan .. ',bold'
+lexers.STYLE_CONSTANT_BUILTIN = "fore:" .. colors.cyan
+lexers.STYLE_FUNCTION_METHOD = "fore:" .. colors.light_cyan
+lexers.STYLE_FUNCTION_BUILTIN = "fore:" .. colors.light_cyan .. ",bold"
-- Lua
-lexers.STYLE_ATTRIBUTE = 'fore:' .. colors.yellow .. ',bold'
+lexers.STYLE_ATTRIBUTE = "fore:" .. colors.yellow .. ",bold"
diff --git a/config/essentials/vis/title.lua b/config/essentials/vis/title.lua
index d743b63..06a3964 100644
--- a/config/essentials/vis/title.lua
+++ b/config/essentials/vis/title.lua
@@ -1,16 +1,28 @@
-require('vis')
+--[[
+Based on https://github.com/erf/vis-title
+Changes made:
+- stylua
+--]]
+
+require("vis")
local function set_title(title)
- -- print() cannot be used here as it will mess up vis
- vis:command(string.format(":!printf '\\033]2;vis %s\\007'", title))
+ -- print() cannot be used here as it will mess up vis
+ vis:command(string.format(":!printf '\\033]2;vis %s\\007'", title))
end
-vis.events.subscribe(vis.events.INIT, function() print('\27[22;2t') end)
+vis.events.subscribe(vis.events.INIT, function()
+ print("\27[22;2t")
+end)
-vis.events.subscribe(vis.events.WIN_OPEN,
- function(win) set_title(win.file.name or '[No Name]') end)
+vis.events.subscribe(vis.events.WIN_OPEN, function(win)
+ set_title(win.file.name or "[No Name]")
+end)
-vis.events.subscribe(vis.events.FILE_SAVE_POST,
- function(file) set_title(file.name) end)
+vis.events.subscribe(vis.events.FILE_SAVE_POST, function(file)
+ set_title(file.name)
+end)
-vis.events.subscribe(vis.events.QUIT, function() print('\27[23;2t') end)
+vis.events.subscribe(vis.events.QUIT, function()
+ print("\27[23;2t")
+end)
diff --git a/config/essentials/vis/vis-go.lua b/config/essentials/vis/vis-go.lua
index b0b383f..bb0c7ab 100644
--- a/config/essentials/vis/vis-go.lua
+++ b/config/essentials/vis/vis-go.lua
@@ -1,3 +1,13 @@
+--[[
+Based on https://gitlab.com/timoha/vis-go
+Changes made:
+- stylua format
+- check if line, col in godef()
+- no formatting because already handled by format.lua
+- removed the goimports option
+- set env variable for godef that fixes "no definition found"
+--]]
+
local function jump_to(path, line, col)
if path then
vis:command(string.format("e %s", path))
@@ -28,7 +38,7 @@ local function godef()
local file = win.file
local pos = win.selection.pos
- local cmd = string.format("godef -i -o %d", pos)
+ local cmd = string.format("GO111MODULE=off godef -i -o %d", pos)
local status, out, err = vis:pipe(file, { start = 0, finish = file.size }, cmd)
if status ~= 0 or not out then
if err then
@@ -44,7 +54,9 @@ local function godef()
-- same file
line, col = string.match(out, "([^:]+):([^:]+)")
end
- jump_to(path, line, col)
+ if line and col then
+ jump_to(path, line, col)
+ end
end
local function godef_back()
diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua
index e35b436..3bfe594 100644
--- a/config/essentials/vis/visrc.lua
+++ b/config/essentials/vis/visrc.lua
@@ -8,6 +8,7 @@ require("build")
-- use Trash directory instead, remove set_dir function
require("backup")
require("cursors")
+require("ctags")
require("title")
require("commentary")
require("complete-line")
@@ -26,7 +27,6 @@ local format = require("format")
local fzfmru = require("fzf-mru")
fzfmru.fzfmru_path = 'grep "^' .. os.getenv("PWD") .. '" | fzf'
-
-- todo:
-- c-scope
-- c-tags
@@ -52,8 +52,8 @@ local function map_cmd(mode, map, command, help)
end, help)
end
--- TOOD: use window selection to restore position
-local function wrap_restore(f, ...)
+-- Store and pop position with command ran in between
+local function wrap_pos_restore(f, ...)
local pos = vis.win.selection.pos
f(...)
vis.win.selection.pos = pos
@@ -70,7 +70,7 @@ end
-----------------------------------
vis:command_register("make", function()
- vis:command("!make && head -n 1")
+ vis:command("!make; head -n 1")
end, "make")
vis:command_register("Q", function()
vis:command("qa!")
@@ -83,29 +83,27 @@ end, "Remove trailing whitespace")
--- MAPPINGS
-------------------------------------
-vis:map(m.NORMAL, "<C-p>", function() vis:command("fzf") end, "Open file with fzf")
-
-
-vis:map(m.NORMAL, " r", function()
- wrap_restore(vis.command, vis, "e $vis_filepath")
-end, "Reload active file")
-
-vis:map(m.NORMAL, "=", format.apply, "Format active file")
-
-map_cmd(m.NORMAL, " c", "e ~/.config/vis/visrc.lua", "Edit config file")
-map_cmd(m.NORMAL, " q", "q!", "Quit (force)")
-map_cmd(m.NORMAL, " s", "!doas vis $vis_filepath", "Edit as superuser")
-map_cmd(m.NORMAL, " w", "w", "Write")
-map_cmd(m.NORMAL, " x", "!chmod u+x $vis_filepath", "Make active file executable")
-
-vis:map(m.NORMAL, " eh", function()
- vis:command("!lowdown $vis_filepath > ${vis_filepath%.md}.html")
- vis:info("exported.")
-end, "Export markdown to html")
-
-map_keys(m.NORMAL, " nl", ":<seq -f '%0.0f. ' 1 ", "Insert numbered list")
-
--- select markdown list element: ,x/^(\d+\.|[-*])\s+.+\n(^ .+\n)*/
+vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args
+ map_cmd(m.NORMAL, " pf", "fzf", "Open file with fzf")
+ map_cmd(m.NORMAL, " pr", "fzfmru", "Open file with fzf")
+
+ vis:map(m.NORMAL, " r", function()
+ wrap_pos_restore(vis.command, vis, "e $vis_filepath")
+ end, "Reload active file")
+ vis:map(m.NORMAL, "=", format.apply, "Format active file")
+ map_cmd(m.NORMAL, "<M-m>", "make", "Run 'make'")
+ map_cmd(m.NORMAL, " c", "e ~/.config/vis/visrc.lua", "Edit config file")
+ map_cmd(m.NORMAL, " q", "q!", "Quit (force)")
+ map_cmd(m.NORMAL, " s", "!doas vis $vis_filepath", "Edit as superuser")
+ map_cmd(m.NORMAL, " w", "w", "Write")
+ map_cmd(m.NORMAL, " x", "!chmod u+x $vis_filepath", "Make active file executable")
+ map_cmd(m.NORMAL, "!", "!bash", "Run bash")
+ map_keys(m.NORMAL, " y", '"+y', "Copy to system clipboard")
+ map_keys(m.VISUAL, " y", '"+y', "Copy to system clipboard")
+ map_keys(m.NORMAL, " nl", ":<seq -f '%0.0f. ' 1 ", "Insert numbered list")
+ map_keys(m.NORMAL, "<M-S-Down>", "ddp", "Move line down")
+ map_keys(m.NORMAL, "<M-S-Up>", "ddkP", "Move line up") -- Doesn't work at end of file
+end)
------------------------------------
--- EVENTS
@@ -120,33 +118,56 @@ vis.events.subscribe(vis.events.INIT, function()
end)
vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args
+ -- automatically cd in parent dir of file
+ vis:command_register("cdp", function()
+ if win.file and win.file.path then
+ local dir = win.file.path:match(".*/")
+ vis:command("cd " .. dir)
+ end
+ end, "Cd to parent dir of file")
+
win.options.relativenumbers = true
+ if win.syntax then
+ vis:info(win.syntax)
+ end
+
+ -- FILETYPE OPTIONS
if win.syntax == "bash" then
map_keys(
m.NORMAL,
- ";p",
+ "\\p",
"V:x/^(\\s*)(.+)$/ c/\\1>\\&2 printf '\\2: %s\\\\n' \"$\\2\"/<Enter><Escape>",
"Print variable"
)
+ map_keys(m.NORMAL, "\\v", 'V:x/^(\\s*)(.+)$/ c/\\1"$(\\2)"/<Enter><Escape>', "Surround in variable")
+ map_keys(m.NORMAL, "\\|", "V:x/\\| / c/|\n\t/<Enter><Escape>", "Wrap one-line multi pipe command")
map_keys(
m.NORMAL,
- ";v",
- "V:x/^(\\s*)(.+)$/ c/\\1\"$(\\2)\"/<Enter><Escape>",
- "Surround in variable"
- )
- map_keys(
- m.NORMAL,
- ";|",
- "V:x/\\| / c/|\n\t/<Enter><Escape>",
- "Wrap one-line multi pipe command"
- )
- map_keys(
- m.NORMAL,
- ";e",
- "V:x/^(\\s*)(.+)$/ c/\\1[ \"\\2\" ] || exit 1/<Enter><Escape>",
+ "\\e",
+ 'V:x/^(\\s*)(.+)$/ c/\\1[ "\\2" ] || exit 1/<Enter><Escape>',
"Condition exit if empty"
)
+ map_cmd(m.NORMAL, "\\sc", "-/\\<case\\>/,/\\<esac\\>/", "Expand to case")
+ map_cmd(m.NORMAL, "\\sw", "-/\\<while/,/\\<done\\>/", "Expand to while")
+ map_cmd(m.NORMAL, "\\sf", "-/\\<for\\>/,/\\<done\\>/", "Expand to for")
+ map_cmd(m.NORMAL, "\\si", "-/\\<if\\>/,/\\<fi\\>/", "Expand to if")
+ end
+
+ if win.syntax == "markdown" then
+ vis:map(m.NORMAL, "\\h", function()
+ vis:command("!lowdown $vis_filepath > ${vis_filepath%.md}.html")
+ vis:info("exported.")
+ end, "Export markdown to html")
+ map_cmd(m.NORMAL, "\\sl", "-+x/(\\d+|[-*])\\s+.+\n/", "Expand to list item")
+ map_cmd(m.NORMAL, "\\sh", "-/^#+/,/^#+/-", "Expand to header")
+ -- select header block by name
+ -- ,x/^# Planning\n([^#]|\n)+
+ win.options.tabwidth = 2
+ win.options.expandtab = true
+ end
+ if win.syntax == "ansi_c" then
+ map_keys(m.NORMAL, "\\a", "f,a <Escape>hdw<S-Tab>i<Tab><Escape>", "Align table")
end
end)
diff --git a/config/essentials/zsh/.gitignore b/config/essentials/zsh/.gitignore
index a13c79f..524b20e 100644
--- a/config/essentials/zsh/.gitignore
+++ b/config/essentials/zsh/.gitignore
@@ -1,3 +1,3 @@
histfile
-zcompcache
+zcompcache*
.zcompdump
diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc
index a38a359..878f04d 100644
--- a/config/essentials/zsh/.zshrc
+++ b/config/essentials/zsh/.zshrc
@@ -40,11 +40,10 @@ then
plug "zdharma-continuum/fast-syntax-highlighting"
plug "zsh-users/zsh-autosuggestions"
plug "zsh-users/zsh-completions"
-
plug "MichaelAquilina/zsh-auto-notify"
export AUTO_NOTIFY_TITLE="zsh"
export AUTO_NOTIFY_BODY="%command [%exit_code]"
- AUTO_NOTIFY_IGNORE+=("gurk" "ttyper" "pulsemixer" "tmux" "btop" "vis" "clock")
+ AUTO_NOTIFY_IGNORE+=("abduco" "gurk" "ttyper" "pulsemixer" "tmux" "btop" "vis" "clock")
fi
# Substring search settings
@@ -116,6 +115,13 @@ add-zsh-hook -Uz precmd set_wt (){ print -Pn "\e]0;%n@%m on %~\a"; }
## automatic ls after cd
add-zsh-hook -Uz chpwd (){ [ "$PWD" = "$HOME" ] || ls -A; }
+bottom_margin() {
+ TBUFFER="$BUFFER"
+ BUFFER="\n\n\n"
+ BUFFER="\n\n\n $TBUFFER"
+}
+add-zsh-hook -Uz precmd bottom_margin
+
### Variables
## Run menuscripts with fzf
export MENUCMD='fzf'
diff --git a/config/essentials/zsh/widgets.zsh b/config/essentials/zsh/widgets.zsh
index 233ea65..cce9fbc 100644
--- a/config/essentials/zsh/widgets.zsh
+++ b/config/essentials/zsh/widgets.zsh
@@ -1,8 +1,7 @@
# Surround line in variable
-surround_in_var()
-{
- BUFFER=" \"\$($BUFFER)\""
- zle beginning-of-line
+surround_in_var() {
+ BUFFER=" \"\$($BUFFER)\""
+ zle beginning-of-line
}
zle -N surround_in_var
bindkey '\ev' surround_in_var
@@ -10,9 +9,7 @@ bindkey '\ev' surround_in_var
# Insert output from the previous command
zmodload -i zsh/parameter
insert-last-command-output() {
- LBUFFER+="$(eval $history[$((HISTCMD-1))])"
+ LBUFFER+="$(eval $history[$((HISTCMD - 1))])"
}
zle -N insert-last-command-output
bindkey "^Xl" insert-last-command-output
-
-#
diff --git a/config/home/.bashrc b/config/home/.bashrc
index 312500d..149270c 100644
--- a/config/home/.bashrc
+++ b/config/home/.bashrc
@@ -1,12 +1,13 @@
SHELL=/bin/bash
PATH=$HOME/bin:$PATH
-color1="\[\033[35m\]"
-color2="\[\033[36m\]"
-color3="\[\033[40m\]"
-color4="\[\033[38m\]"
-bold="\[\033[1m\]"
-reset="\[\033[0m\]"
-PS1="${color1}${bold} ${color3}\\u${reset}${color3}${color4}@${color2}${bold}\\h${reset}${color3} \\w${reset} "
+# color1="\[\033[35m\]"
+# color2="\[\033[36m\]"
+# color3="\[\033[40m\]"
+# color4="\[\033[38m\]"
+# bold="\[\033[1m\]"
+# reset="\[\033[0m\]"
+# PS1="${color1}${bold} ${color3}\\u${reset}${color3}${color4}@${color2}${bold}\\h${reset}${color3} \\w${reset} "
+PS1='$ '
HISTFILE=
. $HOME/.config/shell/aliases.sh
. $HOME/.config/shell/functions.sh
diff --git a/config/home/.mbsyncrc b/config/home/.mbsyncrc
new file mode 100644
index 0000000..aa8c521
--- /dev/null
+++ b/config/home/.mbsyncrc
@@ -0,0 +1,50 @@
+
+IMAPStore luca@spacehb.net-remote
+Host mail.spacehb.net
+Port 993
+User luca@spacehb.net
+PassCmd "pass websites/spacehb.net/luca@spacehb.net"
+AuthMechs LOGIN
+SSLType IMAPS
+CertificateFile /etc/ssl/certs/ca-certificates.crt
+
+MaildirStore luca@spacehb.net-local
+Subfolders Verbatim
+Path /home/aluc/.local/share/mail/luca@spacehb.net/
+Inbox /home/aluc/.local/share/mail/luca@spacehb.net/INBOX
+
+Channel luca@spacehb.net
+Expunge Both
+Far :luca@spacehb.net-remote:
+Near :luca@spacehb.net-local:
+Patterns * !"[Gmail]/All Mail" !"*fts-flatcurve*" !"*virtual*"
+Create Both
+SyncState *
+MaxMessages 0
+ExpireUnread no
+# End profile
+
+IMAPStore billy@spacehb.net-remote
+Host mail.spacehb.net
+Port 993
+User billy@spacehb.net
+PassCmd "pass websites/spacehb.net/billy@spacehb.net"
+AuthMechs LOGIN
+SSLType IMAPS
+CertificateFile /etc/ssl/certs/ca-certificates.crt
+
+MaildirStore billy@spacehb.net-local
+Subfolders Verbatim
+Path /home/aluc/.local/share/mail/billy@spacehb.net/
+Inbox /home/aluc/.local/share/mail/billy@spacehb.net/INBOX
+
+Channel billy@spacehb.net
+Expunge Both
+Far :billy@spacehb.net-remote:
+Near :billy@spacehb.net-local:
+Patterns * !"[Gmail]/All Mail" !"*fts-flatcurve*" !"*virtual*"
+Create Both
+SyncState *
+MaxMessages 0
+ExpireUnread no
+# End profile