fix a lot of things
This commit is contained in:
parent
339c8321b5
commit
9a84223cfd
432
config/init.org
432
config/init.org
|
@ -1,171 +1,273 @@
|
||||||
#+PROPERTY: header-args:emacs-lisp :tangle yes
|
|
||||||
#+TITLE: Emacs Configuration
|
#+TITLE: Emacs Configuration
|
||||||
#+AUTHOR: Mars (@pupbrained)
|
#+AUTHOR: Mars (@pupbrained)
|
||||||
#+EMAIL: mars@pupbrained.xyz
|
#+EMAIL: mars@pupbrained.xyz
|
||||||
|
#+PROPERTY: header-args:emacs-lisp :tangle yes
|
||||||
|
|
||||||
|
* Basic Setup
|
||||||
|
|
||||||
|
** Server
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+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))
|
||||||
; Start server
|
#+end_src
|
||||||
(load "server")
|
|
||||||
(unless (server-running-p) (server-start))
|
** Disable UI Elements
|
||||||
|
|
||||||
; Disable bars
|
#+begin_src emacs-lisp
|
||||||
(menu-bar-mode -1)
|
(menu-bar-mode -1)
|
||||||
(scroll-bar-mode -1)
|
(scroll-bar-mode -1)
|
||||||
(tool-bar-mode -1)
|
(tool-bar-mode -1)
|
||||||
|
#+end_src
|
||||||
; Vim-style scrolling
|
|
||||||
(setq scroll-step 3
|
** Vim-Style Scrolling
|
||||||
scroll-margin 3
|
|
||||||
scroll-conservatively 9999)
|
#+begin_src emacs-lisp
|
||||||
|
(setq scroll-step 3
|
||||||
; Set titlebar for macOS
|
scroll-margin 3
|
||||||
(when (eq system-type 'darwin)
|
scroll-conservatively 9999)
|
||||||
(ns-auto-titlebar-mode))
|
#+end_src
|
||||||
|
|
||||||
; Set font size depending on the system type
|
** System-Specific Settings
|
||||||
(cond
|
|
||||||
((eq system-type 'darwin)
|
#+begin_src emacs-lisp
|
||||||
(setq default-frame-alist '((font . "Maple Mono NF-16"))))
|
(when (and (eq system-type 'darwin) (not (daemonp)))
|
||||||
((eq system-type 'gnu/linux)
|
(ns-auto-titlebar-mode))
|
||||||
(setq default-frame-alist '((font . "Maple Mono NF-12")))))
|
|
||||||
|
(cond
|
||||||
; Set theme
|
((eq system-type 'darwin)
|
||||||
(use-package catppuccin-theme :ensure t :demand t)
|
(setq default-frame-alist '((font . "Maple Mono NF-16"))))
|
||||||
(load-theme 'catppuccin t)
|
((eq system-type 'gnu/linux)
|
||||||
|
(setq default-frame-alist '((font . "Maple Mono NF-12")))))
|
||||||
; Set modeline
|
#+end_src
|
||||||
(use-package doom-modeline
|
|
||||||
:ensure t
|
* Package Management
|
||||||
:hook (after-init . doom-modeline-mode))
|
|
||||||
|
** Theme
|
||||||
; Emoji support
|
|
||||||
(use-package emojify
|
#+begin_src emacs-lisp
|
||||||
:hook (after-init . global-emojify-mode))
|
(use-package catppuccin-theme :ensure t :demand t)
|
||||||
|
(load-theme 'catppuccin t)
|
||||||
; Undo tree
|
#+end_src
|
||||||
(use-package undo-tree
|
|
||||||
:demand t
|
** Dashboard
|
||||||
:config
|
|
||||||
(global-undo-tree-mode)
|
#+begin_src emacs-lisp
|
||||||
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))))
|
(use-package dashboard
|
||||||
|
:ensure t
|
||||||
; Evil mode
|
:config
|
||||||
(use-package evil
|
(dashboard-setup-startup-hook)
|
||||||
:ensure t
|
(setq dashboard-startup-banner 'logo)
|
||||||
:init
|
(setq dashboard-center-content t)
|
||||||
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
|
(setq dashboard-vertically-center-content t)
|
||||||
(setq evil-want-keybinding nil)
|
(setq dashboard-startup-banner 'logo)
|
||||||
(setq evil-undo-system 'undo-tree)
|
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
|
||||||
:config
|
(setq recentf-exclude '("~/.emacs.d/.cache/treemacs-persist")))
|
||||||
(evil-mode 1))
|
#+end_src
|
||||||
|
|
||||||
;; Evil collection
|
** Modeline
|
||||||
(use-package evil-collection
|
|
||||||
:after evil
|
#+begin_src emacs-lisp
|
||||||
:ensure t
|
(use-package doom-modeline
|
||||||
:config
|
:ensure t
|
||||||
(evil-collection-init))
|
:hook (after-init . doom-modeline-mode))
|
||||||
|
#+end_src
|
||||||
;; Evil leader
|
|
||||||
(use-package evil-leader
|
** Emoji Support
|
||||||
:after evil
|
|
||||||
:config
|
#+begin_src emacs-lisp
|
||||||
(global-evil-leader-mode)
|
(use-package emojify
|
||||||
(setq evil-leader/leader "<SPC>") ;; Set the leader key to space
|
:hook (after-init . global-emojify-mode))
|
||||||
(evil-leader/set-key "a" #'eglot-code-actions)
|
#+end_src
|
||||||
(evil-leader/set-key "e" #'treemacs))
|
|
||||||
|
** Undo Tree
|
||||||
; Dashboard
|
|
||||||
(use-package dashboard
|
#+begin_src emacs-lisp
|
||||||
:ensure t
|
(use-package undo-tree
|
||||||
:config
|
:demand t
|
||||||
(dashboard-setup-startup-hook)
|
:config
|
||||||
(setq dashboard-startup-banner 'logo))
|
(global-undo-tree-mode)
|
||||||
|
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))))
|
||||||
(defun dashboard-recentf-filter (file)
|
#+end_src
|
||||||
"Add to ~recentf-exclude~ to filter recent files in dashboard buffer."
|
|
||||||
(when (eq (get-buffer dashboard-buffer-name)
|
* Development Tools
|
||||||
(current-buffer))
|
|
||||||
(string-match "treemacs-persist$" file)))
|
** Direnv
|
||||||
|
|
||||||
(add-to-list 'recentf-exclude 'dashboard-recentf-filter)
|
#+begin_src emacs-lisp
|
||||||
|
(use-package direnv
|
||||||
; Direnv
|
:config
|
||||||
(use-package direnv
|
(direnv-mode))
|
||||||
:config
|
#+end_src
|
||||||
(direnv-mode))
|
|
||||||
|
** Nix
|
||||||
; Nix
|
|
||||||
(use-package nix-mode
|
#+begin_src emacs-lisp
|
||||||
:mode "\\.nix\\'")
|
(use-package nix-mode
|
||||||
|
:mode "\\.nix\\'")
|
||||||
; Treesitter
|
#+end_src
|
||||||
(use-package tree-sitter
|
|
||||||
:hook ((prog-mode . tree-sitter-mode)
|
** Treesitter
|
||||||
(prog-mode . tree-sitter-hl-mode)))
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
(use-package tree-sitter-langs)
|
(use-package treesit-auto
|
||||||
|
:requires treesit
|
||||||
(use-package treesit-auto
|
:config
|
||||||
:config
|
(setq treesit-auto-install 'prompt)
|
||||||
(global-treesit-auto-mode)
|
(global-treesit-auto-mode))
|
||||||
(dolist (lang treesit-language-source-alist)
|
|
||||||
(let ((mode (intern (format "%s-ts-mode" (car lang)))))
|
(use-package treesit
|
||||||
(when (fboundp mode)
|
:requires treesit
|
||||||
(add-to-list 'major-mode-remap-alist
|
:ensure nil
|
||||||
(cons (intern (car lang)) mode))))))
|
:config
|
||||||
|
(mapc #'exordium--add-forward-ts-hook
|
||||||
; Eglot setup
|
'(
|
||||||
(add-hook 'prog-mode-hook 'eglot-ensure)
|
LaTeX
|
||||||
|
bash
|
||||||
(evil-leader/set-key
|
c
|
||||||
"a" #'eglot-code-actions)
|
c++
|
||||||
|
cmake
|
||||||
;; Function to format the buffer using Eglot
|
csharp
|
||||||
(defun my/eglot-format-buffer-on-save ()
|
css
|
||||||
"Format the current buffer if Eglot is active."
|
go
|
||||||
(when (bound-and-true-p eglot--managed-p)
|
go-mod
|
||||||
(eglot-format-buffer)))
|
java
|
||||||
|
js
|
||||||
;; Add the function to the save-hook
|
json
|
||||||
(add-hook 'before-save-hook #'my/eglot-format-buffer-on-save)
|
markdown
|
||||||
|
python
|
||||||
; Flycheck
|
ruby
|
||||||
(use-package flycheck
|
rust
|
||||||
:ensure t
|
scala
|
||||||
:config
|
toml
|
||||||
(add-hook 'after-init-hook #'global-flycheck-mode))
|
typescript
|
||||||
|
yaml
|
||||||
; Sideline
|
))
|
||||||
(use-package sideline-flycheck
|
(setq treesit-font-lock-level 4))
|
||||||
:hook (flycheck-mode . sideline-mode)
|
|
||||||
:init (setq sideline-backends-right '(sideline-flycheck)
|
(use-package tree-sitter-langs)
|
||||||
sideline-delay 0.0))
|
(use-package tree-sitter
|
||||||
|
:diminish
|
||||||
(use-package sideline-flycheck
|
:after (tree-sitter-langs)
|
||||||
:hook (flycheck-mode . sideline-flycheck-setup)
|
:hook
|
||||||
:init (setq sideline-flycheck-display-mode 'line))
|
(tree-sitter-after-on . tree-sitter-hl-mode)
|
||||||
|
:custom
|
||||||
; Eglot
|
(font-lock-maximum-decoration t)
|
||||||
(use-package sideline-eglot
|
:config
|
||||||
:init
|
(when-let ((language-name (alist-get 'ruby-mode
|
||||||
(setq sideline-backends-right '(sideline-eglot)))
|
tree-sitter-major-mode-language-alist)))
|
||||||
|
(add-to-list 'tree-sitter-major-mode-language-alist
|
||||||
(use-package eglot :hook (eglot-mode . sideline-mode)) ; enable it when eglot is on
|
(cons 'enh-ruby-mode language-name)))
|
||||||
|
(add-to-list 'tree-sitter-major-mode-language-alist
|
||||||
; Centaur tabs
|
(cons 'forge-post-mode 'markdown))
|
||||||
(use-package centaur-tabs
|
(global-tree-sitter-mode))
|
||||||
:demand t
|
#+end_src
|
||||||
:config
|
|
||||||
(centaur-tabs-mode t)
|
** Eglot
|
||||||
(setq centaur-tabs-style "wave")
|
|
||||||
:bind
|
#+begin_src emacs-lisp
|
||||||
("C-<prior>" . centaur-tabs-backward)
|
(add-hook 'prog-mode-hook 'eglot-ensure)
|
||||||
("C-<next>" . centaur-tabs-forward))
|
|
||||||
|
(defun my/eglot-format-buffer-on-save ()
|
||||||
(use-package vterm-toggle :ensure t)
|
"Format the current buffer if Eglot is active."
|
||||||
(global-set-key [C-t] 'vterm-toggle)
|
(when (bound-and-true-p eglot--managed-p)
|
||||||
|
(eglot-format-buffer)))
|
||||||
|
|
||||||
|
(add-hook 'before-save-hook #'my/eglot-format-buffer-on-save)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Flycheck
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package flycheck
|
||||||
|
:ensure t
|
||||||
|
:config
|
||||||
|
(add-hook 'after-init-hook #'global-flycheck-mode))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** 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
|
||||||
|
:hook (flycheck-mode . sideline-flycheck-setup)
|
||||||
|
:init (setq sideline-flycheck-display-mode 'line))
|
||||||
|
|
||||||
|
(use-package sideline-eglot
|
||||||
|
:init
|
||||||
|
(setq sideline-backends-right '(sideline-eglot)))
|
||||||
|
|
||||||
|
(use-package eglot :hook (eglot-mode . sideline-mode))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** 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)
|
||||||
|
(setq centaur-tabs-style "wave")
|
||||||
|
:bind
|
||||||
|
("C-<prior>" . centaur-tabs-backward)
|
||||||
|
("C-<next>" . centaur-tabs-forward))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
Loading…
Reference in a new issue