dotfiles/.doom.d/config.el

413 lines
14 KiB
EmacsLisp
Raw Normal View History

2020-01-02 17:54:49 +01:00
(setq user-full-name "inigoortega"
user-mail-address "inigoortega@tutanota.com")
2020-01-16 19:03:06 +01:00
;; -*- lexical-binding: t -*-
2020-01-02 17:54:49 +01:00
(setq doom-font (font-spec :family "monospace" :width 'normal :size 17)
doom-variable-pitch-font (font-spec :family "monospace"))
(setq doom-theme 'doom-gruvbox)
(setq display-line-numbers-type 'relative)
2020-01-16 19:03:06 +01:00
(setq org-directory "~/org/")
(setq sh-symbols
2020-02-21 11:52:49 +01:00
'(sed tail printf echo pidof top dmenu rofi killall sed awk tee basename
ln mkdir rm ssh sleep source ps bash python perl Rscript wget
bunzip2 bzip2 zip unzip gzip gunzip find ls cat egrep grep mv cp
chmod tar stty export spark-shell spark-submit hadoop pyspark aws
2020-04-21 00:01:51 +02:00
dash xdotool xprop 7z p7z zsh fish expr command disown pv alias
2020-01-16 19:03:06 +01:00
))
2020-01-23 15:10:39 +01:00
(setq prelude-symbols
'(not otherwise maybe either fst snd curry uncurry compare min max succ
2020-03-29 16:54:56 +02:00
pred toEnum fromEnum enumFrom enumFromThen enumFromTo enumFromThenTo
minBound maxBound abs negate signum fromInteger show showsPrec showList
toInteger toRational quot rem div mod quotRem divMod toInteger recip
fromRational pi exp log sqrt logBase sin cos tan asin acos atan sinh cosh
tanh asinh acosh atanh map properFraction truncate round ceiling floor
floatRadix floatDigits floatRange decodeFloat encodeFloat exponent
significand scaleFloat isNaN isInfinite isDenormalized isNegativeZero
isIEEE atan2 subtract odd even gcd lcm fromIntegral realToFrac mempty
mappend mconcat fmap pure return fail mapM_ sequence foldMap foldr foldl
foldr1 foldl1 elem minimum sum product traverse sequenceA mapM id const
flip until asTypeOf error errorWithoutStackTrace undefined seq filter head
last tail init null length reverse and or any all concat concatMap scanl
scanr scanr1 iterate repeat replicate cycle take drop dropWhile takeWhile
splitAt span break notElem lookup zip zip3 zipWith zipWith3 unzip unzip3
lines words unlines unwords shows showChar showString showParen readsPrec
readList reads readParen read lex putChar putStr putStrLn print getChar
getLine getContents interact readFile writeFile appendFile readIO readLn
ioError userError))
2020-01-23 15:10:39 +01:00
2020-01-16 19:03:06 +01:00
(setq path-to-ctags "/usr/bin/ctags")
2020-01-23 15:10:39 +01:00
(setq i-keys (mapcar
(lambda (number) (setq command (format "i%c" number)))
(number-sequence 35 91)))
(nconc i-keys (mapcar
2020-03-29 16:54:56 +02:00
(lambda (number) (setq command (format "i%c" number)))
(number-sequence 93 250)))
2020-01-02 17:54:49 +01:00
(defun eval-string (string)
"Evals all the commands inside the string"
(eval (car (read-from-string (format "(progn %s)" string)))))
2020-01-03 00:36:10 +01:00
;;; Shell script highlighting
2020-01-23 15:10:39 +01:00
(defun highlight-words-on-mode (mode symbols &optional face)
2020-01-16 19:03:06 +01:00
"Makes given symbols be highlighted on given mode"
(setq strings (mapcar 'symbol-name symbols))
2020-01-03 00:36:10 +01:00
(setq formatted-words
2020-01-02 17:54:49 +01:00
(concat "\\\\<\\\\(" (mapconcat 'identity
2020-01-16 19:03:06 +01:00
strings "\\\\|") "\\\\)\\\\>"))
2020-01-23 15:10:39 +01:00
(if face
(eval-string (format "(font-lock-add-keywords '%s '((\"%s\" .
%s)))" mode formatted-words face))
(eval-string (format "(font-lock-add-keywords '%s '((\"%s\" .
%s)))" mode formatted-words font-lock-builtin-face))
)
2020-01-02 17:54:49 +01:00
;; highlight options
(font-lock-add-keywords
2020-01-03 00:36:10 +01:00
mode
2020-01-02 17:54:49 +01:00
'(("\\<-[-a-zA-Z0-9]+\\>"
. font-lock-constant-face)))
(font-lock-add-keywords
2020-01-23 15:10:39 +01:00
mode
2020-01-02 17:54:49 +01:00
`((,(concat "[ \t]+"
(regexp-opt
'("!" "!=" "==" "=~") 'paren) "[ \t]+")
. font-lock-constant-face)))
)
2020-01-16 19:03:06 +01:00
(defun create-tags (dir-name)
"Create tags file."
(interactive "DDirectory: ")
(shell-command
(format "%s -f TAGS -e -R %s" path-to-ctags (directory-file-name dir-name)))
)
(map! :n "g r" #'evil-replace-with-register)
(map! :n "SPC w D" #'delete-other-windows)
2020-01-23 17:42:38 +01:00
(defvar my-term-shell "/bin/zsh")
(defadvice ansi-term (before force-bash)
(interactive (list my-term-shell)))
(ad-activate 'ansi-term)
2020-01-16 19:03:06 +01:00
(mapcar
2020-01-23 15:10:39 +01:00
(lambda (command)
(eval-string
2020-02-21 11:52:49 +01:00
(format "(map!
2020-04-21 00:01:51 +02:00
:map text-mode-map
:map prog-mode-map
:map org-mode-map
2020-02-21 11:52:49 +01:00
:i \"%s\" (lambda() (interactive) (insert! \"%s\")))"
2020-04-21 00:01:51 +02:00
command command))) i-keys)
2020-01-16 19:03:06 +01:00
2020-04-21 00:01:51 +02:00
;; Exceptions
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i !" (lambda()
2020-01-23 23:46:41 +01:00
(interactive)
2020-04-21 00:01:51 +02:00
(insert! "i!")))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i \"" (lambda()
(interactive)
(insert! (format "i%c" 34))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i SPC" (lambda()
(interactive)
(insert! "i ")))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i ESC" (lambda()
(interactive)
(insert! "i") (evil-normal-state)))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i RET" (lambda()
(interactive)
(insert! "i")
(execute-kbd-macro (kbd "RET"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i \\" (lambda()
(interactive)
(insert! "i\\")))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i DEL" (lambda()
(interactive)
(insert! "")))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i TAB" (lambda()
(interactive)
(insert! "i")
(execute-kbd-macro (kbd "TAB"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i C-n" (lambda()
(interactive)
(insert! "i") (evil-complete-next)))
2020-01-23 15:10:39 +01:00
2020-04-21 00:01:51 +02:00
;; F keys
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f1>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f1>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f2>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f2>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f3>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f3>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f4>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f4>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f5>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f5>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f6>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f6>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f7>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f7>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f8>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f8>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f9>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f9>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f10>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f10>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f11>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f11>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <f12>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f12>"))))
2020-03-08 13:38:31 +01:00
2020-04-21 00:01:51 +02:00
;; Other special keys
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <pause>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<pause>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <Scroll_Lock>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<Scroll_Lock>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <insert>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<insert>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <deletechar>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<deletechar>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <home>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<home>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <end>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<end>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <prior>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<prior>"))))
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i <next>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<next>"))))
2020-03-08 13:38:31 +01:00
2020-04-21 00:01:51 +02:00
;; i i
(map! :map text-mode-map
:map prog-mode-map
:map org-mode-map
:i "i i" #'evil-normal-state)
2020-01-23 15:10:39 +01:00
(setq dired-dwim-target t)
2020-01-16 19:03:06 +01:00
(show-paren-mode 1)
2020-01-23 15:10:39 +01:00
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(add-hook! 'text-mode-hook #'turn-on-auto-fill)
2020-01-16 19:03:06 +01:00
(setq-default auto-fill-function 'do-auto-fill)
2020-01-23 15:10:39 +01:00
;; (require 'whitespace)
;; (setq whitespace-style '(face lines-tail))
2020-01-23 23:46:41 +01:00
;; (add-hook 'text-mode-hook
;; (setq whitespace-line-column 80)
;; ;; (global-whitespace-mode t) ; for dot on spaces
;; )
2020-01-23 15:10:39 +01:00
;; (setq-default show-trailing-whitespace t)
2020-01-23 23:46:41 +01:00
(setq-default indicate-empty-lines t)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
2020-01-16 19:03:06 +01:00
(global-visual-line-mode)
(global-evil-surround-mode t)
(vimish-fold-global-mode 1)
2020-04-21 00:01:51 +02:00
(add-hook 'prog-mode-hook
(lambda ()
(if (or (derived-mode-p 'python-mode) (derived-mode-p 'haskell-mode))
(progn
(yafolding-mode)
(yafolding-hide-all)
)
(+fold/close-all)
)))
2020-01-23 15:10:39 +01:00
(defun yafolding-hide-rec ()
(interactive)
(setq level (yafolding-get-indent-level))
2020-04-21 00:01:51 +02:00
(while (or (current-line-empty-p) (> level 0))
(if (current-line-empty-p)
(progn
(re-search-backward "^.")
(setq level (yafolding-get-indent-level))
(message (number-to-string level))
)
(progn
(yafolding-go-parent-element)
(setq level (- level 1))
)
))
(yafolding-hide-element)
)
(defun current-line-empty-p ()
;; Spaces not included
(string-match-p "\\`$" (thing-at-point 'line)))
(defun current-line-empty2-p ()
;; Spaces included
(string-match-p "\\`\\s-*$" (thing-at-point 'line)))
2020-01-23 15:10:39 +01:00
2020-01-23 23:46:41 +01:00
(map! :map 'hs-minor-mode-map
:n "z o" #'hs-show-block
)
2020-01-23 15:10:39 +01:00
(map! :map 'yafolding-mode-map
:n "z a" #'yafolding-toggle-fold
:n "z c" #'yafolding-hide-parent-element
:n "z C" #'yafolding-hide-rec
:n "z o" #'yafolding-show-element
:n "z m" #'yafolding-hide-all
:n "z r" #'yafolding-show-all
)
2020-01-16 19:03:06 +01:00
;; Default user.
(setq rcirc-default-nick "initega")
(setq rcirc-default-user-name "initega")
(setq rcirc-default-full-name "initega")
2020-01-23 15:10:39 +01:00
(after! haskell-mode
(progn
(setq
;; Format files with Brittany instead of Stylish
haskell-mode-stylish-haskell-path "brittany"
;; Format buffer with Brittany on save
haskell-stylish-on-save t
;; Suggest removing imports
haskell-process-suggest-remove-import-lines t)))
(add-hook 'haskell-mode-hook
(lambda ()
(interactive)
(haskell-indentation-mode)
(interactive-haskell-mode)
(yas-minor-mode)
))
(map! :map 'haskell-interactive-mode-map
:i "C-j" #'haskell-interactive-mode-history-next)
(map! :map 'haskell-interactive-mode-map
:i "C-k" #'haskell-interactive-mode-history-previous)
;; (setq haskell-process-path-ghci "stack-ghci")
(setq haskell-process-type 'stack-ghci)
(after! dante
(nconc dante-methods '(stack-ghci))
(defun dante-repl-command-line ()
'("stack-ghci"))
)
;; (setq dante-methods
;; '(styx new-impure-nix new-nix nix impure-nix new-build nix-ghci stack mafia
;; bare-cabal bare-ghci)))
2020-01-16 19:03:06 +01:00
2020-01-23 15:10:39 +01:00
(add-hook 'dante-mode-hook
'(lambda () (flycheck-add-next-checker 'haskell-dante
'(warning . haskell-hlint))))
(highlight-words-on-mode 'haskell-mode prelude-symbols)
2020-02-08 10:52:26 +01:00
(setq org-babel-load-languages '((emacs-lisp . t) (ein . t)))
2020-01-16 19:03:06 +01:00
(elpy-enable)
2020-01-02 17:54:49 +01:00
2020-04-21 00:01:51 +02:00
;; Following disabled due to high CPU usage
2020-01-16 19:03:06 +01:00
;;; Use IPython for REPL
2020-04-21 00:01:51 +02:00
;; (setq python-shell-interpreter "jupyter"
;; python-shell-interpreter-args "console --simple-prompt"
;; python-shell-prompt-detect-failure-warning nil)
;; (add-to-list 'python-shell-completion-native-disabled-interpreters
;; "jupyter")
;; (setq python-shell-interpreter "ipython"
;; python-shell-interpreter-args "-i --simple-prompt")
(setq blacken-line-length 80)
2020-03-29 16:54:56 +02:00
(add-hook 'python-mode-hook
2020-04-21 00:01:51 +02:00
(lambda ()
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(blacken-mode)
(setq-default python-indent 4)))
2020-01-16 19:03:06 +01:00
(highlight-words-on-mode 'sh-mode sh-symbols)