2020-08-31 16:57:34 +02:00
|
|
|
;;; wpc-misc.el --- Hosting miscellaneous configuration -*- lexical-binding: t -*-
|
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
;; Author: William Carroll <wpcarro@gmail.com>
|
2020-08-31 16:57:34 +02:00
|
|
|
;; Version: 0.0.1
|
|
|
|
;; Package-Requires: ((emacs "25.1"))
|
2018-04-25 19:26:53 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;; This is the home of any configuration that couldn't find a better home.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2020-08-13 19:05:45 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Dependencies
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(require 'project)
|
|
|
|
(require 'f)
|
|
|
|
(require 'dash)
|
2021-12-24 00:30:31 +01:00
|
|
|
(require 'tvl)
|
2020-08-31 15:49:05 +02:00
|
|
|
(require 'region)
|
2020-09-02 16:01:43 +02:00
|
|
|
(require 'general)
|
2020-08-13 19:05:45 +02:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Configuration
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2020-09-28 01:02:40 +02:00
|
|
|
(setq display-time-string-forms
|
2021-10-07 03:25:00 +02:00
|
|
|
'((format-time-string "%H:%M %a %b %d")))
|
2019-10-09 13:13:56 +02:00
|
|
|
(display-time-mode 1)
|
|
|
|
|
2020-07-06 21:45:33 +02:00
|
|
|
;; Remove the boilerplate in the *scratch* buffer
|
|
|
|
(setq initial-scratch-message "")
|
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
;; disable custom variable entries from being written to ~/.emacs.d/init.el
|
2020-08-31 15:10:08 +02:00
|
|
|
(setq custom-file (f-join user-emacs-directory "custom.el"))
|
2018-04-25 19:26:53 +02:00
|
|
|
(load custom-file 'noerror)
|
|
|
|
|
2019-01-13 20:33:17 +01:00
|
|
|
;; integrate Emacs with X11 clipboard
|
2021-11-09 06:45:43 +01:00
|
|
|
(customize-set-variable 'select-enable-primary t)
|
|
|
|
(customize-set-variable 'select-enable-clipboard t)
|
2022-01-11 00:21:12 +01:00
|
|
|
(customize-set-variable 'evil-visual-update-x-selection-p nil)
|
2019-01-13 20:33:17 +01:00
|
|
|
(general-def 'insert
|
2019-10-09 13:13:56 +02:00
|
|
|
"s-v" #'clipboard-yank
|
|
|
|
"C-S-v" #'clipboard-yank)
|
2019-01-13 20:33:17 +01:00
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
;; transparently edit compressed files
|
|
|
|
(auto-compression-mode t)
|
|
|
|
|
2019-01-13 20:33:17 +01:00
|
|
|
;; autowrap when over the fill-column
|
2019-10-09 13:13:56 +02:00
|
|
|
(setq-default auto-fill-function #'do-auto-fill)
|
2019-01-13 20:33:17 +01:00
|
|
|
|
2018-10-02 15:57:15 +02:00
|
|
|
;; link to Emacs source code
|
2019-10-09 13:13:56 +02:00
|
|
|
;; TODO: Update this link.
|
|
|
|
(setq find-function-C-source-directory
|
|
|
|
"~/Dropbox/programming/emacs/src")
|
2018-10-02 15:57:15 +02:00
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
;; change emacs prompts from "yes or no" -> "y or n"
|
|
|
|
(fset 'yes-or-no-p 'y-or-n-p)
|
|
|
|
|
|
|
|
;; open photos in Emacs
|
|
|
|
(auto-image-file-mode 1)
|
|
|
|
|
|
|
|
;; disable line-wrapping
|
|
|
|
(setq-default truncate-lines 1)
|
|
|
|
|
|
|
|
;; shell file indentation
|
|
|
|
(setq sh-basic-offset 2)
|
|
|
|
(setq sh-indentation 2)
|
|
|
|
|
2020-01-15 23:11:53 +01:00
|
|
|
;; Emacs library that interfaces with my Linux password manager.
|
|
|
|
(use-package password-store)
|
|
|
|
|
2020-02-02 19:31:39 +01:00
|
|
|
(use-package vterm
|
|
|
|
:config
|
|
|
|
(general-define-key
|
|
|
|
:keymaps '(vterm-mode-map)
|
|
|
|
:states '(insert)
|
|
|
|
"C-S-v" #'vterm-yank)
|
|
|
|
(general-define-key
|
|
|
|
:keymaps '(vterm-mode-map)
|
|
|
|
:states '(normal)
|
|
|
|
"K" #'evil-scroll-line-up
|
|
|
|
"J" #'evil-scroll-line-down
|
|
|
|
"C-b" #'evil-scroll-page-up
|
|
|
|
"C-f" #'evil-scroll-page-down))
|
|
|
|
|
2020-01-22 22:12:08 +01:00
|
|
|
;; Use en Emacs buffer as a REST client.
|
|
|
|
;; For more information: http://emacsrocks.com/e15.html
|
|
|
|
(use-package restclient)
|
|
|
|
|
2020-01-16 20:19:30 +01:00
|
|
|
;; Run `package-lint' before publishing to MELPA.
|
|
|
|
(use-package package-lint)
|
|
|
|
|
2020-01-16 02:12:05 +01:00
|
|
|
;; Parser combinators in Elisp.
|
|
|
|
(use-package parsec)
|
|
|
|
|
2019-03-20 16:32:38 +01:00
|
|
|
;; disable company mode when editing markdown
|
|
|
|
;; TODO: move this out of wpc-misc.el and into a later file to call
|
|
|
|
;; `(disable company-mode)'
|
2019-10-09 13:13:56 +02:00
|
|
|
(use-package markdown-mode
|
|
|
|
:config
|
|
|
|
;; TODO: Add assertion that pandoc is installed and it is accessible from
|
|
|
|
;; Emacs.
|
|
|
|
(setq markdown-command "pandoc")
|
|
|
|
(setq markdown-split-window-direction 'right)
|
2019-12-22 22:36:15 +01:00
|
|
|
;; (add-hook 'markdown-mode-hook #'markdown-live-preview-mode)
|
2021-11-06 01:06:43 +01:00
|
|
|
;; Use mode-specific syntax highlighting for code blocks.
|
|
|
|
(setq markdown-fontify-code-blocks-natively t)
|
|
|
|
;; Prevent Emacs from adding a space after the leading 3x-backticks.
|
|
|
|
(setq markdown-spaces-after-code-fence 0))
|
2019-12-22 22:36:15 +01:00
|
|
|
|
2020-01-15 23:11:53 +01:00
|
|
|
(use-package alert)
|
|
|
|
|
2019-12-22 22:36:15 +01:00
|
|
|
(use-package refine)
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;; Required by some google-emacs package commands.
|
|
|
|
(use-package deferred)
|
|
|
|
|
|
|
|
;; git integration
|
2020-01-17 11:26:44 +01:00
|
|
|
(use-package magit
|
|
|
|
:config
|
2020-10-04 17:25:15 +02:00
|
|
|
(add-hook 'git-commit-setup-hook
|
|
|
|
(lambda ()
|
|
|
|
(company-mode -1)
|
|
|
|
(flyspell-mode 1)))
|
2020-01-17 11:26:44 +01:00
|
|
|
(setq magit-display-buffer-function
|
|
|
|
#'magit-display-buffer-fullframe-status-v1))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-01-22 22:13:10 +01:00
|
|
|
(use-package magit-popup)
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;; http
|
|
|
|
(use-package request)
|
|
|
|
|
2021-12-16 06:13:47 +01:00
|
|
|
;; TVL depot stuff
|
2021-12-24 18:06:16 +01:00
|
|
|
(use-package tvl)
|
2021-12-16 06:13:47 +01:00
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;; perl-compatible regular expressions
|
|
|
|
(use-package pcre2el)
|
|
|
|
|
|
|
|
;; alternative to help
|
|
|
|
(use-package helpful)
|
2018-04-25 19:26:53 +02:00
|
|
|
|
2020-09-28 00:49:38 +02:00
|
|
|
;; If called from an existing helpful-mode buffer, reuse that buffer; otherwise,
|
|
|
|
;; call `pop-to-buffer'.
|
|
|
|
(setq helpful-switch-buffer-function
|
|
|
|
(lambda (buffer-or-name)
|
|
|
|
(if (eq major-mode 'helpful-mode)
|
|
|
|
(switch-to-buffer buffer-or-name)
|
|
|
|
(pop-to-buffer buffer-or-name))))
|
|
|
|
|
2020-01-17 11:41:01 +01:00
|
|
|
;; Emacs integration with direnv
|
|
|
|
(use-package direnv
|
|
|
|
:config
|
|
|
|
(direnv-mode))
|
|
|
|
|
2020-01-06 16:20:49 +01:00
|
|
|
;; Superior Elisp library for working with dates and times.
|
|
|
|
;; TODO: Put this where my other installations for dash.el, s.el, a.el, and
|
|
|
|
;; other utility Elisp libraries are located.
|
|
|
|
(use-package ts)
|
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
;; persist history etc b/w Emacs sessions
|
|
|
|
(setq desktop-save 'if-exists)
|
|
|
|
(desktop-save-mode 1)
|
|
|
|
(setq desktop-globals-to-save
|
|
|
|
(append '((extended-command-history . 30)
|
|
|
|
(file-name-history . 100)
|
|
|
|
(grep-history . 30)
|
|
|
|
(compile-history . 30)
|
|
|
|
(minibuffer-history . 50)
|
|
|
|
(query-replace-history . 60)
|
|
|
|
(read-expression-history . 60)
|
|
|
|
(regexp-history . 60)
|
|
|
|
(regexp-search-ring . 20)
|
|
|
|
(search-ring . 20)
|
|
|
|
(shell-command-history . 50)
|
|
|
|
tags-file-name
|
|
|
|
register-alist)))
|
|
|
|
|
2020-10-03 15:50:10 +02:00
|
|
|
;; configure ibuffer
|
|
|
|
(setq ibuffer-default-sorting-mode 'major-mode)
|
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
;; config Emacs to use $PATH values
|
|
|
|
(use-package exec-path-from-shell
|
|
|
|
:if (memq window-system '(mac ns))
|
|
|
|
:config
|
|
|
|
(exec-path-from-shell-initialize))
|
|
|
|
|
|
|
|
;; Emacs autosave, backup, interlocking files
|
|
|
|
(setq auto-save-default nil
|
|
|
|
make-backup-files nil
|
|
|
|
create-lockfiles nil)
|
|
|
|
|
|
|
|
;; ensure code wraps at 80 characters by default
|
2021-12-24 00:30:31 +01:00
|
|
|
(setq-default fill-column 80)
|
2018-04-25 19:26:53 +02:00
|
|
|
|
2021-12-24 03:18:20 +01:00
|
|
|
;; render tabs 2x-chars wide
|
|
|
|
(setq tab-width 2)
|
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
(put 'narrow-to-region 'disabled nil)
|
|
|
|
|
|
|
|
;; trim whitespace on save
|
|
|
|
(add-hook 'before-save-hook #'delete-trailing-whitespace)
|
|
|
|
|
2020-08-25 15:19:19 +02:00
|
|
|
;; call `git secret hide` after saving secrets.json
|
2020-08-20 19:41:39 +02:00
|
|
|
(add-hook 'after-save-hook
|
|
|
|
(lambda ()
|
2020-08-25 15:19:19 +02:00
|
|
|
(when (f-equal? (buffer-file-name)
|
2021-12-24 00:30:31 +01:00
|
|
|
(f-join tvl-depot-path
|
|
|
|
"users"
|
|
|
|
"wpcarro"
|
|
|
|
"secrets.json"))
|
2020-08-20 19:41:39 +02:00
|
|
|
(shell-command "git secret hide"))))
|
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
;; use tabs instead of spaces
|
|
|
|
(setq-default indent-tabs-mode nil)
|
|
|
|
|
2021-11-09 05:30:31 +01:00
|
|
|
;; prefer shorter tab-widths (e.g. writing Go code)
|
|
|
|
(setq-default tab-width 2)
|
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
;; automatically follow symlinks
|
|
|
|
(setq vc-follow-symlinks t)
|
|
|
|
|
|
|
|
;; fullscreen settings
|
2020-08-31 16:57:34 +02:00
|
|
|
(setq ns-use-native-fullscreen nil)
|
2018-04-25 19:26:53 +02:00
|
|
|
|
|
|
|
(use-package yasnippet
|
|
|
|
:config
|
2020-08-31 16:57:34 +02:00
|
|
|
(setq yas-snippet-dirs (list (f-join user-emacs-directory "snippets")))
|
2018-04-25 19:26:53 +02:00
|
|
|
(yas-global-mode 1))
|
|
|
|
|
|
|
|
(use-package projectile
|
|
|
|
:config
|
|
|
|
(projectile-mode t))
|
|
|
|
|
2021-12-24 00:30:31 +01:00
|
|
|
;; TODO(wpcarro): Consider replacing this with a TVL version if it exists.
|
|
|
|
(defun wpc-misc--depot-find (dir)
|
2020-08-31 15:10:08 +02:00
|
|
|
"Find the default.nix nearest to DIR."
|
2020-09-06 19:20:19 +02:00
|
|
|
;; I use 'vc only at the root of my monorepo because 'transient doesn't use my
|
|
|
|
;; .gitignore, which slows things down. Ideally, I could write a version that
|
|
|
|
;; behaves like 'transient but also respects my monorepo's .gitignore and any
|
|
|
|
;; ancestor .gitignore files.
|
2021-12-24 00:30:31 +01:00
|
|
|
(if (f-equal? tvl-depot-path dir)
|
2020-09-06 19:20:19 +02:00
|
|
|
(cons 'vc dir)
|
2021-12-24 00:30:31 +01:00
|
|
|
(when (f-ancestor-of? tvl-depot-path dir)
|
2020-09-06 19:20:19 +02:00
|
|
|
(if (f-exists? (f-join dir "default.nix"))
|
|
|
|
(cons 'transient dir)
|
2021-12-24 00:30:31 +01:00
|
|
|
(wpc-misc--depot-find (f-parent dir))))))
|
2020-08-13 19:05:45 +02:00
|
|
|
|
2021-12-24 00:30:31 +01:00
|
|
|
(add-to-list 'project-find-functions #'wpc-misc--depot-find)
|
2020-08-13 19:05:45 +02:00
|
|
|
|
2020-08-31 15:36:55 +02:00
|
|
|
(defun wpc-misc-pkill (name)
|
|
|
|
"Call the pkill executable using NAME as its argument."
|
|
|
|
(interactive "sProcess name: ")
|
|
|
|
(call-process "pkill" nil nil nil name))
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
(use-package deadgrep
|
2018-04-25 19:26:53 +02:00
|
|
|
:config
|
2019-10-09 13:13:56 +02:00
|
|
|
(general-define-key
|
|
|
|
:keymaps 'deadgrep-mode-map
|
|
|
|
:states 'normal
|
|
|
|
"o" #'deadgrep-visit-result-other-window)
|
2020-01-10 21:30:52 +01:00
|
|
|
(setq-default deadgrep--context '(0 . 3))
|
2020-08-31 15:10:08 +02:00
|
|
|
(defun wpc-misc-deadgrep-region ()
|
2020-01-10 21:30:52 +01:00
|
|
|
"Run a ripgrep search on the active region."
|
|
|
|
(interactive)
|
2020-08-31 15:49:05 +02:00
|
|
|
(deadgrep (region-to-string)))
|
2020-08-31 15:10:08 +02:00
|
|
|
(defun wpc-misc-deadgrep-dwim ()
|
2020-01-10 21:30:52 +01:00
|
|
|
"If a region is active, use that as the search, otherwise don't."
|
|
|
|
(interactive)
|
|
|
|
(with-current-buffer (current-buffer)
|
|
|
|
(if (region-active-p)
|
|
|
|
(setq deadgrep--additional-flags '("--multiline"))
|
2020-08-31 15:10:08 +02:00
|
|
|
(wpc-misc-deadgrep-region)
|
2020-01-10 21:30:52 +01:00
|
|
|
(call-interactively #'deadgrep))))
|
2021-11-08 18:47:24 +01:00
|
|
|
(advice-add 'deadgrep--arguments
|
|
|
|
:filter-return
|
|
|
|
(lambda (args)
|
|
|
|
(push "--hidden" args)
|
|
|
|
(push "--follow" args))))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;; TODO: Do I need this when I have swiper?
|
|
|
|
(use-package counsel)
|
|
|
|
|
|
|
|
(use-package counsel-projectile)
|
2018-04-25 19:26:53 +02:00
|
|
|
|
|
|
|
;; search Google, Stackoverflow from within Emacs
|
|
|
|
(use-package engine-mode
|
|
|
|
:config
|
|
|
|
(defengine google
|
|
|
|
"http://www.google.com/search?ie=utf-8&oe=utf-8&q=%s"
|
|
|
|
:keybinding "g")
|
|
|
|
(defengine stack-overflow
|
|
|
|
"https://stackoverflow.com/search?q=%s"
|
|
|
|
:keybinding "s"))
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;; EGlot (another LSP client)
|
|
|
|
(use-package eglot)
|
|
|
|
|
|
|
|
;; Microsoft's Debug Adapter Protocol (DAP)
|
|
|
|
(use-package dap-mode
|
|
|
|
:after lsp-mode
|
|
|
|
:config
|
|
|
|
(dap-mode 1)
|
|
|
|
(dap-ui-mode 1))
|
|
|
|
|
2018-09-04 21:01:07 +02:00
|
|
|
;; Microsoft's Language Server Protocol (LSP)
|
|
|
|
(use-package lsp-ui
|
|
|
|
:config
|
|
|
|
(add-hook 'lsp-mode-hook #'lsp-ui-mode))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;; Wilfred/suggest.el - Tool for discovering functions basesd on declaring your
|
|
|
|
;; desired inputs and outputs.
|
|
|
|
(use-package suggest)
|
|
|
|
|
|
|
|
;; Malabarba/paradox - Enhances the `list-packages' view.
|
|
|
|
(use-package paradox
|
|
|
|
:config
|
|
|
|
(paradox-enable))
|
|
|
|
|
2021-12-25 01:25:18 +01:00
|
|
|
;; render emojis in Emacs 🕺
|
|
|
|
(use-package emojify
|
|
|
|
:config
|
|
|
|
(add-hook 'after-init-hook #'global-emojify-mode)
|
2021-12-25 03:01:48 +01:00
|
|
|
;; Disable the default styles of:
|
|
|
|
;; - ascii :P (When this is enabled, the vim command, :x, renders as 😶)
|
|
|
|
;; - github :smile:
|
|
|
|
(setq emojify-emoji-styles '(unicode))
|
2021-12-25 01:25:18 +01:00
|
|
|
(defun wpc-misc-copy-emoji ()
|
|
|
|
"Select an emoji from the completing-read menu."
|
|
|
|
(interactive)
|
|
|
|
(clipboard-copy (emojify-completing-read "Copy: "))))
|
|
|
|
|
2020-03-10 23:14:35 +01:00
|
|
|
;; Start the Emacs server
|
2020-09-07 17:30:54 +02:00
|
|
|
(when (not (server-running-p))
|
2020-09-07 17:13:16 +02:00
|
|
|
(server-start))
|
2020-03-10 23:14:35 +01:00
|
|
|
|
2018-04-25 19:26:53 +02:00
|
|
|
(provide 'wpc-misc)
|
2018-09-04 21:01:07 +02:00
|
|
|
;;; wpc-misc.el ends here
|