use poper emacs namespace, move keys to dedicated minor mode

This commit is contained in:
Maciej 2021-03-06 10:52:54 +02:00
parent 7f5f90ae4d
commit 76c7d665c7
Signed by: maciej
GPG key ID: 41D62D42D3B0D765
38 changed files with 337 additions and 221 deletions

View file

@ -14,5 +14,5 @@
:ensure t
:defer t)
(provide 'pkg/avy)
(provide 'icejam-pkg-avy)
;;; avy.el ends here

View file

@ -38,39 +38,6 @@
;;;;;;;;; Emacs bindings ;;;;;;;;;;;;;;;;;;;;;
(global-set-key (kbd "RET") 'newline)
(define-key global-map [home] 'beginning-of-line)
(define-key global-map [end] 'end-of-line)
;;; Helpful key bindings
(global-set-key (kbd "C-c \\") 'split-window-right) ;; Split window to the right
(global-set-key (kbd "C-c /") 'split-window-below) ;; Split window to the bottom
;; Move between windows key bindings
(global-set-key (kbd "C-c <left>") 'windmove-left)
(global-set-key (kbd "C-c <right>") 'windmove-right)
(global-set-key (kbd "C-c <up>") 'windmove-up)
(global-set-key (kbd "C-c <down>") 'windmove-down)
;; The same, but without using arrow keys
(global-set-key (kbd "C-c [") 'windmove-left)
(global-set-key (kbd "C-c ]") 'windmove-right)
(global-set-key (kbd "C-c {") 'windmove-up)
(global-set-key (kbd "C-c }") 'windmove-down)
;; Switch to previous and next buffer
(global-set-key (kbd "C-c s <left>") 'previous-buffer)
(global-set-key (kbd "C-c s <right>") 'next-buffer)
;; The same, but without arrow keys.
(global-set-key (kbd "C-c s [") 'previous-buffer)
(global-set-key (kbd "C-c s ]") 'next-buffer)
;; Kill current buffer and window
(global-set-key (kbd "C-c q") 'kill-buffer-and-window)
;; List buffers
(global-set-key (kbd "C-c b") 'ibuffer)
;; Move buffers around with buffer keys
(use-package buffer-move
@ -81,19 +48,6 @@
("C-c m {" . buf-move-up)
("C-c m }" . buf-move-down))
;; Revert without asking
(defun revert-buffer-no-confirm ()
"Revert buffer without confirmation."
(interactive) (revert-buffer t t))
(global-set-key (kbd "C-c r") 'revert-buffer-no-confirm)
;; Create new terminal
(global-set-key (kbd "<f12>") (lambda ()
(interactive)
(ansi-term "/bin/zsh" "ANSI-Term : Zsh")))
;; #====================== Backup config #==============================
(setq backup-directory-alist
`((".*" . "~/.emacs_backups/auto-save-list")))
@ -166,5 +120,5 @@
(which-key-mode t)
(provide 'pkg/base)
(provide 'icejam-pkg-base)
;;; base.el ends here

View file

@ -9,7 +9,11 @@
(use-package yasnippet-snippets
:ensure t
:defer t)
:defer t
:config
(unbind-key "C-c & C-n" yas-minor-mode-map)
(unbind-key "C-c & C-s" yas-minor-mode-map)
(unbind-key "C-c & C-v" yas-minor-mode-map))
(use-package company
:commands (company-indent-or-complete-common company-yasnippet)
@ -71,5 +75,5 @@
(define-key text-mode-map (kbd "<f13>") 'insert-space-and-complete)
(define-key text-mode-map (kbd "TAB") 'company-indent-or-complete-common)
(provide 'pkg/company-yasnippet)
(provide 'icejam-pkg-company-yasnippet)
;;; company-yasnippet.el ends here

View file

@ -54,5 +54,5 @@
(add-to-list (make-local-variable 'ctags/major-modes-to-update-on-save) mode))
(add-hook 'after-save-hook 'ctags/update-tags-on-save)
(provide 'pkg/ctags)
(provide 'icejam-pkg-ctags)
;;; ctags.el ends here

View file

@ -23,5 +23,5 @@
;; (registers . 5)
(projects . 5)))
(provide 'pkg/dashboard)
(provide 'icejam-pkg-dashboard)
;;; dashboard.el ends here

View file

@ -3,6 +3,8 @@
;;; Notational velocity, backed by OneDrive.
;;; Code:
(require 'icejam-pkg-keys-mode "$HOME/.emacs.d/pkg/keys-mode.el")
(use-package deft
:ensure t
:defer t
@ -11,7 +13,7 @@
deft-default-extension "md"
deft-auto-save-interval 30.0))
(global-set-key (kbd "C-c d d") 'deft)
(define-key icejam-keys-mode-map (kbd "C-c d d") 'deft)
(provide 'pkg/deft)
(provide 'icejam-pkg-deft)
;;; deft.el ends here

View file

@ -7,7 +7,23 @@
:commands flycheck-define-checker
:ensure t
:defer t
:config (global-flycheck-mode t))
:config (global-flycheck-mode t)
(unbind-key "C-c ! C-c" flycheck-mode-map)
(unbind-key "C-c ! C-w" flycheck-mode-map)
(unbind-key "C-c ! ?" flycheck-mode-map)
(unbind-key "C-c ! C" flycheck-mode-map)
(unbind-key "C-c ! H" flycheck-mode-map)
(unbind-key "C-c ! V" flycheck-mode-map)
(unbind-key "C-c ! c" flycheck-mode-map)
(unbind-key "C-c ! e" flycheck-mode-map)
(unbind-key "C-c ! h" flycheck-mode-map)
(unbind-key "C-c ! i" flycheck-mode-map)
(unbind-key "C-c ! l" flycheck-mode-map)
(unbind-key "C-c ! n" flycheck-mode-map)
(unbind-key "C-c ! p" flycheck-mode-map)
(unbind-key "C-c ! s" flycheck-mode-map)
(unbind-key "C-c ! v" flycheck-mode-map)
(unbind-key "C-c ! x" flycheck-mode-map))
(provide 'pkg/flycheck)
(provide 'icejam-pkg-flycheck)
;;; flycheck.el ends here

View file

@ -10,29 +10,29 @@
"
General Actions
^Ivy^ ^Perspectives^ ^Projectile^ ^Magit^
^Ivy^ ^Perspectives^ ^Projectile^ ^Magit^
^^^^^^^^-------------------------------------------------------------------------------------
_a_: Grep in buffer _S_: Switch perspective _s_: Switch project _m_: Git status
_b_: Buffer list _B_: Switch buffer _f_: Find file in project _C_: Git checkout
_t_: Find file _K_: Kill perspective _g_: Grep in current project _M_: Git blame
_d_: Deft _c_: Invalidate cache
_w_: Avy goto word _n_: New project
_l_: Avy goto line _i_: IELM console
_a_: Grep in buffer _p_: Switch perspective _s_: Switch project _m_: Git status
_B_: Buffer list _b_: buffers in perspective _f_: Find file in project _C_: Git checkout
_t_: Find file _K_: Kill perspective _g_: Grep in current project _M_: Git blame
_d_: Deft _c_: Invalidate cache
_w_: Avy goto word _n_: New project
_l_: Avy goto line _i_: IELM console
_:_: Avy goto char
"
("q" nil "cancel" :color blue)
("a" counsel-rg)
("b" ibuffer)
("B" ibuffer)
("t" counsel-find-file)
("d" deft)
("w" avy-goto-word-0)
("l" avy-goto-line)
(":" avy-goto-char)
("S" persp-switch)
("B" persp-ibuffer)
("p" persp-switch)
("b" persp-ibuffer)
("K" persp-kill)
("s" counsel-projectile-switch-project)
@ -55,7 +55,7 @@ _:_: Avy goto char
_c_: Comment line _y_: Yasnippet
_r_: Regex replace _m_: Company
_i_: Indent region _u_: Undo tree
_a_: Align regexp
_a_: Align to regex
_e_: Eval region
_s_: Swiper
"
@ -121,5 +121,5 @@ _i_: Indent buffer _m_: iMenu
("C-c w" . hydra-window-menu/body)
("C-c l" . hydra-language-context-menu/body))
(provide 'pkg/hydra)
(provide 'icejam-pkg-hydra)
;;; hydra.el ends here

View file

@ -6,9 +6,16 @@
(use-package ispell
:ensure t
:config (setq ispell-program-name "aspell")
(setq ispell-extra-args
'("--run-together" "--run-together-limit=5" "--run-together-min=2"))
:hook ((prog-mode text-mode) . flyspell-mode))
(setq ispell-extra-args
'("--run-together" "--run-together-limit=5" "--run-together-min=2"))
:hook ((prog-mode text-mode) . flyspell-mode))
(provide 'pkg/ispell)
(add-hook 'flyspell-mode-hook (lambda ()
(unbind-key "C-," flyspell-mode-map)
(unbind-key "C-." flyspell-mode-map)
(unbind-key "C-;" flyspell-mode-map)
(unbind-key "C-c $" flyspell-mode-map)
(unbind-key "C-M-i" flyspell-mode-map)))
(provide 'icejam-pkg-ispell)
;;; ispell.el ends here

View file

@ -3,6 +3,8 @@
;;; Counsel, Swiper and Ivy.
;;; Code:
(require 'icejam-pkg-keys-mode "$HOME/.emacs.d/pkg/keys-mode.el")
(use-package counsel :ensure t :defer t)
(use-package swiper :ensure t :defer t)
(use-package helpful :ensure t :defer t)
@ -21,18 +23,17 @@
(setq counsel-describe-function-function #'helpful-callable)
(setq counsel-describe-variable-function #'helpful-variable)
(global-set-key (kbd "C-c a") 'counsel-rg)
(global-set-key (kbd "C-c t") 'counsel-find-file)
(global-set-key (kbd "C-c C-s") 'swiper) ;; Find things by regexp
(global-set-key (kbd "M-x") 'counsel-M-x) ;; M-x on steroids
(define-key icejam-keys-mode-map (kbd "C-c a") 'counsel-rg)
(define-key icejam-keys-mode-map (kbd "C-c t") 'counsel-find-file)
(define-key icejam-keys-mode-map (kbd "C-c C-s") 'swiper) ;; Find things by regexp
(define-key icejam-keys-mode-map (kbd "M-x") 'counsel-M-x) ;; M-x on steroids
;; List all key bindings there are.
;; (global-set-key (kbd "<f1> b") 'describe-bindings)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(define-key icejam-keys-mode-map (kbd "<f1> f") 'counsel-describe-function)
(define-key icejam-keys-mode-map (kbd "<f1> v") 'counsel-describe-variable)
(define-key icejam-keys-mode-map (kbd "<f1> l") 'counsel-find-library)
(define-key icejam-keys-mode-map (kbd "<f2> i") 'counsel-info-lookup-symbol)
(define-key icejam-keys-mode-map (kbd "<f2> u") 'counsel-unicode-char)
(provide 'pkg/ivy)
(provide 'icejam-pkg-ivy)
;;; ivy.el ends here

70
pkg/keys-mode.el Normal file
View file

@ -0,0 +1,70 @@
;;; keys-mode.el --- summary
;; Author: Maciej Szlosarczyk
;; Maintainer: Maciej Szlosarczyk
;; Version: 0.1-snapshot
;;; Commentary:
;; My global mode, to house my custom keys.
;;; Code:
(define-minor-mode icejam-keys-mode
"Minor mode for all of my personal key bindings"
:global t
:keymap (make-sparse-keymap))
;; Globally enable my minor mode
(icejam-keys-mode)
;;; Helpful key bindings
(define-key icejam-keys-mode-map (kbd "C-c \\") 'split-window-right) ;; Split window to the right
(define-key icejam-keys-mode-map (kbd "C-c /") 'split-window-below) ;; Split window to the bottom
;; Move between windows key bindings
(define-key icejam-keys-mode-map (kbd "C-c <left>") 'windmove-left)
(define-key icejam-keys-mode-map (kbd "C-c <right>") 'windmove-right)
(define-key icejam-keys-mode-map (kbd "C-c <up>") 'windmove-up)
(define-key icejam-keys-mode-map (kbd "C-c <down>") 'windmove-down)
;; The same, but without using arrow keys
(define-key icejam-keys-mode-map (kbd "C-c [") 'windmove-left)
(define-key icejam-keys-mode-map (kbd "C-c ]") 'windmove-right)
(define-key icejam-keys-mode-map (kbd "C-c {") 'windmove-up)
(define-key icejam-keys-mode-map (kbd "C-c }") 'windmove-down)
;; Switch to previous and next buffer
(define-key icejam-keys-mode-map (kbd "C-c s <left>") 'previous-buffer)
(define-key icejam-keys-mode-map (kbd "C-c s <right>") 'next-buffer)
;; The same, but without arrow keys.
(define-key icejam-keys-mode-map (kbd "C-c s [") 'previous-buffer)
(define-key icejam-keys-mode-map (kbd "C-c s ]") 'next-buffer)
;; Kill current buffer and window
(define-key icejam-keys-mode-map (kbd "C-c q") 'kill-buffer-and-window)
;; List buffers
(define-key icejam-keys-mode-map (kbd "C-c b") 'ibuffer)
;; Create new terminal
(defun start-zsh-term ()
"Start ZSH terminal session."
(ansi-term "/bin/zsh" "Zsh"))
(define-key icejam-keys-mode-map (kbd "<f12>") 'start-zsh-term)
;; Revert without asking
(defun revert-buffer-no-confirm ()
"Revert buffer without confirmation."
(interactive) (revert-buffer t t))
(define-key icejam-keys-mode-map (kbd "C-c r") 'revert-buffer-no-confirm)
;;;;;;;;; Emacs bindings ;;;;;;;;;;;;;;;;;;;;;
(define-key icejam-keys-mode-map [home] 'beginning-of-line)
(define-key icejam-keys-mode-map [end] 'end-of-line)
(provide 'icejam-pkg-keys-mode)
;;; keys-mode.el ends here

View file

@ -7,17 +7,51 @@
:ensure t
:defer t
:requires (company)
:config (setq-default lsp-file-watch-threshold 10000
lsp-restart 'auto-restart
lsp-prefer-capf t
lsp-completion-provider :capf
lsp-server-trace nil
read-process-output-max (* 1024 1024 2)
lsp-enable-file-watchers nil)
:hook ((typescript-mode . lsp-deferred)
(elixir-mode . lsp)
(purescript-mode . lsp-deferred)
(js2-mode . lsp-deferred)))
:config
(setq-default lsp-file-watch-threshold 10000
lsp-restart 'auto-restart
lsp-prefer-capf t
lsp-completion-provider :capf
lsp-server-trace nil
read-process-output-max (* 1024 1024 2)
lsp-enable-file-watchers nil)
(unbind-key "s-l =" lsp-mode-map)
(unbind-key "s-l G" lsp-mode-map)
(unbind-key "s-l T" lsp-mode-map)
(unbind-key "s-l a" lsp-mode-map)
(unbind-key "s-l g" lsp-mode-map)
(unbind-key "s-l r" lsp-mode-map)
(unbind-key "C-S-SPC" lsp-mode-map)
(unbind-key "s-l G g" lsp-mode-map)
(unbind-key "s-l G r" lsp-mode-map)
(unbind-key "s-l G s" lsp-mode-map)
(unbind-key "s-l h g" lsp-mode-map)
(unbind-key "s-l h h" lsp-mode-map)
(unbind-key "s-l h s" lsp-mode-map)
(unbind-key "s-l g a" lsp-mode-map)
(unbind-key "s-l g e" lsp-mode-map)
(unbind-key "s-l g g" lsp-mode-map)
(unbind-key "s-l g h" lsp-mode-map)
(unbind-key "s-l g r" lsp-mode-map)
(unbind-key "s-l T D" lsp-mode-map)
(unbind-key "s-l T L" lsp-mode-map)
(unbind-key "s-l T S" lsp-mode-map)
(unbind-key "s-l T T" lsp-mode-map)
(unbind-key "s-l T b" lsp-mode-map)
(unbind-key "s-l T d" lsp-mode-map)
(unbind-key "s-l T f" lsp-mode-map)
(unbind-key "s-l T l" lsp-mode-map)
(unbind-key "s-l T s" lsp-mode-map)
(unbind-key "s-l F a" lsp-mode-map)
(unbind-key "s-l F b" lsp-mode-map)
(unbind-key "s-l F r" lsp-mode-map)
(unbind-key "s-l = =" lsp-mode-map)
(unbind-key "s-l s D" lsp-mode-map)
(unbind-key "s-l s d" lsp-mode-map)
(unbind-key "s-l s q" lsp-mode-map)
(unbind-key "s-l s r" lsp-mode-map)
(unbind-key "s-l s s" lsp-mode-map)
:hook ((typescript-mode . lsp-deferred)))
(use-package lsp-ui
:ensure t
@ -37,5 +71,5 @@
:defer t
:requires (lsp-mode lsp-ui))
(provide 'pkg/lsp)
(provide 'icejam-pkg-lsp)
;;; lsp.el ends here

View file

@ -9,5 +9,5 @@
(setq result (append (list (car form) result)
(cdr form))))))
(provide 'pkg/macros)
(provide 'icejam-pkg-macros)
;;; macros ends here

View file

@ -11,5 +11,5 @@
(:map magit-blame-mode-map
("<f5> b" . 'magit-blame-quit)))
(provide 'pkg/magit)
(provide 'icejam-pkg-magit)
;;; magit.el ends here

View file

@ -9,7 +9,24 @@
;; Perspectives
;;; Code:
(use-package perspective :config (persp-mode))
(use-package perspective
:config (persp-mode)
(unbind-key "C-x x" persp-mode-map)
(unbind-key "C-x x C-l" persp-mode-map)
(unbind-key "C-x x C-s" persp-mode-map)
(unbind-key "C-x x A" persp-mode-map)
(unbind-key "C-x x a" persp-mode-map)
(unbind-key "C-x x b" persp-mode-map)
(unbind-key "C-x x c" persp-mode-map)
(unbind-key "C-x x i" persp-mode-map)
(unbind-key "C-x x k" persp-mode-map)
(unbind-key "C-x x n" persp-mode-map)
(unbind-key "C-x x p" persp-mode-map)
(unbind-key "C-x x r" persp-mode-map)
(unbind-key "C-x x s" persp-mode-map)
(unbind-key "C-x x <left>" persp-mode-map)
(unbind-key "C-x x <right>" persp-mode-map)
(unbind-key "C-x x C-x x" persp-mode-map))
(provide 'pkg/persp)
;;; pkg/persp.el ends here
(provide 'icejam-pkg-persp)
;;; persp.el ends here

View file

@ -79,5 +79,5 @@
:ensure t
:defer t)
(provide 'pkg/prog-mode)
(provide 'icejam-pkg-prog-mode)
;;; prog-mode ends here

View file

@ -20,5 +20,5 @@
(projectile-mode t)
(provide 'pkg/projectile)
(provide 'icejam-pkg-projectile)
;;; projectile.el ends here

View file

@ -6,6 +6,8 @@
(defconst IS-MAC (eq system-type 'darwin))
(defconst IS-BSD (eq system-type 'berkeley-unix))
(require 'icejam-pkg-keys-mode "$HOME/.emacs.d/pkg/keys-mode.el")
;;;;;;;;; Mac-specific config ;;;;;;;;;;;;;;;;;;;;;
(if IS-MAC
(progn
@ -24,21 +26,24 @@
(setq mac-command-modifier 'meta))))
;;;;;;;;; Mac binding (fix) ;;;;;;;;;;;;;;;;;;
(global-set-key (kbd "H-<right>") 'end-of-line)
(global-set-key (kbd "H-<left>") 'beginning-of-line)
(global-set-key (kbd "H-<up>") 'scroll-down) ; WTF is this reverse, I dunno
(global-set-key (kbd "H-<down>") 'scroll-up)
(define-key icejam-keys-mode-map (kbd "H-<right>") 'end-of-line)
(define-key icejam-keys-mode-map (kbd "H-<left>") 'beginning-of-line)
(define-key icejam-keys-mode-map (kbd "H-<up>") 'scroll-down) ; WTF is this reverse, I dunno
(define-key icejam-keys-mode-map (kbd "H-<down>") 'scroll-up)
(global-set-key [(hyper a)] 'mark-whole-buffer)
(global-set-key [(hyper v)] 'yank)
(global-set-key [(hyper x)] 'kill-region)
(global-set-key [(hyper c)] 'kill-ring-save)
(global-set-key [(hyper s)] 'save-buffer)
(global-set-key [(hyper l)] 'goto-line)
(global-set-key [(hyper w)]
(lambda () (interactive) (delete-window)))
(global-set-key [(hyper z)] 'undo)
(global-set-key [(hyper q)] 'kill-emacs)
(defun delete-window-mac ()
"Kill a window on mac"
(interactive) (delete-window))
(define-key icejam-keys-mode-map [(hyper a)] 'mark-whole-buffer)
(define-key icejam-keys-mode-map [(hyper v)] 'yank)
(define-key icejam-keys-mode-map [(hyper x)] 'kill-region)
(define-key icejam-keys-mode-map [(hyper c)] 'kill-ring-save)
(define-key icejam-keys-mode-map [(hyper s)] 'save-buffer)
(define-key icejam-keys-mode-map [(hyper l)] 'goto-line)
(define-key icejam-keys-mode-map [(hyper w)] 'delete-window-mac)
(define-key icejam-keys-mode-map [(hyper z)] 'undo)
(define-key icejam-keys-mode-map [(hyper q)] 'kill-emacs)
;; Disable meta on right alt (useful for Polish characters)
(setq mac-right-option-modifier nil)))
@ -46,21 +51,21 @@
;;;;;;;;; BSD-specific config ;;;;;;;;;;;;;;;;;;;;;
(if IS-BSD
(progn
(global-set-key (kbd "A-<right>") 'end-of-line)
(global-set-key (kbd "A-<left>") 'beginning-of-line)
(global-set-key (kbd "A-<up>") 'scroll-down) ; WTF is this reverse, I dunno
(global-set-key (kbd "A-<down>") 'scroll-up)
(define-key icejam-keys-mode-map (kbd "A-<right>") 'end-of-line)
(define-key icejam-keys-mode-map (kbd "A-<left>") 'beginning-of-line)
(define-key icejam-keys-mode-map (kbd "A-<up>") 'scroll-down) ; WTF is this reverse, I dunno
(define-key icejam-keys-mode-map (kbd "A-<down>") 'scroll-up)
(global-set-key (kbd "A-a") 'mark-whole-buffer)
(global-set-key (kbd "A-v") 'yank)
(global-set-key (kbd "A-x") 'kill-region)
(global-set-key (kbd "A-c") 'kill-ring-save)
(global-set-key (kbd "A-s") 'save-buffer)
(global-set-key (kbd "A-l") 'goto-line)
(global-set-key (kbd "A-w")
(define-key icejam-keys-mode-map (kbd "A-a") 'mark-whole-buffer)
(define-key icejam-keys-mode-map (kbd "A-v") 'yank)
(define-key icejam-keys-mode-map (kbd "A-x") 'kill-region)
(define-key icejam-keys-mode-map (kbd "A-c") 'kill-ring-save)
(define-key icejam-keys-mode-map (kbd "A-s") 'save-buffer)
(define-key icejam-keys-mode-map (kbd "A-l") 'goto-line)
(define-key icejam-keys-mode-map (kbd "A-w")
(lambda () (interactive) (delete-window)))
(global-set-key (kbd "A-z") 'undo)
(global-set-key (kbd "A-q") 'kill-emacs)))
(define-key icejam-keys-mode-map (kbd "A-z") 'undo)
(define-key icejam-keys-mode-map (kbd "A-q") 'kill-emacs)))
(provide 'pkg/sys-specific)
(provide 'icejam-pkg-sys-specific)
;;; sys-specific.el ends here

View file

@ -22,5 +22,5 @@
(global-undo-tree-mode t)
(provide 'pkg/undo-tree)
(provide 'icejam-pkg-undo-tree)
;;; undo-tree.el ends here