Commit ffb5d333 authored by David Sveningsson's avatar David Sveningsson
Browse files

emacs: misc

parent 76adead8
......@@ -6,6 +6,7 @@
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
#+END_SRC
* Configuration
** Misc
#+BEGIN_SRC emacs-lisp
(setq inhibit-startup-message t)
(setq initial-scratch-message nil)
......@@ -57,7 +58,37 @@
; force transient mark
(transient-mark-mode 1)
#+END_SRC
;; disable bidirectional text
(setq bidi-display-reordering nil)
;; slower UI refresh interval
(setq idle-update-delay 2)
;; use native tooltips
(if (eq system-type 'gnu/linux)
(setq x-gtk-use-system-tooltips nil))
#+END_SRC
** Charset
Set UTF-8 as the default coding system
#+BEGIN_SRC emacs-lisp
(when (fboundp 'set-charset-priority)
(set-charset-priority 'unicode))
(prefer-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(setq locale-coding-system 'utf-8)
(setq-default buffer-file-coding-system 'utf-8)
#+END_SRC
** Backups
Disable creating file backups.
#+BEGIN_SRC emacs-lisp
(setq-default auto-save-default nil
create-lockfiles nil
make-backup-files nil)
#+END_SRC
* Bootstrap
#+BEGIN_SRC emacs-lisp
(package-initialize)
......@@ -69,11 +100,8 @@
swiper
;; old
company
evil-numbers
string-inflection
json-mode
yaml-mode))
))
;; install use-package if not present
(if (not (package-installed-p 'use-package))
......@@ -107,6 +135,8 @@
* Theme
** Doom
#+BEGIN_SRC emacs-lisp
(use-package all-the-icons
:ensure t)
(use-package doom-themes
:ensure t
:config
......@@ -265,6 +295,8 @@ Tabs and ribbons for the mode line.
** String inflection
Cycle camelCase, snake_case etc.
#+BEGIN_SRC emacs-lisp
(use-package string-inflection
:ensure t)
(global-set-key (kbd "C-c C-u") 'ext/string-inflection-all-cycle)
(defvar ext/string-inflection-map
(let ((map (make-sparse-keymap)))
......@@ -275,6 +307,46 @@ Tabs and ribbons for the mode line.
(string-inflection-all-cycle)
(set-transient-map ext/string-inflection-map t))
#+END_SRC
** Which key
#+BEGIN_SRC emacs-lisp
(use-package which-key
:ensure t
:config
(which-key-mode)
(which-key-setup-side-window-bottom))
#+END_SRC
** Prettify symbols
#+BEGIN_SRC emacs-lisp
(global-prettify-symbols-mode +1)
#+END_SRC
** Company
#+BEGIN_SRC emacs-lisp
(use-package company
:ensure t
:config
(setq company-idle-delay 0.1
company-tooltip-limit 10
company-dabbrev-downcase nil
company-dabbrev-ignore-case nil
company-dabbrev-code-other-buffers t
company-tooltip-align-annotations t
company-minimum-prefix-length 3
company-require-match 'never
company-frontends '(company-pseudo-tooltip-frontend company-echo-metadata-frontend)
company-backends '(company-dabbrev-code company-capf company-keywords company-files company-dabbrev)
company-transformers '(company-sort-by-occurrence)))
#+END_SRC
** Whitespace
#+BEGIN_SRC emacs-lisp
(setq-default
whitespace-line-column fill-column
whitespace-style
'(face indentation tabs tab-mark spaces space-mark newline newline-mark trailing lines-tail)
whitespace-display-mappings
'((tab-mark ?\t [?› ?\t])
(newline-mark ?\n [?¬ ?\n])
(space-mark ?\ [?·] [?.])))
#+END_SRC
* Development
** Editorconfig
#+BEGIN_SRC emacs-lisp
......@@ -293,6 +365,7 @@ Syntax checking. https://www.flycheck.org/en/latest/
(global-set-key (kbd "C-c !") 'ext/hydra-flycheck/body)
:config
(setq-default flycheck-disabled-checkers '(javascript-standard))
(setq-default flycheck-idle-change-delay 5)
(defhydra ext/hydra-flycheck
(:hint nil)
"
......@@ -345,6 +418,47 @@ _j_ump _l_ist ^^ _q_uit
:ensure t
:diminish)
#+END_SRC
** smerge
#+BEGIN_SRC emacs-lisp
(use-package smerge-mode
:commands smerge-mode
:init
(global-set-key (kbd "C-c v") 'ext/hydra-smerge/body)
:config
(defhydra ext/hydra-smerge
(:color pink :hint nil :post (smerge-auto-leave))
"
^Move^ ^Keep^ ^Diff^ ^Other^
^^-----------^^-------------------^^---------------------^^-------
_n_ext _b_ase _<_: upper/base _C_ombine
_p_rev _u_pper _=_: upper/lower _r_esolve
^^ _l_ower _>_: base/lower _k_ill current
^^ _a_ll _R_efine
^^ _RET_: current _E_diff
"
("n" smerge-next)
("p" smerge-prev)
("b" smerge-keep-base)
("u" smerge-keep-upper)
("l" smerge-keep-lower)
("a" smerge-keep-all)
("RET" smerge-keep-current)
("\C-m" smerge-keep-current)
("<" smerge-diff-base-upper)
("=" smerge-diff-upper-lower)
(">" smerge-diff-base-lower)
("R" smerge-refine)
("E" smerge-ediff)
("C" smerge-combine-with-next)
("r" smerge-resolve)
("k" smerge-kill-current)
("ZZ" (lambda ()
(interactive)
(save-buffer)
(bury-buffer))
"Save and bury buffer" :color blue)
("q" nil "cancel" :color blue)))
#+END_SRC
* Project management
** Projectile
#+BEGIN_SRC emacs-lisp
......@@ -376,10 +490,16 @@ _j_ump _l_ist ^^ _q_uit
(defun ext/setup-tide-mode ()
(message "Loading ext/setup-tide-mode...")
(tide-setup)
;; configure flycheck to properly work with typescript
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled idle-change))
(flycheck-add-next-checker 'typescript-tide '(t . javascript-eslint))
(flycheck-add-mode 'javascript-eslint 'typescript-mode)
;; force prettify alist from js for all tide-modes (such as typescript)
(setq-local prettify-symbols-alist js--prettify-symbols-alist)
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
(company-mode +1))
......@@ -387,7 +507,7 @@ _j_ump _l_ist ^^ _q_uit
(:hint nil :exit t)
"
^~tide~
_f_ix rename _s_ymbol _l_ist references _p_rettier _R_estart server
_f_ix rename _s_ymbol _l_ist references _p_rettier Restart _S_erver
_r_efactor _R_ename file _o_rganize imports _q_uit _V_erify setup
"
("f" tide-fix)
......@@ -397,7 +517,7 @@ _r_efactor _R_ename file _o_rganize imports _q_uit _V_erify se
("r" tide-refactor)
("o" tide-organize-imports)
("p" prettier-js)
("R" tide-restart-server)
("S" tide-restart-server)
("V" tide-verify-setup)
("q" nil))
:hook
......@@ -419,6 +539,16 @@ _r_efactor _R_ename file _o_rganize imports _q_uit _V_erify se
(setq-default js2-basic-offset 2)
(setq-default js2-mode-show-strict-warnings nil))
#+END_SRC
** JSON
#+BEGIN_SRC emacs-lisp
(use-package json-mode
:ensure t)
#+END_SRC
** YAML
#+BEGIN_SRC emacs-lisp
(use-package yaml-mode
:ensure t)
#+END_SRC
** Web
*** web-mode
#+BEGIN_SRC emacs-lisp
......@@ -438,15 +568,21 @@ _r_efactor _R_ename file _o_rganize imports _q_uit _V_erify se
:mode "\\.njk\\'"
:mode "\\.vue\\'"
:config
(setq tab-width 2)
(flyspell-prog-mode)
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(delete-trailing-whitespace))))
;; configure company-mode
(company-mode +1)
(add-hook 'web-mode-hook
(lambda ()
(setq-local company-minimum-prefix-length 1) ;; often very few suggestion, might as well start as early as possible
(setq-local company-backends '(company-web-html))))
(setq tab-width 2)
(setq web-mode-markup-indent-offset tab-width)
(setq web-mode-css-indent-offset tab-width)
(setq web-mode-code-indent-offset tab-width)
......@@ -481,47 +617,6 @@ _r_efactor _R_ename file _o_rganize imports _q_uit _V_erify se
(flyspell-mode 1))
(add-hook 'markdown-mode-hook 'markdown-hook)
#+END_SRC
* smerge
#+BEGIN_SRC emacs-lisp
(use-package smerge-mode
:commands smerge-mode
:init
(global-set-key (kbd "C-c v") 'ext/hydra-smerge/body)
:config
(defhydra ext/hydra-smerge
(:color pink :hint nil :post (smerge-auto-leave))
"
^Move^ ^Keep^ ^Diff^ ^Other^
^^-----------^^-------------------^^---------------------^^-------
_n_ext _b_ase _<_: upper/base _C_ombine
_p_rev _u_pper _=_: upper/lower _r_esolve
^^ _l_ower _>_: base/lower _k_ill current
^^ _a_ll _R_efine
^^ _RET_: current _E_diff
"
("n" smerge-next)
("p" smerge-prev)
("b" smerge-keep-base)
("u" smerge-keep-upper)
("l" smerge-keep-lower)
("a" smerge-keep-all)
("RET" smerge-keep-current)
("\C-m" smerge-keep-current)
("<" smerge-diff-base-upper)
("=" smerge-diff-upper-lower)
(">" smerge-diff-base-lower)
("R" smerge-refine)
("E" smerge-ediff)
("C" smerge-combine-with-next)
("r" smerge-resolve)
("k" smerge-kill-current)
("ZZ" (lambda ()
(interactive)
(save-buffer)
(bury-buffer))
"Save and bury buffer" :color blue)
("q" nil "cancel" :color blue)))
#+END_SRC
* Hydra
#+BEGIN_SRC emacs-lisp
(use-package hydra
......@@ -665,20 +760,7 @@ Default configuration.
#+END_SRC
* Testing
#+BEGIN_SRC emacs-lisp
(use-package all-the-icons
:ensure t)
(use-package rainbow-mode
:ensure t
:config
(rainbow-mode))
(use-package which-key
:ensure t
:config
(which-key-mode)
(which-key-setup-side-window-bottom))
; Speed up nextline
; https://emacs.stackexchange.com/questions/28736/emacs-pointcursor-movement-lag/28746
(setq auto-window-vscroll nil)
(global-prettify-symbols-mode +1)
#+END_SRC
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment