dotfiles/.doom.d/config.el
inigoortega 1d82ea40dd doom ii
2020-02-08 10:52:26 +01:00

351 lines
12 KiB
EmacsLisp

(setq user-full-name "inigoortega"
user-mail-address "inigoortega@tutanota.com")
;; -*- lexical-binding: t -*-
(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)
(setq org-directory "~/org/")
(setq sh-symbols
'(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 dash xdotool xprop 7z p7z zsh fish expr command disown pv
))
(setq prelude-symbols
'(not otherwise maybe either fst snd curry uncurry compare min max succ
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))
(setq path-to-ctags "/usr/bin/ctags")
(setq i-keys (mapcar
(lambda (number) (setq command (format "i%c" number)))
(number-sequence 35 91)))
(nconc i-keys (mapcar
(lambda (number) (setq command (format "i%c" number)))
(number-sequence 93 250)))
(defun eval-string (string)
"Evals all the commands inside the string"
(eval (car (read-from-string (format "(progn %s)" string)))))
;;; Shell script highlighting
(defun highlight-words-on-mode (mode symbols &optional face)
"Makes given symbols be highlighted on given mode"
(setq strings (mapcar 'symbol-name symbols))
(setq formatted-words
(concat "\\\\<\\\\(" (mapconcat 'identity
strings "\\\\|") "\\\\)\\\\>"))
(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))
)
;; highlight options
(font-lock-add-keywords
mode
'(("\\<-[-a-zA-Z0-9]+\\>"
. font-lock-constant-face)))
(font-lock-add-keywords
mode
`((,(concat "[ \t]+"
(regexp-opt
'("!" "!=" "==" "=~") 'paren) "[ \t]+")
. font-lock-constant-face)))
)
(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)
(defvar my-term-shell "/bin/zsh")
(defadvice ansi-term (before force-bash)
(interactive (list my-term-shell)))
(ad-activate 'ansi-term)
(mapcar
(lambda (command)
(eval-string
(format "(map! :map text-mode-map :map prog-mode-map :i \"%s\" (lambda() (interactive) (insert! \"%s\")))"
command command))) i-keys)
;; Exceptions
(map! :map text-mode-map
:map prog-mode-map
:i "i !" (lambda()
(interactive)
(insert! "i!")))
(map! :map text-mode-map
:map prog-mode-map
:i "i \"" (lambda()
(interactive)
(insert! (format "i%c" 34))))
(map! :map text-mode-map
:map prog-mode-map
:i "i SPC" (lambda()
(interactive)
(insert! "i ")))
(map! :map text-mode-map
:map prog-mode-map
:i "i ESC" (lambda()
(interactive)
(insert! "i") (evil-normal-state)))
(map! :map text-mode-map
:map prog-mode-map
:i "i RET" (lambda()
(interactive)
(insert! "i")
(execute-kbd-macro (kbd "RET"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i \\" (lambda()
(interactive)
(insert! "i\\")))
(map! :map text-mode-map
:map prog-mode-map
:i "i DEL" (lambda()
(interactive)
(insert! "")))
(map! :map text-mode-map
:map prog-mode-map
:i "i TAB" (lambda()
(interactive)
(insert! "i")
(execute-kbd-macro (kbd "TAB"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i C-n" (lambda()
(interactive)
(insert! "i") (evil-complete-next)))
;; F keys
(map! :map text-mode-map
:map prog-mode-map
:i "i <f1>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f1>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f2>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f2>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f3>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f3>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f4>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f4>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f5>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f5>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f6>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f6>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f7>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f7>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f8>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f8>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f9>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f9>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f10>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f10>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f11>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f11>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <f12>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<f12>"))))
;; Other special keys
(map! :map text-mode-map
:map prog-mode-map
:i "i <pause>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<pause>"))))
(map! :map text-mode-map
:map prog-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
:i "i <insert>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<insert>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <deletechar>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<deletechar>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <home>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<home>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <end>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<end>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <prior>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<prior>"))))
(map! :map text-mode-map
:map prog-mode-map
:i "i <next>" (lambda()
(interactive)
(insert! "i") (execute-kbd-macro (kbd "<next>"))))
;; i i
(map! :map text-mode-map
:map prog-mode-map
:map prog-mode-map
:i "i i" #'evil-normal-state)
(setq dired-dwim-target t)
(show-paren-mode 1)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(add-hook! 'text-mode-hook #'turn-on-auto-fill)
(setq-default auto-fill-function 'do-auto-fill)
;; (require 'whitespace)
;; (setq whitespace-style '(face lines-tail))
;; (add-hook 'text-mode-hook
;; (setq whitespace-line-column 80)
;; ;; (global-whitespace-mode t) ; for dot on spaces
;; )
;; (setq-default show-trailing-whitespace t)
(setq-default indicate-empty-lines t)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(global-visual-line-mode)
(global-evil-surround-mode t)
(vimish-fold-global-mode 1)
(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)
)))
(defun yafolding-hide-rec ()
(interactive)
(setq level (yafolding-get-indent-level))
(while (> level 0)
(yafolding-go-parent-element)
(setq level (- level 1)))
(yafolding-hide-element))
(map! :map 'hs-minor-mode-map
:n "z o" #'hs-show-block
)
(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
)
;; Default user.
(setq rcirc-default-nick "initega")
(setq rcirc-default-user-name "initega")
(setq rcirc-default-full-name "initega")
(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)))
(add-hook 'dante-mode-hook
'(lambda () (flycheck-add-next-checker 'haskell-dante
'(warning . haskell-hlint))))
(highlight-words-on-mode 'haskell-mode prelude-symbols)
(setq org-babel-load-languages '((emacs-lisp . t) (ein . t)))
(elpy-enable)
;;; Use IPython for REPL
(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")
(highlight-words-on-mode 'sh-mode sh-symbols)