diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index bbb3a495c22..57707bec131 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ git/gitconfig.local.symlink Brewfile.lock.json +todo/completion.zsh diff --git a/.gitmodules b/.gitmodules new file mode 100755 index 00000000000..435d1c4c2a8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,12 @@ +[submodule "external/zsh-syntax-highlighting"] + path = external/zsh-syntax-highlighting + url = https://github.com/zsh-users/zsh-syntax-highlighting.git +[submodule "external/zsh-completions"] + path = external/zsh-completions + url = https://github.com/zsh-users/zsh-completions.git +[submodule "external/zsh-history-substring-search"] + path = external/zsh-history-substring-search + url = https://github.com/zsh-users/zsh-history-substring-search.git +[submodule "external/zsh-autosuggestions"] + path = external/zsh-autosuggestions + url = https://github.com/zsh-users/zsh-autosuggestions.git diff --git a/LICENSE.md b/LICENSE.md old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 497d64c78ca..c1451c68d12 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ There's a few special files in the hierarchy. Run this: ```sh -git clone https://github.com/holman/dotfiles.git ~/.dotfiles +git clone https://github.com/bhillmann/dotfiles.git ~/.dotfiles cd ~/.dotfiles script/bootstrap ``` diff --git a/bin/battery-status b/bin/battery-status deleted file mode 100755 index a0f75f0fb94..00000000000 --- a/bin/battery-status +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# -# battery-status -# -# A quick little indicator for battery status on your Mac laptop, suitable for -# display in your prompt. - -if test ! "$(uname)" = "Darwin" - then - printf "" - exit 0 -fi - -battstat=$(pmset -g batt) -time_left=$(echo $battstat | - tail -1 | - cut -f2 | - awk -F"; " '{print $3}' | - cut -d' ' -f1 -) - -if [[ $(pmset -g ac) == *"No adapter attached."* ]] -then - emoji='šŸ”‹' -else - emoji='šŸ”Œ' -fi - -if [[ $time_left == *"(no"* || $time_left == *"not"* ]] -then - time_left='āŒ›ļø ' -fi - -if [[ $time_left == *"0:00"* ]] -then - time_left='āš”ļø ' -fi - -printf "\033[1;92m$emoji $time_left \033[0m" diff --git a/bin/e b/bin/e index 501ad6e372b..e31ae8898cd 100755 --- a/bin/e +++ b/bin/e @@ -1,16 +1,33 @@ -#!/bin/sh -# -# Quick shortcut to an editor. -# -# This means that as I travel back and forth between editors, hey, I don't have -# to re-learn any arcane commands. Neat. -# -# USAGE: -# -# $ e -# # => opens the current directory in your editor -# -# $ e . -# $ e /usr/local -# # => opens the specified directory in your editor -exec "$EDITOR" "${1:-.}" +#!/bin/bash -eux +exec vim "$@" +# # Wrapper script to invoke interactive emacs commands in a daemon instance. + +# # These days many people don't suspect it, +# # but Emacs got server ('emacs' binary) and client ('emacsclient') parts. +# # Launching server (i.e. default 'emacs' command) evaluates the config +# # and could potentially take seconds if it's very heavy +# # Launching the client however is lightning fast. It's just a matter of creating a window. + + +# ARGS=( +# # This trick gives you best of two worlds: if there is an Emacs daemon running, +# # it just connects to it. Otherwise, it spawns a daemon first and then connects to it. +# # Without this setting if you didn't have a daemon running, the command would fail. +# -a '' + +# # open a new fram on the current terminal +# # -nw +# # spawn new GUI window, otherwise it tries to launch client in terminal +# --create-frame +# --frame-parameters="'(fullscreen . maximized)" + +# # # process rest of arguments as elisp code +# # --eval +# # # bring focus to the window +# # '(select-frame-set-input-focus (selected-frame))' +# ) + +# # without any extra args it just invokes the daemon instance, otherwise executes the args +# exec emacsclient "${ARGS[@]}" \ +# "$@" # pass through whatever else you are trying to run + diff --git a/bin/fif b/bin/fif new file mode 100755 index 00000000000..c3a685a681a --- /dev/null +++ b/bin/fif @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# alternative using ripgrep-all (rga) combined with fzf-tmux preview +# implementation below makes use of "open" on macOS, which can be replaced by other commands if needed. +# allows to search in PDFs, E-Books, Office documents, zip, tar.gz, etc. (see https://github.com/phiresky/ripgrep-all) +# find-in-file - usage: fif or fif "string with spaces" or fif "regex" +#fif() { +# if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi +# read -r file line column <<< "$(rg --column --line-number --no-messages --hidden --ignore-case --no-heading --files-with-matches "$1" | fzf --preview "echo {} | cut -d ":" -f1" -0 -1 | awk -F: '{print $1, $2, $3}')" +# echo $column +# if [[ -n $file ]] +# then +# e +$line:$column $file +# fi +#} + + +# using ripgrep combined with preview +# find-in-file - usage: fif +fif() { + if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi + file=$(rg --column --line-number --ignore-case --no-messages --hidden --files-with-matches "$1" | fzf --preview "bat --style=changes --wrap never --color always {} | rg --ignore-case --pretty --context 10 '$1' {}" -0 -1) + if [[ -n $file ]] + then + e $file + fi +} + +#fif() { +# if [ ! "$#" -gt 0 ]; then echo "Need a string to search for!"; return 1; fi +# local file +# echo "$@" +# file="$(rga --max-count=1 --ignore-case --files-with-matches --no-messages "$@" | fzf-tmux +m --preview="rga --ignore-case --pretty --context 10 '"$@"' {}")" && open "$file" +#} + +fif "$@" +#echo "$line" +#echo $file +#echo $line +#[[ -n $selected ]] && e $selected diff --git a/bin/fzf-log b/bin/fzf-log new file mode 100755 index 00000000000..2a5e00ffe9f --- /dev/null +++ b/bin/fzf-log @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +hash=$(git log --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" | fzf | awk '{print $1}') +echo $hash | xclip +git showtool $hash \ No newline at end of file diff --git a/bin/git-copy-branch-name b/bin/git-copy-branch-name index 6251fdbdc9b..33adde8731c 100755 --- a/bin/git-copy-branch-name +++ b/bin/git-copy-branch-name @@ -1,7 +1,7 @@ -#!/bin/sh +#!/usr/bin/env sh # # Copy the current branch name to the clipboard. branch=$(git rev-parse --abbrev-ref HEAD) echo $branch -echo $branch | tr -d '\n' | tr -d ' ' | pbcopy +echo $branch | tr -d '\n' | tr -d ' ' | xclip diff --git a/bin/monitor b/bin/monitor new file mode 100755 index 00000000000..5ec97108276 --- /dev/null +++ b/bin/monitor @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +optirun intel-virtual-output diff --git a/bin/s b/bin/s new file mode 100755 index 00000000000..72c2b3e218c --- /dev/null +++ b/bin/s @@ -0,0 +1,2 @@ +#!/bin/bash -eux +exec e "(spacemacs/defer-until-after-user-config #'my/search)" \ No newline at end of file diff --git a/bin/sc b/bin/sc new file mode 100755 index 00000000000..a50d464d015 --- /dev/null +++ b/bin/sc @@ -0,0 +1,2 @@ +#!/bin/bash -eux +exec e "(spacemacs/defer-until-after-user-config #'my/search-code)" \ No newline at end of file diff --git a/bin/search b/bin/search deleted file mode 100755 index fc64731684d..00000000000 --- a/bin/search +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# -# Quick search in a directory for a string ($@). -# -set -e - -# use -iru to search directories ack usually ignores (like .git) -if [ -x /usr/bin/ack-grep ]; then - ack-grep -i "$@" -else - ack -i "$@" -fi diff --git a/bin/set-defaults b/bin/set-defaults deleted file mode 100755 index 333859619a8..00000000000 --- a/bin/set-defaults +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# -# Sets macOS defaults by running $ZSH/macos/set-defaults.sh. - -exec $ZSH/macos/set-defaults.sh diff --git a/bin/tm b/bin/tm new file mode 100755 index 00000000000..54ec1248033 --- /dev/null +++ b/bin/tm @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + + [[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" + if [ $1 ]; then + tmux $change -t "$1" 2>/dev/null || (tmux new-session -d -s $1 && tmux $change -t "$1"); return + fi + session=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | fzf --exit-0) && tmux $change -t "$session" || echo "No sessions found." \ No newline at end of file diff --git a/bin/todo b/bin/todo deleted file mode 100755 index 8a62cbde29a..00000000000 --- a/bin/todo +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# -# Creates something for me to do. -# -# I've used literally every todo list, app, program, script, everything. Even -# the ones you are building and haven't released yet. -# -# I've found that they're all nice in their nice ways, but I still don't use -# them, thus defeating the purpose of a todo list. -# -# All `todo` does is put a file on my Desktop with the filename given. That's -# it. I aggressively prune my desktop of old tasks and keep one or two on there -# at a time. Once I've finished a todo, I just delete the file. That's it. -# -# Millions of dollars later and `touch` wins. - -# Run our new web 2.0 todo list application and raise millions of VC dollars. -touch ~/Desktop/"$*" diff --git a/bin/zssh b/bin/zssh new file mode 100755 index 00000000000..4385b7a00d2 --- /dev/null +++ b/bin/zssh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +ssh "$@" -t zsh diff --git a/docker/aliases.zsh b/docker/aliases.zsh deleted file mode 100644 index 17b10f6bc90..00000000000 --- a/docker/aliases.zsh +++ /dev/null @@ -1,2 +0,0 @@ -alias d='docker $*' -alias d-c='docker-compose $*' diff --git a/emacs-doom/config.el b/emacs-doom/config.el new file mode 100644 index 00000000000..97d41a95429 --- /dev/null +++ b/emacs-doom/config.el @@ -0,0 +1,248 @@ +;;; $DOOMDIR/config.el -*- lexical-binding: t; -*- + +;; Place your private configuration here! Remember, you do not need to run 'doom +;; sync' after modifying this file! + + +;; Some functionality uses this to identify you, e.g. GPG configuration, email +;; clients, file templates and snippets. +(setq user-full-name "Benjamin Hillmann" + user-mail-address "hillmannben@gmail.com" + doom-font (font-spec :family "DejaVu Sans Mono" :size 16) + doom-theme 'doom-monokai-spectrum + display-line-numbers-type nil + + company-idle-delay nil + lsp-ui-sideline-enable nil + lsp-enable-symbol-highlighting nil) + +;; If you use `org' and don't want your org files in the default location below, +;; change `org-directory'. It must be set before org loads! +(setq org-directory (file-truename "~/Dropbox/org/") + org-ellipsis " ā–¼ " + org-adapt-indentation nil + org-habit-show-habits-only-for-today t + ben/org-agenda-directory (file-truename (concat org-directory "gtd/")) + zot-bib "~/Dropbox/zotero/references.bib" + deft-directory org-directory + zot-pdfs-directory "~/Dropbox/zotero/pdfs" + ) + +(setq search-highlight t + search-whitespace-regexp ".*?" + isearch-lax-whitespace t + isearch-regexp-lax-whitespace nil + isearch-lazy-highlight t + isearch-lazy-count t + lazy-count-prefix-format " (%s/%s) " + lazy-count-suffix-format nil + isearch-yank-on-move 'shift + isearch-allow-scroll 'unlimited) + + +;; Add the company-org-roam setup from here https://www.ianjones.us/own-your-second-brain +;; This is done automatically now in the org-roam package +;; (require 'company-org-roam) +;; (use-package company-org-roam +;; :when (featurep! :completion company) +;; :after org-roam +;; :config +;; (set-company-backend! 'org-mode '(company-org-roam company-yasnippet company-dabbrev))) + + +;; https://www.ianjones.us/org-roam-bibtex +;; set-up and install org-noter +;; setup ivy-bibtex ivy-bibtex +(use-package! ivy-bibtex + :config + ;; ivy-bibtex requires ivy's `ivy--regex-ignore-order` regex builder, which + ;; ignores the order of regexp tokens when searching for matching candidates. + ;; Add something like this to your init file: + (setq ivy-re-builders-alist + '((ivy-bibtex . ivy--regex-ignore-order) + (t . ivy--regex-plus)) + ) + ) + +;; Copied from the dotfiles of the original founder of org-roam +;; https://github.com/jethrokuan/dots/blob/master/.doom.d/config.el#L436 +(after! org-journal + (setq org-journal-date-prefix "#+TITLE: " + org-journal-file-format "%Y-%m-%d.org" + org-journal-dir (file-truename (concat org-directory "dailies")) + org-journal-carryover-items nil)) + +(after! org + :init + (require 'org-habit) + + (with-eval-after-load 'flycheck + (flycheck-add-mode 'proselint 'org-mode)) + + (map! :leader + :prefix "n" + "c" #'org-capture) + (map! :map org-mode-map + "M-n" #'outline-next-visible-heading + "M-p" #'outline-previous-visible-heading) + (setq org-src-window-setup 'current-window + org-return-follows-link t + org-babel-load-languages '((emacs-lisp . t) + (sh . t) + (rust . t) + (python . t) + (dot . t) + (R . t)) + org-confirm-babel-evaluate nil + org-use-speed-commands t + org-catch-invisible-edits 'show + org-preview-latex-image-directory "/tmp/ltximg/" + org-structure-template-alist '(("a" . "export ascii") + ("c" . "center") + ("C" . "comment") + ("e" . "example") + ("E" . "export") + ("h" . "export html") + ("l" . "export latex") + ("q" . "quote") + ("s" . "src") + ("v" . "verse") + ("el" . "src emacs-lisp") + ("d" . "definition") + ("t" . "theorem")))) + +(setq org-capture-templates + `(("i" "inbox" entry (file ,(concat ben/org-agenda-directory "inbox.org")) + "* TODO %?") + ("c" "org-protocol-capture" entry (file ,(concat ben/org-agenda-directory "inbox.org")) + "* TODO [[%:link][%:description]]\n\n %i" + :immediate-finish t))) + +(use-package! org-roam + :commands (org-roam-insert org-roam-find-file org-roam-switch-to-buffer org-roam) + :hook + (after-init . org-roam-mode) + :init + (map! :leader + :prefix "n" + :desc "org-roam" "l" #'org-roam + :desc "org-roam-insert" "i" #'org-roam-insert + :desc "org-roam-switch-to-buffer" "b" #'org-roam-switch-to-buffer + :desc "org-roam-find-file" "f" #'org-roam-find-file + :desc "org-roam-show-graph" "g" #'org-roam-show-graph + :desc "org-roam-insert" "i" #'org-roam-insert + :desc "org-roam-capture" "c" #'org-roam-capture) + (setq org-roam-directory org-directory + org-roam-db-location (concat org-directory "org-roam.db") + org-roam-db-gc-threshold most-positive-fixnum + org-roam-graph-exclude-matcher "private" + org-roam-tag-sources '(prop last-directory) + org-id-link-to-org-use-id t) + :config + (setq org-roam-capture-templates + '(("l" "lit" plain (function org-roam--capture-get-point) + "%?" + :file-name "lit/${slug}" + :head "#+title: ${title}\n" + :unnarrowed t) + ("c" "concept" plain (function org-roam--capture-get-point) + "%?" + :file-name "concepts/${slug}" + :head "#+title: ${title}\n" + :unnarrowed t) + ("p" "private" plain (function org-roam-capture--get-point) + "%?" + :file-name "private/${slug}" + :head "#+title: ${title}\n" + :unnarrowed t))) + ;; Keep org dailies in their own folder + ;; https://www.baty.net/2020/keeping-org-roam-daily-notes-in-a-separate-folder/ + (setq org-roam-dailies-capture-templates '(("d" "daily" plain (function org-roam-capture--get-point) "" + :immediate-finish t + :file-name "dailies/%<%Y-%m-%d>" + :head "#+TITLE: %<%Y-%m-%d>"))) + (setq org-roam-capture-ref-templates + '(("r" "ref" plain (function org-roam-capture--get-point) + "%?" + :file-name "lit/${slug}" + :head "#+roam_key: ${ref} +#+roam_tags: website +#+title: ${title} +- source :: ${ref}" + :unnarrowed t))) + (set-company-backend! 'org-mode '(company-capf))) + + +(use-package! org-roam-protocol + :after org-protocol) + +;; org-roam-bibtex (ORB) +;; stitches everything together +(use-package! org-roam-bibtex + :after (org-roam) + :hook (org-roam-mode . org-roam-bibtex-mode) + :config + (setq org-roam-bibtex-preformat-keywords + '("=key=" "title" "url" "file" "author-or-editor" "keywords")) + (setq orb-templates + `(("r" "ref" plain (function org-roam-capture--get-point) + "" + :file-name "lit/${slug}" + :head ,(concat + "#+setupfile: ./hugo_setup.org\n" + "#+title: ${=key=}: ${title}\n" + "#+roam_key: ${ref}\n\n" + "* ${title}\n" + " :PROPERTIES:\n" + " :Custom_ID: ${=key=}\n" + " :URL: ${url}\n" + " :AUTHOR: ${author-or-editor}\n" + " :NOTER_DOCUMENT: %(orb-process-file-field \"${=key=}\")\n" + " :NOTER_PAGE: \n" + " :END:\n") + :unnarrowed t)))) + + +(use-package! bibtex-completion + :config + (setq bibtex-completion-notes-path org-directory + bibtex-completion-bibliography zot-bib + bibtex-completion-pdf-field "file" + bibtex-completion-notes-template-multiple-files + (concat + "#+title: ${title}\n" + "#+roam_key: cite:${=key=}\n" + "* TODO Notes\n" + ":PROPERTIES:\n" + ":Custom_ID: ${=key=}\n" + ":NOTER_DOCUMENT: %(orb-process-file-field \"${=key=}\")\n" + ":AUTHOR: ${author-abbrev}\n" + ":JOURNAL: ${journaltitle}\n" + ":DATE: ${date}\n" + ":YEAR: ${year}\n" + ":DOI: ${doi}\n" + ":URL: ${url}\n" + ":END:\n\n" + ))) + +;; This determines the style of line numbers in effect. If set to `nil', line +;; numbers are disabled. For relative line numbers, set this to `relative'. +(setq display-line-numbers-type t) + + +;; Here are some additional functions/macros that could help you configure Doom: +;; +;; - `load!' for loading external *.el files relative to this one +;; - `use-package!' for configuring packages +;; - `after!' for running code after a package has loaded +;; - `add-load-path!' for adding directories to the `load-path', relative to +;; this file. Emacs searches the `load-path' when you load packages with +;; `require' or `use-package'. +;; - `map!' for binding new keys +;; +;; To get information about any of these functions/macros, move the cursor over +;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k'). +;; This will open documentation for it, including demos of how they are used. +;; +;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how +;; they are implemented. diff --git a/emacs-doom/init.el b/emacs-doom/init.el new file mode 100644 index 00000000000..1336802a1bc --- /dev/null +++ b/emacs-doom/init.el @@ -0,0 +1,184 @@ +;;; init.el -*- lexical-binding: t; -*- + +;; This file controls what Doom modules are enabled and what order they load +;; in. Remember to run 'doom sync' after modifying it! + +;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's +;; documentation. There you'll find a "Module Index" link where you'll find +;; a comprehensive list of Doom's modules and what flags they support. + +;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or +;; 'C-c c k' for non-vim users) to view its documentation. This works on +;; flags as well (those symbols that start with a plus). +;; +;; Alternatively, press 'gd' (or 'C-c c d') on a module to browse its +;; directory (for easy access to its source code). + +(doom! :input + ;;chinese + ;;japanese + ;;layout ; auie,ctsrnm is the superior home row + + :completion + company ; the ultimate code completion backend + ;;helm ; the *other* search engine for love and life + ;;ido ; the other *other* search engine... + ivy ; a search engine for love and life + + :ui + deft ; notational velocity for Emacs + doom ; what makes DOOM look the way it does + doom-dashboard ; a nifty splash screen for Emacs + doom-quit ; DOOM quit-message prompts when you quit Emacs + ;;fill-column ; a `fill-column' indicator + hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW + ;;hydra + ;;indent-guides ; highlighted indent columns + ;;ligatures ; ligatures and symbols to make your code pretty again + ;;minimap ; show a map of the code on the side + modeline ; snazzy, Atom-inspired modeline, plus API + ;;nav-flash ; blink cursor line after big motions + ;;neotree ; a project drawer, like NERDTree for vim + ophints ; highlight the region an operation acts on + (popup +all +defaults) ; tame sudden yet inevitable temporary windows + ;;tabs ; a tab bar for Emacs + ;;treemacs ; a project drawer, like neotree but cooler + ;;unicode ; extended unicode support for various languages + vc-gutter ; vcs diff in the fringe + vi-tilde-fringe ; fringe tildes to mark beyond EOB + ;;window-select ; visually switch windows + workspaces ; tab emulation, persistence & separate workspaces + zen ; distraction-free coding or writing + + :editor + (evil +everywhere); come to the dark side, we have cookies + file-templates ; auto-snippets for empty files + fold ; (nigh) universal code folding + ;;(format +onsave) ; automated prettiness + ;;god ; run Emacs commands without modifier keys + ;;lispy ; vim for lisp, for people who don't like vim + ;;multiple-cursors ; editing in many places at once + ;;objed ; text object editing for the innocent + ;;parinfer ; turn lisp into python, sort of + ;;rotate-text ; cycle region at point between text candidates + snippets ; my elves. They type so I don't have to + ;;word-wrap ; soft wrapping with language-aware indent + + :emacs + dired ; making dired pretty [functional] + electric ; smarter, keyword-based electric-indent + ;;ibuffer ; interactive buffer management + undo ; persistent, smarter undo for your inevitable mistakes + vc ; version-control and Emacs, sitting in a tree + + :term + ;;eshell ; the elisp shell that works everywhere + ;;shell ; simple shell REPL for Emacs + ;;term ; basic terminal emulator for Emacs + ;;vterm ; the best terminal emulation in Emacs + + :checkers + (syntax +childframe); tasing you for every semicolon you forget + spell ; tasing you for misspelling mispelling + ;;grammar ; tasing grammar mistake every you make + + :tools + ;;ansible + debugger ; FIXME stepping through code, to help you add bugs + direnv + ;;docker + editorconfig ; let someone else argue about tabs vs spaces + ;;ein ; tame Jupyter notebooks with emacs + (eval +overlay) ; run code, run (also, repls) + ;;gist ; interacting with github gists + (lookup +docsets + dictionary) ; navigate your code and its documentation + ;;lsp + magit ; a git porcelain for Emacs + ;;make ; run make tasks from Emacs + ;;pass ; password manager for nerds + pdf ; pdf enhancements + ;;prodigy ; FIXME managing external services & code builders + ;;rgb ; creating color strings + ;;taskrunner ; taskrunner for all your projects + ;;terraform ; infrastructure as code + ;;tmux ; an API for interacting with tmux + ;;upload ; map local to remote projects via ssh/ftp + + :os + (:if IS-MAC macos) ; improve compatibility with macOS + ;;tty ; improve the terminal Emacs experience + + :lang + ;;agda ; types of types of types of types... + ;;cc ; C/C++/Obj-C madness + ;;clojure ; java with a lisp + ;;common-lisp ; if you've seen one lisp, you've seen them all + ;;coq ; proofs-as-programs + ;;crystal ; ruby at the speed of c + ;;csharp ; unity, .NET, and mono shenanigans + data ; config/data formats + ;;(dart +flutter) ; paint ui and not much else + ;;elixir ; erlang done right + ;;elm ; care for a cup of TEA? + emacs-lisp ; drown in parentheses + ;;erlang ; an elegant language for a more civilized age + ;;ess ; emacs speaks statistics + ;;faust ; dsp, but you get to keep your soul + ;;fsharp ; ML stands for Microsoft's Language + ;;fstar ; (dependent) types and (monadic) effects and Z3 + ;;gdscript ; the language you waited for + ;;(go +lsp) ; the hipster dialect + ;;(haskell +dante) ; a language that's lazier than I am + ;;hy ; readability of scheme w/ speed of python + ;;idris ; + ;;json ; At least it ain't XML + ;;(java +meghanada) ; the poster child for carpal tunnel syndrome + ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) + julia ; a better, faster MATLAB + ;;kotlin ; a better, slicker Java(Script) + (latex +latexmk +cdlatex) ; writing papers in Emacs has never been so fun + ;;lean + ;;factor + ;;ledger ; an accounting system in Emacs + ;;lua ; one-based indices? one-based indices + markdown ; writing docs for people to ignore + ;;nim ; python + lisp at the speed of c + ;;nix ; I hereby declare "nix geht mehr!" + ;;ocaml ; an objective camel + (org +roam +noter +journal +present) ; organize your plain life in plain text + ;;php ; perl's insecure younger brother + ;;plantuml ; diagrams for confusing people more + ;;purescript ; javascript, but functional + python ; beautiful is better than ugly + ;;qt ; the 'cutest' gui framework ever + R + ;;racket ; a DSL for DSLs + ;;raku ; the artist formerly known as perl6 + ;;rest ; Emacs as a REST client + ;;rst ; ReST in peace + ;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"} + rust ; Fe2O3.unwrap().unwrap().unwrap().unwrap() + ;;scala ; java, but good + ;;scheme ; a fully conniving family of lisps + sh ; she sells {ba,z,fi}sh shells on the C xor + ;;sml + ;;solidity ; do you need a blockchain? No. + ;;swift ; who asked for emoji variables? + ;;terra ; Earth and Moon in alignment for performance. + ;;web ; the tubes + ;;yaml ; JSON, but readable + + :email + ;;(mu4e +gmail) + ;;notmuch + ;;(wanderlust +gmail) + + :app + ;;calendar + ;;irc ; how neckbeards socialize + ;;(rss +org) ; emacs as an RSS reader + ;;twitter ; twitter client https://twitter.com/vnought + + :config + ;;literate + (default +bindings +smartparens)) diff --git a/emacs-doom/packages.el b/emacs-doom/packages.el new file mode 100644 index 00000000000..ab6283cda89 --- /dev/null +++ b/emacs-doom/packages.el @@ -0,0 +1,64 @@ +;; -*- no-byte-compile: t; -*- +;;; $DOOMDIR/packages.el + +;; To install a package with Doom you must declare them here and run 'doom sync' +;; on the command line, then restart Emacs for the changes to take effect -- or +;; use 'M-x doom/reload'. + + +;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: +;(package! some-package) + +;; To install a package directly from a remote git repo, you must specify a +;; `:recipe'. You'll find documentation on what `:recipe' accepts here: +;; https://github.com/raxod502/straight.el#the-recipe-format +;(package! another-package +; :recipe (:host github :repo "username/repo")) + +;; If the package you are trying to install does not contain a PACKAGENAME.el +;; file, or is located in a subdirectory of the repo, you'll need to specify +;; `:files' in the `:recipe': +;(package! this-package +; :recipe (:host github :repo "username/repo" +; :files ("some-file.el" "src/lisp/*.el"))) + +;; If you'd like to disable a package included with Doom, you can do so here +;; with the `:disable' property: +;(package! builtin-package :disable t) + +;; You can override the recipe of a built in package without having to specify +;; all the properties for `:recipe'. These will inherit the rest of its recipe +;; from Doom or MELPA/ELPA/Emacsmirror: +;(package! builtin-package :recipe (:nonrecursive t)) +;(package! builtin-package-2 :recipe (:repo "myfork/package")) + +;; Specify a `:branch' to install a package from a particular branch or tag. +;; This is required for some packages whose default branch isn't 'master' (which +;; our package manager can't deal with; see raxod502/straight.el#279) +;(package! builtin-package :recipe (:branch "develop")) + +;; Use `:pin' to specify a particular commit to install. +;(package! builtin-package :pin "1a2b3c4d5e") + + +;; Doom's packages are pinned to a specific commit and updated from release to +;; release. The `unpin!' macro allows you to unpin single packages... +;(unpin! pinned-package) +;; ...or multiple packages +;(unpin! pinned-package another-pinned-package) +;; ...Or *all* packages (NOT RECOMMENDED; will likely break things) +;(unpin! t) + +;;; Code +;; Add company-org-roam from the tutorial here https://www.ianjones.us/own-your-second-brain +(package! company-org-roam + :recipe (:host github :repo "jethrokuan/company-org-roam")) + +(package! org-roam-bibtex + :recipe (:host github :repo "org-roam/org-roam-bibtex")) + +;;(package! org-ref +;; :recipe (:host github :repo "jkitchin/org-ref")) + +(package! ivy-bibtex + :recipe (:host github :repo "tmalsburg/helm-bibtex")) diff --git a/emacs/patch-babel-mypy.el b/emacs/patch-babel-mypy.el new file mode 100755 index 00000000000..3183d77c52a --- /dev/null +++ b/emacs/patch-babel-mypy.el @@ -0,0 +1,34 @@ +(setq --babel-mypy/exec-python " +output=$(python3 $tfile 2>&1) +res=$? +output=$(echo $output | sed \"$sed_command\") + +echo \"Python output [exit code $res]:\" +echo $output +") + + +(setq --babel-mypy/exec-mypy " +output=$(python3 -m mypy --show-error-codes --strict $tfile 2>&1) +res=$? +output=$(echo $output | sed \"$sed_command\") + +echo \"Mypy output [exit code $res]:\" +echo $output +") + +(setq --babel-mypy/exec-preamble " +tfile=$(mktemp) +cp /dev/stdin $tfile +sed_command=\"s#$tfile#input.py#g\" # need to replace tmp directory for deterministic output +") + +;; see https://code.orgmode.org/bzg/worg/raw/master/org-contrib/babel/ob-template.el +(defun org-babel-execute:mypy (body params) + (let* ((execute (assoc-default :eval params)) + (parts (if execute `(,--babel-mypy/exec-python "echo" ,--babel-mypy/exec-mypy) `(,--babel-mypy/exec-mypy))) + (cmd (string-join (cons --babel-mypy/exec-preamble parts)))) + (org-babel-eval cmd body))) + +;; TODO wonder if tangle helps with highlighting in emacs? +;; (add-to-list 'org-babel-tangle-lang-exts '("mypy" . "py")) diff --git a/emacs/patch-blog.el b/emacs/patch-blog.el new file mode 100755 index 00000000000..daf9ec3d050 --- /dev/null +++ b/emacs/patch-blog.el @@ -0,0 +1,5 @@ +;;; stuff relevant to my blog editing + +(with-eval-after-load 'org + (add-to-list 'org-tag-faces + '("noexport" . (:background "red" :weight bold)))) diff --git a/emacs/patch-helm.el b/emacs/patch-helm.el new file mode 100755 index 00000000000..c11a7447cea --- /dev/null +++ b/emacs/patch-helm.el @@ -0,0 +1,20 @@ +; -*- mode: Lisp; paredit-mode: 0; -*- + + +; reason for patching: need to pass down 'targets' argument +; TODO commit it to spacemacs? +(el-patch-feature helm) +(with-eval-after-load 'helm +(el-patch-defun spacemacs/helm-files-do-rg (&optional dir targets) + "Search in files with `rg'." + (interactive) + ;; --line-number forces line numbers (disabled by default on windows) + ;; no --vimgrep because it adds column numbers that wgrep can't handle + ;; see https://github.com/syl20bnr/spacemacs/pull/8065 + (let* ((root-helm-ag-base-command "rg --smart-case --no-heading --color never --line-number") + (helm-ag-base-command (if spacemacs-helm-rg-max-column-number + (concat root-helm-ag-base-command " --max-columns " (number-to-string spacemacs-helm-rg-max-column-number)) + root-helm-ag-base-command))) + (helm-do-ag dir (el-patch-add targets)))) + +) diff --git a/emacs/patch-org-drill.el b/emacs/patch-org-drill.el new file mode 100755 index 00000000000..85332b24fa9 --- /dev/null +++ b/emacs/patch-org-drill.el @@ -0,0 +1,74 @@ +; -*- mode: Lisp; paredit-mode: 0; -*- + + +; reason for patching: I want to support really simple card types, kind of like simple topics +; (see https://gitlab.com/phillord/org-drill/tree/master#simple-topics) +; , but without even needing an answer + +; TODO add test? +; TODO propose it to org-drill? + +(el-patch-feature org-drill) +(with-eval-after-load 'org-drill + +(el-patch-defun org-drill-entry-status (session) + "Returns a list (STATUS DUE AGE) where DUE is the number of days overdue, +zero being due today, -1 being scheduled 1 day in the future. +AGE is the number of days elapsed since the item was created (nil if unknown). +STATUS is one of the following values: +- nil, if the item is not a drill entry, or has an empty body +- :unscheduled +- :future +- :new +- :failed +- :overdue +- :young +- :old +" + (save-excursion + (unless (org-at-heading-p) + (org-back-to-heading)) + (let ((due (org-drill-entry-days-overdue session)) + (age (org-drill-entry-days-since-creation session t)) + (last-int (org-drill-entry-last-interval 1))) + (list + (cond + ((not (org-drill-entry-p)) + nil) + ((and (org-drill-entry-empty-p) + (let* ((card-type (org-entry-get (point) "DRILL_CARD_TYPE" nil)) + (dat (cdr (assoc card-type org-drill-card-type-alist)))) + ((el-patch-swap or and) (null card-type) + (not (cl-third dat))))) + ;; body is empty, and this is not a card type where empty bodies are + ;; meaningful, so skip it. + nil) + ((null due) ; unscheduled - usually a skipped leech + :unscheduled) + ;; ((eql -1 due) + ;; :tomorrow) + ((cl-minusp due) ; scheduled in the future + :future) + ;; The rest of the stati all denote 'due' items ========================== + ((<= (org-drill-entry-last-quality 9999) + org-drill-failure-quality) + ;; Mature entries that were failed last time are + ;; FAILED, regardless of how young, old or overdue + ;; they are. + :failed) + ((org-drill-entry-new-p) + :new) + ((org-drill-entry-overdue-p session due last-int) + ;; Overdue status overrides young versus old + ;; distinction. + ;; Store marker + due, for sorting of overdue entries + :overdue) + ((<= (org-drill-entry-last-interval 9999) + org-drill-days-before-old) + :young) + (t + :old)) + due age)))) + + +) diff --git a/emacs/patch-org.el b/emacs/patch-org.el new file mode 100755 index 00000000000..45826756d30 --- /dev/null +++ b/emacs/patch-org.el @@ -0,0 +1,61 @@ +; assumes with-eval-after-load 'org + +;; TODO eh, should probably reuse org-insert-heading-after-current ? +(defun my/org-quicknote () + """ + Inserts child heading with an inactive timestamp, useful for adding quick notes to org items + + E.g. before: + + * parent note + some text + ** child + child text + + after you call this function, you end up with: + * parent note + some text + ** child + child text + ** [YYYY-MM-DD Mom HH:MM] + + """ + (interactive) + (let* ((has-children (save-excursion (org-goto-first-child)))) + (org-end-of-subtree) + (let ((org-blank-before-new-entry nil)) (org-insert-heading)) + (org-time-stamp '(16) t) ; 16 means inactive + (if has-children nil (org-do-demote)) (insert " ") + (evil-append 1))) + +(defun my/org-eshell-command (command) + ;; run command in eshell (e.g. [[eshell: ls -al /home]] + (interactive) + (progn + (eshell) + (eshell-return-to-prompt) + (insert command) + (eshell-send-input))) + +;; TODO export it properly? +(org-add-link-type "eshell" 'my/org-eshell-command) + + +;; 'p': raw prefix, 'P': numeric prefix. confusing ... +(defun my/org-wipe-subtree (&optional n) + (interactive "p") + (org-cut-subtree n) + (pop kill-ring)) + + +;; TODO extract in a sep function? e.g. with-current-entry? +;; TODO ert-deftest? +(defun my/org-inline-created () + "Convert CREATED property into inline date" + (interactive) + (let ((created (org-entry-get (point) "CREATED")) + (heading (org-get-heading t t t t))) ;; t t t t means include everything + (save-excursion + (org-back-to-heading t) + (org-edit-headline (concat created " " heading))) + (org-entry-delete (point) "CREATED"))) diff --git a/emacs/patch-python.el b/emacs/patch-python.el new file mode 100755 index 00000000000..dd59bddbcfe --- /dev/null +++ b/emacs/patch-python.el @@ -0,0 +1,13 @@ +; assumes with-eval-after-load 'python + +(with-eval-after-load 'importmagic + (setq importmagic-style-configuration-alist + '((multiline . backslash) + (max_columns . 150)))) + +(with-eval-after-load 'lsp-mode + (setq lsp-pyls-plugins-pylint-args '("--errors-only")) + (setq lsp-pyls-plugins-pyflakes-enabled nil)) + +; TODO disable live mode for mypy? +; https://github.com/warchiefx/dotemacs/blob/e71c779f28955eaa234c097afd6e492ec3ba642e/site-wcx/wcx-lsp.el#L20 diff --git a/emacs/spacemacs.symlink b/emacs/spacemacs.symlink new file mode 100755 index 00000000000..545f38da749 --- /dev/null +++ b/emacs/spacemacs.symlink @@ -0,0 +1,556 @@ +;; -*- mode: emacs-lisp; lexical-binding: t -*- +;; This file is loaded by Spacemacs at startup. +;; It must be stored in your home directory. + +;; To edit press SPC f e d +;; To reload press SPC f e R + +;; added on 20.09.01 from this link https://github.com/syl20bnr/spacemacs/issues/5554 +(defun ask-user-about-lock (file other-user) + "A value of t says to grab the lock on the file." + t) + +(defun dotspacemacs/layers () + "Layer configuration: +This function should only modify configuration layer settings." + (setq-default + ;; Base distribution to use. This is a layer contained in the directory + ;; `+distribution'. For now available distributions are `spacemacs-base' + ;; or `spacemacs'. (default 'spacemacs) + dotspacemacs-distribution 'spacemacs + + ;; Lazy installation of layers (i.e. layers are installed only when a file + ;; with a supported type is opened). Possible values are `all', `unused' + ;; and `nil'. `unused' will lazy install only unused layers (i.e. layers + ;; not listed in variable `dotspacemacs-configuration-layers'), `all' will + ;; lazy install any layer that support lazy installation even the layers + ;; listed in `dotspacemacs-configuration-layers'. `nil' disable the lazy + ;; installation feature and you have to explicitly list a layer in the + ;; variable `dotspacemacs-configuration-layers' to install it. + ;; (default 'unused) + dotspacemacs-enable-lazy-installation 'unused + + ;; If non-nil then Spacemacs will ask for confirmation before installing + ;; a layer lazily. (default t) + dotspacemacs-ask-for-lazy-installation t + + ;; List of additional paths where to look for configuration layers. + ;; Paths must have a trailing slash (i.e. `~/.mycontribs/') + dotspacemacs-configuration-layer-path '() + + ;; List of configuration layers to load. + dotspacemacs-configuration-layers + '(html + ;; ---------------------------------------------------------------- + ;; Example of useful layers you may want to use right away. + ;; Uncomment some layer names and press `SPC f e R' (Vim style) or + ;; `M-m f e R' (Emacs style) to install them. + ;; ---------------------------------------------------------------- + auto-completion + bibtex + better-defaults + emacs-lisp + ivy + git + ;; helm + lsp + markdown + multiple-cursors + org + (shell :variables + shell-default-height 30 + shell-default-position 'bottom) + ;; pdf-tools + spell-checking + syntax-checking + treemacs + version-control + ) + + ;; List of additional packages that will be installed without being + ;; wrapped in a layer. If you need some configuration for these + ;; packages, then consider creating a layer. You can also put the + ;; configuration in `dotspacemacs/user-config'. + ;; To use a local version of a package, use the `:location' property: + ;; '(your-package :location "~/path/to/your-package/") + ;; Also include the dependencies as they will not be resolved automatically. + dotspacemacs-additional-packages + '( + interleave + ;; org-ref + ;; helm-rg + ;; el-patch + ) + + ;; A list of packages that cannot be updated. + dotspacemacs-frozen-packages '() + + ;; A list of packages that will not be installed and loaded. + dotspacemacs-excluded-packages '() + + ;; Defines the behaviour of Spacemacs when installing packages. + ;; Possible values are `used-only', `used-but-keep-unused' and `all'. + ;; `used-only' installs only explicitly used packages and deletes any unused + ;; packages as well as their unused dependencies. `used-but-keep-unused' + ;; installs only the used packages but won't delete unused ones. `all' + ;; installs *all* packages supported by Spacemacs and never uninstalls them. + ;; (default is `used-only') + dotspacemacs-install-packages 'used-only)) + +(defun dotspacemacs/init () + "Initialization: +This function is called at the very beginning of Spacemacs startup, +before layer configuration. +It should only modify the values of Spacemacs settings." + ;; This setq-default sexp is an exhaustive list of all the supported + ;; spacemacs settings. + (setq-default + ;; If non-nil then enable support for the portable dumper. You'll need + ;; to compile Emacs 27 from source following the instructions in file + ;; EXPERIMENTAL.org at to root of the git repository. + ;; (default nil) + dotspacemacs-enable-emacs-pdumper nil + + ;; Name of executable file pointing to emacs 27+. This executable must be + ;; in your PATH. + ;; (default "emacs") + dotspacemacs-emacs-pdumper-executable-file "emacs" + + ;; Name of the Spacemacs dump file. This is the file will be created by the + ;; portable dumper in the cache directory under dumps sub-directory. + ;; To load it when starting Emacs add the parameter `--dump-file' + ;; when invoking Emacs 27.1 executable on the command line, for instance: + ;; ./emacs --dump-file=$HOME/.emacs.d/.cache/dumps/spacemacs-27.1.pdmp + ;; (default (format "spacemacs-%s.pdmp" emacs-version)) + dotspacemacs-emacs-dumper-dump-file (format "spacemacs-%s.pdmp" emacs-version) + + ;; If non-nil ELPA repositories are contacted via HTTPS whenever it's + ;; possible. Set it to nil if you have no way to use HTTPS in your + ;; environment, otherwise it is strongly recommended to let it set to t. + ;; This variable has no effect if Emacs is launched with the parameter + ;; `--insecure' which forces the value of this variable to nil. + ;; (default t) + dotspacemacs-elpa-https t + + ;; Maximum allowed time in seconds to contact an ELPA repository. + ;; (default 5) + dotspacemacs-elpa-timeout 5 + + ;; Set `gc-cons-threshold' and `gc-cons-percentage' when startup finishes. + ;; This is an advanced option and should not be changed unless you suspect + ;; performance issues due to garbage collection operations. + ;; (default '(100000000 0.1)) + dotspacemacs-gc-cons '(100000000 0.1) + + ;; Set `read-process-output-max' when startup finishes. + ;; This defines how much data is read from a foreign process. + ;; Setting this >= 1 MB should increase performance for lsp servers + ;; in emacs 27. + ;; (default (* 1024 1024)) + dotspacemacs-read-process-output-max (* 1024 1024) + + ;; If non-nil then Spacelpa repository is the primary source to install + ;; a locked version of packages. If nil then Spacemacs will install the + ;; latest version of packages from MELPA. (default nil) + dotspacemacs-use-spacelpa nil + + ;; If non-nil then verify the signature for downloaded Spacelpa archives. + ;; (default t) + dotspacemacs-verify-spacelpa-archives t + + ;; If non-nil then spacemacs will check for updates at startup + ;; when the current branch is not `develop'. Note that checking for + ;; new versions works via git commands, thus it calls GitHub services + ;; whenever you start Emacs. (default nil) + dotspacemacs-check-for-update nil + + ;; If non-nil, a form that evaluates to a package directory. For example, to + ;; use different package directories for different Emacs versions, set this + ;; to `emacs-version'. (default 'emacs-version) + dotspacemacs-elpa-subdirectory 'emacs-version + + ;; One of `vim', `emacs' or `hybrid'. + ;; `hybrid' is like `vim' except that `insert state' is replaced by the + ;; `hybrid state' with `emacs' key bindings. The value can also be a list + ;; with `:variables' keyword (similar to layers). Check the editing styles + ;; section of the documentation for details on available variables. + ;; (default 'vim) + dotspacemacs-editing-style 'vim + + ;; If non-nil show the version string in the Spacemacs buffer. It will + ;; appear as (spacemacs version)@(emacs version) + ;; (default t) + dotspacemacs-startup-buffer-show-version t + + ;; Specify the startup banner. Default value is `official', it displays + ;; the official spacemacs logo. An integer value is the index of text + ;; banner, `random' chooses a random text banner in `core/banners' + ;; directory. A string value must be a path to an image format supported + ;; by your Emacs build. + ;; If the value is nil then no banner is displayed. (default 'official) + dotspacemacs-startup-banner 'official + + ;; List of items to show in startup buffer or an association list of + ;; the form `(list-type . list-size)`. If nil then it is disabled. + ;; Possible values for list-type are: + ;; `recents' `bookmarks' `projects' `agenda' `todos'. + ;; List sizes may be nil, in which case + ;; `spacemacs-buffer-startup-lists-length' takes effect. + dotspacemacs-startup-lists '((recents . 5) + (projects . 7)) + + ;; True if the home buffer should respond to resize events. (default t) + dotspacemacs-startup-buffer-responsive t + + ;; Default major mode for a new empty buffer. Possible values are mode + ;; names such as `text-mode'; and `nil' to use Fundamental mode. + ;; (default `text-mode') + dotspacemacs-new-empty-buffer-major-mode 'text-mode + + ;; Default major mode of the scratch buffer (default `text-mode') + dotspacemacs-scratch-mode 'text-mode + + ;; Initial message in the scratch buffer, such as "Welcome to Spacemacs!" + ;; (default nil) + dotspacemacs-initial-scratch-message nil + + ;; List of themes, the first of the list is loaded when spacemacs starts. + ;; Press `SPC T n' to cycle to the next theme in the list (works great + ;; with 2 themes variants, one dark and one light) + dotspacemacs-themes '(spacemacs-dark + spacemacs-light) + + ;; Set the theme for the Spaceline. Supported themes are `spacemacs', + ;; `all-the-icons', `custom', `doom', `vim-powerline' and `vanilla'. The + ;; first three are spaceline themes. `doom' is the doom-emacs mode-line. + ;; `vanilla' is default Emacs mode-line. `custom' is a user defined themes, + ;; refer to the DOCUMENTATION.org for more info on how to create your own + ;; spaceline theme. Value can be a symbol or list with additional properties. + ;; (default '(spacemacs :separator wave :separator-scale 1.5)) + dotspacemacs-mode-line-theme '(spacemacs :separator wave :separator-scale 1.5) + + ;; If non-nil the cursor color matches the state color in GUI Emacs. + ;; (default t) + dotspacemacs-colorize-cursor-according-to-state t + + ;; Default font or prioritized list of fonts. + dotspacemacs-default-font '("Source Code Pro" + :size 10.0 + :weight normal + :width normal) + + ;; The leader key (default "SPC") + dotspacemacs-leader-key "SPC" + + ;; The key used for Emacs commands `M-x' (after pressing on the leader key). + ;; (default "SPC") + dotspacemacs-emacs-command-key "SPC" + + ;; The key used for Vim Ex commands (default ":") + dotspacemacs-ex-command-key ":" + + ;; The leader key accessible in `emacs state' and `insert state' + ;; (default "M-m") + dotspacemacs-emacs-leader-key "M-m" + + ;; Major mode leader key is a shortcut key which is the equivalent of + ;; pressing ` m`. Set it to `nil` to disable it. (default ",") + dotspacemacs-major-mode-leader-key "," + + ;; Major mode leader key accessible in `emacs state' and `insert state'. + ;; (default "C-M-m" for terminal mode, "" for GUI mode). + ;; Thus M-RET should work as leader key in both GUI and terminal modes. + ;; C-M-m also should work in terminal mode, but not in GUI mode. + dotspacemacs-major-mode-emacs-leader-key (if window-system "" "C-M-m") + + ;; These variables control whether separate commands are bound in the GUI to + ;; the key pairs `C-i', `TAB' and `C-m', `RET'. + ;; Setting it to a non-nil value, allows for separate commands under `C-i' + ;; and TAB or `C-m' and `RET'. + ;; In the terminal, these pairs are generally indistinguishable, so this only + ;; works in the GUI. (default nil) + dotspacemacs-distinguish-gui-tab nil + + ;; Name of the default layout (default "Default") + dotspacemacs-default-layout-name "Default" + + ;; If non-nil the default layout name is displayed in the mode-line. + ;; (default nil) + dotspacemacs-display-default-layout nil + + ;; If non-nil then the last auto saved layouts are resumed automatically upon + ;; start. (default nil) + dotspacemacs-auto-resume-layouts nil + + ;; If non-nil, auto-generate layout name when creating new layouts. Only has + ;; effect when using the "jump to layout by number" commands. (default nil) + dotspacemacs-auto-generate-layout-names nil + + ;; Size (in MB) above which spacemacs will prompt to open the large file + ;; literally to avoid performance issues. Opening a file literally means that + ;; no major mode or minor modes are active. (default is 1) + dotspacemacs-large-file-size 1 + + ;; Location where to auto-save files. Possible values are `original' to + ;; auto-save the file in-place, `cache' to auto-save the file to another + ;; file stored in the cache directory and `nil' to disable auto-saving. + ;; (default 'cache) + dotspacemacs-auto-save-file-location 'cache + + ;; Maximum number of rollback slots to keep in the cache. (default 5) + dotspacemacs-max-rollback-slots 5 + + ;; If non-nil, the paste transient-state is enabled. While enabled, after you + ;; paste something, pressing `C-j' and `C-k' several times cycles through the + ;; elements in the `kill-ring'. (default nil) + dotspacemacs-enable-paste-transient-state nil + + ;; Which-key delay in seconds. The which-key buffer is the popup listing + ;; the commands bound to the current keystroke sequence. (default 0.4) + dotspacemacs-which-key-delay 0.4 + + ;; Which-key frame position. Possible values are `right', `bottom' and + ;; `right-then-bottom'. right-then-bottom tries to display the frame to the + ;; right; if there is insufficient space it displays it at the bottom. + ;; (default 'bottom) + dotspacemacs-which-key-position 'bottom + + ;; Control where `switch-to-buffer' displays the buffer. If nil, + ;; `switch-to-buffer' displays the buffer in the current window even if + ;; another same-purpose window is available. If non-nil, `switch-to-buffer' + ;; displays the buffer in a same-purpose window even if the buffer can be + ;; displayed in the current window. (default nil) + dotspacemacs-switch-to-buffer-prefers-purpose nil + + ;; If non-nil a progress bar is displayed when spacemacs is loading. This + ;; may increase the boot time on some systems and emacs builds, set it to + ;; nil to boost the loading time. (default t) + dotspacemacs-loading-progress-bar t + + ;; If non-nil the frame is fullscreen when Emacs starts up. (default nil) + ;; (Emacs 24.4+ only) + dotspacemacs-fullscreen-at-startup nil + + ;; If non-nil `spacemacs/toggle-fullscreen' will not use native fullscreen. + ;; Use to disable fullscreen animations in OSX. (default nil) + dotspacemacs-fullscreen-use-non-native nil + + ;; If non-nil the frame is maximized when Emacs starts up. + ;; Takes effect only if `dotspacemacs-fullscreen-at-startup' is nil. + ;; (default nil) (Emacs 24.4+ only) + dotspacemacs-maximized-at-startup nil + + ;; If non-nil the frame is undecorated when Emacs starts up. Combine this + ;; variable with `dotspacemacs-maximized-at-startup' in OSX to obtain + ;; borderless fullscreen. (default nil) + dotspacemacs-undecorated-at-startup nil + + ;; A value from the range (0..100), in increasing opacity, which describes + ;; the transparency level of a frame when it's active or selected. + ;; Transparency can be toggled through `toggle-transparency'. (default 90) + dotspacemacs-active-transparency 90 + + ;; A value from the range (0..100), in increasing opacity, which describes + ;; the transparency level of a frame when it's inactive or deselected. + ;; Transparency can be toggled through `toggle-transparency'. (default 90) + dotspacemacs-inactive-transparency 90 + + ;; If non-nil show the titles of transient states. (default t) + dotspacemacs-show-transient-state-title t + + ;; If non-nil show the color guide hint for transient state keys. (default t) + dotspacemacs-show-transient-state-color-guide t + + ;; If non-nil unicode symbols are displayed in the mode line. + ;; If you use Emacs as a daemon and wants unicode characters only in GUI set + ;; the value to quoted `display-graphic-p'. (default t) + dotspacemacs-mode-line-unicode-symbols t + + ;; If non-nil smooth scrolling (native-scrolling) is enabled. Smooth + ;; scrolling overrides the default behavior of Emacs which recenters point + ;; when it reaches the top or bottom of the screen. (default t) + dotspacemacs-smooth-scrolling t + + ;; Control line numbers activation. + ;; If set to `t', `relative' or `visual' then line numbers are enabled in all + ;; `prog-mode' and `text-mode' derivatives. If set to `relative', line + ;; numbers are relative. If set to `visual', line numbers are also relative, + ;; but lines are only visual lines are counted. For example, folded lines + ;; will not be counted and wrapped lines are counted as multiple lines. + ;; This variable can also be set to a property list for finer control: + ;; '(:relative nil + ;; :visual nil + ;; :disabled-for-modes dired-mode + ;; doc-view-mode + ;; markdown-mode + ;; org-mode + ;; pdf-view-mode + ;; text-mode + ;; :size-limit-kb 1000) + ;; When used in a plist, `visual' takes precedence over `relative'. + ;; (default nil) + dotspacemacs-line-numbers nil + + ;; Code folding method. Possible values are `evil' and `origami'. + ;; (default 'evil) + dotspacemacs-folding-method 'evil + + ;; If non-nil `smartparens-strict-mode' will be enabled in programming modes. + ;; (default nil) + dotspacemacs-smartparens-strict-mode nil + + ;; If non-nil pressing the closing parenthesis `)' key in insert mode passes + ;; over any automatically added closing parenthesis, bracket, quote, etc... + ;; This can be temporary disabled by pressing `C-q' before `)'. (default nil) + dotspacemacs-smart-closing-parenthesis nil + + ;; Select a scope to highlight delimiters. Possible values are `any', + ;; `current', `all' or `nil'. Default is `all' (highlight any scope and + ;; emphasis the current one). (default 'all) + dotspacemacs-highlight-delimiters 'all + + ;; If non-nil, start an Emacs server if one is not already running. + ;; (default nil) + dotspacemacs-enable-server nil + + ;; Set the emacs server socket location. + ;; If nil, uses whatever the Emacs default is, otherwise a directory path + ;; like \"~/.emacs.d/server\". It has no effect if + ;; `dotspacemacs-enable-server' is nil. + ;; (default nil) + dotspacemacs-server-socket-dir nil + + ;; If non-nil, advise quit functions to keep server open when quitting. + ;; (default nil) + dotspacemacs-persistent-server nil + + ;; List of search tool executable names. Spacemacs uses the first installed + ;; tool of the list. Supported tools are `rg', `ag', `pt', `ack' and `grep'. + ;; (default '("rg" "ag" "pt" "ack" "grep")) + dotspacemacs-search-tools '("rg" "ag" "pt" "ack" "grep") + + ;; Format specification for setting the frame title. + ;; %a - the `abbreviated-file-name', or `buffer-name' + ;; %t - `projectile-project-name' + ;; %I - `invocation-name' + ;; %S - `system-name' + ;; %U - contents of $USER + ;; %b - buffer name + ;; %f - visited file name + ;; %F - frame name + ;; %s - process status + ;; %p - percent of buffer above top of window, or Top, Bot or All + ;; %P - percent of buffer above bottom of window, perhaps plus Top, or Bot or All + ;; %m - mode name + ;; %n - Narrow if appropriate + ;; %z - mnemonics of buffer, terminal, and keyboard coding systems + ;; %Z - like %z, but including the end-of-line format + ;; (default "%I@%S") + dotspacemacs-frame-title-format "%I@%S" + + ;; Format specification for setting the icon title format + ;; (default nil - same as frame-title-format) + dotspacemacs-icon-title-format nil + + ;; Delete whitespace while saving buffer. Possible values are `all' + ;; to aggressively delete empty line and long sequences of whitespace, + ;; `trailing' to delete only the whitespace at end of lines, `changed' to + ;; delete only whitespace for changed lines or `nil' to disable cleanup. + ;; (default nil) + dotspacemacs-whitespace-cleanup nil + + ;; If non nil activate `clean-aindent-mode' which tries to correct + ;; virtual indentation of simple modes. This can interfer with mode specific + ;; indent handling like has been reported for `go-mode'. + ;; If it does deactivate it here. + ;; (default t) + dotspacemacs-use-clean-aindent-mode t + + ;; If non-nil shift your number row to match the entered keyboard layout + ;; (only in insert state). Currently supported keyboard layouts are: + ;; `qwerty-us', `qwertz-de' and `querty-ca-fr'. + ;; New layouts can be added in `spacemacs-editing' layer. + ;; (default nil) + dotspacemacs-swap-number-row nil + + ;; Either nil or a number of seconds. If non-nil zone out after the specified + ;; number of seconds. (default nil) + dotspacemacs-zone-out-when-idle nil + + ;; Run `spacemacs/prettify-org-buffer' when + ;; visiting README.org files of Spacemacs. + ;; (default nil) + dotspacemacs-pretty-docs nil + + ;; If nil the home buffer shows the full path of agenda items + ;; and todos. If non nil only the file name is shown. + dotspacemacs-home-shorten-agenda-source nil)) + +(defun dotspacemacs/user-env () + "Environment variables setup. +This function defines the environment variables for your Emacs session. By +default it calls `spacemacs/load-spacemacs-env' which loads the environment +variables declared in `~/.spacemacs.env' or `~/.spacemacs.d/.spacemacs.env'. +See the header of this file for more information." + (spacemacs/load-spacemacs-env)) + +(defun dotspacemacs/user-init () + "Initialization for user code: +This function is called immediately after `dotspacemacs/init', before layer +configuration. +It is mostly for variables that should be set before packages are loaded. +If you are unsure, try setting them in `dotspacemacs/user-config' first." + ) + +(defun dotspacemacs/user-load () + "Library to load while dumping. +This function is called only while dumping Spacemacs configuration. You can +`require' or `load' the libraries of your choice that will be included in the +dump." + ) + +(defun dotspacemacs/user-config () + "Configuration for user code: +This function is called at the very end of Spacemacs startup, after layer +configuration. +Put your configuration code here, except for variables that should be set +before packages are loaded." + (load-file "~/.dotfiles/emacs/user-config.el") + ) + +;; Do not write anything past this comment. This is where Emacs will +;; auto-generate custom variable definitions. +(defun dotspacemacs/emacs-custom-settings () + "Emacs custom settings. +This is an auto-generated function, do not modify its content directly, use +Emacs customize menu instead. +This function is called at the very end of Spacemacs initialization." +(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. + '(evil-want-Y-yank-to-eol nil) + '(package-selected-packages + '(web-mode web-beautify treemacs-icons-dired tagedit slim-mode scss-mode sass-mode pug-mode prettier-js org-superstar org-ref pdf-tools key-chord helm-bibtex helm helm-core tablist lsp-ivy ivy-bibtex bibtex-completion biblio parsebib biblio-core interleave impatient-mode simple-httpd haml-mode emr clang-format list-utils emmet-mode counsel-css company-web web-completion-data yapfify xterm-color ws-butler winum which-key wgrep volatile-highlights vi-tilde-fringe uuidgen use-package unfill toc-org systemd spaceline powerline smex smeargle shell-pop restart-emacs request rainbow-delimiters pyvenv pytest pyenv-mode py-isort popwin pip-requirements persp-mode pcre2el paradox spinner orgit org-projectile org-category-capture org-present org-pomodoro alert log4e gntp org-plus-contrib org-mime org-download org-bullets open-junk-file neotree mwim multi-term move-text mmm-mode markdown-toc magit-gitflow macrostep lorem-ipsum live-py-mode linum-relative link-hint ivy-hydra indent-guide hy-mode hungry-delete htmlize hl-todo highlight-parentheses highlight-numbers highlight-indentation helm-make google-translate golden-ratio gnuplot gitignore-mode gitconfig-mode gitattributes-mode git-timemachine git-messenger git-link git-gutter-fringe git-gutter-fringe+ gh-md fuzzy flyspell-correct-ivy flycheck-pos-tip flx-ido fill-column-indicator fancy-battery eyebrowse expand-region exec-path-from-shell evil-visualstar evil-visual-mark-mode evil-unimpaired evil-tutor evil-surround evil-search-highlight-persist evil-numbers evil-nerd-commenter evil-mc evil-matchit evil-magit evil-lisp-state evil-indent-plus evil-iedit-state evil-exchange evil-escape evil-ediff evil-args evil-anzu eval-sexp-fu eshell-z eshell-prompt-extras esh-help elisp-slime-nav dumb-jump diminish diff-hl define-word cython-mode counsel-projectile company-statistics company-anaconda column-enforce-mode clean-aindent-mode bind-key auto-yasnippet auto-highlight-symbol auto-dictionary auto-compile aggressive-indent adaptive-wrap ace-window ace-link ac-ispell))) +(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. + ) +) +(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. + '(package-selected-packages + (quote + (yapfify xterm-color ws-butler winum which-key wgrep volatile-highlights vi-tilde-fringe uuidgen use-package unfill toc-org systemd spaceline powerline smex smeargle shell-pop restart-emacs request rainbow-delimiters pyvenv pytest pyenv-mode py-isort popwin pip-requirements persp-mode pcre2el paradox spinner orgit org-projectile org-category-capture org-present org-pomodoro alert log4e gntp org-plus-contrib org-mime org-download org-bullets open-junk-file neotree mwim multi-term move-text mmm-mode markdown-toc magit-gitflow macrostep lorem-ipsum live-py-mode linum-relative link-hint ivy-hydra indent-guide hy-mode hungry-delete htmlize hl-todo highlight-parentheses highlight-numbers highlight-indentation helm-make google-translate golden-ratio gnuplot gitignore-mode gitconfig-mode gitattributes-mode git-timemachine git-messenger git-link git-gutter-fringe git-gutter-fringe+ gh-md fuzzy flyspell-correct-ivy flycheck-pos-tip flx-ido fill-column-indicator fancy-battery eyebrowse expand-region exec-path-from-shell evil-visualstar evil-visual-mark-mode evil-unimpaired evil-tutor evil-surround evil-search-highlight-persist evil-numbers evil-nerd-commenter evil-mc evil-matchit evil-magit evil-lisp-state evil-indent-plus evil-iedit-state evil-exchange evil-escape evil-ediff evil-args evil-anzu eval-sexp-fu eshell-z eshell-prompt-extras esh-help elisp-slime-nav dumb-jump diminish diff-hl define-word cython-mode counsel-projectile company-statistics company-anaconda column-enforce-mode clean-aindent-mode bind-key auto-yasnippet auto-highlight-symbol auto-dictionary auto-compile aggressive-indent adaptive-wrap ace-window ace-link ac-ispell)))) +(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/emacs/user-config.el b/emacs/user-config.el new file mode 100755 index 00000000000..f1c42182742 --- /dev/null +++ b/emacs/user-config.el @@ -0,0 +1,234 @@ +;; ; https://raw.githubusercontent.com/karlicoss/dotfiles-emacs/master/.spacemacs.d/config.el +;; ; refined init.el, gradually will mode all of my config here +;; ; loaded in dotspacemacs/user-config + +;; ;;; random helpers + +;; ; TODO should this be macro?? +;; (cl-defun with-error-on-user-prompt (body) +;; "Suppress user prompt and throw error instead. Useful when we really want to avoid prompts, e.g. in non-interactive functions" +;; (interactive) +;; (cl-letf (((symbol-function 'y-or-n-p) (lambda (arg) (error "IGNORING PROMPT %s" arg)))) +;; (eval body))) +;; ;;; + + +;; ; omg why is elisp so shit... +;; (defun my/get-output (cmd) +;; "shell-command-to-string mixes stderr and stdout, so we can't rely on it for getting filenames etc.. +;; It also ignores exit code. +;; (see https://github.com/emacs-mirror/emacs/blob/b7d4c5d1d1b55fea8382663f18263e2000678be5/lisp/simple.el#L3569-L3573) + +;; This function ignores stderr for now since I haven't figured out how to redirect it to *Messages* buffer :(" +;; (with-output-to-string +;; (with-temp-buffer +;; (shell-command +;; cmd +;; standard-output +;; (current-buffer))))) + + +;; ;;; searching for things +;; (cl-defun my/files-in (path &key (exts nil) (follow nil)) +;; "Search for files with certail extensions and potentially following symlinks. +;; None of standard Elisp functions or popular libs support following symlink :( +;; In addition, rg is ridiculously fast." +;; (assert (stringp path)) ;; TODO surely there is a nicer way?? how to define it next to path? +;; (let* ((patterns (s-join " " (-map (lambda (i) (format "-e %s" i)) exts))) +;; (follows (if follow "--follow" "")) +;; (rg-command (format +;; ;; TODO ugh. quoting third %s broke agenda for some reason (fd complained it wasn't a directory??) +;; "fdfind . %s %s %s -x readlink -f" ; ugh, --zero isn't supported on alpine (cloudmacs) +;; follows +;; patterns +;; path)) +;; (filenames (s-split "\n" (shell-command-to-string rg-command) t))) +;; (-map #'file-truename filenames))) + +;; (cl-defun my/org-files-in (path &key (archive nil) (follow nil)) +;; (my/files-in path :exts (if archive '("org" "org_archive") '("org")) :follow follow)) + + + +;; (with-eval-after-load 'helm +;; ;; patch spacemacs/helm-files-do-rg to support extra targets argument used in --my/helm-files-do-rg +;; (load-file "~/.dotfiles/emacs/patch-helm.el")) + + +;; (cl-defun --my/helm-files-do-rg (dir &key (targets nil) (rg-opts nil)) +;; "Helper function to aid with passing extra arguments to ripgrep" +;; (require 'helm-ag) +;; ;; TODO need to ignore # files? +;; (let ((helm-ag-command-option (s-join " " rg-opts))) +;; ;; NOTE: spacemacs/helm-files-do-rg is patched to support second argument with multiple directories +;; ;; (see patch-helm.el) +;; (spacemacs/helm-files-do-rg dir targets))) + + +;; (defun --my/find-file-defensive (f) +;; "Open file, ignoring lock files, various IO race conditions and user prompts. +;; Returns filename if successful, othewise nil" +;; (ignore-errors (with-error-on-user-prompt `(find-file-read-only f)) f)) + + +;; ;; TODO FIXME fucking hell, elisp doesn't seem to have anything similar to e.g. check_call in python +;; ;; also no simple way to pass set -eu -o pipefail +;; ;; so, if find or xargs fails, you'd get with garbage in the variable + +;; ;; really wish there was some sort of bridge for configuring emacs on other programming languages +;; ;; there is zero benefit of using Elisp for most of typical emacs configs; only obstacles. +;; ;; can't say about other lisps, but very likely it's not very beneficial either +;; (setq my/git-repos-search-root "/home/bhillmann/code") +;; (setq my/search-targets "/home/bhillmann/code") + +;; (defun --my/git-repos-refresh () +;; (let ((search-git-repos-cmd (s-join " " +;; `( +;; "fd" +;; "--follow" ; follow symlink +;; ;; match git dirs, excluding bare repositories (they don't have index) +;; "--hidden" "--full-path" "--type f" "'.git/index$'" +;; ,(format "'%s'" my/git-repos-search-root) +;; "-x" "readlink" "-f" "'{//}'")))) ; resolve symlinks and chop off 'index' +;; (progn +;; (message "refreshing git repos...") +;; (defconst *--my/git-repos* +;; (-distinct +;; (-map (lambda (x) (s-chop-suffix "/.git" x)) +;; (s-split "\n" ; remove duplicates due to symlinking +;; (shell-command-to-string search-git-repos-cmd) t))))))) ; t for omit-nulls + + +;; (defun my/code-targets () +;; "Collects repositories across the filesystem and bootstraps the timer to update them" +;; ; TODO there mustbe some generic caching mechanism for that in elisp? +;; (let ((refresh-interval-seconds (* 60 5))) +;; (progn +;; (unless (boundp '*--my/git-repos*) +;; (--my/git-repos-refresh) +;; (run-with-idle-timer refresh-interval-seconds t '--my/git-repos-refresh)) +;; *--my/git-repos*))) + + + +;; (defun --my/one-off-helm-follow-mode () +;; ;; I only want helm follow when I run helm-ag against my notes, +;; ;; but not all the time, in particular when I'm running my/search-code because it +;; ;; triggers loading LSP etc +;; ;; Problem is helm-follow-mode seems to be handled on per-source basis +;; ;; and there is some logic that tries to persist it in customize-variables +;; ;; for future emacs sessions. +;; ;; helm-ag on one hand seems to use since source (helm-ag-source) for all searches +;; ;; on the orther hand it does some sort of dynamic renaming and messing with source names +;; ;; (e.g. search by "helm-attrset 'name") +;; ;; As a result it's very unclear what's actually happening even after few hours of debugging. +;; ;; also see https://github.com/emacs-helm/helm/issues/2006, + +;; ;; other things I tried (apart from completely random desperate attempts) +;; ;; - setting +;; ;; (setq helm-follow-mode-persistent t) +;; ;; (setq helm-source-names-using-follow `(,(helm-ag--helm-header my/search-targets)))) +;; ;; - using different source similar to helm-ag-source, but with :follow t -- doesn't work :shrug: + +;; ;; in the end I ended up hacking hooks to enable follow mode for specific helm call +;; ;; and disabling on closing the buffer. Can't say I like it at all and looks sort of flaky. + +;; (defun --my/helm-follow-mode-set (arg) +;; "Ugh fucking hell. Need this because helm-follow-mode works as a toggle :eyeroll:" +;; (unless (eq (helm-follow-mode-p) arg) +;; (helm-follow-mode))) + +;; (defun --my/enable-helm-follow-mode () +;; (--my/helm-follow-mode-set t)) + +;; (defun --my/disable-helm-follow-mode () +;; (--my/helm-follow-mode-set nil) +;; (remove-hook 'helm-move-selection-before-hook '--my/enable-helm-follow-mode) +;; (remove-hook 'helm-cleanup-hook '--my/disable-helm-follow-mode)) + +;; ;; ugh, helm-move-selection-before-hook doesn seem like the right one frankly +;; ;; but I haven't found anything better, e.g. helm-after-initialize-hook seems too early +;; ;; helm-after-update-hook kinda worked, but immediately dropped after presenting results +;; ;; as helm complains at 'Not enough candidates' :( +;; (add-hook 'helm-move-selection-before-hook '--my/enable-helm-follow-mode) +;; (add-hook 'helm-cleanup-hook '--my/disable-helm-follow-mode)) + + +;; (defun my/search () +;; (interactive) +;; (--my/one-off-helm-follow-mode) +;; (--my/helm-files-do-rg my/search-targets +;; :rg-opts '("--follow"))) + +;; (defun my/search-code () +;; (interactive) +;; (--my/helm-files-do-rg "/" +;; :targets (my/code-targets) +;; :rg-opts '("-T" "txt" "-T" "md" "-T" "html" "-T" "org" "-g" "!*.org_archive"))) + + +;; (with-eval-after-load 'helm-ag +;; ;; see helm-ag--construct-command. Not configurable otherwise ATM +;; (defun helm-ag--construct-ignore-option (pattern) +;; (concat "--glob=!" pattern))) +;; ;;; + + +;; https://www.reddit.com/r/emacs/comments/4gudyw/help_me_with_my_orgmode_workflow_for_notetaking/ +(setq org-ref-default-bibliography '("~/Dropbox/zotero/references.bib") + org-ref-pdf-directory "~/Dropbox/zotero/pdfs" + org-ref-bibliography-notes "~/Dropbox/zotero/notes.org") + +(setq bibtex-completion-bibliography '("~/Dropbox/zotero/references.bib") + bibtex-completion-library-path '("~/Dropbox/zotero/pdfs") + bibtex-completion-notes-path "~/Dropbox/zotero/notes.org" + bibtex-completion-pdf-field "file" +) + +(autoload 'ivy-bibtex "ivy-bibtex" "" t) +;; ivy-bibtex requires ivy's `ivy--regex-ignore-order` regex builder, which +;; ignores the order of regexp tokens when searching for matching candidates. +;; Add something like this to your init file: +(setq ivy-re-builders-alist + '((ivy-bibtex . ivy--regex-ignore-order) + (t . ivy--regex-plus))) + +;; https://github.com/tmalsburg/helm-bibtex#usage +(setq ivy-bibtex-default-action 'ivy-bibtex-edit-notes) + + +;; fix error +;; added on 20.09.03 from this link https://github.com/syl20bnr/spacemacs/issues/5554 +(defun ask-user-about-lock (file other-user) + "A value of t says to grab the lock on the file." + t) + + +;; treemacs +(setq-default dotspacemacs-configuration-layers '( + (treemacs :variables treemacs-use-follow-mode 'tag)) + ) + +(setq-default dotspacemacs-configuration-layers '( + (treemacs :variables treemacs-use-filewatch-mode t)) + ) + +(with-eval-after-load 'org + (setq org-directory "~/petard/org")) + +(spacemacs/set-leader-keys + "RET" #'swiper + ;; "S s" #'my/search + ;; "S c" #'my/search-code + + ;; ;; TODO extract search-hotkeys so it's easy to extract for the post? + ;; "p P" #'helm-projectile-find-file-in-known-projects + + ;; ; TODO link to my post? + ;; "q q" #'kill-emacs + ) + + + +;; (global-set-key (kbd "") #'my/search) +;; (global-set-key (kbd "") #'my/search-code) diff --git a/external/zsh-autosuggestions b/external/zsh-autosuggestions new file mode 160000 index 00000000000..c7d4a85031c --- /dev/null +++ b/external/zsh-autosuggestions @@ -0,0 +1 @@ +Subproject commit c7d4a85031c101ef9bce0018096622087894dd09 diff --git a/external/zsh-completions b/external/zsh-completions new file mode 160000 index 00000000000..f615a1b518f --- /dev/null +++ b/external/zsh-completions @@ -0,0 +1 @@ +Subproject commit f615a1b518f40d2e6e5a76e0e97198a746d46c76 diff --git a/external/zsh-history-substring-search b/external/zsh-history-substring-search new file mode 160000 index 00000000000..d44159b5e87 --- /dev/null +++ b/external/zsh-history-substring-search @@ -0,0 +1 @@ +Subproject commit d44159b5e87cbdc8fdaa448f09523e12193d7d6d diff --git a/external/zsh-syntax-highlighting b/external/zsh-syntax-highlighting new file mode 160000 index 00000000000..ab1013ae0d8 --- /dev/null +++ b/external/zsh-syntax-highlighting @@ -0,0 +1 @@ +Subproject commit ab1013ae0d8c94a38141d4b75f5ff88ea59bc80e diff --git a/functions/_boom b/functions/_boom old mode 100644 new mode 100755 diff --git a/functions/_brew b/functions/_brew old mode 100644 new mode 100755 diff --git a/functions/_c b/functions/_c old mode 100644 new mode 100755 diff --git a/functions/_git-rm b/functions/_git-rm old mode 100644 new mode 100755 diff --git a/functions/c b/functions/c old mode 100644 new mode 100755 index ac49a5a7f49..afce93da2a8 --- a/functions/c +++ b/functions/c @@ -1,4 +1,4 @@ -#!/bin/zsh +#!/usr/bin/env sh # # This lets you quickly jump into a project directory. # diff --git a/functions/extract b/functions/extract old mode 100644 new mode 100755 diff --git a/functions/gf b/functions/gf old mode 100644 new mode 100755 diff --git a/git/aliases.zsh b/git/aliases.zsh old mode 100644 new mode 100755 diff --git a/git/completion.zsh b/git/completion.zsh deleted file mode 100644 index 81fd2ec7e83..00000000000 --- a/git/completion.zsh +++ /dev/null @@ -1,9 +0,0 @@ -# Uses git's autocompletion for inner commands. Assumes an install of git's -# bash `git-completion` script at $completion below (this is where Homebrew -# tosses it, at least). -completion='$(brew --prefix)/share/zsh/site-functions/_git' - -if test -f $completion -then - source $completion -fi diff --git a/git/gitconfig.local.symlink.example b/git/gitconfig.local.symlink.example old mode 100644 new mode 100755 diff --git a/git/gitconfig.symlink b/git/gitconfig.symlink old mode 100644 new mode 100755 index 29e0e804c06..0f114338f6d --- a/git/gitconfig.symlink +++ b/git/gitconfig.symlink @@ -17,6 +17,7 @@ [core] excludesfile = ~/.gitignore editor = vim + autocrlf = input [apply] whitespace = nowarn [mergetool] @@ -40,3 +41,15 @@ defaultBranch = main [pull] rebase = true + default = simple +[filter "nbstrip_full"] + clean = "jq --indent 1 \ + '(.cells[] | select(has(\"outputs\")) | .outputs) = [] \ + | (.cells[] | select(has(\"execution_count\")) | .execution_count) = null \ + | .metadata = {\"language_info\": {\"name\": \"python\", \"pygments_lexer\": \"ipython3\"}} \ + | .cells[].metadata = {} \ + '" + smudge = cat + required = true +[user] + email = hillmannben@gmail.com diff --git a/git/gitignore.symlink b/git/gitignore.symlink old mode 100644 new mode 100755 diff --git a/homebrew/install.sh b/homebrew/install.sh deleted file mode 100755 index f01dbdc7f75..00000000000 --- a/homebrew/install.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# Homebrew -# -# This installs some of the common dependencies needed (or at least desired) -# using Homebrew. - -# Check for Homebrew -if test ! $(which brew) -then - echo " Installing Homebrew for you." - - # Install the correct homebrew for each OS type - if test "$(uname)" = "Darwin" - then - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - elif test "$(expr substr $(uname -s) 1 5)" = "Linux" - then - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)" - fi - -fi - -exit 0 diff --git a/ruby/aliases.zsh b/ruby/aliases.zsh deleted file mode 100644 index 607599fcbd2..00000000000 --- a/ruby/aliases.zsh +++ /dev/null @@ -1,3 +0,0 @@ -alias sc='script/console' -alias sg='script/generate' -alias sd='script/destroy' diff --git a/ruby/completion.zsh b/ruby/completion.zsh deleted file mode 100644 index 87bdc54ad78..00000000000 --- a/ruby/completion.zsh +++ /dev/null @@ -1,22 +0,0 @@ -# Stolen from -# https://github.com/sstephenson/rbenv/blob/master/completions/rbenv.zsh - -if [[ ! -o interactive ]]; then - return -fi - -compctl -K _rbenv rbenv - -_rbenv() { - local word words completions - read -cA words - word="${words[2]}" - - if [ "${#words}" -eq 2 ]; then - completions="$(rbenv commands)" - else - completions="$(rbenv completions "${word}")" - fi - - reply=("${(ps:\n:)completions}") -} \ No newline at end of file diff --git a/ruby/gemrc.symlink b/ruby/gemrc.symlink deleted file mode 100644 index 63e8ac20eba..00000000000 --- a/ruby/gemrc.symlink +++ /dev/null @@ -1,6 +0,0 @@ ---- -:update_sources: true -:verbose: true -:backtrace: false -:benchmark: false -gem: --no-document diff --git a/ruby/irbrc.symlink b/ruby/irbrc.symlink index d8cf3001043..e69de29bb2d 100644 --- a/ruby/irbrc.symlink +++ b/ruby/irbrc.symlink @@ -1,46 +0,0 @@ -#!/usr/bin/ruby -require 'irb/completion' -require 'rubygems' - -IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history" - -IRB.conf[:PROMPT_MODE] = :SIMPLE - -IRB.conf[:AUTO_INDENT] = true - -class Object - # list methods which aren't in superclass - def local_methods(obj = self) - (obj.methods - obj.class.superclass.instance_methods).sort - end - - # print documentation - # - # ri 'Array#pop' - # Array.ri - # Array.ri :pop - # arr.ri :pop - def ri(method = nil) - unless method && method =~ /^[A-Z]/ # if class isn't specified - klass = self.kind_of?(Class) ? name : self.class.name - method = [klass, method].compact.join('#') - end - puts `ri '#{method}'` - end -end - -# Copies the result of the last operation you ran in IRB to the system -# clipboard (if you're on macOS). -def cop - last_value = IRB.CurrentContext.last_value - %x[echo '#{last_value}' | pbcopy] - "copied \`#{last_value}' to your clipboard" -end - -def me - User.find_by_email(`git config --get user.email`.chomp) -end - -def r - reload! -end diff --git a/script/bootstrap b/script/bootstrap index ec33297de17..c0d78a3ffcc 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -140,17 +140,8 @@ install_dotfiles () { setup_gitconfig install_dotfiles -# If we're on a Mac, let's install and setup homebrew. -if [ "$(uname -s)" == "Darwin" ] -then - info "installing dependencies" - if source bin/dot | while read -r data; do info "$data"; done - then - success "dependencies installed" - else - fail "error installing dependencies" - fi -fi +# Pull the latest changes and update all submodules +git submodule update --init --recursive echo '' echo ' All installed!' diff --git a/system/_path.zsh b/system/_path.zsh old mode 100644 new mode 100755 diff --git a/system/aliases.zsh b/system/aliases.zsh old mode 100644 new mode 100755 diff --git a/system/env.zsh b/system/env.zsh old mode 100644 new mode 100755 index e69de29bb2d..6c70164e692 --- a/system/env.zsh +++ b/system/env.zsh @@ -0,0 +1 @@ +export EDITOR='e' diff --git a/system/grc.zsh b/system/grc.zsh old mode 100644 new mode 100755 diff --git a/system/keys.zsh b/system/keys.zsh old mode 100644 new mode 100755 diff --git a/systemd/dropbox.service b/systemd/dropbox.service new file mode 100644 index 00000000000..7eff8b7f90a --- /dev/null +++ b/systemd/dropbox.service @@ -0,0 +1,17 @@ +[Unit] +Description=Dropbox as a user service +After=local-fs.target network.target + +[Service] +Type=simple +ExecStart=/usr/local/bin/dropboxd +Restart=on-failure +RestartSec=1 +# Note: don't set these in user mode- they're already set, and +# systemd won't have permission to set them- killing your service before +# it starts +# User=%U +# Group=%U + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/systemd/emacs-daemon.service b/systemd/emacs-daemon.service new file mode 100644 index 00000000000..746e8253283 --- /dev/null +++ b/systemd/emacs-daemon.service @@ -0,0 +1,13 @@ +[Unit] +Description=Emacs daemon + +[Service] +Type=forking +# running via zsh -l makes it pick up .profile, which sets up PATH etc +ExecStart=/bin/zsh -l -c '/usr/bin/emacs --daemon' +ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)" +Environment=SSH_AUTH_SOCK=%t/keyring/ssh +Restart=always + +[Install] +WantedBy=default.target diff --git a/tmux/tmux.conf.symlink b/tmux/tmux.conf.symlink new file mode 100755 index 00000000000..08fb10a7713 --- /dev/null +++ b/tmux/tmux.conf.symlink @@ -0,0 +1,72 @@ +set-option -g default-shell /bin/zsh + + + +# disable mouse control by default - change 'off' to 'on' to enable by default. +setw -g mode-mouse on +set-option -g mouse-resize-pane off +set-option -g mouse-select-pane off +set-option -g mouse-select-window off + +unbind C-b +set -g prefix C-a +bind-key a send-prefix + +# if prefix is 'C-a' +bind C-a send-prefix +bind a last-window + +# zoom this pane to full screen +bind + \ + new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \;\ + swap-pane -s tmux-zoom.0 \;\ + select-window -t tmux-zoom + +# restore this pane +bind - \ + last-window \;\ + swap-pane -s tmux-zoom.0 \;\ + kill-window -t tmux-zoom + +# address vim mode switching delay (http://superuser.com/a/252717/65504) +set -s escape-time 0 + +# increase scrollback buffer size +set -g history-limit 50000 + +# tmux messages are displayed for 4 seconds +set -g display-time 4000 + +# refresh 'status-left' and 'status-right' more often +set -g status-interval 5 + +# upgrade $TERM +set -g default-terminal "screen-256color" + +# emacs key bindings in tmux command prompt (prefix + :) are better than +# vi keys, even for vim users +set -g status-keys emacs + +# super useful when using "grouped sessions" and multi-monitor setup +setw -g aggressive-resize on + +# source .tmux.conf as suggested in `man tmux` +bind R source-file '~/.tmux.conf' + +# easier and faster switching between next/prev window +bind C-p previous-window +bind C-n next-window + +# tmux pane-navigation bindings +bind-key h select-pane -L +bind-key C-h select-pane -L +bind-key j select-pane -D +bind-key C-j select-pane -D +bind-key k select-pane -U +bind-key C-k select-pane -U +bind-key l select-pane -R +bind-key C-l select-pane -R + +# Window move bindings +bind-key -r "<" swap-window -t -1 +bind-key -r ">" swap-window -t +1 diff --git a/vim/vimrc.symlink b/vim/vimrc.symlink old mode 100644 new mode 100755 index 0463e21b902..dcebc606a38 --- a/vim/vimrc.symlink +++ b/vim/vimrc.symlink @@ -1,4 +1,119 @@ syntax on +set rtp+=/usr/local/opt/fzf + " Wrap gitcommit file types at the appropriate length filetype indent plugin on + +" Specify a directory for plugins +" - For Neovim: ~/.local/share/nvim/plugged +" - Avoid using standard Vim directory names like 'plugin' +call plug#begin('~/.vim/plugged') + +" Make sure you use single quotes +" +Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +Plug 'junegunn/fzf.vim' + +" Initialize plugin system +call plug#end() + +" fzf configuration +" This is the default extra key bindings +let g:fzf_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + +" Default fzf layout +" - down / up / left / right +let g:fzf_layout = { 'down': '~100%' } + +" In Neovim, you can set up fzf window using a Vim command +let g:fzf_layout = { 'window': 'enew' } +let g:fzf_layout = { 'window': '-tabnew' } +let g:fzf_layout = { 'window': '10split enew' } + +" Customize fzf colors to match your color scheme +let g:fzf_colors = +\ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } + +" Enable per-command history. +" CTRL-N and CTRL-P will be automatically bound to next-history and +" previous-history instead of down and up. If you don't like the change, +" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS. +let g:fzf_history_dir = '~/.local/share/fzf-history' + +" Command for git grep +" - fzf#vim#grep(command, with_column, [options], [fullscreen]) +command! -bang -nargs=* GGrep + \ call fzf#vim#grep( + \ 'git grep --line-number '.shellescape(), 0, + \ { 'dir': systemlist('git rev-parse --show-toplevel')[0] }, 0) + +" Override Colors command. You can safely do this in your .vimrc as fzf.vim +" will not override existing commands. +command! -bang Colors + \ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,0'}, 0) + +" Augmenting Ag command using fzf#vim#with_preview function +" * fzf#vim#with_preview([[options], preview window, [toggle keys...]]) +" * For syntax-highlighting, Ruby and any of the following tools are required: +" - Highlight: http://www.andre-simon.de/doku/highlight/en/highlight.php +" - CodeRay: http://coderay.rubychan.de/ +" - Rouge: https://github.com/jneen/rouge +" +" :Ag - Start fzf with hidden preview window that can be enabled with "?" key +" :Ag! - Start fzf in fullscreen and display the preview window above +command! -bang -nargs=* Ag + \ call fzf#vim#ag(, + \ 0 ? fzf#vim#with_preview('up:60%') + \ : fzf#vim#with_preview('right:50%:hidden', '?'), + \ 0) + +" Similarly, we can apply it to fzf#vim#grep. To use ripgrep instead of ag: +command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(), 1, + \ 0 ? fzf#vim#with_preview('up:60%') + \ : fzf#vim#with_preview('right:50%:hidden', '?'), + \ 0) + +" Likewise, Files command with preview window +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, fzf#vim#with_preview(), 0) + +" Mapping selecting mappings +nmap (fzf-maps-n) +xmap (fzf-maps-x) +omap (fzf-maps-o) + +" Insert mode completion +imap (fzf-complete-word) +imap (fzf-complete-path) +imap (fzf-complete-file-ag) +imap (fzf-complete-line) + +" Advanced customization using autoload functions +inoremap fzf#vim#complete#word({'left': '15%'}) + +" Global line completion (not just open buffers. ripgrep required.) +inoremap fzf#vim#complete(fzf#wrap({ + \ 'prefix': '^.*$', + \ 'source': 'rg -n ^ --color always', + \ 'options': '--ansi --delimiter : --nth 3..', + \ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }})) + +set clipboard=unnamed diff --git a/xorg/xprofile.symlink b/xorg/xprofile.symlink new file mode 100755 index 00000000000..6b303286649 --- /dev/null +++ b/xorg/xprofile.symlink @@ -0,0 +1,2 @@ +xmodmap -e "remove lock = Caps_Lock" +xmodmap -e "keysym Caps_Lock = Escape" \ No newline at end of file diff --git a/yarn/path.zsh b/yarn/path.zsh deleted file mode 100644 index 7d2b91e6c3c..00000000000 --- a/yarn/path.zsh +++ /dev/null @@ -1,7 +0,0 @@ -# sup yarn -# https://yarnpkg.com - -if (( $+commands[yarn] )) -then - export PATH="$PATH:`yarn global bin`" -fi diff --git a/zsh-comps/* b/zsh-comps/* new file mode 120000 index 00000000000..3942efb7965 --- /dev/null +++ b/zsh-comps/* @@ -0,0 +1 @@ +/home/bhillmann/.dotfiles/external/zsh-completions/src/* \ No newline at end of file diff --git a/zsh-comps/install.sh b/zsh-comps/install.sh new file mode 100755 index 00000000000..d11878164f1 --- /dev/null +++ b/zsh-comps/install.sh @@ -0,0 +1,3 @@ +if [[ -d "${ZDOTDIR:-$HOME}/.dotfiles/external/zsh-completions/src" ]]; then + ln -s "${ZDOTDIR:-$HOME}/.dotfiles/external/zsh-completions/src/*" "${ZDOTDIR:-$HOME}/.dotfiles/zsh-comps/" +fi diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh old mode 100644 new mode 100755 index b88e3aa5a1b..34d21b238d1 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -1,3 +1,12 @@ alias reload!='. ~/.zshrc' +## Colorize the ls output ## +alias ls='ls --color=auto' + +### Use a long listing format ## +alias ll='ls -la' +# +### Show hidden files ## +alias l.='ls -d .* --color=auto' + alias cls='clear' # Good 'ol Clear Screen command diff --git a/zsh/completion.zsh b/zsh/completion.zsh deleted file mode 100644 index 1862eecec55..00000000000 --- a/zsh/completion.zsh +++ /dev/null @@ -1,5 +0,0 @@ -# matches case insensitive for lowercase -zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' - -# pasting with tabs doesn't perform completion -zstyle ':completion:*' insert-tab pending diff --git a/zsh/config.zsh b/zsh/config.zsh deleted file mode 100644 index 8ca7389e218..00000000000 --- a/zsh/config.zsh +++ /dev/null @@ -1,39 +0,0 @@ -export LSCOLORS="exfxcxdxbxegedabagacad" -export CLICOLOR=true - -fpath=($ZSH/functions $fpath) - -autoload -U $ZSH/functions/*(:t) - -HISTFILE=~/.zsh_history -HISTSIZE=10000 -SAVEHIST=10000 - -setopt NO_BG_NICE # don't nice background tasks -setopt NO_HUP -setopt NO_LIST_BEEP -setopt LOCAL_OPTIONS # allow functions to have local options -setopt LOCAL_TRAPS # allow functions to have local traps -setopt HIST_VERIFY -setopt SHARE_HISTORY # share history between sessions ??? -setopt EXTENDED_HISTORY # add timestamps to history -setopt PROMPT_SUBST -setopt CORRECT -setopt COMPLETE_IN_WORD -setopt IGNORE_EOF - -setopt APPEND_HISTORY # adds history -setopt INC_APPEND_HISTORY SHARE_HISTORY # adds history incrementally and share it across sessions -setopt HIST_IGNORE_ALL_DUPS # don't record dupes in history -setopt HIST_REDUCE_BLANKS - -# don't expand aliases _before_ completion has finished -# like: git comm-[tab] -setopt complete_aliases - -bindkey '^[^[[D' backward-word -bindkey '^[^[[C' forward-word -bindkey '^[[5D' beginning-of-line -bindkey '^[[5C' end-of-line -bindkey '^[[3~' delete-char -bindkey '^?' backward-delete-char diff --git a/zsh/fpath.zsh b/zsh/fpath.zsh old mode 100644 new mode 100755 diff --git a/zsh/history.zsh b/zsh/history.zsh new file mode 100755 index 00000000000..ff813b31201 --- /dev/null +++ b/zsh/history.zsh @@ -0,0 +1,17 @@ +# Make some sane history settings +HISTFILE="$HOME/.zsh_history" +HISTSIZE=10000000 +SAVEHIST=10000000 +setopt BANG_HIST # Treat the '!' character specially during expansion. +setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format. +setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. +setopt SHARE_HISTORY # Share history between all sessions. +setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history. +setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again. +setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate. +setopt HIST_FIND_NO_DUPS # Do not display a line previously found. +setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space. +setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file. +setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. +setopt HIST_VERIFY # Don't execute immediately upon history expansion. +setopt HIST_BEEP # Beep when accessing nonexistent history. diff --git a/zsh/plugins.zsh b/zsh/plugins.zsh new file mode 100755 index 00000000000..9c15fbbcfb2 --- /dev/null +++ b/zsh/plugins.zsh @@ -0,0 +1,21 @@ +#Load Plugins +if [[ -s "${ZDOTDIR:-$HOME}/.dotfiles/external/zsh-autosuggestions/zsh-autosuggestions.zsh" ]]; then + source "${ZDOTDIR:-$HOME}/.dotfiles/external/zsh-autosuggestions/zsh-autosuggestions.zsh" +fi + +if [[ -s "${ZDOTDIR:-$HOME}/.dotfiles/external/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then + source "${ZDOTDIR:-$HOME}/.dotfiles/external/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" +fi + +if [[ -s "${ZDOTDIR:-$HOME}/.dotfiles/external/zsh-history-substring-search/zsh-history-substring-search.zsh" ]]; then + source "${ZDOTDIR:-$HOME}/.dotfiles/external/zsh-history-substring-search/zsh-history-substring-search.zsh" + #Vi mode command keys + bindkey -M vicmd 'k' history-substring-search-up + bindkey -M vicmd 'j' history-substring-search-down + # bind UP and DOWN arrow keys + zmodload zsh/terminfo + bindkey "$terminfo[kcuu1]" history-substring-search-up + bindkey "$terminfo[kcud1]" history-substring-search-down + bindkey "$terminfo[cuu1]" history-substring-search-up + bindkey "$terminfo[cud1]" history-substring-search-down +fi diff --git a/zsh/prompt.zsh b/zsh/prompt.zsh deleted file mode 100644 index d35b8c53f5c..00000000000 --- a/zsh/prompt.zsh +++ /dev/null @@ -1,77 +0,0 @@ -autoload colors && colors -# cheers, @ehrenmurdick -# http://github.com/ehrenmurdick/config/blob/master/zsh/prompt.zsh - -if (( $+commands[git] )) -then - git="$commands[git]" -else - git="/usr/bin/git" -fi - -git_branch() { - echo $($git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}) -} - -git_dirty() { - if $(! $git status -s &> /dev/null) - then - echo "" - else - if [[ $($git status --porcelain) == "" ]] - then - echo "on %{$fg_bold[green]%}$(git_prompt_info)%{$reset_color%}" - else - echo "on %{$fg_bold[red]%}$(git_prompt_info)%{$reset_color%}" - fi - fi -} - -git_prompt_info () { - ref=$($git symbolic-ref HEAD 2>/dev/null) || return -# echo "(%{\e[0;33m%}${ref#refs/heads/}%{\e[0m%})" - echo "${ref#refs/heads/}" -} - -# This assumes that you always have an origin named `origin`, and that you only -# care about one specific origin. If this is not the case, you might want to use -# `$git cherry -v @{upstream}` instead. -need_push () { - if [ $($git rev-parse --is-inside-work-tree 2>/dev/null) ] - then - number=$($git cherry -v origin/$(git symbolic-ref --short HEAD) 2>/dev/null | wc -l | bc) - - if [[ $number == 0 ]] - then - echo " " - else - echo " with %{$fg_bold[magenta]%}$number unpushed%{$reset_color%}" - fi - fi -} - -directory_name() { - echo "%{$fg_bold[cyan]%}%1/%\/%{$reset_color%}" -} - -battery_status() { - if test ! "$(uname)" = "Darwin" - then - exit 0 - fi - - if [[ $(sysctl -n hw.model) == *"Book"* ]] - then - $ZSH/bin/battery-status - fi -} - -export PROMPT=$'\n$(battery_status)in $(directory_name) $(git_dirty)$(need_push)\n› ' -set_prompt () { - export RPROMPT="%{$fg_bold[cyan]%}%{$reset_color%}" -} - -precmd() { - title "zsh" "%m" "%55<...<%~" - set_prompt -} diff --git a/zsh/vi.zsh b/zsh/vi.zsh new file mode 100755 index 00000000000..53a9e22665d --- /dev/null +++ b/zsh/vi.zsh @@ -0,0 +1,13 @@ +# Vi mode +#bindkey -v +zstyle ':completion:*' menu select + +zmodload zsh/complist +# Group results by category +zstyle ':completion:*' group-name '' + +# use the vi navigation keys in menu completion +bindkey -M menuselect 'h' vi-backward-char +bindkey -M menuselect 'k' vi-up-line-or-history +bindkey -M menuselect 'l' vi-forward-char +bindkey -M menuselect 'j' vi-down-line-or-history diff --git a/zsh/window.zsh b/zsh/window.zsh old mode 100644 new mode 100755 index 805cb92d6f2..f07e67df65a --- a/zsh/window.zsh +++ b/zsh/window.zsh @@ -16,4 +16,3 @@ function title() { ;; esac } - diff --git a/zsh/zshrc.symlink b/zsh/zshrc.symlink old mode 100644 new mode 100755 index d398ac84809..53d23e27de8 --- a/zsh/zshrc.symlink +++ b/zsh/zshrc.symlink @@ -1,8 +1,14 @@ +#!/usr/bin/env zsh + # shortcut to this dotfiles path is $ZSH export ZSH=$HOME/.dotfiles -# your project folder that we can `c [tab]` to -export PROJECTS=~/Code +export TERMINFO=/usr/share/terminfo + +# Set bindkey +bindkey -e + +setopt extendedglob # Stash your environment variables in ~/.localrc. This means they'll stay out # of your main dotfiles repository (which may be public, like this one), but @@ -14,7 +20,7 @@ fi # all of our zsh files typeset -U config_files -config_files=($ZSH/**/*.zsh) +config_files=($ZSH/**/*.zsh~*/external*) # load the path files for file in ${(M)config_files:#*/path.zsh} @@ -28,10 +34,6 @@ do source $file done -# initialize autocomplete here, otherwise functions won't be loaded -autoload -U compinit -compinit - # load every completion after autocomplete loads for file in ${(M)config_files:#*/completion.zsh} do @@ -39,3 +41,50 @@ do done unset config_files + +autoload -Uz compinit && compinit + +# Prompt Setup +# Last update 2/21/2018 +# Taken from Stack Overflow +# http://arjanvandergaag.nl/blog/customize-zsh-prompt-with-vcs-info.html +setopt prompt_subst +autoload -Uz vcs_info +zstyle ':vcs_info:git*' formats "(%b)" + +zstyle ':vcs_info:*' enable git cvs svn + +precmd() {vcs_info 2> /dev/null} + +# # or use precmd, see man zshcontrib +# vcs_info_wrapper() { +# if [ -n "$vcs_info_msg_0_" ]; then +# return "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del" +# fi +# } +# RPROMPT=$'$(vcs_info_wrapper)' + +PROMPT=$'%{\e]0;%d\a%}\n%F{green}%D{%y.%m.%f} %D{%L:%M:%S}%f %F{242}:%f %F{green}%n@%m:%d%f ${vcs_info_msg_0_}\n' + +######## fzf configuration + +# Removed no longer using neovim +# bindkey -s "^P" 'nvim +Files;^M' +# bindkey -s "^G" 'nvim +Rg;^M' + +# Can't seem to get this working +#bindkey -s "^P" "fif;^M" +#bindkey -s "^G" "sc;^M" + +# Source files for configuration +[ -f /usr/share/fzf/key-bindings.zsh ] && source /usr/share/fzf/key-bindings.zsh +[ -f /usr/share/fzf/completion.zsh ] && source /usr/share/fzf/completion.zsh + +export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git' +export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" +export FZF_ALT_C_COMMAND="fd -t d" +export FZF_PREVIEW_COMMAND="bat --style=numbers,changes --wrap never --color always --line-range :500 {}" +export FZF_CTRL_T_OPTS="--min-height 30 --preview-window down:60% --preview-window noborder --preview '($FZF_PREVIEW_COMMAND) 2> /dev/null'" + + +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh \ No newline at end of file