From 85ce390237b1b3b1d052c521cce7720a5a94411a Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sun, 25 Dec 2022 23:09:12 +0700 Subject: [PATCH] vv works now, .project.el for project root, o to open file dirvish --- .config/emacs/init.org | 40 +++++++++++++++++++++++++++++++--- .config/fish/functions/la.fish | 6 +++++ .config/fish/functions/v.fish | 3 +++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 .config/fish/functions/la.fish create mode 100644 .config/fish/functions/v.fish diff --git a/.config/emacs/init.org b/.config/emacs/init.org index 43971bb..ae93b1e 100644 --- a/.config/emacs/init.org +++ b/.config/emacs/init.org @@ -113,7 +113,7 @@ Then bootstrap This is commented out since it adds ever so slightly to init time, but keep it around in case we need to benchmark slow init times later. -#+begin_src emacs-lisp :tangle no +#+begin_src emacs-lisp (straight-use-package 'benchmark-init) (require 'benchmark-init) (add-hook 'after-init-hook 'benchmark-init/deactivate) @@ -377,6 +377,15 @@ Emacs is an great operating system, if only it had a good text editor... (evil-global-set-key 'insert (kbd "C-w") #'evil-delete-backward-word) (evil-define-key 'normal 'global (kbd "q") 'avy-goto-word-0) +;; vv to expand selection to line +(evil-global-set-key 'visual + (kbd "v") + (lambda () + (interactive) + (evil-first-non-blank) + (exchange-point-and-mark) + (evil-end-of-line))) + (add-hook 'emacs-startup-hook (lambda () (evil-define-key 'normal 'global @@ -427,6 +436,8 @@ Emacs is an great operating system, if only it had a good text editor... ;; (define-key evil-consult-map "b" 'evil-window-bottom-right) ;; (define-key evil-consult-map "c" 'evil-window-delete) +(evil-global-set-key 'normal (kbd "C-w") 'save-buffer) + ;; (define-key evil-normal-state-map "," 'evil-consult-map) (defun joe/evil-select-line () @@ -521,8 +532,9 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun (defun joe/window-split-horizontal () (interactive) (set 'joe/popper-side-toggle 'below) (rotate:main-vertical)) (evil-global-set-key 'normal (kbd "w") 'evil-window-map) -(evil-global-set-key 'normal (kbd "C-w") 'save-buffer) - + +(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) @@ -548,6 +560,7 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun "^\\*Flymake.*" flymake-mode "^\\*Flycheck.*" flycheck-error-list-mode "^\\*lsp-help\\*" lsp-help-mode + "^\\*ert\\*" ert-results-mode "^\\*cargo-test\\*" cargo-test-mode ;; "^\\*ansi-term\\*$" term-mode ("^\\*Warnings\\*$" . hide) @@ -637,6 +650,16 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun (evil-define-key 'normal 'global (kbd "M-8") '(lambda () (interactive) (tab-bar-select-tab 8))) (evil-define-key 'normal 'global (kbd "M-9") '(lambda () (interactive) (tab-bar-select-tab 9))) #+end_src +** Projects +#+begin_src emacs-lisp +(defun joe/project-root-override (dir) + (let ((override (locate-dominating-file dir ".project.el"))) + (if override + (cons 'transient override) + nil))) + +(add-hook 'project-find-functions #'joe/project-root-override) +#+end_src ** VEMCO Vertico Embark Marginalia Consult Orderless @@ -830,6 +853,7 @@ targets." (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 @@ -843,6 +867,14 @@ targets." (global-set-key (kbd "C-x d") #'dirvish-dwim) (global-set-key (kbd "C-x C-d") #'joe/dirvish-find-directory) +(defun dired-open-file () + "In dired, open the file named on this line." + (interactive) + (let* ((file (dired-get-filename nil t))) + (message "Opening %s..." file) + (call-process "xdg-open" nil 0 nil file) + (message "Opening %s done" file))) + #+end_src ** Org Mode @@ -1192,6 +1224,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) + (setq magit-bury-buffer-function #'joe/magit-kill-buffers) (setq magit-clone-set-remote.pushDefault t) (setq magit-clone-default-directory "~/Development/") diff --git a/.config/fish/functions/la.fish b/.config/fish/functions/la.fish new file mode 100644 index 0000000..2b549d7 --- /dev/null +++ b/.config/fish/functions/la.fish @@ -0,0 +1,6 @@ +# +# These are very common and useful +# +function la --wraps ls --description "List contents of directory, including hidden files in directory using long format" + ls -lAh --group-directories-first $argv +end diff --git a/.config/fish/functions/v.fish b/.config/fish/functions/v.fish new file mode 100644 index 0000000..b746e5b --- /dev/null +++ b/.config/fish/functions/v.fish @@ -0,0 +1,3 @@ +function v --wraps=nvim --description 'alias v nvim' + nvim $argv; +end