Start removing LSP, add mono-complete, custom dashboard, assorted improvements

This commit is contained in:
Joseph Ferano 2023-04-08 19:49:13 +07:00
parent 359c92028f
commit 51d1081917
2 changed files with 162 additions and 98 deletions

View File

@ -12,7 +12,6 @@ Skipping a bunch of regular expression searching in the file-name-handler-alist
(defvar default-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
#+end_src
*** Garbage Collection
The default Garbage Collector is triggered at 800 KB, way too conservative, let's bump to 512 MB.
@ -94,7 +93,6 @@ Ignore X resources.
(advice-add #'x-apply-session-resources :override #'ignore)
#+end_src
*** UTF-8 Support
#+begin_src emacs-lisp :tangle ./early-init.el
(setq default-input-method nil)
@ -176,13 +174,14 @@ Finish up
(unless (package-installed-p package)
(package-install package)))
'(recentf
benchmark-init
dashboard
olivetti
ligature
;; ligature
highlight-quoted
doom-modeline
hydra
multiple-cursors
;; hydra
;; multiple-cursors
evil
evil-collection
evil-surround
@ -190,7 +189,7 @@ Finish up
evil-commentary
evil-goggles
all-the-icons-ibuffer
ace-window
;; ace-window
popper
centaur-tabs
all-the-icons-completion
@ -202,7 +201,7 @@ Finish up
all-the-icons-completion
orderless
consult
consult-lsp
consult-eglot
dirvish
smtpmail
sendmail
@ -214,12 +213,12 @@ Finish up
undo-fu-session
vundo
which-key
company
company
lsp-mode
lsp-ui
flycheck
dap-mode
;; company
mono-complete
;; lsp-mode
;; lsp-ui
;; flycheck
;; dap-mode
rustic
ob-rust
typescript-mode
@ -236,18 +235,17 @@ Finish up
restclient
magit))
(package-initialize)
(setopt package-vc-selected-packages
'((dashboard . "554dc6f")
(doom-themes :url "https://github.com/JosephFerano/doom-themes")))
'((doom-themes :url "https://github.com/JosephFerano/doom-themes")))
(package-initialize)
#+end_src
** Benchmarking
** COMMENT Benchmarking
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
(require 'benchmark-init)
(add-hook 'after-init-hook 'benchmark-init/deactivate)
#+end_src
@ -311,10 +309,39 @@ This shows up when building Emacs;
#+end_quote
** Visuals
*** Initial Buffer
#+begin_src emacs-lisp :tangle no
(setq initial-buffer-choice "~/.config/emacs/init.org")
#+begin_src emacs-lisp
(defun load-projects ()
(with-temp-buffer
(insert-file-contents project-list-file)
(goto-char (point-min))
(apply #'append (read (current-buffer)))))
(defun my-dashboard ()
"Show Welcome buffer"
(with-current-buffer (get-buffer-create "*Welcome*")
(erase-buffer)
(goto-char (point-min))
(insert-image (create-image "~/Documents/emacs-alt.png"))
(insert "\n\n\n")
(insert "Welcome to Emacs!\n\n")
(let* ((time-str (emacs-init-time))
(time (string-to-number (car (split-string time-str)))))
(insert (format "It took %.3f seconds to start up\n\n" time)))
(insert "Happy hacking!\n\n")
(insert "Projects:\n")
(dolist (proj (load-projects))
(insert (format "\t%s\n" proj)))
(setq cursor-type nil)
(switch-to-buffer (current-buffer))
(goto-char (point-min))
(display-line-numbers-mode 0)
(read-only-mode +1)))
(setq initial-buffer-choice #'my-dashboard)
#+end_src
*** Dashboard
*** COMMENT Dashboard
Use Dashboard.el. First load `all-the-icons` for nicer rendering
#+begin_src emacs-lisp
@ -425,9 +452,6 @@ Setup other stuff
;; Dont compact font caches during GC, in case doom modeline gets laggy issue
(setq inhibit-compacting-font-caches t)
(require 'ligature)
(global-ligature-mode)
(require 'highlight-quoted)
(add-hook 'emacs-lisp-mode-hook 'highlight-quoted-mode)
@ -447,11 +471,17 @@ Setup other stuff
(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?
#+begin_src emacs-lisp :tangle no
(require 'ligature)
(global-ligature-mode)
#+end_src
** Text
#+begin_src emacs-lisp
;; (set-face-attribute 'default nil :family "Fira Code Nerd Font Mono" :height 110)
(set-face-attribute 'default nil :family "Fira Code" :height 110)
(set-face-attribute 'default nil :family "FiraCode Nerd Font Mono" :height 110)
;; (set-face-attribute 'variable-pitch nil :family "Source Code Pro" :height 120)
(setq-default c-basic-offset 4) ;; This is annoying
(setq-default indent-tabs-mode nil)
@ -520,7 +550,7 @@ weren't working, until I randomly saw this in someone's init.el
#+end_src
*** Hydra
#+begin_src emacs-lisp
#+begin_src emacs-lisp :tangle no
(require 'hydra)
(defhydra hydra-navigate (global-map "<f2>")
@ -536,7 +566,7 @@ weren't working, until I randomly saw this in someone's init.el
#+end_src
*** Multiple Cursors
#+begin_src emacs-lisp
#+begin_src emacs-lisp :tangle no
(require 'multiple-cursors)
#+end_src
*** Meow
@ -721,6 +751,7 @@ weren't working, until I randomly saw this in someone's init.el
state))
(evil-define-key 'normal joe/evil-space-mode-map
(kbd "K") #'eldoc
(kbd "SPC t") tab-prefix-map
(kbd "SPC p") project-prefix-map
(kbd "SPC q") 'kill-buffer-and-window
@ -772,9 +803,8 @@ weren't working, until I randomly saw this in someone's init.el
(require 'evil-surround)
(global-evil-surround-mode t)
;; (require 'evil-snipe)
;; (evil-snipe-mode +1)
;; (evil-snipe-override-mode +1)
(require 'evil-snipe)
(evil-snipe-override-mode +1)
(require 'evil-commentary)
(evil-commentary-mode t)
@ -843,15 +873,21 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
(define-key ctl-x-4-map (kbd "-") #'joe/window-split-horizontal)
(define-key ctl-x-4-map (kbd "t") #'rotate-window)
(require 'ace-window)
(global-set-key (kbd "C-x o") #'ace-window)
(global-set-key (kbd "C-x C-o") #'ace-swap-window)
(global-set-key (kbd "s-h") #'windmove-left)
(global-set-key (kbd "s-l") #'windmove-right)
(global-set-key (kbd "s-k") #'windmove-up)
(global-set-key (kbd "s-j") #'windmove-down)
#+end_src
Ace Window will show a hint if there are more than 2 windows, but I don't really use it
#+begin_src emacs-lisp :tangle no
(require 'ace-window)
(global-set-key (kbd "C-x o") #'ace-window)
(global-set-key (kbd "C-x C-o") #'ace-swap-window)
#+end_src
*** Popper
@ -863,7 +899,10 @@ 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
"^\\*eldoc\\*" special-mode
"^\\*ert\\*" ert-results-mode
"^\\*HTTP Response\\*" javascript-mode
"^\\*SQL.*" sql-interactive-mode
"^\\*cargo-test\\*" cargo-test-mode
"^\\*cargo-run\\*" cargo-run-mode
"^\\*rustic-compilation\\*" rustic-compilation-mode
@ -911,15 +950,15 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
(not (window-in-direction 'left)))
(display-buffer-in-direction
buffer
`((window-height . 0.4)
(window-width . 0.4)
`((window-height . 0.45)
(window-width . 0.45)
(direction . right)
(body-function . ,#'select-window))))
(t
(display-buffer-in-direction
buffer
`((window-height . 0.4)
(window-width . 0.4)
`((window-height . 0.45)
(window-width . 0.45)
(direction . below)
(body-function . ,#'select-window))))))
@ -1005,7 +1044,10 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
Other buffer group by `centaur-tabs-get-group-name' with project name."
(list
(cond
((derived-mode-p 'comint-mode)
((or (derived-mode-p 'comint-mode)
(derived-mode-p 'sql-interactive-mode)
(string-equal "*HTTP" (substring (buffer-name) 0 5))
(derived-mode-p 'compilation-mode))
"REPLs")
((or (string-equal "*" (substring (buffer-name) 0 1))
(memq major-mode '(magit-process-mode
@ -1016,9 +1058,6 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
magit-blob-mode
magit-blame-mode)))
"*Buffers*")
((memq major-mode '(helpful-mode
help-mode))
"Help")
(t
"Emacs")))))
@ -1206,22 +1245,22 @@ Vertico Embark Marginalia Consult Orderless
*** Consult
#+begin_src emacs-lisp
(require 'consult)
(require 'consult-lsp)
(require 'consult)
;; (require 'consult-lsp)
;; (defun joe/consult-line ()
;; (interactive)
;; (let ((vertico-posframe-mode -1))
;; (consult-line)))
;; (defun joe/consult-line ()
;; (interactive)
;; (let ((vertico-posframe-mode -1))
;; (consult-line)))
(global-set-key (kbd "C-. C-l") 'consult-line)
;; (global-set-key (kbd "C-. C-l") 'joe/consult-line)
(global-set-key (kbd "C-. C-i") 'consult-imenu)
(global-set-key (kbd "C-. C-t") 'consult-theme)
(global-set-key (kbd "C-. C-r") 'consult-recent-file)
(global-set-key (kbd "C-. C-y") 'consult-yank-from-kill-ring)
(global-set-key (kbd "C-. C-l") 'consult-line)
;; (global-set-key (kbd "C-. C-l") 'joe/consult-line)
(global-set-key (kbd "C-. C-i") 'consult-imenu)
(global-set-key (kbd "C-. C-t") 'consult-theme)
(global-set-key (kbd "C-. C-r") 'consult-recent-file)
(global-set-key (kbd "C-. C-y") 'consult-yank-from-kill-ring)
;; (global-set-key (kbd "C-s") 'swiper-thing-at-point)
;; (global-set-key (kbd "C-s") 'swiper-thing-at-point)
#+end_src
** Dirvish/Dired
@ -1284,9 +1323,18 @@ Vertico Embark Marginalia Consult Orderless
(kbd "M-e") #'dirvish-emerge-menu
(kbd "M-j") #'dirvish-fd-jump)))
;; There's an issue with the keybinding precedence so we need to run this since
;; joe/evil-space-mode-map takes precedence above all else and '-' doesn't do
;; what it should
(defun joe/dirvish-up-dwim ()
(interactive)
(if (eq major-mode 'dired-mode)
(dired-up-directory)
(dirvish-dwim)))
(when (boundp 'evil-mode)
(evil-define-key 'normal joe/evil-space-mode-map (kbd "_") #'project-dired)
(evil-define-key 'normal joe/evil-space-mode-map (kbd "-") #'dirvish-dwim))
(evil-define-key 'normal joe/evil-space-mode-map (kbd "-") #'joe/dirvish-up-dwim))
(global-set-key (kbd "C-x d") #'dirvish-dwim)
(global-set-key (kbd "C-x C-d") #'joe/dirvish-find-directory)
@ -1409,47 +1457,37 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
(evil-define-key 'insert comint-mode-map (kbd "C-n") 'comint-next-input)
(evil-define-key 'insert comint-mode-map (kbd "C-p") 'comint-previous-input))
#+end_src
*** Company
*** Mono-complete
#+begin_src emacs-lisp
;; (evil-global-set-key 'insert (kbd "C-f") #'mono-complete-expand)
(require 'mono-complete)
(evil-global-set-key 'insert (kbd "M-/") #'mono-complete-expand-or-fallback)
(setq mono-complete-backends (list 'dabbrev 'filesystem))
(setq mono-complete-backends (list 'capf 'dabbrev 'filesystem))
(setq completion-in-region-function
(lambda (&rest args)
(apply (if vertico-mode
#'consult-completion-in-region
#'completion--in-region)
args)))
(setq mono-complete-backend-capf-complete-fn #'eglot-completion-at-point)
(setq mono-complete-preview-delay 0.1)
(require 'company)
(with-eval-after-load 'company
(add-to-list 'completion-at-point-functions #'elisp-completion-at-point)
(require 'company)
(setq company-minimum-prefix-length 1)
(setq company-tooltip-align-annotations t)
(setq company-minimum-prefix-length 2)
(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))
(global-company-mode))
(add-to-list 'face-remapping-alist '(mono-complete-preview-face . shadow))
(mono-complete-mode +1)
#+end_src
*** Eldoc
#+begin_src emacs-lisp
(evil-global-set-key 'normal (kbd "K") #'eldoc)
(global-eldoc-mode -1)
#+end_src
*** LSP
*** Eglot
#+begin_src emacs-lisp
(with-eval-after-load 'eglot
(global-eldoc-mode -1)
(flymake-mode -1)
(when (boundp 'evil-mode)
;; (evil-global-set-key 'normal (kbd "M-d") #'lsp-describe-thing-at-point)
(evil-global-set-key 'normal (kbd "SPC li") 'eglot-inlay-hints-mode)
(evil-global-set-key 'normal (kbd "<leader>cs") 'consult-eglot-symbols)))
#+end_src
*** COMMENT LSP
#+begin_src emacs-lisp
(require 'lsp-mode)
(setq lsp-enable-which-key-integration t)
@ -1472,10 +1510,11 @@ 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)
;; All this changes because we are using eglot now
(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 "SPC 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))
@ -1496,7 +1535,7 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
(require 'lsp-ui)
#+end_src
*** Flycheck
*** COMMENT Flycheck
#+begin_src emacs-lisp
(require 'flycheck)
@ -1556,7 +1595,7 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
(add-hook 'compilation-finish-functions 'joe/close-compilation-if-no-warn-err)
#+end_src
** Debugging
*** DAP
*** COMMENT DAP
#+begin_src emacs-lisp
(require 'dap-mode)
;; (setq dap-auto-configure-features '(locals breakpoints expressions tooltip))
@ -1630,12 +1669,35 @@ startup. Reason we have to call this is so the vterm fucntion can call `vterm--i
*** Elisp
#+begin_src emacs-lisp
(global-set-key (kbd "C-x C-r") 'eval-region)
(evil-define-key 'insert emacs-lisp-mode-map (kbd "C-j") 'eval-print-last-sexp)
#+end_src
*** Web
#+begin_src emacs-lisp
(require 'typescript-mode)
(setq typescript-indent-level 2)
#+end_src
*** SQL
#+begin_src emacs-lisp
(defun joe/mark-sql-defun ()
"Mark the current SQL function definition."
(interactive)
(let ((beg (save-excursion
(re-search-backward "^create or replace function [^(]+" nil t)
(match-end 0)))
(end (save-excursion
(re-search-forward "\\(language\\)" nil t)
(line-end-position))))
(when (and beg end)
(goto-char beg)
(set-mark end)))
(evil-visual-line)
(evil-visual-line))
(with-eval-after-load 'sql-mode
(define-key sql-mode-map (kbd "C-M-h") #'joe/mark-sql-defun)
(define-key sql-mode-map (kbd "<f8>") #'sql-connect)
(define-key sql-mode-map (kbd "<f8>") #'sql-connect))
#+end_src
*** C
Design some basic functions for compiling. There's also a hook to close the popper window if there
@ -1756,6 +1818,7 @@ and there's no need for a middle-man when it's already been implemented.
(add-to-list 'org-structure-template-alist '("rs" . "src rust"))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
(add-to-list 'org-structure-template-alist '("hs" . "src haskell"))
(add-to-list 'org-structure-template-alist '("sh" . "src shell"))
(add-to-list 'org-structure-template-alist '("cc" . "src C :includes stdio.h stdlib.h"))
(setq org-edit-src-content-indentation 0))
(with-eval-after-load 'org (joe/org-init))

View File

@ -14,6 +14,7 @@ set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'"
set -gx DOTNET_CLI_TELEMETRY_OPTOUT 1
bind \cx 'if test -z (commandline) ; fg %1 &>/dev/null; else ; clear; commandline "╰─>$ "; end'
bind \e/ accept-autosuggestion
abbr -a -g gs "git status --untracked-files"
abbr -a -g gl "git lop -10"
@ -37,13 +38,13 @@ abbr -a -g gf "git fetch"
abbr -a -g grh "git reset --hard"
abbr -a -g gcl "git clean -fd"
abbr -a -g gd "git diff"
abbr -a -g gb "git branch"
abbr -a -g gba "git branch -a"
# abbr -a -g gpu "git push -u origin"
# abbr -a -g glp "git lfs pull"
# abbr -a -g glm "gss git merge ; glp"
# abbr -a -g gdh "git diff HEAD"
# abbr -a -g gms "git merge --squash"
# abbr -a -g gb "git branch"
# abbr -a -g gba "git branch -a"
# abbr -a -g gr "git rebase"
# abbr -a -g gst "git stash"
# abbr -a -g gsl "git stash list"