Check if we are using evil on startup, this way we can more easily test boon

This commit is contained in:
Joseph Ferano 2023-01-13 21:26:41 +07:00
parent 691fb21335
commit 248d520e01
2 changed files with 145 additions and 86 deletions

View File

@ -489,13 +489,16 @@ weren't working, until I randomly saw this in someone's init.el
(define-key boon-moves-map "l" 'forward-char)
(define-key boon-moves-map "b" 'boon-smarter-backward)
(define-key boon-moves-map "w" 'boon-smarter-forward)
(define-key boon-moves-map ";" '("hop" . avy-goto-char-2))
(define-key boon-command-map (kbd "C-k") 'scroll-down-line)
(define-key boon-command-map (kbd "C-j") 'scroll-up-line)
(define-key boon-command-map (kbd "C-v") 'scroll-up)
(define-key boon-moves-map "q" '("hop" . avy-goto-char-2))
(define-key boon-command-map (kbd "C-k") #'joe/scroll-down-line)
(define-key boon-command-map (kbd "C-j") #'joe/scroll-up-line)
(define-key boon-command-map (kbd "C-d") #'View-scroll-half-page-forward)
(define-key boon-command-map (kbd "C-u") #'View-scroll-half-page-backward)
(defun joe/scroll-up-line () (interactive) (scroll-up-line 2))
(defun joe/scroll-down-line () (interactive) (scroll-down-line 2))
;; (define-key boon-command-map (kbd "C-d") 'joe/smooth-scroll-half-page-down)
;; (define-key boon-command-map (kbd "C-u") 'joe/smooth-scroll-half-page-up)
(define-key boon-moves-map "H" 'backward-paragraph)
(define-key boon-moves-map "L" 'forward-paragraph)
(define-key boon-moves-map "K" 'boon-smarter-upward)
@ -505,14 +508,17 @@ weren't working, until I randomly saw this in someone's init.el
(define-key boon-moves-map "o" 'boon-open-next-line-and-insert)
(define-key boon-moves-map "O" 'boon-open-line-and-insert)
(define-key boon-moves-map "l" 'boon-open-next-line-and-insert)
(define-key boon-moves-map "i" 'boon-set-insert-like-state)
(define-key boon-moves-map "r" 'boon-replace-by-character)
(define-key boon-moves-map "y" 'boon-replace-by-character)
(define-key boon-moves-map "p" 'boon-splice)
(define-key boon-moves-map "y" 'boon-treasure-region)
(define-key ctl-x-map "s" 'save-buffer)
#+end_src
*** Evil
#+begin_src emacs-lisp
#+begin_src emacs-lisp
(setq evil-want-keybinding nil)
(setq evil-undo-system 'undo-fu)
@ -619,6 +625,16 @@ weren't working, until I randomly saw this in someone's init.el
(setq evil-goggles-pulse t)
(setq evil-goggles-async-duration 0.55)
(evil-global-set-key 'normal (kbd "<leader>w") 'evil-window-map)
(define-key evil-window-map "u" #'winner-undo)
(defun joe/scroll-up-line () (interactive) (scroll-up-line 2))
(defun joe/scroll-down-line () (interactive) (scroll-down-line 2))
(evil-global-set-key 'normal (kbd "C-e") #'joe/scroll-up-line)
(evil-global-set-key 'normal (kbd "C-y") #'joe/scroll-down-line)
(evil-global-set-key 'normal (kbd "<leader>p") project-prefix-map)
#+end_src
** Buffers
#+begin_src emacs-lisp
@ -674,10 +690,6 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
(defun joe/window-split-vertical () (interactive) (set 'joe/popper-side-toggle 'right) (rotate:main-horizontal))
(defun joe/window-split-horizontal () (interactive) (set 'joe/popper-side-toggle 'below) (rotate:main-vertical))
(evil-global-set-key 'normal (kbd "<leader>w") 'evil-window-map)
(define-key evil-window-map "u" #'winner-undo)
(define-key ctl-x-4-map (kbd "|") #'joe/window-split-vertical)
(define-key ctl-x-4-map (kbd "-") #'joe/window-split-horizontal)
(define-key ctl-x-4-map (kbd "t") #'rotate-window)
@ -772,11 +784,6 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
(interactive)
(joe/pixel-scroll-lerp 8 1))
(defun joe/scroll-up-line () (interactive) (scroll-up-line 2))
(defun joe/scroll-down-line () (interactive) (scroll-down-line 2))
(evil-global-set-key 'normal (kbd "C-e") #'joe/scroll-up-line)
(evil-global-set-key 'normal (kbd "C-y") #'joe/scroll-down-line)
;; 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)
@ -791,15 +798,15 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
(setq tab-bar-mode t)
(setq tab-bar-show nil)
(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)))
(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)))
#+end_src
** Projects
@ -812,8 +819,6 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
(add-hook 'project-find-functions #'joe/project-root-override)
(evil-global-set-key 'normal (kbd "<leader>p") project-prefix-map)
#+end_src
** VEMCO
@ -974,10 +979,10 @@ targets."
(setq dirvish-reuse-session nil)
(dirvish-define-preview exa (file)
"Use `exa' to generate directory preview."
:require ("exa") ; tell Dirvish to check if we have the executable
(when (file-directory-p file) ; we only interest in directories here
`(shell . ("exa" "--icons" "--color=always" "--no-user" "-al" "--group-directories-first" ,file))))
"Use `exa' to generate directory preview."
:require ("exa") ; tell Dirvish to check if we have the executable
(when (file-directory-p file) ; we only interest in directories here
`(shell . ("exa" "--icons" "--color=always" "--no-user" "-al" "--group-directories-first" ,file))))
(add-to-list 'dirvish-preview-dispatchers 'exa)
(setq dired-listing-switches "-l --sort=version --almost-all --human-readable --time-style=long-iso --group-directories-first --no-group")
@ -998,30 +1003,32 @@ targets."
("r" "~/Repositories" "Repos")
("B" "~/pCloudDrive/" "pCloud")))
(evil-define-key 'normal dirvish-mode-map
(kbd "C-c f") #'dirvish-fd
(kbd "a") #'dirvish-quick-access
(kbd ".") #'dired-create-empty-file
(kbd "f") #'dirvish-file-info-menu
(kbd "y") #'dirvish-yank-menu
(kbd "h") #'dired-up-directory
(kbd "l") #'dired-find-file
(kbd "s") #'dirvish-quicksort
(kbd "v") #'dirvish-vc-menu
(kbd "q") #'dirvish-quit
(kbd "L") #'dirvish-history-go-forward
(kbd "H") #'dirvish-history-go-backward
(kbd "o") #'dired-open-file
(kbd "TAB") #'dirvish-subtree-toggle
(kbd "M-n") #'dirvish-narrow
(kbd "M-l") #'dirvish-ls-switches-menu
(kbd "M-m") #'dirvish-mark-menu
(kbd "M-t") #'dirvish-layout-toggle
(kbd "M-s") #'dirvish-setup-menu
(kbd "M-e") #'dirvish-emerge-menu
(kbd "M-j") #'dirvish-fd-jump))
(when (boundp 'evil-mode)
(evil-define-key 'normal dirvish-mode-map
(kbd "C-c f") #'dirvish-fd
(kbd "a") #'dirvish-quick-access
(kbd ".") #'dired-create-empty-file
(kbd "f") #'dirvish-file-info-menu
(kbd "y") #'dirvish-yank-menu
(kbd "h") #'dired-up-directory
(kbd "l") #'dired-find-file
(kbd "s") #'dirvish-quicksort
(kbd "v") #'dirvish-vc-menu
(kbd "q") #'dirvish-quit
(kbd "L") #'dirvish-history-go-forward
(kbd "H") #'dirvish-history-go-backward
(kbd "o") #'dired-open-file
(kbd "TAB") #'dirvish-subtree-toggle
(kbd "M-n") #'dirvish-narrow
(kbd "M-l") #'dirvish-ls-switches-menu
(kbd "M-m") #'dirvish-mark-menu
(kbd "M-t") #'dirvish-layout-toggle
(kbd "M-s") #'dirvish-setup-menu
(kbd "M-e") #'dirvish-emerge-menu
(kbd "M-j") #'dirvish-fd-jump)))
(evil-global-set-key 'normal (kbd "-") #'dirvish-dwim)
(when (boundp 'evil-mode)
(evil-global-set-key 'normal (kbd "-") #'dirvish-dwim))
(global-set-key (kbd "C-x d") #'dirvish-dwim)
(global-set-key (kbd "C-x C-d") #'joe/dirvish-find-directory)
@ -1134,8 +1141,9 @@ targets."
(add-hook 'vterm-mode-hook
(lambda ()
(define-key vterm-mode-map (kbd "C-c C-x") #'vterm-send-C-x)
(evil-define-key 'insert vterm-mode-map (kbd "C-w") #'vterm-send-C-w)
(evil-define-key 'insert vterm-mode-map (kbd "<delete>") #'vterm-send-delete)
(when (boundp 'evil-mode)
(evil-define-key 'insert vterm-mode-map (kbd "C-w") #'vterm-send-C-w)
(evil-define-key 'insert vterm-mode-map (kbd "<delete>") #'vterm-send-delete))
(setq-local global-hl-line-mode nil)))
#+end_src
@ -1165,22 +1173,26 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
(setq which-key-idle-delay 0.3)
(add-hook 'after-init-hook (lambda () (which-key-mode)))
(which-key-add-keymap-based-replacements evil-normal-state-map
"<leader>f" '("Files")
"<leader>b" '("Buffers")
"<leader>B" '("Bookmarks")
"<leader>c" '("Consult")
"<leader>d" '("Dired")
"<leader>g" '("Git")
"<leader>m" '("Make")
"<leader>t" '("Tabs")
"<leader>p" '("Packages")
"<leader>s" '("Shell (vterm)")
"<leader>h" '("Help"))
(when (boundp 'evil-mode)
(which-key-add-keymap-based-replacements evil-normal-state-map
"<leader>f" '("Files")
"<leader>b" '("Buffers")
"<leader>B" '("Bookmarks")
"<leader>c" '("Consult")
"<leader>d" '("Dired")
"<leader>g" '("Git")
"<leader>m" '("Make")
"<leader>t" '("Tabs")
"<leader>p" '("Packages")
"<leader>s" '("Shell (vterm)")
"<leader>h" '("Help")))
#+end_src
** IDE Features
*** Company
#+begin_src rust
println!("Hello world");
#+end_src
#+begin_src emacs-lisp
@ -1195,7 +1207,6 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
;; (global-set-key (kbd "TAB") 'indent-for-tab-command)
;; (global-set-key (kbd "<backtab>") nil)
;; (straight-use-package 'kind-icon)
;; (require 'kind-icon)
;; (setq completion-in-region-function #'consult-completion-in-region)
@ -1237,19 +1248,64 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
;; company-frontends
;; '(company-pseudo-tooltip-unless-just-one-frontend
;; company-echo-metadata-frontend)
company-backends '((company-capf company-files)))
company-backends '((company-capf company-elisp company-files)))
(setq company-transformers '(company-sort-by-occurrence)))
(add-hook 'after-init-hook (lambda () (global-company-mode)))
;; (straight-use-package
;; '(corfu :type git :host github :repo "minad/corfu" :branch "preview-first"))
;; (setq completion-in-region-function #'completion--in-region)
;; (setq completion-in-region-function
;; (lambda (&rest args)
;; (apply (if vertico-mode
;; #'consult-completion-in-region
;; #'completion--in-region)
;; args)))
;; (straight-use-package 'company)
;; (require 'company)
;; (setq company-minimum-prefix-length 1)
;; (setq company-tooltip-align-annotations t)
;; (setq company-minimum-prefix-length 2)
;; (with-eval-after-load 'company
;; (define-key company-active-map (kbd "C-n") nil)
;; (define-key company-active-map (kbd "C-p") nil)
;; (define-key company-active-map (kbd "<return>") nil)
;; (define-key company-active-map (kbd "RET") nil)
;; (define-key company-active-map (kbd "M-d") #'company-show-doc-buffer)
;; (define-key company-active-map (kbd "C-f") #'company-complete-selection)
;; (define-key company-active-map [tab] #'company-complete-common-or-cycle)
;; (define-key company-active-map (kbd "<backtab>") (lambda () (interactive) (company-complete-common-or-cycle -1)))
;; (setq company-idle-delay 0.15
;; company-tooltip-idle-delay 20
;; company-require-match nil
;; company-frontends '(company-preview-frontend company-echo-metadata-frontend)
;; ;; company-frontends
;; ;; '(company-pseudo-tooltip-unless-just-one-frontend
;; ;; company-echo-metadata-frontend)
;; company-backends '((company-capf company-elisp company-files)))
;; (setq company-transformers '(company-sort-by-occurrence)))
;; (add-hook 'after-init-hook (lambda () (global-company-mode)))
;; (dolist (mode '(inferior-python-mode-hook))
;; (add-hook mode (lambda () (company-mode -1))))
;; (straight-use-package 'cape)
;; ;; (setq completion-at-point-functions '(cape-symbol))
;; (add-to-list 'completion-at-point-functions #'cape-dabbrev)
;; (add-to-list 'completion-at-point-functions #'cape-file)
;; (add-to-list 'completion-at-point-functions #'cape-symbol)
;; (setq completion-at-point-functions '(cape-symbol))
;; (straight-use-package 'corfu)
;; (global-corfu-mode t)
;; (global-corfu-mode 1)
;; (setq corfu-auto t)
;; (setq corfu-auto-delay 0.15)
;; (setq corfu-count 1)
;; (setq corfu-preview-current t)
;; (setq corfu-count 2)
;; ;; (setq corfu-preview-current t)
;; (define-key corfu-map "\C-f" #'corfu-complete)
#+end_src
*** LSP
#+begin_src emacs-lisp
@ -1275,11 +1331,12 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
(setq lsp-signature-render-documentation nil)
(setq lsp-eldoc-render-all nil)
(when (boundp 'evil-mode)
(evil-global-set-key 'normal (kbd "M-d") #'lsp-describe-thing-at-point)
(evil-global-set-key 'normal (kbd "<leader>lh") 'lsp-headerline-breadcrumb-mode)
(evil-global-set-key 'normal (kbd "<leader>li") 'lsp-rust-analyzer-inlay-hints-mode)
(evil-global-set-key 'normal (kbd "<leader>cs") 'consult-lsp-symbols)
(evil-global-set-key 'normal (kbd "<leader>cf") 'consult-lsp-file-symbols)
(evil-global-set-key 'normal (kbd "<leader>cf") 'consult-lsp-file-symbols))
;; This function allows us to extract Rust's true function signature
(cl-defmethod lsp-clients-extract-signature-on-hover (contents (_server-id (eql rust-analyzer)))
@ -1301,11 +1358,12 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
#+begin_src emacs-lisp
(straight-use-package 'flycheck)
;; TODO Add wrapping to these functions
(when (boundp 'evil-mode)
(evil-global-set-key 'normal (kbd "M-e") #'flycheck-next-error)
(evil-global-set-key 'normal (kbd "M-E") #'flycheck-previous-error)
(evil-global-set-key 'normal (kbd "<leader>ee") 'flycheck-mode)
(evil-global-set-key 'normal (kbd "<leader>el") #'flycheck-list-errors)
(evil-global-set-key 'normal (kbd "<leader>ce") #'consult-lsp-diagnostics)
(evil-global-set-key 'normal (kbd "<leader>ce") #'consult-lsp-diagnostics))
#+end_src
*** Compilation
#+begin_src emacs-lisp
@ -1416,11 +1474,9 @@ it doesn't close it.
*** Haskell
#+begin_src emacs-lisp
(straight-use-package 'haskell-mode)
(define-key haskell-interactive-mode-map (kbd "C-n") #'haskell-interactive-mode-history-next)
(define-key haskell-interactive-mode-map (kbd "C-p") #'haskell-interactive-mode-history-previous)
;; (evil-define-key 'insert)
(setq haskell-interactive-popup-errors nil)
(evil-define-key 'insert haskell-interactive-mode-map (kbd "C-n") #'haskell-interactive-mode-history-next)
(evil-define-key 'insert haskell-interactive-mode-map (kbd "C-p") #'haskell-interactive-mode-history-previous)
#+end_src
*** OCaml
@ -1446,7 +1502,6 @@ it doesn't close it.
(substring (shell-command-to-string
"opam config var share 2> /dev/null") 0 -1))
(add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share))
(require 'utop)
#+end_src
We won't use the LSP server but rather directly talk to Merlin, since I guess LSP just wraps Merlin
@ -1454,6 +1509,7 @@ and there's no need for a middle-man when it's already been implemented.
#+begin_src emacs-lisp
;; (require 'utop)
;; Use the opam installed utop
(setq utop-command "opam exec -- utop -emacs")
@ -1498,7 +1554,8 @@ The best git porcelain/client I've ever used. Also kill stray magit buffers left
(magit-restore-window-configuration)
(mapc #'kill-buffer buffers)))
(add-hook 'with-editor-mode-hook 'evil-insert-state)
(when (boundp 'evil-mode)
(add-hook 'with-editor-mode-hook 'evil-insert-state))
(setq magit-bury-buffer-function #'joe/magit-kill-buffers)
(setq magit-clone-set-remote.pushDefault t)

View File

@ -247,6 +247,8 @@ packer.startup(function(use)
}
end
}
use {'hkupty/iron.nvim', tag = "v3.0"}
use { 'gpanders/vim-medieval' }
-- use { 'TimUntersberger/neogit', requires = 'nvim-lua/plenary.nvim' }
end)
@ -270,7 +272,7 @@ autocmd(('BufWritePost'), {
require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'bash', 'rust', 'go', 'help', 'haskell', 'ocaml' },
ensure_installed = { 'c', 'cpp', 'go', 'python', 'lua', 'bash', 'rust', 'go', 'help', 'haskell', 'ocaml' },
highlight = {
enable = true,
additional_vim_regex_highlighting = false