diff --git a/config/default.nix b/config/default.nix index 408c54b..cbebfd1 100644 --- a/config/default.nix +++ b/config/default.nix @@ -1,7 +1,9 @@ {pkgs, ...}: with pkgs; emacsWithPackagesFromUsePackage { - config = ./init.el; + config = ./init.org; + defaultInitFile = true; + package = if pkgs.stdenv.isDarwin then @@ -33,16 +35,18 @@ with pkgs; }) else pkgs.emacs29-pgtk; - defaultInitFile = true; - alwaysEnsure = true; alwaysTangle = true; extraEmacsPackages = epkgs: - with epkgs; [ - treemacs - treemacs-evil - ]; + with epkgs; + [ + treemacs + treemacs-evil + ] + ++ lib.optionals stdenv.isDarwin [ + ns-auto-titlebar + ]; override = epkgs: epkgs diff --git a/config/init.el b/config/init.el index 24f2d4c..7ea10c4 100644 --- a/config/init.el +++ b/config/init.el @@ -6,8 +6,21 @@ (scroll-bar-mode -1) (tool-bar-mode -1) -; Set font -(set-frame-font "Maple Mono NF 12" nil t) +; Vim-style scrolling +(setq scroll-step 3 + scroll-margin 3 + scroll-conservatively 9999) + +; Set titlebar for macOS +(when (eq system-type 'darwin) + (ns-auto-titlebar-mode)) + +; Set font size depending on the system type +(cond + ((eq system-type 'darwin) + (set-frame-font "Maple Mono NF 16" nil t)) + ((eq system-type 'gnu/linux) + (set-frame-font "Maple Mono NF 12" nil t))) ; Set theme (use-package catppuccin-theme :ensure t :demand t) @@ -26,8 +39,8 @@ (use-package undo-tree :demand t :config - (global-undo-tree-mode) ;; Enable undo-tree mode globally - (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))) ;; Directory for undo files + (global-undo-tree-mode) + (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))) ; Evil mode (use-package evil @@ -142,3 +155,6 @@ :bind ("C-<prior>" . centaur-tabs-backward) ("C-<next>" . centaur-tabs-forward)) + +(use-package vterm-toggle :ensure t) +(global-set-key [C-t] 'vterm-toggle) diff --git a/config/init.org b/config/init.org new file mode 100644 index 0000000..31b8c42 --- /dev/null +++ b/config/init.org @@ -0,0 +1,171 @@ +#+PROPERTY: header-args:emacs-lisp :tangle yes +#+TITLE: Emacs Configuration +#+AUTHOR: Mars (@pupbrained) +#+EMAIL: mars@pupbrained.xyz + +#+begin_src emacs-lisp +; Fixes "Symbol's value as variable is void: personal-keybindings" error +(require 'bind-key) + +; Start server +(load "server") +(unless (server-running-p) (server-start)) + +; Disable bars +(menu-bar-mode -1) +(scroll-bar-mode -1) +(tool-bar-mode -1) + +; Vim-style scrolling +(setq scroll-step 3 + scroll-margin 3 + scroll-conservatively 9999) + +; Set titlebar for macOS +(when (eq system-type 'darwin) + (ns-auto-titlebar-mode)) + +; Set font size depending on the system type +(cond + ((eq system-type 'darwin) + (set-frame-font "Maple Mono NF 16" nil t)) + ((eq system-type 'gnu/linux) + (set-frame-font "Maple Mono NF 12" nil t))) + +; Set theme +(use-package catppuccin-theme :ensure t :demand t) +(load-theme 'catppuccin t) + +; Set modeline +(use-package doom-modeline + :ensure t + :hook (after-init . doom-modeline-mode)) + +; Emoji support +(use-package emojify + :hook (after-init . global-emojify-mode)) + +; Undo tree +(use-package undo-tree + :demand t + :config + (global-undo-tree-mode) + (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))) + +; Evil mode +(use-package evil + :ensure t + :init + (setq evil-want-integration t) ;; This is optional since it's already set to t by default. + (setq evil-want-keybinding nil) + (setq evil-undo-system 'undo-tree) + :config + (evil-mode 1)) + +;; Evil collection +(use-package evil-collection + :after evil + :ensure t + :config + (evil-collection-init)) + +;; Evil leader +(use-package evil-leader + :after evil + :config + (global-evil-leader-mode) + (setq evil-leader/leader "<SPC>") ;; Set the leader key to space + (evil-leader/set-key "a" #'eglot-code-actions) + (evil-leader/set-key "e" #'treemacs)) + +; Dashboard +(use-package dashboard + :ensure t + :config + (dashboard-setup-startup-hook) + (setq dashboard-startup-banner 'logo)) + +(defun dashboard-recentf-filter (file) + "Add to ~recentf-exclude~ to filter recent files in dashboard buffer." + (when (eq (get-buffer dashboard-buffer-name) + (current-buffer)) + (string-match "treemacs-persist$" file))) + +(add-to-list 'recentf-exclude 'dashboard-recentf-filter) + +; Direnv +(use-package direnv + :config + (direnv-mode)) + +; Nix +(use-package nix-mode + :mode "\\.nix\\'") + +; Treesitter +(use-package tree-sitter + :hook ((prog-mode . tree-sitter-mode) + (prog-mode . tree-sitter-hl-mode))) + +(use-package tree-sitter-langs) + +(use-package treesit-auto + :config + (global-treesit-auto-mode) + (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) + +(evil-leader/set-key + "a" #'eglot-code-actions) + +;; 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 +(use-package flycheck + :ensure t + :config + (add-hook 'after-init-hook #'global-flycheck-mode)) + +; Sideline +(use-package sideline-flycheck + :hook (flycheck-mode . sideline-mode) + :init (setq sideline-backends-right '(sideline-flycheck) + sideline-delay 0.0)) + +(use-package sideline-flycheck + :hook (flycheck-mode . sideline-flycheck-setup) + :init (setq sideline-flycheck-display-mode 'line)) + +; Eglot +(use-package sideline-eglot + :init + (setq sideline-backends-right '(sideline-eglot))) + +(use-package eglot :hook (eglot-mode . sideline-mode)) ; enable it when eglot is on + +; Centaur tabs +(use-package centaur-tabs + :demand t + :config + (centaur-tabs-mode t) + (setq centaur-tabs-style "wave") + :bind + ("C-<prior>" . centaur-tabs-backward) + ("C-<next>" . centaur-tabs-forward)) + +(use-package vterm-toggle :ensure t) +(global-set-key [C-t] 'vterm-toggle) +#+end_src