summaryrefslogtreecommitdiff
path: root/lisp/programming.el
diff options
context:
space:
mode:
authorJakob L. Kreuze2020-06-01 16:53:50 -0400
committerJakob L. Kreuze2020-06-01 16:53:50 -0400
commit6c7f0b8ae2de30a808901b16b0d462fe833ea1b4 (patch)
tree2cc0a3e9022fc43c39e5b91f4e7832b5387636e9 /lisp/programming.el
parent4d4f759881e310818055c31f286158da9db60d1c (diff)
Break config into files.
Diffstat (limited to 'lisp/programming.el')
-rw-r--r--lisp/programming.el157
1 files changed, 157 insertions, 0 deletions
diff --git a/lisp/programming.el b/lisp/programming.el
new file mode 100644
index 0000000..641a270
--- /dev/null
+++ b/lisp/programming.el
@@ -0,0 +1,157 @@
+;;; programming.el -*- lexical-binding: t; -*-
+;;;
+;;; Author: Jakob L. Kreuze <zerodaysfordays@sdf.org>
+;;; 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
+ ;; Replace `xref' keybindings instead of using the default ones, since these
+ ;; will get overwritten if I'm using a proper tag indexer anyway.
+ :config
+ (define-key dumb-jump-mode-map (kbd "C-M-g") nil)
+ (define-key dumb-jump-mode-map (kbd "C-M-p") nil)
+ (define-key dumb-jump-mode-map (kbd "C-M-q") nil)
+ (define-key dumb-jump-mode-map (kbd "M-.") #'dumb-jump-go)
+ (define-key dumb-jump-mode-map (kbd "M-,") #'dumb-jump-back)
+ (dumb-jump-mode))
+
+(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 <tab> responsible for completion rather than <ret>, so that
+ ;; company isn't quite as in-the-way.
+ :bind
+ (:map company-active-map
+ ("TAB" . company-complete-selection)
+ ("<tab>" . company-complete-selection)
+ ("RET" . nil)
+ ("<return>" . nil)))
+
+(use-package compile
+ :straight nil
+ :bind
+ ("<f12>" . 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)
+ (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-<right>" . sp-forward-slurp-sexp)
+ ("C-<left>" . sp-backward-slurp-sexp)
+ ("M-<right>" . sp-foward-barf-sexp)
+ ("M-<right>" . 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)))
+
+(use-package lsp-ui
+ ;; The only reason I'm using `lsp-ui' is for integration with Flycheck. The
+ ;; features like lenses don't interest me.
+ :init
+ (setq lsp-ui-sideline-enable nil
+ lsp-ui-peek-enable nil
+ lsp-ui-doc-enable nil))
+
+;; Disable the default machinery in `lsp-mode'. The reason I'm using the package
+;; in the first place is for its ability to integrate with the other
+;; programming-related packages I use.
+
+(use-package company-lsp
+ :commands company-lsp
+ :init
+ (setq company-lsp-cache-candidates 'auto))
+
+(use-package lsp-mode
+ :init
+ (setq lsp-prefer-flymake nil
+ lsp-enable-xref t)
+
+ ;; Filesystem hygene.
+ :init
+ (setq lsp-session-file "~/.cache/emacs/.lsp-session-v1"
+ lsp-auto-guess-root t)
+
+ ;; Use `xref' keybindings instead of the default ones.
+ :bind
+ (:map lsp-mode-map
+ ("M-." . lsp-find-definition)
+ ("M-," . pop-tag-mark)))

© 2015 - 2026 Jakob L. Kreuze