;;; $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. It is optional. ;; (setq user-full-name "John Doe" ;; user-mail-address "john@doe.com") ;; Doom exposes five (optional) variables for controlling fonts in Doom: ;; ;; - `doom-font' -- the primary font to use ;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable) ;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for ;; presentations or streaming. ;; - `doom-symbol-font' -- for symbols ;; - `doom-serif-font' -- for the `fixed-pitch-serif' face ;; ;; See 'C-h v doom-font' for documentation and more examples of what they ;; accept. For example: ;; ;;(setq doom-font (font-spec :family "Fira Code" :size 12 :weight 'semi-light) ;; doom-variable-pitch-font (font-spec :family "Fira Sans" :size 13)) ;; ;; If you or Emacs can't find your font, use 'M-x describe-font' to look them ;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to ;; refresh your font settings. If Emacs still can't find your font, it likely ;; wasn't installed correctly. Font issues are rarely Doom issues! ;; There are two ways to load a theme. Both assume the theme is installed and ;; available. You can either set `doom-theme' or manually load a theme with the ;; `load-theme' function. This is the default: (setq doom-theme 'doom-nord) ;; 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) ;; 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 "~/org/") ;; Whenever you reconfigure a package, make sure to wrap your config in an ;; `after!' block, otherwise Doom's defaults may override your settings. E.g. ;; ;; (after! PACKAGE ;; (setq x y)) ;; ;; The exceptions to this rule: ;; ;; - Setting file/directory variables (like `org-directory') ;; - Setting variables which explicitly tell you to set them before their ;; package is loaded (see 'C-h v VARIABLE' to look up their documentation). ;; - Setting doom variables (which start with 'doom-' or '+'). ;; ;; Here are some additional functions/macros that will 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. ;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces, ;; etc). ;; ;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how ;; they are implemented. (add-hook 'clojure-mode-hook #'turn-on-smartparens-strict-mode) (setq gofmt-command "goimports") (add-hook 'before-save-hook 'gofmt-before-save) ;; The default value omits .. which is a pain when navigating directories (setq dired-omit-files "\\`[.]?#\\|\\`[.]\\'\\|^\\.DS_Store\\'\\|^flycheck_.*\\|^\\.project\\(?:ile\\)?\\'\\|^\\.\\(?:svn\\|git\\)\\'\\|^\\.ccls-cache\\'\\|\\(?:\\.js\\)?\\.meta\\'\\|\\.\\(?:elc\\|o\\|pyo\\|swp\\|class\\)\\'") ;; Additional configuration for smartparens (after! smartparens (require 'smartparens-config) (add-hook 'eval-expression-minibuffer-setup-hook 'turn-on-smartparens-strict-mode) ;;;;;;;;;;;;;;;;;;;;;;;; ;; keybinding management (define-key smartparens-mode-map (kbd "C-M-f") 'sp-forward-sexp) (define-key smartparens-mode-map (kbd "C-M-b") 'sp-backward-sexp) (define-key smartparens-mode-map (kbd "C-M-d") 'sp-down-sexp) (define-key smartparens-mode-map (kbd "C-M-a") 'sp-backward-down-sexp) (define-key smartparens-mode-map (kbd "C-S-d") 'sp-beginning-of-sexp) (define-key smartparens-mode-map (kbd "C-S-a") 'sp-end-of-sexp) (define-key smartparens-mode-map (kbd "C-M-e") 'sp-up-sexp) (define-key smartparens-mode-map (kbd "C-M-u") 'sp-backward-up-sexp) (define-key smartparens-mode-map (kbd "C-M-t") 'sp-transpose-sexp) (define-key smartparens-mode-map (kbd "C-M-n") 'sp-forward-hybrid-sexp) (define-key smartparens-mode-map (kbd "C-M-p") 'sp-backward-hybrid-sexp) (define-key smartparens-mode-map (kbd "C-M-k") 'sp-kill-sexp) (define-key smartparens-mode-map (kbd "C-M-w") 'sp-copy-sexp) (define-key smartparens-mode-map (kbd "M-") 'sp-unwrap-sexp) (define-key smartparens-mode-map (kbd "M-") 'sp-backward-unwrap-sexp) (define-key smartparens-mode-map (kbd "C-") 'sp-forward-slurp-sexp) (define-key smartparens-mode-map (kbd "C-") 'sp-forward-barf-sexp) (define-key smartparens-mode-map (kbd "C-M-") 'sp-backward-slurp-sexp) (define-key smartparens-mode-map (kbd "C-M-") 'sp-backward-barf-sexp) (define-key smartparens-mode-map (kbd "M-D") 'sp-splice-sexp) (define-key smartparens-mode-map (kbd "C-M-") 'sp-splice-sexp-killing-forward) (define-key smartparens-mode-map (kbd "C-M-") 'sp-splice-sexp-killing-backward) (define-key smartparens-mode-map (kbd "C-S-") 'sp-splice-sexp-killing-around) (define-key smartparens-mode-map (kbd "C-]") 'sp-select-next-thing-exchange) (define-key smartparens-mode-map (kbd "C-") 'sp-select-previous-thing) (define-key smartparens-mode-map (kbd "C-M-]") 'sp-select-next-thing) (define-key smartparens-mode-map (kbd "M-F") 'sp-forward-symbol) (define-key smartparens-mode-map (kbd "M-B") 'sp-backward-symbol) (define-key smartparens-mode-map (kbd "C-\"") 'sp-change-inner) (define-key smartparens-mode-map (kbd "M-i") 'sp-change-enclosing) (bind-key "C-c f" (lambda () (interactive) (sp-beginning-of-sexp 2)) smartparens-mode-map) (bind-key "C-c b" (lambda () (interactive) (sp-beginning-of-sexp -2)) smartparens-mode-map) (bind-key "C-M-s" (defhydra smartparens-hydra () "Smartparens" ("d" sp-down-sexp "Down") ("e" sp-up-sexp "Up") ("u" sp-backward-up-sexp "Up") ("a" sp-backward-down-sexp "Down") ("f" sp-forward-sexp "Forward") ("b" sp-backward-sexp "Backward") ("k" sp-kill-sexp "Kill" :color blue) ("q" nil "Quit" :color blue)) smartparens-mode-map) (bind-key "H-t" 'sp-prefix-tag-object smartparens-mode-map) (bind-key "H-p" 'sp-prefix-pair-object smartparens-mode-map) (bind-key "H-y" 'sp-prefix-symbol-object smartparens-mode-map) (bind-key "H-h" 'sp-highlight-current-sexp smartparens-mode-map) (bind-key "H-e" 'sp-prefix-save-excursion smartparens-mode-map) (bind-key "H-s c" 'sp-convolute-sexp smartparens-mode-map) (bind-key "H-s a" 'sp-absorb-sexp smartparens-mode-map) (bind-key "H-s e" 'sp-emit-sexp smartparens-mode-map) (bind-key "H-s p" 'sp-add-to-previous-sexp smartparens-mode-map) (bind-key "H-s n" 'sp-add-to-next-sexp smartparens-mode-map) (bind-key "H-s j" 'sp-join-sexp smartparens-mode-map) (bind-key "H-s s" 'sp-split-sexp smartparens-mode-map) (bind-key "H-s r" 'sp-rewrap-sexp smartparens-mode-map) (defvar hyp-s-x-map) (define-prefix-command 'hyp-s-x-map) (bind-key "H-s x" hyp-s-x-map smartparens-mode-map) (bind-key "H-s x x" 'sp-extract-before-sexp smartparens-mode-map) (bind-key "H-s x a" 'sp-extract-after-sexp smartparens-mode-map) (bind-key "H-s x s" 'sp-swap-enclosing-sexp smartparens-mode-map) (bind-key "C-x C-t" 'sp-transpose-hybrid-sexp smartparens-mode-map) (bind-key ";" 'sp-comment emacs-lisp-mode-map) (bind-key "C-M-;" 'sp-comment-sexp smartparens-mode-map) (bind-key [remap c-electric-backspace] 'sp-backward-delete-char smartparens-strict-mode-map) ;;;;;;;;;;;;;;;;;; ;; pair management (sp-with-modes '(minibuffer-mode) (sp-local-pair "'" nil :actions nil) (sp-local-pair "(" nil :wrap "C-(")) (sp-with-modes 'org-mode (sp-local-pair "=" "=" :wrap "C-=")) (sp-with-modes 'textile-mode (sp-local-pair "*" "*") (sp-local-pair "_" "_") (sp-local-pair "@" "@")) (sp-with-modes 'web-mode (sp-local-pair "{{#if" "{{/if") (sp-local-pair "{{#unless" "{{/unless")) ;;; tex-mode latex-mode (sp-with-modes '(tex-mode plain-tex-mode latex-mode) (sp-local-tag "i" "\"<" "\">")) ;;; lisp modes (sp-with-modes sp--lisp-modes (sp-local-pair "(" nil :wrap "C-(" :pre-handlers '(my-add-space-before-sexp-insertion) :post-handlers '(my-add-space-after-sexp-insertion))) (defun my-add-space-after-sexp-insertion (id action _context) (when (eq action 'insert) (save-excursion (forward-char (sp-get-pair id :cl-l)) (when (or (eq (char-syntax (following-char)) ?w) (looking-at (sp--get-opening-regexp))) (insert " "))))) (defun my-add-space-before-sexp-insertion (id action _context) (when (eq action 'insert) (save-excursion (backward-char (length id)) (when (or (eq (char-syntax (preceding-char)) ?w) (and (looking-back (sp--get-closing-regexp)) (not (eq (char-syntax (preceding-char)) ?')))) (insert " "))))))