diff options
Diffstat (limited to 'home-manager/general/programs/emacs')
| -rw-r--r-- | home-manager/general/programs/emacs/#init.el# | 735 | ||||
| -rw-r--r-- | home-manager/general/programs/emacs/config.org | 866 | ||||
| -rw-r--r-- | home-manager/general/programs/emacs/default.nix | 118 | ||||
| -rw-r--r-- | home-manager/general/programs/emacs/early-init.el | 4 | ||||
| -rw-r--r-- | home-manager/general/programs/emacs/init.el | 675 | ||||
| -rw-r--r-- | home-manager/general/programs/emacs/init.old.el | 592 | ||||
| -rw-r--r-- | home-manager/general/programs/emacs/tmpWCGTRZ | 735 |
7 files changed, 3725 insertions, 0 deletions
diff --git a/home-manager/general/programs/emacs/#init.el# b/home-manager/general/programs/emacs/#init.el# new file mode 100644 index 0000000..b17a54b --- /dev/null +++ b/home-manager/general/programs/emacs/#init.el# @@ -0,0 +1,735 @@ +(setq gc-cons-threshold (* 50 1000 1000)) + +(require 'use-package) +(eval-and-compile + (setq use-package-always-ensure t + use-package-expand-minimally t)) + +(use-package savehist + :init + (setq savehist-file "~/.config/emacs/var/savehist.el") + :config + (setq history-length 500) + (setq savehist-additional-variables '(kill-ring search-ring)) + (savehist-mode t)) + +(use-package meow + :config + (defun meow-setup () + (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty) + (meow-motion-overwrite-define-key + '("j" . meow-next) + '("k" . meow-prev) + '("<escape>" . ignore)) + (meow-leader-define-key + ;; SPC j/k will run the original command in MOTION state. + '("j" . "H-j") + '("k" . "H-k") + ;; Use SPC (0-9) for digit arguments. + '("1" . meow-digit-argument) + '("2" . meow-digit-argument) + '("3" . meow-digit-argument) + '("4" . meow-digit-argument) + '("5" . meow-digit-argument) + '("6" . meow-digit-argument) + '("7" . meow-digit-argument) + '("8" . meow-digit-argument) + '("9" . meow-digit-argument) + '("0" . meow-digit-argument) + '("/" . meow-keypad-describe-key) + '("?" . meow-cheatsheet) + '("bk" . kill-this-buffer)) + (meow-normal-define-key + '("0" . meow-expand-0) + '("9" . meow-expand-9) + '("8" . meow-expand-8) + '("7" . meow-expand-7) + '("6" . meow-expand-6) + '("5" . meow-expand-5) + '("4" . meow-expand-4) + '("3" . meow-expand-3) + '("2" . meow-expand-2) + '("1" . meow-expand-1) + '("-" . negative-argument) + '(";" . meow-reverse) + '("," . meow-inner-of-thing) + '("." . meow-bounds-of-thing) + '("[" . meow-beginning-of-thing) + '("]" . meow-end-of-thing) + '("a" . meow-append) + '("A" . meow-open-below) + '("b" . meow-back-word) + '("B" . meow-back-symbol) + '("c" . meow-change) + '("d" . meow-delete) + '("D" . meow-backward-delete) + '("e" . meow-next-word) + '("E" . meow-next-symbol) + '("f" . meow-find) + '("g" . meow-cancel-selection) + '("G" . meow-grab) + '("h" . meow-left) + '("H" . meow-left-expand) + '("i" . meow-insert) + '("I" . meow-open-above) + '("j" . meow-next) + '("J" . meow-next-expand) + '("k" . meow-prev) + '("K" . meow-prev-expand) + '("l" . meow-right) + '("L" . meow-right-expand) + '("m" . meow-join) + '("n" . meow-search) + '("o" . meow-block) + '("O" . meow-to-block) + '("p" . meow-yank) + '("q" . meow-quit) + '("Q" . meow-goto-line) + '("r" . meow-replace) + '("R" . meow-swap-grab) + '("s" . meow-kill) + '("t" . meow-till) + '("u" . meow-undo) + '("U" . meow-undo-in-selection) + '("v" . meow-visit) + '("w" . meow-mark-word) + '("W" . meow-mark-symbol) + '("x" . meow-line) + '("X" . meow-goto-line) + '("y" . meow-save) + '("Y" . meow-sync-grab) + '("z" . meow-pop-selection) + '("'" . repeat) + '("<escape>" . ignore))) + (setq meow-use-enhanced-selection-effect t) + (meow-setup)) + ;; (meow-global-mode 1)) + +(use-package kakoune + ;; Having a non-chord way to escape is important, since key-chords don't work in macros + :bind ("C-z" . ryo-modal-mode) + :hook (after-init . my/kakoune-setup) + :config + (defun ryo-enter () "Enter normal mode" (interactive) (ryo-modal-mode 1)) + (defun my/kakoune-setup () + "Call kakoune-setup-keybinds and then add some personal config." + (kakoune-setup-keybinds) + (setq ryo-modal-cursor-type 'box) + (add-hook 'prog-mode-hook #'ryo-enter) + (define-key ryo-modal-mode-map (kbd "SPC h") 'help-command) + ;; Access all C-x bindings easily + (define-key ryo-modal-mode-map (kbd "z") ctl-x-map) + (ryo-modal-keys + ("," save-buffer) + ("P" counsel-yank-pop) + ("m" mc/mark-next-like-this) + ("M" mc/skip-to-next-like-this) + ("n" mc/mark-previous-like-this) + ("N" mc/skip-to-previous-like-this) + ("M-m" mc/edit-lines) + ("*" mc/mark-all-like-this) + ("v" er/expand-region) + ("C-v" set-rectangular-region-anchor) + ("M-s" mc/split-region) + (";" (("q" delete-window) + ("v" split-window-horizontally) + ("s" split-window-vertically))) + ("C-h" windmove-left) + ("C-j" windmove-down) + ("C-k" windmove-up) + ("C-l" windmove-right) + ("C-u" scroll-down-command :first '(deactivate-mark)) + ("C-d" scroll-up-command :first '(deactivate-mark))))) + +;; This overrides the default mark-in-region with a prettier-looking one, +;; and provides a couple extra commands +(use-package visual-regexp + :ryo + ("s" vr/mc-mark) + ("?" vr/replace) + ("M-/" vr/query-replace)) + +;; Emacs incremental search doesn't work with multiple cursors, but this fixes that +(use-package phi-search + :bind (("C-s" . phi-search) + ("C-r" . phi-search-backward))) + +;; Probably the first thing you'd miss is undo and redo, which requires an extra package +;; to work like it does in kakoune (and almost every other editor). +(use-package undo-tree + :config + (global-undo-tree-mode) + :ryo + ("u" undo-tree-undo) + ("U" undo-tree-redo) + ("SPC u" undo-tree-visualize) + :bind (:map undo-tree-visualizer-mode-map + ("h" . undo-tree-visualize-switch-branch-left) + ("j" . undo-tree-visualize-redo) + ("k" . undo-tree-visualize-undo) + ("l" . undo-tree-visualize-switch-branch-right))) + + +(use-package general + :config + ;; SPC as the global leader key + (general-create-definer spl3g/leader-keys + :prefix "C-c") + + (spl3g/leader-keys + ;; Buffers + "b" '(:ignore t :wk "Buffer") + "bi" '(ibuffer :wk "ibuffer") + "bk" '(kill-this-buffer :wk "Kill this buffer") + "bn" '(next-buffer :wk "Next buffer") + "bp" '(previous-buffer :wk "Previous buffer") + "br" '(revert-buffer :wk "Reload buffer") + "." '(find-file :wk "Find file") + ;; Splits + "w" '(:ignore t :wk "Splits") + "wv" '(split-window-right :wk "Split vertical") + "ws" '(split-window-below :wk "Split") + "ww" '(other-window :wk "Cycle throug windows") + "wc" '(delete-window :wk "Close window") + "wd" '(delete-window :wk "Close window") + "wl" '(evil-window-right :wk "") + "wj" '(evil-window-down :wk "") + "wk" '(evil-window-up :wk "") + "wh" '(evil-window-left :wk "") + "wo" '(delete-other-windows :wk "") + ;; Files + "f" '(:ignore t :wk "Files") + "fc" '((lambda () (interactive) (find-file "~/nixfiles/home-manager/programs/emacs/config.org")) :wk "Edit emacs config") + "fu" '(crux-sudo-edit :wk "Sudo edit file") + ;; Compilation + "c" '(:ignore t :wk "Compilation") + "cc" '(compile :wk "Compile") + "cr" '(recompile :wk "Recompile") + )) + +(defun spl3g/disable-scroll-bars (frame) + (modify-frame-parameters frame + '((vertical-scroll-bars . nil) + (horizontal-scroll-bars . nil)))) +(add-hook 'after-make-frame-functions 'spl3g/disable-scroll-bars) + +(setq default-frame-alist '((font . "Source Code Pro"))) +(set-face-attribute 'default nil + :font "Source Code Pro" + :height 110 + :weight 'medium) +(set-face-attribute 'fixed-pitch nil + :font "Source Code Pro" + :height 110 + :weight 'medium) +(set-face-attribute 'variable-pitch nil + :font "Rubik" + :height 110 + :weight 'medium) +(set-face-attribute 'font-lock-comment-face nil + :slant 'italic) +(set-face-attribute 'font-lock-keyword-face nil + :weight 'bold) + +(add-hook 'prog-mode-hook 'display-line-numbers-mode) +(visual-line-mode 1) + +(use-package catppuccin-theme + :ensure t + :config + (load-theme 'catppuccin t) + (setq catppuccin-flavor 'macchiato) + (catppuccin-reload)) + +(use-package all-the-icons + :ensure t + :if (display-graphic-p)) + +(use-package mood-line + + ;; Enable mood-line + :config + (mood-line-mode) + :custom + (mood-line-segment-modal-meow-state-alist + '((normal "N" . mood-line-meow-normal) + (insert "I" . mood-line-meow-insert) + (keypad "K" . mood-line-meow-keypad) + (beacon "B" . mood-line-meow-beacon) + (motion "M" . mood-line-meow-motion))) + (mood-line-glyph-alist mood-line-glyphs-fira-code) + :custom-face + (mood-line-meow-beacon ((t (:foreground "#f9e2af" :weight bold)))) + (mood-line-meow-insert ((t (:foreground "#a6e3a1" :weight bold)))) + (mood-line-meow-keypad ((t (:foreground "#cba6f7" :weight bold)))) + (mood-line-meow-motion ((t (:foreground "#fab387" :weight bold)))) + (mood-line-meow-normal ((t (:weight bold)))) + (mode-line-inactive ((t (:box (:line-width (2 . 6) :color "#11111b") :inverse-video nil :foreground "#6c7086" :background "#11111b")))) + (mode-line ((t (:box (:line-width (2 . 6) :color "#181825") :background "#181825"))))) + +(use-package good-scroll + :init (good-scroll-mode)) + +(use-package dashboard + :init + (dashboard-setup-startup-hook) + :config + (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) + (setq dashboard-banner-logo-title "Yep, it's emacs, not vim") + (setq dashboard-startup-banner 'logo) + (setq dashboard-center-content t) + (add-to-list 'dashboard-item-generators '(config . dashboard-open-config)) + (setq dashboard-items '((recents . 5) + (agenda . 5)))) + +(setq ring-bell-function 'ignore) + +(use-package indent-guide + :hook (prog-mode . indent-guide-mode)) + +(setq window-resize-pixelwise t) +(setq frame-resize-pixelwise t) +(save-place-mode t) +(defalias 'yes-or-no #'y-or-n-p) + +(add-hook 'org-mode-hook 'org-indent-mode) +(require 'org-tempo) + +(use-package toc-org + :hook (org-mode . toc-org-mode)) + +(use-package org-bullets + :hook (org-mode . org-bullets-mode)) + +(use-package org-auto-tangle + :hook (org-mode . org-auto-tangle-mode)) + +(use-package org-download + :hook + (dired-mode . org-download-enable)) + +(use-package direnv + :config + (direnv-mode)) + +(use-package vertico + :init + (vertico-mode) + :bind (:map vertico-map + ("M-j" . vertico-next) + ("M-k" . vertico-previous) + ("RET" . vertico-directory-enter) + ("DEL" . vertico-directory-delete-char) + ("M-DEL" . vertico-directory-delete-word))) + +(use-package emacs + :init + ;; Add prompt indicator to `completing-read-multiple'. + ;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma. + (defun crm-indicator (args) + (cons (format "[CRM%s] %s" + (replace-regexp-in-string + "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" + crm-separator) + (car args)) + (cdr args))) + (advice-add #'completing-read-multiple :filter-args #'crm-indicator) + + ;; Do not allow the cursor in the minibuffer prompt + (setq minibuffer-prompt-properties + '(read-only t cursor-intangible t face minibuffer-prompt)) + (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) + + ;; Emacs 28: Hide commands in M-x which do not work in the current mode. + ;; Vertico commands are hidden in normal buffers. + ;; (setq read-extended-command-predicate + ;; #'command-completion-default-include-p) + + ;; Enable recursive minibuffers + (setq enable-recursive-minibuffers t)) + +(use-package orderless + :init + (setq completion-styles '(orderless basic) + completion-category-defaults nil + completion-category-overrides '((file (styles partial-completion))))) + +(use-package marginalia + :bind (:map minibuffer-local-map + ("M-A" . marginalia-cycle)) + :init + (marginalia-mode)) + +(use-package consult + ;; Replace bindings. Lazily loaded due by `use-package'. + :bind (;; C-c bindings in `mode-specific-map' + ("C-c k" . consult-kmacro) + ("C-c m" . consult-man) + ("C-c i" . consult-info) + ([remap Info-search] . consult-info) + ("C-c f r" . consult-recent-file) + ("C-c ," . consult-buffer) + ;; C-x bindings in `ctl-x-map' + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer + ;; Custom M-# bindings for fast register access + ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("C-M-#" . consult-register) + ;; Other custom bindings + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ;; M-g bindings in `goto-map' + ("C-c c e" . consult-compile-error) + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ;; M-s bindings in `search-map' + ("M-s d" . consult-fd) + ("M-s g" . consult-grep) + ("M-s G" . consult-git-grep) + ("M-s l" . consult-line) + ("M-s L" . consult-line-multi) + ("M-s k" . consult-keep-lines) + ("M-s u" . consult-focus-lines) + ;; Isearch integration + ("M-s e" . consult-isearch-history) + :map isearch-mode-map + ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch + ("M-r" . consult-history) + ;; Minibuffer history + :map minibuffer-local-map + ("M-s" . consult-history) ;; orig. next-matching-history-element + ("M-r" . consult-history)) ;; orig. previous-matching-history-element) + + ;; Enable automatic preview at point in the *Completions* buffer. This is + ;; relevant when you use the default completion UI. + :hook + (completion-list-mode . consult-preview-at-point-mode) + (eshell-mode . (lambda () + (keymap-set eshell-mode-map "M-h" 'consult-history))) + + ;; The :init configuration is always executed (Not lazy) + :init + + ;; Optionally configure the register formatting. This improves the register + ;; preview for `consult-register', `consult-register-load', + ;; `consult-register-store' and the Emacs built-ins. + (setq register-preview-delay 0.5 + register-preview-function #'consult-register-format) + + ;; Optionally tweak the register preview window. + ;; This adds thin lines, sorting and hides the mode line of the window. + (advice-add #'register-preview :override #'consult-register-window) + + ;; Configure other variables and modes in the :config section, + ;; after lazily loading the package. + :config + + ;; Optionally configure preview. The default value + ;; is 'any, such that any key triggers the preview. + ;; (setq consult-preview-key 'any) + ;; (setq consult-preview-key "M-.") + ;; (setq consult-preview-key '("S-<down>" "S-<up>")) + ;; For some commands and buffer sources it is useful to configure the + ;; :preview-key on a per-command basis using the `consult-customize' macro. + (consult-customize + consult-ripgrep consult-git-grep consult-grep + consult-bookmark consult-recent-file consult-xref + consult--source-bookmark consult--source-file-register + consult--source-recent-file consult--source-project-recent-file) + ;; :preview-key "M-." + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; "C-+" + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) + + ;; By default `consult-project-function' uses `project-root' from project.el. + ;; Optionally configure a different project root function. +;;;; 1. project.el (the default) + ;; (setq consult-project-function #'consult--default-project--function) +;;;; 2. vc.el (vc-root-dir) + ;; (setq consult-project-function (lambda (_) (vc-root-dir))) +;;;; 3. locate-dominating-file + ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git"))) +;;;; 4. projectile.el (projectile-project-root) + ;; (autoload 'projectile-project-root "projectile") + ;; (setq consult-project-function (lambda (_) (projectile-project-root))) +;;;; 5. No project support + ;; (setq consult-project-function nil) + ) + +(use-package smartparens + :init (smartparens-global-mode) + :config + ;; Snitched from doom + (let ((unless-list '(sp-point-before-word-p + sp-point-after-word-p + sp-point-before-same-p))) + (sp-pair "'" nil :unless unless-list) + (sp-pair "\"" nil :unless unless-list)) + (dolist (brace '("(" "{" "[")) + (sp-pair brace nil + :post-handlers '(("||\n[i]" "RET") ("| " "SPC")) + :unless '(sp-point-before-word-p sp-point-before-same-p))) + (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) + (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) + + (sp-local-pair '(python-mode python-ts-mode) "f'" "'") + + ;; Major-mode specific fixes + (sp-local-pair 'ruby-mode "{" "}" + :pre-handlers '(:rem sp-ruby-pre-handler) + :post-handlers '(:rem sp-ruby-post-handler)) + + ;; Don't do square-bracket space-expansion where it doesn't make sense to + (sp-local-pair '(emacs-lisp-mode org-mode markdown-mode gfm-mode) + "[" nil :post-handlers '(:rem ("| " "SPC"))) + + (sp-local-pair '(emacs-lisp-mode org-mode) + "'" nil) + + ;; Reasonable default pairs for HTML-style comments + (sp-local-pair (append sp--html-modes '(markdown-mode gfm-mode)) + "<!--" "-->" + :unless '(sp-point-before-word-p sp-point-before-same-p) + :actions '(insert) :post-handlers '(("| " "SPC"))) + ;; Expand C-style comment blocks. + (defun +default-open-doc-comments-block (&rest _ignored) + (save-excursion + (newline) + (indent-according-to-mode))) + (sp-local-pair + '(js2-mode typescript-mode rjsx-mode rust-mode c-mode c++-mode objc-mode + csharp-mode java-mode php-mode css-mode scss-mode less-css-mode + stylus-mode scala-mode) + "/*" "*/" + :actions '(insert) + :post-handlers '(("| " "SPC") + (" | " "*") + ("|[i]\n[i]" "RET")))) + +;; (use-package dap-mode +;; :defer t +;; :config +;; (require 'dap-python) +;; (setq dap-python-debugger 'debugpy)) + +(use-package move-text + :bind (("C-M-k" . move-text-up) + ("C-M-j" . move-text-down))) + +(global-visual-line-mode t) + +(use-package no-littering) + +(use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) + +(use-package crux + :bind (("C-c o t" . crux-visit-shell-buffer))) + +(use-package helpful + :bind (("C-h f" . 'helpful-callable) + ("C-h v" . 'helpful-variable) + ("C-h k" . 'helpful-key) + ("C-h x" . 'helpful-command) + ("C-c C-d" . 'helpful-at-point) + ("C-h F" . 'helpful-function))) + +(add-hook 'eshell-mode-hook + (lambda () + (keymap-set eshell-mode-map "M-<tab>" 'consult-fish-completions))) + +(use-package eat + :hook (eshell-mode . eat-eshell-mode) + :custom + (eat-enable-auto-line-mode t)) + +;; (defun eat-toggle () +;; "Open eat terminal as a popup." +;; (interactive) +;; (if (eq major-mode 'eat-mode) +;; (delete-window) +;; (let ((buff (get-buffer-create eat-buffer-name))) +;; (cl-assert (and buff (buffer-live-p buff))) +;; (funcall #'pop-to-buffer buff) +;; (with-current-buffer buff +;; (setq-local split-width-threshold nil) +;; (setq-local window-min-height 2) +;; (unless (derived-mode-p 'eat-mode) +;; (eat)))))) + +;; (defun eat-modes() +;; (cond +;; ((and (eq major-mode 'eat-mode) (member 'meow-normal-mode local-minor-modes)) +;; (eat-emacs-mode)) +;; ((and (eq major-mode 'eat-mode) (member 'meow-insert-mode local-minor-modes)) +;; (eat-semi-char-mode)))) +;; (add-hook 'meow-normal-mode-hook #'eat-modes) +;; (add-hook 'meow-insert-mode-hook #'eat-modes) + +(use-package fish-completion + :hook (eshell-mode . fish-completion-mode)) + +(use-package eglot + :bind (("C-c s e e" . eglot) + ("C-c s e d" . eldoc) + ("C-c s e r" . eglot-rename) + ("C-c s e s" . eglot-shutdown) + ("C-c s e f" . eglot-find-declaration) + ("C-c s e i" . eglot-find-implementation)) + :hook + (nix-mode . eglot-ensure) + (python-ts-mode . eglot-ensure) + :config + (add-to-list 'eglot-server-programs '(python-ts-mode . ("pylsp")))) + +(use-package lsp-pyright) +(use-package py-autopep8 + :hook (python-mode . py-autopep8-mode)) + +(use-package rust-mode + :mode "\\.rs\\'") +(use-package flycheck-rust + :config + (with-eval-after-load 'rust-mode + (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))) + +(use-package fish-mode + :mode "\\.fish\\'") + +(use-package nix-mode + :mode ("\\.nix\\'" "\\.nix.in\\'")) +(use-package nix-drv-mode + :ensure nix-mode + :mode "\\.drv\\'") +(use-package nix-shell + :ensure nix-mode + :commands (nix-shell-unpack nix-shell-configure nix-shell-build)) +(use-package nix-repl + :ensure nix-mode + :commands (nix-repl)) + +(use-package web-mode + :mode + ("\\.phtml\\'" + "\\.tpl\\.php\\'" + "\\.[agj]sp\\'" + "\\.as[cp]x\\'" + "\\.erb\\'" + "\\.mustache\\'" + "\\.djhtml\\'")) + +(use-package js2-mode) + +(use-package corfu + :custom + (corfu-cycle t) + (corfu-preselect 'prompt) + (corfu-auto t) + (corfu-popupinfo-delay 0.0) + :bind + (:map corfu-map + ("TAB" . corfu-next) + ([tab] . corfu-next) + ("S-TAB" . corfu-previous) + ([backtab] . corfu-previous)) + + :init + (global-corfu-mode) + (corfu-history-mode) + (corfu-popupinfo-mode) + :config + (add-to-list 'savehist-additional-variables 'corfu-history)) +(use-package emacs + :init + (setq completion-cycle-threshold 3) + + (setq read-extended-command-predicate + #'command-completion-default-include-p) + + (setq tab-always-indent 'complete)) + +(use-package cape + :demand t + :config + (add-to-list 'completion-at-point-functions #'cape-dabbrev) + (add-to-list 'completion-at-point-functions #'cape-file) + (add-to-list 'completion-at-point-functions #'cape-elisp-block) + ) + +(use-package tree-sitter + :init + (global-tree-sitter-mode) + :config + (add-hook 'tree-sitter-mode-hook 'tree-sitter-hl-mode)) +(use-package treesit-auto + :custom + (treesit-auto-install 'prompt) + :config + (treesit-auto-add-to-auto-mode-alist 'all) + (global-treesit-auto-mode)) + +(use-package tree-sitter-langs) + +;; (use-package yasnippet +;; :init (yas-global-mode)) +;; (use-package yasnippet-snippets) + +(use-package flymake + :after eglot + :bind (("C-c s f f" . flymake-start) + ("C-c s f l" . flymake-show-buffer-diagnostics) + ("C-c s f p" . flymake-show-project-diagnostics))) + +(use-package dired + :custom + (dired-listing-switches "-al --group-directories-first")) + + + +;; (add-to-list 'load-path "~/telega.el") +;; (require 'telega) + +(use-package magit + :bind (("C-c o g" . magit))) + +;; (use-package exwm) +;; (require 'exwm) +;; (require 'exwm-config) +;; (exwm-config-example) + +;; (use-package code-cells) + +;; (use-package orgnote +;; :defer t) + +(use-package copilot + :hook (python-ts-mode . copilot-mode) + :bind ("M-RET" . copilot-accept-completion)) + +(setq gc-cons-threshold (* 2 1000 1000)) +(setq read-process-output-max (* 1024 1024)) +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(package-selected-packages + '(dired web-mode vertico use-package treesit-auto tree-sitter-langs toc-org smartparens rust-mode rainbow-delimiters py-autopep8 org-download org-bullets org-auto-tangle orderless no-littering nix-mode move-text mood-line marginalia magit lsp-pyright kakoune js2-mode indent-guide helpful good-scroll general flycheck-rust fish-mode fish-completion eglot eat direnv dashboard crux corfu copilot consult catppuccin-theme cape all-the-icons snow meow))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + ) diff --git a/home-manager/general/programs/emacs/config.org b/home-manager/general/programs/emacs/config.org new file mode 100644 index 0000000..5cbd3b1 --- /dev/null +++ b/home-manager/general/programs/emacs/config.org @@ -0,0 +1,866 @@ +#+Title: spl3g's Emacs config +#+AUTHOR: spl3g +#+STARTUP: showeverything +#+PROPERTY: header-args :tangle init.el +#+OPTIONS: toc:2 +#+auto_tangle: t + +* Table Of Contents :toc: +- [[#progs-to-load-first][Progs to load first]] + - [[#optimise-gc][Optimise gc]] + - [[#use-package][use-package]] + - [[#save-history][Save history]] + - [[#meow-mode][Meow mode]] + - [[#general-keybindings][General keybindings]] +- [[#gui-tweaks][GUI tweaks]] + - [[#disable-gui-shit][Disable gui shit]] + - [[#fonts][Fonts]] + - [[#display-line-numbers][Display line numbers]] + - [[#theme][Theme]] + - [[#icons][Icons]] + - [[#modeline][Modeline]] + - [[#smooth-scroll][Smooth scroll]] + - [[#dashboard][Dashboard]] + - [[#disable-ring-bell][Disable ring-bell]] + - [[#indent-guide][Indent guide]] + - [[#misc][Misc]] +- [[#org-mode][Org mode]] + - [[#enabling-toc][Enabling toc]] + - [[#org-bullets][Org bullets]] + - [[#auto-tangle][Auto-tangle]] + - [[#org-download][Org-download]] + - [[#direnv][Direnv]] +- [[#better-ux][Better UX]] + - [[#vertico][Vertico]] + - [[#consult][Consult]] + - [[#pairs][Pairs]] + - [[#debugging][Debugging]] + - [[#move-lines][Move lines]] + - [[#truncate-lines][Truncate lines]] + - [[#no-littering][No littering]] + - [[#rainbow-delimiters][Rainbow delimiters]] + - [[#crux][Crux]] + - [[#better-help][Better *help*]] +- [[#eshell][Eshell]] + - [[#fish-completions][Fish completions]] + - [[#eat][Eat]] +- [[#lsp][LSP]] + - [[#languages][Languages]] + - [[#corfu][Corfu]] + - [[#tree-sitter][Tree-sitter]] + - [[#snippets][Snippets]] + - [[#flymake][Flymake]] +- [[#dired][Dired]] + - [[#bindings][Bindings]] + - [[#dired-filter][Dired filter]] +- [[#additional-apps][Additional apps]] + - [[#telegram-lol][Telegram lol]] + - [[#magit][Magit]] + - [[#exwm][EXWM]] + - [[#jupyter][Jupyter]] + - [[#orgnote][Orgnote]] + - [[#copilot][Copilot]] +- [[#runtime-performance][Runtime Performance]] + +* Progs to load first +** Optimise gc +#+begin_src emacs-lisp + (setq gc-cons-threshold (* 50 1000 1000)) +#+end_src +** use-package +#+begin_src emacs-lisp + (require 'use-package) + (eval-and-compile + (setq use-package-always-ensure t + use-package-expand-minimally t)) +#+end_src +** Save history +#+begin_src emacs-lisp + (use-package savehist + :init + (setq savehist-file "~/.config/emacs/var/savehist.el") + :config + (setq history-length 500) + (setq savehist-additional-variables '(kill-ring search-ring)) + (savehist-mode t)) +#+end_src +** Meow mode +#+begin_src emacs-lisp + (use-package meow + :config + (defun meow-setup () + (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty) + (meow-motion-overwrite-define-key + '("j" . meow-next) + '("k" . meow-prev) + '("<escape>" . ignore)) + (meow-leader-define-key + ;; SPC j/k will run the original command in MOTION state. + '("j" . "H-j") + '("k" . "H-k") + ;; Use SPC (0-9) for digit arguments. + '("1" . meow-digit-argument) + '("2" . meow-digit-argument) + '("3" . meow-digit-argument) + '("4" . meow-digit-argument) + '("5" . meow-digit-argument) + '("6" . meow-digit-argument) + '("7" . meow-digit-argument) + '("8" . meow-digit-argument) + '("9" . meow-digit-argument) + '("0" . meow-digit-argument) + '("/" . meow-keypad-describe-key) + '("?" . meow-cheatsheet) + '("bk" . kill-this-buffer)) + (meow-normal-define-key + '("0" . meow-expand-0) + '("9" . meow-expand-9) + '("8" . meow-expand-8) + '("7" . meow-expand-7) + '("6" . meow-expand-6) + '("5" . meow-expand-5) + '("4" . meow-expand-4) + '("3" . meow-expand-3) + '("2" . meow-expand-2) + '("1" . meow-expand-1) + '("-" . negative-argument) + '(";" . meow-reverse) + '("," . meow-inner-of-thing) + '("." . meow-bounds-of-thing) + '("[" . meow-beginning-of-thing) + '("]" . meow-end-of-thing) + '("a" . meow-append) + '("A" . meow-open-below) + '("b" . meow-back-word) + '("B" . meow-back-symbol) + '("c" . meow-change) + '("d" . meow-delete) + '("D" . meow-backward-delete) + '("e" . meow-next-word) + '("E" . meow-next-symbol) + '("f" . meow-find) + '("g" . meow-cancel-selection) + '("G" . meow-grab) + '("h" . meow-left) + '("H" . meow-left-expand) + '("i" . meow-insert) + '("I" . meow-open-above) + '("j" . meow-next) + '("J" . meow-next-expand) + '("k" . meow-prev) + '("K" . meow-prev-expand) + '("l" . meow-right) + '("L" . meow-right-expand) + '("m" . meow-join) + '("n" . meow-search) + '("o" . meow-block) + '("O" . meow-to-block) + '("p" . meow-yank) + '("q" . meow-quit) + '("Q" . meow-goto-line) + '("r" . meow-replace) + '("R" . meow-swap-grab) + '("s" . meow-kill) + '("t" . meow-till) + '("u" . meow-undo) + '("U" . meow-undo-in-selection) + '("v" . meow-visit) + '("w" . meow-mark-word) + '("W" . meow-mark-symbol) + '("x" . meow-line) + '("X" . meow-goto-line) + '("y" . meow-save) + '("Y" . meow-sync-grab) + '("z" . meow-pop-selection) + '("'" . repeat) + '("<escape>" . ignore))) + (setq meow-use-enhanced-selection-effect t) + (meow-setup) + (meow-global-mode 1)) +#+end_src +** General keybindings +#+begin_src emacs-lisp + (use-package general + :config + ;; SPC as the global leader key + (general-create-definer spl3g/leader-keys + :prefix "C-c") + + (spl3g/leader-keys + ;; Buffers + "b" '(:ignore t :wk "Buffer") + "bi" '(ibuffer :wk "ibuffer") + "bk" '(kill-this-buffer :wk "Kill this buffer") + "bn" '(next-buffer :wk "Next buffer") + "bp" '(previous-buffer :wk "Previous buffer") + "br" '(revert-buffer :wk "Reload buffer") + "." '(find-file :wk "Find file") + ;; Splits + "w" '(:ignore t :wk "Splits") + "wv" '(split-window-right :wk "Split vertical") + "ws" '(split-window-below :wk "Split") + "ww" '(other-window :wk "Cycle throug windows") + "wc" '(delete-window :wk "Close window") + "wd" '(delete-window :wk "Close window") + "wl" '(evil-window-right :wk "") + "wj" '(evil-window-down :wk "") + "wk" '(evil-window-up :wk "") + "wh" '(evil-window-left :wk "") + "wo" '(delete-other-windows :wk "") + ;; Files + "f" '(:ignore t :wk "Files") + "fc" '((lambda () (interactive) (find-file "~/nixfiles/home-manager/programs/emacs/config.org")) :wk "Edit emacs config") + "fu" '(crux-sudo-edit :wk "Sudo edit file") + ;; Compilation + "c" '(:ignore t :wk "Compilation") + "cc" '(compile :wk "Compile") + "cr" '(recompile :wk "Recompile") + )) + +#+end_src +* GUI tweaks +** Disable gui shit +#+begin_src emacs-lisp + (defun spl3g/disable-scroll-bars (frame) + (modify-frame-parameters frame + '((vertical-scroll-bars . nil) + (horizontal-scroll-bars . nil)))) + (add-hook 'after-make-frame-functions 'spl3g/disable-scroll-bars) +#+end_src +** Fonts +#+begin_src emacs-lisp + (setq default-frame-alist '((font . "Source Code Pro"))) + (set-face-attribute 'default nil + :font "Source Code Pro" + :height 110 + :weight 'medium) + (set-face-attribute 'fixed-pitch nil + :font "Source Code Pro" + :height 110 + :weight 'medium) + (set-face-attribute 'variable-pitch nil + :font "Rubik" + :height 110 + :weight 'medium) + (set-face-attribute 'font-lock-comment-face nil + :slant 'italic) + (set-face-attribute 'font-lock-keyword-face nil + :weight 'bold) +#+end_src +** Display line numbers +#+begin_src emacs-lisp +(add-hook 'prog-mode-hook 'display-line-numbers-mode) +(visual-line-mode 1) +#+end_src + +** Theme +#+begin_src emacs-lisp +(use-package catppuccin-theme + :ensure t + :config + (load-theme 'catppuccin t) + (setq catppuccin-flavor 'macchiato) + (catppuccin-reload)) +#+end_src + +** Icons +#+begin_src emacs-lisp + (use-package all-the-icons + :ensure t + :if (display-graphic-p)) +#+end_src +** Modeline +#+begin_src emacs-lisp + (use-package mood-line + + ;; Enable mood-line + :config + (mood-line-mode) + :custom + (mood-line-segment-modal-meow-state-alist + '((normal "N" . mood-line-meow-normal) + (insert "I" . mood-line-meow-insert) + (keypad "K" . mood-line-meow-keypad) + (beacon "B" . mood-line-meow-beacon) + (motion "M" . mood-line-meow-motion))) + (mood-line-glyph-alist mood-line-glyphs-fira-code) + :custom-face + (mood-line-meow-beacon ((t (:foreground "#f9e2af" :weight bold)))) + (mood-line-meow-insert ((t (:foreground "#a6e3a1" :weight bold)))) + (mood-line-meow-keypad ((t (:foreground "#cba6f7" :weight bold)))) + (mood-line-meow-motion ((t (:foreground "#fab387" :weight bold)))) + (mood-line-meow-normal ((t (:weight bold)))) + (mode-line-inactive ((t (:box (:line-width (2 . 6) :color "#11111b") :inverse-video nil :foreground "#6c7086" :background "#11111b")))) + (mode-line ((t (:box (:line-width (2 . 6) :color "#181825") :background "#181825"))))) +#+end_src + +** Smooth scroll +#+begin_src emacs-lisp + (use-package good-scroll + :init (good-scroll-mode)) +#+end_src + +** Dashboard +#+begin_src emacs-lisp + (use-package dashboard + :init + (dashboard-setup-startup-hook) + :config + (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) + (setq dashboard-banner-logo-title "Yep, it's emacs, not vim") + (setq dashboard-startup-banner 'logo) + (setq dashboard-center-content t) + (add-to-list 'dashboard-item-generators '(config . dashboard-open-config)) + (setq dashboard-items '((recents . 5) + (agenda . 5)))) +#+end_src +** Disable ring-bell +#+begin_src emacs-lisp + (setq ring-bell-function 'ignore) +#+end_src +** Indent guide +#+begin_src emacs-lisp + (use-package indent-guide + :hook (prog-mode . indent-guide-mode)) +#+end_src +** Misc +#+begin_src emacs-lisp + (setq window-resize-pixelwise t) + (setq frame-resize-pixelwise t) + (save-place-mode t) + (defalias 'yes-or-no #'y-or-n-p) +#+end_src +* Org mode +#+begin_src emacs-lisp + (add-hook 'org-mode-hook 'org-indent-mode) + (require 'org-tempo) +#+end_src + +** Enabling toc +#+begin_src emacs-lisp + (use-package toc-org + :hook (org-mode . toc-org-mode)) +#+end_src + +** Org bullets +#+begin_src emacs-lisp + (use-package org-bullets + :hook (org-mode . org-bullets-mode)) +#+end_src +** Auto-tangle +#+begin_src emacs-lisp + (use-package org-auto-tangle + :hook (org-mode . org-auto-tangle-mode)) +#+end_src +** Org-download +#+begin_src emacs-lisp + (use-package org-download + :hook + (dired-mode . org-download-enable)) +#+end_src +** Direnv +#+begin_src emacs-lisp + (use-package direnv + :config + (direnv-mode)) +#+end_src +* Better UX +** Vertico +#+begin_src emacs-lisp + (use-package vertico + :init + (vertico-mode) + :bind (:map vertico-map + ("M-j" . vertico-next) + ("M-k" . vertico-previous) + ("RET" . vertico-directory-enter) + ("DEL" . vertico-directory-delete-char) + ("M-DEL" . vertico-directory-delete-word))) + + (use-package emacs + :init + ;; Add prompt indicator to `completing-read-multiple'. + ;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma. + (defun crm-indicator (args) + (cons (format "[CRM%s] %s" + (replace-regexp-in-string + "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" + crm-separator) + (car args)) + (cdr args))) + (advice-add #'completing-read-multiple :filter-args #'crm-indicator) + + ;; Do not allow the cursor in the minibuffer prompt + (setq minibuffer-prompt-properties + '(read-only t cursor-intangible t face minibuffer-prompt)) + (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) + + ;; Emacs 28: Hide commands in M-x which do not work in the current mode. + ;; Vertico commands are hidden in normal buffers. + ;; (setq read-extended-command-predicate + ;; #'command-completion-default-include-p) + + ;; Enable recursive minibuffers + (setq enable-recursive-minibuffers t)) +#+end_src +*** Ordeless +#+begin_src emacs-lisp + (use-package orderless + :init + (setq completion-styles '(orderless basic) + completion-category-defaults nil + completion-category-overrides '((file (styles partial-completion))))) +#+end_src +*** Marginalia +#+begin_src emacs-lisp + (use-package marginalia + :bind (:map minibuffer-local-map + ("M-A" . marginalia-cycle)) + :init + (marginalia-mode)) +#+end_src +** Consult +#+begin_src emacs-lisp + (use-package consult + ;; Replace bindings. Lazily loaded due by `use-package'. + :bind (;; C-c bindings in `mode-specific-map' + ("C-c k" . consult-kmacro) + ("C-c m" . consult-man) + ("C-c i" . consult-info) + ([remap Info-search] . consult-info) + ("C-c f r" . consult-recent-file) + ("C-c ," . consult-buffer) + ;; C-x bindings in `ctl-x-map' + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer + ;; Custom M-# bindings for fast register access + ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("C-M-#" . consult-register) + ;; Other custom bindings + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ;; M-g bindings in `goto-map' + ("C-c c e" . consult-compile-error) + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ;; M-s bindings in `search-map' + ("M-s d" . consult-fd) + ("M-s g" . consult-grep) + ("M-s G" . consult-git-grep) + ("M-s l" . consult-line) + ("M-s L" . consult-line-multi) + ("M-s k" . consult-keep-lines) + ("M-s u" . consult-focus-lines) + ;; Isearch integration + ("M-s e" . consult-isearch-history) + :map isearch-mode-map + ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch + ("M-r" . consult-history) + ;; Minibuffer history + :map minibuffer-local-map + ("M-s" . consult-history) ;; orig. next-matching-history-element + ("M-r" . consult-history)) ;; orig. previous-matching-history-element) + + ;; Enable automatic preview at point in the *Completions* buffer. This is + ;; relevant when you use the default completion UI. + :hook + (completion-list-mode . consult-preview-at-point-mode) + (eshell-mode . (lambda () + (keymap-set eshell-mode-map "M-h" 'consult-history))) + + ;; The :init configuration is always executed (Not lazy) + :init + + ;; Optionally configure the register formatting. This improves the register + ;; preview for `consult-register', `consult-register-load', + ;; `consult-register-store' and the Emacs built-ins. + (setq register-preview-delay 0.5 + register-preview-function #'consult-register-format) + + ;; Optionally tweak the register preview window. + ;; This adds thin lines, sorting and hides the mode line of the window. + (advice-add #'register-preview :override #'consult-register-window) + + ;; Configure other variables and modes in the :config section, + ;; after lazily loading the package. + :config + + ;; Optionally configure preview. The default value + ;; is 'any, such that any key triggers the preview. + ;; (setq consult-preview-key 'any) + ;; (setq consult-preview-key "M-.") + ;; (setq consult-preview-key '("S-<down>" "S-<up>")) + ;; For some commands and buffer sources it is useful to configure the + ;; :preview-key on a per-command basis using the `consult-customize' macro. + (consult-customize + consult-ripgrep consult-git-grep consult-grep + consult-bookmark consult-recent-file consult-xref + consult--source-bookmark consult--source-file-register + consult--source-recent-file consult--source-project-recent-file) + ;; :preview-key "M-." + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; "C-+" + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) + + ;; By default `consult-project-function' uses `project-root' from project.el. + ;; Optionally configure a different project root function. + ;;;; 1. project.el (the default) + ;; (setq consult-project-function #'consult--default-project--function) + ;;;; 2. vc.el (vc-root-dir) + ;; (setq consult-project-function (lambda (_) (vc-root-dir))) + ;;;; 3. locate-dominating-file + ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git"))) + ;;;; 4. projectile.el (projectile-project-root) + ;; (autoload 'projectile-project-root "projectile") + ;; (setq consult-project-function (lambda (_) (projectile-project-root))) + ;;;; 5. No project support + ;; (setq consult-project-function nil) + ) +#+end_src +** Pairs +#+begin_src emacs-lisp + (use-package smartparens + :init (smartparens-global-mode) + :config + ;; Snitched from doom + (let ((unless-list '(sp-point-before-word-p + sp-point-after-word-p + sp-point-before-same-p))) + (sp-pair "'" nil :unless unless-list) + (sp-pair "\"" nil :unless unless-list)) + (dolist (brace '("(" "{" "[")) + (sp-pair brace nil + :post-handlers '(("||\n[i]" "RET") ("| " "SPC")) + :unless '(sp-point-before-word-p sp-point-before-same-p))) + (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) + (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) + + (sp-local-pair '(python-mode python-ts-mode) "f'" "'") + + ;; Major-mode specific fixes + (sp-local-pair 'ruby-mode "{" "}" + :pre-handlers '(:rem sp-ruby-pre-handler) + :post-handlers '(:rem sp-ruby-post-handler)) + + ;; Don't do square-bracket space-expansion where it doesn't make sense to + (sp-local-pair '(emacs-lisp-mode org-mode markdown-mode gfm-mode) + "[" nil :post-handlers '(:rem ("| " "SPC"))) + + (sp-local-pair '(emacs-lisp-mode org-mode) + "'" nil) + + ;; Reasonable default pairs for HTML-style comments + (sp-local-pair (append sp--html-modes '(markdown-mode gfm-mode)) + "<!--" "-->" + :unless '(sp-point-before-word-p sp-point-before-same-p) + :actions '(insert) :post-handlers '(("| " "SPC"))) + ;; Expand C-style comment blocks. + (defun +default-open-doc-comments-block (&rest _ignored) + (save-excursion + (newline) + (indent-according-to-mode))) + (sp-local-pair + '(js2-mode typescript-mode rjsx-mode rust-mode c-mode c++-mode objc-mode + csharp-mode java-mode php-mode css-mode scss-mode less-css-mode + stylus-mode scala-mode) + "/*" "*/" + :actions '(insert) + :post-handlers '(("| " "SPC") + (" | " "*") + ("|[i]\n[i]" "RET")))) +#+end_src + +** Debugging +#+begin_src emacs-lisp + ;; (use-package dap-mode + ;; :defer t + ;; :config + ;; (require 'dap-python) + ;; (setq dap-python-debugger 'debugpy)) +#+end_src +** Move lines +#+begin_src emacs-lisp + (use-package move-text + :bind (("C-M-k" . move-text-up) + ("C-M-j" . move-text-down))) +#+end_src +** Truncate lines +#+begin_src emacs-lisp + (global-visual-line-mode t) +#+end_src +** No littering +#+begin_src emacs-lisp + (use-package no-littering) +#+end_src +** Rainbow delimiters +#+begin_src emacs-lisp + (use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) +#+end_src +** Crux +#+begin_src emacs-lisp + (use-package crux + :bind (("C-c o t" . crux-visit-shell-buffer))) +#+end_src +** Better *help* +#+begin_src emacs-lisp + (use-package helpful + :bind (("C-h f" . 'helpful-callable) + ("C-h v" . 'helpful-variable) + ("C-h k" . 'helpful-key) + ("C-h x" . 'helpful-command) + ("C-c C-d" . 'helpful-at-point) + ("C-h F" . 'helpful-function))) +#+end_src +* Eshell +#+begin_src emacs-lisp + (add-hook 'eshell-mode-hook + (lambda () + (keymap-set eshell-mode-map "M-<tab>" 'consult-fish-completions))) +#+end_src +** Fish completions +#+begin_src emacs-lisp + (use-package fish-completion + :hook (eshell-mode . fish-completion-mode)) +#+end_src +*** Consult fish completions +#+begin_src emacs-lisp + (use-package consult-fish-completions + :load-path "~/prog/elisp/fish-completions/consult-fish-completions.el" + :hook (eshell-mode . (lambda () + (keymap-set eshell-mode-map "M-<tab>" 'consult-fish-completions)))) +#+end_src +** Eat +#+begin_src emacs-lisp + (use-package eat + :hook (eshell-mode . eat-eshell-mode) + :custom + (eat-enable-auto-line-mode t)) +#+end_src +*** Eat-toggle +#+begin_src emacs-lisp + ;; (defun eat-toggle () + ;; "Open eat terminal as a popup." + ;; (interactive) + ;; (if (eq major-mode 'eat-mode) + ;; (delete-window) + ;; (let ((buff (get-buffer-create eat-buffer-name))) + ;; (cl-assert (and buff (buffer-live-p buff))) + ;; (funcall #'pop-to-buffer buff) + ;; (with-current-buffer buff + ;; (setq-local split-width-threshold nil) + ;; (setq-local window-min-height 2) + ;; (unless (derived-mode-p 'eat-mode) + ;; (eat)))))) +#+end_src +*** Eat modes +#+begin_src emacs-lisp + ;; (defun eat-modes() + ;; (cond + ;; ((and (eq major-mode 'eat-mode) (member 'meow-normal-mode local-minor-modes)) + ;; (eat-emacs-mode)) + ;; ((and (eq major-mode 'eat-mode) (member 'meow-insert-mode local-minor-modes)) + ;; (eat-semi-char-mode)))) + ;; (add-hook 'meow-normal-mode-hook #'eat-modes) + ;; (add-hook 'meow-insert-mode-hook #'eat-modes) +#+end_src +* LSP +#+begin_src emacs-lisp + (use-package eglot + :bind (("C-c s e e" . eglot) + ("C-c s e d" . eldoc) + ("C-c s e r" . eglot-rename) + ("C-c s e s" . eglot-shutdown) + ("C-c s e f" . eglot-find-declaration) + ("C-c s e i" . eglot-find-implementation)) + :hook + (nix-mode . eglot-ensure) + (python-ts-mode . eglot-ensure) + :config + (add-to-list 'eglot-server-programs '(python-ts-mode . ("pylsp")))) +#+end_src +** Languages +*** Python +#+begin_src emacs-lisp + (use-package lsp-pyright) + (use-package py-autopep8 + :hook (python-mode . py-autopep8-mode)) +#+end_src +*** Rust +#+begin_src emacs-lisp + (use-package rust-mode + :mode "\\.rs\\'") + (use-package flycheck-rust + :config + (with-eval-after-load 'rust-mode + (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))) +#+end_src +*** Fish +#+begin_src emacs-lisp + (use-package fish-mode + :mode "\\.fish\\'") +#+end_src +*** Nix +#+begin_src emacs-lisp + (use-package nix-mode + :mode ("\\.nix\\'" "\\.nix.in\\'")) + (use-package nix-drv-mode + :ensure nix-mode + :mode "\\.drv\\'") + (use-package nix-shell + :ensure nix-mode + :commands (nix-shell-unpack nix-shell-configure nix-shell-build)) + (use-package nix-repl + :ensure nix-mode + :commands (nix-repl)) +#+end_src +*** Web +#+begin_src emacs-lisp + (use-package web-mode + :mode + ("\\.phtml\\'" + "\\.tpl\\.php\\'" + "\\.[agj]sp\\'" + "\\.as[cp]x\\'" + "\\.erb\\'" + "\\.mustache\\'" + "\\.djhtml\\'")) +#+end_src +*** JavaScript +#+begin_src emacs-lisp + (use-package js2-mode) +#+end_src +** Corfu +#+begin_src emacs-lisp + (use-package corfu + :custom + (corfu-cycle t) + (corfu-preselect 'prompt) + (corfu-auto t) + (corfu-popupinfo-delay 0.0) + :bind + (:map corfu-map + ("TAB" . corfu-next) + ([tab] . corfu-next) + ("S-TAB" . corfu-previous) + ([backtab] . corfu-previous)) + + :init + (global-corfu-mode) + (corfu-history-mode) + (corfu-popupinfo-mode) + :config + (add-to-list 'savehist-additional-variables 'corfu-history)) + (use-package emacs + :init + (setq completion-cycle-threshold 3) + + (setq read-extended-command-predicate + #'command-completion-default-include-p) + + (setq tab-always-indent 'complete)) +#+end_src +*** Cape +#+begin_src emacs-lisp + (use-package cape + :demand t + :config + (add-to-list 'completion-at-point-functions #'cape-dabbrev) + (add-to-list 'completion-at-point-functions #'cape-file) + (add-to-list 'completion-at-point-functions #'cape-elisp-block) + ) +#+end_src +** Tree-sitter +#+begin_src emacs-lisp + (use-package tree-sitter + :init + (global-tree-sitter-mode) + :config + (add-hook 'tree-sitter-mode-hook 'tree-sitter-hl-mode)) + (use-package treesit-auto + :custom + (treesit-auto-install 'prompt) + :config + (treesit-auto-add-to-auto-mode-alist 'all) + (global-treesit-auto-mode)) +#+end_src +*** Additional langs +#+begin_src emacs-lisp + (use-package tree-sitter-langs) +#+end_src +** Snippets +#+begin_src emacs-lisp + ;; (use-package yasnippet + ;; :init (yas-global-mode)) + ;; (use-package yasnippet-snippets) +#+end_src +** Flymake +#+begin_src emacs-lisp + (use-package flymake + :after eglot + :bind (("C-c s f f" . flymake-start) + ("C-c s f l" . flymake-show-buffer-diagnostics) + ("C-c s f p" . flymake-show-project-diagnostics))) +#+end_src +* Dired +** Bindings +#+begin_src emacs-lisp + (use-package dired + :custom + (dired-listing-switches "-al --group-directories-first")) + +#+end_src +** Dired filter +#+begin_src emacs-lisp + +#+end_src +* Additional apps +** Telegram lol +#+begin_src emacs-lisp + ;; (add-to-list 'load-path "~/telega.el") + ;; (require 'telega) +#+end_src +** Magit +#+begin_src emacs-lisp + (use-package magit + :bind (("C-c o g" . magit))) +#+end_src +** EXWM +#+begin_src emacs-lisp + ;; (use-package exwm) + ;; (require 'exwm) + ;; (require 'exwm-config) + ;; (exwm-config-example) +#+end_src +** Jupyter +#+begin_src emacs-lisp + ;; (use-package code-cells) +#+end_src +** Orgnote +#+begin_src emacs-lisp + ;; (use-package orgnote + ;; :defer t) +#+end_src +** Copilot +#+begin_src emacs-lisp + (use-package copilot + :hook (python-ts-mode . copilot-mode) + :bind ("M-RET" . copilot-accept-completion)) +#+end_src +* Runtime Performance +#+begin_src emacs-lisp + (setq gc-cons-threshold (* 2 1000 1000)) + (setq read-process-output-max (* 1024 1024)) +#+end_src diff --git a/home-manager/general/programs/emacs/default.nix b/home-manager/general/programs/emacs/default.nix new file mode 100644 index 0000000..7b61850 --- /dev/null +++ b/home-manager/general/programs/emacs/default.nix @@ -0,0 +1,118 @@ +{ pkgs, ... }: +let + pkgsForEmacs = with pkgs; [ + tree-sitter + emacs-all-the-icons-fonts + libappindicator + poppler_utils + nil + nodejs + ]; + + pkgsUsePackage = with pkgs; [ + (pkgs.emacsWithPackagesFromUsePackage { + package = pkgs.emacs29-pgtk; + config = ./init.el; + alwaysEnsure = true; + # TODO + # with next flake update delete this, if mood-line hash changes: + # "commit": "10b5195f1b400d64d646f73a21bf5469612a375b", + # "sha256": "0wj8rdgsqsdd2ps3w7sj8a7yhhz0iczwgnalalzws42x8s9yn4j0", + override = final: prev: { + mood-line = prev.melpaPackages.mood-line.overrideAttrs(old: { + src = pkgs.fetchgit { + url = "https://gitlab.com/jessieh/mood-line"; + sha256 = "00vbv40x04g5f9n8i1ylhawslf42fsz0046r3srs4ss6pq8s893r"; + rev = "10b5195f1b400d64d646f73a21bf5469612a375b"; + }; + }); + }; + extraEmacsPackages = epkgs: [ + epkgs.use-package + # (epkgs.melpaBuild rec { + # pname = "codeium"; + # version = "1.2.102"; + + # src = fetchFromGitHub { + # owner = "Exafunction"; + # repo = "codeium.el"; + # rev = "1.4.4"; + # sha256 = "1jjix7fn73ihjnhfivf72wris72f4kwf7xb6k5hxs41fm4kr9hdd"; + # }; + + # commit = "ddc9927ea231ecc5a32f7c9905f92fdfb7912e75"; + + # recipe = writeText "recipe" '' + # (codeium + # :repo "${src.owner}/${src.repo}" + # :fetcher github) + # ''; + # }) + # (epkgs.melpaBuild rec { + # pname = "telega"; + # version = "0.8.216"; + # src = fetchFromGitHub { + # owner = "zevlg"; + # repo = "telega.el"; + # rev = "3899aa8648b9e6deddbb34a2a817ca18acb9d97a"; + # sha256 = "05xrm86gp185mgwb62w720hcbn87salk8z0whq6zf2r2f24l6xbw"; + # }; + # commit = "3899aa8648b9e6deddbb34a2a817ca18acb9d97a"; + # recipe = writeText "recipe" '' + # (telega :fetcher github + # :repo "zevlg/telega.el" + # :files (:defaults "etc" "server" "contrib" "Makefile")) + # ''; + # }) + # (epkgs.melpaBuild rec { + # pname = "orgnote"; + # version = "0.7.17"; + + # src = fetchFromGitHub { + # owner = "Artawower"; + # repo = "orgnote.el"; + # rev = "v${version}"; + # sha256 = "1lrj47h244z4dqq2wyhpww7p3b4sy6bayk8lwlka517lhbcdgh33"; + # }; + + # commit = "ccc40cc346ebf5a6e6a55e3d4a147f0230337350"; + + # recipe = writeText "recipe" '' + # (orgnote + # :repo "${src.owner}/${src.repo}" + # :fetcher github) + # ''; + # }) + (epkgs.melpaBuild rec { + pname = "copilot"; + version = "20231219"; + + src = fetchFromGitHub { + owner = "zerolfx"; + repo = "copilot.el"; + rev = "d4fa14cea818e041b4a536c5052cf6d28c7223d7"; + sha256 = "1bn2im5ybzmwbwbi7v39s0qzmca5isp7zb0ls61y6sramh6k8fsg"; + }; + + packageRequires = with epkgs; [ editorconfig dash s ]; + + commit = "d4fa14cea818e041b4a536c5052cf6d28c7223d7"; + + recipe = writeText "recipe" '' + (copilot + :repo "${src.owner}/${src.repo}" + :fetcher github + :files ("*.el" "dist")) + ''; + }) + ]; + }) + ]; +in +{ + home.packages = pkgsForEmacs ++ pkgsUsePackage; + xdg.configFile = { + # "emacs/init.el".text = builtins.readFile ./init.el; + "emacs/early-init.el".text = builtins.readFile ./early-init.el; + }; +} diff --git a/home-manager/general/programs/emacs/early-init.el b/home-manager/general/programs/emacs/early-init.el new file mode 100644 index 0000000..6e306a1 --- /dev/null +++ b/home-manager/general/programs/emacs/early-init.el @@ -0,0 +1,4 @@ +(menu-bar-mode -1) +(tool-bar-mode -1) +(scroll-bar-mode -1) +(setq-default pgtk-wait-for-event-timeout 0) diff --git a/home-manager/general/programs/emacs/init.el b/home-manager/general/programs/emacs/init.el new file mode 100644 index 0000000..f1a4f90 --- /dev/null +++ b/home-manager/general/programs/emacs/init.el @@ -0,0 +1,675 @@ +(setq gc-cons-threshold (* 50 1000 1000)) + +(require 'use-package) +(eval-and-compile + (setq use-package-always-ensure t + use-package-expand-minimally t)) + +(use-package savehist + :init + (setq savehist-file "~/.config/emacs/var/savehist.el") + :config + (setq history-length 500) + (setq savehist-additional-variables '(kill-ring search-ring)) + (savehist-mode t)) + +(use-package meow + :config + (defun meow-setup () + (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty) + (meow-motion-overwrite-define-key + '("j" . meow-next) + '("k" . meow-prev) + '("<escape>" . ignore)) + (meow-leader-define-key + ;; SPC j/k will run the original command in MOTION state. + '("j" . "H-j") + '("k" . "H-k") + ;; Use SPC (0-9) for digit arguments. + '("1" . meow-digit-argument) + '("2" . meow-digit-argument) + '("3" . meow-digit-argument) + '("4" . meow-digit-argument) + '("5" . meow-digit-argument) + '("6" . meow-digit-argument) + '("7" . meow-digit-argument) + '("8" . meow-digit-argument) + '("9" . meow-digit-argument) + '("0" . meow-digit-argument) + '("/" . meow-keypad-describe-key) + '("?" . meow-cheatsheet) + '("bk" . kill-this-buffer)) + (meow-normal-define-key + '("0" . meow-expand-0) + '("9" . meow-expand-9) + '("8" . meow-expand-8) + '("7" . meow-expand-7) + '("6" . meow-expand-6) + '("5" . meow-expand-5) + '("4" . meow-expand-4) + '("3" . meow-expand-3) + '("2" . meow-expand-2) + '("1" . meow-expand-1) + '("-" . negative-argument) + '(";" . meow-reverse) + '("," . meow-inner-of-thing) + '("." . meow-bounds-of-thing) + '("[" . meow-beginning-of-thing) + '("]" . meow-end-of-thing) + '("a" . meow-append) + '("A" . meow-open-below) + '("b" . meow-back-word) + '("B" . meow-back-symbol) + '("c" . meow-change) + '("d" . meow-delete) + '("D" . meow-backward-delete) + '("e" . meow-next-word) + '("E" . meow-next-symbol) + '("f" . meow-find) + '("g" . meow-cancel-selection) + '("G" . meow-grab) + '("h" . meow-left) + '("H" . meow-left-expand) + '("i" . meow-insert) + '("I" . meow-open-above) + '("j" . meow-next) + '("J" . meow-next-expand) + '("k" . meow-prev) + '("K" . meow-prev-expand) + '("l" . meow-right) + '("L" . meow-right-expand) + '("m" . meow-join) + '("n" . meow-search) + '("o" . meow-block) + '("O" . meow-to-block) + '("p" . meow-yank) + '("q" . meow-quit) + '("Q" . meow-goto-line) + '("r" . meow-replace) + '("R" . meow-swap-grab) + '("s" . meow-kill) + '("t" . meow-till) + '("u" . meow-undo) + '("U" . meow-undo-in-selection) + '("v" . meow-visit) + '("w" . meow-mark-word) + '("W" . meow-mark-symbol) + '("x" . meow-line) + '("X" . meow-goto-line) + '("y" . meow-save) + '("Y" . meow-sync-grab) + '("z" . meow-pop-selection) + '("'" . repeat) + '("<escape>" . ignore))) + (setq meow-use-enhanced-selection-effect t) + (meow-setup) + (meow-global-mode 1)) + +(use-package general + :config + ;; SPC as the global leader key + (general-create-definer spl3g/leader-keys + :prefix "C-c") + + (spl3g/leader-keys + ;; Buffers + "b" '(:ignore t :wk "Buffer") + "bi" '(ibuffer :wk "ibuffer") + "bk" '(kill-this-buffer :wk "Kill this buffer") + "bn" '(next-buffer :wk "Next buffer") + "bp" '(previous-buffer :wk "Previous buffer") + "br" '(revert-buffer :wk "Reload buffer") + "." '(find-file :wk "Find file") + ;; Splits + "w" '(:ignore t :wk "Splits") + "wv" '(split-window-right :wk "Split vertical") + "ws" '(split-window-below :wk "Split") + "ww" '(other-window :wk "Cycle throug windows") + "wc" '(delete-window :wk "Close window") + "wd" '(delete-window :wk "Close window") + "wl" '(evil-window-right :wk "") + "wj" '(evil-window-down :wk "") + "wk" '(evil-window-up :wk "") + "wh" '(evil-window-left :wk "") + "wo" '(delete-other-windows :wk "") + ;; Files + "f" '(:ignore t :wk "Files") + "fc" '((lambda () (interactive) (find-file "~/nixfiles/home-manager/programs/emacs/config.org")) :wk "Edit emacs config") + "fu" '(crux-sudo-edit :wk "Sudo edit file") + ;; Compilation + "c" '(:ignore t :wk "Compilation") + "cc" '(compile :wk "Compile") + "cr" '(recompile :wk "Recompile") + )) + +(defun spl3g/disable-scroll-bars (frame) + (modify-frame-parameters frame + '((vertical-scroll-bars . nil) + (horizontal-scroll-bars . nil)))) +(add-hook 'after-make-frame-functions 'spl3g/disable-scroll-bars) + +(setq default-frame-alist '((font . "Source Code Pro"))) +(set-face-attribute 'default nil + :font "Source Code Pro" + :height 110 + :weight 'medium) +(set-face-attribute 'fixed-pitch nil + :font "Source Code Pro" + :height 110 + :weight 'medium) +(set-face-attribute 'variable-pitch nil + :font "Rubik" + :height 110 + :weight 'medium) +(set-face-attribute 'font-lock-comment-face nil + :slant 'italic) +(set-face-attribute 'font-lock-keyword-face nil + :weight 'bold) + +(add-hook 'prog-mode-hook 'display-line-numbers-mode) +(visual-line-mode 1) + +(use-package catppuccin-theme + :ensure t + :config + (load-theme 'catppuccin t) + (setq catppuccin-flavor 'macchiato) + (catppuccin-reload)) + +(use-package all-the-icons + :ensure t + :if (display-graphic-p)) + +(use-package mood-line + + ;; Enable mood-line + :config + (mood-line-mode) + :custom + (mood-line-segment-modal-meow-state-alist + '((normal "N" . mood-line-meow-normal) + (insert "I" . mood-line-meow-insert) + (keypad "K" . mood-line-meow-keypad) + (beacon "B" . mood-line-meow-beacon) + (motion "M" . mood-line-meow-motion))) + (mood-line-glyph-alist mood-line-glyphs-fira-code) + :custom-face + (mood-line-meow-beacon ((t (:foreground "#f9e2af" :weight bold)))) + (mood-line-meow-insert ((t (:foreground "#a6e3a1" :weight bold)))) + (mood-line-meow-keypad ((t (:foreground "#cba6f7" :weight bold)))) + (mood-line-meow-motion ((t (:foreground "#fab387" :weight bold)))) + (mood-line-meow-normal ((t (:weight bold)))) + (mode-line-inactive ((t (:box (:line-width (2 . 6) :color "#11111b") :inverse-video nil :foreground "#6c7086" :background "#11111b")))) + (mode-line ((t (:box (:line-width (2 . 6) :color "#181825") :background "#181825"))))) + +(use-package good-scroll + :init (good-scroll-mode)) + +(use-package dashboard + :init + (dashboard-setup-startup-hook) + :config + (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) + (setq dashboard-banner-logo-title "Yep, it's emacs, not vim") + (setq dashboard-startup-banner 'logo) + (setq dashboard-center-content t) + (add-to-list 'dashboard-item-generators '(config . dashboard-open-config)) + (setq dashboard-items '((recents . 5) + (agenda . 5)))) + +(setq ring-bell-function 'ignore) + +(use-package indent-guide + :hook (prog-mode . indent-guide-mode)) + +(setq window-resize-pixelwise t) +(setq frame-resize-pixelwise t) +(save-place-mode t) +(defalias 'yes-or-no #'y-or-n-p) + +(add-hook 'org-mode-hook 'org-indent-mode) +(require 'org-tempo) + +(use-package toc-org + :hook (org-mode . toc-org-mode)) + +(use-package org-bullets + :hook (org-mode . org-bullets-mode)) + +(use-package org-auto-tangle + :hook (org-mode . org-auto-tangle-mode)) + +(use-package org-download + :hook + (dired-mode . org-download-enable)) + +(use-package direnv + :config + (direnv-mode)) + +(use-package vertico + :init + (vertico-mode) + :bind (:map vertico-map + ("M-j" . vertico-next) + ("M-k" . vertico-previous) + ("RET" . vertico-directory-enter) + ("DEL" . vertico-directory-delete-char) + ("M-DEL" . vertico-directory-delete-word))) + +(use-package emacs + :init + ;; Add prompt indicator to `completing-read-multiple'. + ;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma. + (defun crm-indicator (args) + (cons (format "[CRM%s] %s" + (replace-regexp-in-string + "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" + crm-separator) + (car args)) + (cdr args))) + (advice-add #'completing-read-multiple :filter-args #'crm-indicator) + + ;; Do not allow the cursor in the minibuffer prompt + (setq minibuffer-prompt-properties + '(read-only t cursor-intangible t face minibuffer-prompt)) + (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) + + ;; Emacs 28: Hide commands in M-x which do not work in the current mode. + ;; Vertico commands are hidden in normal buffers. + ;; (setq read-extended-command-predicate + ;; #'command-completion-default-include-p) + + ;; Enable recursive minibuffers + (setq enable-recursive-minibuffers t)) + +(use-package orderless + :init + (setq completion-styles '(orderless basic) + completion-category-defaults nil + completion-category-overrides '((file (styles partial-completion))))) + +(use-package marginalia + :bind (:map minibuffer-local-map + ("M-A" . marginalia-cycle)) + :init + (marginalia-mode)) + +(use-package consult + ;; Replace bindings. Lazily loaded due by `use-package'. + :bind (;; C-c bindings in `mode-specific-map' + ("C-c k" . consult-kmacro) + ("C-c m" . consult-man) + ("C-c i" . consult-info) + ([remap Info-search] . consult-info) + ("C-c f r" . consult-recent-file) + ("C-c ," . consult-buffer) + ;; C-x bindings in `ctl-x-map' + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer + ;; Custom M-# bindings for fast register access + ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("C-M-#" . consult-register) + ;; Other custom bindings + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ;; M-g bindings in `goto-map' + ("C-c c e" . consult-compile-error) + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ;; M-s bindings in `search-map' + ("M-s d" . consult-fd) + ("M-s g" . consult-grep) + ("M-s G" . consult-git-grep) + ("M-s l" . consult-line) + ("M-s L" . consult-line-multi) + ("M-s k" . consult-keep-lines) + ("M-s u" . consult-focus-lines) + ;; Isearch integration + ("M-s e" . consult-isearch-history) + :map isearch-mode-map + ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch + ("M-r" . consult-history) + ;; Minibuffer history + :map minibuffer-local-map + ("M-s" . consult-history) ;; orig. next-matching-history-element + ("M-r" . consult-history)) ;; orig. previous-matching-history-element) + + ;; Enable automatic preview at point in the *Completions* buffer. This is + ;; relevant when you use the default completion UI. + :hook + (completion-list-mode . consult-preview-at-point-mode) + (eshell-mode . (lambda () + (keymap-set eshell-mode-map "M-h" 'consult-history))) + + ;; The :init configuration is always executed (Not lazy) + :init + + ;; Optionally configure the register formatting. This improves the register + ;; preview for `consult-register', `consult-register-load', + ;; `consult-register-store' and the Emacs built-ins. + (setq register-preview-delay 0.5 + register-preview-function #'consult-register-format) + + ;; Optionally tweak the register preview window. + ;; This adds thin lines, sorting and hides the mode line of the window. + (advice-add #'register-preview :override #'consult-register-window) + + ;; Configure other variables and modes in the :config section, + ;; after lazily loading the package. + :config + + ;; Optionally configure preview. The default value + ;; is 'any, such that any key triggers the preview. + ;; (setq consult-preview-key 'any) + ;; (setq consult-preview-key "M-.") + ;; (setq consult-preview-key '("S-<down>" "S-<up>")) + ;; For some commands and buffer sources it is useful to configure the + ;; :preview-key on a per-command basis using the `consult-customize' macro. + (consult-customize + consult-ripgrep consult-git-grep consult-grep + consult-bookmark consult-recent-file consult-xref + consult--source-bookmark consult--source-file-register + consult--source-recent-file consult--source-project-recent-file) + ;; :preview-key "M-." + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; "C-+" + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) + + ;; By default `consult-project-function' uses `project-root' from project.el. + ;; Optionally configure a different project root function. +;;;; 1. project.el (the default) + ;; (setq consult-project-function #'consult--default-project--function) +;;;; 2. vc.el (vc-root-dir) + ;; (setq consult-project-function (lambda (_) (vc-root-dir))) +;;;; 3. locate-dominating-file + ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git"))) +;;;; 4. projectile.el (projectile-project-root) + ;; (autoload 'projectile-project-root "projectile") + ;; (setq consult-project-function (lambda (_) (projectile-project-root))) +;;;; 5. No project support + ;; (setq consult-project-function nil) + ) + +(use-package smartparens + :init (smartparens-global-mode) + :config + ;; Snitched from doom + (let ((unless-list '(sp-point-before-word-p + sp-point-after-word-p + sp-point-before-same-p))) + (sp-pair "'" nil :unless unless-list) + (sp-pair "\"" nil :unless unless-list)) + (dolist (brace '("(" "{" "[")) + (sp-pair brace nil + :post-handlers '(("||\n[i]" "RET") ("| " "SPC")) + :unless '(sp-point-before-word-p sp-point-before-same-p))) + (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) + (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) + + (sp-local-pair '(python-mode python-ts-mode) "f'" "'") + + ;; Major-mode specific fixes + (sp-local-pair 'ruby-mode "{" "}" + :pre-handlers '(:rem sp-ruby-pre-handler) + :post-handlers '(:rem sp-ruby-post-handler)) + + ;; Don't do square-bracket space-expansion where it doesn't make sense to + (sp-local-pair '(emacs-lisp-mode org-mode markdown-mode gfm-mode) + "[" nil :post-handlers '(:rem ("| " "SPC"))) + + (sp-local-pair '(emacs-lisp-mode org-mode) + "'" nil) + + ;; Reasonable default pairs for HTML-style comments + (sp-local-pair (append sp--html-modes '(markdown-mode gfm-mode)) + "<!--" "-->" + :unless '(sp-point-before-word-p sp-point-before-same-p) + :actions '(insert) :post-handlers '(("| " "SPC"))) + ;; Expand C-style comment blocks. + (defun +default-open-doc-comments-block (&rest _ignored) + (save-excursion + (newline) + (indent-according-to-mode))) + (sp-local-pair + '(js2-mode typescript-mode rjsx-mode rust-mode c-mode c++-mode objc-mode + csharp-mode java-mode php-mode css-mode scss-mode less-css-mode + stylus-mode scala-mode) + "/*" "*/" + :actions '(insert) + :post-handlers '(("| " "SPC") + (" | " "*") + ("|[i]\n[i]" "RET")))) + +;; (use-package dap-mode +;; :defer t +;; :config +;; (require 'dap-python) +;; (setq dap-python-debugger 'debugpy)) + +(use-package move-text + :bind (("C-M-k" . move-text-up) + ("C-M-j" . move-text-down))) + +(global-visual-line-mode t) + +(use-package no-littering) + +(use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) + +(use-package crux + :bind (("C-c o t" . crux-visit-shell-buffer))) + +(use-package helpful + :bind (("C-h f" . 'helpful-callable) + ("C-h v" . 'helpful-variable) + ("C-h k" . 'helpful-key) + ("C-h x" . 'helpful-command) + ("C-c C-d" . 'helpful-at-point) + ("C-h F" . 'helpful-function))) + +(add-hook 'eshell-mode-hook + (lambda () + (keymap-set eshell-mode-map "M-<tab>" 'consult-fish-completions))) + +(use-package fish-completion + :hook (eshell-mode . fish-completion-mode)) + +(use-package consult-fish-completions + :load-path "~/prog/elisp/fish-completions/" + :hook (eshell-mode . (lambda () + (keymap-set eshell-mode-map "M-<tab>" 'consult-fish-completions)))) + +(use-package eat + :hook (eshell-mode . eat-eshell-mode) + :custom + (eat-enable-auto-line-mode t)) + +;; (defun eat-toggle () +;; "Open eat terminal as a popup." +;; (interactive) +;; (if (eq major-mode 'eat-mode) +;; (delete-window) +;; (let ((buff (get-buffer-create eat-buffer-name))) +;; (cl-assert (and buff (buffer-live-p buff))) +;; (funcall #'pop-to-buffer buff) +;; (with-current-buffer buff +;; (setq-local split-width-threshold nil) +;; (setq-local window-min-height 2) +;; (unless (derived-mode-p 'eat-mode) +;; (eat)))))) + +;; (defun eat-modes() +;; (cond +;; ((and (eq major-mode 'eat-mode) (member 'meow-normal-mode local-minor-modes)) +;; (eat-emacs-mode)) +;; ((and (eq major-mode 'eat-mode) (member 'meow-insert-mode local-minor-modes)) +;; (eat-semi-char-mode)))) +;; (add-hook 'meow-normal-mode-hook #'eat-modes) +;; (add-hook 'meow-insert-mode-hook #'eat-modes) + +(use-package eglot + :bind (("C-c s e e" . eglot) + ("C-c s e d" . eldoc) + ("C-c s e r" . eglot-rename) + ("C-c s e s" . eglot-shutdown) + ("C-c s e f" . eglot-find-declaration) + ("C-c s e i" . eglot-find-implementation)) + :hook + (nix-mode . eglot-ensure) + (python-ts-mode . eglot-ensure) + :config + (add-to-list 'eglot-server-programs '(python-ts-mode . ("pylsp")))) + +(use-package lsp-pyright) +(use-package py-autopep8 + :hook (python-mode . py-autopep8-mode)) + +(use-package rust-mode + :mode "\\.rs\\'") +(use-package flycheck-rust + :config + (with-eval-after-load 'rust-mode + (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))) + +(use-package fish-mode + :mode "\\.fish\\'") + +(use-package nix-mode + :mode ("\\.nix\\'" "\\.nix.in\\'")) +(use-package nix-drv-mode + :ensure nix-mode + :mode "\\.drv\\'") +(use-package nix-shell + :ensure nix-mode + :commands (nix-shell-unpack nix-shell-configure nix-shell-build)) +(use-package nix-repl + :ensure nix-mode + :commands (nix-repl)) + +(use-package web-mode + :mode + ("\\.phtml\\'" + "\\.tpl\\.php\\'" + "\\.[agj]sp\\'" + "\\.as[cp]x\\'" + "\\.erb\\'" + "\\.mustache\\'" + "\\.djhtml\\'")) + +(use-package js2-mode) + +(use-package corfu + :custom + (corfu-cycle t) + (corfu-preselect 'prompt) + (corfu-auto t) + (corfu-popupinfo-delay 0.0) + :bind + (:map corfu-map + ("TAB" . corfu-next) + ([tab] . corfu-next) + ("S-TAB" . corfu-previous) + ([backtab] . corfu-previous)) + + :init + (global-corfu-mode) + (corfu-history-mode) + (corfu-popupinfo-mode) + :config + (add-to-list 'savehist-additional-variables 'corfu-history)) +(use-package emacs + :init + (setq completion-cycle-threshold 3) + + (setq read-extended-command-predicate + #'command-completion-default-include-p) + + (setq tab-always-indent 'complete)) + +(use-package cape + :demand t + :config + (add-to-list 'completion-at-point-functions #'cape-dabbrev) + (add-to-list 'completion-at-point-functions #'cape-file) + (add-to-list 'completion-at-point-functions #'cape-elisp-block) + ) + +(use-package tree-sitter + :init + (global-tree-sitter-mode) + :config + (add-hook 'tree-sitter-mode-hook 'tree-sitter-hl-mode)) +(use-package treesit-auto + :custom + (treesit-auto-install 'prompt) + :config + (treesit-auto-add-to-auto-mode-alist 'all) + (global-treesit-auto-mode)) + +(use-package tree-sitter-langs) + +;; (use-package yasnippet +;; :init (yas-global-mode)) +;; (use-package yasnippet-snippets) + +(use-package flymake + :after eglot + :bind (("C-c s f f" . flymake-start) + ("C-c s f l" . flymake-show-buffer-diagnostics) + ("C-c s f p" . flymake-show-project-diagnostics))) + +(use-package dired + :custom + (dired-listing-switches "-al --group-directories-first")) + + + +;; (add-to-list 'load-path "~/telega.el") +;; (require 'telega) + +(use-package magit + :bind (("C-c o g" . magit))) + +;; (use-package exwm) +;; (require 'exwm) +;; (require 'exwm-config) +;; (exwm-config-example) + +;; (use-package code-cells) + +;; (use-package orgnote +;; :defer t) + +(use-package copilot + :hook (python-ts-mode . copilot-mode) + :bind ("M-RET" . copilot-accept-completion)) + +(setq gc-cons-threshold (* 2 1000 1000)) +(setq read-process-output-max (* 1024 1024)) +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(package-selected-packages + '(dired web-mode vertico use-package treesit-auto tree-sitter-langs toc-org smartparens rust-mode rainbow-delimiters py-autopep8 org-download org-bullets org-auto-tangle orderless no-littering nix-mode move-text mood-line marginalia magit lsp-pyright js2-mode indent-guide helpful good-scroll general flycheck-rust fish-mode fish-completion eglot eat direnv dashboard crux corfu copilot consult catppuccin-theme cape all-the-icons snow meow))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + ) diff --git a/home-manager/general/programs/emacs/init.old.el b/home-manager/general/programs/emacs/init.old.el new file mode 100644 index 0000000..766d86d --- /dev/null +++ b/home-manager/general/programs/emacs/init.old.el @@ -0,0 +1,592 @@ +(require 'use-package) + +;; Evil +;; (use-package evil +;; :init +;; (setq evil-want-integration t) +;; (setq evil-want-keybinding nil) +;; (setq evil-split-window-below t) +;; (setq evil-vsplit-window-right t) +;; (evil-mode)) +;; (use-package evil-collection +;; :after evil +;; :config +;; (setq evil-collection-mode-list '(dashboard dired ibuffer)) +;; (evil-collection-init)) + +;; Meow +(use-package meow + :config +(defun meow-setup () + (setq meow-use-clipboard t) + (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty) + (meow-motion-overwrite-define-key + '("j" . meow-next) + '("k" . meow-prev) + '("<escape>" . ignore)) + (meow-leader-define-key + ;; SPC j/k will run the original command in MOTION state. + '("j" . "H-j") + '("k" . "H-k") + ;; Use SPC (0-9) for digit arguments. + '("1" . meow-digit-argument) + '("2" . meow-digit-argument) + '("3" . meow-digit-argument) + '("4" . meow-digit-argument) + '("5" . meow-digit-argument) + '("6" . meow-digit-argument) + '("7" . meow-digit-argument) + '("8" . meow-digit-argument) + '("9" . meow-digit-argument) + '("0" . meow-digit-argument) + '("/" . meow-keypad-describe-key) + '("?" . meow-cheatsheet) + '("bk" . kill-this-buffer)) + (meow-normal-define-key + '("0" . meow-expand-0) + '("9" . meow-expand-9) + '("8" . meow-expand-8) + '("7" . meow-expand-7) + '("6" . meow-expand-6) + '("5" . meow-expand-5) + '("4" . meow-expand-4) + '("3" . meow-expand-3) + '("2" . meow-expand-2) + '("1" . meow-expand-1) + '("-" . negative-argument) + '(";" . meow-reverse) + '("," . meow-inner-of-thing) + '("." . meow-bounds-of-thing) + '("[" . meow-beginning-of-thing) + '("]" . meow-end-of-thing) + '("a" . meow-append) + '("A" . meow-open-below) + '("b" . meow-back-word) + '("B" . meow-back-symbol) + '("c" . meow-change) + '("d" . meow-delete) + '("D" . meow-backward-delete) + '("e" . meow-next-word) + '("E" . meow-next-symbol) + '("f" . meow-find) + '("g" . meow-cancel-selection) + '("G" . meow-grab) + '("h" . meow-left) + '("H" . meow-left-expand) + '("i" . meow-insert) + '("I" . meow-open-above) + '("j" . meow-next) + '("J" . meow-next-expand) + '("k" . meow-prev) + '("K" . meow-prev-expand) + '("l" . meow-right) + '("L" . meow-right-expand) + '("m" . meow-join) + '("n" . meow-search) + '("o" . meow-block) + '("O" . meow-to-block) + '("p" . meow-yank) + '("q" . meow-quit) + '("Q" . meow-goto-line) + '("r" . meow-replace) + '("R" . meow-swap-grab) + '("s" . meow-kill) + '("t" . meow-till) + '("u" . meow-undo) + '("U" . meow-undo-in-selection) + '("v" . meow-visit) + '("w" . meow-mark-word) + '("W" . meow-mark-symbol) + '("x" . meow-line) + '("X" . meow-goto-line) + '("y" . meow-save) + '("Y" . meow-sync-grab) + '("z" . meow-pop-selection) + '("'" . repeat) + '("<escape>" . ignore))) +(meow-setup) +(meow-global-mode 1)) + +;; General Keybindings +(use-package general + :config + + ;; SPC as the global leader key + (general-create-definer spl3g/leader-keys + :prefix "C-c") + + (spl3g/leader-keys + ;; Buffers + "b" '(:ignore t :wk "Buffer") + "bi" '(ibuffer :wk "ibuffer") + "bk" '(kill-this-buffer :wk "Kill this buffer") + "bn" '(next-buffer :wk "Next buffer") + "bp" '(previous-buffer :wk "Previous buffer") + "br" '(revert-buffer :wk "Reload buffer") + "," '(consult-buffer :wk "Switch to buffer") + "." '(find-file :wk "Find file") + ;; Splits + "w" '(:ignore t :wk "Evil splits") + "wv" '(evil-window-vsplit :wk "Split vertical") + "ws" '(evil-window-split :wk "Split") + "ww" '(evil-window-next :wk "Cycle throug windows") + "wc" '(evil-window-delete :wk "Close window") + "wd" '(evil-window-delete :wk "Close window") + ;; Files + "f" '(:ignore t :wk "Files") + "fr" '(consult-recent-file :wk "Resent files") + "fc" '((lambda () (interactive) (find-file "~/.config/emacs/init.el")) :wk "Edit emacs config") + "fu" '(sudo-edit-find-file :wk "Sudo find file") + "fU" '(sudo-edit :wk "Sudo edit file") + ;; Quiting + "q" '(:ignore t :wk "Quiting") + "qq" '(:ignore t :wk "Quit TBD") + "qr" '(:ignore t :wk "Restart TBD") + "qe" '(eval-buffer :wk "Eval buffer") + "r" '(reload-init-file :wk "Reload config") + "l" '(lsp-keymap-prefix :wk "LSP"))) + +;; Which key +(use-package which-key + :init + (which-key-mode 1) + :config + (setq which-key-side-window-location 'bottom + which-key-sort-order #'which-key-key-order-alpha + which-key-sort-uppercase-first nil + which-key-add-column-padding 1 + which-key-max-display-columns nil + which-key-side-window-slot -10 + which-key-side-window-max-height 0.25 + which-key-idle-deley 0.8 + which-key-max-description-length 25 + which-key-allow-imprecise-window-fit t + which-key-separator " -> ")) + + + + +;; Vertico +(use-package vertico + :init + (vertico-mode)) + +;; For persistent history +(savehist-mode 1) +;; Idk what it means but they said that i need it +(use-package emacs + :init + ;; Add prompt indicator to `completing-read-multiple'. + ;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma. + (defun crm-indicator (args) + (cons (format "[CRM%s] %s" + (replace-regexp-in-string + "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" + crm-separator) + (car args)) + (cdr args))) + (advice-add #'completing-read-multiple :filter-args #'crm-indicator) + + ;; Do not allow the cursor in the minibuffer prompt + (setq minibuffer-prompt-properties + '(read-only t cursor-intangible t face minibuffer-prompt)) + (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) + + ;; Emacs 28: Hide commands in M-x which do not work in the current mode. + ;; Vertico commands are hidden in normal buffers. + ;; (setq read-extended-command-predicate + ;; #'command-completion-default-include-p) + + ;; Enable recursive minibuffers + (setq enable-recursive-minibuffers t)) +;; Orderless +(use-package orderless + :init + (setq completion-styles '(orderless basic) + completion-category-defaults nil + completion-category-overrides '((file (styles partial-completion))))) +(use-package marginalia + :bind (:map minibuffer-local-map + ("M-A" . marginalia-cycle)) + :init + (marginalia-mode)) + +;; Consult +(use-package consult + ;; Replace bindings. Lazily loaded due by `use-package'. + :bind (;; C-c bindings in `mode-specific-map' + ("C-c M-x" . consult-mode-command) + ("C-c h" . consult-history) + ("C-c k" . consult-kmacro) + ("C-c m" . consult-man) + ("C-c i" . consult-info) + ([remap Info-search] . consult-info) + ;; C-x bindings in `ctl-x-map' + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x b" . consult-buffer) ;; orig. switch-to-buffer + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump + ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer + ;; Custom M-# bindings for fast register access + ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("C-M-#" . consult-register) + ;; Other custom bindings + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ;; M-g bindings in `goto-map' + ("M-g e" . consult-compile-error) + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ("M-g m" . consult-mark) + ("M-g k" . consult-global-mark) + ("M-g i" . consult-imenu) + ("M-g I" . consult-imenu-multi) + ;; M-s bindings in `search-map' + ("M-s d" . consult-find) + ("M-s D" . consult-locate) + ("M-s g" . consult-grep) + ("M-s G" . consult-git-grep) + ("M-s r" . consult-ripgrep) + ("M-s l" . consult-line) + ("M-s L" . consult-line-multi) + ("M-s k" . consult-keep-lines) + ("M-s u" . consult-focus-lines) + ;; Isearch integration + ("M-s e" . consult-isearch-history) + :map isearch-mode-map + ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch + ;; Minibuffer history + :map minibuffer-local-map + ("M-s" . consult-history) ;; orig. next-matching-history-element + ("M-r" . consult-history)) ;; orig. previous-matching-history-element + + ;; Enable automatic preview at point in the *Completions* buffer. This is + ;; relevant when you use the default completion UI. + :hook (completion-list-mode . consult-preview-at-point-mode) + + ;; The :init configuration is always executed (Not lazy) + :init + + ;; Optionally configure the register formatting. This improves the register + ;; preview for `consult-register', `consult-register-load', + ;; `consult-register-store' and the Emacs built-ins. + (setq register-preview-delay 0.5 + register-preview-function #'consult-register-format) + + ;; Optionally tweak the register preview window. + ;; This adds thin lines, sorting and hides the mode line of the window. + (advice-add #'register-preview :override #'consult-register-window) + + ;; Use Consult to select xref locations with preview + (setq xref-show-xrefs-function #'consult-xref + xref-show-definitions-function #'consult-xref) + + ;; Configure other variables and modes in the :config section, + ;; after lazily loading the package. + :config + + ;; Optionally configure preview. The default value + ;; is 'any, such that any key triggers the preview. + ;; (setq consult-preview-key 'any) + ;; (setq consult-preview-key "M-.") + ;; (setq consult-preview-key '("S-<down>" "S-<up>")) + ;; For some commands and buffer sources it is useful to configure the + ;; :preview-key on a per-command basis using the `consult-customize' macro. + (consult-customize + consult-ripgrep consult-git-grep consult-grep + consult-bookmark consult-recent-file consult-xref + consult--source-bookmark consult--source-file-register + consult--source-recent-file consult--source-project-recent-file) + ;; :preview-key "M-." + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; "C-+" + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) + + ;; By default `consult-project-function' uses `project-root' from project.el. + ;; Optionally configure a different project root function. + ;;;; 1. project.el (the default) + ;; (setq consult-project-function #'consult--default-project--function) + ;;;; 2. vc.el (vc-root-dir) + ;; (setq consult-project-function (lambda (_) (vc-root-dir))) + ;;;; 3. locate-dominating-file + ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git"))) + ;;;; 4. projectile.el (projectile-project-root) + ;; (autoload 'projectile-project-root "projectile") + ;; (setq consult-project-function (lambda (_) (projectile-project-root))) + ;;;; 5. No project support + ;; (setq consult-project-function nil) +) + +;; Hotfuzz +;; (use-package hotfuzz +;; :config +;; (setq completion-styles '(hotfuzz)) +;; (setq completion-ignore-case t)) + +;; Lsp +(use-package lsp-mode + :hook + (python-mode . lsp) + (rust-mode . lsp) + (lsp-mode . lsp-enable-which-key-integration) + (sh-mode . lsp) + :commands lsp) +(use-package lsp-pyright + :ensure t) +(use-package lsp-ui + :hook (lsp-mode-hook . lsp-ui-mode) + :custom + (lsp-ui-peek-always-show t) + (lsp-ui-sideline-show-hover t) + (lsp-ui-doc-enable t)) + +(use-package lsp-treemacs) + +;; Flycheck +(use-package flycheck) + +;; Corfu + Cape +(use-package corfu + :custom + (corfu-cycle t) + (corfu-auto t) + (corfu-preselect 'prompt) + :bind + (:map corfu-map + ("TAB" . corfu-next) + ([tab] . corfu-next) + ("S-TAB" . corfu-previous) + ([backtab] . corfu-previous)) + :init + (global-corfu-mode)) + ;;(use-package cape + ;; :bind (("C-c a f" . cape-file)) + ;; :init + ;; (add-to-list 'completion-at-point-functions # 'cape-file))) +(use-package cape + :init + (add-to-list 'completion-at-point-functions #'cape-file)) +(use-package emacs + :init + (setq completion-cycle-threshold 3) + (setq tab-always-indent 'complete)) + +;; Treemacs +(use-package treemacs + :config + (setq treemacs-no-png-images t)) +(use-package treemacs-evil) +(use-package treemacs-all-the-icons) + +;; Resent files +(recentf-mode 1) +(setq recentf-max-menu-items 25) +(setq recentf-max-saved-items 50) + +;; Sudo +(use-package sudo-edit) + +;; (defun sudo-find-file-hook () +;; (when (and (not (file-writable-p buffer-file-name)) +;; (y-or-n-p-with-timeout "File not writable. Open as root?" 2 t)) +;; (let ((obuf (current-buffer))) +;; (sudo-edit) +;; (unless (equal (current-buffer) obuf) +;; (let) + +;; Parinfer +(electric-pair-mode 1) + +;; NixOS +(use-package nix-mode + :mode "(.nix)$") +;; (use-package nix-drv-mode :elpaca nil +;; :ensure nix-mode +;; :mode ".drv") +;; (use-package nix-shell :elpaca nil +;; :ensure nix-mode +;; :commands (nix-shell-unpack nix-shell-configure nix-shell-build)) +;; (use-package nix-repl :elpaca nil +;; :ensure nix-mode +;; :commands (nix-repl)) + +;; Reload config +(defun reload-init-file () (interactive) + (load-file user-init-file) + (load-file user-init-file)) + +;; Magit +(use-package magit) + +;; Fish +(use-package fish-mode + :mode "(.fish)$") + +;; Rust +(use-package rustic + :ensure + :bind (:map rustic-mode-map + ("M-j" . lsp-ui-imenu) + ("M-?" . lsp-find-references) + ("C-c C-c l" . flycheck-list-errors) + ("C-c C-c a" . lsp-execute-code-action) + ("C-c C-c r" . lsp-rename) + ("C-c C-c q" . lsp-workspace-restart) + ("C-c C-c Q" . lsp-workspace-shutdown) + ("C-c C-c s" . lsp-rust-analyzer-status)) + :config + ;; uncomment for less flashiness + ;; (setq lsp-eldoc-hook nil) + ;; (setq lsp-enable-symbol-highlighting nil) + ;; (setq lsp-signature-auto-activate nil) + + ;; comment to disable rustfmt on save + (setq rustic-format-on-save t) + (add-hook 'rustic-mode-hook 'rk/rustic-mode-hook)) + +(defun rk/rustic-mode-hook () + ;; so that run C-c C-c C-r works without having to confirm, but don't try to + ;; save rust buffers that are not file visiting. Once + ;; https://github.com/brotzeit/rustic/issues/253 has been resolved this should + ;; no longer be necessary. + (when buffer-file-name + (setq-local buffer-save-without-query t)) + (add-hook 'before-save-hook 'lsp-format-buffer nil t)) + +;; Tree-sitter +(use-package treesit-auto + :config + (global-treesit-auto-mode) + (setq treesit-auto-install t)) + +;; Vterm +(use-package vterm) + +;; Org mode +(use-package toc-org + :hook (org-mode-hook . toc-org-enable)) +(add-hook 'org-mode-hook 'org-indent-mode) +(use-package org-bullets + :hook (org-mode-hook . (lambda () (org-bullets-mode)))) + +;; GUI tweaks +;; Display numbers +(global-display-line-numbers-mode 1) +(global-visual-line-mode t) + +;; Theme +(use-package autothemer) +(use-package catppuccin-theme + :ensure t + :config + (load-theme 'catppuccin t) + (setq catppuccin-flavor 'mocha) + (catppuccin-reload)) + +;; Fonts +(set-face-attribute 'default nil + :font "Source Code Pro" + :height 113 + :weight 'medium) +(set-face-attribute 'fixed-pitch nil + :font "Source Code Pro" + :height 113 + :weight 'medium) +(set-face-attribute 'variable-pitch nil + :font "Rubik" + :height 113 + :weight 'medium) +(set-face-attribute 'font-lock-comment-face nil + :slant 'italic) +(set-face-attribute 'font-lock-keyword-face nil + :weight 'bold) + +;; Icons +(use-package all-the-icons + :ensure t + :if (display-graphic-p)) +(use-package all-the-icons-dired + :hook (dired-mode . (lambda () + all-the-icons-dired-mode t))) + +;; Modeline +(use-package mood-line + :init + (mood-line-mode) + :config + (setq mood-line-glyph-alist mood-line-glyphs-unicode)) + +;; Scrolling +(use-package good-scroll + :init (good-scroll-mode)) + +;; Dashboard +(use-package dashboard + :init + (dashboard-setup-startup-hook) + :config + (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) + (setq dashboard-banner-logo-title "Yep, it's emacs, not vim") + (setq dashboard-startup-banner 'logo) + (setq dashboard-center-content t)) + +;; Vterm + + +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(package-selected-packages '(nix-mode)) + '(warning-suppress-types + '((comp) + (comp) + (comp) + (comp) + (comp) + (comp) + (comp) + (comp) + (comp) + (comp) + (comp) + (comp) + (comp)))) +(custom-set-faces) + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + diff --git a/home-manager/general/programs/emacs/tmpWCGTRZ b/home-manager/general/programs/emacs/tmpWCGTRZ new file mode 100644 index 0000000..b17a54b --- /dev/null +++ b/home-manager/general/programs/emacs/tmpWCGTRZ @@ -0,0 +1,735 @@ +(setq gc-cons-threshold (* 50 1000 1000)) + +(require 'use-package) +(eval-and-compile + (setq use-package-always-ensure t + use-package-expand-minimally t)) + +(use-package savehist + :init + (setq savehist-file "~/.config/emacs/var/savehist.el") + :config + (setq history-length 500) + (setq savehist-additional-variables '(kill-ring search-ring)) + (savehist-mode t)) + +(use-package meow + :config + (defun meow-setup () + (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty) + (meow-motion-overwrite-define-key + '("j" . meow-next) + '("k" . meow-prev) + '("<escape>" . ignore)) + (meow-leader-define-key + ;; SPC j/k will run the original command in MOTION state. + '("j" . "H-j") + '("k" . "H-k") + ;; Use SPC (0-9) for digit arguments. + '("1" . meow-digit-argument) + '("2" . meow-digit-argument) + '("3" . meow-digit-argument) + '("4" . meow-digit-argument) + '("5" . meow-digit-argument) + '("6" . meow-digit-argument) + '("7" . meow-digit-argument) + '("8" . meow-digit-argument) + '("9" . meow-digit-argument) + '("0" . meow-digit-argument) + '("/" . meow-keypad-describe-key) + '("?" . meow-cheatsheet) + '("bk" . kill-this-buffer)) + (meow-normal-define-key + '("0" . meow-expand-0) + '("9" . meow-expand-9) + '("8" . meow-expand-8) + '("7" . meow-expand-7) + '("6" . meow-expand-6) + '("5" . meow-expand-5) + '("4" . meow-expand-4) + '("3" . meow-expand-3) + '("2" . meow-expand-2) + '("1" . meow-expand-1) + '("-" . negative-argument) + '(";" . meow-reverse) + '("," . meow-inner-of-thing) + '("." . meow-bounds-of-thing) + '("[" . meow-beginning-of-thing) + '("]" . meow-end-of-thing) + '("a" . meow-append) + '("A" . meow-open-below) + '("b" . meow-back-word) + '("B" . meow-back-symbol) + '("c" . meow-change) + '("d" . meow-delete) + '("D" . meow-backward-delete) + '("e" . meow-next-word) + '("E" . meow-next-symbol) + '("f" . meow-find) + '("g" . meow-cancel-selection) + '("G" . meow-grab) + '("h" . meow-left) + '("H" . meow-left-expand) + '("i" . meow-insert) + '("I" . meow-open-above) + '("j" . meow-next) + '("J" . meow-next-expand) + '("k" . meow-prev) + '("K" . meow-prev-expand) + '("l" . meow-right) + '("L" . meow-right-expand) + '("m" . meow-join) + '("n" . meow-search) + '("o" . meow-block) + '("O" . meow-to-block) + '("p" . meow-yank) + '("q" . meow-quit) + '("Q" . meow-goto-line) + '("r" . meow-replace) + '("R" . meow-swap-grab) + '("s" . meow-kill) + '("t" . meow-till) + '("u" . meow-undo) + '("U" . meow-undo-in-selection) + '("v" . meow-visit) + '("w" . meow-mark-word) + '("W" . meow-mark-symbol) + '("x" . meow-line) + '("X" . meow-goto-line) + '("y" . meow-save) + '("Y" . meow-sync-grab) + '("z" . meow-pop-selection) + '("'" . repeat) + '("<escape>" . ignore))) + (setq meow-use-enhanced-selection-effect t) + (meow-setup)) + ;; (meow-global-mode 1)) + +(use-package kakoune + ;; Having a non-chord way to escape is important, since key-chords don't work in macros + :bind ("C-z" . ryo-modal-mode) + :hook (after-init . my/kakoune-setup) + :config + (defun ryo-enter () "Enter normal mode" (interactive) (ryo-modal-mode 1)) + (defun my/kakoune-setup () + "Call kakoune-setup-keybinds and then add some personal config." + (kakoune-setup-keybinds) + (setq ryo-modal-cursor-type 'box) + (add-hook 'prog-mode-hook #'ryo-enter) + (define-key ryo-modal-mode-map (kbd "SPC h") 'help-command) + ;; Access all C-x bindings easily + (define-key ryo-modal-mode-map (kbd "z") ctl-x-map) + (ryo-modal-keys + ("," save-buffer) + ("P" counsel-yank-pop) + ("m" mc/mark-next-like-this) + ("M" mc/skip-to-next-like-this) + ("n" mc/mark-previous-like-this) + ("N" mc/skip-to-previous-like-this) + ("M-m" mc/edit-lines) + ("*" mc/mark-all-like-this) + ("v" er/expand-region) + ("C-v" set-rectangular-region-anchor) + ("M-s" mc/split-region) + (";" (("q" delete-window) + ("v" split-window-horizontally) + ("s" split-window-vertically))) + ("C-h" windmove-left) + ("C-j" windmove-down) + ("C-k" windmove-up) + ("C-l" windmove-right) + ("C-u" scroll-down-command :first '(deactivate-mark)) + ("C-d" scroll-up-command :first '(deactivate-mark))))) + +;; This overrides the default mark-in-region with a prettier-looking one, +;; and provides a couple extra commands +(use-package visual-regexp + :ryo + ("s" vr/mc-mark) + ("?" vr/replace) + ("M-/" vr/query-replace)) + +;; Emacs incremental search doesn't work with multiple cursors, but this fixes that +(use-package phi-search + :bind (("C-s" . phi-search) + ("C-r" . phi-search-backward))) + +;; Probably the first thing you'd miss is undo and redo, which requires an extra package +;; to work like it does in kakoune (and almost every other editor). +(use-package undo-tree + :config + (global-undo-tree-mode) + :ryo + ("u" undo-tree-undo) + ("U" undo-tree-redo) + ("SPC u" undo-tree-visualize) + :bind (:map undo-tree-visualizer-mode-map + ("h" . undo-tree-visualize-switch-branch-left) + ("j" . undo-tree-visualize-redo) + ("k" . undo-tree-visualize-undo) + ("l" . undo-tree-visualize-switch-branch-right))) + + +(use-package general + :config + ;; SPC as the global leader key + (general-create-definer spl3g/leader-keys + :prefix "C-c") + + (spl3g/leader-keys + ;; Buffers + "b" '(:ignore t :wk "Buffer") + "bi" '(ibuffer :wk "ibuffer") + "bk" '(kill-this-buffer :wk "Kill this buffer") + "bn" '(next-buffer :wk "Next buffer") + "bp" '(previous-buffer :wk "Previous buffer") + "br" '(revert-buffer :wk "Reload buffer") + "." '(find-file :wk "Find file") + ;; Splits + "w" '(:ignore t :wk "Splits") + "wv" '(split-window-right :wk "Split vertical") + "ws" '(split-window-below :wk "Split") + "ww" '(other-window :wk "Cycle throug windows") + "wc" '(delete-window :wk "Close window") + "wd" '(delete-window :wk "Close window") + "wl" '(evil-window-right :wk "") + "wj" '(evil-window-down :wk "") + "wk" '(evil-window-up :wk "") + "wh" '(evil-window-left :wk "") + "wo" '(delete-other-windows :wk "") + ;; Files + "f" '(:ignore t :wk "Files") + "fc" '((lambda () (interactive) (find-file "~/nixfiles/home-manager/programs/emacs/config.org")) :wk "Edit emacs config") + "fu" '(crux-sudo-edit :wk "Sudo edit file") + ;; Compilation + "c" '(:ignore t :wk "Compilation") + "cc" '(compile :wk "Compile") + "cr" '(recompile :wk "Recompile") + )) + +(defun spl3g/disable-scroll-bars (frame) + (modify-frame-parameters frame + '((vertical-scroll-bars . nil) + (horizontal-scroll-bars . nil)))) +(add-hook 'after-make-frame-functions 'spl3g/disable-scroll-bars) + +(setq default-frame-alist '((font . "Source Code Pro"))) +(set-face-attribute 'default nil + :font "Source Code Pro" + :height 110 + :weight 'medium) +(set-face-attribute 'fixed-pitch nil + :font "Source Code Pro" + :height 110 + :weight 'medium) +(set-face-attribute 'variable-pitch nil + :font "Rubik" + :height 110 + :weight 'medium) +(set-face-attribute 'font-lock-comment-face nil + :slant 'italic) +(set-face-attribute 'font-lock-keyword-face nil + :weight 'bold) + +(add-hook 'prog-mode-hook 'display-line-numbers-mode) +(visual-line-mode 1) + +(use-package catppuccin-theme + :ensure t + :config + (load-theme 'catppuccin t) + (setq catppuccin-flavor 'macchiato) + (catppuccin-reload)) + +(use-package all-the-icons + :ensure t + :if (display-graphic-p)) + +(use-package mood-line + + ;; Enable mood-line + :config + (mood-line-mode) + :custom + (mood-line-segment-modal-meow-state-alist + '((normal "N" . mood-line-meow-normal) + (insert "I" . mood-line-meow-insert) + (keypad "K" . mood-line-meow-keypad) + (beacon "B" . mood-line-meow-beacon) + (motion "M" . mood-line-meow-motion))) + (mood-line-glyph-alist mood-line-glyphs-fira-code) + :custom-face + (mood-line-meow-beacon ((t (:foreground "#f9e2af" :weight bold)))) + (mood-line-meow-insert ((t (:foreground "#a6e3a1" :weight bold)))) + (mood-line-meow-keypad ((t (:foreground "#cba6f7" :weight bold)))) + (mood-line-meow-motion ((t (:foreground "#fab387" :weight bold)))) + (mood-line-meow-normal ((t (:weight bold)))) + (mode-line-inactive ((t (:box (:line-width (2 . 6) :color "#11111b") :inverse-video nil :foreground "#6c7086" :background "#11111b")))) + (mode-line ((t (:box (:line-width (2 . 6) :color "#181825") :background "#181825"))))) + +(use-package good-scroll + :init (good-scroll-mode)) + +(use-package dashboard + :init + (dashboard-setup-startup-hook) + :config + (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) + (setq dashboard-banner-logo-title "Yep, it's emacs, not vim") + (setq dashboard-startup-banner 'logo) + (setq dashboard-center-content t) + (add-to-list 'dashboard-item-generators '(config . dashboard-open-config)) + (setq dashboard-items '((recents . 5) + (agenda . 5)))) + +(setq ring-bell-function 'ignore) + +(use-package indent-guide + :hook (prog-mode . indent-guide-mode)) + +(setq window-resize-pixelwise t) +(setq frame-resize-pixelwise t) +(save-place-mode t) +(defalias 'yes-or-no #'y-or-n-p) + +(add-hook 'org-mode-hook 'org-indent-mode) +(require 'org-tempo) + +(use-package toc-org + :hook (org-mode . toc-org-mode)) + +(use-package org-bullets + :hook (org-mode . org-bullets-mode)) + +(use-package org-auto-tangle + :hook (org-mode . org-auto-tangle-mode)) + +(use-package org-download + :hook + (dired-mode . org-download-enable)) + +(use-package direnv + :config + (direnv-mode)) + +(use-package vertico + :init + (vertico-mode) + :bind (:map vertico-map + ("M-j" . vertico-next) + ("M-k" . vertico-previous) + ("RET" . vertico-directory-enter) + ("DEL" . vertico-directory-delete-char) + ("M-DEL" . vertico-directory-delete-word))) + +(use-package emacs + :init + ;; Add prompt indicator to `completing-read-multiple'. + ;; We display [CRM<separator>], e.g., [CRM,] if the separator is a comma. + (defun crm-indicator (args) + (cons (format "[CRM%s] %s" + (replace-regexp-in-string + "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" + crm-separator) + (car args)) + (cdr args))) + (advice-add #'completing-read-multiple :filter-args #'crm-indicator) + + ;; Do not allow the cursor in the minibuffer prompt + (setq minibuffer-prompt-properties + '(read-only t cursor-intangible t face minibuffer-prompt)) + (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) + + ;; Emacs 28: Hide commands in M-x which do not work in the current mode. + ;; Vertico commands are hidden in normal buffers. + ;; (setq read-extended-command-predicate + ;; #'command-completion-default-include-p) + + ;; Enable recursive minibuffers + (setq enable-recursive-minibuffers t)) + +(use-package orderless + :init + (setq completion-styles '(orderless basic) + completion-category-defaults nil + completion-category-overrides '((file (styles partial-completion))))) + +(use-package marginalia + :bind (:map minibuffer-local-map + ("M-A" . marginalia-cycle)) + :init + (marginalia-mode)) + +(use-package consult + ;; Replace bindings. Lazily loaded due by `use-package'. + :bind (;; C-c bindings in `mode-specific-map' + ("C-c k" . consult-kmacro) + ("C-c m" . consult-man) + ("C-c i" . consult-info) + ([remap Info-search] . consult-info) + ("C-c f r" . consult-recent-file) + ("C-c ," . consult-buffer) + ;; C-x bindings in `ctl-x-map' + ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command + ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window + ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame + ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer + ;; Custom M-# bindings for fast register access + ("M-#" . consult-register-load) + ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) + ("C-M-#" . consult-register) + ;; Other custom bindings + ("M-y" . consult-yank-pop) ;; orig. yank-pop + ;; M-g bindings in `goto-map' + ("C-c c e" . consult-compile-error) + ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck + ("M-g g" . consult-goto-line) ;; orig. goto-line + ("M-g M-g" . consult-goto-line) ;; orig. goto-line + ("M-g o" . consult-outline) ;; Alternative: consult-org-heading + ;; M-s bindings in `search-map' + ("M-s d" . consult-fd) + ("M-s g" . consult-grep) + ("M-s G" . consult-git-grep) + ("M-s l" . consult-line) + ("M-s L" . consult-line-multi) + ("M-s k" . consult-keep-lines) + ("M-s u" . consult-focus-lines) + ;; Isearch integration + ("M-s e" . consult-isearch-history) + :map isearch-mode-map + ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string + ("M-s l" . consult-line) ;; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch + ("M-r" . consult-history) + ;; Minibuffer history + :map minibuffer-local-map + ("M-s" . consult-history) ;; orig. next-matching-history-element + ("M-r" . consult-history)) ;; orig. previous-matching-history-element) + + ;; Enable automatic preview at point in the *Completions* buffer. This is + ;; relevant when you use the default completion UI. + :hook + (completion-list-mode . consult-preview-at-point-mode) + (eshell-mode . (lambda () + (keymap-set eshell-mode-map "M-h" 'consult-history))) + + ;; The :init configuration is always executed (Not lazy) + :init + + ;; Optionally configure the register formatting. This improves the register + ;; preview for `consult-register', `consult-register-load', + ;; `consult-register-store' and the Emacs built-ins. + (setq register-preview-delay 0.5 + register-preview-function #'consult-register-format) + + ;; Optionally tweak the register preview window. + ;; This adds thin lines, sorting and hides the mode line of the window. + (advice-add #'register-preview :override #'consult-register-window) + + ;; Configure other variables and modes in the :config section, + ;; after lazily loading the package. + :config + + ;; Optionally configure preview. The default value + ;; is 'any, such that any key triggers the preview. + ;; (setq consult-preview-key 'any) + ;; (setq consult-preview-key "M-.") + ;; (setq consult-preview-key '("S-<down>" "S-<up>")) + ;; For some commands and buffer sources it is useful to configure the + ;; :preview-key on a per-command basis using the `consult-customize' macro. + (consult-customize + consult-ripgrep consult-git-grep consult-grep + consult-bookmark consult-recent-file consult-xref + consult--source-bookmark consult--source-file-register + consult--source-recent-file consult--source-project-recent-file) + ;; :preview-key "M-." + + ;; Optionally configure the narrowing key. + ;; Both < and C-+ work reasonably well. + (setq consult-narrow-key "<") ;; "C-+" + + ;; Optionally make narrowing help available in the minibuffer. + ;; You may want to use `embark-prefix-help-command' or which-key instead. + ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) + + ;; By default `consult-project-function' uses `project-root' from project.el. + ;; Optionally configure a different project root function. +;;;; 1. project.el (the default) + ;; (setq consult-project-function #'consult--default-project--function) +;;;; 2. vc.el (vc-root-dir) + ;; (setq consult-project-function (lambda (_) (vc-root-dir))) +;;;; 3. locate-dominating-file + ;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git"))) +;;;; 4. projectile.el (projectile-project-root) + ;; (autoload 'projectile-project-root "projectile") + ;; (setq consult-project-function (lambda (_) (projectile-project-root))) +;;;; 5. No project support + ;; (setq consult-project-function nil) + ) + +(use-package smartparens + :init (smartparens-global-mode) + :config + ;; Snitched from doom + (let ((unless-list '(sp-point-before-word-p + sp-point-after-word-p + sp-point-before-same-p))) + (sp-pair "'" nil :unless unless-list) + (sp-pair "\"" nil :unless unless-list)) + (dolist (brace '("(" "{" "[")) + (sp-pair brace nil + :post-handlers '(("||\n[i]" "RET") ("| " "SPC")) + :unless '(sp-point-before-word-p sp-point-before-same-p))) + (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) + (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p)) + + (sp-local-pair '(python-mode python-ts-mode) "f'" "'") + + ;; Major-mode specific fixes + (sp-local-pair 'ruby-mode "{" "}" + :pre-handlers '(:rem sp-ruby-pre-handler) + :post-handlers '(:rem sp-ruby-post-handler)) + + ;; Don't do square-bracket space-expansion where it doesn't make sense to + (sp-local-pair '(emacs-lisp-mode org-mode markdown-mode gfm-mode) + "[" nil :post-handlers '(:rem ("| " "SPC"))) + + (sp-local-pair '(emacs-lisp-mode org-mode) + "'" nil) + + ;; Reasonable default pairs for HTML-style comments + (sp-local-pair (append sp--html-modes '(markdown-mode gfm-mode)) + "<!--" "-->" + :unless '(sp-point-before-word-p sp-point-before-same-p) + :actions '(insert) :post-handlers '(("| " "SPC"))) + ;; Expand C-style comment blocks. + (defun +default-open-doc-comments-block (&rest _ignored) + (save-excursion + (newline) + (indent-according-to-mode))) + (sp-local-pair + '(js2-mode typescript-mode rjsx-mode rust-mode c-mode c++-mode objc-mode + csharp-mode java-mode php-mode css-mode scss-mode less-css-mode + stylus-mode scala-mode) + "/*" "*/" + :actions '(insert) + :post-handlers '(("| " "SPC") + (" | " "*") + ("|[i]\n[i]" "RET")))) + +;; (use-package dap-mode +;; :defer t +;; :config +;; (require 'dap-python) +;; (setq dap-python-debugger 'debugpy)) + +(use-package move-text + :bind (("C-M-k" . move-text-up) + ("C-M-j" . move-text-down))) + +(global-visual-line-mode t) + +(use-package no-littering) + +(use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) + +(use-package crux + :bind (("C-c o t" . crux-visit-shell-buffer))) + +(use-package helpful + :bind (("C-h f" . 'helpful-callable) + ("C-h v" . 'helpful-variable) + ("C-h k" . 'helpful-key) + ("C-h x" . 'helpful-command) + ("C-c C-d" . 'helpful-at-point) + ("C-h F" . 'helpful-function))) + +(add-hook 'eshell-mode-hook + (lambda () + (keymap-set eshell-mode-map "M-<tab>" 'consult-fish-completions))) + +(use-package eat + :hook (eshell-mode . eat-eshell-mode) + :custom + (eat-enable-auto-line-mode t)) + +;; (defun eat-toggle () +;; "Open eat terminal as a popup." +;; (interactive) +;; (if (eq major-mode 'eat-mode) +;; (delete-window) +;; (let ((buff (get-buffer-create eat-buffer-name))) +;; (cl-assert (and buff (buffer-live-p buff))) +;; (funcall #'pop-to-buffer buff) +;; (with-current-buffer buff +;; (setq-local split-width-threshold nil) +;; (setq-local window-min-height 2) +;; (unless (derived-mode-p 'eat-mode) +;; (eat)))))) + +;; (defun eat-modes() +;; (cond +;; ((and (eq major-mode 'eat-mode) (member 'meow-normal-mode local-minor-modes)) +;; (eat-emacs-mode)) +;; ((and (eq major-mode 'eat-mode) (member 'meow-insert-mode local-minor-modes)) +;; (eat-semi-char-mode)))) +;; (add-hook 'meow-normal-mode-hook #'eat-modes) +;; (add-hook 'meow-insert-mode-hook #'eat-modes) + +(use-package fish-completion + :hook (eshell-mode . fish-completion-mode)) + +(use-package eglot + :bind (("C-c s e e" . eglot) + ("C-c s e d" . eldoc) + ("C-c s e r" . eglot-rename) + ("C-c s e s" . eglot-shutdown) + ("C-c s e f" . eglot-find-declaration) + ("C-c s e i" . eglot-find-implementation)) + :hook + (nix-mode . eglot-ensure) + (python-ts-mode . eglot-ensure) + :config + (add-to-list 'eglot-server-programs '(python-ts-mode . ("pylsp")))) + +(use-package lsp-pyright) +(use-package py-autopep8 + :hook (python-mode . py-autopep8-mode)) + +(use-package rust-mode + :mode "\\.rs\\'") +(use-package flycheck-rust + :config + (with-eval-after-load 'rust-mode + (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))) + +(use-package fish-mode + :mode "\\.fish\\'") + +(use-package nix-mode + :mode ("\\.nix\\'" "\\.nix.in\\'")) +(use-package nix-drv-mode + :ensure nix-mode + :mode "\\.drv\\'") +(use-package nix-shell + :ensure nix-mode + :commands (nix-shell-unpack nix-shell-configure nix-shell-build)) +(use-package nix-repl + :ensure nix-mode + :commands (nix-repl)) + +(use-package web-mode + :mode + ("\\.phtml\\'" + "\\.tpl\\.php\\'" + "\\.[agj]sp\\'" + "\\.as[cp]x\\'" + "\\.erb\\'" + "\\.mustache\\'" + "\\.djhtml\\'")) + +(use-package js2-mode) + +(use-package corfu + :custom + (corfu-cycle t) + (corfu-preselect 'prompt) + (corfu-auto t) + (corfu-popupinfo-delay 0.0) + :bind + (:map corfu-map + ("TAB" . corfu-next) + ([tab] . corfu-next) + ("S-TAB" . corfu-previous) + ([backtab] . corfu-previous)) + + :init + (global-corfu-mode) + (corfu-history-mode) + (corfu-popupinfo-mode) + :config + (add-to-list 'savehist-additional-variables 'corfu-history)) +(use-package emacs + :init + (setq completion-cycle-threshold 3) + + (setq read-extended-command-predicate + #'command-completion-default-include-p) + + (setq tab-always-indent 'complete)) + +(use-package cape + :demand t + :config + (add-to-list 'completion-at-point-functions #'cape-dabbrev) + (add-to-list 'completion-at-point-functions #'cape-file) + (add-to-list 'completion-at-point-functions #'cape-elisp-block) + ) + +(use-package tree-sitter + :init + (global-tree-sitter-mode) + :config + (add-hook 'tree-sitter-mode-hook 'tree-sitter-hl-mode)) +(use-package treesit-auto + :custom + (treesit-auto-install 'prompt) + :config + (treesit-auto-add-to-auto-mode-alist 'all) + (global-treesit-auto-mode)) + +(use-package tree-sitter-langs) + +;; (use-package yasnippet +;; :init (yas-global-mode)) +;; (use-package yasnippet-snippets) + +(use-package flymake + :after eglot + :bind (("C-c s f f" . flymake-start) + ("C-c s f l" . flymake-show-buffer-diagnostics) + ("C-c s f p" . flymake-show-project-diagnostics))) + +(use-package dired + :custom + (dired-listing-switches "-al --group-directories-first")) + + + +;; (add-to-list 'load-path "~/telega.el") +;; (require 'telega) + +(use-package magit + :bind (("C-c o g" . magit))) + +;; (use-package exwm) +;; (require 'exwm) +;; (require 'exwm-config) +;; (exwm-config-example) + +;; (use-package code-cells) + +;; (use-package orgnote +;; :defer t) + +(use-package copilot + :hook (python-ts-mode . copilot-mode) + :bind ("M-RET" . copilot-accept-completion)) + +(setq gc-cons-threshold (* 2 1000 1000)) +(setq read-process-output-max (* 1024 1024)) +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(package-selected-packages + '(dired web-mode vertico use-package treesit-auto tree-sitter-langs toc-org smartparens rust-mode rainbow-delimiters py-autopep8 org-download org-bullets org-auto-tangle orderless no-littering nix-mode move-text mood-line marginalia magit lsp-pyright kakoune js2-mode indent-guide helpful good-scroll general flycheck-rust fish-mode fish-completion eglot eat direnv dashboard crux corfu copilot consult catppuccin-theme cape all-the-icons snow meow))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + ) |
