;;; programming.el -*- lexical-binding: t; -*- ;;; ;;; Author: Jakob L. Kreuze ;;; URL: https://git.sr.ht/~jakob/.emacs.d/ ;;; ;;; Configuration for "meta" packages which apply to all programming language ;;; development environments I have configured. ;;; (use-package dumb-jump) (use-package company ;; Start suggesting completions (almost) as soon as possible. :config (setq company-idle-delay 0.1 company-minimum-prefix-length 3) ;; Use standard movement keys for selecting entries from the completion popup ;; instead of those used for minibuffer next/previous. :bind (:map company-active-map ("M-n" . nil) ("M-p" . nil) ("C-n" . company-select-next) ("C-p" . company-select-previous)) ;; And have responsible for completion rather than , so that ;; company isn't quite as in-the-way. :bind (:map company-active-map ("TAB" . company-complete-selection) ("" . company-complete-selection) ("RET" . nil) ("" . nil))) (use-package compile :straight nil :bind ("" . compile) ;; Taken from EmacsWiki [1]. The compilation command can be changed by invoking ;; compile with a prefix argument, so I don't see the advantage of popping a ;; prompt every time. ;; ;; [1]: https://www.emacswiki.org/emacs/CompileCommand :init (setq compilation-read-command nil) ;; Hide the compilation buffer upon successful compilation. I typically don't ;; care about the output unless there were errors. :config (add-hook 'compilation-finish-functions (lambda (buf strg) (ignore strg) (let ((win (get-buffer-window buf 'visible))) (when win (delete-window win)))))) (use-package flycheck) (use-package magit :bind ("C-c g" . magit-status)) ;; After several failed attempts at getting into Smartparens, I've finally ;; developed a taste for it. Rommel was not lying when he said that "[i]t's like ;; having cybernetic limbs—it makes you jump higher and punch harder." (use-package smartparens ;; Use the default Smartparens configuration as a base. :config (require 'smartparens-config) ;; Enable the Smartparens-flavored replacement for `show-paren-mode'. :config (show-smartparens-global-mode t) ;; Enable Smartparens in all modes derived from `prog-mode' or `comint-mode', ;; the latter hopefully covering all REPL cases. :hook (prog-mode . turn-on-smartparens-mode) (comint-mode . turn-on-smartparens-mode) ;; Rebind the default keys for manipulating sexps to the alternatives ;; suggested in Emacs and Pairs [1]. ;; ;; [1]: https://ebzzry.io/en/emacs-pairs/ :bind (:map smartparens-mode-map ("C-M-a" . sp-beginning-of-sexp) ("C-M-e" . sp-end-of-sexp) ("C-M-d" . sp-down-sexp) ("C-M-u" . sp-backward-up-sexp) ("C-M-f" . sp-forward-sexp) ("C-M-b" . sp-backward-sexp) ("C-M-n" . sp-next-sexp) ("C-M-p" . sp-previous-sexp) ("M-[" . sp-backward-unwrap-sexp) ("M-]" . sp-unwrap-sexp) ("C-" . sp-forward-slurp-sexp) ("C-" . sp-backward-slurp-sexp) ("M-" . sp-foward-barf-sexp) ("M-" . sp-forward-barf-sexp) ("C-M-t" . sp-transpose-sexp) ("C-M-k" . sp-kill-sexp) ("M-k" . sp-backward-kill-sexp)) ;; The following mask `split-line' and `completion-at-point', respectively, ;; but I have yet to use either of these, so I don't mind using the keys for ;; Smartparens. I use "o" as a mnemonic for "out", and "i" is a mnemonic for ;; "in". :bind (:map smartparens-mode-map ("C-M-o" . sp-up-sexp) ("C-M-i" . sp-backward-down-sexp))) ;; Dash [1] is an alright system for managing documentation offline. We're in ;; Emacs, though, so why not make full use of it and use EWW to browse docs? ;; ;; [1]: https://kapeli.com/dash (defun maybe-install-docset (name) "Install NAME if it is not already installed." (let ((file-name (concat name ".docset"))) (unless (file-exists-p (expand-file-name file-name dash-docs-docsets-path)) (dash-docs-install-docset name)))) (use-package dash-docs :init (setq dash-docs-browser-func 'eww) :config (maybe-install-docset "Rust") :hook (rust-mode . (lambda () (setq-local dash-docs-docsets '("Rust")))) :bind (("C-c C-M-d" . counsel-dash))) (use-package counsel-dash) ;; I configure EWW here because I mostly use it for Dash. Thanks to the ;; Javascript curse, Firefox is my daily driver for recreational browsing. (use-package eww :straight nil :init (setq shr-max-width 80) (setq shr-use-colors nil) (setq shr-use-fonts nil) (setq eww-header-line-format nil)) ;; The last time I tried `lsp-mode', I was unhappy with the sheer amount of ;; stuff that was included. So I use `eglot' instead. Thus far, it's been a ;; pleasant experience. (use-package eglot :config (push :hoverProvider eglot-ignored-server-capabilities))