diff options
64 files changed, 7368 insertions, 0 deletions
diff --git a/.config/aerospace/aerospace.toml b/.config/aerospace/aerospace.toml new file mode 100644 index 0000000..c5ac71c --- /dev/null +++ b/.config/aerospace/aerospace.toml @@ -0,0 +1,183 @@ +# Place a copy of this config to ~/.aerospace.toml +# After that, you can edit ~/.aerospace.toml to your liking + +# You can use it to add commands that run after login to macOS user session. +# 'start-at-login' needs to be 'true' for 'after-login-command' to work +# Available commands: https://nikitabobko.github.io/AeroSpace/commands +after-login-command = [] + +# You can use it to add commands that run after AeroSpace startup. +# 'after-startup-command' is run after 'after-login-command' +# Available commands : https://nikitabobko.github.io/AeroSpace/commands +after-startup-command = [] + +# Start AeroSpace at login +start-at-login = true + +# Normalizations. See: https://nikitabobko.github.io/AeroSpace/guide#normalization +enable-normalization-flatten-containers = true +enable-normalization-opposite-orientation-for-nested-containers = true + +# See: https://nikitabobko.github.io/AeroSpace/guide#layouts +# The 'accordion-padding' specifies the size of accordion padding +# You can set 0 to disable the padding feature +accordion-padding = 100 + +# Possible values: tiles|accordion +default-root-container-layout = 'accordion' + +# Possible values: horizontal|vertical|auto +# 'auto' means: wide monitor (anything wider than high) gets horizontal orientation, +# tall monitor (anything higher than wide) gets vertical orientation +default-root-container-orientation = 'auto' + +# Mouse follows focus when focused monitor changes +# Drop it from your config, if you don't like this behavior +# See https://nikitabobko.github.io/AeroSpace/guide#on-focus-changed-callbacks +# See https://nikitabobko.github.io/AeroSpace/commands#move-mouse +# Fallback value (if you omit the key): on-focused-monitor-changed = [] +on-focused-monitor-changed = ['move-mouse monitor-lazy-center'] + +# You can effectively turn off macOS "Hide application" (cmd-h) feature by toggling this flag +# Useful if you don't use this macOS feature, but accidentally hit cmd-h or cmd-alt-h key +# Also see: https://nikitabobko.github.io/AeroSpace/goodies#disable-hide-app +automatically-unhide-macos-hidden-apps = false + +# Possible values: (qwerty|dvorak) +# See https://nikitabobko.github.io/AeroSpace/guide#key-mapping +[key-mapping] + preset = 'qwerty' + +# Gaps between windows (inner-*) and between monitor edges (outer-*). +# Possible values: +# - Constant: gaps.outer.top = 8 +# - Per monitor: gaps.outer.top = [{ monitor.main = 16 }, { monitor."some-pattern" = 32 }, 24] +# In this example, 24 is a default value when there is no match. +# Monitor pattern is the same as for 'workspace-to-monitor-force-assignment'. +# See: +# https://nikitabobko.github.io/AeroSpace/guide#assign-workspaces-to-monitors +[gaps] + inner.horizontal = 0 + inner.vertical = 0 + outer.left = 0 + outer.bottom = 0 + outer.top = 0 + outer.right = 0 + +# 'main' binding mode declaration +# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes +# 'main' binding mode must be always presented +# Fallback value (if you omit the key): mode.main.binding = {} +[mode.main.binding] + + # All possible keys: + # - Letters. a, b, c, ..., z + # - Numbers. 0, 1, 2, ..., 9 + # - Keypad numbers. keypad0, keypad1, keypad2, ..., keypad9 + # - F-keys. f1, f2, ..., f20 + # - Special keys. minus, equal, period, comma, slash, backslash, quote, semicolon, + # backtick, leftSquareBracket, rightSquareBracket, space, enter, esc, + # backspace, tab + # - Keypad special. keypadClear, keypadDecimalMark, keypadDivide, keypadEnter, keypadEqual, + # keypadMinus, keypadMultiply, keypadPlus + # - Arrows. left, down, up, right + + # All possible modifiers: cmd, alt, ctrl, shift + + # All possible commands: https://nikitabobko.github.io/AeroSpace/commands + + # See: https://nikitabobko.github.io/AeroSpace/commands#exec-and-forget + # You can uncomment the following lines to open up terminal with alt + enter shortcut + # (like in i3) + cmd-shift-d = 'exec-and-forget source /etc/profile; PATH="$HOME/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" passmenu' + cmd-f = 'fullscreen' + cmd-d = 'exec-and-forget source /etc/profile; PATH="$HOME/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" dmenu' + cmd-enter = '''exec-and-forget osascript -e ' + tell application "System Events" + if exists application process "Ghostty" then + tell application process "Ghostty" + click menu item "New Window" of menu "File" of menu bar 1 + end tell + else + tell application "Ghostty" to activate + end if + end tell' + ''' + + cmd-w = '''exec-and-forget osascript -e ' + tell application "System Events" + if exists application process "Google Chrome" then + tell application process "Google Chrome" + click menu item "New Window" of menu "File" of menu bar 1 + end tell + else + tell application "Google Chrome" to activate + end if + end tell' + ''' + + # See: https://nikitabobko.github.io/AeroSpace/commands#layout + cmd-slash = 'layout tiles horizontal vertical' + cmd-comma = 'layout accordion horizontal vertical' + + # See: https://nikitabobko.github.io/AeroSpace/commands#focus + cmd-j = 'focus right' + cmd-k = 'focus left' + + # See: https://nikitabobko.github.io/AeroSpace/commands#move + cmd-shift-j = 'move right' + cmd-shift-k = 'move left' + + # See: https://nikitabobko.github.io/AeroSpace/commands#resize + cmd-minus = 'resize smart -50' + cmd-equal = 'resize smart +50' + + # See: https://nikitabobko.github.io/AeroSpace/commands#workspace + cmd-1 = 'workspace 1' + cmd-2 = 'workspace 2' + cmd-3 = 'workspace 3' + cmd-4 = 'workspace 4' + cmd-5 = 'workspace 5' + cmd-6 = 'workspace 6' + cmd-7 = 'workspace 7' + cmd-8 = 'workspace 8' + cmd-9 = 'workspace 9' + + # See: https://nikitabobko.github.io/AeroSpace/commands#move-node-to-workspace + cmd-shift-1 = 'move-node-to-workspace 1' + cmd-shift-2 = 'move-node-to-workspace 2' + cmd-shift-3 = 'move-node-to-workspace 3' + cmd-shift-4 = 'move-node-to-workspace 4' + cmd-shift-5 = 'move-node-to-workspace 5' + cmd-shift-6 = 'move-node-to-workspace 6' + cmd-shift-7 = 'move-node-to-workspace 7' + cmd-shift-8 = 'move-node-to-workspace 8' + cmd-shift-9 = 'move-node-to-workspace 9' + + # See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth + cmd-semicolon = 'workspace-back-and-forth' + # See: https://nikitabobko.github.io/AeroSpace/commands#move-workspace-to-monitor + cmd-period = 'move-workspace-to-monitor --wrap-around next' + + # See: https://nikitabobko.github.io/AeroSpace/commands#mode + cmd-shift-semicolon = 'mode service' + +# 'service' binding mode declaration. +# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes +[mode.service.binding] + esc = ['reload-config', 'mode main'] + r = ['flatten-workspace-tree', 'mode main'] # reset layout + f = ['layout floating tiling', 'mode main'] # Toggle between floating and tiling layout + backspace = ['close-all-windows-but-current', 'mode main'] + + # sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2 + #s = ['layout sticky tiling', 'mode main'] + + alt-shift-h = ['join-with left', 'mode main'] + alt-shift-j = ['join-with down', 'mode main'] + alt-shift-k = ['join-with up', 'mode main'] + alt-shift-l = ['join-with right', 'mode main'] + + down = 'volume down' + up = 'volume up' + shift-down = ['volume set 0', 'mode main'] diff --git a/.config/carapace/specs/bluegreen.yaml b/.config/carapace/specs/bluegreen.yaml new file mode 100644 index 0000000..6b3d4f1 --- /dev/null +++ b/.config/carapace/specs/bluegreen.yaml @@ -0,0 +1,7 @@ +# yaml-language-server: $schema=https://carapace.sh/schemas/command.json +name: bluegreen +description: Bluegreen +parsing: disabled +completion: + positionalany: ["$carapace.bridge.Click([bluegreen])"] + diff --git a/.config/carapace/specs/pioctl.yaml b/.config/carapace/specs/pioctl.yaml new file mode 100644 index 0000000..0092804 --- /dev/null +++ b/.config/carapace/specs/pioctl.yaml @@ -0,0 +1,7 @@ +# yaml-language-server: $schema=https://carapace.sh/schemas/command.json +name: pioctl +description: Pioctl +parsing: disabled +completion: + positionalany: ["$carapace.bridge.Click([pioctl])"] + diff --git a/.config/carapace/specs/pistarchio.yaml b/.config/carapace/specs/pistarchio.yaml new file mode 100644 index 0000000..cc9738c --- /dev/null +++ b/.config/carapace/specs/pistarchio.yaml @@ -0,0 +1,5 @@ +name: pistarchio +description: pistarchio +parsing: disabled +completion: + positionalany: ["$carapace.bridge.Carapace([pistarchio])"] diff --git a/.config/carapace/specs/upctl.yaml b/.config/carapace/specs/upctl.yaml new file mode 100644 index 0000000..7574e24 --- /dev/null +++ b/.config/carapace/specs/upctl.yaml @@ -0,0 +1,5 @@ +name: upctl +description: upctl +parsing: disabled +completion: + positionalany: ["$carapace.bridge.Cobra([upctl])"] diff --git a/.config/emacs/init.el b/.config/emacs/init.el new file mode 100644 index 0000000..52de580 --- /dev/null +++ b/.config/emacs/init.el @@ -0,0 +1,181 @@ +;; do autoload stuff here +(package-initialize) +(require 'package) +(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t) + +(defun seq-keep (function sequence) + "Apply FUNCTION to SEQUENCE and return the list of all the non-nil results." + (delq nil (seq-map function sequence))) + +(defvar rc/package-contents-refreshed nil) + +(defun rc/package-refresh-contents-once () + (when (not rc/package-contents-refreshed) + (setq rc/package-contents-refreshed t) + (package-refresh-contents))) + +(defun rc/require-one-package (package) + (when (not (package-installed-p package)) + (rc/package-refresh-contents-once) + (package-install package))) + +(defun rc/require (&rest packages) + (dolist (package packages) + (rc/require-one-package package))) + +(defun rc/require-theme (theme) + (let ((theme-package (->> theme + (symbol-name) + (funcall (-flip #'concat) "-theme") + (intern)))) + (rc/require theme-package) + (load-theme theme t))) + + +(rc/require 'dash) +(require 'dash) +(rc/require 'dash-functional) +(require 'dash-functional) + +(defun rc/get-default-font () + (cond + ((eq system-type 'windows-nt) "Consolas-13") + (t "mono-13"))) +(add-to-list 'default-frame-alist `(font . ,(rc/get-default-font))) +(rc/require 'ansi-color) + +(rc/require 'ido 'ido-completing-read+ 'smex 'corfu) +(ido-mode t) +(ido-everywhere t) +(ido-ubiquitous-mode t) +(global-corfu-mode) + +(global-set-key (kbd "M-x") 'smex) +(global-set-key (kbd "M-X") 'smex-major-mode-commands) +;; This is your old M-x. p +(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command) + +(tool-bar-mode 0) +(menu-bar-mode 0) +(scroll-bar-mode 0) +(column-number-mode 1) +(show-paren-mode 1) + +(setq-default inhibit-splash-screen t + make-backup-files nil + tab-width 4 + indent-tabs-mode nil + compilation-scroll-output t + visible-bell (equal system-type 'windows-nt)) + +(setq-default c-basic-offset 4 + c-default-style '((java-mode . "java") + (awk-mode . "awk") + (other . "bsd"))) +(setq split-width-threshold 9999) + +(defun rc/duplicate-line () + "Duplicate current line" + (interactive) + (let ((column (- (point) (point-at-bol))) + (line (let ((s (thing-at-point 'line t))) + (if s (string-remove-suffix "\n" s) "")))) + (move-end-of-line 1) + (newline) + (insert line) + (move-beginning-of-line 1) + (forward-char column))) + +(global-set-key (kbd "M-J") 'text-scale-decrease) +(global-set-key (kbd "M-K") 'text-scale-increase) + +(global-set-key (kbd "M-c") 'rc/duplicate-line) +(global-set-key (kbd "C-c p") 'find-file-at-point) +(global-display-line-numbers-mode) +(setq next-line-add-newlines t) +(setq display-line-numbers-type 'relative) + +(rc/require 'direnv 'editorconfig 'multiple-cursors) +(editorconfig-mode 1) +(electric-pair-mode) +(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines) +(global-set-key (kbd "C->") 'mc/mark-next-like-this) +(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) +(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this) +(global-set-key (kbd "C-.") 'mc/mark-all-in-region) + +(rc/require 'cl-lib 'magit) +(setq magit-auto-revert-mode nil) +(global-set-key (kbd "C-c m s") 'magit-status) +(global-set-key (kbd "C-c m l") 'magit-log) + +(require 'dired-x) +(setq dired-omit-files + (concat dired-omit-files "\\|^\\..+$")) +(setq-default dired-dwim-target t) +(setq dired-listing-switches "-alh") + +;; stolen from: https://emacs.stackexchange.com/questions/24698/ansi-escape-sequences-in-compilation-mode +(rc/require 'ansi-color) +(defun endless/colorize-compilation () + "Colorize from `compilation-filter-start' to `point'." + (let ((inhibit-read-only t)) + (ansi-color-apply-on-region + compilation-filter-start (point)))) +(add-hook 'compilation-filter-hook + #'endless/colorize-compilation) + +(setq TeX-auto-save t) +(setq TeX-parse-self t) +(setq-default TeX-master nil) + +(setq completion-auto-select 'second-tab) +(setq completions-format 'one-column) +(setq completions-max-height 20) +(define-key completion-in-region-mode-map (kbd "M-p") #'minibuffer-previous-completion) +(define-key completion-in-region-mode-map (kbd "M-n") #'minibuffer-next-completion) +;; (rc/require 'consult 'vertico 'orderless) +;; (setq completion-in-region-function #'completion--) + + +(rc/require + 'nix-mode + 'go-mode + 'auctex + 'yaml-pro + 'rust-mode) + + +(require 'lsp-mode) +(add-hook 'rust-mode-hook #'lsp-deferred) +(add-hook 'go-mode-hook #'lsp-deferred) +(defun lsp-go-install-save-hooks () + (add-hook 'before-save-hook #'lsp-format-buffer t t) + (add-hook 'before-save-hook #'lsp-organize-imports t t)) +(add-hook 'go-mode-hook #'lsp-go-install-save-hooks) +(lsp-register-custom-settings + '(("gopls.hints.assignVariableTypes" t t) + ("gopls.hints.compositeLiteralFields" t t) + ("gopls.hints.compositeLiteralTypes" t t) + ("gopls.hints.constantValues" t t) + ("gopls.hints.functionTypeParameters" t t) + ("gopls.hints.parameterNames" t t) + ("gopls.hints.rangeVariableTypes" t t))) + +(rc/require-theme 'gruber-darker) +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(custom-enabled-themes '(gruber-darker)) + '(custom-safe-themes + '("ba4ab079778624e2eadbdc5d9345e6ada531dc3febeb24d257e6d31d5ed02577" "a9dc7790550dcdb88a23d9f81cc0333490529a20e160a8599a6ceaf1104192b5" "5f128efd37c6a87cd4ad8e8b7f2afaba425425524a68133ac0efd87291d05874" "5b9a45080feaedc7820894ebbfe4f8251e13b66654ac4394cb416fef9fdca789" "9013233028d9798f901e5e8efb31841c24c12444d3b6e92580080505d56fd392" "6adeb971e4d5fe32bee0d5b1302bc0dfd70d4b42bad61e1c346599a6dc9569b5" "8d3ef5ff6273f2a552152c7febc40eabca26bae05bd12bc85062e2dc224cde9a" "75b2a02e1e0313742f548d43003fcdc45106553af7283fb5fad74359e07fe0e2" "b9761a2e568bee658e0ff723dd620d844172943eb5ec4053e2b199c59e0bcc22" "9d29a302302cce971d988eb51bd17c1d2be6cd68305710446f658958c0640f68" "f053f92735d6d238461da8512b9c071a5ce3b9d972501f7a5e6682a90bf29725" "dc8285f7f4d86c0aebf1ea4b448842a6868553eded6f71d1de52f3dcbc960039" "38c0c668d8ac3841cb9608522ca116067177c92feeabc6f002a27249976d7434" "162201cf5b5899938cfaec99c8cb35a2f1bf0775fc9ccbf5e63130a1ea217213" "ff24d14f5f7d355f47d53fd016565ed128bf3af30eb7ce8cae307ee4fe7f3fd0" "da75eceab6bea9298e04ce5b4b07349f8c02da305734f7c0c8c6af7b5eaa9738" "e3daa8f18440301f3e54f2093fe15f4fe951986a8628e98dcd781efbec7a46f2" "631c52620e2953e744f2b56d102eae503017047fb43d65ce028e88ef5846ea3b" "88f7ee5594021c60a4a6a1c275614103de8c1435d6d08cc58882f920e0cec65e" "dfb1c8b5bfa040b042b4ef660d0aab48ef2e89ee719a1f24a4629a0c5ed769e8" "e13beeb34b932f309fb2c360a04a460821ca99fe58f69e65557d6c1b10ba18c7" default)) + '(package-selected-packages + '(doom-themes corfu yaml-pro smex rust-mode nix-mode multiple-cursors magit lsp-ui ido-completing-read+ gruber-darker-theme go-mode editorconfig direnv dash-functional auctex))) +(custom-set-faces) + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + diff --git a/.config/ghostty/config b/.config/ghostty/config new file mode 100644 index 0000000..d682f8c --- /dev/null +++ b/.config/ghostty/config @@ -0,0 +1,19 @@ +keybind = alt+k=scroll_page_fractional:-0.4 +keybind = alt+j=scroll_page_fractional:+0.4 +# keybind = alt+b=scroll_page_up +# keybind = alt+f=scroll_page_down +keybind = alt+c=copy_to_clipboard +keybind = alt+v=paste_from_clipboard +keybind = alt+shift+k=increase_font_size:1 +keybind = alt+shift+j=decrease_font_size:1 + +keybind = ctrl+zero=unbind +keybind = ctrl+enter=unbind +theme=GruvboxLuke +window-decoration=false +confirm-close-surface=false +macos-option-as-alt=true + +clipboard-read = allow +clipboard-write = allow +clipboard-paste-protection=false diff --git a/.config/ghostty/themes/GruvboxLuke b/.config/ghostty/themes/GruvboxLuke new file mode 100644 index 0000000..3f09286 --- /dev/null +++ b/.config/ghostty/themes/GruvboxLuke @@ -0,0 +1,23 @@ +palette = 0=#262626 +palette = 1=#d75f5f +palette = 2=#afaf00 +palette = 3=#ffaf00 +palette = 4=#83adad +palette = 5=#d485ad +palette = 6=#85ad85 +palette = 7=#dab997 +palette = 8=#8a8a8a +palette = 9=#d75f5f +palette = 10=#afaf00 +palette = 11=#ffaf00 +palette = 12=#83adad +palette = 13=#d485ad +palette = 14=#85ad85 +palette = 15=#ebdbb2 + +background = #262626 +foreground = #dab997 +cursor-color = #dab997 + +selection-background = #665c54 +selection-foreground = #ebdbb2 diff --git a/.config/git/config b/.config/git/config new file mode 100644 index 0000000..d8d52cb --- /dev/null +++ b/.config/git/config @@ -0,0 +1,24 @@ +[commit] + gpgsign = false + +[gpg] + format = "ssh" + +[merge] + tool = "fugitive" + +[mergetool "fugitive"] + cmd = "vim -f -c \"Gdiff\" \"$MERGED\"" + +[user] + email = "ivi@vinkies.net" + name = "Mike Vink" + signingKey = "/Users/ivi/.ssh/id_ed25519_sk.pub" + +[worktree] + guessRemote = true + +# [includeIf "hasconfig:remote.*.url:git@github.com:**/**"] +# path = "/nix-config/mut/git/github" +# [includeIf "hasconfig:remote.*.url:https://github.com/**/**"] +# path = "/nix-config/mut/git/github" diff --git a/.config/git/github b/.config/git/github new file mode 100644 index 0000000..421194d --- /dev/null +++ b/.config/git/github @@ -0,0 +1,2 @@ +[user] + email = "59492084+ivi-vink@users.noreply.github.com" diff --git a/.config/git/ignore b/.config/git/ignore new file mode 100644 index 0000000..1ea4fc3 --- /dev/null +++ b/.config/git/ignore @@ -0,0 +1,6 @@ +/.direnv/ +/.envrc +/.env +.vimsession.vim +tfplan +plan diff --git a/.config/k9s/aliases.yaml b/.config/k9s/aliases.yaml new file mode 100644 index 0000000..ee4d9ec --- /dev/null +++ b/.config/k9s/aliases.yaml @@ -0,0 +1,9 @@ +aliases: + dp: deployments + sec: v1/secrets + jo: jobs + cr: clusterroles + crb: clusterrolebindings + ro: roles + rb: rolebindings + np: networkpolicies diff --git a/.config/k9s/config.yaml b/.config/k9s/config.yaml new file mode 100644 index 0000000..de5ae68 --- /dev/null +++ b/.config/k9s/config.yaml @@ -0,0 +1,42 @@ +k9s: + portForwardAddress: 0.0.0.0 + liveViewAutoRefresh: false + screenDumpDir: /home/ivi/.local/state/k9s/screen-dumps + refreshRate: 2 + maxConnRetry: 5 + readOnly: false + noExitOnCtrlC: false + ui: + enableMouse: false + headless: true + logoless: true + crumbsless: false + reactive: true + noIcons: false + skin: gruvbox + skipLatestRevCheck: false + disablePodCounting: false + shellPod: + image: busybox:1.35.0 + namespace: default + limits: + cpu: 100m + memory: 100Mi + imageScans: + enable: false + exclusions: + namespaces: [] + labels: {} + logger: + tail: 100 + buffer: 5000 + sinceSeconds: -1 + textWrap: false + showTime: false + thresholds: + cpu: + critical: 90 + warn: 70 + memory: + critical: 90 + warn: 70 diff --git a/.config/k9s/skins/gruvbox.yaml b/.config/k9s/skins/gruvbox.yaml new file mode 100644 index 0000000..d3bd8e4 --- /dev/null +++ b/.config/k9s/skins/gruvbox.yaml @@ -0,0 +1,105 @@ +# ----------------------------------------------------------------------------- +# K9s Gruvbox Dark Skin +# Author: [@indiebrain](https://github.com/indiebrain) +# ----------------------------------------------------------------------------- + +# Styles... +foreground: &foreground "#ebdbb2" +background: &background "#272727" +current_line: ¤t_line "#ebdbb2" +selection: &selection "#3c3735" +comment: &comment "#bdad93" +cyan: &cyan "#689d69" +green: &green "#989719" +orange: &orange "#d79920" +magenta: &magenta "#b16185" +blue: &blue "#448488" +red: &red "#cc231c" + +k9s: + body: + fgColor: *foreground + bgColor: *background + logoColor: *blue + prompt: + fgColor: *foreground + bgColor: *background + suggestColor: *orange + info: + fgColor: *magenta + sectionColor: *foreground + help: + fgColor: *foreground + bgColor: *background + keyColor: *magenta + numKeyColor: *blue + sectionColor: *green + dialog: + fgColor: *foreground + bgColor: *background + buttonFgColor: *foreground + buttonBgColor: *magenta + buttonFocusFgColor: white + buttonFocusBgColor: *cyan + labelFgColor: *orange + fieldFgColor: *foreground + frame: + border: + fgColor: *selection + focusColor: *current_line + menu: + fgColor: *foreground + keyColor: *magenta + numKeyColor: *magenta + crumbs: + fgColor: *foreground + bgColor: *comment + activeColor: *blue + status: + newColor: *cyan + modifyColor: *blue + addColor: *green + errorColor: *red + highlightColor: *orange + killColor: *comment + completedColor: *comment + title: + fgColor: *foreground + bgColor: *background + highlightColor: *orange + counterColor: *blue + filterColor: *magenta + views: + charts: + bgColor: background + defaultDialColors: + - *blue + - *red + defaultChartColors: + - *blue + - *red + table: + fgColor: *foreground + bgColor: *background + cursorFgColor: "#fff" + cursorBgColor: *current_line + header: + fgColor: *foreground + bgColor: *background + sorterColor: *selection + xray: + fgColor: *foreground + bgColor: *background + cursorColor: *current_line + graphicColor: *blue + showIcons: false + yaml: + keyColor: *magenta + colonColor: *blue + valueColor: *foreground + logs: + fgColor: *foreground + bgColor: *background + indicator: + fgColor: *foreground + bgColor: *background diff --git a/.config/lf/cleaner b/.config/lf/cleaner new file mode 100755 index 0000000..9513d38 --- /dev/null +++ b/.config/lf/cleaner @@ -0,0 +1,6 @@ +#!/bin/sh +if [ -n "$FIFO_UEBERZUG" ]; then + printf '{"action": "remove", "identifier": "PREVIEW"}\n' > "$FIFO_UEBERZUG" +else + exec kitten icat --clear --stdin no --transfer-mode file < /dev/null > /dev/tty +fi diff --git a/.config/lf/icons b/.config/lf/icons new file mode 100644 index 0000000..aad068c --- /dev/null +++ b/.config/lf/icons @@ -0,0 +1,77 @@ +di 📁 +fi 📃 +tw 🤝 +ow 📂 +ln ⛓ +or ❌ +ex 🎯 +*.txt ✍ +*.mom ✍ +*.me ✍ +*.ms ✍ +*.avif 🖼 +*.png 🖼 +*.webp 🖼 +*.ico 🖼 +*.jpg 📸 +*.jpe 📸 +*.jpeg 📸 +*.gif 🖼 +*.svg 🗺 +*.tif 🖼 +*.tiff 🖼 +*.xcf 🖌 +*.html 🌎 +*.xml 📰 +*.gpg 🔒 +*.css 🎨 +*.pdf 📚 +*.djvu 📚 +*.epub 📚 +*.csv 📓 +*.xlsx 📓 +*.tex 📜 +*.md 📘 +*.r 📊 +*.R 📊 +*.rmd 📊 +*.Rmd 📊 +*.m 📊 +*.mp3 🎵 +*.opus 🎵 +*.ogg 🎵 +*.m4a 🎵 +*.flac 🎼 +*.wav 🎼 +*.mkv 🎥 +*.mp4 🎥 +*.webm 🎥 +*.mpeg 🎥 +*.avi 🎥 +*.mov 🎥 +*.mpg 🎥 +*.wmv 🎥 +*.m4b 🎥 +*.flv 🎥 +*.zip 📦 +*.rar 📦 +*.7z 📦 +*.tar 📦 +*.z64 🎮 +*.v64 🎮 +*.n64 🎮 +*.gba 🎮 +*.nes 🎮 +*.gdi 🎮 +*.1 ℹ +*.nfo ℹ +*.info ℹ +*.log 📙 +*.iso 📀 +*.img 📀 +*.bib 🎓 +*.ged 👪 +*.part 💔 +*.torrent 🔽 +*.jar ♨ +*.java ♨ diff --git a/.config/lf/lfrc b/.config/lf/lfrc new file mode 100644 index 0000000..e34d8c3 --- /dev/null +++ b/.config/lf/lfrc @@ -0,0 +1,188 @@ +# Luke's lf settings + + +# Note on Image Previews +# For those wanting image previews, like this system, there are four steps to +# set it up. These are done automatically for LARBS users, but I will state +# them here for others doing it manually. +# +# 1. ueberzug must be installed. +# 2. The scope file (~/.config/lf/scope for me), must have a command similar to +# mine to generate ueberzug images. +# 3. A `set cleaner` line as below is a cleaner script. +# 4. lf should be started through a wrapper script (~/.local/bin/lfub for me) +# that creates the environment for ueberzug. This command can be be aliased +# in your shellrc (`alias lf="lfub") or if set to a binding, should be +# called directly instead of normal lf. + +# Basic vars +set shellopts '-eu' +set ifs "\n" +set scrolloff 10 +set icons +set period 1 +set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml" +set cleaner '~/.config/lf/cleaner' +set previewer '~/.config/lf/scope' +set autoquit true +set relativenumber + +cmd z %{{ + result="$(zoxide query --exclude "${PWD}" -- "$@")" + lf -remote "send ${id} cd '${result}'" +}} +map z push :z<space> + +# cmds/functions +cmd open ${{ +# case $(file --mime-type "$(readlink -f $f)" -b) in +# application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) localc $fx ;; +# image/vnd.djvu|application/pdf|application/octet-stream|application/postscript) setsid -f zathura $fx >/dev/null 2>&1 ;; +# text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;; +# image/x-xcf) setsid -f gimp $f >/dev/null 2>&1 ;; +# image/svg+xml) display -- $f ;; +# image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\)\(_large\)*$" | +# setsid -f nsxiv -aio 2>/dev/null | while read -r file; do +# [ -z "$file" ] && continue +# lf -remote "send select \"$file\"" +# lf -remote "send toggle" +# done & +# ;; +# audio/*|video/x-ms-asf) mpv --audio-display=no $f ;; +# video/*) setsid -f mpv $f -quiet >/dev/null 2>&1 ;; +# application/pdf|application/vnd.djvu|application/epub*) setsid -f zathura $fx >/dev/null 2>&1 ;; +# application/pgp-encrypted) $EDITOR $fx ;; +# application/vnd.openxmlformats-officedocument.wordprocessingml.document|application/vnd.oasis.opendocument.text|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet|application/octet-stream|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) setsid -f libreoffice $fx >/dev/null 2>&1 ;; +# *) for f in $fx; do setsid -f $OPENER $f >/dev/null 2>&1; done;; +# esac +}} + +cmd mkdir $mkdir -p "$@" + +cmd extract ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + printf "%s\n\t" "$fx" + printf "extract?[y/N]" + read ans + [ $ans = "y" ] && { + case $fx in + *.tar.bz2) tar xjf $fx ;; + *.tar.gz) tar xzf $fx ;; + *.bz2) bunzip2 $fx ;; + *.rar) unrar e $fx ;; + *.gz) gunzip $fx ;; + *.tar) tar xf $fx ;; + *.tbz2) tar xjf $fx ;; + *.tgz) tar xzf $fx ;; + *.zip) unzip $fx ;; + *.Z) uncompress $fx ;; + *.7z) 7z x $fx ;; + *.tar.xz) tar xf $fx ;; + esac + } +}} + +cmd delete ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + printf "%s\n\t" "$fx" + printf "delete?[y/N]" + read ans + [ $ans = "y" ] && rm -rf -- $fx +}} + +cmd moveto ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + clear; echo "Move to where?" + dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" && + for x in $fx; do + eval mv -iv \"$x\" \"$dest\" + done && + notify-send "🚚 File(s) moved." "File(s) moved to $dest." +}} + +cmd copyto ${{ + clear; tput cup $(($(tput lines)/3)); tput bold + set -f + clear; echo "Copy to where?" + dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" && + for x in $fx; do + eval cp -ivr \"$x\" \"$dest\" + done && + notify-send "📋 File(s) copied." "File(s) copies to $dest." +}} + +cmd setbg "$1" + +cmd bulkrename ${{ + tmpfile_old="$(mktemp)" + tmpfile_new="$(mktemp)" + + [ -n "$fs" ] && fs=$(basename -a $fs) || fs=$(ls) + + echo "$fs" > "$tmpfile_old" + echo "$fs" > "$tmpfile_new" + $EDITOR "$tmpfile_new" + + [ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new"; exit 1; } + + paste "$tmpfile_old" "$tmpfile_new" | while IFS="$(printf '\t')" read -r src dst + do + [ "$src" = "$dst" ] || [ -e "$dst" ] || mv -- "$src" "$dst" + done + + rm -f "$tmpfile_old" "$tmpfile_new" + lf -remote "send $id unselect" +}} + +cmd on-quit ${{ + if [ -e /tmp/lf-on-quit ]; then + cat /tmp/lf-on-quit + rm /tmp/lf-on-quit + else + echo $OLDPWD + fi +}} + +cmd change-last-dir &{{ + echo "$PWD" > /tmp/lf-on-quit +}} + +# Bindings +map ~ change-last-dir +map . $$EDITOR ${PWD} +map <c-f> $lf -remote "send $id select \"$(fzf)\"" +map J $lf -remote "send $id cd $(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf)" +map gh +map g top +map D delete +map E extract +map C copyto +map M moveto +map <c-n> push :mkdir<space>""<left> +map <c-r> reload +map <c-s> set hidden! +map <enter> shell +map x $$f +map X !$f +map o &mimeopen "$f" +map O $mimeopen --ask "$f" + +map A :rename; cmd-end # at the very end +map c push A<c-u> # new rename +map I :rename; cmd-home # at the very beginning +map i :rename # before extension +map a :rename; cmd-right # after extension +map B bulkrename +map b $setbg $f +map <backspace2> clear + +map <c-e> down +map <c-y> up +map V push :!nvim<space> + +map W $setsid -f $TERMINAL >/dev/null 2>&1 + +map Y $printf "%s" "$fx" | xclip -selection clipboard diff --git a/.config/lf/scope b/.config/lf/scope new file mode 100755 index 0000000..57c0ed9 --- /dev/null +++ b/.config/lf/scope @@ -0,0 +1,59 @@ +#!/bin/sh + +# File preview handler for lf. + +set -C -f +IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" + +image() { + if [ -f "$1" ] && command -V kitten >/dev/null 2>&1; then + kitten icat --transfer-mode file --stdin no --place "${2}x${3}@${4}x${5}" "$1" < /dev/null > /dev/tty + elif [ -f "$1" ] && [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && command -V ueberzug >/dev/null 2>&1; then + printf '{"action": "add", "identifier": "PREVIEW", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$4" "$5" "$(($2-1))" "$(($3-1))" "$1" > "$FIFO_UEBERZUG" + else + mediainfo "$6" + fi +} + +# Note that the cache file name is a function of file information, meaning if +# an image appears in multiple places across the machine, it will not have to +# be regenerated once seen. + +case "$(file --dereference --brief --mime-type -- "$1")" in + image/avif) CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)" + [ ! -f "$CACHE" ] && convert "$1" "$CACHE.jpg" + image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" ;; + image/vnd.djvu) + CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)" + [ ! -f "$CACHE" ] && djvused "$1" -e 'select 1; save-page-with /dev/stdout' | convert -density 200 - "$CACHE.jpg" > /dev/null 2>&1 + image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" ;; +image/svg+xml) + CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)" + [ ! -f "$CACHE" ] && inkscape --convert-dpi-method=none -o "$CACHE.png" --export-overwrite -D --export-png-color-mode=RGBA_16 "$1" + image "$CACHE.png" "$2" "$3" "$4" "$5" "$1" + ;; + image/*) image "$1" "$2" "$3" "$4" "$5" "$1" ;; + text/html) open "$1" ;; + text/troff) man ./ "$1" | col -b ;; + text/* | */xml | application/json | application/x-ndjson) bat -p --theme ansi --terminal-width "$(($4-2))" -f "$1" ;; + audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;; + video/* ) + CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)" + [ ! -f "$CACHE" ] && ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0 + image "$CACHE" "$2" "$3" "$4" "$5" "$1" + ;; + */pdf) + CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)" + [ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE" + image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" + ;; + */epub+zip|*/mobi*) + CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)" + [ ! -f "$CACHE.jpg" ] && gnome-epub-thumbnailer "$1" "$CACHE.jpg" + image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" + ;; + application/*zip) atool --list -- "$1" ;; + *opendocument*) odt2txt "$1" ;; + application/pgp-encrypted) gpg -d -- "$1" ;; +esac +exit 1 diff --git a/.config/nushell/config.nu b/.config/nushell/config.nu new file mode 100644 index 0000000..c13da9f --- /dev/null +++ b/.config/nushell/config.nu @@ -0,0 +1,921 @@ +if ($env | default "" DOCKER_NAME | get DOCKER_NAME | is-empty) { + if (pidof gpg-agent | is-empty) { gpgconf --launch gpg-agent } + if ("~/.gnupg/S.gpg-agent.ssh" | path exists) { + ln -sf ("~/.gnupg/S.gpg-agent.ssh" | path expand) $env.SSH_AUTH_SOCK + } + # try {pnsh-nvim} +} +# Nushell Config File +# +# version = "0.99.1" + +# For more information on defining custom themes, see +# https://www.nushell.sh/book/coloring_and_theming.html +# And here is the theme collection +# https://github.com/nushell/nu_scripts/tree/main/themes +let dark_theme = { + # color for nushell primitives + separator: white + leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off + header: green_bold + empty: blue + # Closures can be used to choose colors for specific values. + # The value (in this case, a bool) is piped into the closure. + # eg) {|| if $in { 'light_cyan' } else { 'light_gray' } } + bool: light_cyan + int: white + filesize: cyan + duration: white + date: purple + range: white + float: white + string: white + nothing: white + binary: white + cell-path: white + row_index: green_bold + record: white + list: white + block: white + hints: dark_gray + search_result: { bg: red fg: white } + shape_and: purple_bold + shape_binary: purple_bold + shape_block: blue_bold + shape_bool: light_cyan + shape_closure: green_bold + shape_custom: green + shape_datetime: cyan_bold + shape_directory: cyan + shape_external: cyan + shape_externalarg: green_bold + shape_external_resolved: light_yellow_bold + shape_filepath: cyan + shape_flag: blue_bold + shape_float: purple_bold + # shapes are used to change the cli syntax highlighting + shape_garbage: { fg: white bg: red attr: b } + shape_glob_interpolation: cyan_bold + shape_globpattern: cyan_bold + shape_int: purple_bold + shape_internalcall: cyan_bold + shape_keyword: cyan_bold + shape_list: cyan_bold + shape_literal: blue + shape_match_pattern: green + shape_matching_brackets: { attr: u } + shape_nothing: light_cyan + shape_operator: yellow + shape_or: purple_bold + shape_pipe: purple_bold + shape_range: yellow_bold + shape_record: cyan_bold + shape_redirection: purple_bold + shape_signature: green_bold + shape_string: green + shape_string_interpolation: cyan_bold + shape_table: blue_bold + shape_variable: purple + shape_vardecl: purple + shape_raw_string: light_purple +} + +let light_theme = { + # color for nushell primitives + separator: dark_gray + leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off + header: green_bold + empty: blue + # Closures can be used to choose colors for specific values. + # The value (in this case, a bool) is piped into the closure. + # eg) {|| if $in { 'dark_cyan' } else { 'dark_gray' } } + bool: dark_cyan + int: dark_gray + filesize: cyan_bold + duration: dark_gray + date: purple + range: dark_gray + float: dark_gray + string: dark_gray + nothing: dark_gray + binary: dark_gray + cell-path: dark_gray + row_index: green_bold + record: dark_gray + list: dark_gray + block: dark_gray + hints: dark_gray + search_result: { fg: white bg: red } + shape_and: purple_bold + shape_binary: purple_bold + shape_block: blue_bold + shape_bool: light_cyan + shape_closure: green_bold + shape_custom: green + shape_datetime: cyan_bold + shape_directory: cyan + shape_external: cyan + shape_externalarg: green_bold + shape_external_resolved: light_purple_bold + shape_filepath: cyan + shape_flag: blue_bold + shape_float: purple_bold + # shapes are used to change the cli syntax highlighting + shape_garbage: { fg: white bg: red attr: b } + shape_glob_interpolation: cyan_bold + shape_globpattern: cyan_bold + shape_int: purple_bold + shape_internalcall: cyan_bold + shape_keyword: cyan_bold + shape_list: cyan_bold + shape_literal: blue + shape_match_pattern: green + shape_matching_brackets: { attr: u } + shape_nothing: light_cyan + shape_operator: yellow + shape_or: purple_bold + shape_pipe: purple_bold + shape_range: yellow_bold + shape_record: cyan_bold + shape_redirection: purple_bold + shape_signature: green_bold + shape_string: green + shape_string_interpolation: cyan_bold + shape_table: blue_bold + shape_variable: purple + shape_vardecl: purple + shape_raw_string: light_purple +} + +# The default config record. This is where much of your global configuration is setup. +$env.config = { + show_banner: true # true or false to enable or disable the welcome banner at startup + + ls: { + use_ls_colors: true # use the LS_COLORS environment variable to colorize output + clickable_links: true # enable or disable clickable links. Your terminal has to support links. + } + + rm: { + always_trash: false # always act as if -t was given. Can be overridden with -p + } + + table: { + mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other + index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column + show_empty: true # show 'empty list' and 'empty record' placeholders for command output + padding: { left: 1, right: 1 } # a left right padding of each column in a table + trim: { + methodology: wrapping # wrapping or truncating + wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology + truncating_suffix: "..." # A suffix used by the 'truncating' methodology + } + header_on_separator: false # show header text on separator/border line + # abbreviated_row_count: 10 # limit data rows from top and bottom after reaching a set point + } + + error_style: "fancy" # "fancy" or "plain" for screen reader-friendly error messages + + # Whether an error message should be printed if an error of a certain kind is triggered. + display_errors: { + exit_code: false # assume the external command prints an error message + # Core dump errors are always printed, and SIGPIPE never triggers an error. + # The setting below controls message printing for termination by all other signals. + termination_signal: true + } + + # datetime_format determines what a datetime rendered in the shell would look like. + # Behavior without this configuration point will be to "humanize" the datetime display, + # showing something like "a day ago." + datetime_format: { + # normal: '%a, %d %b %Y %H:%M:%S %z' # shows up in displays of variables or other datetime's outside of tables + # table: '%m/%d/%y %I:%M:%S%p' # generally shows up in tabular outputs such as ls. commenting this out will change it to the default human readable datetime format + } + + explore: { + status_bar_background: { fg: "#1D1F21", bg: "#C4C9C6" }, + command_bar_text: { fg: "#C4C9C6" }, + highlight: { fg: "black", bg: "yellow" }, + status: { + error: { fg: "white", bg: "red" }, + warn: {} + info: {} + }, + selected_cell: { bg: light_blue }, + } + + history: { + max_size: 100_000 # Session has to be reloaded for this to take effect + sync_on_enter: true # Enable to share history between multiple sessions, else you have to close the session to write history to file + file_format: "plaintext" # "sqlite" or "plaintext" + isolation: false # only available with sqlite file_format. true enables history isolation, false disables it. true will allow the history to be isolated to the current session using up/down arrows. false will allow the history to be shared across all sessions. + } + + completions: { + case_sensitive: false # set to true to enable case-sensitive completions + quick: true # set this to false to prevent auto-selecting completions when only one remains + partial: true # set this to false to prevent partial filling of the prompt + algorithm: "prefix" # prefix or fuzzy + sort: "smart" # "smart" (alphabetical for prefix matching, fuzzy score for fuzzy matching) or "alphabetical" + external: { + enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow + max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options + completer: null # check 'carapace_completer' above as an example + } + use_ls_colors: true # set this to true to enable file/path/directory completions using LS_COLORS + } + + filesize: { + metric: false # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) + format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto + } + + cursor_shape: { + emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (line is the default) + vi_insert: block # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (block is the default) + vi_normal: underscore # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (underscore is the default) + } + + color_config: $dark_theme # if you want a more interesting theme, you can replace the empty record with `$dark_theme`, `$light_theme` or another custom record + footer_mode: 25 # always, never, number_of_rows, auto + float_precision: 2 # the precision for displaying floats in tables + buffer_editor: null # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL + use_ansi_coloring: true + bracketed_paste: true # enable bracketed paste, currently useless on windows + edit_mode: emacs # emacs, vi + shell_integration: { + # osc2 abbreviates the path if in the home_dir, sets the tab/window title, shows the running command in the tab/window title + osc2: true + # osc7 is a way to communicate the path to the terminal, this is helpful for spawning new tabs in the same directory + osc7: true + # osc8 is also implemented as the deprecated setting ls.show_clickable_links, it shows clickable links in ls output if your terminal supports it. show_clickable_links is deprecated in favor of osc8 + osc8: true + # osc9_9 is from ConEmu and is starting to get wider support. It's similar to osc7 in that it communicates the path to the terminal + osc9_9: false + # osc133 is several escapes invented by Final Term which include the supported ones below. + # 133;A - Mark prompt start + # 133;B - Mark prompt end + # 133;C - Mark pre-execution + # 133;D;exit - Mark execution finished with exit code + # This is used to enable terminals to know where the prompt is, the command is, where the command finishes, and where the output of the command is + osc133: true + # osc633 is closely related to osc133 but only exists in visual studio code (vscode) and supports their shell integration features + # 633;A - Mark prompt start + # 633;B - Mark prompt end + # 633;C - Mark pre-execution + # 633;D;exit - Mark execution finished with exit code + # 633;E - Explicitly set the command line with an optional nonce + # 633;P;Cwd=<path> - Mark the current working directory and communicate it to the terminal + # and also helps with the run recent menu in vscode + osc633: true + # reset_application_mode is escape \x1b[?1l and was added to help ssh work better + reset_application_mode: true + } + render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt. + use_kitty_protocol: false # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this. + highlight_resolved_externals: false # true enables highlighting of external commands in the repl resolved by which. + recursion_limit: 50 # the maximum number of times nushell allows recursion before stopping it + + plugins: {} # Per-plugin configuration. See https://www.nushell.sh/contributor-book/plugins.html#configuration. + + plugin_gc: { + # Configuration for plugin garbage collection + default: { + enabled: true # true to enable stopping of inactive plugins + stop_after: 10sec # how long to wait after a plugin is inactive to stop it + } + plugins: { + # alternate configuration for specific plugins, by name, for example: + # + # gstat: { + # enabled: false + # } + } + } + + hooks: { + pre_prompt: [{ null }] # run before the prompt is shown + pre_execution: [{ null }] # run before the repl input is run + env_change: { + PWD: [{|before, after| null }] # run if the PWD environment is different since the last repl input + } + display_output: "if (term size).columns >= 100 { table -e } else { table }" # run to display the output of a pipeline + command_not_found: { null } # return an error message when a command is not found + } + + menus: [ + # Configuration for default nushell menus + # Note the lack of source parameter + { + name: completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: columnar + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + } + style: { + text: green + selected_text: { attr: r } + description_text: yellow + match_text: { attr: u } + selected_match_text: { attr: ur } + } + } + { + name: ide_completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: ide + min_completion_width: 0, + max_completion_width: 50, + max_completion_height: 10, # will be limited by the available lines in the terminal + padding: 0, + border: true, + cursor_offset: 0, + description_mode: "prefer_right" + min_description_width: 0 + max_description_width: 50 + max_description_height: 10 + description_offset: 1 + # If true, the cursor pos will be corrected, so the suggestions match up with the typed text + # + # C:\> str + # str join + # str trim + # str split + correct_cursor_pos: false + } + style: { + text: green + selected_text: { attr: r } + description_text: yellow + match_text: { attr: u } + selected_match_text: { attr: ur } + } + } + { + name: history_menu + only_buffer_difference: true + marker: "? " + type: { + layout: list + page_size: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + { + name: help_menu + only_buffer_difference: true + marker: "? " + type: { + layout: description + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + selection_rows: 4 + description_rows: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + ] + + keybindings: [ + { + name: completion_menu + modifier: none + keycode: tab + mode: [emacs vi_normal vi_insert] + event: { + until: [ + { send: menu name: completion_menu } + { send: menunext } + { edit: complete } + ] + } + } + { + name: completion_previous_menu + modifier: shift + keycode: backtab + mode: [emacs, vi_normal, vi_insert] + event: { send: menuprevious } + } + { + name: ide_completion_menu + modifier: control + keycode: space + mode: [emacs vi_normal vi_insert] + event: { + until: [ + { send: menu name: ide_completion_menu } + { send: menunext } + { edit: complete } + ] + } + } + { + name: history_menu + modifier: control + keycode: char_r + mode: [emacs, vi_insert, vi_normal] + event: { send: menu name: history_menu } + } + { + name: help_menu + modifier: none + keycode: f1 + mode: [emacs, vi_insert, vi_normal] + event: { send: menu name: help_menu } + } + { + name: next_page_menu + modifier: control + keycode: char_x + mode: emacs + event: { send: menupagenext } + } + { + name: undo_or_previous_page_menu + modifier: control + keycode: char_z + mode: emacs + event: { + until: [ + { send: menupageprevious } + { edit: undo } + ] + } + } + { + name: escape + modifier: none + keycode: escape + mode: [emacs, vi_normal, vi_insert] + event: { send: esc } # NOTE: does not appear to work + } + { + name: cancel_command + modifier: control + keycode: char_c + mode: [emacs, vi_normal, vi_insert] + event: { send: ctrlc } + } + { + name: quit_shell + modifier: control + keycode: char_d + mode: [emacs, vi_normal, vi_insert] + event: { send: ctrld } + } + { + name: clear_screen + modifier: control + keycode: char_l + mode: [emacs, vi_normal, vi_insert] + event: { send: clearscreen } + } + { + name: search_history + modifier: control + keycode: char_q + mode: [emacs, vi_normal, vi_insert] + event: { send: searchhistory } + } + { + name: open_command_editor + modifier: control + keycode: char_o + mode: [emacs, vi_normal, vi_insert] + event: { send: openeditor } + } + { + name: move_up + modifier: none + keycode: up + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: menuup } + { send: up } + ] + } + } + { + name: move_down + modifier: none + keycode: down + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: menudown } + { send: down } + ] + } + } + { + name: move_left + modifier: none + keycode: left + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: menuleft } + { send: left } + ] + } + } + { + name: move_right_or_take_history_hint + modifier: none + keycode: right + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: historyhintcomplete } + { send: menuright } + { send: right } + ] + } + } + { + name: move_one_word_left + modifier: control + keycode: left + mode: [emacs, vi_normal, vi_insert] + event: { edit: movewordleft } + } + { + name: move_one_word_right_or_take_history_hint + modifier: control + keycode: right + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: historyhintwordcomplete } + { edit: movewordright } + ] + } + } + { + name: move_to_line_start + modifier: none + keycode: home + mode: [emacs, vi_normal, vi_insert] + event: { edit: movetolinestart } + } + { + name: move_to_line_start + modifier: control + keycode: char_a + mode: [emacs, vi_normal, vi_insert] + event: { edit: movetolinestart } + } + { + name: move_to_line_end_or_take_history_hint + modifier: none + keycode: end + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: historyhintcomplete } + { edit: movetolineend } + ] + } + } + { + name: move_to_line_end_or_take_history_hint + modifier: control + keycode: char_e + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: historyhintcomplete } + { edit: movetolineend } + ] + } + } + { + name: move_to_line_start + modifier: control + keycode: home + mode: [emacs, vi_normal, vi_insert] + event: { edit: movetolinestart } + } + { + name: move_to_line_end + modifier: control + keycode: end + mode: [emacs, vi_normal, vi_insert] + event: { edit: movetolineend } + } + { + name: move_down + modifier: control + keycode: char_n + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: menudown } + { send: down } + ] + } + } + { + name: move_up + modifier: control + keycode: char_p + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + { send: menuup } + { send: up } + ] + } + } + { + name: delete_one_character_backward + modifier: none + keycode: backspace + mode: [emacs, vi_insert] + event: { edit: backspace } + } + { + name: delete_one_word_backward + modifier: control + keycode: backspace + mode: [emacs, vi_insert] + event: { edit: backspaceword } + } + { + name: delete_one_character_forward + modifier: none + keycode: delete + mode: [emacs, vi_insert] + event: { edit: delete } + } + { + name: delete_one_character_forward + modifier: control + keycode: delete + mode: [emacs, vi_insert] + event: { edit: delete } + } + { + name: delete_one_character_backward + modifier: control + keycode: char_h + mode: [emacs, vi_insert] + event: { edit: backspace } + } + { + name: delete_one_word_backward + modifier: control + keycode: char_w + mode: [emacs, vi_insert] + event: { edit: backspaceword } + } + { + name: move_left + modifier: none + keycode: backspace + mode: vi_normal + event: { edit: moveleft } + } + { + name: newline_or_run_command + modifier: none + keycode: enter + mode: emacs + event: { send: enter } + } + { + name: move_left + modifier: control + keycode: char_b + mode: emacs + event: { + until: [ + { send: menuleft } + { send: left } + ] + } + } + { + name: move_right_or_take_history_hint + modifier: control + keycode: char_f + mode: emacs + event: { + until: [ + { send: historyhintcomplete } + { send: menuright } + { send: right } + ] + } + } + { + name: redo_change + modifier: control + keycode: char_g + mode: emacs + event: { edit: redo } + } + { + name: undo_change + modifier: control + keycode: char_z + mode: emacs + event: { edit: undo } + } + { + name: paste_before + modifier: control + keycode: char_y + mode: emacs + event: { edit: pastecutbufferbefore } + } + { + name: cut_word_left + modifier: control + keycode: char_w + mode: emacs + event: { edit: cutwordleft } + } + { + name: cut_line_to_end + modifier: control + keycode: char_k + mode: emacs + event: { edit: cuttolineend } + } + { + name: cut_line_from_start + modifier: control + keycode: char_u + mode: emacs + event: { edit: cutfromstart } + } + { + name: swap_graphemes + modifier: control + keycode: char_t + mode: emacs + event: { edit: swapgraphemes } + } + { + name: move_one_word_left + modifier: alt + keycode: left + mode: emacs + event: { edit: movewordleft } + } + { + name: move_one_word_right_or_take_history_hint + modifier: alt + keycode: right + mode: emacs + event: { + until: [ + { send: historyhintwordcomplete } + { edit: movewordright } + ] + } + } + { + name: move_one_word_left + modifier: alt + keycode: char_b + mode: emacs + event: { edit: movewordleft } + } + { + name: move_one_word_right_or_take_history_hint + modifier: alt + keycode: char_f + mode: emacs + event: { + until: [ + { send: historyhintwordcomplete } + { edit: movewordright } + ] + } + } + { + name: delete_one_word_forward + modifier: alt + keycode: delete + mode: emacs + event: { edit: deleteword } + } + { + name: delete_one_word_backward + modifier: alt + keycode: backspace + mode: emacs + event: { edit: backspaceword } + } + { + name: delete_one_word_backward + modifier: alt + keycode: char_m + mode: emacs + event: { edit: backspaceword } + } + { + name: cut_word_to_right + modifier: alt + keycode: char_d + mode: emacs + event: { edit: cutwordright } + } + { + name: upper_case_word + modifier: alt + keycode: char_u + mode: emacs + event: { edit: uppercaseword } + } + { + name: lower_case_word + modifier: alt + keycode: char_l + mode: emacs + event: { edit: lowercaseword } + } + { + name: capitalize_char + modifier: alt + keycode: char_c + mode: emacs + event: { edit: capitalizechar } + } + # The following bindings with `*system` events require that Nushell has + # been compiled with the `system-clipboard` feature. + # If you want to use the system clipboard for visual selection or to + # paste directly, uncomment the respective lines and replace the version + # using the internal clipboard. + { + name: copy_selection + modifier: control_shift + keycode: char_c + mode: emacs + event: { edit: copyselection } + # event: { edit: copyselectionsystem } + } + { + name: cut_selection + modifier: control_shift + keycode: char_x + mode: emacs + event: { edit: cutselection } + # event: { edit: cutselectionsystem } + } + # { + # name: paste_system + # modifier: control_shift + # keycode: char_v + # mode: emacs + # event: { edit: pastesystem } + # } + { + name: select_all + modifier: control_shift + keycode: char_a + mode: emacs + event: { edit: selectall } + } + ] +} + +if ("~/.cache/wal/sequences" | path exists) { ^cat ~/.cache/wal/sequences } +source ~/.cache/zoxide.nu +if ("~/.cache/starship.nu" | path exists) { source ~/.cache/starship.nu } +if ("~/.cache/carapace.nu" | path exists) { source ~/.cache/carapace.nu } + +$env.K9S_DEFAULT_PF_ADDRESS = "0.0.0.0" +$env.config.show_banner = false + +alias p = pnsh-nvim +alias k = kubectl +alias d = docker +alias t = terraform +alias g = git +alias f = nvim +G +only + +let pistarchio_dir = "~/Programming/Pionative/pistarchio" | path expand +$env.PISTARCHIO_STACKS_DIR = $pistarchio_dir + "/stacks" +$env.PISTARCHIO_LIBRARY_DIR = $pistarchio_dir + "/library" +$env.PISTARCHIO_VENDOR_DESTINATION_DIR = ($pistarchio_dir + "/../clients") | path expand +# overlay use ~/Programming/Pionative/quickstart/.venv/bin/activate.nu diff --git a/.config/nushell/env.nu b/.config/nushell/env.nu new file mode 100644 index 0000000..435a090 --- /dev/null +++ b/.config/nushell/env.nu @@ -0,0 +1,213 @@ +# Nushell Environment Config File +# +# version = "0.99.1" + +def create_left_prompt [] { + let dir = match (do --ignore-errors { $env.PWD | path relative-to $nu.home-path }) { + null => $env.PWD + '' => '~' + $relative_pwd => ([~ $relative_pwd] | path join) + } + + let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold }) + let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold }) + let path_segment = $"($path_color)($dir)(ansi reset)" + + $path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)" +} + +def create_right_prompt [] { + # create a right prompt in magenta with green separators and am/pm underlined + let time_segment = ([ + (ansi reset) + (ansi magenta) + (date now | format date '%x %X') # try to respect user's locale + ] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" | + str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}") + + let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([ + (ansi rb) + ($env.LAST_EXIT_CODE) + ] | str join) + } else { "" } + + ([$last_exit_code, (char space), $time_segment] | str join) +} + +# Use nushell functions to define your right and left prompt +$env.PROMPT_COMMAND = {|| create_left_prompt } +# FIXME: This default is not implemented in rust code as of 2023-09-08. +$env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt } + +# The prompt indicators are environmental variables that represent +# the state of the prompt +$env.PROMPT_INDICATOR = {|| "> " } +$env.PROMPT_INDICATOR_VI_INSERT = {|| ": " } +$env.PROMPT_INDICATOR_VI_NORMAL = {|| "> " } +$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " } + +# If you want previously entered commands to have a different prompt from the usual one, +# you can uncomment one or more of the following lines. +# This can be useful if you have a 2-line prompt and it's taking up a lot of space +# because every command entered takes up 2 lines instead of 1. You can then uncomment +# the line below so that previously entered commands show with a single `🚀`. +# $env.TRANSIENT_PROMPT_COMMAND = {|| "🚀 " } +# $env.TRANSIENT_PROMPT_INDICATOR = {|| "" } +# $env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = {|| "" } +# $env.TRANSIENT_PROMPT_INDICATOR_VI_NORMAL = {|| "" } +# $env.TRANSIENT_PROMPT_MULTILINE_INDICATOR = {|| "" } +# $env.TRANSIENT_PROMPT_COMMAND_RIGHT = {|| "" } + +# Specifies how environment variables are: +# - converted from a string to a value on Nushell startup (from_string) +# - converted from a value back to a string when running external commands (to_string) +# Note: The conversions happen *after* config.nu is loaded +$env.ENV_CONVERSIONS = { + "PATH": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } + "Path": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } +} + +# Directories to search for scripts when calling source or use +# The default for this is $nu.default-config-dir/scripts +$env.NU_LIB_DIRS = [ + ($nu.default-config-dir | path join 'scripts') # add <nushell-config-dir>/scripts + ($nu.data-dir | path join 'completions') # default home for nushell completions +] + +# Directories to search for plugin binaries when calling register +# The default for this is $nu.default-config-dir/plugins +$env.NU_PLUGIN_DIRS = [ + ($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins +] + +# To load from a custom file you can use: +# source ($nu.default-config-dir | path join 'custom.nu') + +let darwin: bool = (uname | get operating-system) == "Darwin" +let nix: bool = "/nix" | path exists + +if $darwin and $nix { + $env.__NIX_DARWIN_SET_ENVIRONMENT_DONE = 1 + + $env.PATH = [ + $"($env.HOME)/.nix-profile/bin" + $"/etc/profiles/per-user/($env.USER)/bin" + "/run/current-system/sw/bin" + "/nix/var/nix/profiles/default/bin" + "/usr/local/bin" + "/usr/bin" + "/usr/sbin" + "/bin" + "/sbin" + ] + $env.EDITOR = "VIM" + $env.NIX_PATH = [ + $"darwin-config=($env.HOME)/.nixpkgs/darwin-configuration.nix" + "/nix/var/nix/profiles/per-user/root/channels" + ] + $env.NIX_SSL_CERT_FILE = "/etc/ssl/certs/ca-certificates.crt" + $env.PAGER = "less -R" + $env.TERMINFO_DIRS = [ + $"($env.HOME)/.nix-profile/share/terminfo" + $"/etc/profiles/per-user/($env.USER)/share/terminfo" + "/run/current-system/sw/share/terminfo" + "/nix/var/nix/profiles/default/share/terminfo" + "/usr/share/terminfo" + ] + $env.XDG_CONFIG_DIRS = [ + $"($env.HOME)/.nix-profile/etc/xdg" + $"/etc/profiles/per-user/($env.USER)/etc/xdg" + "/run/current-system/sw/etc/xdg" + "/nix/var/nix/profiles/default/etc/xdg" + ] + $env.XDG_DATA_DIRS = [ + $"($env.HOME)/.nix-profile/share" + $"/etc/profiles/per-user/($env.USER)/share" + "/run/current-system/sw/share" + "/nix/var/nix/profiles/default/share" + ] + $env.TERM = $env.TERM + $env.NIX_USER_PROFILE_DIR = $"/nix/var/nix/profiles/per-user/($env.USER)" + $env.NIX_PROFILES = [ + "/nix/var/nix/profiles/default" + "/run/current-system/sw" + $"/etc/profiles/per-user/($env.USER)" + $"($env.HOME)/.nix-profile" + ] + + if ($"($env.HOME)/.nix-defexpr/channels" | path exists) { + $env.NIX_PATH = ($env.PATH | split row (char esep) | append $"($env.HOME)/.nix-defexpr/channels") + } + + if (false in (ls -l `/nix/var/nix`| where type == dir | where name == "/nix/var/nix/db" | get mode | str contains "w")) { + $env.NIX_REMOTE = "daemon" + } +} + +# To add entries to PATH (on Windows you might use Path), you can use the following pattern: +# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path') +# An alternate way to add entries to $env.PATH is to use the custom command `path add` +# which is built into the nushell stdlib: +use std "path add" +# $env.PATH = ($env.PATH | split row (char esep)) +# path add /some/path +# path add ($env.CARGO_HOME | path join "bin") +try { + if $darwin { + $env.PATH = ["/opt/homebrew/bin" "/opt/X11/bin" "/opt/local/bin" "/opt/local/sbin"] ++ $env.PATH + } +} +path add ($env.HOME | path join ".local" "bin") +$env.PATH = ($env.PATH | uniq) + +$env.XDG_CACHE_HOME = "~/.cache" | path expand +$env.XDG_DATA_HOME = "~/.local/share" | path expand +$env.XDG_CONFIG_HOME = "~/.config" | path expand + +if (which carapace | is-not-empty) { + $env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense' # optional + carapace _carapace nushell | save --force ~/.cache/carapace.nu +} +if (which zoxide | is-not-empty) { + zoxide init nushell --cmd=cd | save --force ~/.cache/zoxide.nu +} +if (which starship | is-not-empty) { + starship init nu | save --force ~/.cache/starship.nu +} + +if (not ("/var/run/docker.sock" | path exists)) and (not darwin) { + $env.DOCKER_HOST = $"unix://($env | default $"/run/($env.USER)" XDG_RUNTIME_DIR | get XDG_RUNTIME_DIR)/docker.sock" +} + +# if not ("/.dockerenv" | path exists) { +# do --env { +# let ssh_agent_file = ( +# $nu.temp-path | path join $"ssh-agent-($env.USER).nuon" +# ) +# +# if ($ssh_agent_file | path exists) { +# let ssh_agent_env = open ($ssh_agent_file) +# if (ps | where pid == ($ssh_agent_env.SSH_AGENT_PID | into int) | is-not-empty) { +# load-env $ssh_agent_env +# return +# } else { +# rm $ssh_agent_file +# } +# } +# +# let ssh_agent_env = ssh-agent -c +# | lines +# | first 2 +# | parse "setenv {name} {value};" +# | transpose --header-row +# | into record +# load-env $ssh_agent_env +# $ssh_agent_env | save --force $ssh_agent_file +# } +# } diff --git a/.config/nushell/history.txt b/.config/nushell/history.txt new file mode 100644 index 0000000..34c5d47 --- /dev/null +++ b/.config/nushell/history.txt @@ -0,0 +1,1167 @@ +bash +ls .config/nushell/ +vi .config/nushell/env.nu +path +path add +vi .config/nushell/env.nu +vi .config/nushell/config.nu +vi /nix-config/profiles/core/home.nix +xdg-open https://google.com +cat .local/bin/desktop-open-pipe +/nix/store/zcw13r2mmpzlnv2yvfl13mcpky3hivq1-system-path/bin/xdg-open https://google.com +which xdg-open +vi /nix-config +cd /nix-config/ +git fetch --all +ls +htop +ssh-add ~/.ssh/id_ed25519_sk +vi +git fetch --all +git pull +vi +sudo nixos-rebuild switch --flake /nix-config +vi /nix-config/profiles/core/home.nix +vi +cd mut/neovim/pack/plugins/start/blink.cmp/ +git status +vi +ls +vi +cd /nix-config/ +vi mut/neovim/lua/my/packages/blink.lua +vi +cp /nix-config/mut/surf/surf-open.sh /nix-config/mut/bin +surf-open.sh +vi .local/bin/surf-open.sh +mkdir tmp +surf-open.sh +sudo nixos-rebuild switch --flake /nix-config +chromium +vi /nix-config/mut/surf/ +sudo nixos-rebuild switch --flake /nix-config +man surf +man tabbed +xwininfo +vi /nix-config/profiles/graphical/suckless.nix +sudo nixos-rebuild switch --flake /nix-config +xwininfo +surf-open.sh https://troubleshooters.com/linux/surf.htm +vi /nix-config/mut/tabbed/config.def.h +sudo nixos-rebuild switch --flake /nix-config +cat ~/.ssh/id_rsa_yubikey.pub +vi /nix-config/lib/my.nix +ssh-add ~/.ssh/id_ed25519_sk +ssh 192.168.178.44 +ssh -i ~/.ssh/id_ed25519_sk 192.168.178.44 -p 2222 +ssh -i ~/.ssh/id_ed25519_sk 192.168.178.44 -p 2222 -vvv +build-pixie +build-pixie pump +which run-pixiecore +which run-pixiecore | open ($in | get patch) +which run-pixiecore | open ($in | get path) +which run-pixiecore | open ($in.0 | get path) +run-pixiecore +ssh -i ~/.ssh/id_ed25519_sk 192.168.178.44 -p 2222 -vvv +ls +ls initrd/ +ls +ls init/bin/ +cd initrd/initrw +cd initrd/ +ls +ls initrd.zst +ls -l initrd.zst +ls -al initrd.zst +zstd +zstd -h +zstd initrd -o here +zstd initrd -o ~/here +cd .. +cd here +ls +cd .. +ls +cd +ls +cd ~/here +ls ~/here +file ~/here +rm ~/here +cd initrd/ +ls +zstd +zstd -h +zstd -d initrd -o ~/here +cd ~/here +ls +cd ../ +ls +file here +cpio +open here | cpio -idmv +ls +cd nix/ +ls +cd store/ +ls +cd .. +cat init +ls +rm -rf nix +sudo rm -rf ./nix +ls +mkdir unpackedinitrd +cd unpackedinitrd/ +cp ../here . +ls +open here | cpio -idmv +ls +cat init +cat init | grep mnt +cd +cd /nix-config +vi +git status +vi +ls +vi +ssh-add ~/.ssh/id_ed25519_sk +git push +git remote remove origin +surf-open.sh +surf +tabbed +surf-open.sh +which surf-open.sh +which surf-open.sh | get path | open +which surf-open.sh | get path.0 | open +which surf-open.sh | get path.0 | nvim +which surf-open.sh | get path.0 | nvim $in +ls tmp +rm tmp/tabbed-surf.xid +vi +git remote add origin git@github.com:ivi-vink/flake.git +vi +cccccbhnjjflcnulunfkudgidkhejkdlibutfngdreeh +cd +cd Programming/ThirdParty/ +git clone https://github.com/martanne/vis +cd vis +makegcc +gcc +./configure +gcc +vi Dockerfile +cd vis +make docker +vi Dockerfile +ls +./vis +vi hello +vis +vi +mv vis ~/.local/bin +vi +vis +cd +vis +cd Programming/ +vis +ls +vis +cd ~/.config/ +man vis-open +vis-open +ls +./vis-open +vis +ls +vis +vi +vis +cd +rm ~/.local/bin/vis +cd /nix-config/ +vi flake.nix +s +sudo nixos-rebuild switch --flake /nix-config +vis +which vis +echo 1 2 3 | vis-menu +^echo 1 2 3 | vis-menu +^echo 1\n2 3 | vis-menu +^ls | vis-menu +ls | get name | vis-menu +ls | each {get name} | vis-menu +ls | each {|f| $f.name} | vis-menu +ls | each {|f| $f.name} +ls | each {|f| $f.name} | to tsv +ls | each {|f| $f.name} +ls | each {|f| $f.name} | to json +ls | each {|f| $f.name} | to text +ls | each {|f| $f.name} | to text | vis-menu +let result = ls | each {|f| $f.name} | to text | vis-menu +$result +vis +man vis +cd .config/vis +ls +wget https://repo.or.cz/vis-quickfix.git/blob_plain/ff8e5e14c0b9e47238fa14723e1a0f5913ee3aeb:/init.lua +ls +mkdir quickfix +mv init.lua quickfix/ +vis visrc.lua +grpe +cd .config/vis +grep -n require +grep -n require . +grep -n require * +grep -rn require * +vis +grep -n -rn require * +which grep +grep require * +which rg +vis visrc.lua +vis +vis +vis +which bash +ls /bin/bash +ls /usr/bin/bash +vis +ls +vis +cd .config/vis +vis +vis visrc.lua +vis +cd .config/vis +vis +touch vislogs +surf +surf-open.sh +surf-open.sh google.com +surf-open.sh https://google.com +surf +rm tmp/tabbed-surf.xid +cd +cd .config/vis +vis +tail -f vislogs +ls +vis +grep -rn require quickfix +vis +ls +rm debug +rm --debug +rm '--debug' +ls +rm vislogs +ls +vis +cd .config/vis +vis +vis visrc.lua +vis +vis visrc.lua +fmt +which fmt +vis +cd .config/vis +vis +vis visrc.lua +ll +ls +vis-open .config +vi /run/current-system/sw/bin/vis-open +which sh +ls /etc/profiles/per-user/ivi/bin/sh +ls -l /etc/profiles/per-user/ivi/bin/sh +ls -l /etc/profiles/per-user/ivi/bin/sh | get target +ls -l /nix/store/88s532drks0ip0ffyp9va413zssq9hvr-home-manager-path/bin/sh +ls -l /nix/store/88s532drks0ip0ffyp9va413zssq9hvr-home-manager-path/bin/sh | get target +vi /run/current-system/sw/bin/vis-open +which vis-open +$env.PATH +chmod +x .local/bin/vis-open +which vis-open +vis-open .config +vi ~/.local/bin/vis-open +vis-open .config +vi ~/.local/bin/vis-open +vis-open .config +vi ~/.local/bin/vis-open +vis-open .config +vi ~/.local/bin/vis-open +man getops +vis +vis .local/bin/vis-open +rm .local/bin/vis-open +rm .config/vis/--debug +vis +cd Programming/Projects/csapp/ +ls +vis Makefile +vis `--debug` +ls +rm --debug +rm ./--debug +vis ~/.config/vis/quickfix/init.lua +ls +rm ./--debug +vis +ls +mkdir 4 +ls +cd 4 +ls +cd .. +vis +git status +git add . +git commit -m dunno +ls +vis 58_decode2.s +ls +vis 58_decode2.s +vis *.s +vis +man getopts +man vis +lf +vis +vis +ls +cd 4 +ls +ls ../3/ +vis +vis ~/.config/vis/visrc.lua +vis +cd 4 +vis +sb-battery +rm -rf tmp/ +surf-open.sh https://google.com +mkdir tmp +vis +git clone https://github.com/seifferth/vis-editorconfig "$HOME/.config/vis/edconf" +uarocks install editorconfig-core +luarocks install editorconfig-core +which lua +lua +vis +man vis +vis +cd third vis +ls +vis ~/.config/vis/visrc.lua +cd third vis +ls +man vis-complete +ls --raw +^ls +^ls | vis-complete +^ls | vis-complete --file +^ls | vis-complete --file *.c +^ls | vis-complete --word *.c +vis-complete --word *.c +man vis-complete +l +ls +vis Dockerfile +cd csapp +ls +sb-battery +cd /nix-config/ +vi machines/pump-netboot.nix +cd /nix-config/ +build-pixie pump +run-pixiecore +run-pixiecore +which build-pixie +ls -al /run/current-system/sw/bin/build-pixie +vi machines/pump-netboot.nix +sudo nixos-rebuild switch --flake /nix-config +which build-pixie +ls -l /run/current-system/sw/bin/build-pixie +ls init/ +man read +bash +ls init/ +man switch_root +ls init +ls init/init +cat init/init +cd unpackedinitrd/ +ls +ls nix/store +ls **/* +ls **/init +ls **/init | each { |f| $f.name } +open nix/store/r1m9wckjsjgiiai77hfxazc0mc3k2nc3-extra-utils/bin/init +rm -rf unpackedinitrd/ +sudo rm -rf unpackedinitrd/ +rm -rf init/ +rm -f init +rm -f kernel/ +rm -f kernel +rm -f initrd/ +rm -f initrd +vi machines/pump-netboot.nix +ls +cd +ls +ls -l +rm lib +ls -l +vi init/init +cpio +man cpio +nix-collect-garbage -d +df -h +sudo nixos-rebuild switch --flake /nix-config +build-pixie pump +ls +open hando +open hando | xdg-open $in +surf-open.sh https://drive.google.com/drive/folders/1r5DIUnDRfc1JlgZmRUEODCxsw5YcnixW +ls +ls hando +ls +ls initrd/ +open initrd/initrd | zstd -d -o unpacked +ls unpacked +file unpacked +open unpacked | cpio -d +open unpacked | cpio +cpio --help +open unpacked | cpio -i +ls +ls unpacked +mkdir unpacked +mkdir test +mv unpacked test +cd test +ls +cd . +cd .. +ls -al tes +ls -al test +sudo rm -rf +ls +sudo rm -rf test +ls -al test +mkdir test +mv unpacked test +cd test +open unpacked | cpio -i +ls +ls nix/ +ls nix/store/ +ls ../init +ls nix/store/6wxswzjpf7fp5flag2baqqkm75rqqykf-linux-6.6.68-modules-shrunk +ls nix/store/6wxswzjpf7fp5flag2baqqkm75rqqykf-linux-6.6.68-modules-shrunk/lib/ +ls nix/store/**/init +file nix/store/v971vc1mpx06qavx6z9kwj3nbyifbd1g-extra-utils/bin/init +ls +cd .. +ls +sudo nixos-rebuild switch --flake /nix-config +cd /nix-config/ +vi flake.nix +sudo nixos-rebuild switch --flake /nix-config +sudo nixos-rebuild switch --flake /nix-config --impure +vi flake.nix +sudo nixos-rebuild switch --flake /nix-config --impure +run-pixiecore +which run-pixiecore | get path.0 +ls -l /run/current-system/sw/bin/run-pixiecore +ls -l /run/current-system/sw/bin/run-pixiecore | get target.0 | open $in +ls /nix/store/m9j4rark32jdpigzdwdpj1q9w9l70230-nixos-system-pump-25.05.20241229.88195a9/init +ls /nix/store/m9j4rark32jdpigzdwdpj1q9w9l70230-nixos-system-pump-25.05.20241229.88195a9/init/ +ls /nix/store/m9j4rark32jdpigzdwdpj1q9w9l70230-nixos-system-pump-25.05.20241229.88195a9/init +cat /nix/store/m9j4rark32jdpigzdwdpj1q9w9l70230-nixos-system-pump-25.05.20241229.88195a9/init +run-pixiecore +ssh -i ~/.ssh/id_ed25519_sk 192.168.178.44 -p 2222 -vvv +vi /etc/resolv.conf +ip +ip a +ip route +sudo -E vi /etc/resolv.conf +run-pixiecore +rm tmp/tabbed-surf.xid +pass show personal/home-admin +vis +cd /nix-config/ +gitu +git status +git diff +git add . +git commit -m 'fix netboot' +ls init/ +rm ~/tmp/tabbed-surf.xid +git rm --cached init* +git rm --cached kernel* +ls +rm init* kernel* +ls +rm result +ls +git status +git add . +git commit --amend +git stash pop +git status +vis flake.nix +git diff +git stash clear +git diff +vis flake.lock +git diff +git clean -fd +ls +git reset --hard +ls +git pull +ls +curl -LO larbs.xyz/larbs.sh +vis larbs.sh +mv larbs.sh ~/larbs.sh +cd ~ +ls +ls larbs.sh +cd /nix-config/ +git pull +git log +git pull --rebase +vi +git branch --set-upstream-to=origin/master master +git pull --rebase +git diff +vis mut/ghostty/config +git rebase --continue +git add mut/ghostty/config +git status +git rebase --continue +git push +vis +mv ~/.config/vis ~/vis.bu +just +nix-shell -p just +ls ~/.config/ +ls ~/.config/nvim +ls -l ~/.config +s +sudo nixos-rebuild switch --flake /nix-config --impure +vis flake.nix +ls mut/vis/ +ls mut/vis/vis-editorconfig/ +ls ~/.config/vis/ +ls -l ~/.config/vis +ls -l ~/.config +ls +surfraw +ls +bash +ls +which sh +readlink sh +readlink /etc/profiles/per-user/ivi/bin/sh +realpaht /nix/store/gh3ri50y5k7mjmvxz4ncllb4xqjj3nhp-home-manager-path/bin/sh +realpath /nix/store/gh3ri50y5k7mjmvxz4ncllb4xqjj3nhp-home-manager-path/bin/sh +surf +ls .local/bin/dmenu +vis .local/bin/dmenu +rm .local/bin/dmenu +wget https://raw.githubusercontent.com/LukeSmithxyz/LARBS/master/static/progs.csv +ls +git status +cd /nix-config/ +cd pnsh +vis progs.csv +git add progs.csv +git status +gs +git commit -m 'add progs.csv' +git log +git push +virt-admin +virt-viewer +cd /nix-config/ +cd mut/vis +ls +touch Makefile +ls +vis Makefile +vis larbs.sh +ls /run/secrets/ +sudo su +ls Downloads/ +ls Downloads | sort +ls Downloads +ls Downloads | sort-by modified +cd Downloads/ +ls Downloads | sort-by modified +ls | sort-by modified +ls | sort-by --reverse modified +cd +ls +cd /nix-config/ +ls +vis secrets/root.yaml +ls -al +vis .sops.yaml +vis machines/pump-netboot.nix +cd ~/.config +ls age +ls +cd - +vis machines/pump-netboot.nix +ls ~/sync/ +ls ~/sync/my/ +ls ~/.config/ +ls ~/.config/sops/age/ +cat /home/ivi/.config/sops/age/keys.txt +vis machines/pump-netboot.nix +vis profiles/homeserver/transmission.nix +run-pixiecore +ssh 192.168.178.44 +TERM=xterm ssh 192.168.178.44 +sudo su +cd /nix-config/ +nix shell +cd /nix-config/ +nix repl +vis flake.nix +nix repl +nix flake --help +nix flake lock +nix repl +vis flake.nix +nix repl +vis flake.nix +rg sops-nix +vis profiles/core/secrets.nix +nix repl +vis profiles/netboot/system.nix +cd /nix-config/ +ls +cat .sops.yaml +ls /run/secrets.d/ +sudo su +age +ls +cat pump +ls +age +age-keygen -o pump-age-keys.txt +cd /nix-config/ +vis ~/.config/sops/age/keys.txt +cat ~/pump-age-keys.txt +vis .sops.yaml +age +sops -h +sops -h | less +sops -r +sops -r ./secrets/* +sops -r ./secrets/**/* +./secrets/**/* | each {|f| sops -r $f.name } +ls ./secrets/**/* | each {|f| sops -r $f.name } +ls ./secrets/**/* +ls ./secrets/**/* | where type == file | each {|f| sops -r $f.name } +ls ./secrets/**/* | where type == file | each {|f| sops -r -i $f.name } +git status +git add secrets +git status +sops ./secrets/porkbun +vis ./secrets/porkbun +cat .sops.yaml +sops -h | less +ls ./secrets/**/* | where type == file | each {|f| sops updatekeys -r -i $f.name } +ls ./secrets/**/* | where type == file | each {|f| sops updatekeys -i $f.name } +ls ./secrets/**/* | where type == file | each {|f| sops updatekeys $f.name } +git status +vis ./secrets/porkbun +sops ./secrets/porkbun +ls ./secrets/**/* | where type == file | each {|f| sops updatekeys $f.name } +vis /nix-config/secrets/root.yaml +sops updatekeys +sops updatekeys ./secrets +ls ./secrets/**/* | where type == file | each {|f| sops updatekeys $f.name } +vis /nix-config/secrets/serber/ivi +git log +git clean -fd ./secrets/ +git status +git rm --cached ./clean +git diff +git diff --cached +git status +ls ./secrets/**/* | where type == file | each {|f| git restore --stage $f.name } +git status +git clean -fd ./secrets/ +git status +git reset --hard ./clean +ls ./secrets/**/* | where type == file | each {|f| git restore $f.name } +git status +ls ./secrets/**/* | where type == file | each {|f| sops updatekeys $f.name } +git status +vis /nix-config/secrets/serber/ivi +vis .sops.yaml +vis /nix-config/secrets/porkbun +sops updatekeys ./secrets/porkbun +sops -h +sops -h | less +bash +git status +git add secrets +git commit -m 'sops updatekeys' +git log +git push +TERM=xterm ssh 192.168.178.44 +sed /192.168.178.44/d ~/.ssh/known_hosts +sed -i /192.168.178.44/d ~/.ssh/known_hosts +run-pixiecore +cd +cat pump-age-keys.txt +TERM=xterm ssh 192.168.178.44 +vis /nix-config/profiles/homeserver/ +vis /nix-config/profiles/homeserver/nginx.nix +sudo nixos-rebuild switch --flake /nix-config --impure +ssh 192.168.178.44 +pass show personal/zpool +TERM=xterm ssh 192.168.178.44 +sed -i /192.168.178.44/d ~/.ssh/known_hosts +run-pixiecore +TERM=xterm ssh 192.168.178.44 +vis /nix-config/profiles/homeserver/transmission.nix +sudo nixos-rebuild switch --flake /nix-config --impure +run-pixiecore +pass show personal/zpool +cat pump-age-keys.txt +TERM=xterm ssh 192.168.178.44 +sed -i /192.168.178.44/d ~/.ssh/known_hosts +virt-manager +pass show personal/zpool +cat pump-age-keys.txt +cd /nix-config/ +ls +vis profiles/homeserver/transmission.nix +vis machines/pump-netboot.nix +grep -rn docker . +grep -rn rootless . +vis profiles/homeserver/transmission.nix +TERM=xterm ssh 192.168.178.44 +cd /nix-config/ +vis profiles/homeserver/transmission.nix +sudo nixos-rebuild switch --flake /nix-config --impure +run-pixiecore +pass show personal/zpool +cat pump-age-keys.txt +cd +cat pump-age-keys.txt +ssh 192.168.178.44 +TERM=xterm ssh 192.168.178.44 +sed -i /192.168.178.44/d ~/.ssh/known_hosts +cat pump-age-keys.txt +curl 192.168.178.44:9091 +curl -f 192.168.178.44:9091 +curl -4 http://192.168.178.44:9091 +curl - http://192.168.178.44:9091 +curl http://192.168.178.44:9091 +TERM=xterm ssh 192.168.178.44 +cd /nix-config/ +vis profiles/homeserver/transmission.nix +curl http://192.168.178.44:8096 +curl -L http://192.168.178.44:8096 +ip a +TERM=xterm ssh 192.168.178.44 +cd /var/lib/libvirt/images/ +ls +sudo su +ssh 192.168.122.158 +ssh root@192.168.122.158 +ssh ivi@192.168.122.159 +TERM=xterm ssh ivi@192.168.122.159 +cd /nix-config/ +ls +mv ~/larbs.sh . +ls +mv larbs.sh mvbs.sh +vis larbs.sh +ssh ivi@192.168.122.159 +TERM=xterm ssh ivi@192.168.122.159 +TERM=xterm ssh ivi@192.168.122.159 < /nix-config/mvbs.sh +open /nix-config/mvbs.sh | TERM=xterm ssh ivi@192.168.122.159 +ssh-add ~/.ssh/id_ed25519_sk +ssh-add -L +open /nix-config/mvbs.sh | TERM=xterm ssh root@192.168.122.159 +open /nix-config/mvbs.sh | TERM=xterm ssh ivi@192.168.122.159 +vis mvbs.sh +TERM=xterm ssh ivi@192.168.122.159 +TERM=xterm ssh root@192.168.122.159 +open /nix-config/mvbs.sh | TERM=xterm ssh ivi@192.168.122.159 +open /nix-config/mvbs.sh | TERM=xterm ssh root@192.168.122.159 +bash +ssh-copy-id +TERM=xterm ssh-copy-id root@192.168.122.159 +ssh 'root@192.168.122.159' +open /nix-config/mvbs.sh | TERM=xterm ssh root@192.168.122.159 +scp /nix-config/mvbs.sh root@192.168.122.159:/opt/installer | TERM=xterm ssh root@192.168.122.159 /opt/installer +scp /nix-config/mvbs.sh root@192.168.122.159:/opt/installer; TERM=xterm ssh root@192.168.122.159 bash /opt/installer +scp /nix-config/mvbs.sh root@192.168.122.159:/opt/installer; TERM=xterm ssh root@192.168.122.159 +ls +vi mvbs.sh +vis mvbs.sh +virt-manager +cd /e +cd /nix-config/ +grep progs.csv +grep desktop progs.csv +grep -e '^desktop' progs.csv +grep -e '^desktop' -e '^cli' progs.csv +vis progs.csv +ls ~/.config/vis/ +cd /nix-config/mut/dwm/ +git stuat +git status +cd ../.. +vis mut/dwm/dwm.c +git subtree +git subtree push --prefix mut/dwm git@github.com:ivi-vink/dwm.git master +git subtree pull --prefix mut/dwm git@github.com:ivi-vink/dwm.git master +git status +rm mut/vis/Makefile +TERM=xterm ssh root@192.168.122.159 +git add . +git commit -m 'fix homeserver and start xbps' +git push +git subtree pull --prefix mut/dwm git@github.com:ivi-vink/dwm.git master +git subtree push --prefix mut/dwm git@github.com:ivi-vink/dwm.git master -f +cd ~ +ls +git clone git@github.com:ivi-vink/dwm.git +cp -r /nix-config/mut/dwm dwm +ls dwm +rm -rf dwm/dwm +cp -r /nix-config/mut/dwm/* dwm +ls dwm +cd dwm +git status +git diff +git add . +git commit -m 'fix homeserver and start xbps' +git push +cd /nix-config +ls +rm tmp/tabbed-surf.xid +git clone git@github.com:ivi-vink/vis.git +cd vis +ls +git remote +git remote add upstream git@github.com:martanne/vis.git +git fetch upstream v0.9 +git status +git checkout v0.9 +git checkout upstream/v0.9 +git checkout -b v0.9 +git checkout master +git log +git branch -d v0.9 +git checkout refs/tags/v0.9 +carapace +cd vis +git remote +git fetch upstream v0.9 +ssh-add ~/.ssh/id_ed25519_sk +ls +git checkout upstream/refs/tags/v0.9 +git checkout upstream/v0.9 +git fetch upstream +git reset --hard v0.9 +git push -f +git clone git@github.com:ivi-vink/lua.git +cd .. +git clone git@github.com:ivi-vink/lua.git +cd lua/ +vis Makefile +man make +vis Makefile +ls +rm Makefile +cd .. +git clone git@github.com:pionative/pnsh.git +cd pnsh/ +ls +cd ~/sync/my/ +ls +cd ../.. +cd lua +cd /nix-config +ls +cd ~/sync/my/ +ls +cd +cd ~/sync/my/ +ls +cd notes +ls +cd .. +ls +vis Dockerfile.vis +ls +cat Dockerfile.vis +cd lua +ls +curl -L -R -O https://www.lua.org/ftp/lua-5.4.7.tar.gz +ls +tar zxf lua-5.4.7.tar.gz +ls +rm -rf lua-5.4.7/ +ls +tar zxf --strip-components 1 lua-5.4.7.tar.gz +tar -zxf --strip-components 1 lua-5.4.7.tar.gz +ls +tar -zxf lua-5.4.7.tar.gz --strip-components 1 +ls +rm lua-5.4.7.tar.gz +ls +git add . +git commit -m 'fetch tarball' +sed -i -e 's/^TO_LIB=.*/\0 liblua.so/' Makefile +git diff +sed -i -e 's/^CFLAGS.*/\0 -fPIC/' src/Makefile +git diff +sed -i -e '/^LUA_A=/a LUA_SO= liblua.so' src/Makefile +sed -i -e 's/^ALL_T=.*/\0 $(LUA_SO)/' src/Makefile +git diff +echo >> src/Makefile +^echo >> src/Makefile +bash +git diff +git add . +git commit -m 'patch to also compile shared object' +vis Makefile +man LD_LIBRARY_PATHERR +man LD_LIBRARY_PATH +ls /usr/lib +vis Makefile +virt-manager +ssh-add ~/.ssh/id_ed25519_sk +ssh 'root@192.168.122.159' +ssh 'root@192.168.122.158' +sed -i /192.168.122.158/d ~/.ssh/known_hosts +ssh 'root@192.168.122.158' +eval +ssh-add ~/.ssh/id_ed25519_sk +ssh-agent +$env.SSH_AUTH_SOCK = '/tmp/ssh-XXXXXXeXq31s/agent.30985' +ssh-add ~/.ssh/id_ed25519_sk +cd vis +cd .. +cd lua +ls +git push +ssh-add ~/.ssh/id_ed25519_sk +git push +ls +cd .. +git clone git@github.com:ivi-vink/luarocks.git +cd luarocks/ +ls +curl -L -R -O https://luarocks.github.io/luarocks/releases/luarocks-3.11.1.tar.gz +ls +tar -zxf luarocks-3.11.1.tar.gz --strip-components 1 +ls +rm luarocks-3.11.1.tar.gz +ls +cat configure +vis ./configure +ls +git add . +git commit -m 'fetch tarball' +git push +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.159:/opt/installer; TERM=xterm ssh root@192.168.122.159 +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.159:/opt/installer; TERM=xterm ssh root@192.168.122.158 +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.158:/opt/installer; TERM=xterm ssh root@192.168.122.158 +ssh 'ivi@192.168.122.158' +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.158:/opt/installer; TERM=xterm ssh root@192.168.122.158 +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.158:/opt; TERM=xterm ssh root@192.168.122.158 +vis Dockerfile.vis +cd /nix-config/ +git diff +cd +ls +ls larbs.sh +vis larbs.sh +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.158:/opt; TERM=xterm ssh root@192.168.122.158 +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.158:/opt; TERM=xterm ssh root@192.168.122.158 +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.158:/opt; TERM=xterm ssh root@192.168.122.158 bash +vis mvbs.sh +git add progs.csv +git status +git commit -m 'update progs' +git push +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.158:/opt; TERM=xterm ssh root@192.168.122.158 +cd /nix-config/ +vis mvbs.sh +cd +cd lua/ +ls +vi Makefile +git diff +ls +vi src/Makefile +git diff +make +vi src/Makefile +vi +git push +vis +cd /nix-config/ +ls +vis mvbs.sh +cd ~ +cd lua/ +ls +git push +cd - +cd /nix-config/ +ls +cd pnsh/ +ls +cd /nix-config/ +ls +cd sync my +vis mvbs.sh +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.158:/opt; TERM=xterm ssh root@192.168.122.158 +vi Dockerfile.vis +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.158:/opt; TERM=xterm ssh root@192.168.122.158 +cd +git add progs.csv +git commit -m 'update progs' +git push +cd /nix-config/ +scp /nix-config/mvbs.sh /nix-config/progs.csv root@192.168.122.158:/opt; TERM=xterm ssh root@192.168.122.158 +ls +git status +git diff progs.csv +git add progs.csv mvbs.sh +git commit -m 'update progs mvbs.sh' +git push +git status +git diff +cd /nix-config/ +git status +vis +vis progs.csv +cd /nix-config/ +virt-manager +cd /nix-config/ +ssh 'ivi@192.168.122.68' +ssh 'ivi@192.168.122.86' +ssh 'root@192.168.122.86' +ssh 'ivi@192.168.122.86' +LS +ls +ssh 'root@192.168.122.86' +ssh-copy-id +ssh-copy-id 'root@192.168.122.86' +ssh 'root@192.168.122.86' +ssh-agent +$env.SSH_AUTH_SOCK = "/tmp/ssh-XXXXXXiOxnW8/agent.21661" +ssh 'root@192.168.122.86' +TERM=xterm ssh 'root@192.168.122.86' +TERM=xterm scp /nix-config/progs.csv /nix-config/mvbs.sh 'root@192.168.122.86:/opt' +oksh +nix-shell -p oksh +e +vis +cd /nix-config/ +git status +tig +rm bash_carapace_completion +ls +git status +vis mut/nushell/config.nu +git diff +git add . +git commit -m 'update progs mvbs.sh' +git push +ls +rm tmp/tabbed-surf.xid +man git +ls +cd /nix-config/ +ls +cd +man git clone +mkdir .local/src +cd .local/src/ +ls +git clone git@github.com:ivi-vink/dotfiles.git +cd dotfiles/ +git checkout -b master --orphan +git checkout -b master --orphan origin +git checkout master --orphan origin +git checkout master --orphan +git checkout -b master --orphan +git checkout -b master --orphan origin/main +git checkout master --orphan origin/main +git checkout --orphan master +git status +git diff +git stat +git stattus +git status +git rm --cached . +git rm -r --cached . +git status +rm -rf * +ls +git status +vis .gitmodules +ls +mkdir -p .local/bin +mkdir .local/bin +cd /nix-config/ +ls +ls mut/ +cp -r /nix-config/mut/bin/* .local/bin +ls .local/bin +rm .local/bin/hs +rm .local/bin/choose +ls .local/bin +git add .local +git status +rm .gitmodules +vis .gitignore +rm .gitignore +vis .gitconfig +rm .gitconfig +git status +git add .local +git commit -m 'copy bin' +ls +mkdir .config +cp -r /nix-config/mut/aerospace .config +cp -r /nix-config/mut/carapace .config +cp -r /nix-config/mut/dwmblocks .config +cp -r /nix-config/mut/ghostty/ .config +cp -r /nix-config/mut/k9s .config +cp -r /nix-config/mut/neovim/* .config/nvim +mkdir .config/nvim +cp -r /nix-config/mut/neovim/* .config/nvim +ls .config/nvim/ +cp -r /nix-config/mut/wal .config +cp -r /nix-config/mut/emacs .config +ls .config/emacs/ +cp -r /nix-config/mut/git .config +ls .config/git/ +open .config/git/config +vis .config/git/config +cp -r /nix-config/mut/lf .config +ls diff --git a/.config/nushell/login.nu b/.config/nushell/login.nu new file mode 100644 index 0000000..4ca972e --- /dev/null +++ b/.config/nushell/login.nu @@ -0,0 +1,14 @@ +def load-posix-env [p: string] { + bash -c $"source ($p) && env" + | lines + | parse "{n}={v}" + | filter { |x| ($x.n not-in $env) or $x.v != ($env | get $x.n) } + | where n not-in ["_", "LAST_EXIT_CODE", "DIRS_POSITION"] + | transpose --header-row + | into record + | load-env +} + +load-posix-env /etc/profile +# load-posix-env $"($env.HOME)/.profile" +$env.PATH = $env.PATH ++ [$"($env.HOME)/.local/bin"] diff --git a/.config/nushell/scripts/task.nu b/.config/nushell/scripts/task.nu new file mode 100644 index 0000000..6c7968b --- /dev/null +++ b/.config/nushell/scripts/task.nu @@ -0,0 +1,434 @@ +# Spawn a task to run in the background, even when the shell is closed. +# +# Note that a fresh Nushell interpreter is spawned to execute the +# given task, so it won't inherit the current scope's variables, +# custom commands and alias definitions. +# +# It will only inherit environment variables which can be converted to a string. +# +# Note that the closure can't take arguments. +# +# Example usage: task spawn { echo "Hello, World!" } +export def spawn [ + command: closure # The closure to run. + --working-directory (-w): directory # Specify the working directory the task will be run in. + --immediate (-i) # Immediately start the task. + --stashed (-s) # Create the task in Stashed state. Useful to avoid immediate execution if the queue is empty + --delay (-d): duration # Queue the task for execution only after the duration. + --group (-g): string # The group to spawn the task under. + --after (-a): int # Start the task once all specified tasks have successfully finished. As soon as one of the dependencies fails, this task will fail as well. + --priority (-o): string # Start this task with a higher priority. The higher the number, the faster it will be processed. + --label (-l): string # Label the task. This string will be shown in the `status` column of `task status`. +] -> int { + mut args = [] + + if $working_directory != null { + $args = ($args | prepend ["--working-directory", $working_directory]) + } + if $immediate { + $args = ($args | prepend "--immediate") + } + if $stashed { + $args = ($args | prepend "--stashed") + } + if $delay != null { + $args = ($args | prepend ["--delay" ($delay | format duration sec | parse "{secs} {_}" | get 0.secs)]) + } + if $group != null { + $args = ($args | prepend ["--group" $group]) + } + if $after != null { + $args = ($args | prepend ["--after" $after]) + } + if $priority != null { + $args = ($args | prepend ["--priority" $priority]) + } + if $label != null { + $args = ($args | prepend ["--label" $label]) + } + + let source_path = mktemp --tmpdir --suffix "-nu-task" + + ( + view source $command + | str trim --left --char "{" + | str trim --right --char "}" + ) + | save --force $source_path + + (pueue add --print-task-id ...$args $"nu --config '($nu.config-path)' --env-config '($nu.env-path)' ($source_path)") +} + +# Remove tasks from the queue. +# Running or paused tasks need to be killed first. +export def remove [ + ...ids: int # IDs of the tasks to remove from the status list. +] { + pueue remove ...$ids +} + +# Switches the queue position of two tasks. +# Only works for queued or stashed tasks. +export def switch [ + task_id_1: int # The first task ID. + task_id_2: int # The second task ID. +] { + pueue switch $task_id_1 $task_id_2 +} + +# Stash a task that is not currently running. +# +# Stashed tasks won't be automatically started. +# You will have to queue them or start them by hand. +export def stash [ + ...ids: int # IDs of the tasks to stash. +] { + pueue stash ...$ids +} + +# Queue stashed tasks for execution. +export def queue [ + ...ids: int # IDs of the tasks to queue. + --delay (-d): duration # Queue only after the specified delay. +] { + let args = if $delay != null { + ["--delay" ($delay | format duration sec | parse '{secs} {_}' | get 0.secs)] + } else { + [] + } + + pueue enqueue ...$args ...$ids +} + +# Resume operation of specific tasks or groups of tasks. +# +# By default, this resumes the default group and all its tasks. +# It can also be used force-start specific tasks or start whole groups. +export def start [ + ...ids: int # IDs of the tasks to start. By default all the tasks in the default group will be started. + --group (-g): string # Resume a specific group and all paused tasks in it. The group will be set to running and its paused tasks will be resumed. + --all (-a) # Resume all groups. All groups will be set to running and paused tasks will be resumed. +] { + mut args = [] + + if $group != null { + $args = ($args | prepend ["--group" $group]) + } + if $all { + $args = ($args | prepend "--all") + } + + pueue start ...$args +} + +# Restart failed or successful task(s). +# +# By default, identical tasks will be created and +# enqueued, but it's possible to restart in-place. +# +# You can also edit a few properties, such as +# the path and the command of the task, before restarting. +export def restart [ + ...ids: int # IDs of the tasks to restart. + --all-failed (-a) # Restart all failed tasks across all groups. Nice to use in combination with `--in-place/i`. + --failed-in-group (-g): string # Like `--all-failed`, but only restart tasks failed tasks of a specific group. The group will be set to running and its paused tasks will be resumed. + --start-immediately (-k) # Immediately start the tasks, no matter how many open slots there are. This will ignore any dependencies tasks may have. + --stashed (-s) # Set the restarted task to a "Stashed" state. Useful to avoid immediate execution. + --in-place (-i) # Restart the tasks by reusing the already existing tasks. + --not-in-place (-n) # Opposite of `--in-place`. This is already the default unless you have `restart_in_place` set to true. + --edit (-e) # Edit the tasks' commands before restarting + --edit-path (-p) # Edit the tasks' paths before restarting + --edit-label (-l) # Edit the tasks' labels before restarting +] { + mut args = [] + + if $all_failed { + $args = ($args | prepend "--all-failed") + } + if $failed_in_group != null { + $args = ($args | prepend "--failed-in-group") + } + if $start_immediately { + $args = ($args | prepend "--start-immediately") + } + if $stashed { + $args = ($args | prepend "--stashed") + } + if $in_place { + $args = ($args | prepend "--in-place") + } + if $not_in_place { + $args = ($args | prepend "--not-in-place") + } + if $edit { + $args = ($args | prepend "--edit") + } + if $edit_path { + $args = ($args | prepend "--edit-path") + } + if $edit_label { + $args = ($args | prepend "--edit-label") + } + + pueue restart ...$args ...$ids +} + +# Either pause a running tasks or a specific groups of tasks. +# +# By default, pauses the default group and all its tasks. +# +# A paused group won't start any new tasks automatically. +export def pause [ + ...ids: int # IDs of the tasks to pause. + --group (-g) # Pause a specific group + --all (-a) # Pause all groups. + --wait (-w) # Only pause the specified group and let already running tasks finish by themselves +] { + mut args = [] + + if $group != null { + $args = ($args | prepend "--group") + } + if $all != null { + $args = ($args | prepend "--all") + } + if $wait != null { + $args = ($args | prepend "--wait") + } + + pueue pause ...$args ...$ids +} + +# Kill specific running tasks or whole task groups. +# +# Kills all tasks of the default group when no ids or a specific group are provided. +export def kill [ + ...ids: int # IDs of the tasks to kill. + --group (-g): string # Kill all running tasks in a group. This also pauses the group. + --all (-a) # Kill all running tasks across ALL groups. This also pauses all groups. + --signal (-s): string # Send a UNIX signal instead of simply killing the process. DISCLAIMER: This bypasses Pueue's process handling logic! You might enter weird invalid states, use at your own descretion. +] { + mut args = [] + + if $group != null { + $args = ($args | prepend ["--group" $group]) + } + if $all { + $args = ($args | prepend "--all") + } + if $signal != null { + $args = ($args | prepend ["--signal" $signal]) + } + + pueue kill ...$args ...$ids +} + +# Send something to a task. Useful for sending confirmations such as "y\n". +export def send [ + id: int # ID of the task to send something to. + input: string # The input that should be sent to the process. +] { + pueue send $id $input +} + +# Edit the command, path or label of a stashed or queued task. +# +# By default only the command is edited. +# +# Multiple properties can be added in one go. +export def edit [ + id: int # ID of the task to edit. + --command (-c) # Edit the task's command + --path (-p) # Edit the task's path + --label (-l) # Edit the task's label +] { + mut args = [] + + if $command { + $args = ($args | prepend "--command") + } + if $path { + $args = ($args | prepend "--path") + } + if $label { + $args = ($args | prepend "--label") + } + + pueue edit ...$args $id +} + +# Use this to add or remove groups. +# +# By default, this will simply display all known groups. +export def group [] { + pueue group --json | from json +} + +# Create a new group with a name. +export def "group add" [ + name: string # The name of the new group. + --parallel (-p): int # The amount of parallel tasks the group can run at one time. +] { + let args = if $parallel != null { + ["--parallel" $parallel] + } else { + [] + } + + pueue group add ...$args $name +} + +# Remove a group with a name. +export def "group remove" [ + name: string # The name of the group to be removed. +] { + pueue group remove $name +} + +# Display the current status of all tasks. +export def status [ + --detailed (-d) # Return a table with more detailed information. +] { + let output = ( + pueue status --json + | from json + | get tasks + | transpose --ignore-titles status + | flatten + ) + + # TODO: Rename the Done column to done. + if not $detailed { + $output | select id label group Done? status? start? end? + } else { + $output + } +} + +# Display the output of tasks. +# +# Only the last few lines will be shown by default for multiple tasks. +# If you want to follow the output, use `--tail/-t`. +export def log [ + ...ids: int # The tasks to check the outputs of. + --last (-l): int # Only print the last N lines of each task's output. This is done by default if you're looking at multiple tasks. + --tail (-t) # Follow the output as it is printing. Only works with 1 task. When used in conjunction with `--last`, the last N lines will be printed before starting to wait for output. + --detailed (-d) # Include all fields, don't simplify output. +] { + def process_raw [raw: string] { + let full = ( + $raw + | from json + | transpose -i info + | flatten --all + | flatten --all + ) + + if $detailed { + $full + } else { + $full | select id label group Done? status? start? end? + } + } + + if (($ids | length) == 1) { + if $tail { + let args = if $last != null { + ["--lines" $last] + } else { + [] + } + + pueue follow ...$ids + } else { + let args = if $last != null { + ["--lines" $last] + } else { + [] + } + + process_raw (pueue log --full --json ...$args ...$ids) + | first + } + } else { + if $tail { + echo $"(ansi red)--tail can only be used with one task.(ansi reset)" + return + } + + let args = if $last != null { + ["--lines" $last] + } else { + [] + } + + process_raw (pueue log --full --json ...$args ...$ids) + } +} + +# Wait until the provided tasks are finished. +# +# This is like join() or await in many languages. +export def wait [ + ...ids: int # IDs of the tasks to wait for. + --group (-g): string # Wait for all tasks in a specific group. + --all (-a) # Wait for all tasks across all groups and the default group. + --quiet (-q) # Don't show any log output while waiting. + --status (-s): string # Wait for tasks to reach a specific task status. +] { + mut args = [] + + if $group != null { + $args = ($args | prepend ["--group" $group]) + } + if $all { + $args = ($args | prepend $all) + } + if $quiet { + $args = ($args | prepend $quiet) + } + if $status != null { + $args = ($args | prepend ["--status" $status]) + } + + pueue wait ...$args ...$ids +} + +# Remove tasks from the status list. +export def clean [ + --successful-only (-s) # Only clean tasks that finished successfully + --group (-g): string # Only clean tasks of a specific group +] { + mut args = [] + + if $successful_only { + $args = ($args | prepend "--successful-only") + } + if $group != null { + $args = ($args | prepend ["--group" $group]) + } + + pueue clean ...$args +} + +# Shutdown pueue and thus this module. +export def shutdown [] { + pueue shutdown +} + +# Set the maximum parallel tasks for a group. +# +# Note that no tasks will be stopped if the number is lowered. +# The limit only applies when schelduing. +export def set-parallel-limit [ + max: int # The maximum parallel tasks allowed for a group when schelduing. + --group (-g): string # The group to set the limit for. By default this is `default`. +] { + let args = if $group != null { + ["--group" $group] + } else { + [] + } + + pueue parallel ...$args $max +} diff --git a/.config/nvim/README.md b/.config/nvim/README.md new file mode 100644 index 0000000..3a441bd --- /dev/null +++ b/.config/nvim/README.md @@ -0,0 +1,2 @@ +# mike_neovim +installs my neovim config on mac or linux diff --git a/.config/nvim/after/queries/nu/highlights.scm b/.config/nvim/after/queries/nu/highlights.scm new file mode 100644 index 0000000..55b04ed --- /dev/null +++ b/.config/nvim/after/queries/nu/highlights.scm @@ -0,0 +1,313 @@ +;;; --- +;;; keywords +[ + "def" + "alias" + "export-env" + "export" + "extern" + "module" + + "let" + "let-env" + "mut" + "const" + + "hide-env" + + "source" + "source-env" + + "overlay" + "register" + + "loop" + "while" + "error" + + "do" + "if" + "else" + "try" + "catch" + "match" + + "break" + "continue" + "return" + +] @keyword + +(hide_mod "hide" @keyword) +(decl_use "use" @keyword) + +(ctrl_for + "for" @keyword + "in" @keyword +) +(overlay_list "list" @keyword.storage.modifier) +(overlay_hide "hide" @keyword.storage.modifier) +(overlay_new "new" @keyword.storage.modifier) +(overlay_use + "use" @keyword.storage.modifier + "as" @keyword +) +(ctrl_error "make" @keyword.storage.modifier) + +;;; --- +;;; literals +(val_number) @number +(val_duration unit: _ @variable.parameter) +(val_filesize unit: _ @variable.parameter) +(val_binary + [ + "0b" + "0o" + "0x" + ] @number + "[" @punctuation.bracket + digit: [ + "," @punctuation.delimiter + (hex_digit) @number + ] + "]" @punctuation.bracket +) @number +(val_bool) @constant.builtin +(val_nothing) @constant.builtin +(val_string) @variable.parameter +arg_str: (val_string) @variable.parameter +file_path: (val_string) @variable.parameter +(val_date) @number +(inter_escape_sequence) @constant.character.escape +(escape_sequence) @constant.character.escape +(val_interpolated [ + "$\"" + "$\'" + "\"" + "\'" +] @string) +(unescaped_interpolated_content) @string +(escaped_interpolated_content) @string +(expr_interpolated ["(" ")"] @variable.parameter) + +;;; --- +;;; operators +(expr_binary [ + "+" + "-" + "*" + "/" + "mod" + "//" + "++" + "**" + "==" + "!=" + "<" + "<=" + ">" + ">=" + "=~" + "!~" + "and" + "or" + "xor" + "bit-or" + "bit-xor" + "bit-and" + "bit-shl" + "bit-shr" + "in" + "not-in" + "starts-with" + "ends-with" +] @operator ) + +(where_command [ + "+" + "-" + "*" + "/" + "mod" + "//" + "++" + "**" + "==" + "!=" + "<" + "<=" + ">" + ">=" + "=~" + "!~" + "and" + "or" + "xor" + "bit-or" + "bit-xor" + "bit-and" + "bit-shl" + "bit-shr" + "in" + "not-in" + "starts-with" + "ends-with" +] @operator) + +(assignment [ + "=" + "+=" + "-=" + "*=" + "/=" + "++=" +] @operator) + +(expr_unary ["not" "-"] @operator) + +(val_range [ + ".." + "..=" + "..<" +] @operator) + +["=>" "=" "|"] @operator + +[ + "o>" "out>" + "e>" "err>" + "e+o>" "err+out>" + "o+e>" "out+err>" +] @operator + +;;; --- +;;; punctuation +[ + "," + ";" +] @punctuation.special + +(param_long_flag ["--"] @punctuation.delimiter) +(long_flag ["--"] @punctuation.delimiter) +(long_flag_equals_value ["--"] @punctuation.delimiter) +(short_flag ["-"] @punctuation.delimiter) +(long_flag_equals_value ["="] @punctuation.special) +(param_short_flag ["-"] @punctuation.delimiter) +(param_rest "..." @punctuation.delimiter) +(param_type [":"] @punctuation.special) +(param_value ["="] @punctuation.special) +(param_cmd ["@"] @punctuation.special) +(param_opt ["?"] @punctuation.special) +(returns "->" @punctuation.special) + +[ + "(" ")" + "{" "}" + "[" "]" +] @punctuation.bracket + +(val_record + (record_entry ":" @punctuation.delimiter)) +key: (identifier) @property + +;;; --- +;;; identifiers +(param_rest + name: (_) @variable.parameter) +(param_opt + name: (_) @variable.parameter) +(parameter + param_name: (_) @variable.parameter) +(param_cmd + (cmd_identifier) @string) + +(param_long_flag (long_flag_identifier) @attribute) +(param_short_flag (param_short_flag_identifier) @attribute) + +(short_flag (short_flag_identifier) @attribute) +(long_flag_identifier) @attribute + +(scope_pattern [(wild_card) @function]) + +(cmd_identifier) @function +; generated with Nu 0.93.0 +; > help commands +; | filter { $in.command_type == builtin and $in.category != core } +; | each {$'"($in.name | split row " " | $in.0)"'} +; | uniq +; | str join ' ' +(command + head: [ + (cmd_identifier) @function.builtin + (#any-of? @function.builtin + "all" "ansi" "any" "append" "ast" "bits" "bytes" "cal" "cd" "char" "clear" + "collect" "columns" "compact" "complete" "config" "cp" "date" "debug" + "decode" "default" "detect" "dfr" "drop" "du" "each" "encode" "enumerate" + "every" "exec" "exit" "explain" "explore" "export-env" "fill" "filter" + "find" "first" "flatten" "fmt" "format" "from" "generate" "get" "glob" + "grid" "group" "group-by" "hash" "headers" "histogram" "history" "http" + "input" "insert" "inspect" "interleave" "into" "is-empty" "is-not-empty" + "is-terminal" "items" "join" "keybindings" "kill" "last" "length" + "let-env" "lines" "load-env" "ls" "math" "merge" "metadata" "mkdir" + "mktemp" "move" "mv" "nu-check" "nu-highlight" "open" "panic" "par-each" + "parse" "path" "plugin" "port" "prepend" "print" "ps" "query" "random" + "range" "reduce" "reject" "rename" "reverse" "rm" "roll" "rotate" + "run-external" "save" "schema" "select" "seq" "shuffle" "skip" "sleep" + "sort" "sort-by" "split" "split-by" "start" "stor" "str" "sys" "table" + "take" "tee" "term" "timeit" "to" "touch" "transpose" "tutor" "ulimit" + "uname" "uniq" "uniq-by" "update" "upsert" "url" "values" "view" "watch" + "where" "which" "whoami" "window" "with-env" "wrap" "zip" + ) + ]) + +(command + "^" @punctuation.delimiter + head: (_) @function +) + +"where" @function.builtin + +(path + ["." "?"] @punctuation.delimiter +) @variable.parameter + +(stmt_let (identifier) @variable) + +(val_variable + "$" @punctuation.special + [ + (identifier) @variable + "in" @special + "nu" @namespace + "env" @constant + ] +) @none + +(record_entry + ":" @punctuation.special) + +;;; --- +;;; types +(flat_type) @type +(list_type + "list" @type.enum + ["<" ">"] @punctuation.bracket +) +(collection_type + ["record" "table"] @type.enum + "<" @punctuation.bracket + key: (_) @variable.parameter + ["," ":"] @punctuation.special + ">" @punctuation.bracket +) + +(shebang) @keyword.directive +(comment) @comment +( + (comment) @comment.documentation + (decl_def) +) +( + (parameter) + (comment) @comment.documentation +) diff --git a/.config/nvim/after/queries/nu/indents.scm b/.config/nvim/after/queries/nu/indents.scm new file mode 100644 index 0000000..488772a --- /dev/null +++ b/.config/nvim/after/queries/nu/indents.scm @@ -0,0 +1,25 @@ +[ + (expr_parenthesized) + (parameter_bracks) + + (val_record) + (val_list) + (val_closure) + (val_table) + + (block) +] @indent.begin + +[ + "}" + "]" + ")" +] @indent.end + +[ + "}" + "]" + ")" +] @indent.branch + +(comment) @indent.auto diff --git a/.config/nvim/after/queries/nu/injections.scm b/.config/nvim/after/queries/nu/injections.scm new file mode 100644 index 0000000..30804d6 --- /dev/null +++ b/.config/nvim/after/queries/nu/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment"))
\ No newline at end of file diff --git a/.config/nvim/compiler/ansible-lint.vim b/.config/nvim/compiler/ansible-lint.vim new file mode 100644 index 0000000..9427092 --- /dev/null +++ b/.config/nvim/compiler/ansible-lint.vim @@ -0,0 +1,11 @@ +if exists('current_compiler') + finish +endif +let current_compiler = 'go-test' + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal <args> +endif + +CompilerSet makeprg=compile\ ansible-lint +CompilerSet errorformat=%Z%f:%l\ %m,%Z%f:%l,%E%\\%%(%\\S%\\)%\\@=%m,%C%\\%%(%\\S%\\)%\\@=%m,%-G diff --git a/.config/nvim/compiler/go-test.vim b/.config/nvim/compiler/go-test.vim new file mode 100644 index 0000000..61442e5 --- /dev/null +++ b/.config/nvim/compiler/go-test.vim @@ -0,0 +1,14 @@ +if exists('current_compiler') + finish +endif +let current_compiler = 'go-test' + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal <args> +endif + +" %f>%l:%c:%t:%n:%m +CompilerSet makeprg=go\ test +CompilerSet errorformat=%.%#:\ %m\ %f:%l,%.%#:\ %m\ at\ %f:%l%.%#, + +" vim: sw=2 sts=2 et diff --git a/.config/nvim/compiler/helm.vim b/.config/nvim/compiler/helm.vim new file mode 100644 index 0000000..7e4b21d --- /dev/null +++ b/.config/nvim/compiler/helm.vim @@ -0,0 +1,14 @@ +if exists('current_compiler') + finish +endif +let current_compiler = 'go-test' + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal <args> +endif + +CompilerSet makeprg=compile\ helm\ lint +CompilerSet errorformat=\[%t%.%#\]%.%#\ template:\ %f:%l:%c:\ %m, + \\[%t%.%#\]\ %f:\ %m, + +" vim: sw=2 sts=2 et diff --git a/.config/nvim/compiler/nix.lua b/.config/nvim/compiler/nix.lua new file mode 100644 index 0000000..d012641 --- /dev/null +++ b/.config/nvim/compiler/nix.lua @@ -0,0 +1 @@ +vim.opt.errorformat = [[%.%#at %f:%l:%c%.%#,%mat %f:%l:%c,%.%#error:%.%#'%f': %m,]] diff --git a/.config/nvim/compiler/racket.vim b/.config/nvim/compiler/racket.vim new file mode 100644 index 0000000..1f98a41 --- /dev/null +++ b/.config/nvim/compiler/racket.vim @@ -0,0 +1,26 @@ +if exists('current_compiler') + finish +endif +let current_compiler = 'go-test' + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal <args> +endif + +" The errorformat can also use vim's regular expression syntax (albeit in a rather awkward way) which gives us a solution to the problem. We can use a non-capturing group and a zero-width assertion to require the presence of these signaling phrases without consuming them. This then allows the %m to pick them up. As plain regular expression syntax this zero-width assertion looks like: +" +" \%(undefined reference\|multiple definition\)\@= +" +" But in order to use it in efm we need to replace \ by %\ and % by %% + + +CompilerSet makeprg=compile\ racket +CompilerSet errorformat=\%Z%*\\S%.%#, + \%C\ \ \ %f:%l:%c, + \%C\ \ \ %f:%l:%c:\ %m, + \%C\ \ %.%#%\\%%(module%\\spath:%\\\|at\:%\\\|in\:%\\\|expected\:%\\\|given\:%\\)%\\@=%m, + \%C\ %.%#, + \%E%\\%%(%\\w%\\)%\\@=%f:%*\\d:%*\\d:\ %m, + \%E%*\\f:%*\\d:%*\\d:\ %m, + \%E%\\%%(%\\S%\\+:%\\\|%\.%\\+--%\\)%\\@=%m, +" vim: sw=2 sts=2 et diff --git a/.config/nvim/compiler/rust.lua b/.config/nvim/compiler/rust.lua new file mode 100644 index 0000000..272ae18 --- /dev/null +++ b/.config/nvim/compiler/rust.lua @@ -0,0 +1 @@ +vim.opt.errorformat=[[%-G,%-Gerror: aborting %.%#,%-Gerror: Could not compile %.%#,%Eerror: %m,%Eerror[E%n]: %m,%Wwarning: %m,%Inote: %m,%C %#--> %f:%l:%c,%E left:%m,%C right:%m %f:%l:%c,%Z]] diff --git a/.config/nvim/compiler/terragrunt.vim b/.config/nvim/compiler/terragrunt.vim new file mode 100644 index 0000000..54f94ef --- /dev/null +++ b/.config/nvim/compiler/terragrunt.vim @@ -0,0 +1,21 @@ +if exists('current_compiler') + finish +endif +let current_compiler = 'go-test' + +if exists(':CompilerSet') != 2 + command -nargs=* CompilerSet setlocal <args> +endif + +" The errorformat can also use vim's regular expression syntax (albeit in a rather awkward way) which gives us a solution to the problem. We can use a non-capturing group and a zero-width assertion to require the presence of these signaling phrases without consuming them. This then allows the %m to pick them up. As plain regular expression syntax this zero-width assertion looks like: +" +" \%(undefined reference\|multiple definition\)\@= +" +" But in order to use it in efm we need to replace \ by %\ and % by %% + + +CompilerSet makeprg=terragrunt +CompilerSet errorformat=%.%#level=%t%.%#msg=%f:%l%\\,%c-%*\\d:\ %m, + \%Z%m, + \%E-\ %m\ (at\ %f:%l\\,%c-%*\\d), +" vim: sw=2 sts=2 et diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..7da402c --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1 @@ +return require("my")
\ No newline at end of file diff --git a/.config/nvim/lua/my/events.lua b/.config/nvim/lua/my/events.lua new file mode 100644 index 0000000..933ba19 --- /dev/null +++ b/.config/nvim/lua/my/events.lua @@ -0,0 +1,120 @@ +local lsp = require("my.lsp") +local oil = require("oil") +local lint = require("lint") +local event = vim.api.nvim_create_autocmd +local command = vim.api.nvim_create_user_command + +vim.api.nvim_create_augroup("my", {clear= true}) +vim.api.nvim_create_augroup("conf#events", {clear= true}) + +event( + "User", + {group= "conf#events", + pattern= { "ZoxideDirChanged" }, + callback= function() + vim.schedule(function() + oil.open(vim.fn.getcwd()) + end) + end}) + +event( + "BufReadPost", + {group= "conf#events", + pattern= { "*" }, + callback=function() + local pattern = "'\\s\\+$'" + vim.cmd("syn match TrailingWhitespace " .. pattern) + vim.cmd("hi link TrailingWhitespace IncSearch") + end}) + +event( + "BufWritePost", + {group= "conf#events", + pattern={ "*" }, + callback=function() + lint.try_lint() + vim.schedule(function() vim.diagnostic.setloclist({open= false}) end) + end}) + +local session_file = vim.fn.expand("~/.vimsession.vim") +event( + "VimLeave", + {group= "conf#events", + pattern= { "*" }, + callback=function() + vim.cmd("mksession! " .. session_file) + end}) + +event( + "LspAttach", + {group = "conf#events", + pattern = { "*" }, + callback = function(ev) + lsp.attach({ + client = vim.lsp.get_client_by_id(ev.data.client_id), + buf = ev.buf, + }) + end}) + +event( + "LspAttach", + {group = "conf#events", + pattern = { "*" }, + callback = function(ev) + lsp.attach({ + client = vim.lsp.get_client_by_id(ev.data.client_id), + buf = ev.buf, + }) + end}) + +-- filetypes + +event( + "FileType", { + group="conf#events", + pattern={ "go", "gomod", "gowork", "gotmpl" }, + callback=function(ev) + vim.lsp.start({ + name="gopls", + cmd={ "gopls" }, + root_dir=vim.fs.root(ev.buf, {"go.work", "go.mod", ".git"}) + }) + end, + }) + +event( + "FileType", { + group="conf#events", + pattern={ "python" }, + callback=function(ev) + vim.lsp.start({ + name="basedpyright", + cmd={ "basedpyright-langserver", "--stdio" }, + settings={ + basedpyright = { + analysis = { + autoSearchPaths = true, + diagnosticMode = "openFilesOnly", + useLibraryCodeForTypes = true, + autoImportCompletions = true, + inlayHints = { + variableTypes = true, + callArgumentNames = true, + functionReturnTypes = true, + genericTypes = true, + }, + }, + }, + }, + root_dir=vim.fs.root(ev.buf, { + 'pyproject.toml', + 'setup.py', + 'setup.cfg', + 'requirements.txt', + 'Pipfile', + 'pyrightconfig.json', + '.git', + }) + }) + end, + }) diff --git a/.config/nvim/lua/my/init.lua b/.config/nvim/lua/my/init.lua new file mode 100644 index 0000000..76bf1f0 --- /dev/null +++ b/.config/nvim/lua/my/init.lua @@ -0,0 +1,550 @@ +require("my.settings") +_G.P = function(...) + vim.iter({...}):map(vim.inspect):each(print) +end +_G.ternary = function ( cond , T , F ) + if cond then return T else return F end +end +vim.cmd "colorscheme kanagawa-wave" + +vim.cmd "filetype plugin on" +vim.cmd "filetype indent on" +vim.cmd "highlight WinSeparator guibg=None" +vim.cmd "packadd cfilter" + +vim.api.nvim_set_hl(0, "VirtualTextWarning", {link= "Grey"}) +vim.api.nvim_set_hl(0, "VirtualTextError", {link= "DiffDelete"}) +vim.api.nvim_set_hl(0, "VirtualTextInfo", {link= "DiffChange"}) +vim.api.nvim_set_hl(0, "VirtualTextHint", {link= "DiffAdd"}) +vim.diagnostic.config({virtual_text = false, virtual_lines = { highlight_whole_line = false, only_current_line = true } }) + +local map = vim.keymap.set +local unmap = vim.keymap.del +function i_grep(word, file) + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes( + ":silent grep " + .. ternary(not (word == ""), word .. " ", "") + .. file:gsub("oil://", "") + .. "<c-f>B<left>i<space>", + true, false, true + ), + "n", false + ) +end + +function cope() + require("quicker").refresh() + vim.cmd(":botright copen " .. math.floor(vim.o.lines / 2.1)) +end + +map("n", "gb", ":GBrowse<CR>") +map("n", "g<cr>", ":G<cr>") +map("n", "ge", function() vim.diagnostic.open_float() end) +map("n", "-", ":Oil<cr>") +map("n", "<leader>qf", cope) +map("n", "<leader>q<BS>", ":cclose<cr>") +map("n", "<leader>ll", ":lopen<cr>") +map("n", "<leader>l<BS>", ":lclose<cr>") +map("n", "<M-h>", cope) +map("n", "<C-n>", ":cnext<cr>") +map("n", "<C-p>", ":cprev<cr>") +map("n", "<C-a>", ":Rerun<CR>") +map("n", "<C-s>", function() + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes( + ":Sh<up><c-f>", + true, false, true + ), + "n", false + ) + vim.schedule(function() + vim.cmd("let v:searchforward = 0") + map("n","/","/Sh.*",{buffer=true}) + map("n","?","?Sh.*",{buffer=true}) + end) +end) +map("n", "<C-x>", function() + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes( + ":Compile<up><c-f>", + true, false, true + ), + "n", false + ) + vim.schedule(function() + vim.cmd("let v:searchforward = 0") + map("n","/","/Compile.*",{buffer=true}) + map("n","?","?Compile.*",{buffer=true}) + end) +end) +map("n", "[q",":cprevious<cr>") +map("n", "]q",":cnext<cr>") +map("n", "[x",":lprevious<cr>") +map("n", "]x",":lnext<cr>") +map("n", "[g",":GV<cr>") +map("n", "]g",":GV?<cr>") +map("n", "]G",":GV!<cr>") +map("n", "<leader>:", function() i_grep("<c-r><c-w>", vim.fn.bufname("%")) end) +map("v", "<leader>:", ":Vgrep!<cr>") +map("n", "<leader>;", function() i_grep("", vim.fn.fnamemodify(vim.fn.bufname("%"), ":h")) end) +map("v", "<leader>;", ":Vgrep<cr>") +map("n", "<leader>'", ":Find ") +map("n", "<leader>x<cr>", function() vim.cmd "b #" end) + +require("nvim_comment").setup() + +local oil_actions = require("oil.actions") +map("n", "_", oil_actions.open_cwd.callback) + +local fzf = require("fzf-lua") +local action = (require "fzf-lua.actions") +fzf.setup {"max-perf"} +fzf.register_ui_select() +map("n", "<leader>xp", fzf.files) +map("n", "<leader>xa", fzf.args) +map("n", "<leader>x;", fzf.quickfix) +map("n", "<leader>xb", function() + fzf.buffers({ + actions={default={fn=action.buf_edit_or_qf}} + }) +end) + +local obsidian = require("obsidian") +obsidian.setup { workspaces = { + { name = "notes", path = ternary(vim.fn.isdirectory(vim.fn.expand("~/Sync/my/notes")) == 1, "~/Sync/my/notes", "~/sync/my/notes")} +}} + + +vim.api.nvim_create_user_command( + "Vgrep", +function(cmd) + local buf, lrow, lcol = unpack(vim.fn.getpos("'<")) + local buf, rrow, rcol = unpack(vim.fn.getpos("'>")) + -- (local [line & rest] (vim.api.nvim_buf_get_text 0 (- <row 1) (- <col 1) (- >row 1) >col {})) + local firstline = + vim.iter(vim.api.nvim_buf_get_text(0, lrow-1, lcol-1, rrow-1, rcol, {})) + :next() + if cmd.bang then + i_grep(firstline, vim.fn.bufname("%")) + else + i_grep(firstline, vim.fn.fnamemodify(vim.fn.bufname("%"), ":h")) + end +end, + {range= 1, bang=true} +) + +vim.api.nvim_create_user_command( + "NixEdit", +function(cmd) + local f = io.popen("nix eval --raw /nix-config#nixosConfigurations." .. vim.fn.hostname() .. ".pkgs." .. cmd.args) + vim.cmd("e " .. f:read()) +end, + {nargs=1} +) + + +local last_job_state = nil +local last_job_thunk = nil +local last_job_lines = "" +function qf(inputs, opts) + local id, title = inputs.id, inputs.title + local prettify = function(line) + local l = line:gsub("%c+%[[0-9:;<=>?]*[!\"#$%%&'()*+,-./]*[@A-Z%[%]^_`a-z{|}~]*;?[A-Z]?", "") + return l + end + local in_qf = function() + return vim.opt_local.buftype:get() == "quickfix" + end + local is_at_last_line = function() + local row, _ = vim.api.nvim_win_get_cursor(0) + local last_line = vim.api.nvim_buf_line_count(0) + return row == last_line + end + return function(lines) + lines = vim.iter(lines):map(prettify):totable() + vim.schedule(function() + local what = { + id=id, + title=title, + lines=lines, + efm=opts.efm, + } + vim.fn.setqflist( + {}, "a", what + ) + if (not in_qf()) or (is_at_last_line() and in_qf()) then + vim.cmd ":cbottom" + end + end) + end +end + +function qfjob(cmd, stdin, opts) + last_job_lines = "" + local opts = opts or {} + opts.filter = opts.filter or (function(line) + return line + end) + + local title = table.concat(cmd, " ") + vim.fn.setqflist({}, " ", {title=title}) + local append_lines = qf(vim.fn.getqflist({id=0,title=1}), opts) + last_job_state = vim.system( + cmd, { + stdin=stdin, + stdout=function(err,data) + if data then + if not opts.buffer then + append_lines(vim.iter(data:gmatch("[^\n]+")):map(opts.filter)) + else + last_job_lines = last_job_lines .. data + end + end + end, + stderr=function(err,data) + if data then + if not opts.buffer then + append_lines(vim.iter(data:gmatch("[^\n]+")):map(opts.filter)) + else + last_job_lines = last_job_lines .. data + end + end + end, + }, + function(job) + vim.schedule(function() + if opts.buffer then + append_lines(vim.iter(last_job_lines:gmatch("[^\n]+")):map(opts.filter)) + end + + local winnr = vim.fn.winnr() + if not (job.code == 0) then + cope() + if not (winnr == vim.fn.winnr()) then + vim.notify([["]] .. title .. [[" failed!]]) + vim.cmd "wincmd p | cbot" + end + else + if opts.open then + cope() + end + vim.notify([["]] .. title .. [[" succeeded!]]) + end + end) + end) +end + +vim.api.nvim_create_user_command( + "Find", + function(cmd) + local bufs = vim.iter(vim.api.nvim_list_bufs()) + :fold({}, function(acc, b) + acc[vim.api.nvim_buf_get_name(b)] = vim.api.nvim_buf_get_mark(b, [["]]) + return acc + end) + qfjob({ "fdfind", "--absolute-path", "--type", "f", "-E", vim.fn.expand("%:."), cmd.args }, nil, {efm = "%f:%l:%c:%m", open = true, filter = function(line) + local pos = bufs[line] or {} + local lnum, col = (pos[1] or "1"), (pos[2] or "0") + return line .. ":" .. lnum .. ":" .. col .. ":" .. "hello" + end}) + end, + {nargs="*", bang=true, complete="file"}) + +function opts_for_args(args) + local opts = { + go = { + test = function(cmd) + return {buffer = true, efm=require('my.packages.go').efm()} + end + } + } + local arg_opts = vim.iter(args) + :fold(opts, function(acc, v) + if type(acc) == "table" and acc[v] then + return acc[v] + end + return acc + end) + if type(arg_opts) == "function" then + return arg_opts() + elseif type(arg_opts) == "table" then + return (arg_opts[1] or function() return {} end)() + end +end + +vim.api.nvim_create_user_command( + "Sh", + function(cmd) + local thunk = function() qfjob({ "nu", "--commands", cmd.args }, nil, opts_for_args(cmd.fargs)) end + last_job_thunk = thunk + thunk() + end, + {nargs="*", bang=true, complete="shellcmd"}) + +vim.api.nvim_create_user_command( + "Rerun", + function(cmd) + if not last_job_state then + vim.notify "nothing to rerun" + else + if not last_job_state:is_closing() then + vim.notify "Last job not finished" + else + last_job_thunk() + end + end + end, {bang=true}) + +vim.api.nvim_create_user_command( + "Stop", + function() + if last_job_state then + last_job_state:kill() + vim.notify "killed job" + else + vim.notify "nothing to do" + end + end, {bang=true}) + +local browse_git_remote = function(fugitive_data) + local path = fugitive_data.path + if not path then + local bufname = vim.fn.bufname("%") + if vim.startswith(bufname,"oil://") then + local d = "oil://" .. vim.fs.dirname(fugitive_data.git_dir) .. "/" + path = bufname:sub(d:len()+1, bufname:len()) + end + end + assert(path) + + local home, org, project, repo = "", "" + if vim.startswith(fugitive_data.remote, "git@") then + home, repo = fugitive_data.remote:match("git@([^:]+):(.*)%.git") + if not (home and repo) then + home, org, project, repo = fugitive_data.remote:match("git@([^:]+):.*/(.*)/(.*)/(.*)") + end + end + assert((home and org and project and repo) or (home and repo)) + + local homes = { + ["ssh.dev.azure.com"] = "dev.azure.com", + } + if homes[home] then + home = homes[home] + end + + local urls = { + ["bitbucket.org"] = { + ["tree"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/src/" .. fugitive_data.commit .. "/" .. path + end, + ["blob"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/src/" .. fugitive_data.commit .. "/" .. path + end, + ["commit"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/commits/" .. fugitive_data.commit + end, + ["ref"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/commits/" .. fugitive_data.commit + end, + }, + ["dev.azure.com"] = { + ["tree"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. org .. "/" .. project .. "/_git/" .. repo .. "?version=GB" .. fugitive_data.commit .. "&path=/" .. path + end, + ["blob"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. org .. "/" .. project.. "/_git/" .. repo .. "?version=GB" .. fugitive_data.commit .. "&path=/" .. path + end, + ["commit"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. org .. "/" .. project.. "/_git/" .. repo .. "/commit/" .. fugitive_data.commit + end, + ["ref"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. org .. "/" .. project.. "/_git/" .. repo .. "/commit/" .. fugitive_data.commit + end, + }, + ["gitlab.com"] = { + ["tree"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/-/tree/" .. fugitive_data.commit .. "/" .. path + end, + ["blob"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/-/blob/" .. fugitive_data.commit .. "/" .. path + end, + ["commit"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/-/commit/" .. fugitive_data.commit + end, + ["ref"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/-/commit/" .. fugitive_data.commit + end, + }, + ["github.com"] = { + ["tree"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/tree/" .. fugitive_data.commit .. "/" .. path + end, + ["blob"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/blob/" .. fugitive_data.commit .. "/" .. path + end, + ["commit"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/commit/" .. fugitive_data.commit + end, + ["ref"] = function(home, org, project, repo) + return "https://" .. home .. "/" .. repo .. "/commit/" .. fugitive_data.commit + end, + }, + } + + return urls[home][fugitive_data.type](home, org, project, repo) +end +vim.g.fugitive_browse_handlers = { browse_git_remote } + +-- require("lsp_signature").setup() +require("nvim-treesitter.configs").setup({highlight = {enable = true}}) +require("gitsigns").setup({ + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'right_align', -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + virt_text_priority = 100, + use_focus = true, + }, +}) + +vim.opt.clipboard:append({"unnamedplus"}) + +local osc52 = require("vim.ui.clipboard.osc52") + +function paste() + return { + vim.fn.split(vim.fn.getreg(""), "\n"), + vim.fn.getregtype("") + } +end +-- function xclip(lines) +-- vim.system({ "nu", "--commands", "xclip -f -sel c | xclip"}, {stdin=lines, text=true}, nil) +-- end +function pbcopy(lines) + vim.system({ "nu", "--commands", "pbcopy"}, {stdin=lines, text=true}, nil) +end + +-- Unix, Linux variants +local fh, err = assert(io.popen("which pbcopy 2>/dev/null", "r")) +if fh:read() then + vim.g.clipboard = { + name = 'pbcopy Clipboard', + copy = { + ['+'] = pbcopy, + ['*'] = pbcopy, + }, + paste = { + ['+'] = paste, + ['*'] = paste, + }, + } +else + vim.g.clipboard = { + name = 'OSC 52', + copy = { + ['+'] = require('vim.ui.clipboard.osc52').copy('+'), + ['*'] = require('vim.ui.clipboard.osc52').copy('*'), + }, + paste = { + ['+'] = require('vim.ui.clipboard.osc52').paste('+'), + ['*'] = require('vim.ui.clipboard.osc52').paste('*'), + }, + } +end +require("my.events") +require("my.packages") + +-- require('render-markdown').setup ({ +-- opts = { +-- file_types = { "markdown", "Avante" }, +-- }, +-- ft = { "markdown", "Avante" },}) +-- require('avante_lib').load() +-- -- require('copilot').setup {} +-- require('avante').setup ({ +-- provider = "openai", +-- openai = { +-- model = "gpt-4o", +-- }, +-- behaviour = { +-- auto_suggestions = false, +-- auto_set_highlight_group = true, +-- auto_set_keymaps = true, +-- auto_apply_diff_after_generation = false, +-- support_paste_from_clipboard = false, +-- }, +-- mappings = { +-- --- @class AvanteConflictMappings +-- diff = { +-- ours = "co", +-- theirs = "ct", +-- all_theirs = "ca", +-- both = "cb", +-- cursor = "cc", +-- next = "]x", +-- prev = "[x", +-- }, +-- suggestion = { +-- accept = "<M-l>", +-- next = "<M-]>", +-- prev = "<M-[>", +-- dismiss = "<C-]>", +-- }, +-- jump = { +-- next = "]]", +-- prev = "[[", +-- }, +-- submit = { +-- normal = "<CR>", +-- insert = "<C-s>", +-- }, +-- sidebar = { +-- apply_all = "A", +-- apply_cursor = "a", +-- switch_windows = "<Tab>", +-- reverse_switch_windows = "<S-Tab>", +-- }, +-- }, +-- }) + +require("quicker").setup({ + keys = { + { + ">", + function() + require("quicker").expand({ before = 2, after = 2, add_to_existing = true }) + end, + desc = "Expand quickfix context", + }, + { + "<", + function() + require("quicker").collapse() + end, + desc = "Collapse quickfix context", + }, + }, +}) +-- (local +-- draw +-- (fn [toggle] +-- (if +-- toggle +-- (do +-- (vim.cmd "set virtualedit=all") +-- (vim.keymap.set :v "<leader>;" "<esc>:VBox<CR>") +-- (vim.keymap.set "n" "J" "<C-v>j:VBox<CR>") +-- (vim.keymap.set "n" "K" "<C-v>k:VBox<CR>") +-- (vim.keymap.set "n" "L" "<C-v>l:VBox<CR>") +-- (vim.keymap.set "n" "H" "<C-v>h:VBox<CR>")) +-- (do +-- (vim.cmd "set virtualedit=") +-- (vim.keymap.del :v "<leader>;") +-- (vim.keymap.del "n" "J") +-- (vim.keymap.del "n" "K") +-- (vim.keymap.del "n" "L") +-- (vim.keymap.del "n" "H"))))) diff --git a/.config/nvim/lua/my/lsp.lua b/.config/nvim/lua/my/lsp.lua new file mode 100644 index 0000000..2fad5aa --- /dev/null +++ b/.config/nvim/lua/my/lsp.lua @@ -0,0 +1,46 @@ +function set_buf_opt(buf, name, value) + return function() vim.api.nvim_buf_set_option(buf, name, value) end +end + +function buf_map(mode, key, fn) + return function() vim.keymap.set(mode, key, fn, {silent= true, noremap = true, buffer = 0}) end +end + +function lsp_action(action) + return vim.lsp.buf[action] +end + +local capability_map = { + -- completionProvider = (set_buf_opt :omnifunc "v:lua.vim.lsp.omnifunc"), + -- hoverProvider = set_buf_opt("keywordprg", ":LspHover"), + renameProvider = buf_map("n", "<leader>gr", lsp_action("rename")), + signatureHelpProvider = buf_map("n", "<leader>gs", lsp_action("signature_help")), + definitionProvider = buf_map("n", "<leader>gd", lsp_action("definition")), + declaration = buf_map("n", "<leader>gD", lsp_action("declaration")), + implementationProvider = buf_map("n", "<leader>gi", lsp_action("implementation")), + referencesProvider = buf_map("n", "<leader>gg", lsp_action("references")), + documentSymbolProvider = buf_map("n", "<leader>gds", lsp_action("workspace_symbol")), + codeActionProvider = buf_map("n", "<leader>ga", lsp_action("code_action")), + codeLensProvider = buf_map("n", "<leader>gl", vim.lsp.codelens.run), + inlayHintProvider = function() + vim.lsp.inlay_hint.enable(true) + buf_map("n", "<leader>gh", function() vim.lsp.inlay_hint.enable(0, not vim.lsp.inlay_hint.is_enabled(0)) end) + end, + documentFormattingProvider = function() + set_buf_opt("formatexpr", "v:lua.vim.lsp.format()") + buf_map("n", "<leader>gq", function() vim.lsp.buf.format({async= true}) end) + end, +} + +local M = {} + +M.attach = function (ev) + vim.iter(ev.client.server_capabilities) + :each(function(c) + local fn = capability_map[c] + if fn then fn() end + end) + ev.client.capabilities = require('blink.cmp').get_lsp_capabilities(ev.client.capabilities) +end + +return M diff --git a/.config/nvim/lua/my/packages/blink.lua b/.config/nvim/lua/my/packages/blink.lua new file mode 100644 index 0000000..31726dc --- /dev/null +++ b/.config/nvim/lua/my/packages/blink.lua @@ -0,0 +1,57 @@ +local blink = require('blink.cmp') +blink.setup { + fuzzy = { prebuilt_binaries = { force_version = "v0.10.0" } }, + -- 'default' for mappings similar to built-in completion + -- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate) + -- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept + -- See the full "keymap" documentation for information on defining your own keymap. + keymap = { preset = 'default' }, + + appearance = { + -- Sets the fallback highlight groups to nvim-cmp's highlight groups + -- Useful for when your theme doesn't support blink.cmp + -- Will be removed in a future release + use_nvim_cmp_as_default = true, + -- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono' + }, + + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` + sources = { + default = { 'lsp', 'path', 'snippets', 'buffer' }, + }, + + snippets = { preset = 'luasnip' }, +} + +local map = vim.keymap.set +local unmap = vim.keymap.del +local event = vim.api.nvim_create_autocmd +map("n", "<leader>xf", function() + event({"CmdwinEnter"}, { + once = true, + callback = function() + map("i","<c-j>", function() + blink.hide() + vim.schedule(function() + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes("<cr>", true, false, true), + "c", false) + end) + end,{buffer=true}) + map("i","<bs>","<c-o>vT/d",{buffer=true}) + end + }) + event({"CmdwinLeave"}, { + once = true, + callback = function() + unmap("i","<c-j>",{buffer=true}) + unmap("i","<bs>",{buffer=true}) + end + }) + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes(":edit <c-r>=expand('%:p:h')<cr><c-f>A/", true, false, true), + "c", false) +end) diff --git a/.config/nvim/lua/my/packages/dap.lua b/.config/nvim/lua/my/packages/dap.lua new file mode 100644 index 0000000..c9240f9 --- /dev/null +++ b/.config/nvim/lua/my/packages/dap.lua @@ -0,0 +1,125 @@ +local dap = require("dap") +local adapters = dap.adapters +local configurations = dap.configurations + +local dapui = require("dapui") +local dappy = require("dap-python") + +adapters.delve = { + type="server", + port="${port}", + executable={ + command="dlv", + args= { "dap", "-l", "127.0.0.1:${port}" } + } +} + +configurations.go = { + {type = "delve", + name = "Debug", + request = "launch", + env = {CGO_CFLAGS="-Wno-error=cpp"}, + program = "${file}"}, + {type = "delve", + name = "DebugTest", + request = "launch", + mode = "test", + env = {CGO_CFLAGS="-Wno-error=cpp"}, + program = "${file}"}, + {type = "delve", + name = "DebugTerraform", + request = "launch", + program = "${file}", + env = {CGO_CFLAGS="-Wno-error=cpp"}, + args = { "-debug" }}, + {type = "delve", + name = "DebugTerraformAcc", + request = "launch", + program = "${file}", + mode = "test", + env = {CGO_CFLAGS="-Wno-error=cpp", TF_ACC=1}}, + {type = "delve", + name = "DebugTestSuite", + request = "launch", + mode = "test", + env = {CGO_CFLAGS="-Wno-error=cpp"}, + program = "${fileDirname}"}, +} + +dapui.setup { + expand_lines=false, + layouts={ + {position="bottom", size=10, elements={ {id="repl", size=0.5}, {id="console", size=0.5} }}, + {position="left", size=40, elements={ {id="breakpoints",size=0.25}, {id="stacks", size=0.25}, {id="watches", size=0.25}, {id="scopes", size=0.25} }}, + {position="bottom", size=25, elements={ {id="repl", size=0.35}, {id="watches", size=0.65} }}, + } +} + +dappy.setup() + +-- (local run_table +-- {:python +-- (fn [fname] +-- { +-- :name (.. "Launch " fname) +-- :program fname +-- :console "externalTerminal" +-- :request "launch" +-- :type "python" +-- :cwd :/Users/ivi/Programming +-- :waitOnAbnormalExit true +-- :waitOnNormalExit true})}) +-- (vim.keymap.set +-- :n +-- "s;" +-- (fn [] +-- (local fname (vim.fn.fnamemodify (vim.fn.bufname "%") ":p")) +-- (local get_config (. run_table (vim.opt_local.ft:get))) +-- +-- (set dap.defaults.fallback.external_terminal +-- {:command :/Applications/Alacritty.app/Contents/MacOS/alacritty +-- :args [:-T :dap :--working-directory (vim.fn.getcwd) :-e]}) +-- +-- (if get_config +-- (dap.run (get_config fname))))) + + +vim.keymap.set("n", "si", + function() + dapui.toggle {layout=1, reset=true} + dapui.toggle {layout=2, reset=true} + end, {silent=true}) + +vim.keymap.set("n", "s<enter>", function() dapui.toggle {layout=3, reset=true} end, {silent=true}) +-- ;; "breakpoints", +-- ;; "repl", +-- ;; "scopes", +-- ;; "stacks", +-- ;; "watches", +-- ;; "hover", +-- ;; "console",) +vim.keymap.set("n", "sfw", + function() + dapui.float_element("watches", {width=vim.api.nvim_win_get_width(0), height=30, enter=true}) + end, {silent=true}) + +vim.keymap.set("n", "sfs", + function() + dapui.float_element("scopes", {width=vim.api.nvim_win_get_width(0), height=30, enter=true}) + end, {silent=true}) + +vim.keymap.set("n", "sq", dap.terminate, {silent=true}) +vim.keymap.set("n", "sc", dap.continue, {silent=true}) +vim.keymap.set("n", "sr", dap.run_to_cursor, {silent=true}) +vim.keymap.set("n", "sn", dap.step_over, {silent=true}) +vim.keymap.set("n", "ss", dap.step_into, {silent=true}) +vim.keymap.set("n", "so", dap.step_out, {silent=true}) +vim.keymap.set("n", "sb", dap.toggle_breakpoint, {silent=true}) +vim.keymap.set("n", "sB", dap.set_breakpoint, {silent=true}) +vim.keymap.set("n", "slp", + function() + dap.set_breakpoint(nil, nil, vim.fn.input("Log point message: ")) + end, {silent=true}) + +vim.keymap.set("n", "st", dap.repl.toggle, {silent=true}) +vim.keymap.set("n", "sl", dap.run_last, {silent=true}) diff --git a/.config/nvim/lua/my/packages/go.lua b/.config/nvim/lua/my/packages/go.lua new file mode 100644 index 0000000..4abf384 --- /dev/null +++ b/.config/nvim/lua/my/packages/go.lua @@ -0,0 +1,75 @@ +local M = {} +local go = require("go") +local gotest = require("go.gotest") +go.setup { + test_efm = false, -- errorfomat for quickfix, default mix mode, set to true will be efm only + luasnip = true, + + goimports = false, + fillstruct = false, + gofmt = false, + max_line_len = nil, + tag_transform = false, + test_dir = false, + comment_placeholder = " ", + icons = false, + verbose = false, + log_path = vim.fn.expand("~/tmp/gonvim.log"), + lsp_cfg = false, + lsp_gofumpt = false, + lsp_on_attach = nil, + lsp_keymaps = false, + lsp_codelens = false, + diagnostic = false, + lsp_inlay_hints = {enable= false}, + gopls_remote_auto = false, + gocoverage_sign = "█", + sign_priority = 7, + dap_debug = false, + dap_debug_gui = false, + dap_debug_keymap = false, + dap_vt = false, + textobjects = false, + gopls_cmd = nil, + build_tags = "", + test_runner = "go", + run_in_floaterm = false, + iferr_vertical_shift = 4, +} + +local efm = function() + local indent = [[%\\%( %\\)]] + local efm = [[%-G=== RUN %.%#]] + efm = efm .. [[,%-G]] .. indent .. [[%#--- PASS: %.%#]] + efm = efm .. [[,%G--- FAIL: %\\%(Example%\\)%\\@= (%.%#)]] + efm = efm .. [[,%G]] .. indent .. [[%#--- FAIL: (%.%#)]] + efm = efm .. [[,%A]] .. indent .. [[%\\+%[%^:]%\\+: %f:%l: %m]] + efm = efm .. [[,%+Gpanic: test timed out after %.%\\+]] + efm = efm .. ',%+Afatal error: %.%# [recovered]' + efm = efm .. [[,%+Afatal error: %.%#]] + efm = efm .. [[,%+Apanic: %.%#]] + -- + -- -- exit + efm = efm .. ',%-Cexit status %[0-9]%\\+' + efm = efm .. ',exit status %[0-9]%\\+' + -- -- failed lines + efm = efm .. ',%-CFAIL%\\t%.%#' + efm = efm .. ',FAIL%\\t%.%#' + -- compiling error + + efm = efm .. ',%A%f:%l:%c: %m' + efm = efm .. ',%A%f:%l: %m' + efm = efm .. ',%f:%l +0x%[0-9A-Fa-f]%\\+' -- pannic with adress + efm = efm .. ',%-G%\\t%\\f%\\+:%\\d%\\+ +0x%[0-9A-Fa-f]%\\+' -- test failure, address invalid inside + -- multi-line + efm = efm .. ',%+G%\\t%m' + -- efm = efm .. ',%-C%.%#' -- ignore rest of unmatched lines + -- efm = efm .. ',%-G%.%#' + + efm = string.gsub(efm, ' ', [[\ ]]) + -- log(efm) + return efm +end +gotest.efm = efm +M.efm = efm +return M diff --git a/.config/nvim/lua/my/packages/init.lua b/.config/nvim/lua/my/packages/init.lua new file mode 100644 index 0000000..9c3a65f --- /dev/null +++ b/.config/nvim/lua/my/packages/init.lua @@ -0,0 +1,6 @@ +require("my.packages.oil") +require("my.packages.blink") +require("my.packages.lint") +require("my.packages.luasnip") +require("my.packages.dap") +require("my.packages.go") diff --git a/.config/nvim/lua/my/packages/lint.lua b/.config/nvim/lua/my/packages/lint.lua new file mode 100644 index 0000000..815f9b3 --- /dev/null +++ b/.config/nvim/lua/my/packages/lint.lua @@ -0,0 +1,26 @@ +local lint = require("lint") +local conform = require("conform") + +function is_executable(program) + return vim.fn.executable(program) == 1 +end + +lint.linters_by_ft = { + markdown=ternary(is_executable("vale"), { "vale" }, {}), + python=ternary(is_executable("ruff"), { "ruff" }, {}), + sh={ "shellcheck" }, +} + +conform.setup { + formatters_by_ft={ + python= { "ruff_format", "isort" }, + go= { "goimports" }, + nix= { "alejandra" }, + terraform= { "terraform_fmt" }, + hcl= { "terraform_fmt" }, + }, + format_on_save={ + timeout_ms= 500, + lsp_fallback= false + } +} diff --git a/.config/nvim/lua/my/packages/lualine.fnl b/.config/nvim/lua/my/packages/lualine.fnl new file mode 100644 index 0000000..4f57425 --- /dev/null +++ b/.config/nvim/lua/my/packages/lualine.fnl @@ -0,0 +1,17 @@ +(local lualine (require :lualine)) +(local clients #(do + (local bn (vim.fn.fnamemodify (vim.fn.bufname :%) ::p)) + (local m (bn:match ".*clients/([a-z]+)/.*")) + (if (not= nil m) + m + ""))) +(lualine.setup + {:extensions [:quickfix :fugitive :oil :fzf :nvim-dap-ui] + :sections + {:lualine_c ["%=" {1 clients :color :WarningMsg}]} + :winbar + {:lualine_a [:filename]} + :inactive_winbar + {:lualine_a [:filename]} + :tabline + {:lualine_a [:tabs]}}) diff --git a/.config/nvim/lua/my/packages/luasnip.lua b/.config/nvim/lua/my/packages/luasnip.lua new file mode 100644 index 0000000..338b343 --- /dev/null +++ b/.config/nvim/lua/my/packages/luasnip.lua @@ -0,0 +1,44 @@ +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local isn = ls.indent_snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local events = require("luasnip.util.events") +local ai = require("luasnip.nodes.absolute_indexer") +local extras = require("luasnip.extras") +local l = extras.lambda +local rep = extras.rep +local p = extras.partial +local m = extras.match +local n = extras.nonempty +local dl = extras.dynamic_lambda +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local conds = require("luasnip.extras.expand_conditions") +local postfix = require("luasnip.extras.postfix").postfix +local types = require("luasnip.util.types") +local parse = require("luasnip.util.parser").parse_snippet +local ms = ls.multi_snippet +local k = require("luasnip.nodes.key_indexer").new_key + +vim.keymap.set( { "i", }, "<C-K>", ls.expand, {silent= true}) +vim.keymap.set( { "i", "s" }, "<C-L>", function() if ls.expand_or_jumpable() then ls.expand_or_jump(1) end end, {silent=true}) +vim.keymap.set( { "i", "s" }, "<C-J>", function() ls.jump(-1) end, {silent=true}) +vim.keymap.set( { "i", "s" }, "<C-E>", function() + if ls.choice_active() then + ls.change_choice(1) + end +end, {silent=true}) + +ls.add_snippets( + "go", { + s("echo", { t("fmt.Println("), i(1), t(")"), i(2) }), + s("echof", { t("fmt.Printf(\"%v\\n\", "), i(1), t(")"), i(2) }), + s("log", { t("fmt.Println("), i(1), t(")"), i(2) }), + s("logf", { t("fmt.Printf(\"%v\\n\", "), i(1), t(")"), i(2) }), + }) diff --git a/.config/nvim/lua/my/packages/oil.lua b/.config/nvim/lua/my/packages/oil.lua new file mode 100644 index 0000000..fa66001 --- /dev/null +++ b/.config/nvim/lua/my/packages/oil.lua @@ -0,0 +1,75 @@ +local oil=require("oil") +local fzf=require("fzf-lua") +local map = vim.keymap.set +local unmap = vim.keymap.del + +oil.setup({ + default_file_explorer = true, + skip_confirm_for_simple_edits = true, + + columns = {"size","permissions"}, + view_options = { + show_hidden = false, + is_hidden_file = function(name, bufnr) + return vim.startswith(name, ".") + end, + is_always_hidden = function(name, bufnr) return false end, + sort = { {"type" ,"asc"}, {"name","asc"} } + }, + + + keymaps = { + ["g?"] = "actions.show_help", + ["<CR>"] = "actions.select", + ["<C-s>"] = function() + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes( + ":Sh<up><c-f>", + true, false, true + ), + "n", false + ) + vim.schedule(function() + vim.cmd("let v:searchforward = 0") + map("n","/","/Sh.*",{buffer=true}) + map("n","?","?Sh.*",{buffer=true}) + end) + end, + [ "<C-h>" ] = "actions.select_split", + [ "<C-t>" ] = "actions.select_tab", + [ "<C-p>" ] = fzf.files, + [ "<C-c>" ] = "actions.close", + [ "<C-l>" ] = "actions.refresh", + [ "." ] = "actions.open_cmdline", + [ "gx" ] = { + callback = function() + local file, dir = oil.get_cursor_entry(), oil.get_current_dir() + if dir and file then + vim.cmd("argadd " .. dir .. file.name) + vim.cmd "args" + end + end + }, + [ "gX" ] = { + callback = function() + local file, dir = oil.get_cursor_entry(), oil.get_current_dir() + if dir and file then + vim.cmd("argdel " .. dir .. file.name) + vim.cmd "args" + end + end + }, + [ "gc" ] = { + callback = function() + vim.cmd("argdel *") + vim.cmd("args") + end + }, + [ "-" ] = "actions.parent", + [ "_" ] = "actions.open_cwd", + [ "cd" ] = "actions.cd", + [ "~" ] = "actions.tcd", + [ "gs" ] = "actions.change_sort", + [ "g." ] = "actions.toggle_hidden" + } +}) diff --git a/.config/nvim/lua/my/settings.lua b/.config/nvim/lua/my/settings.lua new file mode 100644 index 0000000..f08bf16 --- /dev/null +++ b/.config/nvim/lua/my/settings.lua @@ -0,0 +1,68 @@ +vim.g.codeium_enabled = false +vim.g.loaded_2html_plugin = false +vim.g.loaded_fzf = false +vim.g.loaded_health = false +vim.g.loaded_matchit = false +vim.g.loaded_matchparen = nil +vim.g.loaded_netrwPlugin = false +vim.g.loaded_rplugin = false +vim.g.loaded_shada = false +vim.g.loaded_tohtml = false +vim.g.loaded_tutor = false + +vim.g.zoxide_use_select = true +vim.g.zoxide_hook = "pwd" +vim.g.mapleader = " " +vim.g.maplocalleader = " " +vim.g.dirvish_mode = ":sort | sort ,^.*[^/]$, r" + +vim.opt.grepprg = "rg --vimgrep" +vim.opt.grepformat = "%f:%l:%c:%m" +vim.opt.shortmess:append("c") +vim.opt.diffopt:append("vertical") +vim.opt.isfname:append("@-@") +vim.opt.wmw = 10 +vim.opt.inccommand = "split" +vim.opt.signcolumn = "yes" +vim.opt.smd = false +vim.opt.scrolloff = 8 +vim.opt.termguicolors = true +vim.opt.incsearch = true +vim.opt.undofile = true +vim.opt.undodir = vim.fn.expand("~/.local/share/nvim/undo") +vim.opt.backup = false +vim.opt.backupcopy = "yes" +vim.opt.swapfile = false +vim.opt.wrap = false +vim.opt.splitbelow = true +vim.opt.magic = true +vim.opt.showbreak = "+++" +-- vim.opt.; listchars {:eol ""} +vim.opt.list = true +vim.opt.autoread = true +vim.opt.autoindent = true +vim.opt.smartindent = true +vim.opt.expandtab = true +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.hidden = true +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.exrc = true +vim.opt.secure = true +-- vim.opt.; completeopt "menu,longest,preview" +vim.opt.wmnu = true +vim.opt.wop = "pum" +-- vim.opt.; wildmode "list:longest" +vim.opt.complete = ".,w,k,kspell,b" +vim.opt.foldopen = "block,hor,jump,mark,percent,quickfix,search,tag" +vim.opt.laststatus = 3 +-- vim.opt.; winbar "%=%m %f" +vim.opt.winbar = "" +vim.opt.hlsearch = false +vim.opt.showtabline = 1 +vim.opt.cmdheight = 1 + +vim.opt.shellpipe = "out+err>" +vim.opt.shell = "sh" diff --git a/.config/vis/themes/gruvbox.lua b/.config/vis/themes/gruvbox.lua new file mode 100644 index 0000000..a54008a --- /dev/null +++ b/.config/vis/themes/gruvbox.lua @@ -0,0 +1,129 @@ +-- Gruvbox color scheme by Pavel Pertsev (https://github.com/morhetz) +-- For the Vis text editor by Marc Tanner (https://github.com/martanne) + +-- Set to 'dark' or 'light' +local mode = 'dark' +-- Set to 'hard', 'medium', or 'soft' +local contrast = 'medium' + +local gruvbox = { + dark0h = '#1d2021', + dark0 = '#282828', + dark0s = '#32302f', + dark1 = '#3c3836', + dark2 = '#504945', + dark3 = '#665c54', + dark4 = '#7c6f64', + light0h = '$f9f5d7', + light0 = '#fbf1c7', + light0s = '#f2e5bc', + light1 = '#ebdbb2', + light2 = '#d5c4a1', + light3 = '#bdae93', + light4 = '#a89984', + gray = '#928374', + red0 = '#fb4934', + red1 = '#9d0006', + green0 = '#b8bb26', + green1 = '#79740e', + yellow0 = '#fabd2f', + yellow1 = '#b57614', + blue0 = '#83a598', + blue1 = '#076678', + purple0 = '#d3869b', + purple1 = '#8f3f71', + aqua0 = '#8ec07c', + aqua1 = '#427b58', + orange0 = '#fe8019', + orange1 = '#af3a03', +} + +local colors = {} + +if mode == 'dark' then + if contrast == 'hard' then + colors.bg0 = gruvbox.dark0h + elseif contrast == 'medium' then + colors.bg0 = gruvbox.dark0 + elseif contrast == 'soft' then + colors.bg0 = gruvbox.dark0s + end + colors.bg1 = gruvbox.dark1 + colors.bg2 = gruvbox.dark2 + colors.bg3 = gruvbox.dark3 + colors.bg4 = gruvbox.dark4 + colors.fg0 = gruvbox.light0 + colors.fg1 = gruvbox.light1 + colors.fg2 = gruvbox.light2 + colors.fg3 = gruvbox.light3 + colors.fg4 = gruvbox.light4 + colors.gray = gruvbox.gray + colors.red = gruvbox.red0 + colors.green = gruvbox.green0 + colors.yellow = gruvbox.yellow0 + colors.blue = gruvbox.blue0 + colors.purple = gruvbox.purple0 + colors.aqua = gruvbox.aqua0 + colors.orange = gruvbox.orange0 +elseif mode == 'light' then + if contrast == 'hard' then + colors.bg0 = gruvbox.light0h + elseif contrast == 'medium' then + colors.bg0 = gruvbox.light0 + elseif contrast == 'soft' then + colors.bg0 = gruvbox.light0s + end + colors.bg1 = gruvbox.light1 + colors.bg2 = gruvbox.light2 + colors.bg3 = gruvbox.light3 + colors.bg4 = gruvbox.light4 + colors.fg0 = gruvbox.dark0 + colors.fg1 = gruvbox.dark1 + colors.fg2 = gruvbox.dark2 + colors.fg3 = gruvbox.dark3 + colors.fg4 = gruvbox.dark4 + colors.gray = gruvbox.gray + colors.red = gruvbox.red1 + colors.green = gruvbox.green1 + colors.yellow = gruvbox.yellow1 + colors.blue = gruvbox.blue1 + colors.purple = gruvbox.purple1 + colors.aqua = gruvbox.aqua1 + colors.orange = gruvbox.orange1 +end + +-- To use your terminal's default background (e.g. for transparency), set the value below to 'back:default,fore:'..colors.fg1 +vis.lexers.STYLE_DEFAULT = 'back:'..colors.bg0..',fore:'..colors.fg1 +vis.lexers.STYLE_NOTHING = '' +vis.lexers.STYLE_CLASS = 'fore:'..colors.yellow +vis.lexers.STYLE_COMMENT = 'fore:'..colors.gray..',italics' +vis.lexers.STYLE_CONSTANT = 'fore:'..colors.purple +vis.lexers.STYLE_DEFINITION = 'fore:'..colors.yellow +vis.lexers.STYLE_ERROR = 'fore:'..colors.red..',back:'..colors.bg0..',reverse' +vis.lexers.STYLE_FUNCTION = 'fore:'..colors.green..',bold' +vis.lexers.STYLE_KEYWORD = 'fore:'..colors.red +vis.lexers.STYLE_LABEL = 'fore:'..colors.red +vis.lexers.STYLE_NUMBER = 'fore:'..colors.purple +vis.lexers.STYLE_OPERATOR = vis.lexers.STYLE_DEFAULT +vis.lexers.STYLE_REGEX = 'fore:'..colors.aqua +vis.lexers.STYLE_STRING = 'fore:'..colors.green +vis.lexers.STYLE_PREPROCESSOR = 'fore:'..colors.aqua +vis.lexers.STYLE_TAG = 'fore:'..colors.blue +vis.lexers.STYLE_TYPE = 'fore:'..colors.yellow +vis.lexers.STYLE_VARIABLE = 'fore:'..colors.blue +vis.lexers.STYLE_WHITESPACE = '' +vis.lexers.STYLE_EMBEDDED = 'fore:'..colors.orange +vis.lexers.STYLE_IDENTIFIER = 'fore:'..colors.blue + +vis.lexers.STYLE_LINENUMBER = 'fore:'..colors.bg4 +vis.lexers.STYLE_LINENUMBER_CURSOR = 'fore:'..colors.yellow..',back:'..colors.bg1 +vis.lexers.STYLE_CURSOR = 'reverse' +vis.lexers.STYLE_CURSOR_PRIMARY = vis.lexers.STYLE_CURSOR..',fore:'..colors.yellow +vis.lexers.STYLE_CURSOR_LINE = 'back:'..colors.bg1 +vis.lexers.STYLE_COLOR_COLUMN = 'reverse' +vis.lexers.STYLE_SELECTION = 'back:'..colors.bg3..',reverse' +vis.lexers.STYLE_STATUS = 'fore:'..colors.bg1..',back:'..colors.fg4..',reverse' +vis.lexers.STYLE_STATUS_FOCUSED = 'fore:'..colors.bg2..',back:'..colors.fg1..',reverse' +vis.lexers.STYLE_SEPARATOR = 'fore:'..colors.bg3 +vis.lexers.STYLE_INFO = 'fore:'..colors.yellow..',bold' +vis.lexers.STYLE_EOF = vis.lexers.STYLE_LINENUMBER diff --git a/.config/vis/themes/lemonsoda.lua b/.config/vis/themes/lemonsoda.lua new file mode 100644 index 0000000..2034e7d --- /dev/null +++ b/.config/vis/themes/lemonsoda.lua @@ -0,0 +1,144 @@ +-- lemonsoda.lua + +-- Copyright (C) 2024 + +-- Author: scaramacai +-- ------------------------------------------------------------------------------ +-- This software is available under 2 licenses -- choose whichever you prefer. +-- ------------------------------------------------------------------------------ +-- ALTERNATIVE A - Public Domain (www.unlicense.org) +-- This is free and unencumbered software released into the public domain. +-- Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +-- software, either in source code form or as a compiled binary, for any purpose, +-- commercial or non-commercial, and by any means. +-- In jurisdictions that recognize copyright laws, the author or authors of this +-- software dedicate any and all copyright interest in the software to the public +-- domain. We make this dedication for the benefit of the public at large and to +-- the detriment of our heirs and successors. We intend this dedication to be an +-- overt act of relinquishment in perpetuity of all present and future rights to +-- this software under copyright law. +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +-- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +-- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +-- ------------------------------------------------------------------------------ +-- ALTERNATIVE B - MIT License +-- Copyright (c) 2024 scaramacai +-- Permission is hereby granted, free of charge, to any person obtaining a copy of +-- this software and associated documentation files (the "Software"), to deal in +-- the Software without restriction, including without limitation the rights to +-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +-- of the Software, and to permit persons to whom the Software is furnished to do +-- so, subject to the following conditions: +-- The above copyright notice and this permission notice shall be included in all +-- copies or substantial portions of the Software. +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +-- SOFTWARE. +-- ------------------------------------------------------------------------------ + + + + + +local lexers = vis.lexers + +local colors = { + ['fg1'] = '#d0d0d0', + ['fg2'] = '#bfbfbf', + ['fg3'] = '#afafaf', + ['fg4'] = '#9e9e9e', + ['fg6'] = '#dbdbdb', + ['bg1'] = '#2e3440', + ['bg2'] = '#323232', + ['bg3'] = '#444444', + ['bg4'] = '#565656', + ['builtin'] = '#ffb4b0', + ['keyword'] = '#ffd000', + ['const'] = '#d1d900', + ['comment'] = '#7b7b3d', + ['func'] = '#8199ff', + ['str'] = '#db94ff', + ['fg_type'] = '#75d27c', + ['var'] = '#4ebae0', + ['selection']= '#3e4450', + ['warning'] = '#2365ff', + ['warning2'] = '#0061e6', + ['back_ln'] = '#555555', + ['fore_ln'] = '#f8f8f8', + ['headers'] = '#225577', + ['prep'] = '#abab9d', + ['type2'] = '#f66151', +} + +lexers.STYLE_DEFAULT = 'fore:'..colors.fg1..','..'back:'..colors.bg1 +lexers.STYLE_NOTHING = '' +lexers.STYLE_CLASS = 'fore:'..colors.func..','..'bold' +lexers.STYLE_COMMENT = 'fore:'..colors.comment..','..'italics' +lexers.STYLE_CONSTANT = 'fore:'..colors.const +lexers.STYLE_CONSTANT_BUILTIN = 'fore:'..colors.const..','..'bold' +lexers.STYLE_ERROR = 'fore:'..colors.warning..','..'italics' +lexers.STYLE_FUNCTION = 'fore:'..colors.func +lexers.STYLE_FUNCTION_BUILTIN = 'fore:'..colors.func..','..'bold' +lexers.STYLE_KEYWORD = 'fore:'..colors.keyword +lexers.STYLE_LABEL = 'fore:'..colors.warning +lexers.STYLE_NUMBER = 'fore:'..colors.const +lexers.STYLE_OPERATOR = 'fore:'..colors.fg2 +lexers.STYLE_REGEX = 'fore:'..colors.str +lexers.STYLE_STRING = 'fore:'..colors.str +lexers.STYLE_PREPROCESSOR = 'fore:'..colors.prep +lexers.STYLE_TAG = 'fore:'..colors.fg3 +lexers.STYLE_TYPE = 'fore:'..colors.fg_type +lexers.STYLE_VARIABLE = 'fore:'..colors.warning +lexers.STYLE_VARIABLE_BUILTIN = 'fore:'..colors.warning..',bold' +lexers.STYLE_WHITESPACE = '' +lexers.STYLE_EMBEDDED = 'fore:'..colors.builtin..','..'back:'..colors.bg2 +lexers.STYLE_IDENTIFIER = 'fore:'..colors.var +lexers.STYLE_BRACELIGHT = 'fore:'..colors.func,'back:'..colors.bg2..','..'bold' +lexers.STYLE_BRACEBAD = 'fore:'..colors.warning,'back:'..colors.bg3..','..'bold' +-- view.STYLE_CONTROLCHAR = +lexers.STYLE_INDENTGUIDE = 'fore:'..colors.comment +lexers.STYLE_CALLTIP = 'fore:'..colors.fg1..','..'back:'..colors.bg2 +lexers.STYLE_FOLDDISPLAYTEXT = 'fore:'..colors.bg2 + +-- Tgag styles. +-- lexers.STYLE_ANNOTATION = 'fore:'..colors.magenta +lexers.STYLE_ATTRIBUTE = 'fore:'..colors.fg3 +lexers.STYLE_BOLD = 'bold' +lexers.STYLE_CODE = '' +-- lexers.STYLE_FUNCTION_METHOD = +lexers.STYLE_HEADING = 'fore:'..colors.fg1 .. ',back:' .. colors.headers +lexers.STYLE_ITALIC = 'italics' +-- lexers.STYLE_LINK = +-- lexers.STYLE_LIST = +lexers.STYLE_REFERENCE = 'fore:'..colors.var +-- lexers.STYLE_UNDERLINE = 'fore:'..colors.warning +lexers.STYLE_LINENUMBER = 'fore:'..colors.fg1..','..'back:'..colors.bg2 +lexers.STYLE_LINENUMBER_CURSOR = 'fore:'..colors.fore_ln..','..'back:'..colors.back_ln + +lexers.STYLE_CURSOR = 'fore:'..colors.bg1..',back:'..colors.fg4 +lexers.STYLE_CURSOR_PRIMARY = 'fore:'..colors.bg1..',back:'..colors.fg1 +lexers.STYLE_CURSOR_LINE = 'back:'..colors.bg4 +lexers.STYLE_COLOR_COLUMN = 'back:'..colors.bg4 +lexers.STYLE_SELECTION = 'back:'..colors.selection +--lexers.STYLE_STATUS = 'reverse' +lexers.STYLE_STATUS = 'fore:'..colors.fg2..',back:'..colors.bg3 +--lexers.STYLE_STATUS_FOCUSED = 'reverse,bold' +lexers.STYLE_STATUS_FOCUSED = 'fore:'..colors.fg2..',back:'..colors.bg3..',bold' +lexers.STYLE_SEPARATOR = lexers.STYLE_DEFAULT + + +-- Markdown +lexers.STYLE_HR = '' +for i = 1,6 do lexers['STYLE_HEADING_H'..i] = lexers.STYLE_HEADING end +lexers.STYLE_BOLD = 'bold' +lexers.STYLE_ITALIC = 'italics' +lexers.STYLE_LIST = lexers.STYLE_KEYWORD +lexers.STYLE_LINK = lexers.STYLE_KEYWORD +lexers.STYLE_REFERENCE = lexers.STYLE_KEYWORD diff --git a/.config/vis/themes/peaksea.lua b/.config/vis/themes/peaksea.lua new file mode 100644 index 0000000..a23be9d --- /dev/null +++ b/.config/vis/themes/peaksea.lua @@ -0,0 +1,114 @@ +local lexers = vis.lexers +local peaksea={ + bgdark='#1c1c1c',--black + bglight='#e4e4e4',--white + annotationdark='#5fff87',--green + annotationlight='#00875f',--tuerkis + functiondark='#e8a0e8',--violett + functionlight='#af5faf',--pink + normalfontdark='#d0d0d0',--dark grey + normalfontlight='#000000',--grey + stringdark='#afd7ff',--light grey + stringlight='#005f5f',--cyan + numberdark='#e0c060',--dark yellow + numberlight='#875f00',--dark yellow little brown + commentdark='#d0d090',--dark golden dirty + commentlight='#5f5f00',--light golden dirty + bgerrordark='#aa0000',--red + bgerrorlight='#80c0e0',--red + fglinenumberdark='#b0b0b0',--white + fglinenumberlight='#6c6c6c',--grey + constantdark='#80c0e0',--cyan + constantlight='#000000', + identifierdark='#d0d0d0',--white + identifierlight='#000000', + bgstatusdark='#d7ff00',--dark yellow + bgstatuslight='#000000', + bgcursordark='#262626', + bgcursorlight='#add8e6',--cyan + fgoperatorlight='#005faf',--blue + fgdark='#d0d0d0', + fglight='#1b1b1b', + embeddedlight='#875f00', + fgstatusbarlight='#5fffaf' +} +if background==nil +then + background="dark" +end + +if background=="dark" +then + lexers.STYLE_DEFAULT='fore:'..peaksea.fgdark..', back:'..peaksea.bgdark + lexers.STYLE_CLASS='fore:'..peaksea.normalfontdark + lexers.STYLE_COMMENT='fore:'..peaksea.commentdark + lexers.STYLE_CONSTANT='fore:'..peaksea.constantdark + lexers.STYLE_DEFINITION='fore:'..peaksea.bgerrordark--TODO + lexers.STYLE_ERROR='fore:'..peaksea.commentdark..',back:'..peaksea.bgerrordark + lexers.STYLE_FUNCTION='fore:'..peaksea.functiondark + lexers.STYLE_KEYWORD = 'fore:'..peaksea.stringdark--if other logical operators + lexers.STYLE_LABEL = 'fore:'..peaksea.functiondark + lexers.STYLE_NUMBER = 'fore:'..peaksea.numberdark + vis.lexers.STYLE_OPERATOR = vis.lexers.STYLE_DEFAULT--for the brackets + lexers.STYLE_REGEX = 'fore:'..peaksea.bgerrordark + lexers.STYLE_STRING = 'fore:'..peaksea.stringdark + lexers.STYLE_PREPROCESSOR = 'fore:'..peaksea.annotationdark--annotations + lexers.STYLE_TAG = 'fore:'..peaksea.bgerrordark + lexers.STYLE_TYPE = 'fore:'..peaksea.functiondark + lexers.STYLE_VARIABLE = 'fore:'..peaksea.functiondark + lexers.STYLE_WHITESPACE = '' + lexers.STYLE_EMBEDDED = 'fore:'..peaksea.commentdark + lexers.STYLE_IDENTIFIER = 'fore:'..peaksea.identifierdark --imports and co + + lexers.STYLE_LINENUMBER='fore:'..peaksea.fglinenumberdark..',back:'..peaksea.bgdark + lexers.STYLE_LINENUMBER_CURSOR = 'fore:'..peaksea.fglinenumberdark..',back:'..peaksea.bgdark + lexers.STYLE_CURSOR='fore:'..peaksea.bgdark..',back:'..peaksea.annotationdark + + lexers.STYLE_CURSOR_PRIMARY = 'fore:'..peaksea.bgdark..',back:'..peaksea.stringdark--cursor in normal mode + lexers.STYLE_CURSOR_LINE = 'back:'..peaksea.bgcursordark + + lexers.STYLE_COLOR_COLUMN = 'back:'..peaksea.normalfontdark + lexers.STYLE_SELECTION = 'fore:'..peaksea.bgdark..',back:'..peaksea.stringdark + lexers.STYLE_STATUS = 'fore:'..peaksea.bgdark..',back:'..peaksea.bgstatusdark + lexers.STYLE_STATUS_FOCUSED = 'fore:'..peaksea.bgdark..',back:'..peaksea.bgstatusdark + lexers.STYLE_SEPARATOR = 'back:'..peaksea.bgstatusdark + lexers.STYLE_INFO = 'fore:'..peaksea.bgerrordark + lexers.STYLE_EOF = 'fore:'..peaksea.fglinenumberdark..',back:'..peaksea.bgdark +elseif background=="light" +then + lexers.STYLE_DEFAULT='fore:'..peaksea.fglight..',back:'..peaksea.bglight + lexers.STYLE_CLASS='fore:'..peaksea.normalfontlight + lexers.STYLE_COMMENT='fore:'..peaksea.commentlight + lexers.STYLE_CONSTANT='fore:'..peaksea.constantlight + lexers.STYLE_DEFINITION='fore:'..peaksea.bgerrorlight--TODO + lexers.STYLE_ERROR='fore:'..peaksea.commentlight..',back:'..peaksea.bgerrorlight + lexers.STYLE_FUNCTION='fore:'..peaksea.functionlight + lexers.STYLE_KEYWORD = 'fore:'..peaksea.fgoperatorlight..',bold'--if other logical operators + lexers.STYLE_LABEL = 'fore:'..peaksea.functionlight + lexers.STYLE_NUMBER = 'fore:'..peaksea.numberlight + vis.lexers.STYLE_OPERATOR = 'fore:'..peaksea.fgoperatorlight + lexers.STYLE_REGEX = 'fore:'..peaksea.bgerrorlight + lexers.STYLE_STRING = 'fore:'..peaksea.stringlight + lexers.STYLE_PREPROCESSOR = 'fore:'..peaksea.annotationlight--annotations + lexers.STYLE_TAG = 'fore:'..peaksea.bgerrorlight + lexers.STYLE_TYPE = 'fore:'..peaksea.functionlight + lexers.STYLE_VARIABLE = 'fore:'..peaksea.functionlight + lexers.STYLE_WHITESPACE = '' + lexers.STYLE_EMBEDDED = 'fore:'..peaksea.embeddedlight + lexers.STYLE_IDENTIFIER = 'fore:'..peaksea.identifierlight --imports and co + + lexers.STYLE_LINENUMBER='fore:'..peaksea.fglinenumberlight..',back:'..peaksea.bglight + lexers.STYLE_LINENUMBER_CURSOR = 'fore:'..peaksea.fglinenumberlight..',back:'..peaksea.bglight + lexers.STYLE_CURSOR='fore:'..peaksea.bglight..',back:'..peaksea.bgdark--bgcursorlight + + lexers.STYLE_CURSOR_PRIMARY = 'fore:'..peaksea.bgdark..',back:'..peaksea.bgcursorlight--cursor in normal mode + lexers.STYLE_CURSOR_LINE = 'back:'..peaksea.bglight + + lexers.STYLE_COLOR_COLUMN = 'back:'..peaksea.normalfontlight + lexers.STYLE_SELECTION = 'fore:'..peaksea.bglight..',back:'..peaksea.bgcursorlight..',bold' + lexers.STYLE_STATUS = 'fore:'..peaksea.bglight..',back:'..peaksea.bgstatuslight + lexers.STYLE_STATUS_FOCUSED = 'fore:'..peaksea.fgstatusbarlight..',back:'..peaksea.bgstatuslight + lexers.STYLE_SEPARATOR = 'back:'..peaksea.bgstatuslight + lexers.STYLE_INFO = 'fore:'..peaksea.bgerrorlight + lexers.STYLE_EOF = 'fore:'..peaksea.fglinenumberlight..',back:'..peaksea.bglight +end diff --git a/.config/vis/vis-editorconfig/.editorconfig b/.config/vis/vis-editorconfig/.editorconfig new file mode 100644 index 0000000..d60c879 --- /dev/null +++ b/.config/vis/vis-editorconfig/.editorconfig @@ -0,0 +1,5 @@ +root = true + +[*.lua] +indent_style = space +indent_size = 2 diff --git a/.config/vis/vis-editorconfig/README.md b/.config/vis/vis-editorconfig/README.md new file mode 100644 index 0000000..9b9b72c --- /dev/null +++ b/.config/vis/vis-editorconfig/README.md @@ -0,0 +1,89 @@ +# vis-editorconfig + +A [vis][vis] plugin for [editorconfig][ec]. + +[vis]: https://github.com/martanne/vis +[ec]: http://editorconfig.org/ + +## Installation + +You'll need the Lua wrapper for editorconfig-core installed. This can +be done through luarocks: `luarocks install editorconfig-core` + +```shell +git clone https://github.com/seifferth/vis-editorconfig "$HOME/.config/vis/edconf" +``` + +Then add `require('edconf')` to your `visrc.lua`. + +You may use a different name for the local repository, if you like. +You could, for instance, use `$HOME/.config/vis/vis-editorconfig` and +`require('vis-editorconfig')`. Note, however, that the repository **must +not** be called `editorconfig`. Since the editorconfig-core lua library +is also called `editorconfig`, naming the repository `editorconfig` +will cause name conflicts that result in infinite recursion. + +## Functionality + +Not all editorconfig functionality is supported by vis and hence by this +plugin. At this moment, there is full support for the following settings: + +- indent_style +- indent_size +- tab_width +- insert_final_newline + +The following settings are implemented partially and / or support is +turned off by default: + +- spell_language: This is not yet part of the editorconfig specification + (cf. <https://github.com/editorconfig/editorconfig/issues/315>), but + it is implemented anyway. Since vis does not support spellchecking + natively, this plugin will only set `vis.win.file.spell_language` to + the specified value. It is then up to the spellchecking plugin to + respect that variable. +- trim_trailing_whitespace: Turned off by default, can be enabled + via `:set edconfhooks on`. +- end_of_line: Turned off by default, partial support can be enabled + via `:set edconfhooks on`. Only `crlf` and `lf` are supported, plain + `cr` is not. The implementation is also very basic. If end_of_line + is set to `crlf`, a return character will be inserted at the end of + each line that does not yet end with `crlf`. If end_of_line is set + to `lf`, return characters at the end of a line will be stripped. + While I would encourage every vis user to stick to `lf` terminated + files, this might be convenient if, for some reason, they do need + to compose `crlf` terminated files. +- max_line_length: Turned off by default, partial support can be + enabled via `:set edconfhooks on`. There is no straightforward way + to automatically wrap content that might be written in arbitrary + programming (or non-programming) languages. For that reason, + vis-editorconfig doesn't even try. If max_line_length is enabled, + vis-editorconfig issues a warning, however, indicating which lines + are longer than the specified length. Note that you will miss this + warning if you write your file with `:wq`, so if you care about it, + write it with `:w<RETURN>:q`. + +The reason those last three settings are optional and turned off by +default is their scalability. Each of those operations is implemented +as a pre-save-hook with a complexity of O(n), where n is the filesize. +Since vis is incredibly good at editing huge files efficiently, there +seems to be a very real danger that those hooks could cause the editor +to freeze just before a user's valuable changes are written to disk. + +You can turn support for those pre-save-hooks on or off at any time +by running + + :set edconfhooks on + +or + + :set edconfhooks off + +If `edconfhooks` are enabled, they will be executed as configured in +`.editorconfig`. If you want to take a less cautious approach and enable +these hooks by default, simply add an additional line below the module +import in `visrc.lua`: + + require('editorconfig/edconf') + vis:command('set edconfhooks on') -- supposing you did previously + -- require('vis') diff --git a/.config/vis/vis-editorconfig/edconf.lua b/.config/vis/vis-editorconfig/edconf.lua new file mode 100644 index 0000000..7c92f4d --- /dev/null +++ b/.config/vis/vis-editorconfig/edconf.lua @@ -0,0 +1,208 @@ +require "vis" +local ec = require "editorconfig" +local M = {} + +-- Simple wrapper +local function vis_set(option, value) + if type(value) == "boolean" then + if value then + value = "yes" + else + value = "no" + end + end + + vis:command("set " .. option .. " " .. value) +end + +local function set_pre_save(f, value) + if value == "true" then + vis.events.subscribe(vis.events.FILE_SAVE_PRE, f) + else + vis.events.unsubscribe(vis.events.FILE_SAVE_PRE, f) + end +end + +local function set_file_open(f, value) + if value == "true" then + vis.events.subscribe(vis.events.FILE_OPEN, f) + else + vis.events.unsubscribe(vis.events.FILE_OPEN, f) + end +end + +-- Custom functionality +M.hooks_enabled = false +vis:option_register("edconfhooks", "bool", function(value) + M.hooks_enabled = value +end, "Enable optional pre-save-hooks for certain editorconfig settings") + +local function insert_final_newline(file) + -- Technically speaking, this is a pre-save-hook as well and could + -- therefore respect edconf_hooks_enabled. Since this function runs + -- blazingly fast and scales with a complexity of O(1), however, + -- there is no need to disable it. + if file.size > 0 and file:content(file.size-1, 1) ~= '\n' then + file:insert(file.size, '\n') + end +end + +local function strip_final_newline(file) + -- In theory, this would have a complexity of O(n) as well and could + -- thus be made optional via edconf_hooks_enabled. On the other hand, + -- this is probably a very rare edge case, so stripping all trailing + -- newline characters is probably safe enough. + while file:content(file.size-1, 1) == '\n' do + file:delete(file.size-1, 1) + end +end + +local function trim_trailing_whitespace(file) + if not M.hooks_enabled then return end + for i=1, #file.lines do + if string.match(file.lines[i], '[ \t]$') then + file.lines[i] = string.gsub(file.lines[i], '[ \t]*$', '') + end + end +end + +local function enforce_crlf_eol(file) + if not M.hooks_enabled then return end + for i=1, #file.lines do + if not string.match(file.lines[i], '\r$') then + file.lines[i] = string.gsub(file.lines[i], '$', '\r') + end + end +end + +local function enforce_lf_eol(file) + if not M.hooks_enabled then return end + for i=1, #file.lines do + if string.match(file.lines[i], '\r$') then + file.lines[i] = string.gsub(file.lines[i], '\r$', '') + end + end +end + +M.max_line_length = 80 -- This is ugly, but we do want to use + -- single function that we can register + -- or unregister as needed +local function max_line_length(file) + if not M.hooks_enabled then return end + local overlong_lines = {} + for i=1, #file.lines do + if string.len(file.lines[i]) > M.max_line_length then + table.insert(overlong_lines, i) + end + end + if #overlong_lines > 0 then + local lines_are = (function(x) + if x>1 then return "lines are" else return "line is" end + end)(#overlong_lines) + vis:info(string.format( + "%d %s longer than %d characters: %s", + #overlong_lines, lines_are, M.max_line_length, + table.concat(overlong_lines, ",") + )) + end +end + +local OPTIONS = { + indent_style = function (value) + vis_set("expandtab", (value == "space")) + end, + + indent_size = function (value) + if value ~= "tab" then -- tab_width is a synonym anyway + vis_set("tabwidth", value) + end + end, + + tab_width = function (value) + vis_set("tabwidth", value) + end, + + spelling_language = function (value, file) + file.spelling_language = value + end, + + insert_final_newline = function (value) + -- According to the editorconfig specification, insert_final_newline + -- false is supposed to mean stripping the final newline, if present. + -- See https://editorconfig-specification.readthedocs.io/#supported-pairs + -- + -- Quote: insert_final_newline Set to true ensure file ends with a + -- newline when saving and false to ensure it doesn’t. + -- + set_pre_save(insert_final_newline, tostring(value == "true")) + set_pre_save(strip_final_newline, tostring(value == "false")) + end, + + trim_trailing_whitespace = function (value) + set_pre_save(trim_trailing_whitespace, value) + end, + + -- End of line is only partially implemented. While vis does not + -- support customized newlines, it does work well enough with crlf + -- newlines. Therefore, setting end_of_line=crlf will just ensure + -- that there is a cr at the end of each line. Setting end_of_line=lf + -- will strip any cr characters at the end of lines. This hopefully + -- eases the pain of working with crlf files a little. + end_of_line = function (value) + set_pre_save(enforce_crlf_eol, tostring(value == "crlf")) + set_pre_save(enforce_lf_eol, tostring(value == "lf")) + end, + + -- There is probably no straightforward way to enforce a maximum line + -- length across different programming languages. If a maximum line + -- length is set, we can at least issue a warning, however. + max_line_length = function(value) + if value ~= "off" then + M.max_line_length = tonumber(value) + end + set_pre_save(max_line_length, tostring(value ~= "off")) + end, + + -- Not supported by vis + -- charset + -- Partial support + -- end_of_line + -- max_line_length +} + +-- Compatible with editorconfig-core-lua v0.3.0 +local function ec_iter(p) + local i = 0 + local props, keys = ec.parse(p) + local n = #keys + return function () + i = i + 1 + if i <= n then + return keys[i], props[keys[i]] + end + end +end + +local function ec_set_values(win) + if not win or not win.file or not win.file.path then return end + for name, value in ec_iter(win.file.path) do + if OPTIONS[name] then + OPTIONS[name](value, win.file) + end + end +end + + +vis:command_register("econfig_parse", function() + ec_set_values(vis.win) +end, "(Re)parse an editorconfig file") + +vis.events.subscribe(vis.events.WIN_OPEN, function (win) + ec_set_values(win) +end) + +vis.events.subscribe(vis.events.FILE_SAVE_POST, function() + ec_set_values(vis.win) +end) + +return M diff --git a/.config/vis/vis-editorconfig/init.lua b/.config/vis/vis-editorconfig/init.lua new file mode 100644 index 0000000..39291d4 --- /dev/null +++ b/.config/vis/vis-editorconfig/init.lua @@ -0,0 +1,4 @@ +local source_str = debug.getinfo(1, 'S').source:sub(2) +local script_path = source_str:match('(.*/)') + +return dofile(script_path .. 'edconf.lua') diff --git a/.config/vis/vis-format/.editorconfig b/.config/vis/vis-format/.editorconfig new file mode 100644 index 0000000..7c67854 --- /dev/null +++ b/.config/vis/vis-format/.editorconfig @@ -0,0 +1,10 @@ +[*.lua] +indent_style = space +indent_size = 2 +max_line_length = 79 +quote_type = single + +[*.md] +max_line_length = 79 +indent_style = space +indent_size = 2 diff --git a/.config/vis/vis-format/LICENSE b/.config/vis/vis-format/LICENSE new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/.config/vis/vis-format/LICENSE @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/.config/vis/vis-format/README.md b/.config/vis/vis-format/README.md new file mode 100644 index 0000000..c310de6 --- /dev/null +++ b/.config/vis/vis-format/README.md @@ -0,0 +1,157 @@ +# vis-format - integrates vis with external formatters + +A plugin for [vis](https://github.com/martanne/vis) to integrate `prettier`, +`rustfmt` etc. + +### Installation + +Clone this repository to where you install your plugins. (If this is your first +plugin, running `git clone https://github.com/milhnl/vis-format` in +`~/.config/vis/` will probably work). + +Then, add something like the following to your `visrc`. + + local format = require('vis-format') + vis:map(vis.modes.NORMAL, '=', format.apply) + +### Usage + +Press `=` to format the whole file. + +Currently, the following formatters are supported out-of-the-box. + +- `bash`: [shfmt](https://github.com/mvdan/sh) +- `csharp`: [CSharpier](https://csharpier.com/). Although + [dotnet-format](https://github.com/dotnet/format) is the 'default' formatter + for dotnet, it does not support formatting stdin (and does not break lines). +- `git-commit`: Actually `diff` with an extra check, as that's how + `vis.ftdetect` ends up labeling it. Uses `fmt -w` and some glue code to + reformat the commit body, but not the summary and comments. +- `go`: `gofmt` +- `lua`: [StyLua](https://github.com/JohnnyMorganz/StyLua) and + [LuaFormatter](https://github.com/Koihik/LuaFormatter), depending on which + config file is in the working directory. +- `markdown`: `prettier` with `--prose-wrap` enabled if `colorcolumn` is set. +- `powershell`: + [PSScriptAnalyzer](https://learn.microsoft.com/en-gb/powershell/utility-modules/psscriptanalyzer/overview?view=ps-modules#installing-psscriptanalyzer) + via `powershell.exe` in the WSL if available or `pwsh`. +- `rust`: `rustfmt` +- `text`: `fmt` with width based on colorcolumn if set, otherwise joined + paragraphs. + +I'm working on some more heuristics for detecting which formatter to use for +languages without a 'blessed' formatter. In the meantime, this is how you add +the ones you want to use: + + format.formatters.html = format.stdio_formatter("prettier --parser html") + +### Advanced usage + +The following methods and tables are fields of the table that is returned by +`require('vis-format')` (e.g. `format`). You can use them to extend or +configure `vis-format`. + +#### `formatters` + +A table containing the configured formatters. There are some predefined (see +the list above under "Usage"), and you can add or override those by assigning +your formatter to a key corresponding to the vis `syntax` it is relevant for. +Each entry is of either of these forms: + + { + apply = func(win, range, pos) end, + options = { + ranged = nil, + check_same = nil, + } + } + +or + + { + pick = func(win, range, pos) end, + } + +The first form directly defines a formatter. An entry containing `pick` is +executed and its result is directly used as a formatter. A recommended way to +use `pick` is to return a different formatter from the `formatters` table. Note +that using the vis `syntax` as keys in this table is only necessary for +formatters that are run directly. This means that `lua` is a good key for a +`pick` entry, which chooses between the formatters found at `stylua` and +`luaformatter`. + +#### `stdio_formatter(command[, options])` + +The `stdio_formatter` function wraps the command to produce something like +this: + + { + apply = function(win, range, pos) end, + options = { ranged = false } + } + +The command given can also be a function, which is expected to return a string, +which is then used as a command. This allows you to use the given range, or +options from `win`. `ranged` is automatically set to true in this case. + +Apart from mapping `vis-format` in normal mode, you can also define an operator +(with `vis:operator_new`) to format ranges of code/text. This will require a +formatter that can work with ranges of text. Configuring that looks like this: + + -- Add a formatter that can use a range + format.formatters.lua = format.stdio_formatter(function(win, range, pos) + return 'stylua -s --range-start ' .. range.start .. ' --range-end ' + .. range.finish .. ' -' + end) + + -- Bind it to keys + vis:operator_new('=', format.apply) -- this'll handle ranges + vis:map(vis.modes.NORMAL, '=', function() -- this'll format whole files + format.apply(vis.win.file, nil, vis.win.selection.pos) + end) + +#### `with_filename` + +Most formatters take a path for where `stdin` would be. If the file has a path +`with_filename` concatenates the option and the shell-escaped path. Note that +it does not add any spaces to separate options/arguments. + + stdio_formatter(function(win) + return 'shfmt ' .. with_filename(win, '--filename ') .. ' -' + end, { ranged = false }) + +#### `options` + +The options listed here are also available in the options field of a formatter. + +- `options.check_same` (`boolean|number`) — After formatting, to avoid updating + the file, `vis-format` can compare the old and the new. If this is set to a + number, that's the maximum size of the file for which it is enabled. +- `options.on_save` (`boolean|function(win)`) — Enable a pre-save hook that + formats the file. If `on_save` is a function, it is run before saving to + determine whether formatting is required. + +### Bugs + +Ranged formatting is not enabled and will currently not work with `prettier`. +Prettier extends the range given on the command line to the beginning and end +of the statement containing it. This will not work with how `vis-format` +currently applies the output. I have some ideas on how to fix this, but wanted +to release what works first. + +#### Note on editor options and vis versions before 0.9 + +`vis` has an `options` table with editor settings like tab width etc. built-in +since 0.9. `vis-format` will not read this most of the time, because the +correct way to configure formatters is with their dedicated configuration +files, or `.editorconfig` (Which can be read in vis with +[vis-editorconfig](https://github.com/seifferth/vis-editorconfig) and +[vis-editorconfig-options](https://github.com/milhnl/vis-editorconfig-options) +). + +The included formatter integrations that _do_ use this information assume that +the `options` table in `vis` and `win` is present. If you use an older version, +`vis-format` will still work, but can't detect your editor settings. To fix +that, look at the +[vis-options-backport](https://github.com/milhnl/vis-options-backport) plugin. +This will 'polyfill' that for older versions. diff --git a/.config/vis/vis-format/init.lua b/.config/vis/vis-format/init.lua new file mode 100644 index 0000000..1843afd --- /dev/null +++ b/.config/vis/vis-format/init.lua @@ -0,0 +1,364 @@ +local format = { + options = { + check_same = true, + }, +} + +local with_filename = function(win, option) + if win.file.path then + return option .. "'" .. win.file.path:gsub("'", "\\'") .. "'" + else + return '' + end +end + +local heuristic_debug = '' +vis:command_register('format-debug', function() + vis:message(heuristic_debug) + return true +end) + +local new_pos_heuristic = function(win, new, pos) + local new_size = #new + do -- Try creating a pattern that'll match one position in the new content + local converters = { + function(fragment) + return fragment + :gsub('([(%:)%:.%:%%:+%:-%:*%:?%:[%:^%:$])', '%%%1') -- all rgx chars + :gsub('(%S)%s+', '%1%%s*') -- only leading space literal, rest flex + end, + function(fragment) + return fragment + :gsub('^%s+', '') -- ignore leading space + :gsub('([(%:)%:.%:%%:+%:-%:*%:?%:[%:^%:$])', '%%%1') -- all rgx chars + :gsub('%s+', '%%s*') -- flexibly match all space + end, + function(fragment) + return fragment + :gsub('%W+', '%%W+') -- only match on alphanumerics + :gsub('^%%W%+', '') -- ignore non-alphanumerics at start + end, + } + local converter_index = 1 + local fragment_size = 4 + heuristic_debug = heuristic_debug .. '\n-----------------------------\n' + while + fragment_size <= 1024 + and fragment_size <= (win.file.size - pos) * 2 + and converter_index <= #converters + do + local pattern = + converters[converter_index](win.file:content(pos, fragment_size)) + local new_pos = new:find(pattern) + heuristic_debug = heuristic_debug + .. ('pattern: ' .. pattern .. '\n') + .. ('pos: ' .. pos .. '\n') + .. ('new_pos: ' .. (new_pos or 'nil') .. '\n') + .. ('posdiff: ' .. math.abs((new_pos or 0) - pos) .. '\n') + .. ('sizediff: ' .. math.abs(new_size - win.file.size) .. '\n') + .. '\n' + if new_pos == nil then + converter_index = converter_index + 1 + elseif -- pattern has 1 match, and it isn't too far away (false positive) + math.abs(new_pos - pos) + < (math.abs(new_size - win.file.size) * 10 + 30) + and new:find(pattern, new_pos + 1) == nil + then + heuristic_debug = heuristic_debug .. '\nsuccess: ' .. new_pos .. '\n' + return new_pos - 1 + else + fragment_size = fragment_size * 2 + end + end + end + + do -- Try same offset of right side of the same line if # of lines matches + local new_pos, new_lines, new_line_start = nil, 1, nil + for i = 1, new_size do + if new:sub(i, i) == '\n' then + if new_lines == win.selection.line and new_line_start ~= nil then + local line_length = #win.file.lines[win.selection.line] + new_pos = i - line_length + win.selection.col - 2 + new_pos = new_line_start < new_pos and new_pos or new_line_start + end + new_lines = new_lines + 1 + if new_lines == win.selection.line then + new_line_start = i + end + end + end + if (new_lines - 1) == #win.file.lines then + return new_pos + end + end + + return nil +end + +local win_formatter = function(func, options) + return { + apply = function(win, range, pos) + if + range ~= nil + and not options.ranged + and range.start ~= 0 + and range.finish ~= win.file.size + then + return nil, + 'Formatter for ' .. win.syntax .. ' does not support ranges', + pos + end + local _, err, new_pos = func(win, range, pos) + vis:insert('') -- redraw and friends don't work + return nil, err, new_pos or pos + end, + options = options, + } +end + +local func_formatter = function(func, options) + return win_formatter(function(win, range, pos) + local size = win.file.size + local all = { start = 0, finish = size } + if range == nil then + range = all + end + local check_same = (options and options.check_same ~= nil) + and options.check_same + or format.options.check_same + local check = check_same == true + or (type(check_same) == 'number' and check_same >= size) + + local out, err, new_pos = func(win, range, pos) + if err ~= nil then + return nil, err, pos + elseif out == nil or out == '' then + return nil, 'No output from formatter', pos + elseif not check or win.file:content(all) ~= out then + new_pos = new_pos or new_pos_heuristic(win, out, pos) or pos + local start, finish = range.start, range.finish + win.file:delete(range) + win.file:insert(start, out:sub(start + 1, finish + (out:len() - size))) + end + return nil, nil, new_pos + end, options) +end + +local stdio_formatter = function(cmd, options) + return func_formatter(function(win, range, pos) + local command = type(cmd) == 'function' and cmd(win, range, pos) or cmd + local status, out, err = vis:pipe(win.file, range, command) + if status ~= 0 then + return nil, err, nil + end + return out, nil, nil + end, options or { ranged = type(cmd) == 'function' }) +end + +local prettier_formatter = function(cmd, options) + return func_formatter(function(win, range, pos) + local command = type(cmd) == 'function' and cmd(win, range, pos) or cmd + command = command + .. with_filename(win, ' --stdin-filepath ') + .. (' --cursor-offset ' .. pos) + local status, out, err = vis:pipe(win.file, range, command) + if status ~= 0 then + return nil, err, nil + end + local new_pos = tonumber(err) + return out, nil, new_pos >= 0 and new_pos or nil + end, options or { ranged = type(cmd) == 'function' }) +end + +local formatters = {} +formatters = { + bash = stdio_formatter(function(win) + return 'shfmt ' .. with_filename(win, '--filename ') .. ' -' + end), + csharp = stdio_formatter('dotnet csharpier'), + diff = { + pick = function(win) + for _, pattern in ipairs(vis.ftdetect.filetypes['git-commit'].ext) do + if ((win.file.name or ''):match('[^/]+$') or ''):match(pattern) then + return formatters['git-commit'] + end + end + end, + }, + ['git-commit'] = func_formatter(function(win, range, pos) + local width = (win.options and win.options.colorcolumn ~= 0) + and (win.options.colorcolumn - 1) + or 72 + local parts = {} + local fmt = nil + local summary = true + for line in win.file:lines_iterator() do + local txt = not line:match('^#') + if fmt == nil or fmt ~= txt then + fmt = txt and not summary + local prev = parts[#parts] and parts[#parts].finish or 0 + parts[#parts + 1] = { + fmt = fmt, + start = prev, + finish = prev + #line + 1, + } + summary = summary and not txt + else + parts[#parts].finish = parts[#parts].finish + #line + 1 + end + end + local out = '' + for _, part in ipairs(parts) do + if part.fmt then + local status, partout, err = + vis:pipe(win.file, part, 'fmt -w ' .. width) + if status ~= 0 then + return nil, err + end + out = out .. (partout or '') + else + out = out .. win.file:content(part) + end + end + return out + end, { ranged = false }), + go = stdio_formatter('gofmt'), + lua = { + pick = function(win) + local fz = io.popen([[ + test -e .lua-format && echo luaformatter || echo stylua + ]]) + if fz then + local out = fz:read('*a') + local _, _, status = fz:close() + if status == 0 then + return formatters[out:gsub('\n$', '')] + end + end + end, + }, + luaformatter = stdio_formatter('lua-format'), + markdown = prettier_formatter(function(win) + if win.options and win.options.colorcolumn ~= 0 then + return 'prettier --parser markdown --prose-wrap always ' + .. ('--print-width ' .. (win.options.colorcolumn - 1)) + else + return 'prettier --parser markdown' + end + end, { ranged = false }), + powershell = 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) + 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 ') + .. ' -' + else + return 'stylua -s ' .. 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) + else + return "fmt | awk -v n=-1 '" + .. ' {' + .. ' if ($0 == "") {' + .. ' n = n <= 0 ? 2 : 1' + .. ' } else {' + .. ' if (n == 0) sub(/^ */, "");' + .. ' n = 0;' + .. ' }' + .. ' printf("%s", $0 (n == 0 ? " " : ""));' + .. ' for(i = 0; i < n; i++)' + .. ' printf("\\n");' + .. ' }' + .. "'" + end + end, { ranged = false }), +} + +local getwinforfile = function(file) + for win in vis:windows() do + if win and win.file and win.file.path == file.path then + return win + end + end +end + +local pick = function(win) + local formatter = formatters[win.syntax] + if formatter and formatter.pick then + formatter = formatter.pick(win) + end + return formatter +end + +local keyhandler = function(file_or_keys, range, pos) + local _, err + 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 + end + or function() + win.selection.pos = pos + return 0 + end + pos = pos ~= nil and pos or win.selection.pos + local formatter = format.pick(win) + if formatter == nil then + vis:info('No formatter for ' .. win.syntax) + return ret() + end + _, err, pos = formatter.apply(win, range, pos) + if err ~= nil then + if err:match('\n') then + vis:message(err) + else + vis:info(err) + end + end + vis:insert('') -- redraw and friends don't work + return ret() +end + +vis.events.subscribe(vis.events.FILE_SAVE_PRE, function(file) + local win = type(file) ~= 'string' and getwinforfile(file) or vis.win + local formatter = format.pick(win) + if formatter == nil then + return + end + local on_save = (formatter.options and formatter.options.on_save ~= nil) + and formatter.options.on_save + or format.options.on_save + if type(on_save) == 'function' and not on_save(win) then + return + elseif not on_save then + return + end + local _, err, pos = formatter.apply(win, nil, win.selection.pos) + if err ~= nil then + vis:info('Warning: formatting failed. Run manually for details') + else + win.selection.pos = pos + vis:insert('') -- redraw and friends don't work + end +end) + +format.formatters = formatters +format.pick = pick +format.apply = keyhandler +format.stdio_formatter = stdio_formatter +format.with_filename = with_filename + +return format diff --git a/.config/vis/vis-quickfix/gitw b/.config/vis/vis-quickfix/gitw new file mode 100755 index 0000000..0f17645 --- /dev/null +++ b/.config/vis/vis-quickfix/gitw @@ -0,0 +1,20 @@ +#!/bin/sh + +git diff --no-prefix --no-ext-diff --relative -U0 | +awk ' +/^\+\+\+ / { + file = $2 + next +} + +file && /^@@/ { + match($0, /\+[0-9]+/) + line = substr($0, RSTART + 1, RLENGTH - 1) + next +} + +line && /^[+-]/ { + printf "%s:%d:%s\n", file, line, $0 + line = 0 +} +' diff --git a/.config/vis/vis-quickfix/init.lua b/.config/vis/vis-quickfix/init.lua new file mode 100644 index 0000000..a185ea3 --- /dev/null +++ b/.config/vis/vis-quickfix/init.lua @@ -0,0 +1,525 @@ +-- SPDX-License-Identifier: GPL-3.0-or-later +-- © 2020 Georgi Kirilov + +require("vis") +local vis = vis + +local getcwd + +if vis:module_exist"lfs" then + require"lfs" + local lfs = lfs + + getcwd = lfs.currentdir +else + getcwd = function() + return io.popen"pwd":read"*l" + end +end + +local progname = ... + +local M = { + grepformat = { + "^%s*([^:]+):(%d+):(%d+):(.*)$", -- git-grep with --column + "^%s*([^:]+):(%d+):(.-)(.*)$", + }, + errorformat = { + "^%s*([^:]+):(%d+):(%d+):(.*)$", + "^%s*([^:]+):(%d+):(.-)(.*)$", + "^(%S+) %S+ (%d+) (.-)(.*)$", -- cscope + [0] = { + ["Entering directory [`']([^']+)'"] = true, + ["Leaving directory [`']([^']+)'"] = false, + }, + }, + grepprg = "grep -n", + makeprg = "make -k", + errorfile = "errors.err", + peek = true, + menu = false, + action = {}, +} + +local cwin +local ctitle +local lines = {valid = {}} +local no_more = "No more items" +local no_errors = "No Errors" + +local function find_nearest_after(line) + local ccur + for c, v in ipairs(lines.valid) do + if v[1] >= line then + ccur = c + break + end + end + if not ccur then + return nil, no_more + end + return {ccur, lines.valid[ccur][1]} +end + +local function find_nth_valid(count) + if count < 1 or count > #lines.valid then + return nil, no_more + end + return {count, lines.valid[count][1]} +end + +local function set_marks(win, ccur) + if not ccur then return end + local fname = win.file.name + local pwd = getcwd() + local pathname = fname:find("^/") and fname or pwd .. "/" .. fname + local i = ccur + while lines.valid[i] and lines.valid[i].path == pathname do + i = i - 1 + end + local ln = lines.valid[i + 1] + while ln and ln.path == pathname do + -- I wish there was a way to convert from ln:col to pos + -- without setting the selection + win.selection:to(ln.line, ln.column or 1) + ln.mark = win.file:mark_set(win.selection.pos) + i = i + 1 + ln = lines.valid[i] + end +end + +local function botright_reopen(filename, ccur) + -- This function closes and opens windows in a specific order, just so + -- the error window ends up at bottom position. + -- This is fragile, and does not work in all possible situations. + -- Having a window with a modified file is one example. + -- Even if the file was not modified, closing the window will lead to loss of + -- any state local to it. + -- It would be nice if vis had :botright or something to that effect. + local cursors = {} + for w in vis:windows() do + if w.file.name then + cursors[w.file.name] = w.selection.pos + end + if cwin and w ~= cwin then + w:close() + end + end + for w in vis:windows() do + if w.file.name and w.file.modified then + vis:info"No write since last change" + return false + end + end + if filename then + vis:command(string.format((cwin and "open" or "e") .. " %q", filename)) + set_marks(vis.win, ccur) + if cursors[filename] then + vis.win.selection.pos = cursors[filename] + end + else + vis:command"new" + end + return true +end + +local function counter(ccur) + return string.format("%s/%d", + ccur or "-", + #lines.valid) +end + +local function display(ccur, cline) + local ln = lines.valid[ccur] + local pwd = getcwd() + local cname = ln.path:find(pwd) and ln.path:gsub(pwd, "", 1):gsub("^/", "") or ln.path + if vis.win.file.name ~= cname then + if not botright_reopen(ln.path, ccur) then return end + end + local column = ln.column + if type(column) ~= "number" then + column = nil + -- else + -- TODO: some tools report virtual columns, others - physical. + -- local indent = vis.win.file.lines[ln.line]:match"^%s+" or "" + -- local _, tabs = indent:gsub("\t", "") + -- -- XXX: assume tools to report 8 columns-wide tabs + -- column = column - tabs * 8 + tabs + end + if cwin then + cwin.selection:to(cline, 1) + local pos = cwin.selection.pos + local clen = cwin.file.lines[cline] + lines.range = {start = pos, finish = pos + #clen - 1} + end + if ln.mark then + local newpos = vis.win.file:mark_get(ln.mark) + if newpos then + vis.win.selection.pos = newpos + end + else + -- XXX: degrade to using raw line:column; + -- so far, only triggered by consecutive hard links + -- where vis keeps the old file.name but the error list + -- switches to the new. set_marks gets confused and sets no marks. + vis.win.selection:to(ln.line, column or 1) + end + if not cwin and ln.message then + vis:info(string.format("[%s] %s", counter(ccur), ln.message:gsub("^%s", ""))) + end + lines.ccur = ccur + lines.cline = cline +end + +local function _cc(count) + if not count then return end + local location, err = find_nth_valid(count) + if not location then + vis:info(err) + return + end + return table.unpack(location) +end + +local function guard(func) + return function(...) + if #lines.valid == 0 then + vis:info(no_errors) + return + end + local ccur, cline = func(...) + if ccur and cline then + display(ccur, cline) + end + end +end + +local cc = guard(function(count) + return _cc(count or lines.ccur or 1) +end) + +local cnext = guard(function(count) + return _cc((lines.ccur or 0) + (count or 1)) +end) + +local cprev = guard(function(count) + return _cc((lines.ccur or 2) - (count or 1)) +end) + +local crewind = guard(function() + return _cc(1) +end) + +local clast = guard(function() + return _cc(#lines.valid) +end) + +local cnfile = guard(function(count) + count = count or 1 + if not lines.ccur then + lines.ccur = 1 + end + local cur_fname = lines.valid[lines.ccur].path + for i = lines.ccur + 1, #lines.valid do + local filename = lines.valid[i].path + if filename then + if filename ~= cur_fname then + count = count - 1 + end + if count == 0 then + return i, lines.valid[i][1] + end + end + end + vis:info(no_more) +end) + +local cpfile = guard(function(count) + count = count or 1 + if not lines.ccur then + lines.ccur = 1 + end + local cur_fname = lines.valid[lines.ccur].path + for i = lines.ccur - 1, 1, -1 do + local filename = lines.valid[i].path + if filename then + if filename ~= cur_fname then + count = count - 1 + end + if count == 0 then + return i, lines.valid[i][1] + end + end + end + vis:info(no_more) +end) + +local function open_error_window() + if cwin then return end + if not ctitle then + vis:info(no_errors) + return + end + local fname = vis.win.file.name + vis:command"new" + cwin = vis.win + cwin.file:insert(0, lines.buffer or "") + cwin.file.modified = false + local cline1 + if lines.cline then + cline1 = lines.cline + else + local first = find_nth_valid(1) + cline1 = first and first[2] or 1 + end + cwin.selection:to(cline1, 1) + if lines.cline then + local pos = cwin.selection.pos + local clen = cwin.file.lines[lines.cline] + lines.range = {start = pos, finish = pos + #clen - 1} + end + if #lines.valid > 0 then + if cwin.options then + cwin.options.cursorline = true + else + vis:command"set cursorline" + end + end + cwin:map(vis.modes.NORMAL, "<Enter>", function() + if #lines.valid == 0 then + vis:info(no_errors) + return + end + local location, err = find_nearest_after(vis.win.selection.line) + if not location then + vis:info(err) + return + end + display(table.unpack(location)) + if M.menu then + cwin:close() + end + end) + botright_reopen(fname, lines.ccur) + vis:feedkeys"<vis-window-prev>" +end + +local function cwindow() + if cwin then + cwin:close(true) + else + open_error_window() + end +end + +local function store_from_string(str, fmt) + if str and string.len(str) == 0 then + str = nil + end + lines = {buffer = str, valid = {}} + if not lines.buffer then return end + if not fmt then + fmt = M.errorformat + elseif type(fmt) == "string" then + fmt = {fmt} + end + local i = 0 + local dirstack = {} + local pwd = getcwd() + for ln in lines.buffer:gmatch("[^\n]+") do + i = i + 1 + for patt, push in pairs(fmt[0] or {}) do + local dir = ln:match(patt) + if dir then + if push then + table.insert(dirstack, dir) + elseif dirstack[#dirstack] == dir then + table.remove(dirstack) + end + end + end + local cwd = dirstack[#dirstack] or pwd + local filename, line, column, message + for _, f in ipairs(fmt) do + filename, line, column, message = ln:match(f) + if filename and line then + break + end + end + if filename and line then + local pathname = filename:find("^/") and filename or string.format("%s/%s", cwd, filename) + local t = {i, path = pathname, line = tonumber(line), column = tonumber(column), message = message} + table.insert(lines.valid, t) + end + end +end + +local function store_from_file(errorfile) + if errorfile then + M.errorfile = errorfile + end + local efile = io.open(errorfile or M.errorfile) + if not efile then + vis:info(string.format("Can't open errorfile %s", errorfile or M.errorfile)) + return + end + local str = efile:read"*all" + efile:close() + store_from_string(str) + return true +end + +local function store_from_window(win) + local str = win.file:content(0, win.file.size) + store_from_string(str) +end + +local function cfile(argv) + if store_from_file(argv[1]) then + local was_open + if cwin then + cwin:close(true) + was_open = true + end + ctitle = string.format(argv[1] and "%s %s" or "%s", argv[0], argv[1]) + if was_open then + open_error_window() + end + crewind() + end +end + +local function cbuffer(argv) + store_from_window(vis.win) + local fname = vis.win.file.name + ctitle = string.format(fname and "%s (%s)" or "%s", argv[0], fname) + vis.win.file.modified = false + crewind() +end + +local function _cexpr(cmd, fmt, title, is_make) + if not cmd or #cmd == 0 then vis:info"Argument required" return end + ctitle = title or cmd + local code, stdout = vis:pipe(nil, nil, cmd .. " 2>&1") + local was_open + if cwin then + cwin:close(true) + was_open = true + end + store_from_string(stdout, fmt) + lines.code = code ~= 0 and code or nil + if is_make and code == 0 then + vis:info(string.format("'%s' finished", M.makeprg)) + return + end + if was_open or M.peek or #lines.valid == 0 then + open_error_window() + end + if not M.peek and #lines.valid > 0 then + crewind() + end +end + +local function quote_spaces(argv) + for i, arg in ipairs(argv) do + if arg:find("[ \t\n]") then + argv[i] = "'" .. arg .. "'" + end + end +end + +local function cexpr(argv) + quote_spaces(argv) + _cexpr(table.concat(argv, " ")) +end + +local function grep(argv) + quote_spaces(argv) + table.insert(argv, 1, M.grepprg) + _cexpr(table.concat(argv, " "), M.grepformat) +end + +local function make(argv) + quote_spaces(argv) + table.insert(argv, 1, M.makeprg) + _cexpr(table.concat(argv, " "), M.errorformat, nil, true) +end + +local function h(msg) + return string.format("|@%s| %s", progname, msg) +end + +vis.events.subscribe(vis.events.INIT, function() + -- These commands assume an existing error list: + local ccommands = { + cn = {cnext, "Display the [arg]-th next error"}, + cp = {cprev, "Display the [arg]-th previous error"}, + cnf = {cnfile, "Display the first error in the [arg]-th next file"}, + cpf = {cpfile, "Display the last error in the [arg]-th previous file"}, + cc = {cc, "Display [arg]-th error. If [arg] is omitted, the same error is displayed again."}, + cr = {crewind, "Display the first error"}, + cla = {clast, "Display the last error"}, + } + -- These commands create a new error list: + local qcommands = { + cf = {cfile, "Read the error list from [arg]"}, + cb = {cbuffer, "Read the error list from the current file"}, + cex = {cexpr, "Create an error list using the result of [args]"}, + grep = {grep, string.format("Create an error list using the result of '%s'", M.grepprg)}, + make = {make, string.format("Create an error list using the result of '%s'", M.makeprg)}, + cw = {cwindow, "Toggle the error window"}, + } + for cmd, def in pairs(ccommands) do + local func, help = table.unpack(def) + vis:command_register(cmd, function(argv) + local count = argv[1] and tonumber(argv[1]) + func(count) + end, h(help)) + M.action[cmd] = function(arg) + -- XXX: do not convert, say, "1" to 1; a digit can be passed by vis.map but it is not a count + local count = type(arg) == "number" and arg + func(count) + end + end + for cmd, def in pairs(qcommands) do + local func, help = table.unpack(def) + vis:command_register(cmd, func, h(help)) + end + M.cexpr = _cexpr + vis:option_register("qfm", "bool", function(value, toggle) + if toggle then + M.menu = not M.menu + else + M.menu = value + end + end, h"Menu - jumping to an error with <Enter> closes the error window") + vis:option_register("qfp", "bool", function(value, toggle) + if toggle then + M.peek = not M.peek + else + M.peek = value + end + end, h"Peek - :make, :grep, and :cex do not jump to the first error") +end) + +vis.events.subscribe(vis.events.WIN_STATUS, function(win) + if win ~= cwin then return end + win:status( + string.format(" [Quickfix List]%s :%s", (win.file.modified and " [+]" or ""), ctitle), + lines.code and string.format("exit: %d « [%s] ", lines.code, counter(lines.ccur)) + or string.format("[%s] ", counter(lines.ccur)) + ) +end) + +vis.events.subscribe(vis.events.WIN_CLOSE, function(win) + if win ~= cwin then return end + cwin = nil +end) + +vis.events.subscribe(vis.events.WIN_HIGHLIGHT, function(win) + if win ~= cwin then return end + if not (lines and lines.range) then return end + win:style(win.STYLE_CURSOR_PRIMARY, lines.range.start, lines.range.finish) +end) + +return M diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua new file mode 100644 index 0000000..898df9c --- /dev/null +++ b/.config/vis/visrc.lua @@ -0,0 +1,98 @@ +-- load standard vis module, providing parts of the Lua API +require('vis') +require('vis-editorconfig') +local quickfix = require('vis-quickfix') +local format = require('vis-format') +local m = vis.modes + +quickfix.grepprg = "rg --hidden --no-ignore-vcs --vimgrep" + +vis.ftdetect.filetypes.terraform = { + ext = { "%.tf$" }, +} +for k, _ in pairs(format.formatters) do + format.formatters[k] = nil +end +format.formatters.python = format.stdio_formatter("ruff format -", {on_save=true}) +format.formatters.terraform = format.stdio_formatter("terraform fmt -", {on_save=true}) + +vis.events.subscribe(vis.events.INIT, function() + vis:command"set shell '/usr/bin/bash'" + vis:command"set edconfhooks on" + vis:command"set theme lemonsoda" + + vis:map(m.INSERT, '<C-r>"', '<C-r>+') + vis:map(m.NORMAL, 'y', '<vis-register>+<vis-operator-yank>') + vis:map(m.VISUAL, 'y', '<vis-register>+<vis-operator-yank>') + vis:map(m.VISUAL_LINE, 'y', '<vis-register>+<vis-operator-yank>') + vis:map(m.NORMAL, 'd', '<vis-register>+<vis-operator-delete>') + vis:map(m.VISUAL, 'd', '<vis-register>+<vis-operator-delete>') + vis:map(m.VISUAL_LINE, 'd', '<vis-register>+<vis-operator-delete>') + vis:map(m.NORMAL, 'p', '<vis-register>+<vis-put-after>') + vis:map(m.VISUAL, 'p', '<vis-register>+<vis-put-after>') + vis:map(m.VISUAL_LINE, 'p', '<vis-register>+<vis-put-after>') + vis:map(m.NORMAL, 'P', '<vis-register>+<vis-put-before>') + vis:map(m.VISUAL, 'P', '<vis-register>+<vis-put-before>') + vis:map(m.VISUAL_LINE, 'P', '<vis-register>+<vis-put-before>') +end) + +local files = {} +vis.events.subscribe(vis.events.WIN_OPEN, function(win) + vis:command"set cul on" + local radix = files[vis.win.file.path] + for p, i in pairs(files) do + if (radix == nil) or (radix >= i) then + files[p] = i + 1 + end + end + if vis.win.file.path then + files[vis.win.file.path] = 0 + end +end) + +vis:map(m.NORMAL, "<M-x>b", function() + local keys = {} + for k in pairs(files) do if k ~= vis.win.file.path then table.insert(keys, k) end end + if next(keys) == nil then + return true + end + table.sort(keys, function(a, b) return files[a] < files[b] end) + local code, result, err = vis:pipe(table.concat(keys, "\n"), "vis-menu -l 3") + if result then + vis:command("e " .. result) + end + return true; +end) + +vis:map(m.NORMAL, "<M-x>~", function() + vis:command("cd " .. vis.win.file.path:match("(.+)/[^/]+$")) + return true; +end) +vis:map(m.NORMAL, "<M-x>f", function() + local code, result, err = vis:pipe("", "vis-open .") + if result then + + if not os.execute("cd " .. result) then + vis:command("e " .. result) + else + vis:command("cd " .. result) + local code, result, err = vis:pipe("", "lf --print-selection") + if not result then return true end + local lines = {} + for line in result:gmatch("[^\n]+") do table.insert(lines, line) end + if lines[1] then + vis:command("e " .. lines[1]) + end + end + return true; + end + return true; +end) +vis:map(m.NORMAL, "<M-x>-", function() + local code, result, err = vis:pipe("", "lf --print-selection") + vis:command("cd " .. err) + if result then + vis:command("e " .. result) + end + return true; +end) diff --git a/.config/wal/colorschemes/dark/default.json b/.config/wal/colorschemes/dark/default.json new file mode 100644 index 0000000..eed9503 --- /dev/null +++ b/.config/wal/colorschemes/dark/default.json @@ -0,0 +1,26 @@ +{ + "wallpaper": "/home/ivi/Wallpapers/nixos.png", + "special": { + "background": "#262626", + "foreground": "#dab997", + "cursor": "#dab997" + }, + "colors": { + "color0": "#262626", + "color1": "#d75f5f", + "color2": "#afaf00", + "color3": "#ffaf00", + "color4": "#83adad", + "color5": "#d485ad", + "color6": "#85ad85", + "color7": "#dab997", + "color8": "#8a8a8a", + "color9": "#d75f5f", + "color10": "#afaf00", + "color11": "#ffaf00", + "color12": "#83adad", + "color13": "#d485ad", + "color14": "#85ad85", + "color15": "#ebdbb2" + } +} diff --git a/.local/bin/putdotfiles b/.local/bin/putdotfiles new file mode 100755 index 0000000..d75599a --- /dev/null +++ b/.local/bin/putdotfiles @@ -0,0 +1,4 @@ +#!/bin/sh +putgitrepo \ + git@github.com:ivi-vink/dotfiles.git \ + /home/$USER diff --git a/.local/bin/putgitrepo b/.local/bin/putgitrepo new file mode 100755 index 0000000..ac91bb7 --- /dev/null +++ b/.local/bin/putgitrepo @@ -0,0 +1,13 @@ +#!/bin/sh +putgitrepo() { + # Downloads a gitrepo $1 and places the files in $2 only overwriting conflicts + [ -z "$3" ] && branch="master" || branch="$repobranch" + dir=$(mktemp -d) + [ ! -d "$2" ] && mkdir -p "$2" + chown "$name":wheel "$dir" "$2" + sudo -u "$name" git -C "$repodir" clone --depth 1 \ + --single-branch --no-tags -q --recursive -b "$branch" \ + --recurse-submodules "$1" "$dir" + sudo -u "$name" cp -rfT "$dir" "$2" +} +putgitrepo "$@" |
