Emacs updates

This commit is contained in:
inigoortega 2020-01-23 15:10:39 +01:00
parent bf6d388d3f
commit a56e7d1cf4
4 changed files with 250 additions and 74 deletions

View File

@ -15,20 +15,52 @@
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)
(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 "\\\\|") "\\\\)\\\\>"))
(eval-string (format "(font-lock-add-keywords 'sh-mode '((\"%s\" .
font-lock-builtin-face)))" formatted-words))
(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
@ -36,7 +68,7 @@ font-lock-builtin-face)))" formatted-words))
'(("\\<-[-a-zA-Z0-9]+\\>"
. font-lock-constant-face)))
(font-lock-add-keywords
'sh-mode
mode
`((,(concat "[ \t]+"
(regexp-opt
'("!" "!=" "==" "=~") 'paren) "[ \t]+")
@ -51,52 +83,135 @@ font-lock-builtin-face)))" formatted-words))
)
(map! :n "g r" #'evil-replace-with-register)
(map! :n "SPC w D" #'delete-other-windows)
(setq min-char 35)
(setq max-char 250)
(setq i-keys (mapcar
(lambda (number) (setq command (format "i%c" number)))
(number-sequence min-char 91)))
(nconc i-keys (mapcar
(lambda (number) (setq command (format "i%c" number)))
(number-sequence 93 max-char)))
(mapcar
(lambda (command) (eval-string
(format "(map! :i \"%s\" (lambda() (interactive) (insert \"%s\")))"
command command)))
i-keys)
;; (mapcar
;; (lambda (command) (eval-string
;; (format "(map! :i \"%s\" (lambda() (interactive) (insert \"%s\")))"
;; command command)))
;; i-keys)
(lambda (command)
(eval-string
(format "(map! :i \"%s\" (lambda() (interactive) (insert \"%s\")))"
command command))) i-keys)
;; Exceptions
(map! :i "i !" (lambda() (interactive) (insert "i!")))
(map! :i "i \"" (lambda() (interactive) (insert (format "i%c" 34))))
(map! :i "i SPC" (lambda() (interactive) (insert "i ")))
(map! :i "i ESC" (lambda() (interactive) (insert "i") (evil-normal-state)))
(map! :i "i RET" (lambda() (interactive)
(insert "i")
(execute-kbd-macro (kbd "RET"))))
(map! :i "i \\" (lambda() (interactive) (insert "i\\")))
(map! :i "i DEL" (lambda() (interactive) (insert "")))
(map! :i "i TAB" (lambda() (interactive)
(insert "i")
(execute-kbd-macro (kbd "TAB"))))
(map! :i "i C-n" (lambda() (interactive) (insert "i") (evil-complete-next)))
;; i i
;; F keys
(map! :i "i <f1>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f1>"))))
(map! :i "i <f2>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f2>"))))
(map! :i "i <f3>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f3>"))))
(map! :i "i <f4>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f4>"))))
(map! :i "i <f5>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f5>"))))
(map! :i "i <f6>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f6>"))))
(map! :i "i <f7>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f7>"))))
(map! :i "i <f8>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f8>"))))
(map! :i "i <f9>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f9>"))))
(map! :i "i <f10>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f10>"))))
(map! :i "i <f11>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f11>"))))
(map! :i "i <f12>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f12>"))))
;; Other special keys
(map! :i "i <pause>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<pause>"))))
(map! :i "i <Scroll_Lock>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<Scroll_Lock>"))))
(map! :i "i <insert>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<insert>"))))
(map! :i "i <deletechar>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<deletechar>"))))
(map! :i "i <home>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<home>"))))
(map! :i "i <end>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<end>"))))
(map! :i "i <prior>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<prior>"))))
(map! :i "i <next>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<next>"))))
;; i i
(map! :i "i i" #'evil-normal-state)
(setq dired-dwim-target t)
(show-paren-mode 1)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(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)
(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 '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")
(add-hook! 'haskell-mode-hook #'hindent-mode (lambda() (add-hook!
'before-save-hook
(progn
(hindent-reformat-buffer)
(recenter-top-bottom)
) nil 'local)))
(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)
))
(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)
(elpy-enable)
;;; Use IPython for REPL

View File

@ -168,8 +168,36 @@ Delete other windows:
(insert "i")
(execute-kbd-macro (kbd "RET"))))
(map! :i "i \\" (lambda() (interactive) (insert "i\\")))
(map! :i "i DEL" (lambda() (interactive) (insert "")))
(map! :i "i TAB" (lambda() (interactive)
(insert "i")
(execute-kbd-macro (kbd "TAB"))))
(map! :i "i C-n" (lambda() (interactive) (insert "i") (evil-complete-next)))
;; F keys
(map! :i "i <f1>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f1>"))))
(map! :i "i <f2>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f2>"))))
(map! :i "i <f3>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f3>"))))
(map! :i "i <f4>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f4>"))))
(map! :i "i <f5>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f5>"))))
(map! :i "i <f6>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f6>"))))
(map! :i "i <f7>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f7>"))))
(map! :i "i <f8>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f8>"))))
(map! :i "i <f9>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f9>"))))
(map! :i "i <f10>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f10>"))))
(map! :i "i <f11>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f11>"))))
(map! :i "i <f12>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<f12>"))))
;; Other special keys
(map! :i "i <pause>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<pause>"))))
(map! :i "i <Scroll_Lock>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<Scroll_Lock>"))))
(map! :i "i <insert>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<insert>"))))
(map! :i "i <deletechar>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<deletechar>"))))
(map! :i "i <home>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<home>"))))
(map! :i "i <end>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<end>"))))
(map! :i "i <prior>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<prior>"))))
(map! :i "i <next>" (lambda() (interactive) (insert "i") (execute-kbd-macro (kbd "<next>"))))
;; i i
(map! :i "i i" #'evil-normal-state)
#+END_SRC
@ -181,9 +209,10 @@ Delete other windows:
#+END_SRC
** General
Paren mode:
Delitimers:
#+BEGIN_SRC emacs-lisp
(show-paren-mode 1)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
#+END_SRC
Cutting lines at 80th character:
@ -197,8 +226,9 @@ Highlight after 80:
;; (require 'whitespace)
;; (setq whitespace-style '(face lines-tail))
(add-hook 'text-mode-hook
(setq whitespace-line-column 80)
(global-whitespace-mode t))
;; (setq whitespace-line-column 80)
(global-whitespace-mode t) ; for dot on spaces
)
#+END_SRC
DISABLED. Highlight trailing whitespaces:
@ -217,9 +247,35 @@ Evil-surround work everywhere:
(global-evil-surround-mode t)
#+END_SRC
Folding
Folding:
#+BEGIN_SRC emacs-lisp
(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 '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
)
#+END_SRC
IRC (not working):
@ -231,17 +287,19 @@ IRC (not working):
#+END_SRC
** Haskell
Haskell-mode configs:
#+BEGIN_SRC emacs-lisp
;; Ancient code for hindent
;; (add-hook! 'haskell-mode-hook
;; #'hindent-mode
;; (lambda() (add-hook!
;; 'before-save-hook
;; (progn
;; (hindent-reformat-buffer)
;; (recenter-top-bottom)
;; ) nil 'local)))
# ;; Ancient code for hindent
# ;; (add-hook! 'haskell-mode-hook
# ;; #'hindent-mode
# ;; (lambda() (add-hook!
# ;; 'before-save-hook
# ;; (progn
# ;; (hindent-reformat-buffer)
# ;; (recenter-top-bottom)
# ;; ) nil 'local)))
Haskell stylish:
#+BEGIN_SRC emacs-lisp
(after! haskell-mode
(progn
(setq
@ -253,7 +311,7 @@ Haskell-mode configs:
haskell-process-suggest-remove-import-lines t)))
#+END_SRC
Haskell-mode hook to activate minor modes. I think it is useless.
Haskell-mode hook to activate minor modes (yafolding...).
#+BEGIN_SRC emacs-lisp
(add-hook 'haskell-mode-hook
(lambda ()
@ -307,6 +365,7 @@ Highlight predule:
(add-to-list 'python-shell-completion-native-disabled-interpreters
"jupyter")
#+END_SRC
** Shell script
#+BEGIN_SRC emacs-lisp
(highlight-words-on-mode 'sh-mode sh-symbols)

View File

@ -1,12 +1,18 @@
;;; init.el -*- lexical-binding: t; -*-
;; Copy this file to ~/.doom.d/init.el or ~/.config/doom/init.el ('doom install'
;; will do this for you). The `doom!' block below controls what modules are
;; enabled and in what order they will be loaded. Remember to run 'doom refresh'
;; after modifying it.
;; This file controls what Doom modules are enabled and what order they load in.
;; Remember to run 'doom sync' after modifying it!
;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's
;; documentation. There you'll find information about all of Doom's modules
;; and what flags they support.
;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or
;; 'C-c g k' for non-vim users) to view its documentation. This works on
;; flags as well (those symbols that start with a plus).
;;
;; More information about these modules (and what flags they support) can be
;; found in modules/README.org.
;; Alternatively, press 'gd' (or 'C-c g d') on a module to browse its
;; directory (for easy access to its source code).
(doom! :input
;;chinese
@ -70,16 +76,19 @@
;;term ; terminals in Emacs
;;vterm ; another terminals in Emacs
:checkers
syntax ; tasing you for every semicolon you forget
;;spell ; tasing you for misspelling mispelling
;;grammar ; tasing grammar mistake every you make
:tools
;;ansible
;;debugger ; FIXME stepping through code, to help you add bugs
;;direnv
;;docker
;;editorconfig ; let someone else argue about tabs vs spaces
;;ein ; tame Jupyter notebooks with emacs
ein ; tame Jupyter notebooks with emacs
(eval +overlay) ; run code, run (also, repls)
flycheck ; tasing you for every semicolon you forget
;;flyspell ; tasing you for misspelling mispelling
;;gist ; interacting with github gists
(lookup ; helps you navigate your code and documentation
+docsets) ; ...or in Dash docsets locally
@ -165,25 +174,7 @@
irc ; how neckbeards socialize
;;(rss +org) ; emacs as an RSS reader
;;twitter ; twitter client https://twitter.com/vnought
;;write ; emacs for writers (fiction, notes, papers, etc.)
:config
literate
(default +bindings +smartparens))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-names-vector
["#3c3836" "#fb4933" "#b8bb26" "#fabd2f" "#83a598" "#d3869b" "#8ec07c" "#ebdbb2"])
'(custom-safe-themes
(quote
("8f97d5ec8a774485296e366fdde6ff5589cf9e319a584b845b6f7fa788c9fa9a" default)))
'(pdf-view-midnight-colors (quote ("#fdf4c1" . "#282828"))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

View File

@ -11,15 +11,26 @@
;;
;; Here are a couple examples:
;; All of Doom's packages are pinned to a specific commit, and updated from
;; release to release. To un-pin all packages and live on the edge, do:
;(setq doom-pinned-packages nil)
;; ...but to unpin a single package:
;(package! pinned-package :pin nil)
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;(package! some-package)
; Python
(package! elpy)
(package! blacken)
(package! ein)
; (package! ein)
(package! evil-replace-with-register)
(package! hindent)
(package! highlight-operators)
(package! highlight)
(package! yafolding)
;; To install a package directly from a particular repo, you'll need to specify
;; a `:recipe'. You'll find documentation on what `:recipe' accepts here: