Adds evil mode, counsel, projectile, magit and leader keys configuration.
This commit is contained in:
parent
99a6d4e578
commit
fbd768b22d
1 changed files with 179 additions and 9 deletions
188
init.el
188
init.el
|
|
@ -24,17 +24,14 @@
|
|||
(invert-face 'mode-line)
|
||||
(run-with-timer 0.1 nil #'invert-face 'mode-line))
|
||||
|
||||
;; ---------- Setting up font
|
||||
;; ---- Setting up font
|
||||
(set-face-attribute 'default nil :font "Fira Code Retina") ; TODO: setup ligatures.
|
||||
|
||||
; Setup theme
|
||||
(load-theme 'wombat)
|
||||
|
||||
;; Make ESC quit prompts.
|
||||
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
|
||||
|
||||
;; Initialize package sources.
|
||||
|
||||
;; Initialize package sources.
|
||||
(require 'package)
|
||||
|
||||
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
||||
|
|
@ -52,8 +49,16 @@
|
|||
(require 'use-package)
|
||||
(setq use-package-always-ensure t)
|
||||
|
||||
|
||||
(use-package swiper)
|
||||
(use-package counsel)
|
||||
|
||||
;; Use counsel for M-x when switching buffers and when opening files.
|
||||
(use-package counsel
|
||||
:bind (("M-x" . counsel-M-x)
|
||||
("C-x b" . counsel-ibuffer)
|
||||
("C-x C-f" . counsel-find-file)
|
||||
:map minibuffer-local-map ; TODO: not exactly sure what this is for, investigate.
|
||||
("C-r" . 'counsel-minibuffer-history)))
|
||||
|
||||
(use-package ivy
|
||||
:diminish
|
||||
|
|
@ -63,9 +68,9 @@
|
|||
("C-j" . ivy-next-line)
|
||||
("C-k" . ivy-previous-line)
|
||||
:map ivy-switch-buffer-map ; Bindings for switching buffers (C-x C-b)
|
||||
("C-k" . ivy-previous-lie)
|
||||
("C-k" . ivy-done) ; Test out, change if not comfortable.
|
||||
("C-k" . ivy-switch-buffer-kill) ; Test, out change if not comfortable.
|
||||
("C-k" . ivy-previous-line)
|
||||
("C-l" . ivy-done) ; Test out, change if not comfortable.
|
||||
("C-d" . ivy-switch-buffer-kill) ; Test, out change if not comfortable.
|
||||
; Maybe add a next line bind.
|
||||
:map ivy-reverse-i-search-map ; Binding for reverse search (history search)
|
||||
("C-k" . ivy-previous-line)
|
||||
|
|
@ -116,3 +121,168 @@
|
|||
|
||||
;; Corrects (and improves) org-mode's native fontification.
|
||||
(doom-themes-org-config))
|
||||
|
||||
(use-package rainbow-delimiters
|
||||
:hook (prog-mode . rainbow-delimiters-mode))
|
||||
|
||||
;; Show completion after pressing a prefix.x
|
||||
(use-package which-key
|
||||
:diminish
|
||||
:init (which-key-mode)
|
||||
:config
|
||||
(setq which-key-idle-delay 0.3))
|
||||
|
||||
;; Show description and keybindings for commands when using counsel-M-x
|
||||
(use-package ivy-rich
|
||||
:init
|
||||
(ivy-rich-mode))
|
||||
|
||||
;; Show more information in help pages.
|
||||
;; TODO: helpful is not working right now, try again later.
|
||||
(use-package helpful
|
||||
:init
|
||||
(setq counsel-describe-function-function #'helpful-callable)
|
||||
(setq counsel-describe-variable-function #'helpful-variable)
|
||||
:bind
|
||||
([remap describe-function] . counsel-describe-function)
|
||||
([remap describe-command] . helpful-command)
|
||||
([remap describe-variable] . counsel-describe-variable)
|
||||
([remap describe-key] . helpful-key))
|
||||
|
||||
;; Setup hydra.
|
||||
(use-package hydra)
|
||||
|
||||
;; Window size hydras.
|
||||
(defhydra hydra-window-size (:timeout 4)
|
||||
"Window horizontal size"
|
||||
("<" evil-window-decrease-width "decrease width")
|
||||
(">" evil-window-increase-width "increase width")
|
||||
("+" evil-window-increase-height "increase height")
|
||||
("-" evil-window-decrease-height "decrease height")
|
||||
("f" nil "finished" :exit t))
|
||||
|
||||
|
||||
;; Setup leader key.
|
||||
(use-package general
|
||||
:config
|
||||
(general-create-definer mariano/leader-keys
|
||||
:keymaps '(normal visual emacs) ; Where the prefix will work. Consider taking out insert mode if too annoying.
|
||||
:prefix "SPC"
|
||||
:gloabl-prefix "C-SPC")) ;; This prefix will work everywhere.
|
||||
|
||||
;; Basic leader keys.
|
||||
(mariano/leader-keys
|
||||
"s" 'save-buffer)
|
||||
|
||||
;; Window leader keys.
|
||||
(mariano/leader-keys
|
||||
"w" '(:ignore t :which-key "windows")
|
||||
"w-" '(split-window-below :which-key "split vertical")
|
||||
"w|" '(split-window-horizontally :which-key "split horizontal")
|
||||
"wj" '(evil-window-down :which-key "window below")
|
||||
"wk" '(evil-window-up :which-key "window above")
|
||||
"wh" '(evil-window-left :which-key "window left")
|
||||
"wl" '(evil-window-right :which-key "window right")
|
||||
"ws" '(hydra-window-size/body :which-key "window size")
|
||||
"wd" '(delete-window :which-key "delete current window"))
|
||||
|
||||
;; Kill all buffers except the current one.
|
||||
(defun kill-other-buffers ()
|
||||
"Kill all other buffers."
|
||||
(interactive)
|
||||
(mapc 'kill-buffer ;; Apply the command kill-buffer to all elements of the list.
|
||||
(delq (current-buffer) ;; Remove the current buffer from the list of to-be-removed.
|
||||
(cl-remove-if-not 'buffer-file-name (buffer-list))))) ;; Only remove file buffers.
|
||||
|
||||
;; Buffer leader keys.
|
||||
(mariano/leader-keys
|
||||
"b" '(:ignore t :which-key "buffers")
|
||||
"bs" '(counsel-switch-buffer :which-key "switch buffer")
|
||||
"bk" '(kill-buffer :which-key "kill buffer")
|
||||
"be" '(eval-buffer :which-key "eval buffer")
|
||||
"bO" '(kill-other-buffers :which-key "keep only the current buffer"))
|
||||
|
||||
;; Files leader keys.
|
||||
(mariano/leader-keys
|
||||
"f" '(:ignore t :which-key "files")
|
||||
"ff" '(counsel-find-file :which-key "find file")
|
||||
"fw" '(save-buffer :which-key "write file"))
|
||||
|
||||
;; Makes the specified modes to start in emacs mode (no vim keybindings)
|
||||
(defun mariano/evil-hook ()
|
||||
(dolist ( mode '(custom-mode
|
||||
eshell-mode
|
||||
term-mode))
|
||||
(add-to-list 'evil-emacs-state-modes mode)))
|
||||
|
||||
(use-package evil
|
||||
:init
|
||||
(setq evil-want-integration t)
|
||||
(setq evil-want-keybinding nil)
|
||||
;; (setq evil-want-C-u-scroll t) ;; I may want it in the future.
|
||||
(setq evil-want-C-i-jump nil) ;; I have never used the jump functionality, turn it on if needed.
|
||||
;; :hook (evil-mode . mariano/evil-hook) ;; Only set up when I find a need for this.
|
||||
:config
|
||||
(evil-mode 1)
|
||||
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
|
||||
(define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)
|
||||
|
||||
;; Allow navigation in wrwapped lines.
|
||||
;; Deactivated because it causes dj to behave differently.
|
||||
;; (evil-global-set-key 'motion "j" 'evil-next-visual-line)
|
||||
;; (evil-global-set-key 'motion "k" 'evil-previous-visual-line)
|
||||
|
||||
;; Always start in normal mode in the messages buffer.
|
||||
(evil-set-initial-state 'messages-buffer-mode 'normal))
|
||||
|
||||
(use-package evil-collection
|
||||
:after evil
|
||||
:config
|
||||
(evil-collection-init))
|
||||
|
||||
(use-package key-chord
|
||||
:config
|
||||
(key-chord-mode 1)
|
||||
(key-chord-define evil-insert-state-map "kj" 'evil-normal-state))
|
||||
|
||||
(use-package projectile
|
||||
:diminish
|
||||
:config (projectile-mode)
|
||||
:bind-keymap
|
||||
("C-c p" . projectile-command-map)
|
||||
:init
|
||||
(when (file-directory-p "~/dev") ;; Setup ~/dev as my local code repository.
|
||||
(setq projectile-project-search-path '("~/dev")))
|
||||
(setq projectile-switch-project-action #'projectile-dired)) ;; This does not work with counsel-projectile installed, refer to https://github.com/ericdanan/counsel-projectile/issues/62
|
||||
|
||||
;; Extra ivy actions for projectile commands.
|
||||
(use-package counsel-projectile
|
||||
:after projectile
|
||||
:config (counsel-projectile-mode))
|
||||
|
||||
|
||||
(use-package magit)
|
||||
;; :custom
|
||||
;; (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) ;; Use this if diffing in a different window is annoying.
|
||||
|
||||
;; Leader keybindings for magit.
|
||||
(mariano/leader-keys
|
||||
"g" '(:ignore t :which-key "magit")
|
||||
"gs" '(magit-status :which-key "status")
|
||||
"gc" '(magit-branch-or-checkout :which-key "branch or checkout")
|
||||
"gp" '(magit-push-current-to-pushremote :which-key "push to remote"))
|
||||
|
||||
;; (use-package forge) ;; Use this package if I want to do extra git stuff from emacs.
|
||||
|
||||
;; Display line numbers (Only in prog modes).
|
||||
(column-number-mode) ; Show colum in modeline.
|
||||
(global-display-line-numbers-mode t)
|
||||
;; Always use relative when using line numbers mode.
|
||||
(add-hook 'display-line-numbers-mode-hook (lambda () (setq display-line-numbers 'relative)))
|
||||
|
||||
;; Disable line numbers for certain modes.
|
||||
(dolist (mode '(org-mode-hook
|
||||
term-mode-hook
|
||||
shell-mode-hook
|
||||
eshell-mode-hook))
|
||||
(add-hook mode (lambda () (display-line-numbers-mode 0))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue