diff options
| author | venomade <venomade@venomade.com> | 2026-04-08 15:07:12 +0100 |
|---|---|---|
| committer | venomade <venomade@venomade.com> | 2026-04-08 15:07:12 +0100 |
| commit | d422bc2b77ece72be1098bf05728275ef3306ee5 (patch) | |
| tree | 8b6b6f0da228dc99f36d91cf7841c425963e73f5 | |
| parent | a6543a0ba0e5399515e3dbe507a8bd12958839cc (diff) | |
Asahi Bugs - Forked GL is very annoying to deal with - Fairydust branch requires 8GB of RAM for display - AArch64 Linux is not very compatible with much software - DRM and other video related things are buggy/do not work - Updating can often break fairydust
37 files changed, 2538 insertions, 620 deletions
diff --git a/config/alacritty/alacritty.toml b/config/alacritty/alacritty.toml new file mode 100644 index 0000000..cb32c5f --- /dev/null +++ b/config/alacritty/alacritty.toml @@ -0,0 +1,23 @@ +[general] +import = ['~/.config/alacritty/modus-vivendi.toml'] + +[window] +padding = { x = 6, y = 6 } +dynamic_padding = true +title = 'Terminal' + +[font] +normal = { family = 'AporeticSansMonoNerdFont', style = 'Regular' } +size = 12 + +[selection] +save_to_clipboard = true + +[cursor] +style = { shape = 'Beam', blinking = 'On'} + +[terminal] +shell = '/home/venomade/.nix-profile/bin/zsh' + +[hints] +alphabet = 'neiotsradhwyfupl' diff --git a/config/alacritty/modus-vivendi.toml b/config/alacritty/modus-vivendi.toml new file mode 100644 index 0000000..20d13c1 --- /dev/null +++ b/config/alacritty/modus-vivendi.toml @@ -0,0 +1,28 @@ +# Colors Modus-Vivendi +[colors.normal] +black = '#1e1e1e' +red = '#ff5f59' +green = '#44bc44' +yellow = '#d0bc00' +blue = '#2fafff' +magenta = '#feacd0' +cyan = '#00d3d0' +white = '#ffffff' +[colors.bright] +black = '#535353' +red = '#ff7f9f' +green = '#00c06f' +yellow = '#dfaf7a' +blue = '#00bcff' +magenta = '#b6a0ff' +cyan = '#6ae4b9' +white = '#989898' +[colors.cursor] +cursor = '#ffffff' +text = '#000000' +[colors.primary] +background = '#000000' +foreground = '#ffffff' +[colors.selection] +background = '#5a5a5a' +text = '#ffffff' diff --git a/config/bat/config b/config/bat/config index 2d65ccf..b7de378 100644 --- a/config/bat/config +++ b/config/bat/config @@ -1 +1 @@ ---theme="modus_vivendi" +--theme="Catppuccin Mocha" diff --git a/config/emacs/config.org b/config/emacs/config.org index d0a2ce3..02c7bd0 100644 --- a/config/emacs/config.org +++ b/config/emacs/config.org @@ -1,26 +1,165 @@ #+TITLE: My Emacs Config #+AUTHOR: Venomade -This is my Emacs config that is theoretically going to be simpler than my previous configs. I have been trying out neovim more recently and I liked how simple it can be, giving it very quick startup times. I've tried the Emacs Daemon in the past but have never really jived with it so I would rather just have a fast launch time instead. The target is that `emacs-init-time` should be <2 seconds. - -* Non-Package Configuration -This section is the main non-package configuration of my Emacs config, everything here should be run before everything else in order to set up the basic environment for using packages. +This is my Emacs config. There are many like it, but this one is mine. According to my archive, it has been rewritten 10+ times since I wrote the first iteration in 2022. My general philosophy for this config is to not use external packages where the built in functionality is enough and any external packages used should follow the Emacs philosophy and design style and not duplicate functionality as much as reasonably possible. In this vein I use *Eglot* and *Corfu* instead of *LSP-Mode* and *Company* as an example of this philosophy. Not all code written in this configuration is my own, though most of it is, with the rest being made up of other people's configs, stack overflow snippets and code from various blog sites from other Emacs users including [[https://xenodium.com][Xenodium]], [[http://www.xahlee.info/][Xah Lee]] and [[https://systemcrafters.net/][System Crafters]]. + +* Table of Contents +:PROPERTIES: +:TOC: :include all :ignore this :depth 2 +:END: +:CONTENTS: +- [[#bootstrap][Bootstrap]] + - [[#package-manager][Package Manager]] + - [[#native-compilation][Native Compilation]] + - [[#garbage-collection][Garbage Collection]] + - [[#shell-path][Shell Path]] + - [[#custom-file][Custom File]] + - [[#file-hygiene][File Hygiene]] + - [[#suppress-noise][Suppress Noise]] + - [[#macos][MacOS]] +- [[#appearance][Appearance]] + - [[#theme][Theme]] + - [[#font-configuration][Font Configuration]] + - [[#mode-line][Mode Line]] + - [[#icons][Icons]] + - [[#highlight-changes][Highlight Changes]] + - [[#highlight-keywords][Highlight Keywords]] + - [[#highlight-and-dim-parentheses][Highlight and Dim Parentheses]] + - [[#pretty-symbols][Pretty Symbols]] + - [[#window-focus-flash][Window Focus Flash]] +- [[#ui-behaviour][UI Behaviour]] + - [[#frame-and-window][Frame and Window]] + - [[#line-numbers][Line Numbers]] + - [[#scrolling][Scrolling]] + - [[#line-wrapping][Line Wrapping]] + - [[#keybinding-help][Keybinding Help]] + - [[#compilation][Compilation]] + - [[#zen-mode][Zen Mode]] +- [[#editing-behaviour][Editing Behaviour]] + - [[#indentation][Indentation]] + - [[#smart-line-beginning][Smart Line Beginning]] + - [[#open-line][Open Line]] + - [[#replace-selection][Replace Selection]] + - [[#trailing-whitespace][Trailing Whitespace]] + - [[#move-lines][Move Lines]] + - [[#delimiter-pairing][Delimiter Pairing]] + - [[#undo-history][Undo History]] + - [[#short-answers][Short Answers]] + - [[#quit-confirmation][Quit Confirmation]] +- [[#session-and-navigation][Session and Navigation]] + - [[#recent-files][Recent Files]] + - [[#save-position][Save Position]] + - [[#minibuffer-history][Minibuffer History]] + - [[#dired][Dired]] + - [[#buffer-list][Buffer List]] + - [[#project-management][Project Management]] + - [[#eshell][EShell]] + - [[#info-pages][Info Pages]] +- [[#completion-and-lsp][Completion and LSP]] + - [[#completion-style][Completion Style]] + - [[#minibuffer-completion][Minibuffer Completion]] + - [[#completion-annotations][Completion Annotations]] + - [[#consult][Consult]] + - [[#in-buffer-completion][In-Buffer Completion]] + - [[#snippets][Snippets]] + - [[#completion-extensions][Completion Extensions]] + - [[#lsp-client][LSP Client]] + - [[#lsp-booster][LSP Booster]] + - [[#lsp-transient-menu][LSP Transient Menu]] + - [[#documentation-popups][Documentation Popups]] + - [[#diagnostics][Diagnostics]] +- [[#org-mode][Org Mode]] + - [[#core-configuration][Core Configuration]] + - [[#heading-bullets][Heading Bullets]] + - [[#org-tempo-snippets][Org Tempo Snippets]] + - [[#link-behaviour][Link Behaviour]] + - [[#tables-of-contents][Tables of Contents]] + - [[#disable-auto-indent][Disable Auto-Indent]] +- [[#language-support][Language Support]] + - [[#lua][Lua]] + - [[#nix][Nix]] + - [[#cc][C/C++]] + - [[#emacs-lisp][Emacs Lisp]] + - [[#common-lisp][Common Lisp]] + - [[#fennel][Fennel]] + - [[#markdown-notes][Markdown Notes]] +- [[#keybindings][Keybindings]] +:END: + +* Bootstrap +:PROPERTIES: +:CUSTOM_ID: bootstrap +:END: +** Package Manager +:PROPERTIES: +:CUSTOM_ID: package-manager +:END: +Setup =use-package= and [[https://melpa.org/][Melpa]], the community Emacs package repository. +#+begin_src emacs-lisp + (require 'package) + (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) + (package-initialize) +#+end_src -** Internal +** Native Compilation +:PROPERTIES: +:CUSTOM_ID: native-compilation +:END: +Setup Native Compilation if available. #+begin_src emacs-lisp - ;; Setup Native Compilation if available (if (native-comp-available-p) (setq package-native-compile t)) +#+end_src - ;; Disable the command key on MacOS - (setq mac-command-modifier nil) +** Garbage Collection +:PROPERTIES: +:CUSTOM_ID: garbage-collection +:END: +Improve Emacs' garbage collection by increasing the garbage size and collecting when idle. +*Packages*: =gcmh= by [[https://web.archive.org/web/20250808164421/https://akrl.sdf.org/][Andrea Corallo]] +#+begin_src emacs-lisp + (use-package gcmh + :ensure t + :hook (after-init . gcmh-mode) + :config + (setq gcmh-high-cons-threshold (* 128 1024 1024) ; 128MB + gcmh-idle-delay 10 + gcmh-verbose nil)) +#+end_src - ;; Use a custom.el file instead of init.el to store uncommitable changes +** Shell Path +:PROPERTIES: +:CUSTOM_ID: shell-path +:END: +Append to the =exec-path= variable paths that are set in the =zsh= shell. +#+begin_src emacs-lisp + (use-package exec-path-from-shell + :ensure t + :config + (setq exec-path-from-shell-shell-name "/bin/zsh" + exec-path-from-shell-arguments '("-l" "-i" "-c")) + (when (memq window-system '(mac ns x)) + (exec-path-from-shell-initialize))) +#+end_src + +** Custom File +:PROPERTIES: +:CUSTOM_ID: custom-file +:END: +Use a =custom.el= file instead of the =init.el= to store uncommitable, device-local changes. +#+begin_src emacs-lisp (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) + (when (file-exists-p custom-file) (load custom-file)) +#+end_src - ;; Set Backups, Autosaves and Lockfiles to all be stored in the .emacs.d directory +** File Hygiene +:PROPERTIES: +:CUSTOM_ID: file-hygiene +:END: +Store backups, autosaves and lockfiles in the =.emacs.d= directory. +#+begin_src emacs-lisp (let* ((backup-dir (expand-file-name "backups/" user-emacs-directory)) (autosave-dir (expand-file-name "autosaves/" user-emacs-directory)) (lock-dir (expand-file-name "lock/" user-emacs-directory))) @@ -31,135 +170,217 @@ This section is the main non-package configuration of my Emacs config, everythin (setq backup-directory-alist `((".*" . ,(directory-file-name backup-dir))) auto-save-file-name-transforms `((".*" ,(directory-file-name autosave-dir) t)) lock-file-name-transforms `((".*" ,(directory-file-name lock-dir) t)))) +#+end_src - ;; Don't show Warning and Compile-Log buffers in a window +** Suppress Noise +:PROPERTIES: +:CUSTOM_ID: suppress-noise +:END: +Don't show =*Warnings*= and =*Compile-Log*= buffers in a window. +#+begin_src emacs-lisp (add-to-list 'display-buffer-alist '("\\`\\*\\(Warnings\\|Compile-Log\\)\\*\\'" (display-buffer-no-window) (allow-no-window . t))) - - ;; Use 'trash' to trash system files instead of permanently rm-ing - (setq trash-directory "~/.Trash") - (defun system-move-file-to-trash (file) - "Use \"trash\" to move FILE to the system trash." - (cl-assert (executable-find "trash") nil "'trash' executable not found.") - (call-process "trash" nil 0 nil "-F" file)) #+end_src -** User Interface +** MacOS +:PROPERTIES: +:CUSTOM_ID: macos +:END: +Settings specific for use on MacOS. +*** Disable Command Key +:PROPERTIES: +:CUSTOM_ID: disable-command-key +:END: +Disable the command key on MacOS. #+begin_src emacs-lisp - ;; Allow any size of the Emacs GUI - (setq frame-resize-pixelwise t - ;; Configure line numbers display - display-line-numbers-width-start t - display-line-numbers-width 4 - display-line-numbers-grow-only t - ;; Disable bell - ring-bell-function 'ignore - ;; Confirm on C-x C-c - ns-confirm-quit t - ;; Don't open files opened from an external source in a new frame - ns-pop-up-frames nil - ;; Add a scroll margin and improve scrolling - scroll-margin 10 ; Doesn't work with smooth-scrolling - scroll-conservatively 100 - scroll-step 1) - - ;; Default to no wrapping on buffers - (setq-default truncate-lines t) - - ;; Replace the $ signs for truncation with spaces - (set-display-table-slot standard-display-table 'truncation 32) + (setq mac-command-modifier nil) +#+end_src - ;; Disable extra GUI interfaces - (tool-bar-mode -1) - (scroll-bar-mode -1) - (menu-bar-mode -1) +*** Matching Titlebar +:PROPERTIES: +:CUSTOM_ID: matching-titlebar +:END: +Match the titlebar to the current theme on MacOS. +*Packages*: =ns-auto-titlebar= by [[https://github.com/purcell/ns-auto-titlebar][Steve Purcell]] +#+begin_src emacs-lisp + (use-package ns-auto-titlebar + :ensure t + :config + (when (eq system-type 'darwin) (ns-auto-titlebar-mode))) +#+end_src - ;; Display line numbers from startup - (add-hook 'emacs-startup-hook #'global-display-line-numbers-mode) +*** Block Pop-Ups +:PROPERTIES: +:CUSTOM_ID: block-pop-ups +:END: +Don't open files opened from an external source in a new frame on MacOS. +#+begin_src emacs-lisp + (setq ns-pop-up-frames nil) +#+end_src - ;; Focus new frames on creation - (add-hook 'after-make-frame-functions - (lambda (f) - (select-frame-set-input-focus f))) +* Appearance +:PROPERTIES: +:CUSTOM_ID: appearance +:END: +** Theme +:PROPERTIES: +:CUSTOM_ID: theme +:END: +Use the =ef-dream= for a comfortable readable experience . +*Packages*: =ef-themes= by [[https://protesilaos.com/emacs/ef-themes][Protesilaos]] +#+begin_src emacs-lisp + (use-package ef-themes + :ensure t + :config + (ef-themes-take-over-modus-themes-mode 1)) - ;; Custom quit messages from DOOM and DOOM Emacs - (setq quit-messages - `(; from DOOM 1 - ,(format "I wouldn't leave if I were you. %s is much worse." - (if (featurep 'windows-nt) "DOS" "UNIX")) - "Ya know, next time you come in here I'm gonna toast ya." - "Go ahead and leave. See if I care." - "Are you sure you want to quit this great editor?" - ; from DOOM Emacs - "(setq nothing t everything 'permitted)" - "Emacs will remember that." - "Emacs, Emacs never changes." - "Hey! Hey, M-x listen!" - "Wake up, Mr. Stallman. Wake up and smell the ashes." - "You are *not* prepared!" - "Please don't go. The drones need you. They look up to you.")) + (setq modus-themes-italic-constructs t + modus-themes-bold-constructs t) - (defun random-quit-message () - "Return a randomly chosen quit message from `quit-messages'." - (nth (random (length quit-messages)) quit-messages)) + (load-theme 'ef-dream t) +#+end_src - (defun message-confirm-kill-emacs (&rest _) - "Prompt the user with a random message before quitting. - Returns t to allow kill if the user answers yes; nil otherwise." - (let* ((msg (random-quit-message)) - (prompt (format "%s Really quit Emacs? " msg))) - (yes-or-no-p (propertize prompt 'face '(italic default))))) +** Font Configuration +:PROPERTIES: +:CUSTOM_ID: font-configuration +:END: +Setup both =monospace= and =variable-pitch= fonts along with their sizes in =org-mode=. +#+begin_src emacs-lisp + (defun font-setup (&optional frame) + (with-selected-frame (or frame (selected-frame)) + + (let* ((fontconf '((fixed-font . "MonofurNerdFont") + (variable-font . "MonofurNerdFont") + (size . 13))) + (fixed-font (cdr (assoc 'fixed-font fontconf))) + (variable-font (cdr (assoc 'variable-font fontconf))) + (pt-size (cdr (assoc 'size fontconf))) + (height (* pt-size 10)) + (frame-font (concat fixed-font "-" (number-to-string pt-size)))) + ; Fixed-width faces + (dolist (face '(default fixed-pitch)) + (set-face-attribute face nil + :font fixed-font + :height height + :weight 'regular)) + ; Variable-pitch face + (set-face-attribute 'variable-pitch nil + :font variable-font + :height height + :weight 'regular) + + ; Syntax styling + (set-face-attribute 'font-lock-comment-face nil :slant 'italic) + (set-face-attribute 'font-lock-keyword-face nil :slant 'italic) + + ; Frame font + (add-to-list 'default-frame-alist `(font . ,frame-font))) + + + (let* ((variable-tuple + (cond ((x-list-fonts "Google Sans") '(:font "Google Sans")) + ((x-family-fonts "Sans Serif") '(:family "Sans Serif")) + (nil (warn "Cannot find a Sans Serif Font. Install Google Sans.")))) + (base-font-color (face-foreground 'default nil 'default)) + (headline `(:inherit default :weight bold :foreground ,base-font-color))) + + ; TODO: Split these up + (custom-theme-set-faces + 'user + `(org-level-8 ((t (,@headline ,@variable-tuple)))) + `(org-level-7 ((t (,@headline ,@variable-tuple)))) + `(org-level-6 ((t (,@headline ,@variable-tuple)))) + `(org-level-5 ((t (,@headline ,@variable-tuple)))) + `(org-level-4 ((t (,@headline ,@variable-tuple :height 1.0)))) + `(org-level-3 ((t (,@headline ,@variable-tuple :height 1.2)))) + `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.4)))) + `(org-level-1 ((t (,@headline ,@variable-tuple :height 1.6)))) + `(org-document-title ((t (,@headline ,@variable-tuple :height 1.8 :underline nil)))))))) + (if (daemonp) + (add-hook 'after-make-frame-functions #'font-setup) + (font-setup)) + + ; Theme the fonts and styles for various org elements + (custom-theme-set-faces + 'user + '(org-block ((t (:inherit fixed-pitch)))) + '(org-code ((t (:inherit (shadow fixed-pitch))))) + '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch))))) + '(org-indent ((t (:inherit (org-hide fixed-pitch))))) + '(org-link ((t (:foreground "#89b4fa" :underline t)))) + '(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch))))) + '(org-property-value ((t (:inherit fixed-pitch))) t) + '(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch))))) + '(org-table ((t (:inherit fixed-pitch)))) + '(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8)))) + '(org-verbatim ((t (:inherit (shadow fixed-pitch)))))) +#+end_src - (setq confirm-kill-emacs #'message-confirm-kill-emacs) +** Mode Line +:PROPERTIES: +:CUSTOM_ID: mode-line +:END: +Use a much more readable modeline compared to the default. +*Packages*: =doom-modeline= from [[https://seagle0128.github.io/doom-modeline/][Centaur Emacs]] +#+begin_src emacs-lisp + (use-package doom-modeline + :ensure t + :hook (after-init . doom-modeline-mode) + :config + (setq doom-modeline-icon t + doom-modeline-height 0 ; minimum + doom-modeline-bar-width 0 ; disabled + doom-modeline-project-detection 'project ; use project.el + doom-modeline-buffer-state-icon nil + doom-modeline-highlight-modified-buffer-name nil + doom-modeline-percent-position nil + line-number-mode nil + doom-modeline-buffer-encoding nil + doom-modeline-time-live-icon nil + doom-modeline-time-icon nil + display-time-default-load-average nil + display-time-format "%a %d %b | %R" + helm-ag-show-status-function nil)) ;HACK: Doom Modeline checks for this even though I don't use helm +#+end_src - ;; Enable which-key on startup - (add-hook 'emacs-startup-hook #'which-key-mode) +** Icons +:PROPERTIES: +:CUSTOM_ID: icons +:END: +Make use of the [[https://www.nerdfonts.com/][Nerd Fonts]] to show icons in Emacs. +*Packages*: =nerd-icons=, =nerd-icons-dired= and =nerd-icons-completion= by [[https://github.com/rainstormstudio/nerd-icons.el][Daniel Ding]] and =nerd-icons-ibuffer= from [[https://github.com/seagle0128/nerd-icons-ibuffer][Centaur Emacs]] +#+begin_src emacs-lisp + (use-package nerd-icons + :ensure t + :if (display-graphic-p)) - ;; Disable line numbers in fundamental mode - (let ((no-numbers-modes '(fundamental-mode-hook))) - (dolist (hk no-numbers-modes) - (add-hook hk (lambda () (display-line-numbers-mode 0))))) + (use-package nerd-icons-dired + :ensure t + :after nerd-icons + :hook + (dired-mode . nerd-icons-dired-mode)) - ;; Colorise the compile-mode buffer - (require 'ansi-color) - (defun colorize-compilation-buffer () - (ansi-color-apply-on-region compilation-filter-start (point))) - (add-hook 'compilation-filter-hook 'colorize-compilation-buffer) + (use-package nerd-icons-completion + :ensure t + :after nerd-icons + :hook + (after-init . nerd-icons-completion-mode)) - ;; Shorten symbols into their single character equivalent - (global-prettify-symbols-mode 1) + (use-package nerd-icons-ibuffer + :ensure t + :after nerd-icons + :hook (ibuffer-mode . nerd-icons-ibuffer-mode)) +#+end_src - ;; Font Setup - (let* ((fontconf '((fixed-font . "AporeticSansMonoNerdFont") - (variable-font . "Google Sans") - (size . 16))) - (fixed-font (cdr (assoc 'fixed-font fontconf))) - (variable-font (cdr (assoc 'variable-font fontconf))) - (pt-size (cdr (assoc 'size fontconf))) - (height (* pt-size 10)) - (frame-font (concat fixed-font "-" (number-to-string pt-size)))) - ; Fixed-width faces - (dolist (face '(default fixed-pitch)) - (set-face-attribute face nil - :font fixed-font - :height height - :weight 'regular)) - ; Variable-pitch face - (set-face-attribute 'variable-pitch nil - :font variable-font - :height height - :weight 'regular) - - ; Syntax styling - (set-face-attribute 'font-lock-comment-face nil :slant 'italic) - (set-face-attribute 'font-lock-keyword-face nil :slant 'italic) - - ; Frame font - (add-to-list 'default-frame-alist `(font . ,frame-font))) - - ;; Spacious user interface elements +** COMMENT Padding and Spacing +:PROPERTIES: +:CUSTOM_ID: padding-and-spacing +:END: +Spacious user interface elements with custom widths and colours. +*Packages*: =spacious-padding= by [[https://protesilaos.com/emacs/spacious-padding][Protesilaos]] +#+begin_src emacs-lisp (use-package spacious-padding :ensure t :hook (after-init . spacious-padding-mode) @@ -178,26 +399,274 @@ This section is the main non-package configuration of my Emacs config, everythin :mode-line-inactive spacious-padding-line-inactive :header-line-active spacious-padding-line-active :header-line-inactive spacious-padding-line-inactive))) +#+end_src + +** Highlight Changes +:PROPERTIES: +:CUSTOM_ID: highlight-changes +:END: +Temporarily highlight modified regions to help the visual transition when making large changes via =undo= or =kill-region=. +*Packages*: =goggles= by [[https://github.com/minad/goggles][Daniel Mendler]] +#+begin_src emacs-lisp + (use-package goggles + :ensure t + :hook ((prog-mode text-mode) . goggles-mode) + :config + (setq-default goggles-pulse t)) +#+end_src + +** Highlight Keywords +:PROPERTIES: +:CUSTOM_ID: highlight-keywords +:END: +Highlight actionable keywords such as =TODO=, =FIXME= and =ERROR=. +*Packages*: =hl-todo= by [[https://github.com/tarsius/hl-todo][Jonas Bernoulli]] +#+begin_src emacs-lisp + (use-package hl-todo + :ensure t + :hook ((org-mode . hl-todo-mode) + (prog-mode . hl-todo-mode)) + :config + (add-to-list 'hl-todo-keyword-faces '("ERROR" . "#8c5353"))) +#+end_src + +** COMMENT Rainbow Delimiters +Colour brackets and other delimiters to improve visual grepping of scope while programming. +*Packages*: =rainbow-delimiters= by [[https://github.com/Fanael/rainbow-delimiters][Fanael Linithien]] +#+begin_src emacs-lisp + (use-package rainbow-delimiters + :ensure t + :hook (prog-mode . rainbow-delimiters-mode)) +#+end_src + +** Highlight and Dim Parentheses +:PROPERTIES: +:CUSTOM_ID: highlight-and-dim-parentheses +:END: +For =lisp= modes, highlight parentheses that are local to the current point with decreasing brightness the less local they are, and set all parentheses to be dim in these modes by default. +*Packages*: =highlight-parentheses= by [[https://sr.ht/~tsdh/highlight-parentheses.el/][Tassilo Horn]] +#+begin_src emacs-lisp + (use-package highlight-parentheses + :ensure t + :custom + (hl-paren-colors '("white" "#cccccc" "#999999" "#666666" "#444444")) + (hl-paren-background-colors '(nil nil nil nil nil)) + :config + (set-face-attribute 'hl-paren-face nil :weight 'bold)) + + (defface dim-parens-face + '((t :foreground "#666666")) + "Face for dimmed parentheses.") + + (defun dim-parens--enable () + (font-lock-add-keywords + nil + '(("[()]" 0 'dim-parens-face t)) + 'append) + (font-lock-flush) + (highlight-parentheses-mode 1)) + + (defun dim-parens--disable () + (font-lock-remove-keywords + nil + '(("[()]" 0 'dim-parens-face t))) + (font-lock-flush) + (highlight-parentheses-mode -1)) + + (define-minor-mode dim-parens-mode + "Dim all parens, highlighting the enclosing pair at point." + :lighter " DimP" + (if dim-parens-mode + (dim-parens--enable) + (dim-parens--disable))) +#+end_src + +** Pretty Symbols +:PROPERTIES: +:CUSTOM_ID: pretty-symbols +:END: +Shorten symbols into their single character equivalent. +#+begin_src emacs-lisp + (global-prettify-symbols-mode 1) +#+end_src + +** Window Focus Flash +:PROPERTIES: +:CUSTOM_ID: window-focus-flash +:END: +Flash between windows when switching to make obvious which window is active. +*Packages*: =winpulse= by [[https://xenodium.com/introducing-winpulse][Álvaro Ramírez (Xenodium)]] +#+begin_src emacs-lisp + (use-package winpulse + :vc (:url "https://github.com/xenodium/winpulse" + :rev :newest) + :config + (winpulse-mode +1)) +#+end_src + +* UI Behaviour +:PROPERTIES: +:CUSTOM_ID: ui-behaviour +:END: +** Frame and Window +:PROPERTIES: +:CUSTOM_ID: frame-and-window +:END: +*** Resize GUI +:PROPERTIES: +:CUSTOM_ID: resize-gui +:END: +Allow any size to be set for the Emacs GUI. +#+begin_src emacs-lisp + (setq frame-resize-pixelwise t) +#+end_src + +*** Focus Frames +:PROPERTIES: +:CUSTOM_ID: focus-frames +:END: +Focus new frames when they're created. +#+begin_src emacs-lisp + (add-hook 'after-make-frame-functions + (lambda (f) + (select-frame-set-input-focus f))) +#+end_src + +*** Disable Default Annoyances +:PROPERTIES: +:CUSTOM_ID: disable-default-annoyances +:END: +Disable the Bell and other unwanted GUI features. +#+begin_src emacs-lisp + (setq ring-bell-function 'ignore) + + (tool-bar-mode -1) + (scroll-bar-mode -1) + (menu-bar-mode -1) +#+end_src + +** Line Numbers +:PROPERTIES: +:CUSTOM_ID: line-numbers +:END: +Configure line numbers display width and resizing, and display them from startup unless in =fundamental-mode= or =text-mode=. +#+begin_src emacs-lisp + (setq display-line-numbers-width-start t + display-line-numbers-width 4 + display-line-numbers-grow-only t) + + (add-hook 'emacs-startup-hook #'global-display-line-numbers-mode) + + (dolist (hk '(fundamental-mode-hook text-mode-hook Info-mode-hook)) + (add-hook hk (lambda () (display-line-numbers-mode -1)))) +#+end_src + +** Scrolling +:PROPERTIES: +:CUSTOM_ID: scrolling +:END: +Add a scroll margin and improve scrolling. +#+begin_src emacs-lisp + (setq scroll-margin 10 + scroll-conservatively 100 + scroll-step 1) +#+end_src + +** Line Wrapping +:PROPERTIES: +:CUSTOM_ID: line-wrapping +:END: +Set the default to not wrap long lines but truncate with spaces. Enable it explicitly in =text-mode=. +#+begin_src emacs-lisp + (setq-default truncate-lines t) + + (set-display-table-slot standard-display-table 'truncation 32) - ;; Enable line wrapping for text documents (add-hook 'text-mode-hook 'visual-line-mode) - ;; Disable line numbers in text mode - (add-hook 'text-mode-hook (lambda () (display-line-numbers-mode -1))) #+end_src -** Functionality +** Keybinding Help +:PROPERTIES: +:CUSTOM_ID: keybinding-help +:END: +Enable =which-key= on startup. +#+begin_src emacs-lisp + (add-hook 'emacs-startup-hook #'which-key-mode) +#+end_src + +** Compilation +:PROPERTIES: +:CUSTOM_ID: compilation +:END: +Configure =compile-mode= by colourising it, having it scroll on compilation output and allow files and projects to set their own compile-commands. +#+begin_src emacs-lisp + (require 'ansi-color) + + (defun colorize-compilation-buffer () + (ansi-color-apply-on-region compilation-filter-start (point))) + (add-hook 'compilation-filter-hook 'colorize-compilation-buffer) + + (setq compilation-scroll-output t) + + (put 'compile-command 'safe-local-variable #'stringp) +#+end_src + +** Zen Mode +:PROPERTIES: +:CUSTOM_ID: zen-mode +:END: +Centre the buffer and disable line numbers for a calmer writing experience. +*Packages*: =olivetti= by [[https://github.com/rnkn/olivetti][Paul W. Rankin]] +#+begin_src emacs-lisp + (use-package olivetti + :ensure t + :config + ; TODO: Disable line numbers, probably in the line numbers section, but probably try and link the sections somehow + (setq olivetti-minimum-body-width 100)) +#+end_src + +* Editing Behaviour +:PROPERTIES: +:CUSTOM_ID: editing-behaviour +:END: +** Indentation +:PROPERTIES: +:CUSTOM_ID: indentation +:END: +Indent code with 2 spaces by default. #+begin_src emacs-lisp - ;; Indent with spaces (setq-default indent-tabs-mode nil - ;; Use 2 spaces tab-width 2 tab-stop-list (number-sequence 2 100 2) c-basic-offset 2) +#+end_src - ;; Regex find and replace shortcut - (keymap-global-set "C-c r" 'replace-regexp) +** Smart Line Beginning +:PROPERTIES: +:CUSTOM_ID: smart-line-beginning +:END: +Override the built-in =beginning-of-line= function to give respect to context when making the movement. +#+begin_src emacs-lisp + (progn + (defun smart-beginning-of-line () + "Move the cursor to the beginning of text on the line." + (interactive) + (let ((initial-point (point))) + (back-to-indentation) + (when (eq initial-point (point)) + (move-beginning-of-line 1)))) + (defun setup-prog-mode-c-a () + (local-set-key (kbd "C-a") 'smart-beginning-of-line)) + (add-hook 'prog-mode-hook 'setup-prog-mode-c-a) + (add-hook 'conf-mode-hook 'setup-prog-mode-c-a)) +#+end_src - ;; Functions to match vi's 'o' and 'O' +** Open Line +:PROPERTIES: +:CUSTOM_ID: open-line +:END: +Functions to match vi's '=o=' and '=O=' motions, this helps to bypass whatever function is called on the =Return= key. +#+begin_src emacs-lisp (cl-labels ((vi-open-line-above () "Open line above the current line." @@ -211,41 +680,178 @@ This section is the main non-package configuration of my Emacs config, everythin (interactive) (unless (eolp) (end-of-line)) (newline-and-indent))) + ; TODO: Move to keybindings section (define-key (current-global-map) (kbd "C-c o") #'vi-open-line-above) (define-key (current-global-map) (kbd "C-c O") #'vi-open-line-below) (which-key-add-key-based-replacements "C-c o" "open-line-above") (which-key-add-key-based-replacements "C-c O" "open-line-below")) +#+end_src - ;; Move to the beginning of the line with respect to context - (progn - (defun smart-beginning-of-line () - "Move the cursor to the beginning of text on the line." - (interactive) - (let ((initial-point (point))) - (back-to-indentation) - (when (eq initial-point (point)) - (move-beginning-of-line 1)))) - (defun setup-prog-mode-c-a () - (local-set-key (kbd "C-a") 'smart-beginning-of-line)) - (add-hook 'prog-mode-hook 'setup-prog-mode-c-a) - (add-hook 'conf-mode-hook 'setup-prog-mode-c-a)) +** Replace Selection +:PROPERTIES: +:CUSTOM_ID: replace-selection +:END: +Overwrite selection when typing while a selection is active. +#+begin_src emacs-lisp + (use-package delsel + :hook (after-init . delete-selection-mode)) +#+end_src - ;; Clean up trailing whitespace +** Trailing Whitespace +:PROPERTIES: +:CUSTOM_ID: trailing-whitespace +:END: +Clean up trailing whitespace on save. +#+begin_src emacs-lisp (progn (defun prog-nuke-trailing-whitespace () "Removes trailing whitespace at the end of the line." (when (or (derived-mode-p 'prog-mode) (derived-mode-p 'conf-mode)) (delete-trailing-whitespace))) (add-hook 'before-save-hook 'prog-nuke-trailing-whitespace)) +#+end_src - ;; Enable overwriting selection with the built-in delsel package - (use-package delsel - :hook (after-init . delete-selection-mode)) +** Move Lines +:PROPERTIES: +:CUSTOM_ID: move-lines +:END: +Move text up and down with a single keybind. +*Packages*: =move-text= by [[https://github.com/emacsfodder/move-text][Jason Milkins at Emacs Fodder]] +#+begin_src emacs-lisp + (use-package move-text + :ensure t + :config + (defun indent-region-advice (&rest ignored) + (let ((deactivate deactivate-mark)) + (if (region-active-p) + (indent-region (region-beginning) (region-end)) + (indent-region (line-beginning-position) (line-end-position))) + (setq deactivate-mark deactivate))) + + (advice-add 'move-text-up :after 'indent-region-advice) + (advice-add 'move-text-down :after 'indent-region-advice)) +#+end_src - ;; Use y/n and other similar shortenings for dialogue response +** Delimiter Pairing +:PROPERTIES: +:CUSTOM_ID: delimiter-pairing +:END: +Insert matching delimiters using the keybindings from =paredit=. +*Packages*: =smartparens= by [[https://github.com/Fuco1/smartparens][Matus Goljer]] +#+begin_src emacs-lisp + (use-package smartparens + :ensure t + :hook (prog-mode text-mode markdown-mode comint-mode) + :config + (require 'smartparens-config) + (sp-use-paredit-bindings)) +#+end_src + +** Undo History +:PROPERTIES: +:CUSTOM_ID: undo-history +:END: +Make the undo history persistent between sessions and create multi-branch undo history. +*Packages*: =undo-tree= by [[https://www.dr-qubit.org/undo-tree.html][Tony 'qubit' Cubitt]] +#+begin_src emacs-lisp + (use-package undo-tree + :ensure t + :init + (global-undo-tree-mode 1) + :config + (setq undo-tree-auto-save-history t + undo-tree-history-directory-alist `(("." . ,(expand-file-name ".cache" user-emacs-directory))))) +#+end_src + +** Short Answers +:PROPERTIES: +:CUSTOM_ID: short-answers +:END: +Use =y= / =n= and other similar shortenings for dialogue responses. +#+begin_src emacs-lisp (setopt use-short-answers t) +#+end_src + +** Quit Confirmation +:PROPERTIES: +:CUSTOM_ID: quit-confirmation +:END: +Ask for confirmation on =C-x C-c= before quitting using custom quit messages from the DOOM games and DOOM Emacs. +#+begin_src emacs-lisp + (setq quit-messages + `(; from DOOM 1 + ,(format "I wouldn't leave if I were you. %s is much worse." + (if (featurep 'windows-nt) "DOS" "UNIX")) + "Ya know, next time you come in here I'm gonna toast ya." + "Go ahead and leave. See if I care." + "Are you sure you want to quit this great editor?" + ; from DOOM 2 + "Get outta here and go back to your boring programs." + "Just leave. When you come back, I'll be waiting with a bat." + "You're lucky I don't smack you for thinking about leaving. " + ; from DOOM Emacs + "(setq nothing t everything 'permitted)" + "Emacs will remember that." + "Emacs, Emacs never changes." + "Hey! Hey, M-x listen!" + "Wake up, Mr. Stallman. Wake up and smell the ashes." + "You are *not* prepared!" + "Please don't go. The drones need you. They look up to you.")) + + (defun random-quit-message () + "Return a randomly chosen quit message from `quit-messages'." + (nth (random (length quit-messages)) quit-messages)) + + (defun message-confirm-kill-emacs (&rest _) + "Prompt the user with a random message before quitting. + Returns t to allow kill if the user answers yes; nil otherwise." + (let* ((msg (random-quit-message)) + (prompt (format "%s Really quit Emacs? " msg))) + (yes-or-no-p (propertize prompt 'face '(italic default))))) - ;; Configure the built-in file-manager dired + (setq confirm-kill-emacs #'message-confirm-kill-emacs) +#+end_src + +* Session and Navigation +:PROPERTIES: +:CUSTOM_ID: session-and-navigation +:END: + +** Recent Files +:PROPERTIES: +:CUSTOM_ID: recent-files +:END: +Keep track of recently accessed files with =recentf=. +#+begin_src emacs-lisp + (add-hook 'emacs-startup-hook #'recentf-mode) +#+end_src + +** Save Position +:PROPERTIES: +:CUSTOM_ID: save-position +:END: +Save the location of the cursor in files between sessions. +#+begin_src emacs-lisp + (add-hook 'emacs-startup-hook #'save-place-mode) +#+end_src + +** Minibuffer History +:PROPERTIES: +:CUSTOM_ID: minibuffer-history +:END: +Save the minibuffer history between sessions. +#+begin_src emacs-lisp + (use-package savehist + :hook (after-init . savehist-mode)) +#+end_src + +** Dired +:PROPERTIES: +:CUSTOM_ID: dired +:END: +Configure =dired-mode= so that directories are always copied and deleted recursively, target's for functions are intuited and all files are listed and display human readable metadata. Allow recursive expansion with =TAB= to easily travel directories. +*Packages*: =dired-subtree= by [[https://github.com/Fuco1/dired-hacks/blob/master/dired-subtree.el][Matus Goljer]] +#+begin_src emacs-lisp (use-package dired :commands (dired) :hook @@ -253,17 +859,59 @@ This section is the main non-package configuration of my Emacs config, everythin (dired-mode . hl-line-mode)) :config (setq dired-recursive-copies 'always - dired-recursive-deletes 'always - ; delete-by-moving-to-trash t ; FIXME: Currently Broken, need to find why + dired-recursive-deletes 'always dired-dwim-target t - insert-directory-program "~/.nix-profile/bin/ls" dired-listing-switches "-lah")) - ;; Return to last position after leaving a file - (add-hook 'emacs-startup-hook #'save-place-mode) + (use-package dired-subtree + :ensure t + :after dired + :bind + (:map dired-mode-map + ("TAB" . (lambda () (interactive) (dired-subtree-toggle) (revert-buffer))) + ("<backtab>" . dired-subtree-remove)) + :config + (setq dired-subtree-use-backgrounds nil)) +#+end_src - ;; Setup a pretty and useful eshell prompt - (progn +** Buffer List +:PROPERTIES: +:CUSTOM_ID: buffer-list +:END: +Group =project.el= projects together in the =ibuffer=. +*Packages*: =ibuffer-project= by [[https://github.com/muffinmad/emacs-ibuffer-project][Andrii Kolomoiets]] +#+begin_src emacs-lisp + (use-package ibuffer-project + :ensure t + :after project + :config + (add-hook + 'ibuffer-hook + (lambda () + (setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups)) + (unless (eq ibuffer-sorting-mode 'project-file-relative) + (ibuffer-do-sort-by-project-file-relative))))) +#+end_src + +** Project Management +:PROPERTIES: +:CUSTOM_ID: project-management +:END: +A transient menu interface for =project.el=. +*Packages*: =disproject= by [[https://github.com/aurtzy/disproject][aurtzy]] +#+begin_src emacs-lisp + (use-package disproject + :ensure t + :after project) +#+end_src + +** EShell +:PROPERTIES: +:CUSTOM_ID: eshell +:END: +Setup the =eshell= prompt to be both visually appealing and useful. +#+begin_src emacs-lisp + (progn ; TODO: Fix this, as is likely completely broken (No Colour) (dolist (spec '((eshell-prompt-user-face font-lock-keyword-face "Face for the username in the eshell prompt.") (eshell-prompt-venv-face font-lock-string-face "Face for the virtualenv name in the eshell prompt.") @@ -326,283 +974,91 @@ This section is the main non-package configuration of my Emacs config, everythin (setq eshell-prompt-function 'eshell-prompt eshell-prompt-regexp "^[^λ\n]*λ ")) - - ;; Bind recent files to C-x C-r - (add-hook 'emacs-startup-hook #'recentf-mode) - (keymap-global-set "C-x C-r" 'recentf-open) - (which-key-add-key-based-replacements "C-x C-r" "Recent Files") - (put 'compile-command 'safe-local-variable #'stringp) - - ;; Persistently save minibuffer history between sessions - (use-package savehist - :hook (after-init . savehist-mode)) - - ;; Local info files directory - (add-to-list 'Info-directory-list "/Users/venomade/Documents/Info/") - - ;; Scroll on compilation mode output - (setq compilation-scroll-output t) - - ;; Add keybinds for compiling - (keymap-global-set "C-c m c" 'compile) - (keymap-global-set "C-c m r" 'recompile) - (which-key-add-key-based-replacements "C-c m" "make") #+end_src -* Basic Package Configuration -This is the configuration for the necessary packages required for my base Emacs experience for all cases. - -** Setup +** Info Pages +:PROPERTIES: +:CUSTOM_ID: info-pages +:END: +Configuration for =Info-mode= to set the location for local info files. #+begin_src emacs-lisp - ;; Setup Melpa - (require 'package) - (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) - (package-initialize) + (add-to-list 'Info-directory-list (expand-file-name "~/Documents/Info/")) #+end_src -** Internal Packages +* Completion and LSP +:PROPERTIES: +:CUSTOM_ID: completion-and-lsp +:END: +** Completion Style +:PROPERTIES: +:CUSTOM_ID: completion-style +:END: +Make completion matching much more powerful. +*Packages*: =orderless= by [[https://github.com/oantolin/orderless][Omar Antolín Camarena]] #+begin_src emacs-lisp - ;; Improved Garbage Collection - (use-package gcmh - :ensure t - :hook (after-init . gcmh-mode) - :config - (setq gcmh-high-cons-threshold (* 128 1024 1024) ; 128MB - gcmh-idle-delay 10 - gcmh-verbose nil)) - - ;; Find executables that are usable from the specified shell - (use-package exec-path-from-shell + (use-package orderless :ensure t :config - (setq exec-path-from-shell-shell-name "/bin/zsh" - exec-path-from-shell-arguments '("-l" "-i" "-c")) - (when (memq window-system '(mac ns x)) - (exec-path-from-shell-initialize))) + (setq completion-styles '(orderless basic) + completion-category-defaults nil + completion-category-overrides '((file (styles . (partial-completion))) + (eglot (styles . (orderless)))))) #+end_src -** User Interface Packages +** Minibuffer Completion +:PROPERTIES: +:CUSTOM_ID: minibuffer-completion +:END: +Enable powerful minibuffer completion with fuzzy finding. +*Packages*: =vertico= by [[https://github.com/minad/vertico][Daniel Mendler]] #+begin_src emacs-lisp - ;; Catppuccin Color Theme - (use-package catppuccin-theme - :ensure t - :config - (setq catppuccin-flavor 'mocha) - (catppuccin-set-color 'base "#000000") - (catppuccin-set-color 'mantle "#181818") - (catppuccin-set-color 'crust "#111111") - (catppuccin-set-color 'overlay2 "#9B9B9B") - (catppuccin-set-color 'overlay1 "#858585") - (catppuccin-set-color 'overlay0 "#707070") - (catppuccin-set-color 'surface2 "#5C5C5C") - (catppuccin-set-color 'surface1 "#474747") - (catppuccin-set-color 'surface0 "#333333") - (catppuccin-reload) - (load-theme 'catppuccin t)) - - ;; Automatically match the titlebar to the theme - (use-package ns-auto-titlebar - :ensure t - :config - (when (eq system-type 'darwin) (ns-auto-titlebar-mode))) - - ;; More readable modeline from DOOM Emacs - (use-package doom-modeline - :ensure t - :hook (after-init . doom-modeline-mode) - :config - (setq doom-modeline-height 0 ; minimum - doom-modeline-bar-width 0 ; disabled - doom-modeline-project-detection 'project ; use project.el - doom-modeline-buffer-state-icon nil - doom-modeline-highlight-modified-buffer-name nil - doom-modeline-percent-position nil - line-number-mode nil - doom-modeline-buffer-encoding nil - doom-modeline-time-live-icon nil - doom-modeline-time-icon nil - display-time-default-load-average nil - display-time-format "%a %d %b | %R" - helm-ag-show-status-function nil)) ;HACK: Doom Modeline asks for this but I don't use helm - - ;; Icons for use with a nerd-font - (use-package nerd-icons - :ensure t - :if (display-graphic-p)) - - ;; Nerd Icons in the file manager - (use-package nerd-icons-dired - :ensure t - :after nerd-icons - :hook - (dired-mode . nerd-icons-dired-mode)) - - ;; Nerd Icons in the buffer menu - (use-package nerd-icons-ibuffer - :ensure t - :after nerd-icons - :hook (ibuffer-mode . nerd-icons-ibuffer-mode)) - - ;; Color brackets for visual grepping - (use-package rainbow-delimiters - :ensure t - :hook (prog-mode . rainbow-delimiters-mode)) - - ;; Highlight todo comments - (use-package hl-todo - :ensure t - :hook ((org-mode . hl-todo-mode) - (prog-mode . hl-todo-mode)) - :config - (add-to-list 'hl-todo-keyword-faces '("ERROR" . "#8c5353"))) - - ;; Highlight large changes - (use-package goggles - :ensure t - :hook ((prog-mode text-mode) . goggles-mode) - :config - (setq-default goggles-pulse t)) - - ;; Nicer view to manager project.el projects - (use-package disproject - :ensure t - :after project - :bind (:map ctl-x-map - ("p" . disproject-dispatch))) - - ;; Sort buffers by project in the buffer manager - (use-package ibuffer-project + (use-package vertico :ensure t - :after project - :config - (add-hook - 'ibuffer-hook - (lambda () - (setq ibuffer-filter-groups (ibuffer-project-generate-filter-groups)) - (unless (eq ibuffer-sorting-mode 'project-file-relative) - (ibuffer-do-sort-by-project-file-relative)))) - (keymap-global-set "C-x C-b" 'ibuffer)) + :hook (after-init . vertico-mode) + :bind (:map vertico-map + ("DEL" . vertico-directory-delete-char))) #+end_src -** Functionality Packages +** Completion Annotations +:PROPERTIES: +:CUSTOM_ID: completion-annotations +:END: +Give completions annotations to describe what a function does. +*Packages*: =marginalia= by [[https://github.com/minad/marginalia][Daniel Mendler]] #+begin_src emacs-lisp - ;; Move text up and down with a single keybind - (use-package move-text - :ensure t - :config - (keymap-global-set "M-p" 'move-text-up) - (keymap-global-set "M-n" 'move-text-down) - (defun indent-region-advice (&rest ignored) - (let ((deactivate deactivate-mark)) - (if (region-active-p) - (indent-region (region-beginning) (region-end)) - (indent-region (line-beginning-position) (line-end-position))) - (setq deactivate-mark deactivate))) - - (advice-add 'move-text-up :after 'indent-region-advice) - (advice-add 'move-text-down :after 'indent-region-advice)) - - ;; Automatically insert matching delimiters and jump between them - (use-package smartparens - :ensure t - :hook (prog-mode text-mode markdown-mode) - :config - (require 'smartparens-config) - (sp-use-paredit-bindings)) - - ;; Undo across history and across revisions - (use-package undo-tree - :ensure t - :init - (global-undo-tree-mode 1) - :config - (setq undo-tree-auto-save-history t - undo-tree-history-directory-alist `(("." . ,(expand-file-name ".cache" user-emacs-directory))))) - - ;; Insert accents with a menu - (use-package accent - :ensure t - :bind* (("C-'" . accent-menu)) - :config - (setq accent-diacritics '((a (á ã â à)) ; só para Português - (e (é ê)) - (i (í)) - (o (ó õ ô)) - (u (ú)) - (c (ç)) - (A (Á Ã Â À)) - (E (É Ê)) - (I (Í)) - (O (Ó Õ Ô)) - (U (Ú))))) - - ;; Allow recursive expansion in the dired file-manager - (use-package dired-subtree + (use-package marginalia :ensure t - :after dired - :bind - (:map dired-mode-map - ("TAB" . (lambda () (interactive) (dired-subtree-toggle) (revert-buffer))) - ("<backtab>" . dired-subtree-remove)) - :config - (setq dired-subtree-use-backgrounds nil)) + :after vertico consult nerd-icons + :hook + ((emacs-startup . marginalia-mode) + (marginalia-mode . nerd-icons-completion-marginalia-setup))) #+end_src -* Advanced Package Configuration -This configuration is for specific filetypes/languages and more advanced packages. It is sorted by module for easy enabling and disabling, and ordered by relevance to most modes. - -** Corfu Completion +** Consult +:PROPERTIES: +:CUSTOM_ID: consult +:END: +These packages provide replacements for built-in emacs functions that have support for completion. +*Packages*: =consult= by [[https://github.com/minad/consult][Daniel Mendler]] and =affe= also by [[https://github.com/minad/affe][Daniel Mendler]] #+begin_src emacs-lisp - ;; Make completion matching much more powerful - (use-package orderless - :ensure t - :config - (setq completion-styles '(orderless basic) - completion-category-defaults nil - completion-category-overrides '((file (styles . (partial-completion))) - (eglot (styles . (orderless)))))) - - ;; Snippet expansion allows for powerful multi-stage completion - (use-package yasnippet - :ensure t - :hook (prog-mode . yas-minor-mode) - :bind - (("C-c y n" . yas-new-snippet) - ("C-c y v" . yas-visit-snippet-file) - ("C-c y i" . yas-insert-snippet)) - :config - (yas-reload-all)) - - ;; Add some base snippets - (use-package yasnippet-snippets - :after yasnippet + (use-package consult :ensure t) - ;; Combiner for multiple completion backends - (use-package cape - :ensure t - :config - ;; TODO find out what the wrap buster actually does (caching or whatever) - (advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)) - - (use-package yasnippet-capf + (use-package affe :ensure t - :after cape) - - (defun eglot-capf-with-yasnippet () - (setq-local completion-at-point-functions - (list - (cape-capf-super - #'eglot-completion-at-point - #'yasnippet-capf)))) - (with-eval-after-load 'eglot - (add-hook 'eglot-managed-mode-hook #'eglot-capf-with-yasnippet)) + :after consult) +#+end_src - ;; The fast completion menu +** In-Buffer Completion +:PROPERTIES: +:CUSTOM_ID: in-buffer-completion +:END: +Lightweight completion popup package for an improved auto-completion experience along with Nerd Font icons for symbol representation. +*Packages*: =corfu= by [[https://github.com/minad/corfu][Daniel Mendler]] and =nerd-icons-corfu= by [[https://github.com/LuigiPiucco/nerd-icons-corfu][Luigi Sartor Piucco]] +#+begin_src emacs-lisp (use-package corfu :ensure t - :hook ((prog-mode . corfu-mode) - (eshell-mode . corfu-mode)) + :hook (prog-mode eshell-mode markdown-mode comint-mode) :bind (:map corfu-map ("TAB" . corfu-insert) ("<tab>" . corfu-insert) @@ -635,105 +1091,125 @@ This configuration is for specific filetypes/languages and more advanced package (add-to-list 'corfu-margin-formatters #'nerd-icons-corfu-formatter)) #+end_src -** Miscellaneous Completion +** Snippets +:PROPERTIES: +:CUSTOM_ID: snippets +:END: +Snippet expansion with powerful multi-stage completion along with a collection of common snippets. +*Packages*: =yasnippet= by [[https://joaotavora.github.io/yasnippet/][João Távora]] and =yasnippet-snippets= by [[https://github.com/AndreaCrotti/yasnippet-snippets][Andrea Crotti]] #+begin_src emacs-lisp - ;; Powerful minibuffer completion - (use-package vertico - :ensure t - :hook (after-init . vertico-mode) - :bind (:map vertico-map - ("DEL" . vertico-directory-delete-char))) - - ;; Powerful completion replacements for various other emacs functions - (use-package consult + (use-package yasnippet :ensure t - :bind (("M-g g" . consult-goto-line) - ("M-g M-g" . consult-goto-line) - ("C-c s" . consult-line)) - + :hook (prog-mode . yas-minor-mode) :config - (which-key-add-key-based-replacements "C-c s" "search-lines")) + (yas-reload-all)) - ;; Powerful completion replacements for find-style emacs functions - (use-package affe - :ensure t - :after consult - :bind (("C-c f f" . affe-find) - ("C-c f g" . affe-grep)) - :init - (which-key-add-key-based-replacements "C-c f" "find-file") - (which-key-add-key-based-replacements "C-c f f" "find-fuzzy") - (which-key-add-key-based-replacements "C-c f g" "find-greppy")) + (use-package yasnippet-snippets + :after yasnippet + :ensure t) +#+end_src - ;; Add descriptive annotations to minibuffer completions - (use-package marginalia +** Completion Extensions +:PROPERTIES: +:CUSTOM_ID: completion-extensions +:END: +Use =cape= to provide =completion-at-point= extensions. +*Packages*: =cape= by [[https://github.com/minad/cape][Daniel Mendler]] +#+begin_src emacs-lisp + (use-package cape :ensure t - :after vertico - :config (marginalia-mode 1)) + :config + ; TODO find out what the wrap buster actually does (caching or whatever) + (advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)) +#+end_src - ;; Add nerd-font icons to completions in minibuffer - (use-package nerd-icons-completion +*** YASnippet Capf +:PROPERTIES: +:CUSTOM_ID: yasnippet-capf +:END: +Display =yasnippet= in completions. +*Packages*: =yasnippet-capf= by [[https://github.com/elken/yasnippet-capf][Ellis Kenyő]] +#+begin_src emacs-lisp + (use-package yasnippet-capf :ensure t - :after vertico marginalia - :hook - (marginalia-mode . nerd-icons-completion-marginalia-setup) - (after-init . nerd-icons-completion-mode)) + :after cape) +#+end_src + +*** Eglot and YASnippet - Together At Last! +:PROPERTIES: +:CUSTOM_ID: eglot-and-yasnippet---together-at-last +:END: +Combine =eglot= and =yasnippet= into a combined completion function. +#+begin_src emacs-lisp + (defun eglot-capf-with-yasnippet () + (setq-local completion-at-point-functions + (list + (cape-capf-super + #'eglot-completion-at-point + #'yasnippet-capf)))) + (with-eval-after-load 'eglot + (add-hook 'eglot-managed-mode-hook #'eglot-capf-with-yasnippet)) #+end_src -** Eglot +** LSP Client +:PROPERTIES: +:CUSTOM_ID: lsp-client +:END: +Use =eglot= as a lightweight interface for LSP servers to enable smart completion, diagnostics and much more within Emacs. +*Packages*: =eglot= by [[https://joaotavora.github.io/eglot/][João Távora]] #+begin_src emacs-lisp (use-package eglot :ensure t :after cape :config - ;; Disable progress indicator in the modeline + ; Disable progress indicator in the modeline (setq eglot-report-progress nil eglot-extend-to-xref t)) +#+end_src + +*** Consult Integration +:PROPERTIES: +:CUSTOM_ID: consult-integration +:END: +Jump to workspace symbols from the LSP with a consult interface. +*Packages*: =consult-eglot= by [[https://github.com/mohkale/consult-eglot][Mohsin Kaleem]] +#+begin_src emacs-lisp + (use-package consult-eglot + :ensure t + :after consult eglot) +#+end_src + - ;; Use a rust binary to do lsp communication and then send results to emacs - ; Booster at https://github.com/blahgeek/emacs-lsp-booster +** LSP Booster +:PROPERTIES: +:CUSTOM_ID: lsp-booster +:END: +Use a rust-powered booster to communicate more efficiently between Emacs and the LSP server. The booster can be downloaded from [[https://github.com/blahgeek/emacs-lsp-booster][Yikai Zhao]]. +*Packages*: =eglot-booster= by [[https://github.com/jdtsmith/eglot-booster][JD Smith]] +#+begin_src emacs-lisp (use-package eglot-booster :vc (:url "https://github.com/jdtsmith/eglot-booster.git") :ensure t :after eglot :config - ;; Use emacs-30's built in JSON handler + ; Use emacs-30's built in JSON handler (setq eglot-booster-io-only t) (eglot-booster-mode)) + #+end_src - ;; Jump to workspace symbols from the LSP with consult - (use-package consult-eglot - :ensure t - :after eglot) - - ;; Install markdown support for eldoc - (use-package markdown-mode - :ensure t) - - ;; Popup lsp documentation information in a floating box - (use-package eldoc-box - :ensure t) - ;; Follow markdown links inside eldoc boxes on selection - (defun markdown-follow-help-or-link-at-point-advice (orig-fun &rest args) - "Prefer to use the help-echo property as `browse-url' target." - (let* ((event-win (posn-window (event-start last-input-event))) - (help-echo (with-selected-frame (window-frame event-win) - (with-current-buffer (window-buffer event-win) - (get-text-property (point) 'help-echo)))) - (help-is-url (url-type (url-generic-parse-url help-echo)))) - (message "if %s (browse-url %S)" help-is-url help-echo) - (if help-is-url - (browse-url help-echo) - (apply orig-fun args)))) - (advice-add 'markdown-follow-link-at-point :around #'markdown-follow-help-or-link-at-point-advice) - ;; Menu for eglot and related functions +** LSP Transient Menu +:PROPERTIES: +:CUSTOM_ID: lsp-transient-menu +:END: +A menu for =eglot= and related functions for easy access. +#+begin_src emacs-lisp (require 'transient) (transient-define-prefix eglot-transient () "Transient menu for Eglot." [["Server" ("c" "Reconnect" eglot-reconnect) - ("q" "Shutdown" eglot-shutdown) + ("C" "Shutdown" eglot-shutdown) ("I" "Server Info" eglot-show-workspace-configuration)] ["Navigation" ("g" "Go to Definition" xref-find-definitions) @@ -759,10 +1235,47 @@ This configuration is for specific filetypes/languages and more advanced package ("L" "Project Diagnostics" flymake-show-project-diagnostics)]] (interactive) (transient-setup 'eglot-transient)) +#+end_src + +** Documentation Popups +:PROPERTIES: +:CUSTOM_ID: documentation-popups +:END: +View documentation with =eldoc= in a popup, correctly syntax highlighted in =markdown= and limited to only use =eglot= when available. +*Packages*: =eldoc-box= by [[https://github.com/casouri/eldoc-box][Yuan Fu]] and =markdown-mode= by [[https://jblevins.org/projects/markdown-mode/][Jason Blevins]] +#+begin_src emacs-lisp + (use-package markdown-mode + :ensure t) + + (use-package eldoc-box + :ensure t) + ; Follow markdown links inside eldoc boxes on selection + (defun markdown-follow-help-or-link-at-point-advice (orig-fun &rest args) + "Prefer to use the help-echo property as `browse-url' target." + (let* ((event-win (posn-window (event-start last-input-event))) + (help-echo (with-selected-frame (window-frame event-win) + (with-current-buffer (window-buffer event-win) + (get-text-property (point) 'help-echo)))) + (help-is-url (url-type (url-generic-parse-url help-echo)))) + (message "if %s (browse-url %S)" help-is-url help-echo) + (if help-is-url + (browse-url help-echo) + (apply orig-fun args)))) + (advice-add 'markdown-follow-link-at-point :around #'markdown-follow-help-or-link-at-point-advice) - (define-key eglot-mode-map (kbd "C-c l") #'eglot-transient) + (add-hook 'eglot-managed-mode-hook + (lambda () + (setq-local eldoc-documentation-functions + (list #'eglot-hover-eldoc-function)))) +#+end_src - ;; Display error and warning highlighting from eglot +** Diagnostics +:PROPERTIES: +:CUSTOM_ID: diagnostics +:END: +Display diagnostics such as Information, Warnings and Errors within the relevant text buffer and in a separate combined buffer. +*Packages*: =flycheck= by [[https://www.flycheck.org/en/latest/][Bozhidar Batsov and the Flycheck Maintainers]] and =flycheck-eglot= by [[https://github.com/flycheck/flycheck-eglot][Sergey Firsov and the Flycheck Maintainers]] +#+begin_src emacs-lisp (use-package flycheck :ensure t :config @@ -776,16 +1289,36 @@ This configuration is for specific filetypes/languages and more advanced package (global-flycheck-eglot-mode 1)) #+end_src -** Org Mode +* Org Mode +:PROPERTIES: +:CUSTOM_ID: org-mode +:END: +** Core Configuration +:PROPERTIES: +:CUSTOM_ID: core-configuration +:END: +Configuration for =org-mode= for code blocks and cleaner looks. #+begin_src emacs-lisp - ;; Open source blocks in the current window + ; Open source blocks in the current window (setq org-src-window-setup 'current-window - ;; Don't confirm when evaluating a code block + ; Don't confirm when evaluating a code block org-confirm-babel-evaluate nil - ;; Make org documents more seamless by hiding markup + ; Make org documents more seamless by hiding markup org-hide-emphasis-markers t) - ;; A nicer org-bullets for headers + ; Enable a non-monospace font for org documents + (add-hook 'org-mode-hook 'variable-pitch-mode) + ; Enable line wrapping for org documents + (add-hook 'org-mode-hook 'visual-line-mode) +#+end_src + +** Heading Bullets +:PROPERTIES: +:CUSTOM_ID: heading-bullets +:END: +Make the header =*= look like varying bullet points. +*Packages*: =org-superstar= by [[https://github.com/integral-dw/org-superstar-mode][D. Williams]] +#+begin_src emacs-lisp (use-package org-superstar :ensure t :hook (org-mode . org-superstar-mode) @@ -793,91 +1326,108 @@ This configuration is for specific filetypes/languages and more advanced package (org-superstar-remove-leading-stars t) (org-superstar-headline-bullets-list '("•" "•" "•" "•" "•"))) +#+end_src - ;; Specify the variable font for org-mode text - (let* ((variable-tuple - (cond ((x-list-fonts "Google Sans") '(:font "Google Sans")) - ((x-family-fonts "Sans Serif") '(:family "Sans Serif")) - (nil (warn "Cannot find a Sans Serif Font. Install Google Sans.")))) - (base-font-color (face-foreground 'default nil 'default)) - (headline `(:inherit default :weight bold :foreground ,base-font-color))) - - (custom-theme-set-faces - 'user - `(org-level-8 ((t (,@headline ,@variable-tuple)))) - `(org-level-7 ((t (,@headline ,@variable-tuple)))) - `(org-level-6 ((t (,@headline ,@variable-tuple)))) - `(org-level-5 ((t (,@headline ,@variable-tuple)))) - `(org-level-4 ((t (,@headline ,@variable-tuple :height 1.1)))) - `(org-level-3 ((t (,@headline ,@variable-tuple :height 1.2)))) - `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.3)))) - `(org-level-1 ((t (,@headline ,@variable-tuple :height 1.4)))) - `(org-document-title ((t (,@headline ,@variable-tuple :height 1.6 :underline nil)))))) - - ;; Enable a non-monospace font for org documents - (add-hook 'org-mode-hook 'variable-pitch-mode) - ;; Enable line wrapping for org documents - (add-hook 'org-mode-hook 'visual-line-mode) - ;; Disable line numbers in org mode - (add-hook 'org-mode-hook (lambda () (display-line-numbers-mode -1))) - - ;; Theme the fonts and styles for various org elements - (custom-theme-set-faces - 'user - '(org-block ((t (:inherit fixed-pitch)))) - '(org-code ((t (:inherit (shadow fixed-pitch))))) - '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch))))) - '(org-indent ((t (:inherit (org-hide fixed-pitch))))) - '(org-link ((t (:foreground "#89b4fa" :underline t)))) - '(org-meta-line ((t (:inherit (font-lock-comment-face fixed-pitch))))) - '(org-property-value ((t (:inherit fixed-pitch))) t) - '(org-special-keyword ((t (:inherit (font-lock-comment-face fixed-pitch))))) - '(org-table ((t (:inherit fixed-pitch)))) - '(org-tag ((t (:inherit (shadow fixed-pitch) :weight bold :height 0.8)))) - '(org-verbatim ((t (:inherit (shadow fixed-pitch)))))) - - ;; Provides quick snippets for common org templates - ;(add-to-list 'org-modules 'org-tempo) +** Org Tempo Snippets +:PROPERTIES: +:CUSTOM_ID: org-tempo-snippets +:END: +Quick snippets for common org templates. +#+begin_src emacs-lisp (require 'org-tempo) - ; FIXME: Won't enable for some reason, - ; figure out why, and make it lazy +#+end_src - ;; Open org mode links in current window +** Link Behaviour +:PROPERTIES: +:CUSTOM_ID: link-behaviour +:END: +Open =org-mode= links in the current window. +#+begin_src emacs-lisp (setq org-link-frame-setup '((file . find-file) (wl . wl-other-frame) (vm . vm-visit-folder-other-frame) (gnus . gnus))) +#+end_src - (add-hook 'org-mode-hook (lambda () (electric-indent-local-mode -1))) +** Tables of Contents +:PROPERTIES: +:CUSTOM_ID: tables-of-contents +:END: +Generate and update indexes automatically in Org documents. +#+begin_src emacs-lisp + (use-package org-make-toc + :ensure t + :hook org-mode + :custom + (org-make-toc-insert-custom-ids t)) #+end_src -* Language Specific Configuration -These are the configurations for specific programming languages that should be enabled or disabled based on what is needed at any time. +** Disable Auto-Indent +:PROPERTIES: +:CUSTOM_ID: disable-auto-indent +:END: +Disable automatic indentation when editing org documents. +#+begin_src emacs-lisp + (add-hook 'org-mode-hook (lambda () (electric-indent-local-mode -1))) +#+end_src +* Language Support +:PROPERTIES: +:CUSTOM_ID: language-support +:END: ** Lua +:PROPERTIES: +:CUSTOM_ID: lua +:END: +*Packages*: =lua-mode= by [[https://immerrr.github.io/lua-mode/][immerrr]] #+begin_src emacs-lisp (use-package lua-mode :ensure t - :hook (lua-mode . eglot-ensure) + :hook eglot-ensure :config - ;; Use a 2 space indent level for formatting + ; Use a 2 space indent level for formatting (setq lua-indent-level 2 - ;; Use lua 5.4 for documentation + ; Use lua 5.4 for documentation lua-documentation-url "https://www.lua.org/manual/5.4/manual.html")) ;; Settings for lua_ls - (setq-default eglot-workspace-configuration - `(:Lua - (:completion (:callSnippet "Replace") - :runtime (:version "Lua 5.4" - :path ["?.lua" - "?/init.lua" - "./stubs/?.lua" - "./stubs/?/init.lua"]) - :workspace (:library [,(concat (getenv "HOME") "/.luarocks/share/lua/5.4") - "./stubs"]) - :diagnostics (:enable t)))) + (add-hook 'lua-mode-hook + (lambda () + (setq-local eglot-workspace-configuration + `(:Lua + (:codeLens (:enable :json-false) + + :completion (:enable t + :callSnippet "Replace" + :autoRequire :json-false + :showWord "Disable" + :postfix "@") + + :diagnostics (:enable t + :disable ["lowercase-global" + "spell-check"] + :severity (:undefined-field "Warning" + :undefined-global "Warning")) + + :format (:enable t) + + :hint (:enable t + :paramName "Disable" + :paramType :json-false) + + :hover (:enable t) + + :runtime (:version "Lua 5.4" + :path ["?.lua" + "?/init.lua" + "./stubs/?.lua" + "./stubs/?/init.lua"]) + + :semantic (:enable :json-false) + + :workspace (:library [,(concat (getenv "HOME") "/.luarocks/share/lua/5.4") + "./stubs"])))))) ; TODO Try fix this only for lua-mode as that is where the bug is (setq eglot-ignored-server-capabilities @@ -885,16 +1435,154 @@ These are the configurations for specific programming languages that should be e #+end_src ** Nix +:PROPERTIES: +:CUSTOM_ID: nix +:END: +*Packages*: =nix-mode= by [[https://github.com/NixOS/nix-mode][The NixOS Maintainers]] #+begin_src emacs-lisp (use-package nix-mode :ensure t :mode "\\.nix\\'" + :hook eglot-ensure :config - (add-hook 'nix-mode-hook #'eglot-ensure t) (add-to-list 'eglot-server-programs '(nix-mode . ("nil")))) #+end_src -** COMMENT ZK +** C/C++ +:PROPERTIES: +:CUSTOM_ID: cc +:END: +*Packages*: =rmsbolt= by [[https://gitlab.com/jgkamat/rmsbolt][Kay Kamat]] +#+begin_src emacs-lisp + (add-hook 'c++-mode-hook #'eglot-ensure) + (add-hook 'c-mode-hook #'eglot-ensure) + + (setq c-default-style "linux" + c-basic-offset 2) + + (use-package rmsbolt + :ensure t + :custom + (rmsbolt-asm-format nil)) + + (setq gdb-many-windows t + gdb-show-main t) +#+end_src + +** Emacs Lisp +:PROPERTIES: +:CUSTOM_ID: emacs-lisp +:END: +#+begin_src emacs-lisp + (add-hook 'emacs-lisp-mode-hook #'dim-parens-mode) + (add-hook 'emacs-lisp-mode-hook (lambda () (local-set-key (kbd "M-p") #'ignore) + (local-set-key (kbd "M-n") #'ignore))) + + ;; (defun mycommand + ;; (when (and (this-predicate) + ;; (that-predicate)) + ;; (do-something) + ;; (do-some-more) + ;; (a-third-thing))) +#+end_src + +** Common Lisp +:PROPERTIES: +:CUSTOM_ID: common-lisp +:END: +*Packages*: =sly= by [[https://github.com/joaotavora/sly][João Távora]] +#+begin_src emacs-lisp + (use-package sly + :ensure t + :hook ((lisp-mode . dim-parens-mode)) + :bind (:map lisp-mode-map + ("M-p" . ignore) + ("M-n" . ignore)) + :custom + (inferior-lisp-program "ros -Q run")) + + (require 'transient) + (transient-define-prefix lisp-transient () + "Transient menu for Sly." + [["REPL" + ("c" "Connect" sly) + ("C" "Shutdown" sly-quit-lisp) + ("I" "Sly Info" sly-info)] + ["Navigation" + ("g" "Go to Definition" sly-edit-definition) + ("d" "Describe Thing at Point" sly-describe-symbol) + ("f" "Find References" sly-who-references) + ("i" "Inspect Evaluation" sly-inspect) + ("h" "Hyperspec Lookup" hyperspec-lookup) ] + ["Code Actions" + ("a" "Code Actions" eglot-code-actions) + ("q" "Quick Fix" eglot-code-action-quickfix) + ("=" "Format Buffer" eglot-format-buffer) + ("o" "Organize Imports" eglot-code-action-organize-imports) + ("r" "Rename Symbol" eglot-rename) ]] + (interactive) + (transient-setup 'lisp-transient)) +#+end_src + +** Fennel +:PROPERTIES: +:CUSTOM_ID: fennel +:END: +*Packages*: =fennel-mode= by [[https://git.sr.ht/~technomancy/fennel-mode][Phil Hagelberg]] +#+begin_src emacs-lisp + (use-package fennel-mode + :ensure t + :hook ((fennel-mode . fennel-proto-repl-minor-mode) + (fennel-mode . dim-parens-mode) + (fennel-mode . eglot-ensure) + (fennel-repl-mode . dim-parens-mode)) + :bind (:map fennel-mode-map + ("M-p" . ignore) + ("M-n" . ignore))) + + (defun fennel-capf-after-eglot () + (when (derived-mode-p 'fennel-mode) + (setq-local completion-at-point-functions + '(fennel-proto-repl-complete fennel-complete tags-completion-at-point-function)))) + + (add-hook 'eglot-managed-mode-hook #'fennel-capf-after-eglot t) + + (add-hook 'fennel-mode-hook + (lambda () + (push '("lambda" . 955) prettify-symbols-alist))) + + (require 'transient) + (transient-define-prefix fennel-transient () + "Transient menu for Fennel." + [["Server" + ("c" "Reconnect" eglot-reconnect) + ("C" "Shutdown" eglot-shutdown)] + ["Navigation" + ("g" "Go to Definition" xref-find-definitions) + ("d" "Describe Thing at Point" eldoc-box-help-at-point) + ("D" "Print Documentation" fennel-show-documentation) + ("f" "Find References" xref-find-references)] + ["Code Actions" + ("a" "Code Actions" eglot-code-actions) + ("q" "Quick Fix" eglot-code-action-quickfix) + ("=" "Format with fnlfmt" fennel-format) + ("o" "Organize Imports" eglot-code-action-organize-imports) + ("r" "Rename Symbol" eglot-rename)] + ["Diagnostics" + ("l" "List Diagnostics" flycheck-list-errors) + ("L" "Project Diagnostics" flymake-show-project-diagnostics)] + ["REPL" + ("z" "Start Proto REPL" fennel-proto-repl) + ("b" "Eval Buffer" fennel-proto-repl-eval-buffer)]] + (interactive) + (transient-setup 'fennel-transient)) +#+end_src + +** Markdown Notes +:PROPERTIES: +:CUSTOM_ID: markdown-notes +:END: +*Packages*: =zk4e= by [[https://codeberg.org/mcookly/zk-emacs][Maximilian Cook]] and =tomlparse= by [[https://github.com/johannes-mueller/tomlparse.el][Johannes Mueller]] #+begin_src emacs-lisp (use-package tomlparse :ensure t) @@ -902,35 +1590,30 @@ These are the configurations for specific programming languages that should be e (use-package zk4e :ensure t :after tomlparse + :hook (markdown-mode . eglot-ensure) :vc ( :url "https://codeberg.org/mcookly/zk4e" :branch "main" :rev :newest) :config (setq zk4e-notebook-directories '(("Notes" . "~/Documents/Notes"))) - (zk4e-select-notebook "Notes")) + (zk4e-select-notebook "Notes") + (add-hook 'zk4e-edit-hook 'zk4e-maybe-name-buffer) + (add-to-list 'eglot-server-programs + '(markdown-mode . ("zk" "lsp")))) #+end_src -** Denote +** COMMENT Markdown Notes (Denote) +*Packages*: =denote=, =denote-org= and =consult-denote= by [[https://protesilaos.com/emacs/denote][Protesilaos]] and =denote-menu= by [[https://www.scss.tcd.ie/~sulimanm/posts/denote-menu.html][Mohamed Suliman]] #+begin_src emacs-lisp (use-package denote :ensure t :hook (dired-mode . denote-dired-mode) - :bind - (("C-c n n" . denote) - ("C-c n N" . denote-type) - ("C-c n r" . denote-rename-file) - ("C-c n l f" . denote-link) - ("C-c n b" . denote-backlinks) - ("C-c n g" . denote-grep)) :config (setq denote-directory (expand-file-name "~/Documents/Denotes/")) (denote-rename-buffer-mode 1)) (use-package consult-denote :ensure t - :bind - (("C-c n f" . consult-denote-find) - ("C-c n g" . consult-denote-grep)) :config (consult-denote-mode 1)) @@ -938,13 +1621,118 @@ These are the configurations for specific programming languages that should be e (use-package denote-menu :ensure t - :bind - (("C-c n d" . list-denotes)) :config (add-hook 'denote-menu-mode-hook (lambda () (display-line-numbers-mode -1)))) (use-package denote-org - :ensure t - :bind - (("C-c n l h" . denote-org-link-to-heading))) + :ensure t) +#+end_src + +* COMMENT Testing +:PROPERTIES: +:CUSTOM_ID: testing +:END: +#+begin_src emacs-lisp +#+end_src + +* Keybindings +:PROPERTIES: +:CUSTOM_ID: keybindings +:END: +This section contains one large =emacs-lisp= block that contains all the custom keybindings for easy reference and modification. +#+begin_src emacs-lisp + (require 'bind-key) + ;; Buffer Begin and End + (bind-key* "C-," 'beginning-of-buffer) + (bind-key* "C-." 'end-of-buffer) + + ;; Regex find and replace + (keymap-global-set "C-c r" 'replace-regexp) + + ;; Recent files + (keymap-global-set "C-x C-r" 'recentf-open) + (which-key-add-key-based-replacements "C-x C-r" "recent-files") + + ;; Compile Mode + (keymap-global-set "C-c m c" 'compile) + (keymap-global-set "C-c m r" 'recompile) + (keymap-global-set "C-c m g" 'rmsbolt) + (which-key-add-key-based-replacements "C-c m" "make") + + ;; Move text up and down + (keymap-global-set "M-p" 'move-text-up) + (keymap-global-set "M-n" 'move-text-down) + + ;; Zen Mode + (keymap-global-set "C-c z" 'olivetti-mode) + + ;; IBuffer + (keymap-global-set "C-x C-b" 'ibuffer) + + ;; Project management + (keymap-set ctl-x-map "p" 'disproject-dispatch) + + ;; Search lines + (keymap-global-set "C-c s" 'consult-line) + (which-key-add-key-based-replacements "C-c s" "search-lines") + + ;; Go to line + (keymap-global-set "M-g M-g" 'consult-goto-line) + (keymap-global-set "M-g g" 'consult-goto-line) + (keymap-global-set "C-c g" 'consult-goto-line) + (which-key-add-key-based-replacements "C-c g" "goto-line") + + ;; Find Files + (keymap-global-set "C-c f f" 'affe-find) + (keymap-global-set "C-c f g" 'affe-grep) + (keymap-global-set "C-c f ." (lambda () (interactive) (affe-find default-directory))) + (which-key-add-key-based-replacements "C-c f ." "affe-find-cwd") + (keymap-global-set "C-c f c" (lambda () (interactive) (find-file "~/.config/emacs/config.org"))) + (which-key-add-key-based-replacements "C-c f c" "find-config") + (keymap-global-set "C-c f t" (lambda () (interactive) (find-file "~/Documents/Notes/TODO.md"))) + (which-key-add-key-based-replacements "C-c f t" "find-todo") + (which-key-add-key-based-replacements "C-c f" "find-file") + + ;; Denote + ;; (keymap-global-set "C-c n n" 'denote) + ;; (keymap-global-set "C-c n N" 'denote-type) + ;; (keymap-global-set "C-c n r" 'denote-rename-file) + ;; (keymap-global-set "C-c n l f" 'denote-link) + ;; (keymap-global-set "C-c n l h" 'denote-org-link-to-heading) + ;; (keymap-global-set "C-c n b" 'denote-backlinks) + ;; (keymap-global-set "C-c n g" 'denote-grep) + ;; (keymap-global-set "C-c n f" 'consult-denote-find) + ;; (keymap-global-set "C-c n d" 'list-denotes) + ;; (which-key-add-key-based-replacements "C-c n" "denotes") + + ;; ZK Notes + (keymap-global-set "C-c n a" 'zk4e-alias) + (keymap-global-set "C-c n e" 'zk4e-edit) + (keymap-global-set "C-c n d" (lambda () (interactive) (zk4e-new "Diario"))) + (which-key-add-key-based-replacements "C-c n d" "zk4e-diario") + (which-key-add-key-based-replacements "C-c n" "zk4e") + + ;; Modus Themes + (keymap-global-set "C-c v t" 'modus-themes-toggle) + (keymap-global-set "C-c v s" 'modus-themes-select) + (which-key-add-key-based-replacements "C-c v" "vivendi-theme") + + ;; Yasnippet + (keymap-global-set "C-c y n" 'yas-new-snippet) + (keymap-global-set "C-c y v" 'yas-visit-snippet-file) + (keymap-global-set "C-c y i" 'yas-insert-snippet) + (which-key-add-key-based-replacements "C-c y" "yasnippets") + + ;; Eglot + (define-key eglot-mode-map (kbd "C-c l") + (lambda () + (interactive) + (cond ((eq major-mode 'fennel-mode) (call-interactively #'fennel-transient)) + (t (call-interactively #'eglot-transient))))) + + ;; Sly + ; INFO: Can't use sly-mode-map because that doesn't get loaded till later on + (define-key lisp-mode-map (kbd "C-c l") (lambda () + (interactive) + (call-interactively #'lisp-transient))) #+end_src diff --git a/config/kak/autoload/auto-pairs b/config/kak/autoload/auto-pairs new file mode 160000 +Subproject e812ee6006b1c3d8c9afa45a0a90d28714636f8 diff --git a/config/kak/autoload/fzf.kak b/config/kak/autoload/fzf.kak new file mode 160000 +Subproject 8fcce0c9fcea36d2371877eea4045ac26ad7698 diff --git a/config/kak/autoload/kak-ansi b/config/kak/autoload/kak-ansi new file mode 160000 +Subproject 14feefb47012bb03dcbbbc920cc51f54f4eee4b diff --git a/config/kak/autoload/kak-harpoon b/config/kak/autoload/kak-harpoon new file mode 160000 +Subproject 28e2019d4a619e3a4a14d420177532a82c7903f diff --git a/config/kak/autoload/kakboard b/config/kak/autoload/kakboard new file mode 160000 +Subproject 5759dcc5af593ff88a7faecc41a8f549ec44077 diff --git a/config/kak/autoload/kakoune-focus b/config/kak/autoload/kakoune-focus new file mode 160000 +Subproject d39ee2f1dcf450f5c8b05c6bfda0227e9b985d9 diff --git a/config/kak/autoload/kakoune-state-save b/config/kak/autoload/kakoune-state-save new file mode 160000 +Subproject e8b6c269ac91eab45b0fe0d2b1f5dd49515ecd0 diff --git a/config/kak/autoload/kakoune-sudo-write b/config/kak/autoload/kakoune-sudo-write new file mode 160000 +Subproject ec0d6d26ceaadd93d6824630ba587b31e442214 diff --git a/config/kak/autoload/kakpipe b/config/kak/autoload/kakpipe new file mode 160000 +Subproject 7f29ee36b26cf1a6aab2ceb74a9d46f71de11f2 diff --git a/config/kak/autoload/nanoline.kak b/config/kak/autoload/nanoline.kak new file mode 160000 +Subproject a7c5773e592fbc62341e4f34bf78ee5d0d44c5c diff --git a/config/kak/autoload/standard-library b/config/kak/autoload/standard-library new file mode 120000 index 0000000..24049f7 --- /dev/null +++ b/config/kak/autoload/standard-library @@ -0,0 +1 @@ +/nix/store/kr84jgb3bfca47m0njizy2pi61adh2wk-kakoune-2025.06.03/share/kak/rc \ No newline at end of file diff --git a/config/kak/colemak.kak b/config/kak/colemak.kak new file mode 100644 index 0000000..e4af6ff --- /dev/null +++ b/config/kak/colemak.kak @@ -0,0 +1,38 @@ +map global normal n j +map global normal <a-n> <a-j> +map global normal <a-N> <a-J> +map global normal e k +map global normal i l +map global normal I L +map global normal <a-i> <a-l> +map global normal <a-I> <a-L> + +map global normal j n +map global normal <a-j> <a-n> +map global normal <a-J> <a-N> +map global normal J N +map global normal l i +map global normal <a-l> <a-i> +map global normal <a-L> <a-I> + +map global normal k e +map global normal K E +map global normal <a-e> <a-k> +map global normal <a-k> <a-e> +map global normal <a-E> <a-K> +map global normal <a-K> <a-E> + +# Select whole lines when moving selection with J or K +map global normal N Jx +map global normal E Kx + +# Make I insert before every line +map global normal L "<a-s>I" + +map global goto l '' +map global goto i l -docstring 'line end' +map global goto j '' +map global goto n j -docstring 'buffer bottom' +map global goto e '' +map global goto k '' +map global goto e k -docstring 'buffer top' diff --git a/config/kak/colors/black_mocha.kak b/config/kak/colors/black_mocha.kak new file mode 100644 index 0000000..518400b --- /dev/null +++ b/config/kak/colors/black_mocha.kak @@ -0,0 +1,82 @@ +# Black Mocha + +evaluate-commands %sh{ + rosewater='rgb:f5e0dc' + flamingo='rgb:f2cdcd' + pink='rgb:f5c2e7' + mauve='rgb:cba6f7' + red='rgb:f38ba8' + maroon='rgb:eba0ac' + peach='rgb:fab387' + yellow='rgb:f9e2af' + green='rgb:a6e3a1' + teal='rgb:94e2d5' + sky='rgb:89dceb' + sapphire='rgb:74c7ec' + blue='rgb:89b4fa' + lavender='rgb:b4befe' + text='rgb:cdd6f4' + subtext1='rgb:bac2de' + subtext0='rgb:a6adc8' + overlay2='rgb:9399b2' + overlay1='rgb:7f849c' + overlay0='rgb:6c7086' + surface2='rgb:585b70' + surface1='rgb:45475a' + surface0='rgb:313244' + base='rgb:000000' + mantle='rgb:181825' + crust='rgb:11111b' + + echo " + set-face global title ${text}+b + set-face global header ${subtext0}+b + set-face global bold ${maroon}+b + set-face global italic ${maroon}+i + set-face global mono ${green} + set-face global block ${sapphire} + set-face global link ${blue} + set-face global bullet ${peach} + set-face global list ${peach} + + set-face global Default ${text},${base} + set-face global PrimarySelection ${text},${surface2} + set-face global SecondarySelection ${text},${surface2} + set-face global PrimaryCursor ${crust},${rosewater} + set-face global SecondaryCursor ${text},${overlay0} + set-face global PrimaryCursorEol ${surface2},${lavender} + set-face global SecondaryCursorEol ${surface2},${overlay1} + set-face global LineNumbers ${overlay1},${base} + set-face global LineNumbersWrapped ${base},${base} + set-face global LineNumberCursor ${lavender},${base}+b + set-face global MenuForeground ${text},${surface1}+b + set-face global MenuBackground ${text},${surface0} + set-face global MenuInfo ${crust},${teal} + set-face global Information ${crust},${teal} + set-face global Error ${crust},${red} + set-face global StatusLine ${text},${mantle} + set-face global StatusLineMode ${crust},${yellow} + set-face global StatusLineInfo ${crust},${teal} + set-face global StatusLineValue ${crust},${yellow} + set-face global StatusCursor ${crust},${rosewater} + set-face global Prompt ${teal},${base}+b + set-face global MatchingChar ${maroon},${base} + set-face global Whitespace ${overlay1},${base}+f + set-face global WrapMarker Whitespace + set-face global BufferPadding ${base},${base} + + set-face global value ${peach} + set-face global type ${blue} + set-face global variable ${text} + set-face global module ${maroon} + set-face global function ${blue} + set-face global string ${green} + set-face global keyword ${mauve} + set-face global operator ${sky} + set-face global attribute ${green} + set-face global comment ${overlay0} + set-face global documentation comment + set-face global meta ${yellow} + set-face global builtin ${red} + " +} diff --git a/config/kak/colors/modus-vivendi.kak b/config/kak/colors/modus-vivendi.kak new file mode 100644 index 0000000..32930b9 --- /dev/null +++ b/config/kak/colors/modus-vivendi.kak @@ -0,0 +1,210 @@ +# Modus-Vivendi theme for Kakoune + +# Color palette +# declare-option str black default +declare-option str bg_main 'default' +declare-option str bg_terminal_main 'rgb:000000' +declare-option str fg_main 'rgb:ffffff' +declare-option str bg_dim 'rgb:1e1e1e' +declare-option str fg_dim 'rgb:989898' +declare-option str bg_alt 'rgb:000000' +declare-option str fg_alt 'rgb:c6daff' +declare-option str bg_active 'rgb:535353' +declare-option str bg_inactive 'rgb:303030' +declare-option str red 'rgb:ff5f59' +declare-option str red_bright 'rgb:ff7f86' +declare-option str green 'rgb:44bc44' +declare-option str green_bright 'rgb:00c06f' +declare-option str yellow 'rgb:d0bc00' +declare-option str yellow_bright 'rgb:dfaf7a' +declare-option str blue 'rgb:2fafff' +declare-option str blue_bright 'rgb:00bcff' +declare-option str purple 'rgb:feacd0' +declare-option str purple_bright 'rgb:b6a0ff' +declare-option str bg_mode_line 'rgb:000000' +declare-option str fg_mode_line 'rgb:cdd6f4' +declare-option str cursor 'rgb:ffffff' +declare-option str bg_hl_line 'rgb:2f3849' +declare-option str fg_space 'rgb:646464' +declare-option str magenta_warmer 'rgb:f78fe7' +declare-option str blue_warmer 'rgb:79a8ff' +declare-option str cyan 'rgb:00d3d0' +declare-option str cyan_warmer 'rgb:4ae2f0' +declare-option str cyan_cooler 'rgb:6ae4b9' +declare-option str red_faint 'rgb:ff9580' +declare-option str green_faint 'rgb:88ca9f' +declare-option str yellow_faint 'rgb:d2b580' +declare-option str blue_faint 'rgb:82b0ec' +declare-option str magenta_faint 'rgb:caa6df' +declare-option str cyan_faint 'rgb:9ac8e0' +declare-option str fg_link 'rgb:79a8ff' +declare-option str fg_prose_code 'rgb:6ae4b9' + +declare-option str psel 'rgb:5a5a5a' +declare-option str ssel 'rgb:2f3849' + +# Reference +# https://github.com/mawww/kakoune/blob/master/colors/default.kak +# For code +set-face global value 'rgb:ffffff' +set-face global type 'rgb:6ae4b9' +set-face global variable 'rgb:00d3d0' +set-face global keyword 'rgb:b6a0ff' +set-face global module 'rgb:ffffff' +set-face global function 'rgb:feacd0' +set-face global string 'rgb:79a8ff' +set-face global builtin 'rgb:f78fe7' +set-face global constant 'rgb:00bcff' +set-face global comment 'rgb:989898' +set-face global meta 'rgb:ff7f86' + +set-face global operator 'rgb:ffffff' +set-face global comma 'rgb:ffffff' +set-face global bracket 'rgb:2f7f9f' + +# For markup +set-face global title "%opt{fg_main}+b" +set-face global header "%opt{fg_main}+b" +set-face global bold "%opt{fg_main}+b" +set-face global italic "%opt{fg_main}+i" +set-face global mono "%opt{fg_prose_code}" +set-face global block "%opt{fg_dim}" +set-face global link "%opt{fg_link}+u" +set-face global bullet "%opt{fg_dim}" +set-face global list "%opt{fg_main}" + +# Builtin faces +#set-face global Default "%opt{fg_main},%opt{bg_main}" +set-face global Default "%opt{fg_main},default" +set-face global PrimarySelection "default,%opt{psel}" +set-face global SecondarySelection "default,%opt{ssel}" +set-face global PrimaryCursor "%opt{bg_terminal_main},%opt{cursor}" +set-face global SecondaryCursor "%opt{bg_terminal_main},%opt{fg_alt}" +set-face global PrimaryCursorEol "%opt{bg_terminal_main},%opt{red_bright}" +set-face global SecondaryCursorEol "%opt{bg_terminal_main},%opt{blue}" +set-face global LineNumbers "%opt{fg_dim},%opt{bg_main}" +set-face global LineNumberCursor "%opt{fg_alt},%opt{bg_main}+b" +set-face global LineNumbersWrapped "%opt{bg_dim},%opt{bg_main}+i" +set-face global MenuForeground "%opt{bg_terminal_main},%opt{fg_main}+b" +set-face global MenuBackground "%opt{fg_main},%opt{bg_alt}" +set-face global MenuInfo "%opt{fg_alt},%opt{bg_alt}" +set-face global Information "%opt{fg_mode_line},%opt{bg_mode_line}" +set-face global Error "%opt{red},%opt{bg_mode_line}" +set-face global StatusLine "%opt{fg_mode_line},%opt{bg_mode_line}" +set-face global StatusLineMode "%opt{fg_mode_line},%opt{bg_mode_line}" +set-face global StatusLineInfo "%opt{fg_mode_line},%opt{bg_mode_line}" +set-face global StatusLineValue "%opt{fg_mode_line},%opt{bg_mode_line}" +set-face global StatusCursor "%opt{fg_main},%opt{blue}" +set-face global Prompt "%opt{fg_mode_line},%opt{bg_mode_line}" +set-face global MatchingChar "%opt{blue},%opt{bg_main}" +set-face global Whitespace "%opt{fg_space},%opt{bg_main}+f" +set-face global WrapMarker Whitespace +set-face global BufferPadding "%opt{bg_terminal_main},%opt{bg_main}" + +# For tree-sitter (kak-tree-sitter) +# -- Keywords -- +set-face global ts_keyword "%opt{purple_bright}" +set-face global ts_keyword_conditional "%opt{purple_bright}+i" +set-face global ts_keyword_control_conditional "%opt{purple_bright}+i" +set-face global ts_keyword_control_import "%opt{purple_bright}+i" +set-face global ts_keyword_directive "%opt{red_bright}+i" +set-face global ts_keyword_storage "%opt{purple_bright}" +set-face global ts_keyword_storage_modifier "%opt{purple_bright}" +set-face global ts_keyword_storage_modifier_mut "%opt{purple_bright}" +set-face global ts_keyword_storage_modifier_ref "%opt{cyan_cooler}" + +# -- Functions -- +set-face global ts_function "%opt{purple}" +set-face global ts_function_builtin "%opt{magenta_warmer}+i" +set-face global ts_function_macro "%opt{red_bright}" +set-face global ts_function_method "%opt{purple}" + +# -- Types -- +set-face global ts_type "%opt{cyan_cooler}" +set-face global ts_type_builtin "%opt{cyan_cooler}" +set-face global ts_type_enum_variant "%opt{cyan_warmer}" +set-face global ts_type_parameter "%opt{cyan}+i" +set-face global ts_constructor "%opt{cyan_cooler}" + +# -- Strings -- +set-face global ts_string "%opt{blue_warmer}" +set-face global ts_string_regexp "%opt{green_bright}" +set-face global ts_string_escape "%opt{purple}" +set-face global ts_string_special "%opt{blue}" +set-face global ts_string_special_path "%opt{green_bright}" +set-face global ts_string_special_symbol "%opt{purple_bright}" +set-face global ts_string_symbol "%opt{red_bright}" + +# -- Constants -- +set-face global ts_constant "%opt{blue_bright}" +set-face global ts_constant_builtin "%opt{blue_bright}" +set-face global ts_constant_builtin_boolean "%opt{blue_bright}" +set-face global ts_constant_character "%opt{blue_bright}" +set-face global ts_constant_macro "%opt{red_bright}" +set-face global ts_constant_numeric "%opt{fg_main}" + +# -- Variables -- +set-face global ts_variable "%opt{cyan}" +set-face global ts_variable_builtin "%opt{purple_bright}" +set-face global ts_variable_other_member "%opt{cyan_warmer}" +set-face global ts_variable_parameter "%opt{cyan}+i" + +# -- Comments & operators -- +set-face global ts_comment "%opt{fg_dim}" +set-face global ts_comment_unused "%opt{fg_dim}+s" +set-face global ts_operator "%opt{fg_main}" +set-face global ts_punctuation "%opt{fg_main}" +set-face global ts_punctuation_special "%opt{purple_bright}" + +# -- Properties, namespaces, labels -- +set-face global ts_property "%opt{cyan}" +set-face global ts_namespace "%opt{cyan}+i" +set-face global ts_label "%opt{cyan}+i" +set-face global ts_attribute "%opt{red_bright}" + +# -- Markup -- +set-face global ts_markup_bold "%opt{fg_main}+b" +set-face global ts_markup_italic "%opt{fg_main}+i" +set-face global ts_markup_strikethrough "%opt{fg_dim}+s" +set-face global ts_markup_heading "%opt{fg_main}+b" +set-face global ts_markup_heading_1 "%opt{fg_main}+b" +set-face global ts_markup_heading_2 "%opt{yellow_faint}+b" +set-face global ts_markup_heading_3 "%opt{blue_faint}+b" +set-face global ts_markup_heading_4 "%opt{purple}+b" +set-face global ts_markup_heading_5 "%opt{green_faint}+b" +set-face global ts_markup_heading_6 "%opt{red_faint}+b" +set-face global ts_markup_heading_marker "%opt{fg_dim}" +set-face global ts_markup_list_checked "%opt{fg_dim}" +set-face global ts_markup_list_numbered "%opt{fg_dim}" +set-face global ts_markup_list_unchecked "%opt{fg_dim}" +set-face global ts_markup_list_unnumbered "%opt{fg_dim}" +set-face global ts_markup_link_label "%opt{fg_link}" +set-face global ts_markup_link_url "%opt{fg_alt}" +set-face global ts_markup_link_uri "%opt{fg_alt}" +set-face global ts_markup_link_text "%opt{fg_link}+u" +set-face global ts_markup_quote "%opt{fg_main}+i" +set-face global ts_markup_raw "%opt{fg_prose_code}" + +# -- Diff -- +set-face global ts_diff_plus "%opt{green}" +set-face global ts_diff_minus "%opt{red}" +set-face global ts_diff_delta "%opt{blue}" +set-face global ts_diff_delta_moved "%opt{purple_bright}" + +# -- Diagnostics -- +set-face global ts_error "%opt{red}+b" +set-face global ts_warning "%opt{yellow}+b" +set-face global ts_hint "%opt{blue}+b" +set-face global ts_info "%opt{green}+b" + +# -- Others -- +set-face global ts_embedded "%opt{purple_bright}" +set-face global ts_include "%opt{purple_bright}" +set-face global ts_load "%opt{purple_bright}" +set-face global ts_tag "%opt{purple_bright}" +set-face global ts_tag_error "%opt{red}" +set-face global ts_text "%opt{fg_main}" +set-face global ts_text_title "%opt{fg_main}+b" +set-face global ts_conceal "%opt{fg_dim}+i" +set-face global ts_special "%opt{blue}" +set-face global ts_spell "%opt{fg_main}" diff --git a/config/kak/compilation-mode.kak b/config/kak/compilation-mode.kak new file mode 100644 index 0000000..bdbb5e2 --- /dev/null +++ b/config/kak/compilation-mode.kak @@ -0,0 +1,61 @@ +# Requires kakpipe and unbuffer + +declare-option -docstring "The last command ran in compilation-mode +"\ +str compile_last_command "" + +declare-option -docstring "How the compile buffer should be displayed +Options: + 'default': Create a new buffer in the current kakoune window + 'new': Create a new window via ':terminal' + 'tmux_vertical': Create a tmux vertical split + 'tmux_horizontal': Create a tmux horizontal split + 'tmux_popup': Create a tmux popup window +"\ +str compile_run_mode "default" + +define-command -hidden -params 1.. compile-exec %{ + evaluate-commands %sh{ + case "$kak_opt_compile_run_mode" in + default) + exec kakpipe fifo -s "$kak_session" -- unbuffer "$@" + ;; + new) + printf 'terminal kak -e "set-option global compile_run_mode default; compile %s"\n' "$*" + ;; + tmux_vertical|tmux_horizontal|tmux_popup) + if [ -z "$kak_client_env_TMUX" ]; then + echo 'fail "tmux is not running"' + exit + fi + case "$kak_opt_compile_run_mode" in + tmux_vertical) + tmux_args="split-window -t '${kak_client_env_TMUX_PANE}' -v" + ;; + tmux_horizontal) + tmux_args="split-window -t '${kak_client_env_TMUX_PANE}' -h" + ;; + tmux_popup) + tmux_args="popup -E -t '${kak_client_env_TMUX_PANE}'" + ;; + esac + printf "nop %%sh{ tmux %s kak -e 'set-option global compile_run_mode default; compile %s' }\n" "$tmux_args" "$*" + ;; + esac + } +} + +define-command -docstring "Compile: run a command in a fifo buffer" compile -params 1.. %{ + set-option global compile_last_command "%arg{@}" + compile-exec %arg{@} +} + +define-command -docstring "Recompile: re-run the last compile command" recompile %{ + evaluate-commands %sh{ + if [ -z "$kak_opt_compile_last_command" ]; then + echo 'fail "No previous compile command"' + else + echo "compile-exec $kak_opt_compile_last_command" + fi + } +} diff --git a/config/kak/compilation-mode_classic.kak b/config/kak/compilation-mode_classic.kak new file mode 100644 index 0000000..348fcf0 --- /dev/null +++ b/config/kak/compilation-mode_classic.kak @@ -0,0 +1,20 @@ +# Requires kakpipe and unbuffer + +declare-option str compile_last_command "" + +define-command -docstring "Compile: run a command in a fifo buffer" compile -params 1.. %{ + set-option global compile_last_command "%arg{@}" + evaluate-commands %sh{ exec kakpipe fifo -s $kak_session -- unbuffer "$@" } +} + +define-command -docstring "Recompile: re-run the last compile command" recompile %{ + evaluate-commands %sh{ + if [ -z "$kak_opt_compile_last_command" ]; then + echo 'fail "No previous compile command"' + else + exec kakpipe fifo -s $kak_session -- unbuffer $kak_opt_compile_last_command + fi + } +} + + diff --git a/config/kak/kakrc b/config/kak/kakrc new file mode 100644 index 0000000..06bf35c --- /dev/null +++ b/config/kak/kakrc @@ -0,0 +1,357 @@ +# Venomade's kakrc + + +# ------ +# SOURCE +# ------ + +# Use Colemak keybinds +source ~/.config/kak/colemak.kak +source ~/.config/kak/compilation-mode.kak + + +# ------- +# OPTIONS +# ------- + +# Set tab width +set-option global tabstop 2 +set-option global indentwidth 2 + +# Display line numbers +add-highlighter global/ number-lines -hlcursor + +# Softwrap long lines +add-highlighter global/ wrap -word -indent + +# Set the colorscheme +colorscheme 'modus-vivendi' + +# Move the modeline to the top of the screen +set-option global ui_options terminal_status_on_top=yes + +# Don't show changelog at startup +set-option global startup_info_version 10000000000000 + +# Add scroll margin +set-option global scrolloff 5,5 + +# Use ripgrep instead of grep +set-option global grepcmd 'rg -HUn --no-heading --sort path --vimgrep' + +# Remove trailing whitespace on save +hook -group auto-trim-whitespace global BufWritePre .* %{ try %{ execute-keys -draft \%s\h+$<ret>d } } + +# Disable Clippy +set-option -add global ui_options terminal_assistant=none + +# Disable word completion +set-option global completers filename + +# -------- +# KEYBINDS +# -------- + +# Buffer Keybinds +declare-user-mode buffer-mode +map global user b ':enter-user-mode buffer-mode<ret>' -docstring 'buffer...' +map global buffer-mode d ':delete-buffer<ret>' -docstring 'delete buffer' +map global buffer-mode k ':delete-buffer!<ret>' -docstring 'kill buffer' +map global buffer-mode n ':buffer-next<ret>' -docstring 'next buffer' +map global buffer-mode p ':buffer-previous<ret>' -docstring 'previous buffer' + +# map global buffer-mode b '<esc>:prompt -buffer-completion buffer: %{ buffer %val{text} }<ret>' -docstring 'switch buffer' + +# Comment line +map global normal "#" ":comment-line<ret>" + +# File Keybinds +declare-user-mode file-mode +map global user f ':enter-user-mode file-mode<ret>' -docstring 'file...' +# map global file-mode f '<esc>:prompt -shell-script-candidates %{ fd --type f } file: %{ edit %val{text} }<ret>' -docstring "find file" +map global file-mode c ':e ~/.config/kak/kakrc<ret>' -docstring 'open config' +map global file-mode t ':e ~/Documents/Notes/TODO.md<ret>' -docstring 'open todo' + +# Search case-insensitive by default +map global normal "/" "/(?Si)" +map global normal "?" "?(?Si)" +map global normal "<a-/>" "<a-/>(?Si)" +map global normal "<a-?>" "<a-?>(?Si)" + +# Select inner line +map global normal X x_ + +# Use tab for autocomplete +# hook global InsertCompletionShow .* %{ +# try %{ +# execute-keys -draft 'h<a-K>\h<ret>' +# map window insert <tab> <c-n> +# map window insert <s-tab> <c-p> +# hook -once -always window InsertCompletionHide .* %{ +# unmap window insert <tab> <c-n> +# unmap window insert <s-tab> <c-p> +# } +# } +# } + +# Tab jumps to next snippet placeholder by default in insert mode +map global insert <tab> '<esc>: lsp-snippets-select-next-placeholders<ret>i' +map global insert <s-tab> '<esc>: lsp-snippets-select-next-placeholders<ret>i' # optional reverse + +# When completion menu shows, remap tab to cycle completions — but only if not in a snippet +hook global InsertCompletionShow .* %{ + try %{ + execute-keys -draft 'h<a-K>\h<ret>' + try %{ + eval %sh{ [ -n "${kak_opt_lsp_snippets_placeholder_groups}" ] && echo "fail" } + map window insert <tab> <c-n> + map window insert <s-tab> <c-p> + hook -once -always window InsertCompletionHide .* %{ + unmap window insert <tab> <c-n> + unmap window insert <s-tab> <c-p> + } + } + } +} + +# Map tab and shift-tab to indent and dedent in normal mode +map global normal <tab> '>' +map global normal <s-tab> '<' + +# Terminal related bindings +declare-user-mode terminal-mode +map global user t ':enter-user-mode terminal-mode<ret>' -docstring 'terminal...' +map global terminal-mode t ':terminal zsh<ret>' -docstring 'open terminal' +map global terminal-mode s ':tmux-repl-horizontal <ret>' -docstring 'open terminal split (H)' +map global terminal-mode v ':tmux-repl-vertical<ret>' -docstring 'open terminal split (V)' + +define-command smart-gh \ + -docstring "Smart goto line start." \ +%{ + set-register c %val{cursor_column} + + execute-keys gi + + evaluate-commands %sh{ + orig_col="${kak_reg_c}" + indent_col="${kak_cursor_column}" + + if [ "${orig_col}" -le "${indent_col}" ]; then + echo "execute-keys gh" + fi + } +} + + +map global goto h <esc>:smart-gh<ret> -docstring 'line begin (smart)' + +# Window Management +declare-user-mode window-mode +map global user w ':enter-user-mode window-mode<ret>' -docstring 'window...' +map global window-mode s ':tmux-terminal-horizontal kak -c %val{session}<ret>' -docstring 'open window split (H)' +map global window-mode v ':tmux-terminal-vertical kak -c %val{session}<ret>' -docstring 'open window split (V)' + + +# ------- +# PLUGINS +# ------- + +# Nanoline is a cleaner alternative to the default modeline +set-option global nanoline_rw_face_dark rgb:11111b,rgb:b4befe +nanoline dark +nanoline-format + +# Use auto-pairs +enable-auto-pairs + +# Enable Copy-Paste with kakboard +hook global WinCreate .* %{ kakboard-enable } + +# Load LSP +eval %sh{kak-lsp} + +set-option global modelinefmt "%opt{lsp_modeline} %opt{modelinefmt}" + +map global user l ':enter-user-mode lsp<ret>' -docstring 'lsp...' + +map global goto d <esc>:lsp-definition<ret> -docstring 'LSP definition' +map global goto r <esc>:lsp-references<ret> -docstring 'LSP references' +map global goto y <esc>:lsp-type-definition<ret> -docstring 'LSP type definition' + +map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder' + +map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol' +map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol' +map global object f '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method' +map global object t '<a-semicolon>lsp-object Class Interface Module Namespace Struct<ret>' -docstring 'LSP class or module' +map global object d '<a-semicolon>lsp-diagnostic-object error warning<ret>' -docstring 'LSP errors and warnings' +map global object D '<a-semicolon>lsp-diagnostic-object error<ret>' -docstring 'LSP errors' + +hook global WinSetOption lsp_code_action_indicator=.* %{ + set-option window lsp_code_action_indicator "[A]" +} + +hook global WinSetOption lsp_progress_indicator=.* %{ + set-option window lsp_progress_indicator "[P]" +} + +hook global GlobalSetOption lsp_modeline_message_requests=.* %{ + evaluate-commands %sh{ + if [ -n "$kak_hook_param_capture_0" ]; then + echo "set-option global lsp_modeline_message_requests '[M]'" + fi + } +} + +# Save with formatting with :W +define-command W %{ + lsp-formatting-sync + w +} + +set-face global InlayDiagnosticHint 'rgb:444444' + +# FZF + +require-module fzf +set-option global fzf_tmux_popup true +set-option global fzf_tmux_popup_width '80%' +set-option global fzf_default_opts '--color=base16' +set-option global fzf_highlight_command 'bat' +require-module fzf-file +set-option global fzf_file_command 'fd' +require-module fzf-grep +set-option global fzf_grep_command 'rg' + +map global file-mode f ':require-module fzf-file; fzf-file<ret>' -docstring 'find file' +map global file-mode p ':require-module fzf-file; fzf-file buffile-dir<ret>' -docstring 'find file at path' +map global file-mode g ':require-module fzf-grep; fzf-grep<ret>' -docstring 'grep files' +map global file-mode d ':require-module fzf-cd; fzf-cd<ret>' -docstring 'change directory' +map global file-mode / ':require-module fzf-search; fzf-buffer-search<ret>' -docstring 'search current file' + +map global buffer-mode b ':require-module fzf-buffer; fzf-buffer<ret>' -docstring 'switch buffer' + +# map global user F ':fzf-mode<ret>' -docstring 'fzf...' + +# Harpoon +harpoon-add-bindings + +# Kakpipe +require-module kakpipe + +set-option global compile_run_mode 'tmux_horizontal' + +declare-user-mode compile-mode +map global user c ':enter-user-mode compile-mode<ret>' -docstring 'compile...' +map global compile-mode c '<esc>:prompt -shell-completion "compile: " %{ evaluate-commands %sh{ echo "compile $kak_text" } }<ret>' -docstring 'compile' +map global compile-mode r ':recompile<ret>' -docstring 'recompile' + +# Kakoune Focus +declare-user-mode selection-mode +map global user s ':enter-user-mode selection-mode<ret>' -docstring 'selection...' +map global selection-mode f ':focus-toggle<ret>' -docstring "toggle selections focus" + +define-command focus-live-enable %{ + focus-selections + hook -group focus window NormalIdle .* %{ focus-extend } +} +define-command focus-live-disable %{ + remove-hooks window focus + focus-clear +} + + +# --------- +# FILETYPES +# --------- + +# Lua +hook global BufSetOption filetype=lua %{ + set-option buffer lsp_servers %exp{ + # Minimal setup for luals (Lua doesn't really work with LSP, I've tried) + [luals] + filetypes = ["lua"] + root_globs = [".git/", ".luarc.json", ".luarc.jsonc", ".editorconfig", ".kakrc"] + command = "lua-language-server" + + [luals.settings.Lua] + codeLens.enable = false + completion.autoRequire = false # afaik not supported by kakoune + completion.enable = true + completion.callSnippet = "Replace" + completion.showWord = "Disable" + completion.postfix = "@" + diagnostics.enable = true + diagnostics.disable = [ + "lowercase-global", + "spell-check", + ] + format.enable = true + hint.enable = true + hint.paramName = "Disable" + hint.paramType = false + hover.enable = true + runtime.path = [ + "?.lua", + "?/init.lua", + ] + runtime.version = "Lua 5.4" + semantic.enable = false + + [luals.settings.Lua.diagnostics.severity] + undefined-field = "Warning" + undefined-global = "Warning" + + # [emmylua_ls] + # filetypes = ["lua"] + # root_globs = [".git/", ".luarc.json", ".editorconfig", ".kakrc", ".emmyrc.json"] + # command = "emmylua_ls" + } +} + +hook global WinSetOption filetype=lua %{ + add-highlighter window/emmylua_direct regex "---\s*(@(?:alias|as|class|enum|generic|return|type|overload))\s+([^\n]*)" 1:attribute 2:type + add-highlighter window/emmylua_labeled regex "---\s*(@(?:alias|cast|field|param))\s+([a-zA-Z0-9_\?]*) ([^\n]*)" 1:attribute 2:variable 3:type + add-highlighter window/emmylua_enum_variant regex '---\s*\|\s*("[^\n]*")' 1:string +} + +# Markdown +hook global BufSetOption filetype=markdown %{ + set-option buffer lsp_servers %exp{ + [zk_lsp] + filetypes = ["markdown"] + root_globs = [".git/", ".zk/", ".kakrc"] + command = "zk" + args = ["lsp"] + [harper] + filetypes = ["markdown"] + root_globs = [".git/", ".zk/", ".kakrc"] + command = "harper-ls" + args = ["--stdio"] + settings_section = "_" + [harper.settings._.harper-ls] + #isolateEnglish = true # Currently very buggy + dialect = "British" + [harper.settings._.harper-ls.markdown] + IgnoreLinkTitle = true } +} + +# ---- +# MISC +# ---- + +# TODO: Fix this TODO Highlighter +hook -group todohighlight global BufCreate .* %{ + add-highlighter buffer/todo-highlight regex "%opt{comment_line}[ \t]*\b(TODO|FIXME|HACK)\b" 1:default+bu@comment +} + +# Enable LSP (Must come just before settings, after everything else lsp) +lsp-enable + +lsp-diagnostic-lines-disable global +lsp-inlay-diagnostics-enable global +# lsp-inlay-code-lenses-enable global +lsp-inlay-hints-enable global +set-option global lsp_hover_anchor true +# lsp-auto-hover-enable +lsp-auto-signature-help-enable diff --git a/config/kanata/config.kbd b/config/kanata/config.kbd new file mode 100644 index 0000000..a805cf7 --- /dev/null +++ b/config/kanata/config.kbd @@ -0,0 +1,39 @@ +#| +This minimal config changes Caps Lock to act as Caps Lock on quick tap, but +if held, it will act as Left Ctrl. It also changes the backtick/grave key to +act as backtick/grave on quick tap, but change ijkl keys to arrow keys on hold. + +This text between the two pipe+octothorpe sequences is a multi-line comment. +|# + +;; Text after double-semicolons are single-line comments. + +#| +One defcfg entry may be added, which is used for configuration key-pairs. These +configurations change kanata's behaviour at a more global level than the other +configuration entries. +|# + +(defcfg + #| + This configuration will process all keys pressed inside of kanata, even if + they are not mapped in defsrc. This is so that certain actions can activate + at the right time for certain input sequences. By default, unmapped keys are + not processed through kanata due to a Windows issue related to AltGr. If you + use AltGr in your keyboard, you will likely want to follow the simple.kbd + file while unmapping lctl and ralt from defsrc. + |# + process-unmapped-keys yes +) + +(defsrc + caps +) + +(deflayer default + @cap +) + +(defalias + cap (tap-hold 200 200 esc lctl) +) diff --git a/config/nvim/.luarc.json b/config/nvim/.luarc.json index bd8a14b..d6288ee 100644 --- a/config/nvim/.luarc.json +++ b/config/nvim/.luarc.json @@ -1,7 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json", "Lua.runtime.version": "LuaJIT", - "diagnostics.globals": ["vim"], "workspace.checkThirdParty": false, "workspace.library": [ "$VIMRUNTIME" diff --git a/config/shell/alias b/config/shell/alias index 8c17329..a431fd9 100644 --- a/config/shell/alias +++ b/config/shell/alias @@ -8,3 +8,6 @@ alias fzf="fzf --preview 'bat --style=numbers --color=always {}'" alias vi="nvim" alias vim="nvim" alias em="emacs -nw" +alias et="emacsclient -t" +alias ec="emacsclient -c" +alias sbcl="ros run --" \ No newline at end of file diff --git a/config/shell/functions b/config/shell/functions index a300316..0661814 100644 --- a/config/shell/functions +++ b/config/shell/functions @@ -14,3 +14,7 @@ function y() { [ "$cwd" != "$PWD" ] && [ -d "$cwd" ] && builtin cd -- "$cwd" rm -f -- "$tmp" } + +function pcd() { + cd "$(project)" +} diff --git a/config/shell/vars b/config/shell/vars index b74f722..03936fe 100644 --- a/config/shell/vars +++ b/config/shell/vars @@ -1,5 +1,7 @@ -export EDITOR=nvim +export EDITOR=kak export ZK_NOTEBOOK_DIR=$HOME/Documents/Notes export XDG_CONFIG_HOME=$HOME/.config export GOPATH=$HOME/.go export LIMA_SHELL=/bin/zsh +export LANGUAGE=en_GB +export CPATH=/usr/include diff --git a/config/starship/config.toml b/config/starship/config.toml index d9cd4d2..00e6b86 100644 --- a/config/starship/config.toml +++ b/config/starship/config.toml @@ -5,7 +5,6 @@ add_newline = true format = """ -${custom.linux} $nix_shell\ $directory\ $git_branch\ @@ -22,13 +21,13 @@ $cmd_duration\ $line_break\ $character""" -[custom.linux] -format = '[$symbol \[$output\]]($style) ' -symbol = ' ' -command = "cat /etc/os-release | grep '^ID=' | sed 's/ID=//' | sed 's/^./\\U&/'" -os = 'linux' -style = 'bold #f5e0dc' -when = true +#[custom.linux] +#format = '[$symbol \[$output\]]($style) ' +#symbol = ' ' +#command = "cat /etc/os-release | grep '^ID=' | sed 's/ID=//' | sed 's/^./\\U&/'" +#os = 'linux' +#style = 'bold #f5e0dc' +#when = true [nix_shell] format = '[$symbol]($style) ' @@ -94,4 +93,3 @@ error_symbol = '[](bold #f38ba8)' # TODO # - [direnv] - diff --git a/config/tmux/tmux.conf b/config/tmux/tmux.conf new file mode 100644 index 0000000..e87d8aa --- /dev/null +++ b/config/tmux/tmux.conf @@ -0,0 +1,66 @@ +set -a terminal-features "screen-256color:RGB" +set -ga terminal-overrides ",*col*:Tc" +set -g allow-passthrough all +set -ga update-environment TERM +set -ga update-environment TERM_PROGRAM +set -g prefix C-SPACE +set -g default-shell "~/.nix-profile/bin/zsh" + +set -g base-index 1 +setw -g pane-base-index 1 +set -g renumber-windows on + +set -g status-position top +set -g status-justify right +set -g status-style "bg=default" +set -g window-status-current-style "fg=#b4befe bold" +set -g message-style "bg=default fg=#b4befe bold" +set -g status-right "" +set -g status-left-length 40 +set -g status-left "#S " + +set -g mouse on + +set-option -g set-titles on +set-option -g set-titles-string "#T" + +set -g visual-activity off +set -g visual-bell off +set -g visual-silence off +setw -g monitor-activity off +set -g bell-action none + +setw -g mode-style 'fg=#000000 bg=#cdd6f4 bold' + +set -g window-style 'bg=#151515' +set -g window-active-style 'bg=#000000' + +set -g pane-border-style 'fg=#a6adc8' +set -g pane-active-border-style 'fg=#b4befe' + +bind s split-window -h -c "#{pane_current_path}" +bind v split-window -v -c "#{pane_current_path}" +unbind '"' +unbind % + +bind-key Tab next-window +bind-key k confirm-before -p "kill window #W? (y/n)" kill-window +bind-key c new-window + +bind-key t display-popup + +bind-key h select-pane -L +bind-key i select-pane -R +bind-key e select-pane -U +bind-key n select-pane -D + +bind -n M-Left select-pane -L +bind -n M-Right select-pane -R +bind -n M-Up select-pane -U +bind -n M-Down select-pane -D + +bind r source-file "~/.config/tmux/tmux.conf" \; display-message "Config reloaded" +bind b set -g status +bind g neww -n "lazygit" lazygit +bind y new-window -n "yazi" yazi +bind E show-environment -g diff --git a/config/translate-shell/init.trans b/config/translate-shell/init.trans new file mode 100644 index 0000000..5d16d36 --- /dev/null +++ b/config/translate-shell/init.trans @@ -0,0 +1,7 @@ +{ + :translate-shell "0.9.7" + :verbose false + :hl "en" + :tl "pt-br" + :user-agent "Mozilla/5.0 (X11; CrOS aarch64 15329.44.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36" +} diff --git a/config/yazi/yazi.toml b/config/yazi/yazi.toml index 4f05c94..59cc31d 100644 --- a/config/yazi/yazi.toml +++ b/config/yazi/yazi.toml @@ -5,3 +5,8 @@ show_hidden = true linemode = "size" scrolloff = 12 ratio = [1,2,0] + +[opener] +edit = [ + { run = "kak %s", block = true, for = "unix" }, +] diff --git a/config/zk/config.toml b/config/zk/config.toml index b9d3ca2..6605d1d 100644 --- a/config/zk/config.toml +++ b/config/zk/config.toml @@ -15,21 +15,20 @@ colon-tags = false multiword-tags = true [tool] -editor = "nvim" -shell = "/bin/zsh" +editor = "/home/venomade/.nix-profile/bin/emacs" +shell = "/home/venomade/.nix-profile/bin/zsh" fzf-preview = "bat -p --color always {-1}" -[alias] -todo = "zk edit TODO" - -push = "git fetch && if [ \"$(git rev-parse @)\" = \"$(git rev-parse @{u})\" ]; then git add -A && git commit -m \"Update: $(date '+%Y-%m-%d %H:%M:%S')\" && git push; else echo \"Local branch is not up‑to‑date with the remote; aborting.\"; fi" -pull = "git pull" -history = "git log --pretty=format:\"%s\" | tail -10; echo" - -rm = "rm -i $@.md" - [lsp] [lsp.diagnostics] wiki-title = "hint" dead-link = "error" missing-backlink = { level = "warning", position = "bottom" } + +[group.diario] +paths = ["Diario"] + +[group.diario.note] +filename = "{{format-date now '%Y-%m-%d'}}" +extension = "md" +template = "daily.md" diff --git a/config/zk/templates/daily.md b/config/zk/templates/daily.md new file mode 100644 index 0000000..cb128bd --- /dev/null +++ b/config/zk/templates/daily.md @@ -0,0 +1,9 @@ +--- +title: Entrada do Diário - {{format-date now '%Y-%m-%d'}} +tags: [diario, {{format-date now '%B'}}, {{format-date now 'year'}}] +--- +<!-- + +# Entrada do Diário - {{format-date now '%Y-%m-%d'}} + +{{content}} diff --git a/dots/lesskey b/dots/lesskey new file mode 100644 index 0000000..9d06169 --- /dev/null +++ b/dots/lesskey @@ -0,0 +1,4 @@ +n forw-line +e back-line +j repeat-search +J reverse-search diff --git a/dots/zshrc b/dots/zshrc new file mode 100644 index 0000000..4d4b507 --- /dev/null +++ b/dots/zshrc @@ -0,0 +1,55 @@ +# Venomade's zshrc + +# source global variables and aliases +[ -f "$HOME/.config/shell/alias" ] && source "$HOME/.config/shell/alias" +[ -f "$HOME/.config/shell/vars" ] && source "$HOME/.config/shell/vars" +[ -f "$HOME/.config/shell/functions" ] && source "$HOME/.config/shell/functions" + +# load modules +zmodload zsh/complist +autoload -U compinit && compinit +autoload -U colors && colors + +# completion +zstyle ':completion:*' menu select +zstyle ':completion:*' special-dirs true +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} ma=0\;33 + +# options +setopt append_history inc_append_history share_history +setopt auto_menu menu_complete +setopt auto_param_slash +setopt no_case_glob no_case_match +setopt globdots +setopt extended_glob +setopt share_history + +# history +export HISTFILE=~/.zsh_history +export HISTSIZE=10000 +export SAVEHIST=10000 + + +# termtitle +shorten_path() { + local path="${PWD/#$HOME/~}" + local parts=("${(@s:/:)path}") + + if (( ${#parts} > 3 )); then + echo "${parts[1]}/.../${parts[-2]}/${parts[-1]}" + else + echo "$path" + fi +} + +autoload -Uz add-zsh-hook +precmd() { + print -Pn "\e]0;$(shorten_path)\a" +} + +export STARSHIP_CONFIG=~/.config/starship/config.toml +eval "$(starship init zsh)" + +# source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + +bindkey -e diff --git a/flake.lock b/flake.lock index 0d96965..47563c9 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -20,8 +38,44 @@ "type": "github" } }, + "nix-darwin-emacs": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1772076615, + "narHash": "sha256-ELVNo7zh6N32Ooncgs9URPpWwC86tWPYoieJPLxTaGo=", + "owner": "nix-giant", + "repo": "nix-darwin-emacs", + "rev": "065050b9e06a30c01b41539b75464fff972fecd6", + "type": "github" + }, + "original": { + "owner": "nix-giant", + "repo": "nix-darwin-emacs", + "rev": "065050b9e06a30c01b41539b75464fff972fecd6", + "type": "github" + } + }, "nixpkgs": { "locked": { + "lastModified": 1759397282, + "narHash": "sha256-ohaApD0NtpszUBgTl/GGBUkNYwVgaQWivugNpuip9X8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b2f842e4d99dc35a0951b9582c64bb26789e929d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-25.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { "lastModified": 1771008912, "narHash": "sha256-gf2AmWVTs8lEq7z/3ZAsgnZDhWIckkb+ZnAo5RzSxJg=", "owner": "nixos", @@ -39,7 +93,23 @@ "root": { "inputs": { "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "nix-darwin-emacs": "nix-darwin-emacs", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 93a558c..204de9a 100644 --- a/flake.nix +++ b/flake.nix @@ -1,31 +1,34 @@ { description = "Home Manager configuration of venomade"; - inputs = { - # Specify the source of Home Manager and Nixpkgs. nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + nix-darwin-emacs = { + url = "github:nix-giant/nix-darwin-emacs/065050b9e06a30c01b41539b75464fff972fecd6"; + }; }; - outputs = - { nixpkgs, home-manager, ... }: + { nixpkgs, home-manager, nix-darwin-emacs, ... }: let - system = "aarch64-darwin"; - pkgs = nixpkgs.legacyPackages.${system}; + mkHome = system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ ./home.nix ]; + extraSpecialArgs = { + inherit system nix-darwin-emacs; + }; + }; in { - homeConfigurations."venomade" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; - - # Specify your home configuration modules here, for example, - # the path to your home.nix. - modules = [ ./home.nix ]; - - # Optionally use extraSpecialArgs - # to pass through arguments to home.nix + homeConfigurations = { + "venomade" = mkHome "aarch64-linux"; + "venomade-darwin" = mkHome "aarch64-darwin"; }; }; } diff --git a/home.nix b/home.nix index 49dd79a..7cf5f66 100644 --- a/home.nix +++ b/home.nix @@ -1,12 +1,20 @@ -{ config, lib, pkgs, ... }: - +{ config, lib, pkgs, system, nix-darwin-emacs, ... }: let - emacsFlake = builtins.getFlake "github:nix-giant/nix-darwin-emacs/065050b9e06a30c01b41539b75464fff972fecd6"; + isDarwin = builtins.match ".*-darwin" system != null; + + emacsPackage = + if isDarwin + then nix-darwin-emacs.packages.${system}.emacs-30 + else pkgs.emacs-pgtk; + + homeDirectory = + if isDarwin + then "/Users/venomade" + else "/home/venomade"; in { home.username = "venomade"; - home.homeDirectory = "/Users/venomade"; - + home.homeDirectory = homeDirectory; home.packages = with pkgs; [ # Neovim @@ -14,9 +22,16 @@ in imagemagick fzf ripgrep + fd # Emacs - (emacsFlake.packages.${system}.emacs-30) + emacsPackage + emacs-lsp-booster + + # Kakoune + kakoune + kakoune-lsp + expect # Nix nil @@ -24,20 +39,42 @@ in # Lua lua-language-server lua5_4 - lua5_4.pkgs.luarocks - # Personal + # Rust + rustc + cargo + rust-analyzer + clippy + + # C + clang + clang-tools + bear + valgrind + + # Lisp + luaPackages.fennel + fnlfmt + fennel-ls + + # Shell + zsh + tmux bat + bat-extras.batman + bat-extras.batdiff eza jellyfin-tui lazygit starship yazi zk - lima - - ]; + harper + translate-shell + ] ++ lib.optionals isDarwin [ + lima + ]; programs.git = { enable = true; settings.user = { @@ -47,20 +84,30 @@ in }; home.stateVersion = "25.11"; - programs.home-manager.enable = true; - - home.file = + home.file = let - dir = "${config.home.homeDirectory}/.dotfiles/config"; - in - lib.mapAttrs + configDir = "${config.home.homeDirectory}/.dotfiles/config"; + dotsDir = "${config.home.homeDirectory}/.dotfiles/dots"; + + configEntries = lib.mapAttrs (name: _: { target = ".config/${name}"; - source = config.lib.file.mkOutOfStoreSymlink "${dir}/${name}"; + source = config.lib.file.mkOutOfStoreSymlink "${configDir}/${name}"; recursive = true; }) (lib.filterAttrs (name: type: type == "directory") (builtins.readDir ./config)); + + dotsEntries = lib.mapAttrs + (name: _: { + target = ".${name}"; + source = config.lib.file.mkOutOfStoreSymlink "${dotsDir}/${name}"; + }) + (lib.filterAttrs + (name: type: type == "regular") + (builtins.readDir ./dots)); + in + configEntries // dotsEntries; } |
