blegh
This commit is contained in:
parent
468bac3270
commit
09232be6a3
|
@ -71,195 +71,33 @@
|
|||
tealdeer.enable = false;
|
||||
wezterm.extraConfig = builtins.readFile ./wezterm.lua;
|
||||
|
||||
emacs = {
|
||||
enable = true;
|
||||
package = pkgs.emacs29-pgtk;
|
||||
|
||||
extraPackages = epkgs:
|
||||
with epkgs; [
|
||||
catppuccin-theme
|
||||
company
|
||||
dashboard
|
||||
direnv
|
||||
doom-modeline
|
||||
eglot
|
||||
evil
|
||||
evil-leader
|
||||
flycheck
|
||||
flycheck-inline
|
||||
ligature
|
||||
lua-mode
|
||||
ns-auto-titlebar
|
||||
nix-mode
|
||||
treemacs
|
||||
treemacs-evil
|
||||
treesit-auto
|
||||
treesit-grammars.with-all-grammars
|
||||
tree-sitter-langs
|
||||
vterm
|
||||
];
|
||||
|
||||
extraConfig = ''
|
||||
; Catppuccin theme
|
||||
(load-theme 'catppuccin :no-confirm)
|
||||
|
||||
; Doom modeline
|
||||
(require 'doom-modeline)
|
||||
(doom-modeline-mode 1)
|
||||
|
||||
; Set titlebar
|
||||
(when (eq system-type 'darwin) (ns-auto-titlebar-mode))
|
||||
|
||||
; Set font
|
||||
(set-frame-font "Maple Mono NF 16" nil t)
|
||||
|
||||
; Show line numbers
|
||||
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
|
||||
(setq display-line-numbers-type 'relative)
|
||||
|
||||
; Change default indent size to 2 spaces
|
||||
(setq-default indent-tabs-mode nil) ;; Use spaces instead of tabs
|
||||
(setq-default standard-indent 2) ;; Change indent
|
||||
(setq-default tab-width 2) ;; Change tab width
|
||||
|
||||
; Evil mode
|
||||
(setq evil-want-C-u-scroll t)
|
||||
(require 'evil)
|
||||
(evil-mode 1)
|
||||
|
||||
(setq scroll-step 3)
|
||||
(setq scroll-margin 3)
|
||||
(setq scroll-conservatively 9999)
|
||||
|
||||
;; Treemacs (+ evil mode support)
|
||||
(require 'treemacs)
|
||||
(require 'treemacs-evil) ; Optional: if you want Evil keybindings for Treemacs
|
||||
|
||||
;; Evil leader
|
||||
(global-evil-leader-mode)
|
||||
(evil-leader/set-leader "<SPC>")
|
||||
(evil-leader/set-key "e" 'treemacs)
|
||||
|
||||
;; Centered scrolling
|
||||
(defun my/evil-scroll-up ()
|
||||
"Scroll up half a screen and center the line."
|
||||
(interactive)
|
||||
(evil-scroll-up nil)
|
||||
(recenter))
|
||||
|
||||
(defun my/evil-scroll-down ()
|
||||
"Scroll down half a screen and center the line."
|
||||
(interactive)
|
||||
(evil-scroll-down nil)
|
||||
(recenter))
|
||||
|
||||
(define-key evil-normal-state-map (kbd "C-u") 'my/evil-scroll-up)
|
||||
(define-key evil-normal-state-map (kbd "C-d") 'my/evil-scroll-down)
|
||||
|
||||
; Disable unnecessary bars
|
||||
(menu-bar-mode -1)
|
||||
(scroll-bar-mode -1)
|
||||
(tool-bar-mode -1)
|
||||
|
||||
; Dashboard
|
||||
(require 'dashboard)
|
||||
(dashboard-setup-startup-hook)
|
||||
(setq dashboard-startup-banner 'logo)
|
||||
|
||||
; Direnv
|
||||
(direnv-mode)
|
||||
|
||||
; Nix setup
|
||||
(require 'nix-mode)
|
||||
(add-to-list 'auto-mode-alist '("\\.nix\\'" . nix-mode))
|
||||
(add-to-list 'interpreter-mode-alist '("nix" . nix-mode))
|
||||
|
||||
; Lua setup
|
||||
(require 'lua-mode)
|
||||
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
|
||||
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
|
||||
|
||||
; Tree-sitter setup
|
||||
(require 'treesit)
|
||||
(require 'tree-sitter-langs)
|
||||
(require 'treesit-auto)
|
||||
(global-treesit-auto-mode)
|
||||
|
||||
(add-hook 'prog-mode-hook #'tree-sitter-mode)
|
||||
(add-hook 'prog-mode-hook #'tree-sitter-hl-mode)
|
||||
|
||||
;; Use Tree-sitter for better syntax highlighting
|
||||
(dolist (lang treesit-language-source-alist)
|
||||
(let ((mode (intern (format "%s-ts-mode" (car lang)))))
|
||||
(when (fboundp mode)
|
||||
(add-to-list 'major-mode-remap-alist
|
||||
(cons (intern (car lang)) mode)))))
|
||||
|
||||
; Eglot setup
|
||||
(add-hook 'prog-mode-hook 'eglot-ensure)
|
||||
(add-hook 'nix-mode-hook 'eglot-ensure)
|
||||
|
||||
;; Function to format the buffer using Eglot
|
||||
(defun my/eglot-format-buffer-on-save ()
|
||||
"Format the current buffer if Eglot is active."
|
||||
(when (bound-and-true-p eglot--managed-p)
|
||||
(eglot-format-buffer)))
|
||||
|
||||
;; Add the function to the save-hook
|
||||
(add-hook 'before-save-hook #'my/eglot-format-buffer-on-save)
|
||||
|
||||
; Flycheck setup
|
||||
(require 'flycheck)
|
||||
(global-flycheck-mode)
|
||||
|
||||
; Flycheck-inline setup
|
||||
(require 'flycheck-inline)
|
||||
(add-hook 'flycheck-mode-hook #'flycheck-inline-mode)
|
||||
|
||||
; Disable Flycheck modeline error messages
|
||||
(setq-default flycheck-mode-line-prefix "")
|
||||
(setq-default flycheck-display-errors-function #'flycheck-inline-display-errors)
|
||||
|
||||
; Company mode setup
|
||||
(require 'company)
|
||||
(global-company-mode) ; Enable Company mode globally
|
||||
|
||||
; Key bindings for company mode
|
||||
(setq company-idle-delay 0.2) ; Start completion after a short delay
|
||||
(setq company-minimum-prefix-length 1) ; Start completion after typing 1 character
|
||||
(setq company-show-numbers t) ; Show numbers for completion candidates
|
||||
(global-set-key (kbd "M-/") 'company-complete) ; Trigger completion manually with M-/
|
||||
|
||||
(defun my/compile-and-focus-treemacs ()
|
||||
"Run `compile` and focus on the project root in `Treemacs`."
|
||||
(interactive)
|
||||
(let ((default-directory (project-root (project-current t))))
|
||||
(compile (read-shell-command "Compile command: " (concat (or compile-command "make") " ")))
|
||||
(treemacs-select-window)))
|
||||
|
||||
(global-set-key (kbd "C-c C-c") 'my/compile-and-focus-treemacs)
|
||||
|
||||
; Ligatures
|
||||
(setq maple-ligatures
|
||||
'(;; coding ligatures
|
||||
"<!---" "--->" "|||>" "<!--" "<|||" "<==>" "-->" "->>" "-<<" "..=" "!=="
|
||||
"#_(" "/==" "||>" "||=" "|->" "===" "==>" "=>>" "=<<" "=/=" ">->" ">=>"
|
||||
">>-" ">>=" "<--" "<->" "<-<" "<||" "<|>" "<=" "<==" "<=>" "<=<" "<<-"
|
||||
"<<=" "<~>" "<~~" "~~>" ">&-" "<&-" "&>>" "&>" "->" "-<" "-~" ".=" "!="
|
||||
"#_" "/=" "|=" "|>" "==" "=>" ">-" ">=" "<-" "<|" "<~" "~-" "~@" "~="
|
||||
"~>" "~~"
|
||||
|
||||
;; whitespace ligatures
|
||||
"---" "..." "{|" "[|" ".?" "::" ":::" "::=" ":="
|
||||
":>" ":<" "\;\;" "!!" "!!." "!!!" "?." "?:" "??" "?=" "**" "***" "*>"
|
||||
"*/" "--" "#:" "#!" "#?" "##" "###" "####" "#=" "/*" "/>" "//" "/**"
|
||||
"///" "$(" ">&" "<&" "&&" "|}" "|]" "$>" ".." "++" "+++" "+>" "=:="
|
||||
"=!=" ">:" ">>" ">>>" "<:" "<*" "<*>" "<$" "<$>" "<+" "<+>" "<>" "<<"
|
||||
"<<<" "</" "</>" "^=" "%%"))
|
||||
(ligature-set-ligatures 'prog-mode maple-ligatures)
|
||||
(global-ligature-mode t)
|
||||
'';
|
||||
};
|
||||
emacs.package = with pkgs;
|
||||
emacs29-pgtk.overrideAttrs (old: {
|
||||
patches =
|
||||
(old.patches or [])
|
||||
++ [
|
||||
# Fix OS window role (needed for window managers like yabai)
|
||||
(fetchpatch {
|
||||
url = "https://raw.githubusercontent.com/d12frosted/homebrew-emacs-plus/master/patches/emacs-28/fix-window-role.patch";
|
||||
sha256 = "0c41rgpi19vr9ai740g09lka3nkjk48ppqyqdnncjrkfgvm2710z";
|
||||
})
|
||||
# Use poll instead of select to get file descriptors
|
||||
(fetchpatch {
|
||||
url = "https://raw.githubusercontent.com/d12frosted/homebrew-emacs-plus/master/patches/emacs-29/poll.patch";
|
||||
sha256 = "0j26n6yma4n5wh4klikza6bjnzrmz6zihgcsdx36pn3vbfnaqbh5";
|
||||
})
|
||||
# Enable rounded window with no decoration
|
||||
(fetchpatch {
|
||||
url = "https://raw.githubusercontent.com/d12frosted/homebrew-emacs-plus/master/patches/emacs-29/round-undecorated-frame.patch";
|
||||
sha256 = "0x187xvjakm2730d1wcqbz2sny07238mabh5d97fah4qal7zhlbl";
|
||||
})
|
||||
# Make Emacs aware of OS-level light/dark mode
|
||||
(fetchpatch {
|
||||
url = "https://raw.githubusercontent.com/d12frosted/homebrew-emacs-plus/master/patches/emacs-28/system-appearance.patch";
|
||||
sha256 = "14ndp2fqqc95s70fwhpxq58y8qqj4gzvvffp77snm2xk76c1bvnn";
|
||||
})
|
||||
];
|
||||
});
|
||||
|
||||
git = {
|
||||
extraConfig.credential.helper = "osxkeychain";
|
||||
|
|
199
modules/home/emacs/config/init.el
Normal file
199
modules/home/emacs/config/init.el
Normal file
|
@ -0,0 +1,199 @@
|
|||
; Catppuccin theme
|
||||
(load-theme 'catppuccin :no-confirm)
|
||||
|
||||
; Doom modeline
|
||||
(require 'doom-modeline)
|
||||
(doom-modeline-mode 1)
|
||||
|
||||
; Set titlebar
|
||||
(when (eq system-type 'darwin) (ns-auto-titlebar-mode))
|
||||
|
||||
; Set font
|
||||
(set-frame-font "Maple Mono NF 16" nil t)
|
||||
|
||||
; Show line numbers
|
||||
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
|
||||
(setq display-line-numbers-type 'relative)
|
||||
|
||||
; Change default indent size to 2 spaces
|
||||
(setq-default indent-tabs-mode nil) ;; Use spaces instead of tabs
|
||||
(setq-default standard-indent 2) ;; Change indent
|
||||
(setq-default tab-width 2) ;; Change tab width
|
||||
|
||||
; Vim-like Scrolling
|
||||
(setq scroll-step 3)
|
||||
(setq scroll-margin 3)
|
||||
(setq scroll-conservatively 9999)
|
||||
|
||||
; Evil mode
|
||||
(setq evil-want-C-u-scroll t)
|
||||
(require 'evil)
|
||||
(evil-mode 1)
|
||||
|
||||
;; Treemacs (+ evil mode support)
|
||||
(require 'treemacs)
|
||||
(require 'treemacs-evil) ; Optional: if you want Evil keybindings for Treemacs
|
||||
|
||||
;; Evil leader
|
||||
(global-evil-leader-mode)
|
||||
(evil-leader/set-leader "<SPC>")
|
||||
(evil-leader/set-key "e" 'treemacs)
|
||||
|
||||
;; Centered scrolling
|
||||
(defun my/evil-scroll-up ()
|
||||
"Scroll up half a screen and center the line."
|
||||
(interactive)
|
||||
(evil-scroll-up nil)
|
||||
(recenter))
|
||||
|
||||
(defun my/evil-scroll-down ()
|
||||
"Scroll down half a screen and center the line."
|
||||
(interactive)
|
||||
(evil-scroll-down nil)
|
||||
(recenter))
|
||||
|
||||
(define-key evil-normal-state-map (kbd "C-u") 'my/evil-scroll-up)
|
||||
(define-key evil-normal-state-map (kbd "C-d") 'my/evil-scroll-down)
|
||||
|
||||
; Disable unnecessary bars
|
||||
(menu-bar-mode -1)
|
||||
(scroll-bar-mode -1)
|
||||
(tool-bar-mode -1)
|
||||
|
||||
; Dashboard
|
||||
(require 'dashboard)
|
||||
(dashboard-setup-startup-hook)
|
||||
(setq dashboard-startup-banner 'logo)
|
||||
|
||||
; Direnv
|
||||
(direnv-mode)
|
||||
|
||||
; Nix setup
|
||||
(require 'nix-mode)
|
||||
(add-to-list 'auto-mode-alist '("\\.nix\\'" . nix-mode))
|
||||
(add-to-list 'interpreter-mode-alist '("nix" . nix-mode))
|
||||
|
||||
; Lua setup
|
||||
(require 'lua-mode)
|
||||
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
|
||||
(add-to-list 'interpreter-mode-alist '("lua" . lua-mode))
|
||||
|
||||
; Tree-sitter setup
|
||||
(require 'treesit)
|
||||
(require 'tree-sitter-langs)
|
||||
(require 'treesit-auto)
|
||||
(global-treesit-auto-mode)
|
||||
|
||||
(add-hook 'prog-mode-hook #'tree-sitter-mode)
|
||||
(add-hook 'prog-mode-hook #'tree-sitter-hl-mode)
|
||||
|
||||
;; Use Tree-sitter for better syntax highlighting
|
||||
(dolist (lang treesit-language-source-alist)
|
||||
(let ((mode (intern (format "%s-ts-mode" (car lang)))))
|
||||
(when (fboundp mode)
|
||||
(add-to-list 'major-mode-remap-alist
|
||||
(cons (intern (car lang)) mode)))))
|
||||
|
||||
; Eglot setup
|
||||
(add-hook 'prog-mode-hook 'eglot-ensure)
|
||||
(add-hook 'nix-mode-hook 'eglot-ensure)
|
||||
|
||||
;; Function to format the buffer using Eglot
|
||||
(defun my/eglot-format-buffer-on-save ()
|
||||
"Format the current buffer if Eglot is active."
|
||||
(when (bound-and-true-p eglot--managed-p)
|
||||
(eglot-format-buffer)))
|
||||
|
||||
;; Add the function to the save-hook
|
||||
(add-hook 'before-save-hook #'my/eglot-format-buffer-on-save)
|
||||
|
||||
; Flycheck setup
|
||||
(require 'flycheck)
|
||||
(flycheck-mode . sideline-mode)
|
||||
(require 'sideline-flycheck)
|
||||
(flycheck-mode . sideline-flycheck-setup)
|
||||
|
||||
; Key bindings for company mode
|
||||
(setq company-idle-delay 0.2) ; Start completion after a short delay
|
||||
(setq company-minimum-prefix-length 1) ; Start completion after typing 1 character
|
||||
(setq company-show-numbers t) ; Show numbers for completion candidates
|
||||
(global-set-key (kbd "M-/") 'company-complete) ; Trigger completion manually with M-/
|
||||
|
||||
(defun my/compile-and-focus-treemacs ()
|
||||
"Run `compile` and focus on the project root in `Treemacs`."
|
||||
(interactive)
|
||||
(let ((default-directory (project-root (project-current t))))
|
||||
(compile (read-shell-command "Compile command: " (concat (or compile-command "make") " ")))
|
||||
(treemacs-select-window)))
|
||||
|
||||
(global-set-key (kbd "C-c C-c") 'my/compile-and-focus-treemacs)
|
||||
|
||||
; Ligatures
|
||||
(setq maple-ligatures
|
||||
'(;; coding ligatures
|
||||
"==" "===" "!=" "=/=" "!==" ">=" "<=" "<<<"
|
||||
"->" "=>" "-->" "==>" "<->" "<=>" "<==>"
|
||||
"->>" "-<<" "=<<" ">>=" ">>-" "<<-" "<-<"
|
||||
"</" "/>" "<>" "</>" "<!--" "<--" "-<"
|
||||
"|>" "||>" "|||>" "<|>" ">=>" "=>>" "<|"
|
||||
"<||" "<|||" "<<=" ">-" "<-" "++" "--"
|
||||
"&&" "||" "!!" "??" ".." "::" "##" "###"
|
||||
"####" "#####" "######" "#_(" "|->" ">->"
|
||||
"<==" "<=<" "<~>" "<~~" "~~>" "-~" ".="
|
||||
"#_" "<~" "~-" "~@" "~>" "~~" "---" "..."
|
||||
"{|" "[|" ":::" "::=" ":=" ":>" ":<" "!!!"
|
||||
"?." "?:" "***" "*/" "/*" "//" "/**" "///"
|
||||
"|}" "|]" "+++" "+>" "=:=" "=!=" ">:" ">>"
|
||||
">>>" "<:" "<*" "<*>" "<$>" "<+" "<+>" "<<"
|
||||
|
||||
;; misc. ligatures
|
||||
"[TODO]" "TODO))" "todo))" "[FIXME]" "FIXME))" "fixme))"
|
||||
"[TRACE]" "[DEBUG]" "[INFO]" "[WARN]" "[ERROR]" "[FATAL]"))
|
||||
(ligature-set-ligatures 'prog-mode maple-ligatures)
|
||||
(global-ligature-mode t)
|
||||
|
||||
; Codeium
|
||||
(add-to-list 'completion-at-point-functions #'codeium-completion-at-point)
|
||||
(setq use-dialog-box nil) ;; do not use popup boxes
|
||||
|
||||
;; if you don't want to use customize to save the api-key
|
||||
;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
|
||||
|
||||
;; get codeium status in the modeline
|
||||
(setq codeium-mode-line-enable
|
||||
(lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion)))))
|
||||
(add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t)
|
||||
|
||||
;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server
|
||||
(setq codeium-api-enabled
|
||||
(lambda (api)
|
||||
(memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion))))
|
||||
|
||||
;; You can overwrite all the codeium configs!
|
||||
;; for example, we recommend limiting the string sent to codeium for better performance
|
||||
(defun my-codeium/document/text ()
|
||||
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max))))
|
||||
|
||||
;; if you change the text, you should also change the cursor_offset
|
||||
;; warning: this is measured by UTF-8 encoded bytes
|
||||
(defun my-codeium/document/cursor_offset ()
|
||||
(codeium-utf8-byte-length
|
||||
(buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point))))
|
||||
|
||||
(setq codeium/document/text 'my-codeium/document/text)
|
||||
(setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset)
|
||||
|
||||
; Corfu mode setup
|
||||
(require 'corfu)
|
||||
(global-corfu-mode) ; Enable Corfu mode globally
|
||||
(setq corfu-auto t)
|
||||
|
||||
(defun corfu-codeium-completion-at-point ()
|
||||
"Completion at point with codeium using corfu."
|
||||
(when (and (bound-and-true-p codeium-mode)
|
||||
(or (not (bound-and-true-p corfu-mode))
|
||||
corfu-mode))
|
||||
(codeium--completion-at-point)))
|
||||
|
||||
;; Add corfu-codeium-completion-at-point to the completion-at-point-functions
|
||||
(add-hook 'completion-at-point-functions #'corfu-codeium-completion-at-point)
|
32
modules/home/emacs/default.nix
Normal file
32
modules/home/emacs/default.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{...}: {
|
||||
programs.emacs = {
|
||||
enable = true;
|
||||
|
||||
extraPackages = epkgs:
|
||||
with epkgs; [
|
||||
catppuccin-theme
|
||||
codeium
|
||||
corfu
|
||||
dashboard
|
||||
direnv
|
||||
doom-modeline
|
||||
evil
|
||||
evil-leader
|
||||
flycheck
|
||||
ligature
|
||||
lua-mode
|
||||
nix-mode
|
||||
ns-auto-titlebar
|
||||
sideline
|
||||
sideline-flycheck
|
||||
tree-sitter-langs
|
||||
treemacs
|
||||
treemacs-evil
|
||||
treesit-auto
|
||||
treesit-grammars.with-all-grammars
|
||||
vterm
|
||||
];
|
||||
|
||||
extraConfig = builtins.readFile ./config/init.el;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue