From 329e6863f76a6c7d0559446ae5c32c63197fc38d Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Tue, 23 Aug 2022 22:14:03 +0700 Subject: [PATCH] Bankrupt: Olivetti, kill buffer bindings, vterm, dirvish, company/lsp --- .emacs.bankruptcy/init.org | 174 ++++++++++++++++++++++++++++++++++--- 1 file changed, 162 insertions(+), 12 deletions(-) diff --git a/.emacs.bankruptcy/init.org b/.emacs.bankruptcy/init.org index d11fff0..578f9de 100644 --- a/.emacs.bankruptcy/init.org +++ b/.emacs.bankruptcy/init.org @@ -65,6 +65,13 @@ Prioritize old byte-compiled source files over newer sources. It saves us a litt #+begin_src emacs-lisp :tangle ./early-init.el (setq load-prefer-newer nil) + +(setq safe-local-variable-values + '((eval add-hook 'after-save-hook + '(lambda nil + (org-babel-tangle)) + nil t))) + #+end_src *** UTF-8 Support #+begin_src emacs-lisp :tangle ./early-init.el @@ -121,7 +128,6 @@ literate file. #+begin_src emacs-lisp (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) (load custom-file t) - #+end_src This avoids those annoying *#backup#* files that get added and eventually slow down loading the file again. @@ -141,8 +147,14 @@ This avoids those annoying *#backup#* files that get added and eventually slow d kept-new-versions 6 kept-old-versions 2 version-control t) + +(global-set-key (kbd "C-x k") #'kill-this-buffer) +(global-set-key (kbd "C-x M-k") #'kill-buffer) + #+END_SRC ** Visuals +*** Dashboard + Use Dashboard.el. First load `all-the-icons` for nicer rendering #+begin_src emacs-lisp @@ -162,6 +174,40 @@ Use Dashboard.el. First load `all-the-icons` for nicer rendering (add-hook 'dashboard-mode-hook (lambda () (setq-local line-spacing 12))) #+end_src +*** Olivetti + +#+begin_src emacs-lisp +(straight-use-package 'olivetti) +(setq olivetti-minimum-body-width 100) +#+end_src + +*** Themes + +Simple functions to remember the last chosen theme. + +#+begin_src emacs-lisp + +(straight-use-package 'doom-themes) +(setq custom-safe-themes t) + +(defun joe/save-current-theme () + (let ((filename (expand-file-name "data" user-emacs-directory))) + (with-temp-buffer + (print `((last-used-theme . ,custom-enabled-themes)) (current-buffer)) + (if (file-writable-p filename) + (write-file filename) + (message (format "Cannot save themes because %s is not writable" filename)))))) +(add-hook 'kill-emacs-hook #'joe/save-current-theme) + +(let ((filename (expand-file-name "data" user-emacs-directory))) + (if (file-readable-p filename) + (let ((theme-data (with-temp-buffer + (insert-file-contents filename) + (buffer-string)))) + (mapc 'load-theme (cdr (car (read theme-data))))))) +#+end_src +*** Other + Setup other stuff #+begin_src emacs-lisp @@ -194,11 +240,6 @@ Setup other stuff (setq inhibit-startup-screen t) -(straight-use-package 'doom-themes) -(setq custom-safe-themes t) -;; (load-theme 'doom-vibrant t) -(load-theme 'doom-one-light t) - (straight-use-package 'ligature) (global-ligature-mode) @@ -239,10 +280,13 @@ Setup other stuff (org-indent-mode))) #+end_src -** VEMCO (Vertico Embark Marginalia Consult Orderless) +** VEMCO Vertico Embark Marginalia Consult Orderless #+begin_src emacs-lisp +(require 'all-the-icons) + +(straight-use-package 'all-the-icons-completion) (straight-use-package '(vertico :files (:defaults "extensions/*") :includes (vertico-directory))) ;; :bind (:map vertico-map ;; ("\M-G" . vertico-multiform-mode) @@ -262,30 +306,55 @@ Vertico Embark Marginalia Consult Orderless (straight-use-package 'embark-consult) (straight-use-package 'marginalia) -(marginalia-mode) (setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) +(marginalia-mode) +(require 'all-the-icons-completion) +(all-the-icons-completion-mode) +(all-the-icons-completion-marginalia-setup) + +(add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup) (straight-use-package 'consult) +(global-set-key (kbd "C-x b") #'consult-buffer) (straight-use-package 'orderless) (setq completion-styles '(orderless basic) completion-category-overrides '((file (styles basic partial-completion)))) #+end_src +** Helpful +#+begin_src emacs-lisp +(straight-use-package 'helpful) +(global-set-key (kbd "C-h f") #'helpful-callable) +(global-set-key (kbd "C-h v") #'helpful-variable) +(global-set-key (kbd "C-h k") #'helpful-key) +(global-set-key (kbd "C-c C-d") #'helpful-at-point) +(global-set-key (kbd "C-h F") #'helpful-function) +(global-set-key (kbd "C-h C") #'helpful-command) +#+end_src + ** Dirvish/Dired #+begin_src emacs-lisp - (straight-use-package 'dirvish) + (dirvish-override-dired-mode) (setq delete-by-moving-to-trash t) (setq dired-dwim-target t) + (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" "-H" "--icons" "--color=always" "--no-user" "-al" "--group-directories-first" ,file)))) (add-to-list 'dirvish-preview-dispatchers 'exa) + (setq dired-listing-switches "-l --almost-all --human-readable --time-style=long-iso --group-directories-first --no-group") (setq dirvish-preview-dispatchers (cl-substitute 'pdf-preface 'pdf dirvish-preview-dispatchers)) -(define-key global-map (kbd "M--") #'dirvish) + +(defun joe/dirvish-find-directory (dir) + (interactive "FDirvish Directory:") + (dirvish-dwim dir)) + +(define-key global-map (kbd "C-x d") #'dirvish) +(define-key global-map (kbd "C-x C-d") #'joe/dirvish-find-directory) #+end_src ** Terminals/Shells @@ -295,6 +364,11 @@ Vertico Embark Marginalia Consult Orderless (setq vterm-timer-delay 0.01) (setq vterm-buffer-name-string "VTerm - %s") (setq vterm-max-scrollback 100000) +(straight-use-package 'multi-vterm) +(define-key global-map (kbd "C-c t v") #'vterm-other-window) +(define-key global-map (kbd "C-c t t") #'multi-vterm) +(define-key global-map (kbd "C-c t p") #'multi-vterm-prev) +(define-key global-map (kbd "C-c t n") #'multi-vterm-next) #+end_src @@ -330,8 +404,8 @@ Emacs is an great operating system, if only it had a good text editor... ("l" text-scale-decrease "out") ("d" View-scroll-half-page-forward "half page down") ("u" View-scroll-half-page-backward "half page up") - ("y" View-scroll-line-forward "line down") - ("e" View-scroll-line-backward "line up") + ("e" View-scroll-line-forward "line down") + ("y" View-scroll-line-backward "line up") ) #+end_src @@ -492,6 +566,82 @@ Emacs is an great operating system, if only it had a good text editor... ("C-d" scroll-up-command :first '(deactivate-mark)))) (add-hook 'after-init-hook 'my/kakoune-setup) +#+end_src +** IDE Features +*** C +#+begin_src emacs-lisp +;; (straight-use-package 'yasnippet) +(straight-use-package 'markdown-mode) +(straight-use-package 'lsp-mode) +;; (straight-use-package 'eglot) +;; (setq completion-in-region-function (kind-icon-enhance-completion completion-in-region-function)) + + +(setq completion-in-region-function #'consult-completion-in-region) +(global-set-key [remap dabbrev-expand] 'hippie-expand) + +;; (straight-use-package 'cape) +;; (add-to-list 'completion-at-point-functions #'cape-symbol) +;; (add-to-list 'completion-at-point-functions #'cape-file) +;; (add-to-list 'completion-at-point-functions #'cape-dabbrev) +;; (straight-use-package 'kind-icon) +;; (require 'kind-icon) + +(straight-use-package 'company) +(require 'company) +(setq company-idle-delay 0 + company-tooltip-idle-delay 10 + company-require-match nil + company-frontends '(company-preview-frontend company-echo-metadata-frontend) + ;; company-frontends '(company-text-icons-margin company-echo-metadata-frontend) + company-backends '((company-capf company-files))) + +(setq company-transformers '(company-sort-by-occurrence)) +;; (setq company-transformers '()) +(add-to-list 'completion-at-point-functions #'elisp-completion-at-point) +(with-eval-after-load 'company + (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 "") (lambda () (interactive) (company-complete-common-or-cycle -1)))) +(global-company-mode) + +;; (delete 'elisp-completion-at-point completion-at-point-functions) +;; (delete 'cape-symbol completion-at-point-functions) + +;; (straight-use-package 'corfu) +;; (global-corfu-mode) +;; (setq +;; corfu-cycle t ;; Enable cycling for `corfu-next/previous' +;; corfu-auto t ;; Enable auto completion +;; corfu-separator ?\s ;; Orderless field separator +;; corfu-quit-at-boundary nil ;; Never quit at completion boundary +;; corfu-quit-no-match nil ;; Never quit, even if there is no match +;; corfu-preview-current t ;; Disable current candidate preview +;; corfu-preselect-first t ;; Disable candidate preselection +;; corfu-on-exact-match nil ;; Configure handling of exact matches +;; corfu-echo-documentation t ;; Disable documentation in the echo area +;; corfu-scroll-margin 5) ;; Use scroll margin +;; (setq corfu-preview-current t) +;; (straight-use-package +;; (setq-local corfu-auto t +;; corfu-auto-delay 0.1 +;; corfu-auto-prefix 1 +;; completion-styles '(orderless basic)) + + +;; (global-set-key (kbd "") +;; (lambda () +;; (interactive) +;; (let ((company-tooltip-idle-delay 0.0)) +;; (company-complete) +;; (and company-candidates +;; (company-call-frontends 'post-command))))) +;; Enable fancy-dabbrev previews everywhere: +;; (global-fancy-dabbrev-mode) +;; (global-set-key [tab] #'fancy-dabbrev-expand-or-indent) +;; (global-set-key (kbd "") 'fancy-dabbrev-backward) +;; (require 'yasnippet) +;; (yas-global-mode 1) #+end_src ** Magit