emacs: emacs style ergonomic buffer keybindings, more clean up
This commit is contained in:
parent
d4879ef719
commit
b6aec65c87
@ -215,14 +215,12 @@ Finish up
|
||||
vundo
|
||||
which-key
|
||||
mono-complete
|
||||
;; harpoon
|
||||
harpoon
|
||||
format-all
|
||||
yasnippet
|
||||
consult-yasnippet
|
||||
;; company
|
||||
;; lsp-mode
|
||||
;; lsp-ui
|
||||
;; flycheck
|
||||
lsp-mode
|
||||
flycheck
|
||||
;; Org
|
||||
org-bullets
|
||||
org-fancy-priorities
|
||||
@ -1022,9 +1020,10 @@ Fill region is great, except when you don't need it...
|
||||
(require 'all-the-icons-ibuffer)
|
||||
(add-hook 'ibuffer-mode-hook #'all-the-icons-ibuffer-mode)
|
||||
(global-set-key [remap list-buffers] 'ibuffer)
|
||||
(global-set-key (kbd "C-x B") 'ibuffer)
|
||||
(global-set-key (kbd "C-x b") 'consult-project-buffer)
|
||||
(global-set-key (kbd "C-x C-b") 'consult-buffer)
|
||||
(evil-define-key '(normal insert visual emacs) 'global
|
||||
(kbd "C-b") #'consult-buffer)
|
||||
(evil-define-key '(normal insert visual emacs) 'global
|
||||
(kbd "C-S-b") #'ibuffer)
|
||||
|
||||
(defun joe/switch-other-buffer ()
|
||||
"Switch to other buffer"
|
||||
@ -1069,17 +1068,8 @@ Harpoon lets you quickly switch between bookmarked buffers
|
||||
(global-set-key (kbd "M-7") 'harpoon-go-to-7)
|
||||
(global-set-key (kbd "M-8") 'harpoon-go-to-8)
|
||||
|
||||
(global-set-key (kbd "C-c h 1") 'harpoon-go-to-1)
|
||||
(global-set-key (kbd "C-c h 2") 'harpoon-go-to-2)
|
||||
(global-set-key (kbd "C-c h 3") 'harpoon-go-to-3)
|
||||
(global-set-key (kbd "C-c h 4") 'harpoon-go-to-4)
|
||||
(global-set-key (kbd "C-c h 5") 'harpoon-go-to-5)
|
||||
(global-set-key (kbd "C-c h 6") 'harpoon-go-to-6)
|
||||
(global-set-key (kbd "C-c h 7") 'harpoon-go-to-7)
|
||||
(global-set-key (kbd "C-c h 8") 'harpoon-go-to-8)
|
||||
(global-set-key (kbd "C-c h 9") 'harpoon-go-to-9)
|
||||
#+end_src
|
||||
** Windows
|
||||
|
||||
*** Window Management
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
@ -1142,6 +1132,13 @@ Harpoon lets you quickly switch between bookmarked buffers
|
||||
|
||||
(global-set-key (kbd "s-<f10>") #'joe/resize-frames)
|
||||
#+end_src
|
||||
|
||||
In case we delete a frame by accident;
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(undelete-frame-mode)
|
||||
#+end_src
|
||||
|
||||
**** COMMENT Unused for now
|
||||
Ace Window will show a hint if there are more than 2 windows, but I don't really use it
|
||||
|
||||
@ -1180,192 +1177,6 @@ Ace Window will show a hint if there are more than 2 windows, but I don't really
|
||||
(window-parameters
|
||||
(no-delete-other-windows . t)))))
|
||||
|
||||
#+end_src
|
||||
*** COMMENT Tab-bar & Tab-line
|
||||
#+begin_src emacs-lisp
|
||||
(global-set-key (kbd "s-n") #'tab-line-switch-to-next-tab)
|
||||
(global-set-key (kbd "s-p") #'tab-line-switch-to-prev-tab)
|
||||
|
||||
#+end_src
|
||||
*** COMMENT Scrolling
|
||||
#+begin_src emacs-lisp
|
||||
(require 'pixel-scroll)
|
||||
(setq pixel-scroll-precision-large-scroll-height 10.0)
|
||||
(setq pixel-scroll-precision-interpolation-factor 30)
|
||||
|
||||
|
||||
(defun joe/pixel-scroll-lerp (amount direction)
|
||||
(let ((half-height (* direction (/ (window-height) amount)))
|
||||
(point-min-or-max (if (> direction 0) (point-min) (point-max))))
|
||||
(when (or (and (pos-visible-in-window-p (point-min))
|
||||
(< direction 0)))
|
||||
(pixel-scroll-precision-interpolate (* 5 half-height)))
|
||||
(pixel-scroll-precision-interpolate (* 5 half-height))))
|
||||
|
||||
(defun joe/smooth-scroll-half-page-down ()
|
||||
"Smooth scroll down"
|
||||
(interactive)
|
||||
(joe/pixel-scroll-lerp 1.5 -1))
|
||||
;; (pixel-scroll-kbd-up))
|
||||
|
||||
(defun joe/smooth-scroll-half-page-up ()
|
||||
"Smooth scroll up"
|
||||
(interactive)
|
||||
(joe/pixel-scroll-lerp 1.5 1))
|
||||
|
||||
(defun joe/smooth-scroll-short-down ()
|
||||
"Smooth scroll down"
|
||||
(interactive)
|
||||
(joe/pixel-scroll-lerp 8 -1))
|
||||
|
||||
(defun joe/smooth-scroll-short-up ()
|
||||
"Smooth scroll down"
|
||||
(interactive)
|
||||
(joe/pixel-scroll-lerp 8 1))
|
||||
|
||||
;; scroll-up-command
|
||||
(global-set-key (kbd "C-v") #'joe/smooth-scroll-half-page-down)
|
||||
(global-set-key (kbd "M-v") #'joe/smooth-scroll-half-page-up)
|
||||
(global-set-key (kbd "C-S-v") #'joe/smooth-scroll-short-down)
|
||||
(global-set-key (kbd "M-S-v") #'joe/smooth-scroll-short-up)
|
||||
|
||||
(defun joe/scroll-other-half-down ()
|
||||
(interactive)
|
||||
(scroll-other-window 8))
|
||||
(defun joe/scroll-other-half-up ()
|
||||
(interactive)
|
||||
(scroll-other-window -8))
|
||||
|
||||
(global-set-key (kbd "C-M-v") #'joe/scroll-other-half-down)
|
||||
(global-set-key (kbd "C-M-S-V") #'joe/scroll-other-half-up)
|
||||
|
||||
(require 'topspace)
|
||||
|
||||
#+end_src
|
||||
** Tabs/Workspaces
|
||||
*** COMMENT Centaur Tabs
|
||||
#+begin_src emacs-lisp
|
||||
;; (require 'centaur-tabs)
|
||||
(setq centaur-tabs-set-bar 'under)
|
||||
(setq x-underline-at-descent-line t)
|
||||
(setq centaur-tabs-set-close-button nil)
|
||||
(setq centaur-tabs-set-icons t)
|
||||
(setq centaur-tabs-show-navigation-buttons nil)
|
||||
(setq centaur-tabs-set-close-button nil)
|
||||
(setq centaur-tabs-set-modified-marker nil)
|
||||
(setq centaur-tabs-show-new-tab-button nil)
|
||||
(setq centaur-tabs-label-fixed-length 16)
|
||||
|
||||
(defun joe/forward-tab-or-popup ()
|
||||
(interactive)
|
||||
(if (popper-popup-p (current-buffer))
|
||||
(popper-cycle)
|
||||
(centaur-tabs-forward-tab)))
|
||||
(defun joe/backward-tab-or-popup ()
|
||||
(interactive)
|
||||
(if (popper-popup-p (current-buffer))
|
||||
(popper-cycle)
|
||||
(centaur-tabs-backward-tab)))
|
||||
|
||||
;; (global-set-key (kbd "s-n") #'centaur-tabs-forward-tab)
|
||||
;; (global-set-key (kbd "s-p") #'centaur-tabs-backward-tab)
|
||||
|
||||
(global-set-key (kbd "s-n") #'joe/forward-tab-or-popup)
|
||||
(global-set-key (kbd "s-p") #'joe/backward-tab-or-popup)
|
||||
|
||||
(global-set-key (kbd "s-N") #'centaur-tabs-forward-group)
|
||||
(global-set-key (kbd "s-P") #'centaur-tabs-backward-group)
|
||||
(global-set-key (kbd "C-s-p") #'centaur-tabs-move-current-tab-to-left)
|
||||
(global-set-key (kbd "C-s-n") #'centaur-tabs-move-current-tab-to-right)
|
||||
|
||||
(dolist (mode '(dashboard-mode-hook))
|
||||
(add-hook mode 'centaur-tabs-local-mode))
|
||||
|
||||
(with-eval-after-load 'centaur-tabs
|
||||
(defun joe/fix-centaur-tabs (THEME)
|
||||
(centaur-tabs-mode -1)
|
||||
(centaur-tabs-mode))
|
||||
|
||||
(advice-add 'consult-theme :after #'joe/fix-centaur-tabs)
|
||||
(defun centaur-tabs-buffer-groups ()
|
||||
"`centaur-tabs-buffer-groups' control buffers' group rules.
|
||||
|
||||
Group centaur-tabs with mode if buffer is derived from `eshell-mode' `emacs-lisp-mode' `dired-mode' `org-mode' `magit-mode'.
|
||||
All buffer name start with * will group to \"Emacs\".
|
||||
Other buffer group by `centaur-tabs-get-group-name' with project name."
|
||||
(list
|
||||
(cond
|
||||
((or (derived-mode-p 'comint-mode)
|
||||
(derived-mode-p 'sql-interactive-mode)
|
||||
(string-match "*HTTP" (buffer-name))
|
||||
(derived-mode-p 'compilation-mode))
|
||||
"REPLs")
|
||||
((or (and (string-equal "*" (substring (buffer-name) 0 1))
|
||||
(not (string-match "*Org Src" (buffer-name))))
|
||||
(memq major-mode '(magit-process-mode
|
||||
magit-status-mode
|
||||
magit-diff-mode
|
||||
magit-log-mode
|
||||
magit-file-mode
|
||||
magit-blob-mode
|
||||
magit-blame-mode)))
|
||||
"*Buffers*")
|
||||
(t
|
||||
"Emacs")))))
|
||||
|
||||
(centaur-tabs-mode +1)
|
||||
#+end_src
|
||||
*** COMMENT Tabs
|
||||
#+begin_src emacs-lisp
|
||||
;; (setq tab-bar-mode t)
|
||||
;; (setq tab-bar-show nil)
|
||||
|
||||
;; (global-set-key (kbd "M-1") '(lambda () (interactive) (tab-bar-select-tab 1)))
|
||||
;; (global-set-key (kbd "M-2") '(lambda () (interactive) (tab-bar-select-tab 2)))
|
||||
;; (global-set-key (kbd "M-3") '(lambda () (interactive) (tab-bar-select-tab 3)))
|
||||
;; (global-set-key (kbd "M-4") '(lambda () (interactive) (tab-bar-select-tab 4)))
|
||||
;; (global-set-key (kbd "M-5") '(lambda () (interactive) (tab-bar-select-tab 5)))
|
||||
;; (global-set-key (kbd "M-6") '(lambda () (interactive) (tab-bar-select-tab 6)))
|
||||
;; (global-set-key (kbd "M-7") '(lambda () (interactive) (tab-bar-select-tab 7)))
|
||||
;; (global-set-key (kbd "M-8") '(lambda () (interactive) (tab-bar-select-tab 8)))
|
||||
;; (global-set-key (kbd "M-9") '(lambda () (interactive) (tab-bar-select-tab 9)))
|
||||
|
||||
;; (evil-global-set-key 'insert (kbd "M-1") '(lambda () (interactive) (tab-bar-select-tab 1)))
|
||||
;; (evil-global-set-key 'insert (kbd "M-2") '(lambda () (interactive) (tab-bar-select-tab 2)))
|
||||
;; (evil-global-set-key 'insert (kbd "M-3") '(lambda () (interactive) (tab-bar-select-tab 3)))
|
||||
;; (evil-global-set-key 'insert (kbd "M-4") '(lambda () (interactive) (tab-bar-select-tab 4)))
|
||||
;; (evil-global-set-key 'insert (kbd "M-5") '(lambda () (interactive) (tab-bar-select-tab 5)))
|
||||
;; (evil-global-set-key 'insert (kbd "M-6") '(lambda () (interactive) (tab-bar-select-tab 6)))
|
||||
;; (evil-global-set-key 'insert (kbd "M-7") '(lambda () (interactive) (tab-bar-select-tab 7)))
|
||||
;; (evil-global-set-key 'insert (kbd "M-8") '(lambda () (interactive) (tab-bar-select-tab 8)))
|
||||
;; (evil-global-set-key 'insert (kbd "M-9") '(lambda () (interactive) (tab-bar-select-tab 9)))
|
||||
|
||||
;; (evil-global-set-key 'normal (kbd "M-1") '(lambda () (interactive) (tab-bar-select-tab 1)))
|
||||
;; (evil-global-set-key 'normal (kbd "M-2") '(lambda () (interactive) (tab-bar-select-tab 2)))
|
||||
;; (evil-global-set-key 'normal (kbd "M-3") '(lambda () (interactive) (tab-bar-select-tab 3)))
|
||||
;; (evil-global-set-key 'normal (kbd "M-4") '(lambda () (interactive) (tab-bar-select-tab 4)))
|
||||
;; (evil-global-set-key 'normal (kbd "M-5") '(lambda () (interactive) (tab-bar-select-tab 5)))
|
||||
;; (evil-global-set-key 'normal (kbd "M-6") '(lambda () (interactive) (tab-bar-select-tab 6)))
|
||||
;; (evil-global-set-key 'normal (kbd "M-7") '(lambda () (interactive) (tab-bar-select-tab 7)))
|
||||
;; (evil-global-set-key 'normal (kbd "M-8") '(lambda () (interactive) (tab-bar-select-tab 8)))
|
||||
;; (evil-global-set-key 'normal (kbd "M-9") '(lambda () (interactive) (tab-bar-select-tab 9)))
|
||||
|
||||
#+end_src
|
||||
*** Frames
|
||||
#+begin_src emacs-lisp
|
||||
(undelete-frame-mode)
|
||||
(defun joe/select-frame ()
|
||||
(interactive)
|
||||
(let* ((frames (mapcar
|
||||
(lambda (f) (cons (substring-no-properties
|
||||
(cdr (assoc 'name (frame-parameters f))))
|
||||
f))
|
||||
(frame-list)))
|
||||
(selected-frame-name (completing-read "Select Frame: " (mapcar #'car frames)))
|
||||
(selected-frame (alist-get selected-frame-name frames "" nil 'string-equal)))
|
||||
(select-frame-set-input-focus selected-frame)))
|
||||
|
||||
(define-key 'ctl-x-5-prefix (kbd "RET") #'joe/select-frame)
|
||||
#+end_src
|
||||
** Projects
|
||||
|
||||
@ -1862,7 +1673,6 @@ odd looking ~'(t .t)~ is for specifying a default for all other actions.
|
||||
;; (:name "Ferano.io Unread" :query "m:/ferano.io/Inbox AND g:unread" :key ?u)))
|
||||
#+end_src
|
||||
** Avy
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(require 'avy)
|
||||
(setq avy-case-fold-search nil)
|
||||
@ -2001,7 +1811,6 @@ close and remove the hook
|
||||
(require 'vundo)
|
||||
#+end_src
|
||||
** Which Key
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(require 'which-key)
|
||||
(setq which-key-idle-delay 0.3)
|
||||
@ -2341,27 +2150,6 @@ nice to add some more functionality similar to gptel-quick, like dwim behavior
|
||||
(clipboard-kill-region (point-min) (point-max)))
|
||||
#+end_src
|
||||
** Programming Languages
|
||||
*** COMMENT treesitter
|
||||
#+begin_src emacs-lisp
|
||||
(setq major-mode-remap-alist
|
||||
'((csharp-mode . csharp-ts-mode)))
|
||||
|
||||
#+end_src
|
||||
|
||||
To run the default hooks, I came up with this, which is either really stupid or really cool.
|
||||
This checks if it’s a ts mode then runs their counterparts.
|
||||
|
||||
– MahmoudAdam
|
||||
[[https://www.emacswiki.org/emacs/Tree-sitter][Link]]
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun run-non-ts-hooks ()
|
||||
(let ((major-name (symbol-name major-mode)))
|
||||
(when (string-match-p ".*-ts-mode" major-name)
|
||||
(run-hooks (intern (concat (replace-regexp-in-string "-ts" "" major-name) "-hook"))))))
|
||||
|
||||
(add-hook 'prog-mode-hook 'run-non-ts-hooks)
|
||||
#+end_src
|
||||
*** Clojure
|
||||
#+begin_src emacs-lisp
|
||||
(require 'clojure-mode)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user