fix a lot of things

This commit is contained in:
Mars 2024-08-13 21:28:53 -04:00
parent 339c8321b5
commit 9a84223cfd
Signed by: pupbrained
GPG key ID: 0FF5B8826803F895

View file

@ -1,163 +1,268 @@
#+PROPERTY: header-args:emacs-lisp :tangle yes
#+TITLE: Emacs Configuration
#+AUTHOR: Mars (@pupbrained)
#+EMAIL: mars@pupbrained.xyz
#+PROPERTY: header-args:emacs-lisp :tangle yes
* Basic Setup
** Server
#+begin_src emacs-lisp
; Fixes "Symbol's value as variable is void: personal-keybindings" error
(require 'bind-key)
(require 'bind-key)
(load "server")
(unless (server-running-p) (server-start))
#+end_src
; Start server
(load "server")
(unless (server-running-p) (server-start))
** Disable UI Elements
; Disable bars
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
#+begin_src emacs-lisp
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
#+end_src
; Vim-style scrolling
(setq scroll-step 3
** Vim-Style Scrolling
#+begin_src emacs-lisp
(setq scroll-step 3
scroll-margin 3
scroll-conservatively 9999)
#+end_src
; Set titlebar for macOS
(when (eq system-type 'darwin)
** System-Specific Settings
#+begin_src emacs-lisp
(when (and (eq system-type 'darwin) (not (daemonp)))
(ns-auto-titlebar-mode))
; Set font size depending on the system type
(cond
(cond
((eq system-type 'darwin)
(setq default-frame-alist '((font . "Maple Mono NF-16"))))
((eq system-type 'gnu/linux)
(setq default-frame-alist '((font . "Maple Mono NF-12")))))
#+end_src
; Set theme
(use-package catppuccin-theme :ensure t :demand t)
(load-theme 'catppuccin t)
* Package Management
; Set modeline
(use-package doom-modeline
** Theme
#+begin_src emacs-lisp
(use-package catppuccin-theme :ensure t :demand t)
(load-theme 'catppuccin t)
#+end_src
** Dashboard
#+begin_src emacs-lisp
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
(setq dashboard-startup-banner 'logo)
(setq dashboard-center-content t)
(setq dashboard-vertically-center-content t)
(setq dashboard-startup-banner 'logo)
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
(setq recentf-exclude '("~/.emacs.d/.cache/treemacs-persist")))
#+end_src
** Modeline
#+begin_src emacs-lisp
(use-package doom-modeline
:ensure t
:hook (after-init . doom-modeline-mode))
#+end_src
; Emoji support
(use-package emojify
** Emoji Support
#+begin_src emacs-lisp
(use-package emojify
:hook (after-init . global-emojify-mode))
#+end_src
; Undo tree
(use-package undo-tree
** Undo Tree
#+begin_src emacs-lisp
(use-package undo-tree
:demand t
:config
(global-undo-tree-mode)
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))))
#+end_src
; 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))
* Development Tools
;; Evil collection
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init))
** Direnv
;; 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
#+begin_src emacs-lisp
(use-package direnv
:config
(direnv-mode))
#+end_src
; Nix
(use-package nix-mode
** Nix
#+begin_src emacs-lisp
(use-package nix-mode
:mode "\\.nix\\'")
#+end_src
; Treesitter
(use-package tree-sitter
:hook ((prog-mode . tree-sitter-mode)
(prog-mode . tree-sitter-hl-mode)))
** Treesitter
(use-package tree-sitter-langs)
(use-package treesit-auto
#+begin_src emacs-lisp
(use-package treesit-auto
:requires treesit
: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))))))
(setq treesit-auto-install 'prompt)
(global-treesit-auto-mode))
; Eglot setup
(add-hook 'prog-mode-hook 'eglot-ensure)
(use-package treesit
:requires treesit
:ensure nil
:config
(mapc #'exordium--add-forward-ts-hook
'(
LaTeX
bash
c
c++
cmake
csharp
css
go
go-mod
java
js
json
markdown
python
ruby
rust
scala
toml
typescript
yaml
))
(setq treesit-font-lock-level 4))
(evil-leader/set-key
"a" #'eglot-code-actions)
(use-package tree-sitter-langs)
(use-package tree-sitter
:diminish
:after (tree-sitter-langs)
:hook
(tree-sitter-after-on . tree-sitter-hl-mode)
:custom
(font-lock-maximum-decoration t)
:config
(when-let ((language-name (alist-get 'ruby-mode
tree-sitter-major-mode-language-alist)))
(add-to-list 'tree-sitter-major-mode-language-alist
(cons 'enh-ruby-mode language-name)))
(add-to-list 'tree-sitter-major-mode-language-alist
(cons 'forge-post-mode 'markdown))
(global-tree-sitter-mode))
#+end_src
;; Function to format the buffer using Eglot
(defun my/eglot-format-buffer-on-save ()
** Eglot
#+begin_src emacs-lisp
(add-hook 'prog-mode-hook 'eglot-ensure)
(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)
(add-hook 'before-save-hook #'my/eglot-format-buffer-on-save)
#+end_src
; Flycheck
(use-package flycheck
** Flycheck
#+begin_src emacs-lisp
(use-package flycheck
:ensure t
:config
(add-hook 'after-init-hook #'global-flycheck-mode))
#+end_src
; Sideline
(use-package sideline-flycheck
** Sideline
#+begin_src emacs-lisp
(use-package sideline-flycheck
:hook (flycheck-mode . sideline-mode)
:init (setq sideline-backends-right '(sideline-flycheck)
sideline-delay 0.0))
(use-package sideline-flycheck
(use-package sideline-flycheck
:hook (flycheck-mode . sideline-flycheck-setup)
:init (setq sideline-flycheck-display-mode 'line))
; Eglot
(use-package sideline-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
(use-package eglot :hook (eglot-mode . sideline-mode))
#+end_src
; Centaur tabs
(use-package centaur-tabs
** VTerm Toggle
#+begin_src emacs-lisp
(use-package vterm-toggle :ensure t)
(global-set-key [C-t] 'vterm-toggle)
#+end_src
* Evil Mode and Keybindings
** Evil Mode
#+begin_src emacs-lisp
(use-package evil
:ensure t
:init
(setq evil-want-integration t)
(setq evil-want-C-u-scroll t)
(setq evil-want-keybinding nil)
(setq evil-undo-system 'undo-tree)
:config
(evil-mode 1))
#+end_src
** Evil Collection
#+begin_src emacs-lisp
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init))
#+end_src
** Evil Leader
#+begin_src emacs-lisp
(use-package evil-leader
:after evil
:config
(global-evil-leader-mode)
(setq evil-leader/leader "<SPC>")
(evil-leader/set-key "a" #'eglot-code-actions)
(evil-leader/set-key "e" #'treemacs))
#+end_src
** Easier Copy/Paste
#+begin_src emacs-lisp
(global-set-key (kbd "C-S-c") 'kill-ring-save)
(global-set-key (kbd "C-S-v") 'yank)
#+end_src
* Tab Management
** Centaur Tabs
#+begin_src emacs-lisp
(use-package centaur-tabs
:demand t
:config
(centaur-tabs-mode t)
@ -165,7 +270,4 @@
: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