Compare commits
6 commits
679dc36038
...
1d4c5a3e1a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d4c5a3e1a | ||
|
|
4bba7122f3 | ||
|
|
ff386ad54e | ||
|
|
18a621528f | ||
|
|
8e7aa7505b | ||
|
|
5754dab06c |
4 changed files with 941 additions and 340 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -17,3 +17,5 @@
|
|||
/.lsp-session-v1
|
||||
/.dap-breakpoints
|
||||
/.cache/
|
||||
projectile-bookmarks.eld
|
||||
projectile.cache
|
||||
14
README.org
14
README.org
|
|
@ -1,12 +1,12 @@
|
|||
* LEARNING EMACS
|
||||
** DONE configure vertico
|
||||
** DONE configure projectile
|
||||
** TODO configure lsps for:
|
||||
- [ ] nix
|
||||
- [ ] go
|
||||
- [ ] python
|
||||
- [ ] bash
|
||||
*** TODO learn use lsp completion
|
||||
*** TODO learn to use compile
|
||||
** DONE configure lsps for:
|
||||
- [x] nix
|
||||
- [x] go
|
||||
- [x] python
|
||||
- [x] bash
|
||||
*** DONE learn use lsp completion
|
||||
*** DONE learn to use compile
|
||||
** DONE configure fzf.el
|
||||
** DONE go through the magit tutorial
|
||||
|
|
|
|||
921
config.org
Normal file
921
config.org
Normal file
|
|
@ -0,0 +1,921 @@
|
|||
#+TITLE: Emacs Configuration
|
||||
#+AUTHOR: nikolaishields
|
||||
#+PROPERTY: header-args:emacs-lisp :tangle yes
|
||||
#+STARTUP: overview
|
||||
|
||||
* Bootstrap
|
||||
This configuration needs to be loaded by =init.el=. Create an =init.el= with this content:
|
||||
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
;;; init.el --- Load org config -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
;;; Load literate config from config.org
|
||||
|
||||
;;; Code:
|
||||
(require 'org)
|
||||
(org-babel-load-file
|
||||
(expand-file-name
|
||||
"config.org"
|
||||
user-emacs-directory))
|
||||
|
||||
(provide 'init)
|
||||
;;; init.el ends here
|
||||
#+end_src
|
||||
|
||||
* Performance Optimization
|
||||
Early-init optimizations for faster Emacs startup.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq read-process-output-max (* 1024 1024)) ; 1mb
|
||||
|
||||
;; Faster startup
|
||||
(setq package-enable-at-startup nil)
|
||||
(setq site-run-file nil)
|
||||
#+end_src
|
||||
|
||||
** Garbage Collection
|
||||
The garbage collector in Emacs can significantly impact performance. We can optimize it in several ways:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Increase garbage collection threshold
|
||||
;; Default is 800 kilobytes
|
||||
(setq gc-cons-threshold 100000000) ; 100mb during initialization
|
||||
(setq gc-cons-percentage 0.6) ; Default is 0.1
|
||||
|
||||
;; Reset garbage collection after initialization
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(setq gc-cons-threshold 16777216 ; 16mb
|
||||
gc-cons-percentage 0.1)))
|
||||
|
||||
;; Collect garbage when Emacs is out of focus
|
||||
(add-function :after after-focus-change-function
|
||||
(lambda ()
|
||||
(unless (frame-focus-state)
|
||||
(garbage-collect))))
|
||||
#+end_src
|
||||
|
||||
** File Processing
|
||||
Optimize how Emacs handles file operations and processes:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Increase amount of data read from processes
|
||||
(setq read-process-output-max (* 1024 1024)) ; 1mb
|
||||
|
||||
;; File name handler optimization
|
||||
(defvar default-file-name-handler-alist file-name-handler-alist)
|
||||
(setq file-name-handler-alist nil) ; Remove handlers during startup
|
||||
|
||||
;; Restore file name handlers after initialization
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(setq file-name-handler-alist default-file-name-handler-alist)))
|
||||
#+end_src
|
||||
|
||||
** Startup Optimizations
|
||||
Disable unnecessary features during startup:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Faster startup
|
||||
(setq package-enable-at-startup nil) ; Don't load packages at startup
|
||||
(setq site-run-file nil) ; Don't load site-wide runtime config
|
||||
(setq frame-inhibit-implied-resize t) ; Don't resize frame during init
|
||||
|
||||
;; Disable UI elements early
|
||||
(push '(menu-bar-lines . 0) default-frame-alist)
|
||||
(push '(tool-bar-lines . 0) default-frame-alist)
|
||||
(push '(vertical-scroll-bars) default-frame-alist)
|
||||
|
||||
;; Disable bidirectional text scanning for small performance boost
|
||||
(setq-default bidi-paragraph-direction 'left-to-right)
|
||||
(setq bidi-inhibit-bpa t)
|
||||
#+end_src
|
||||
|
||||
** Font Performance
|
||||
Optimize font rendering:
|
||||
#+begin_src emacs-lisp
|
||||
;; Prevent font cache compaction during GC for potentially better performance
|
||||
;; at the cost of higher memory usage
|
||||
(setq inhibit-compacting-font-caches t)
|
||||
;; Font rendering optimization
|
||||
(setq use-default-font-for-symbols nil)
|
||||
(when (functionp 'harfbuzz-font)
|
||||
(setq harfbuzz-font t))
|
||||
|
||||
;; File operation optimization
|
||||
(setq find-file-visit-truename nil) ; Don't resolve symlinks
|
||||
(setq vc-follow-symlinks nil) ; Don't follow symlinks in version control
|
||||
#+end_src
|
||||
|
||||
** IO Performance
|
||||
Optimize file system operations:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Lock files (handle with care)
|
||||
(setq create-lockfiles nil) ; Disable lock files completely
|
||||
;; OR for more granular control:
|
||||
(setq lock-file-name-transforms ; Store lock files elsewhere
|
||||
`((".*" ,(concat user-emacs-directory "locks/") t)))
|
||||
|
||||
;; Backup settings (safer alternative to disabling)
|
||||
(setq backup-directory-alist ; Store backups in separate directory
|
||||
`(("." . ,(concat user-emacs-directory "backups"))))
|
||||
(setq backup-by-copying t) ; Always copy, don't rename
|
||||
(setq delete-old-versions t) ; Clean up old backups
|
||||
(setq kept-new-versions 6) ; Keep 6 newest versions
|
||||
(setq kept-old-versions 2) ; Keep 2 oldest versions
|
||||
|
||||
;; Auto-save optimization
|
||||
(setq auto-save-list-file-prefix nil) ; Disable auto-save list
|
||||
(setq auto-save-default t) ; Keep auto-save itself enabled
|
||||
(setq auto-save-interval 1000) ; Increase operations between auto-saves
|
||||
(setq auto-save-timeout 30) ; Increase idle time before auto-save
|
||||
|
||||
;; Local variables handling
|
||||
(setq enable-local-variables :safe) ; Only allow safe variables
|
||||
(setq enable-dir-local-variables nil) ; Disable directory locals
|
||||
(setq enable-local-eval nil) ; Disable local eval for security
|
||||
|
||||
;; Display and rendering
|
||||
(setq redisplay-skip-fontification-on-input t) ; Skip fontification during typing
|
||||
(setq fast-but-imprecise-scrolling t) ; Faster scrolling
|
||||
(setq jit-lock-defer-time 0.05) ; Tiny delay for better responsiveness
|
||||
|
||||
#+end_src
|
||||
** Monitoring Performance
|
||||
Tools to help monitor Emacs performance:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Profile emacs startup
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(message "*** Emacs loaded in %s with %d garbage collections."
|
||||
(format "%.2f seconds"
|
||||
(float-time
|
||||
(time-subtract after-init-time before-init-time)))
|
||||
gcs-done)))
|
||||
#+end_src
|
||||
|
||||
* Basic UI Configuration
|
||||
Remove unnecessary UI elements and set basic preferences.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Disable unnecessary UI elements
|
||||
(dolist (mode '(scroll-bar-mode
|
||||
tool-bar-mode
|
||||
tooltip-mode
|
||||
menu-bar-mode))
|
||||
(when (fboundp mode) (funcall mode -1)))
|
||||
|
||||
(set-fringe-mode 10)
|
||||
(winner-mode 1)
|
||||
|
||||
;; Basic settings
|
||||
(setq inhibit-startup-message t
|
||||
visible-bell nil
|
||||
ring-bell-function 'ignore
|
||||
use-dialog-box nil
|
||||
custom-file (locate-user-emacs-file "custom-vars.el"))
|
||||
|
||||
(load custom-file 'noerror 'nomessage)
|
||||
#+end_src
|
||||
|
||||
* Basic Settings
|
||||
** File Management
|
||||
Configure how Emacs handles file changes and buffer updates.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Auto-revert settings
|
||||
(global-auto-revert-mode 1) ; Auto-refresh buffers when files change
|
||||
(setq global-auto-revert-non-file-buffers t) ; Also auto-refresh dired and other buffers
|
||||
(setq auto-revert-verbose nil) ; Don't show message when reverting buffers
|
||||
#+end_src
|
||||
* Package Management
|
||||
Configure package archives and initialize use-package.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(require 'package)
|
||||
(setq package-archives
|
||||
'(("melpa" . "https://melpa.org/packages/")
|
||||
("org" . "https://orgmode.org/elpa/")
|
||||
("elpa" . "https://elpa.gnu.org/packages/")))
|
||||
|
||||
(package-initialize)
|
||||
|
||||
;; Bootstrap use-package
|
||||
(unless (package-installed-p 'use-package)
|
||||
(package-refresh-contents)
|
||||
(package-install 'use-package))
|
||||
|
||||
(require 'use-package)
|
||||
(setq use-package-always-ensure t)
|
||||
#+end_src
|
||||
|
||||
* Theme and Visual Settings
|
||||
Configure the visual appearance of Emacs.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Theme configuration
|
||||
(use-package catppuccin-theme)
|
||||
(use-package doom-modeline
|
||||
:init (doom-modeline-mode 1)
|
||||
:custom
|
||||
(doom-modeline-height 35)
|
||||
(nerd-icons-scale-factor 1.35)
|
||||
(doom-modeline-minor-modes-icon nil)
|
||||
(doom-modeline-major-modes-icon nil)
|
||||
(doom-modeline-icon t)
|
||||
(doom-modeline-time-live-icon t))
|
||||
|
||||
;; Load theme
|
||||
(setq modus-themes-mode-line '(accented borderless padded))
|
||||
(load-theme 'modus-vivendi t)
|
||||
|
||||
;; Font configuration
|
||||
(set-face-attribute 'default nil :font "FiraCode Nerd Font" :height 125)
|
||||
|
||||
;; Line numbers
|
||||
(column-number-mode)
|
||||
(global-display-line-numbers-mode t)
|
||||
(dolist (mode '(term-mode-hook
|
||||
vterm-mode-hook))
|
||||
(add-hook mode (lambda () (display-line-numbers-mode 0))))
|
||||
#+end_src
|
||||
|
||||
* Evil Mode Configuration
|
||||
Vim keybindings for Emacs.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package evil
|
||||
:init
|
||||
(setq evil-want-integration t
|
||||
evil-want-keybinding nil)
|
||||
:config
|
||||
(evil-mode 1))
|
||||
|
||||
(use-package evil-collection
|
||||
:after evil
|
||||
:config
|
||||
(evil-collection-init))
|
||||
|
||||
; Make ESC quit prompts
|
||||
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
|
||||
#+end_src
|
||||
|
||||
* Completion Framework
|
||||
Configure Vertico, Orderless, and Marginalia for enhanced completion.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package vertico
|
||||
:ensure t
|
||||
:bind (:map vertico-map
|
||||
("C-j" . vertico-next)
|
||||
("C-k" . vertico-previous)
|
||||
("C-f" . vertico-exit)
|
||||
:map minibuffer-local-map
|
||||
("M-h" . backward-kill-word))
|
||||
:custom
|
||||
(vertico-cycle t)
|
||||
:init
|
||||
(vertico-mode))
|
||||
|
||||
(use-package consult
|
||||
:ensure t)
|
||||
|
||||
(use-package orderless
|
||||
:custom
|
||||
(completion-styles '(orderless basic))
|
||||
(completion-category-overrides '((file (styles basic partial-completion)))))
|
||||
|
||||
(use-package marginalia
|
||||
:after vertico
|
||||
:custom
|
||||
(marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil))
|
||||
:init
|
||||
(marginalia-mode))
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
** Minibuffer History
|
||||
Preserve command, search, and input history between sessions.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package savehist
|
||||
:init
|
||||
(savehist-mode)
|
||||
:custom
|
||||
(savehist-file (expand-file-name "savehist" user-emacs-directory))
|
||||
(savehist-additional-variables '(search-ring ; Search history
|
||||
regexp-search-ring ; Regexp search history
|
||||
extended-command-history ; M-x history
|
||||
kill-ring ; Kill ring history
|
||||
compile-command ; Compilation commands
|
||||
log-edit-comment-ring)) ; VCS commit messages
|
||||
(savehist-autosave-interval 60) ; Save every minute
|
||||
(history-length 1000) ; Store more history
|
||||
(history-delete-duplicates t)) ; Remove duplicates
|
||||
#+end_src
|
||||
* Project Management
|
||||
Projectile configuration for project management.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package consult-projectile
|
||||
:ensure t)
|
||||
|
||||
(use-package projectile
|
||||
:diminish projectile-mode
|
||||
:bind
|
||||
("C-M-p" . projectile-find-file)
|
||||
:bind-keymap
|
||||
("C-c p" . projectile-command-map)
|
||||
:init
|
||||
(setq projectile-project-search-path '("~/Code/git.dwavesys.local/"
|
||||
"~/Code/nikolaishields/"
|
||||
"~/.emacs.d/"
|
||||
"/etc/nixos")
|
||||
projectile-auto-discover t
|
||||
projectile-enable-caching t
|
||||
projectile-indexing-method 'alien)
|
||||
:config
|
||||
(projectile-mode)
|
||||
(run-with-idle-timer 10 t #'projectile-discover-projects-in-search-path))
|
||||
#+end_src
|
||||
|
||||
** Project Layout Templates
|
||||
Configure automatic window and buffer layouts for projects.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Default layout configuration
|
||||
(defun default-project-layout ()
|
||||
"Set up the default window layout for any project.
|
||||
Creates a three-window layout:
|
||||
- Main editing window
|
||||
- Terminal (vterm)
|
||||
- Dired for file management"
|
||||
(delete-other-windows) ; Clear current layout
|
||||
(split-window-below) ; Create horizontal split
|
||||
(other-window 1) ; Move to new window
|
||||
(projectile-run-vterm) ; Start terminal
|
||||
(other-window 1) ; Move to next window
|
||||
(dired (projectile-project-root)) ; Open project root in dired
|
||||
(other-window -2)) ; Return to main window
|
||||
|
||||
;; Universal project setup
|
||||
(defun my-universal-project-setup ()
|
||||
"Set up project-specific layout and settings.
|
||||
Called automatically when switching projects."
|
||||
(default-project-layout))
|
||||
|
||||
;; Apply layout when switching projects
|
||||
(add-hook 'projectile-after-switch-project-hook 'my-universal-project-setup)
|
||||
#+end_src
|
||||
|
||||
** Additional Layout Templates
|
||||
Alternative layout templates for different project types.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun dev-project-layout ()
|
||||
"Development-focused project layout.
|
||||
Includes main editor, terminal, and test runner."
|
||||
(delete-other-windows)
|
||||
(split-window-right) ; Vertical split for code/tests
|
||||
(other-window 1)
|
||||
(split-window-below) ; Horizontal split for terminal
|
||||
(other-window 1)
|
||||
(projectile-run-vterm)
|
||||
(other-window -2))
|
||||
|
||||
(defun docs-project-layout ()
|
||||
"Documentation project layout.
|
||||
Includes editor, preview, and file browser."
|
||||
(delete-other-windows)
|
||||
(split-window-right) ; Vertical split for editing/preview
|
||||
(other-window 1)
|
||||
(split-window-below) ; Horizontal split for files
|
||||
(other-window 1)
|
||||
(dired (projectile-project-root))
|
||||
(other-window -2))
|
||||
|
||||
;; Project type specific setups
|
||||
(defun project-type-setup ()
|
||||
"Apply different layouts based on project type."
|
||||
(cond
|
||||
;; Documentation projects
|
||||
((file-exists-p (expand-file-name "docs" (projectile-project-root)))
|
||||
(docs-project-layout))
|
||||
;; Development projects
|
||||
((file-exists-p (expand-file-name "src" (projectile-project-root)))
|
||||
(dev-project-layout))
|
||||
;; Default for all other projects
|
||||
(t (default-project-layout))))
|
||||
|
||||
;; Optional: Replace universal setup with type-specific setup
|
||||
;; (add-hook 'projectile-after-switch-project-hook 'project-type-setup)
|
||||
#+end_src
|
||||
|
||||
** Layout Utilities
|
||||
Helper functions for managing project layouts.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun save-window-layout ()
|
||||
"Save current window layout for the project."
|
||||
(interactive)
|
||||
(window-configuration-to-register
|
||||
(intern (concat ":" (projectile-project-name)))))
|
||||
|
||||
(defun restore-window-layout ()
|
||||
"Restore saved window layout for the project."
|
||||
(interactive)
|
||||
(jump-to-register
|
||||
(intern (concat ":" (projectile-project-name)))))
|
||||
|
||||
;; Bind layout commands
|
||||
(define-key projectile-mode-map (kbd "C-c p L s") 'save-window-layout)
|
||||
(define-key projectile-mode-map (kbd "C-c p L r") 'restore-window-layout)
|
||||
#+end_src
|
||||
|
||||
** Project Compilation
|
||||
Configure project compilation settings and shortcuts.
|
||||
|
||||
*** Basic Compilation Setup
|
||||
Set up silent compilation and basic key bindings.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Silent compilation function
|
||||
(defun my-projectile-compile-project-silently ()
|
||||
"Compile the project using the preset command without prompting.
|
||||
Uses the project's default compilation command as specified in
|
||||
.dir-locals.el or projectile's default command for the project type."
|
||||
(interactive)
|
||||
(let ((compilation-read-command nil)) ;; Prevent prompt
|
||||
(projectile-compile-project nil)))
|
||||
|
||||
;; Bind to key
|
||||
(define-key projectile-mode-map (kbd "C-c m") 'my-projectile-compile-project-silently)
|
||||
#+end_src
|
||||
|
||||
*** Enhanced Compilation Features
|
||||
Additional compilation utilities and settings.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Compilation window settings
|
||||
(setq compilation-window-height 15) ; Set compilation window height
|
||||
(setq compilation-scroll-output t) ; Auto-scroll compilation buffer
|
||||
|
||||
;; Auto-close compilation window if successful
|
||||
(defun my-compilation-exit-function (status code msg)
|
||||
"Close the compilation window if compilation was successful."
|
||||
(when (and (eq status 'exit) (zerop code))
|
||||
(let ((window (get-buffer-window "*compilation*")))
|
||||
(when window
|
||||
(quit-window nil window)))))
|
||||
|
||||
(add-hook 'compilation-finish-functions #'my-compilation-exit-function)
|
||||
|
||||
;; Colorize compilation buffer
|
||||
(require 'ansi-color)
|
||||
(defun my-colorize-compilation-buffer ()
|
||||
"Colorize compilation buffer output."
|
||||
(let ((inhibit-read-only t))
|
||||
(ansi-color-apply-on-region compilation-filter-start (point))))
|
||||
|
||||
(add-hook 'compilation-filter-hook #'my-colorize-compilation-buffer)
|
||||
|
||||
;; Save all buffers before compiling
|
||||
(setq compilation-ask-about-save nil)
|
||||
(setq compilation-save-buffers-predicate 'save-some-buffers)
|
||||
#+end_src
|
||||
|
||||
*** Project-Specific Compilation
|
||||
Configure different compilation commands for different project types.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun my-project-compilation-command ()
|
||||
"Return the appropriate compilation command based on project type."
|
||||
(cond
|
||||
;; Make-based projects
|
||||
((file-exists-p (expand-file-name "Makefile" (projectile-project-root)))
|
||||
"make")
|
||||
;; Node.js projects
|
||||
((file-exists-p (expand-file-name "package.json" (projectile-project-root)))
|
||||
"npm run build")
|
||||
;; Python projects
|
||||
((file-exists-p (expand-file-name "setup.py" (projectile-project-root)))
|
||||
"python setup.py build")
|
||||
;; Default
|
||||
(t projectile-project-compilation-cmd)))
|
||||
|
||||
;; Function to compile with specific command
|
||||
(defun my-projectile-compile-with-command ()
|
||||
"Compile project with a specific command based on project type."
|
||||
(interactive)
|
||||
(let ((compilation-command (my-project-compilation-command)))
|
||||
(projectile-compile-project compilation-command)))
|
||||
|
||||
;; Bind alternative compilation command
|
||||
(define-key projectile-mode-map (kbd "C-c M") 'my-projectile-compile-with-command)
|
||||
#+end_src
|
||||
|
||||
*** Compilation Notifications
|
||||
Add desktop notifications for compilation results.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun my-compilation-notify (buffer msg)
|
||||
"Send a desktop notification when compilation is done."
|
||||
(if (string-match "^finished" msg)
|
||||
(notifications-notify
|
||||
:title "Compilation Finished"
|
||||
:body "Project compilation completed successfully!"
|
||||
:timeout 5000
|
||||
:urgency 'normal)
|
||||
(notifications-notify
|
||||
:title "Compilation Failed"
|
||||
:body "There were errors in compilation."
|
||||
:timeout 5000
|
||||
:urgency 'critical)))
|
||||
|
||||
(add-hook 'compilation-finish-functions #'my-compilation-notify)
|
||||
#+end_src
|
||||
* LSP Configuration
|
||||
Language Server Protocol setup for development.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package lsp-mode
|
||||
:init
|
||||
(setq lsp-keymap-prefix "C-c l")
|
||||
:hook
|
||||
((python-ts-mode . lsp-deferred)
|
||||
(go-ts-mode . lsp-deferred)
|
||||
(rust-ts-mode . lsp-deferred)
|
||||
(js-ts-mode . lsp-deferred)
|
||||
(typescript-ts-mode . lsp-deferred)
|
||||
(lsp-mode . lsp-enable-which-key-integration))
|
||||
:commands (lsp lsp-deferred)
|
||||
:custom
|
||||
(lsp-enable-symbol-highlighting t)
|
||||
(lsp-enable-indentation t)
|
||||
(lsp-enable-on-type-formatting t)
|
||||
(lsp-modeline-code-actions-enable t)
|
||||
(lsp-modeline-diagnostics-enable t)
|
||||
(lsp-completion-provider :capf)
|
||||
(lsp-idle-delay 0.500))
|
||||
|
||||
(use-package lsp-ui
|
||||
:hook (lsp-mode . lsp-ui-mode)
|
||||
:custom
|
||||
(lsp-ui-doc-enable t)
|
||||
(lsp-ui-doc-show-with-cursor t)
|
||||
(lsp-ui-doc-show-with-mouse nil)
|
||||
(lsp-ui-doc-position 'at-point)
|
||||
(lsp-ui-doc-delay 0.5)
|
||||
(lsp-ui-sideline-enable t)
|
||||
(lsp-ui-sideline-show-diagnostics t)
|
||||
(lsp-ui-sideline-show-hover t)
|
||||
(lsp-ui-sideline-show-code-actions t))
|
||||
#+end_src
|
||||
*** LSP Key Bindings
|
||||
Configure key bindings for common Language Server Protocol operations.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(with-eval-after-load 'lsp-mode
|
||||
;; Navigation
|
||||
(define-key lsp-mode-map (kbd "C-c l d") 'lsp-find-definition) ; Go to definition
|
||||
(define-key lsp-mode-map (kbd "C-c l r") 'lsp-find-references) ; Find references
|
||||
(define-key lsp-mode-map (kbd "C-c l s") 'lsp-find-implementation) ; Find implementations
|
||||
|
||||
;; Code actions and documentation
|
||||
(define-key lsp-mode-map (kbd "C-c l h") 'lsp-describe-thing-at-point) ; Show documentation
|
||||
(define-key lsp-mode-map (kbd "C-c l a") 'lsp-execute-code-action) ; Show available actions
|
||||
|
||||
;; Refactoring
|
||||
(define-key lsp-mode-map (kbd "C-c l R") 'lsp-rename) ; Rename symbol
|
||||
(define-key lsp-mode-map (kbd "C-c l f") 'lsp-format-buffer)) ; Format buffer
|
||||
#+end_src
|
||||
|
||||
**** Key Binding Quick Reference
|
||||
| Key | Command | Description |
|
||||
|-------------+--------------------------------+-------------------------------------------|
|
||||
| ~C-c l d~ | lsp-find-definition | Jump to definition of symbol at point |
|
||||
| ~C-c l r~ | lsp-find-references | Find all references to symbol |
|
||||
| ~C-c l s~ | lsp-find-implementation | Find implementations of interface/class |
|
||||
| ~C-c l h~ | lsp-describe-thing-at-point | Show documentation for symbol at point |
|
||||
| ~C-c l a~ | lsp-execute-code-action | Show and execute code actions |
|
||||
| ~C-c l R~ | lsp-rename | Rename symbol across project |
|
||||
| ~C-c l f~ | lsp-format-buffer | Format current buffer |
|
||||
|
||||
**** Additional Useful Bindings
|
||||
You might also want to add these common LSP operations:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(with-eval-after-load 'lsp-mode
|
||||
;; Workspace operations
|
||||
(define-key lsp-mode-map (kbd "C-c l w r") 'lsp-workspace-restart) ; Restart LSP server
|
||||
(define-key lsp-mode-map (kbd "C-c l w q") 'lsp-workspace-shutdown) ; Shutdown LSP server
|
||||
|
||||
;; Additional navigation
|
||||
(define-key lsp-mode-map (kbd "C-c l t") 'lsp-find-type-definition) ; Find type definition
|
||||
(define-key lsp-mode-map (kbd "C-c l g") 'lsp-find-declaration) ; Find declaration
|
||||
|
||||
;; Misc
|
||||
(define-key lsp-mode-map (kbd "C-c l i") 'lsp-organize-imports) ; Organize imports
|
||||
(define-key lsp-mode-map (kbd "C-c l l") 'lsp-lens-mode)) ; Toggle code lens
|
||||
#+end_src
|
||||
|
||||
**** IDE-like Key Bindings
|
||||
For those preferring more traditional IDE-like bindings:
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Optional: More familiar IDE-like bindings
|
||||
(with-eval-after-load 'lsp-mode
|
||||
;; Common IDE bindings (disabled by default - uncomment to use)
|
||||
;; (define-key lsp-mode-map (kbd "M-.") 'lsp-find-definition) ; Go to definition
|
||||
;; (define-key lsp-mode-map (kbd "M-?") 'lsp-find-references) ; Find references
|
||||
;; (define-key lsp-mode-map (kbd "M-RET") 'lsp-execute-code-action) ; Show code actions
|
||||
)
|
||||
#+end_src
|
||||
|
||||
* Development Tools
|
||||
Configure completion, snippets, and syntax checking.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package company
|
||||
:hook (lsp-mode . company-mode)
|
||||
:custom
|
||||
(company-minimum-prefix-length 1)
|
||||
(company-idle-delay 0.0))
|
||||
|
||||
(use-package company-box
|
||||
:hook (company-mode . company-box-mode))
|
||||
|
||||
(use-package yasnippet
|
||||
:config
|
||||
(yas-global-mode 1))
|
||||
|
||||
(use-package yasnippet-snippets
|
||||
:after yasnippet)
|
||||
|
||||
(use-package flycheck
|
||||
:init
|
||||
(global-flycheck-mode))
|
||||
(use-package which-key
|
||||
:init
|
||||
(which-key-mode)
|
||||
:diminish which-key-mode
|
||||
:custom
|
||||
(which-key-idle-delay 0.2)
|
||||
(which-key-popup-type 'side-window)
|
||||
(which-key-side-window-location 'bottom)
|
||||
(which-key-sort-order 'which-key-key-order)
|
||||
:config
|
||||
;; Make sure this is a proper alist
|
||||
(setq which-key-replacement-alist
|
||||
'(((nil . "prefix") . ("" . "prefix")) ;; Correct format
|
||||
((nil . "left") . ("" . "←"))
|
||||
((nil . "right") . ("" . "→")))))
|
||||
|
||||
;; Command Log Mode for debugging/demonstrations
|
||||
(use-package command-log-mode
|
||||
:commands command-log-mode)
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: t
|
||||
* Org Mode Configuration
|
||||
Configure Org Mode and Org Roam for note-taking and task management.
|
||||
|
||||
** Basic Org Settings
|
||||
Set up fundamental Org mode configurations.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Task management
|
||||
(setq org-todo-keywords
|
||||
'((sequence "TODO" "IN-PROGRESS" "BLOCKED" "DONE")))
|
||||
|
||||
;; Tags configuration
|
||||
(setq org-tag-alist '(("work") ("garage")))
|
||||
|
||||
;; Agenda configuration
|
||||
(setq org-agenda-files '("~/Documents/notes/daily/"))
|
||||
#+end_src
|
||||
|
||||
** Org Roam
|
||||
Configure Org Roam for note-taking and personal knowledge management.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package org-roam
|
||||
:ensure t
|
||||
:custom
|
||||
;; Set up directories
|
||||
(org-roam-directory (file-truename "~/Documents/notes"))
|
||||
(org-roam-dailies-directory (file-truename "~/Documents/notes/daily"))
|
||||
(org-roam-completion-everywhere t)
|
||||
|
||||
;; Configure daily note templates
|
||||
(org-roam-dailies-capture-templates
|
||||
'(("d" "default" entry "* %<%I:%M %p>: %?"
|
||||
:if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n"))))
|
||||
|
||||
:bind
|
||||
;; Main Org Roam bindings
|
||||
(("C-c n l" . org-roam-buffer-toggle)
|
||||
("C-c n f" . org-roam-node-find)
|
||||
("C-c n i" . org-roam-node-insert)
|
||||
|
||||
;; Org mode specific bindings
|
||||
:map org-mode-map
|
||||
("C-M-i" . completion-at-point)
|
||||
|
||||
;; Dailies bindings
|
||||
:map org-roam-dailies-map
|
||||
("Y" . org-roam-dailies-capture-yesterday)
|
||||
("T" . org-roam-dailies-capture-tomorrow))
|
||||
|
||||
:bind-keymap
|
||||
("C-c n d" . org-roam-dailies-map)
|
||||
|
||||
:config
|
||||
;; Load dailies module
|
||||
(require 'org-roam-dailies)
|
||||
|
||||
;; Enable auto-sync
|
||||
(org-roam-db-autosync-mode))
|
||||
|
||||
;; Ensure auto-sync is enabled globally
|
||||
(org-roam-db-autosync-mode)
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: t
|
||||
|
||||
** Utility Functions
|
||||
Custom functions to enhance Org Roam functionality.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun org-roam-node-insert-immediate (arg &rest args)
|
||||
"Insert a node immediately without the capture process.
|
||||
ARG and ARGS are passed to `org-roam-node-insert'."
|
||||
(interactive "P")
|
||||
(let ((args (cons arg args))
|
||||
(org-roam-capture-templates (list (append (car org-roam-capture-templates)
|
||||
'(:immediate-finish t)))))
|
||||
(apply #'org-roam-node-insert args)))
|
||||
|
||||
;; Bind the immediate insert function
|
||||
(global-set-key (kbd "C-c n I") #'org-roam-node-insert-immediate)
|
||||
#+end_src
|
||||
|
||||
** Additional Org Settings
|
||||
Optional but useful Org mode configurations.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; Visual settings
|
||||
(setq org-hide-emphasis-markers t) ; Hide markup symbols
|
||||
(setq org-pretty-entities t) ; Show UTF8 characters
|
||||
|
||||
;; Behavior settings
|
||||
(setq org-return-follows-link t) ; Return follows links
|
||||
(setq org-startup-folded 'show2levels) ; Start with some levels shown
|
||||
|
||||
;; Capture templates
|
||||
(setq org-capture-templates
|
||||
'(("t" "Todo" entry (file+headline "~/Documents/notes/tasks.org" "Tasks")
|
||||
"* TODO %?\n %i\n %a")
|
||||
("n" "Note" entry (file+datetree "~/Documents/notes/notes.org")
|
||||
"* %?\nEntered on %U\n %i\n %a")))
|
||||
#+end_src
|
||||
|
||||
* Version Control
|
||||
Magit configuration for Git integration.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package magit
|
||||
:bind ("C-M-;" . magit-status)
|
||||
:commands (magit-status magit-get-current-branch)
|
||||
:custom
|
||||
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
|
||||
|
||||
(use-package magit-todos
|
||||
:after magit
|
||||
:config
|
||||
(magit-todos-mode 1))
|
||||
#+end_src
|
||||
|
||||
* Terminal Support
|
||||
Configure VTerm for terminal emulation.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package vterm
|
||||
:commands vterm
|
||||
:custom
|
||||
(term-prompt-regexp "^[^#$%>\n]*[#$%>] *")
|
||||
(vterm-max-scrollback 10000))
|
||||
|
||||
(use-package multi-vterm
|
||||
:after vterm
|
||||
:config
|
||||
(add-hook 'vterm-mode-hook
|
||||
(lambda ()
|
||||
(setq-local evil-insert-state-cursor 'box)
|
||||
(evil-insert-state))))
|
||||
|
||||
(use-package multi-vterm :ensure t)
|
||||
(use-package multi-vterm
|
||||
:ensure t
|
||||
:config
|
||||
(add-hook 'vterm-mode-hook
|
||||
(lambda ()
|
||||
(setq-local evil-insert-state-cursor 'box)
|
||||
(evil-insert-state)))
|
||||
(define-key vterm-mode-map [return] #'vterm-send-return)
|
||||
(setq vterm-keymap-exceptions nil)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-e") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-f") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-a") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-v") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-b") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-w") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-u") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-d") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-n") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-m") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-p") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-j") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-k") #'Vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-r") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-t") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-g") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-c") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-SPC") #'vterm--self-insert)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd "C-d") #'vterm--self-insert)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd ",c") #'multi-vterm)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd ",n") #'multi-vterm-next)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd ",p") #'multi-vterm-prev)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd "i") #'evil-insert-resume)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd "o") #'evil-insert-resume)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd "<return>") #'evil-insert-resume))
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: t
|
||||
|
||||
* Tree-sitter Configuration
|
||||
Modern syntax highlighting and parsing.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package treesit-auto
|
||||
:ensure t
|
||||
:config
|
||||
(global-treesit-auto-mode))
|
||||
|
||||
(setq treesit-language-source-alist
|
||||
'((bash "https://github.com/tree-sitter/tree-sitter-bash")
|
||||
(cmake "https://github.com/uyha/tree-sitter-cmake")
|
||||
(css "https://github.com/tree-sitter/tree-sitter-css")
|
||||
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
|
||||
(go "https://github.com/tree-sitter/tree-sitter-go")
|
||||
(html "https://github.com/tree-sitter/tree-sitter-html")
|
||||
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
|
||||
(json "https://github.com/tree-sitter/tree-sitter-json")
|
||||
(python "https://github.com/tree-sitter/tree-sitter-python")
|
||||
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
|
||||
(yaml "https://github.com/ikatyang/tree-sitter-yaml")))
|
||||
|
||||
;; Install tree-sitter languages
|
||||
(defun efs/install-treesit-language (lang)
|
||||
"Install tree-sitter grammar for LANG if it's not already installed."
|
||||
(unless (treesit-language-available-p lang)
|
||||
(treesit-install-language-grammar lang)))
|
||||
|
||||
(dolist (lang '(bash cmake css elisp go html javascript json python typescript yaml))
|
||||
(efs/install-treesit-language lang))
|
||||
|
||||
;; Remap major modes to tree-sitter versions
|
||||
(setq major-mode-remap-alist
|
||||
'((python-mode . python-ts-mode)
|
||||
(javascript-mode . js-ts-mode)
|
||||
(js-mode . js-ts-mode)
|
||||
(typescript-mode . typescript-ts-mode)
|
||||
(json-mode . json-ts-mode)
|
||||
(css-mode . css-ts-mode)
|
||||
(yaml-mode . yaml-ts-mode)
|
||||
(bash-mode . bash-ts-mode)
|
||||
(go-mode . go-ts-mode)))
|
||||
#+end_src
|
||||
|
||||
* Latex
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(with-eval-after-load 'ox-latex
|
||||
;; Add the `mimore` LaTeX class
|
||||
(add-to-list 'org-latex-classes
|
||||
'("mimore"
|
||||
"\\documentclass{mimore}
|
||||
[NO-DEFAULT-PACKAGES]
|
||||
[PACKAGES]
|
||||
[EXTRA]"
|
||||
("\\section{%s}" . "\\section*{%s}")
|
||||
("\\subsection{%s}" . "\\subsection*{%s}")
|
||||
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|
||||
("\\paragraph{%s}" . "\\paragraph*{%s}")
|
||||
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
|
||||
#+end_src
|
||||
344
init.el
344
init.el
|
|
@ -1,335 +1,13 @@
|
|||
(scroll-bar-mode -1)
|
||||
(tool-bar-mode -1)
|
||||
(tooltip-mode -1)
|
||||
(set-fringe-mode 10)
|
||||
(menu-bar-mode -1)
|
||||
(winner-mode 1)
|
||||
;;; init.el --- Load org config -*- lexical-binding: t -*-
|
||||
;;; Commentary:
|
||||
;;; Load literate config from config.org
|
||||
|
||||
(setq inhibit-startup-message t)
|
||||
(setq visible-bell nil)
|
||||
(setq ring-bell-function 'ignore)
|
||||
(setq auto-save-timeout '2)
|
||||
(setq auto-save-interval '2)
|
||||
(setq global-auto-revert-non-file-buffers t)
|
||||
(setq custom-file (locate-user-emacs-file "custom-vars.el"))
|
||||
(load custom-file 'noerror 'nomessage)
|
||||
;;; Code:
|
||||
(require 'org)
|
||||
(org-babel-load-file
|
||||
(expand-file-name
|
||||
"config.org"
|
||||
user-emacs-directory))
|
||||
|
||||
(setq use-dialog-box nil)
|
||||
(global-auto-revert-mode 1)
|
||||
(setq global-auto-rever-non-file-buffers t)
|
||||
|
||||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
||||
(require 'package)
|
||||
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
|
||||
("org" . "https://orgmode.org/elpa/")
|
||||
("elpa" . "https://elpa.gnu.org/packages/")))
|
||||
(package-initialize)
|
||||
(package-refresh-contents)
|
||||
|
||||
;; Initialize use-package on non-linux platforms
|
||||
(unless (package-installed-p 'use-package)
|
||||
(package-install 'use-package))
|
||||
|
||||
(require 'use-package)
|
||||
(setq use-package-always-ensure t)
|
||||
(use-package catppuccin-theme)
|
||||
(use-package doom-modeline
|
||||
:ensure t
|
||||
:init (doom-modeline-mode 1)
|
||||
:custom (doom-modeline-height 35)
|
||||
(nerd-icons-scale-factor 1.35)
|
||||
(doom-modeline-minor-modes-icon nil)
|
||||
(doom-modeline-major-modes-icon nil)
|
||||
(doom-modeline-icon t)
|
||||
(doom-modeline-time-live-icon t))
|
||||
(use-package command-log-mode)
|
||||
|
||||
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
|
||||
|
||||
(setq modus-themes-mode-line '(accented borderless padded))
|
||||
(load-theme 'modus-vivendi t)
|
||||
|
||||
(column-number-mode)
|
||||
(global-display-line-numbers-mode t)
|
||||
(dolist (mode '(term-mode-hook
|
||||
vterm-mode-hook))
|
||||
(add-hook mode (lambda () (display-line-numbers-mode 0))))
|
||||
|
||||
(use-package which-key
|
||||
:init (which-key-mode)
|
||||
:diminish which-key-mode
|
||||
:config
|
||||
(setq which-key-idle-delay 0))
|
||||
|
||||
(set-face-attribute 'default nil :font "FiraCode Nerd Font" :height 125)
|
||||
|
||||
(use-package kagi
|
||||
:ensure t
|
||||
:custom
|
||||
;; Univernal Summarizer settings
|
||||
(kagi-summarizer-engine "cecil")
|
||||
(kagi-summarizer-default-language "EN")
|
||||
(kagi-summarizer-cache t))
|
||||
|
||||
(use-package vterm
|
||||
:commands vterm
|
||||
:config
|
||||
(setq term-prompt-regexp "^[^#$%>\n]*[#$%>] *")
|
||||
(setq vterm-max-scrollback 10000))
|
||||
|
||||
(setq org-todo-keywords
|
||||
'((sequence "TODO" "IN-PROGRESS" "BLOCKED" "DONE")))
|
||||
|
||||
(setq org-tag-alist '(("work") ("garage")))
|
||||
|
||||
(setq wl-copy-process nil)
|
||||
(defun wl-copy (text)
|
||||
(setq wl-copy-process (make-process :name "wl-copy"
|
||||
:buffer nil
|
||||
:command '("wl-copy" "-f" "-n")
|
||||
:connection-type 'pipe
|
||||
:noquery t))
|
||||
(process-send-string wl-copy-process text)
|
||||
(process-send-eof wl-copy-process))
|
||||
(defun wl-paste ()
|
||||
(if (and wl-copy-process (process-live-p wl-copy-process))
|
||||
nil ; should return nil if we're the current paste owner
|
||||
(shell-command-to-string "wl-paste -n | tr -d \r")))
|
||||
(setq interprogram-cut-function 'wl-copy)
|
||||
(setq interprogram-paste-function 'wl-paste)
|
||||
|
||||
;; Enable Evil
|
||||
(use-package evil
|
||||
:ensure t
|
||||
:init
|
||||
(setq evil-want-integration t)
|
||||
(setq evil-want-keybinding nil)
|
||||
:config
|
||||
(evil-mode 1))
|
||||
|
||||
(use-package evil-collection
|
||||
:after evil
|
||||
:ensure t
|
||||
:config
|
||||
(evil-collection-init))
|
||||
|
||||
;; org
|
||||
(use-package org-roam
|
||||
:ensure t
|
||||
:custom
|
||||
(org-roam-directory (file-truename "~/Documents/notes"))
|
||||
(org-roam-dailies-directory (file-truename "~/Documents/notes/daily"))
|
||||
(org-roam-completion-everywhere t)
|
||||
(org-roam-dailies-capture-templates
|
||||
'(("d" "default" entry "* %<%I:%M %p>: %?"
|
||||
:if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n"))))
|
||||
:bind (("C-c n l" . org-roam-buffer-toggle)
|
||||
("C-c n f" . org-roam-node-find)
|
||||
("C-c n i" . org-roam-node-insert)
|
||||
:map org-mode-map
|
||||
("C-M-i" . completion-at-point)
|
||||
:map org-roam-dailies-map
|
||||
("Y" . org-roam-dailies-capture-yesterday)
|
||||
("T" . org-roam-dailies-capture-tomorrow))
|
||||
:bind-keymap
|
||||
("C-c n d" . org-roam-dailies-map)
|
||||
:config
|
||||
(require 'org-roam-dailies) ;; Ensure the keymap is available
|
||||
(org-roam-db-autosync-mode))
|
||||
|
||||
(org-roam-db-autosync-mode)
|
||||
;; Bind this to C-c n I
|
||||
(defun org-roam-node-insert-immediate (arg &rest args)
|
||||
(interactive "P")
|
||||
(let ((args (cons arg args))
|
||||
(org-roam-capture-templates (list (append (car org-roam-capture-templates)
|
||||
'(:immediate-finish t)))))
|
||||
(apply #'org-roam-node-insert args)))
|
||||
|
||||
(setq org-agenda-files '("~/Documents/notes/daily/"))
|
||||
(save-place-mode 1)
|
||||
|
||||
;; vertico
|
||||
(unless (package-installed-p 'vertico)
|
||||
(package-install 'vertico))
|
||||
|
||||
(use-package vertico
|
||||
:ensure t
|
||||
:bind (:map vertico-map
|
||||
("C-j" . vertico-next)
|
||||
("C-k" . vertico-previous)
|
||||
("C-f" . vertico-exit)
|
||||
:map minibuffer-local-map
|
||||
("M-h" . backward-kill-word))
|
||||
:custom
|
||||
(vertico-cycle t)
|
||||
:init
|
||||
(vertico-mode))
|
||||
|
||||
(use-package savehist
|
||||
:init
|
||||
(savehist-mode))
|
||||
|
||||
(use-package marginalia
|
||||
:after vertico
|
||||
:ensure t
|
||||
:custom
|
||||
(marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil))
|
||||
:init
|
||||
(marginalia-mode))
|
||||
|
||||
;; lsp
|
||||
(use-package lsp-mode
|
||||
:ensure t)
|
||||
|
||||
(use-package lsp-nix
|
||||
:ensure lsp-mode
|
||||
:after (lsp-mode)
|
||||
:demand t
|
||||
:custom
|
||||
(lsp-nix-nil-formatter ["nixpkgs-fmt"]))
|
||||
|
||||
(use-package nix-mode
|
||||
:hook (nix-mode . lsp-deferred)
|
||||
:ensure t)
|
||||
;; optionally
|
||||
(use-package lsp-ui
|
||||
:commands lsp-ui-mode
|
||||
:config
|
||||
(setq lsp-ui-doc-enable t)
|
||||
(setq lsp-ui-doc-header t)
|
||||
(setq lsp-ui-doc-include-signature t)
|
||||
(setq lsp-ui-doc-border (face-foreground 'default))
|
||||
(setq lsp-ui-sideline-show-code-actions t)
|
||||
(setq lsp-ui-sideline-delay 0.05))
|
||||
;; optionally if you want to use debugger
|
||||
(use-package dap-mode)
|
||||
|
||||
;; optional if you want which-key integration
|
||||
(use-package which-key
|
||||
:config
|
||||
(which-key-mode))
|
||||
|
||||
(use-package magit
|
||||
:bind ("C-M-;" . magit-status)
|
||||
:commands (magit-status magit-get-current-branch)
|
||||
:custom
|
||||
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
|
||||
|
||||
(use-package magit-todos
|
||||
:defer t)
|
||||
|
||||
(use-package consult
|
||||
:ensure t)
|
||||
|
||||
(use-package consult-projectile
|
||||
:ensure t)
|
||||
|
||||
(defun dw/switch-project-action ()
|
||||
"Switch to a workspace with the project name and start `magit-status'."
|
||||
(persp-switch (projectile-project-name))
|
||||
(magit-status))
|
||||
|
||||
(defun default-project-layout ()
|
||||
"Set up the default window layout for any project."
|
||||
(delete-other-windows) ; Close all other windows
|
||||
(split-window-below) ; Split the window horizontally
|
||||
(other-window 1) ; Move to the new window
|
||||
(projectile-run-vterm) ; Move to the new window
|
||||
(other-window 1) ; Move to the new window
|
||||
(dired (projectile-project-root)) ; Open Dired in the new window
|
||||
(other-window -2)) ; Move back to the second window
|
||||
(defun my-universal-project-setup ()
|
||||
"Set up the project-specific layout and settings for any project."
|
||||
(default-project-layout))
|
||||
|
||||
(add-hook 'projectile-after-switch-project-hook 'my-universal-project-setup)
|
||||
(use-package projectile
|
||||
:diminish projectile-mode
|
||||
:config (projectile-mode)
|
||||
:demand t
|
||||
:bind ("C-M-p" . projectile-find-file)
|
||||
:bind-keymap
|
||||
("C-c p" . projectile-command-map)
|
||||
:init
|
||||
(setq projectile-project-search-path '("~/Code/git.dwavesys.com/" "~/.emacs.d/" "/etc/nixos" ))
|
||||
(setq projectile-auto-discover t))
|
||||
|
||||
|
||||
|
||||
(global-set-key (kbd "M-n") #'other-window)
|
||||
|
||||
;; emacs-land leader-key
|
||||
(define-prefix-command '*my-leader*)
|
||||
(global-set-key (kbd "C-t") *my-leader*)
|
||||
|
||||
;; example:
|
||||
(define-key *my-leader* (kbd "C-b") #'previous-buffer)
|
||||
|
||||
(use-package multi-vterm :ensure t)
|
||||
(use-package multi-vterm
|
||||
:ensure t
|
||||
:config
|
||||
(add-hook 'vterm-mode-hook
|
||||
(lambda ()
|
||||
(setq-local evil-insert-state-cursor 'box)
|
||||
(evil-insert-state)))
|
||||
(define-key vterm-mode-map [return] #'vterm-send-return)
|
||||
(setq vterm-keymap-exceptions nil)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-e") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-f") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-a") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-v") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-b") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-w") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-u") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-d") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-n") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-m") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-p") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-j") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-k") #'Vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-r") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-t") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-g") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-c") #'vterm--self-insert)
|
||||
(evil-define-key 'insert vterm-mode-map (kbd "C-SPC") #'vterm--self-insert)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd "C-d") #'vterm--self-insert)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd ",c") #'multi-vterm)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd ",n") #'multi-vterm-next)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd ",p") #'multi-vterm-prev)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd "i") #'evil-insert-resume)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd "o") #'evil-insert-resume)
|
||||
(evil-define-key 'normal vterm-mode-map (kbd "<return>") #'evil-insert-resume))
|
||||
|
||||
(use-package orderless
|
||||
:ensure t
|
||||
:custom
|
||||
(completion-styles '(orderless basic))
|
||||
(completion-category-overrides '((file (styles basic partial-completion)))))
|
||||
|
||||
(setq treesit-language-source-alist
|
||||
'((bash "https://github.com/tree-sitter/tree-sitter-bash")
|
||||
(cmake "https://github.com/uyha/tree-sitter-cmake")
|
||||
(css "https://github.com/tree-sitter/tree-sitter-css")
|
||||
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
|
||||
(go "https://github.com/tree-sitter/tree-sitter-go")
|
||||
(html "https://github.com/tree-sitter/tree-sitter-html")
|
||||
(javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
|
||||
(json "https://github.com/tree-sitter/tree-sitter-json")
|
||||
(make "https://github.com/alemuller/tree-sitter-make")
|
||||
(markdown "https://github.com/ikatyang/tree-sitter-markdown")
|
||||
(python "https://github.com/tree-sitter/tree-sitter-python")
|
||||
(toml "https://github.com/tree-sitter/tree-sitter-toml")
|
||||
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")
|
||||
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
|
||||
(docker "https://github.com/camdencheek/tree-sitter-dockerfile")
|
||||
(yaml "https://github.com/ikatyang/tree-sitter-yaml")))
|
||||
|
||||
(defun my-projectile-compile-project-silently ()
|
||||
"Compile the project using the preset command without prompting."
|
||||
(interactive)
|
||||
(let ((compilation-read-command nil)) ;; Prevent prompt
|
||||
(projectile-compile-project nil)))
|
||||
|
||||
(define-key projectile-mode-map (kbd "C-c m") 'my-projectile-compile-project-silently)
|
||||
(provide 'init)
|
||||
;;; init.el ends here
|
||||
|
|
|
|||
Loading…
Reference in a new issue