diff --git a/.config/emacs/elisp/welcome.el b/.config/emacs/elisp/welcome.el index 289af07..648af29 100644 --- a/.config/emacs/elisp/welcome.el +++ b/.config/emacs/elisp/welcome.el @@ -101,7 +101,7 @@ (buffer-size) (erase-buffer) (goto-char (point-min)) - (insert-image (create-image "/home/joe/.config/emacs/Emacs@256.png")) + (insert-image (create-image (expand-file-name "Emacs@256.png" user-emacs-directory))) (insert "\n\n\n") (insert "Welcome to Emacs!\n\n") ;; (dashboard-insert-center "testing this thing out\n\n") diff --git a/.config/emacs/init.org b/.config/emacs/init.org index 0797fe2..6f921ff 100644 --- a/.config/emacs/init.org +++ b/.config/emacs/init.org @@ -269,7 +269,7 @@ need to benchmark slow init times later. ** Misc Stuff #+begin_SRC emacs-lisp -(setq default-directory "/home/joe/") +(setq default-directory (expand-file-name "~")) (setq vc-follow-symlinks t) ; Visit real file when editing a symlink without prompting. (global-auto-revert-mode t) ; Revert buffer's file when the file changes on disk @@ -531,8 +531,8 @@ Setup other stuff ;; TODO Likely not needed anymore -;; (dolist (mode '(dired-mode-hook lsp-help-mode-hook fundamental-mode-hook)) -;; (add-hook mode (lambda () (setq truncate-lines t)))) +(dolist (mode '(dired-mode-hook lsp-help-mode-hook fundamental-mode-hook)) + (add-hook mode (lambda () (setq truncate-lines t)))) #+end_src Ligatures... are they that useful? @@ -639,7 +639,7 @@ Emacs is an great operating system, if only it had a good text editor... (global-set-key (kbd "M-o") #'joe/insert-line-below) (global-set-key (kbd "M-O") #'joe/insert-line-above) -;; (setq-default truncate-lines nil) +(setq-default truncate-lines t) (setq-default truncate-partial-width-windows nil) (defun joe/backward-kill-word-or-kill-region () @@ -844,6 +844,13 @@ Fill region is great, except when you don't need it... (setq evil-goggles-pulse t) (setq evil-goggles-async-duration 0.55) +(defun joe/evil-search-symbol-forward () + (interactive) + (evil-search-word t nil t)) + +(evil-global-set-key 'normal "*" #'joe/evil-search-symbol-forward) +(evil-global-set-key 'normal "#" #'evil-search-word-forward) + ;; Recenter lines after mark jump ;; (defun joe/recenter-after-goto-mark () ;; (interactive) @@ -938,6 +945,18 @@ Fill region is great, except when you don't need it... (keymap-set smartparens-mode-map "M-(" 'sp-wrap-round) (keymap-set smartparens-mode-map "M-[" 'sp-wrap-square) (keymap-set smartparens-mode-map "M-{" 'sp-wrap-curly) + +(defun sp-wrap-single-quote () + (interactive) + (sp-wrap-with-pair "'")) + +(defun sp-wrap-double-quote () + (interactive) + (sp-wrap-with-pair "\"")) + +(keymap-set smartparens-mode-map "M-'" 'sp-wrap-single-quote) +(keymap-set smartparens-mode-map "M-\"" 'sp-wrap-double-quote) + #+end_src *** expand-region #+begin_src emacs-lisp @@ -1012,6 +1031,7 @@ Fill region is great, except when you don't need it... (switch-to-buffer (other-buffer))) (global-set-key (kbd "C-x l") 'joe/switch-other-buffer) +(global-set-key (kbd "C-x C-l") 'joe/switch-other-buffer) (save-place-mode t) (setq save-place-file (expand-file-name "places" user-emacs-directory)) @@ -1441,21 +1461,64 @@ odd looking ~'(t .t)~ is for specifying a default for all other actions. ;; (require 'consult-lsp) -(global-set-key (kbd "M-s l") #'consult-line) -(global-set-key (kbd "M-s g") #'consult-ripgrep) -(global-set-key (kbd "M-s f") #'consult-find) -(global-set-key (kbd "M-s y") #'consult-yank-from-kill-ring) -(global-set-key (kbd "M-s r") #'consult-recent-file) -(global-set-key (kbd "M-s i") #'consult-imenu) +(defvar consult-map (make-sparse-keymap)) +(global-set-key (kbd "C-;") consult-map) +(define-key consult-map (kbd "a") 'command-a) +;; Bind the prefix +(define-key consult-map (kbd "l") #'consult-line) +(define-key consult-map (kbd "C-l") #'consult-line-multi) +(define-key consult-map (kbd "F") #'consult-find) +(define-key consult-map (kbd "g") #'consult-ripgrep) +(define-key consult-map (kbd "y") #'consult-yank-from-kill-ring) +(define-key consult-map (kbd "r") #'consult-recent-file) +(define-key consult-map (kbd "i") #'consult-imenu) +(define-key consult-map (kbd "t") #'consult-theme) +(defun joe/evil-search-symbol-forward () + (interactive) + (evil-search-word-forward 1 t)) + +(evil-global-set-key 'normal "*" #'joe/evil-search-symbol-forward) +(evil-global-set-key 'normal "#" #'evil-search-word-forward) + +(defun joe/consult-line-symbol-at-point () + "Search for a line matching the symbol found near point." + (interactive) + (consult-line + (or (thing-at-point 'symbol)))) + +(defun joe/consult-line-word-at-point () + "Search for a line matching the word found near point." + (interactive) + (consult-line + (or (thing-at-point 'word)))) + +(defun joe/consult-ripgrep-symbol-at-point () + "Run consult-ripgrep with the symbol at point as the initial search term." + (interactive) + (let* ((term (thing-at-point 'symbol)) + (search-term (if term term ""))) + (consult-ripgrep nil search-term))) + +(defun joe/consult-ripgrep-word-at-point () + "Run consult-ripgrep with the word at point as the initial search term." + (interactive) + (let* ((term (thing-at-point 'symbol)) + (search-term (if term term ""))) + (consult-ripgrep default-directory search-term))) + +(define-key consult-map (kbd ".") #'joe/consult-line-symbol-at-point) +(define-key consult-map (kbd "C-.") #'joe/consult-line-word-at-point) +(define-key consult-map (kbd ",") #'joe/consult-ripgrep-symbol-at-point) +(define-key consult-map (kbd "C-,") #'joe/consult-ripgrep-word-at-point) #+end_src *** Orderless #+begin_src emacs-lisp - (require 'orderless) - (setq completion-styles '(orderless basic) - completion-category-overrides '((file (styles basic partial-completion)))) +(require 'orderless) +(setq completion-styles '(orderless basic) + completion-category-overrides '((file (styles basic partial-completion)))) #+end_src ** App Launcher #+begin_src emacs-lisp @@ -1523,7 +1586,7 @@ odd looking ~'(t .t)~ is for specifying a default for all other actions. (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-") #'dirvish-setup-menu (kbd "M-e") #'dirvish-emerge-menu (kbd "M-j") #'dirvish-fd-jump))) @@ -1661,7 +1724,7 @@ odd looking ~'(t .t)~ is for specifying a default for all other actions. (require 'avy) (setq avy-case-fold-search nil) (setq avy-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l ?q ?w ?e ?r ?u ?i ?o ?p ?z ?x ?c ?v ?n ?m)) -(global-set-key (kbd "C-;") #'avy-goto-char) ;; I use this most frequently +(global-set-key (kbd "M-s") #'avy-goto-char) ;; I use this most frequently ;; (define-key global-map (kbd "C-'") 'avy-goto-line) ;; Consistent with ivy-avy (define-key global-map (kbd "M-g c") 'avy-goto-char) (define-key global-map (kbd "M-g e") 'avy-goto-word-0) ;; lots of candidates @@ -1895,6 +1958,7 @@ These help speed eglot up apparently [[https://www.reddit.com/r/emacs/comments/1 (setq lsp-modeline-diagnostics-enable nil) (setq lsp-modeline-code-actions-enable nil) (setq lsp-lens-enable nil) +(setq lsp-ui-doc-show-with-mouse nil) (setq lsp-signature-auto-activate nil) (setq lsp-eldoc-enable-hover nil) (setq eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit) @@ -1970,6 +2034,7 @@ start it, so go through all existing buffers that match the mode and belong to t (defun joe/flycheck-buffer-and-previous () (interactive) (flycheck-buffer) (flycheck-previous-error)) (defun joe/flycheck-clear-if-active () + (interactive) (when (bound-and-true-p flycheck-mode) (flycheck-clear))) @@ -2718,7 +2783,7 @@ TODO: We need to create a var for a project based base branch ** Initial Buffer #+begin_src emacs-lisp -(load-file "/home/joe/.config/emacs/elisp/welcome.el") +(load-file (expand-file-name "elisp/welcome.el" user-emacs-directory)) #+end_src * COMMENT Local variables ;; Local Variables: