463 lines
17 KiB
EmacsLisp
463 lines
17 KiB
EmacsLisp
;;-*-coding: iso-latin-1-*-
|
||
;; Disable GC for the duration of init scripts
|
||
(let ((gc-cons-threshold most-positive-fixnum))
|
||
(global-auto-revert-mode t)
|
||
;;(w32-register-hot-key [C-])
|
||
(defconst user-init-dir
|
||
(cond ((boundp 'user-emacs-directory)
|
||
user-emacs-directory)
|
||
((boundp 'user-init-directory)
|
||
user-init-directory)
|
||
(t "~/.emacs.d/")))
|
||
|
||
(defun load-user-file (file)
|
||
(interactive "f")
|
||
"Load a file in current user's configuration directory"
|
||
(load-file (expand-file-name file user-init-dir)))
|
||
;; Lmao do the loading here
|
||
|
||
|
||
;; Eval buffer
|
||
(global-set-key (kbd "<f5>") #'eval-buffer)
|
||
|
||
;;; PACKAGE BOOTSTRAPPING ;;;
|
||
|
||
(require 'package)
|
||
(setq package-enable-at-startup nil)
|
||
(add-to-list 'package-archives
|
||
'("melpa" . "https://melpa.org/packages/"))
|
||
|
||
(package-initialize)
|
||
|
||
;; Bootstrap `use-package'
|
||
(unless (package-installed-p 'use-package)
|
||
(package-refresh-contents)
|
||
(package-install 'use-package))
|
||
|
||
(eval-when-compile
|
||
(require 'use-package))
|
||
|
||
(use-package ssh-agency
|
||
:ensure t)
|
||
|
||
(use-package benchmark-init
|
||
:ensure t
|
||
:config
|
||
;; To disable collection of benchmark data after init is done.
|
||
(add-hook 'after-init-hook 'benchmark-init/deactivate))
|
||
|
||
(use-package tangotango-theme
|
||
:ensure t
|
||
:config (load-theme 'tangotango t))
|
||
|
||
(use-package magit
|
||
:ensure t)
|
||
;;:init (setq magit-git-executable "C:/capybara/git/bin/git.exe"))
|
||
|
||
(use-package centered-cursor-mode
|
||
:ensure t)
|
||
|
||
(use-package projectile
|
||
:ensure t
|
||
:config (projectile-global-mode))
|
||
|
||
(use-package helm-projectile
|
||
:ensure t)
|
||
|
||
(use-package projectile-ripgrep
|
||
:ensure t)
|
||
|
||
(use-package sudo-edit
|
||
:ensure t)
|
||
|
||
(use-package treemacs
|
||
:ensure t
|
||
:defer t
|
||
:init
|
||
(with-eval-after-load 'winum
|
||
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
|
||
:config
|
||
(progn
|
||
(setq treemacs-collapse-dirs (if treemacs-python-executable 3 0)
|
||
treemacs-deferred-git-apply-delay 0.5
|
||
treemacs-directory-name-transformer #'identity
|
||
treemacs-display-in-side-window t
|
||
treemacs-eldoc-display 'simple
|
||
treemacs-file-event-delay 2000
|
||
treemacs-file-extension-regex treemacs-last-period-regex-value
|
||
treemacs-file-follow-delay 0.2
|
||
treemacs-file-name-transformer #'identity
|
||
treemacs-follow-after-init t
|
||
treemacs-expand-after-init t
|
||
treemacs-find-workspace-method 'find-for-file-or-pick-first
|
||
treemacs-git-command-pipe ""
|
||
treemacs-goto-tag-strategy 'refetch-index
|
||
treemacs-header-scroll-indicators '(nil . "^^^^^^")
|
||
treemacs-hide-dot-git-directory t
|
||
treemacs-indentation 2
|
||
treemacs-indentation-string " "
|
||
treemacs-is-never-other-window nil
|
||
treemacs-max-git-entries 5000
|
||
treemacs-missing-project-action 'ask
|
||
treemacs-move-files-by-mouse-dragging t
|
||
treemacs-move-forward-on-expand nil
|
||
treemacs-no-png-images nil
|
||
treemacs-no-delete-other-windows t
|
||
treemacs-project-follow-cleanup nil
|
||
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory)
|
||
treemacs-position 'left
|
||
treemacs-read-string-input 'from-child-frame
|
||
treemacs-recenter-distance 0.1
|
||
treemacs-recenter-after-file-follow nil
|
||
treemacs-recenter-after-tag-follow nil
|
||
treemacs-recenter-after-project-jump 'always
|
||
treemacs-recenter-after-project-expand 'on-distance
|
||
treemacs-litter-directories '("/node_modules" "/.venv" "/.cask")
|
||
treemacs-project-follow-into-home nil
|
||
treemacs-show-cursor nil
|
||
treemacs-show-hidden-files t
|
||
treemacs-silent-filewatch nil
|
||
treemacs-silent-refresh nil
|
||
treemacs-sorting 'alphabetic-asc
|
||
treemacs-select-when-already-in-treemacs 'move-back
|
||
treemacs-space-between-root-nodes t
|
||
treemacs-tag-follow-cleanup t
|
||
treemacs-tag-follow-delay 1.5
|
||
treemacs-text-scale nil
|
||
treemacs-user-mode-line-format nil
|
||
treemacs-user-header-line-format nil
|
||
treemacs-wide-toggle-width 70
|
||
treemacs-width 35
|
||
treemacs-width-increment 1
|
||
treemacs-width-is-initially-locked t
|
||
treemacs-workspace-switch-cleanup nil)
|
||
|
||
;; The default width and height of the icons is 22 pixels. If you are
|
||
;; using a Hi-DPI display, uncomment this to double the icon size.
|
||
;;(treemacs-resize-icons 44)
|
||
|
||
(treemacs-follow-mode t)
|
||
(treemacs-filewatch-mode t)
|
||
(treemacs-fringe-indicator-mode 'always)
|
||
(when treemacs-python-executable
|
||
(treemacs-git-commit-diff-mode t))
|
||
|
||
(pcase (cons (not (null (executable-find "git")))
|
||
(not (null treemacs-python-executable)))
|
||
(`(t . t)
|
||
(treemacs-git-mode 'deferred))
|
||
(`(t . _)
|
||
(treemacs-git-mode 'simple)))
|
||
|
||
(treemacs-hide-gitignored-files-mode nil))
|
||
:bind
|
||
(:map global-map
|
||
("M-0" . treemacs-select-window)
|
||
("C-x t 1" . treemacs-delete-other-windows)
|
||
("C-x t t" . treemacs)
|
||
("C-x t d" . treemacs-select-directory)
|
||
("C-x t B" . treemacs-bookmark)
|
||
("C-x t C-t" . treemacs-find-file)
|
||
("C-x t M-t" . treemacs-find-tag)))
|
||
|
||
;; (use-package treemacs-evil
|
||
;; :after (treemacs evil)
|
||
;; :ensure t)
|
||
|
||
(use-package treemacs-projectile
|
||
:after (treemacs projectile)
|
||
:ensure t)
|
||
|
||
(use-package treemacs-icons-dired
|
||
:hook (dired-mode . treemacs-icons-dired-enable-once)
|
||
:ensure t)
|
||
|
||
(use-package treemacs-magit
|
||
:after (treemacs magit)
|
||
:ensure t)
|
||
|
||
(use-package treemacs-persp ;;treemacs-perspective if you use perspective.el vs. persp-mode
|
||
:after (treemacs persp-mode) ;;or perspective vs. persp-mode
|
||
:ensure t
|
||
:config (treemacs-set-scope-type 'Perspectives))
|
||
|
||
(use-package treemacs-tab-bar ;;treemacs-tab-bar if you use tab-bar-mode
|
||
:after (treemacs)
|
||
:ensure t
|
||
:config (treemacs-set-scope-type 'Tabs))
|
||
|
||
(treemacs-start-on-boot)
|
||
|
||
;;; USER CONFIG ;;;
|
||
|
||
;;Remapping treemacs
|
||
(define-key treemacs-mode-map (kbd "C-j") nil)
|
||
(define-key treemacs-mode-map (kbd "C-k") nil)
|
||
(define-key treemacs-mode-map (kbd "C-;") 'treemacs-RET-action)
|
||
|
||
;;Using helm as minibuffer autocompletion manager
|
||
(setf projectile-completion-system 'helm)
|
||
(setf projectile-indexing-method 'alien)
|
||
|
||
;;Allowing per project compilation command
|
||
(setq projectile-per-project-compilation-buffer t)
|
||
|
||
;; Windows: Let git's UI ask for passphrase
|
||
;;(setenv "SSH_ASKPASS" "git-gui--askpass")
|
||
;;(require 'exec-path
|
||
;;(exec-path-from-shell
|
||
;;l-copy-env "SSH_AGENT_PID")
|
||
;;(exec-path-from-shell-copy-env "SSH_AUTH_SOCK")
|
||
|
||
;; Display line numbers ;;in prog files
|
||
;;(add-hook 'prog-mode-hook 'display-line-numbers-mode)
|
||
(add-hook 'after-init-hook 'global-display-line-numbers-mode t)
|
||
|
||
;; Disable backup files
|
||
(setq make-backup-files nil)
|
||
|
||
;; Disable window cruft
|
||
(menu-bar-mode -1)
|
||
|
||
;; Disable toolbar
|
||
(tool-bar-mode -1)
|
||
|
||
;; Disable scrollbar
|
||
(scroll-bar-mode -1)
|
||
|
||
;; Use better buffer list
|
||
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
||
|
||
;; Allow remember risky variable usage
|
||
(advice-add 'risky-local-variable-p :override #'ignore)
|
||
|
||
;; Skip windows when switching
|
||
(defvar ignore-windows-containing-buffers-matching-res '("Treemacs.*")
|
||
"List of regular expressions specifying windows to skip (if window contains buffer that matches, skip)")
|
||
|
||
(defadvice other-window (before other-window-ignore-windows-containing activate)
|
||
"skip over windows containing buffers which match regular expressions in 'ignore-windows-containing-buffers-matching-res"
|
||
(if (and (= 1 (ad-get-arg 0)) (interactive-p))
|
||
(let* ((win (next-window))
|
||
(bname (buffer-name (window-buffer win))))
|
||
(when (some 'identity (mapcar '(lambda (re)
|
||
(string-match re bname))
|
||
ignore-windows-containing-buffers-matching-res))
|
||
(ad-set-arg 0 2)))))
|
||
|
||
;; Disable splash screen and startup message
|
||
(setq inhibit-startup-message t)
|
||
(setq initial-scratch-message nil)
|
||
|
||
;; Use regex search toolsx
|
||
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
|
||
(global-set-key (kbd "C-r") 'isearch-backward-regexp)
|
||
|
||
;; On-home-row pointxx movement
|
||
(global-set-key (kbd "C-k") 'next-line)
|
||
(global-set-key (kbd "C-l") 'previous-line)
|
||
(global-set-key (kbd "C-;") 'forward-char)
|
||
(global-set-key (kbd "C-<2D>") 'forward-char)
|
||
(global-set-key (kbd "C-j") 'backward-char)
|
||
|
||
(global-set-key (kbd "C-f") 'forward-word)
|
||
(global-set-key (kbd "C-b") 'backward-word)
|
||
|
||
(global-set-key (kbd "C-S-d") (lambda () (interactive) (delete-char -1)))
|
||
|
||
(global-set-key (kbd "C-x C-u") (lambda () (interactive) (other-window -1)))
|
||
(global-set-key (kbd "C-x C-o") (lambda () (interactive) (other-window 1)))
|
||
(global-set-key (kbd "C-x u") 'dired-jump)
|
||
(global-set-key (kbd "C-x o") 'delete-blank-lines)
|
||
|
||
;; On-home-row cycling through buffers
|
||
(global-set-key (kbd "C-x C-j") 'previous-buffer)
|
||
(global-set-key (kbd "C-x C-<2D>") 'next-buffer)
|
||
(global-set-key (kbd "C-x C-;") 'next-buffer)
|
||
|
||
;; x(global-set-key (kbd "C-x C-<2D>") 'enlarge-window)
|
||
;;(global-set-key (kbd "C-x C-'") 'enlarge-window)
|
||
(global-set-key (kbd "C-c C-'") (lambda () (interactive) (enlarge-window 10)))
|
||
(global-set-key (kbd "C-c C-/") (lambda () (interactive) (enlarge-window -10)))
|
||
|
||
(global-set-key (kbd "C-z") 'kill-whole-line)
|
||
;;(global-set-key (kbd "C-x C-o") (lambda () (interactive) (other-window 1)))
|
||
;;(global-set-key (kbd "C-x u") 'dired-jump)
|
||
;;(global-set-key (kbd "C-x o") 'delete-blank-lines)
|
||
|
||
(global-set-key (kbd "C-n") 'undo)
|
||
(define-key input-decode-map [?\C-m] [C-m])
|
||
(global-set-key (kbd "<C-m>") 'undo-redo)
|
||
|
||
|
||
;;zap-to-char M-z, toggle-input-method C-\, transpose-chars C-t
|
||
(global-set-key (kbd "M-b") 'backward-char)
|
||
(global-set-key (kbd "M-f") 'forward-char)
|
||
|
||
(global-set-key (kbd "C-c C-SPC") 'string-insert-rectangle)
|
||
(global-set-key (kbd "C-x C-SPC") 'rectangle-mark-mode)
|
||
(global-set-key (kbd "C-x SPC") 'pop-global-mark)
|
||
|
||
(desktop-save-mode 1)
|
||
(setq desktop-restore-eager nil)
|
||
;;(setf desktop-restore-eager 5)
|
||
(delete-selection-mode 1)
|
||
|
||
;; C++
|
||
(add-hook 'c++-mode-hook (lambda ()
|
||
(setq-local comment-start "/*")
|
||
(setq-local comment-end "*/")
|
||
(setq-local comment-style 'extra-line)))
|
||
|
||
(global-set-key [f6] 'comment-region)
|
||
(global-set-key (kbd "M-i") (lambda () (interactive) (scroll-up 1)) )
|
||
(global-set-key (kbd "M-p") (lambda () (interactive) (scroll-down 1)) )
|
||
|
||
(global-set-key [f9] (lambda () (interactive) (find-file user-init-file)) )
|
||
|
||
(global-set-key [f8] 'projectile-find-file)
|
||
(global-set-key [f7] 'projectile-compile-project)
|
||
|
||
|
||
;; oddly specific buffer movement
|
||
|
||
(global-set-key (kbd "C-h u") 'info-apropos)
|
||
(global-set-key (kbd "C-,") (lambda () (interactive) (move-to-window-line -1)) )
|
||
(global-set-key (kbd "M-,") (lambda () (interactive) (move-to-window-line 0)) )
|
||
(global-set-key (kbd "C-.") 'end-of-buffer)
|
||
(global-set-key (kbd "M-.") 'beginning-of-buffer)
|
||
|
||
;; info-apropos mapping
|
||
(global-set-key (kbd "C-h u") 'info-apropos)
|
||
|
||
;;frame size control
|
||
(global-set-key (kbd "C-x C-c") 'toggle-frame-maximized)
|
||
|
||
;; (global-set-key (kbd "C-x C-<dead-acute>") 'enlarge-window)
|
||
;; Remapping save commit in Magit
|
||
(define-key with-editor-mode-map (kbd "C-c C-c") nil)
|
||
|
||
;;Tell grep-find and ripgrep-regexp to follow symlinks
|
||
(grep-apply-setting
|
||
'grep-find-command
|
||
'("find -L . -type f -exec grep --color=auto -nH --null -e \{\} +" . 58))
|
||
|
||
|
||
|
||
;;
|
||
(define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file)
|
||
(define-key dired-mode-map (kbd "a") 'dired-find-file)
|
||
(setq global-auto-revert-non-file-buffers t)
|
||
(add-hook 'dired-mode-hook (lambda () (setq-local auto-revert-verbose nil)) )
|
||
(add-hook 'ibuffer-mode-hook (lambda () (ibuffer-auto-mode t)))
|
||
|
||
(setq compilation-scroll-output t)
|
||
|
||
;;Don't ask for following symlinks (nil = treat as from where we're accessing)
|
||
|
||
(setq vc-follow-symlinks nil)
|
||
|
||
|
||
;; Copy config
|
||
(defun copy-region-or-word ()
|
||
"If mark is active, copy region. Otherwise, copy word currently on cursor"
|
||
(interactive)
|
||
(if mark-active
|
||
(if (bound-and-true-p rectangle-mark-mode)
|
||
(progn (copy-rectangle-as-kill (region-beginning) (region-end))
|
||
(kill-new (mapconcat 'identity (extract-rectangle (region-beginning) (region-end)) "\n")))
|
||
(kill-ring-save (region-beginning) (region-end)))
|
||
(let ((region (bounds-of-thing-at-point 'symbol)))
|
||
(copy-region-as-kill (car region) (cdr region)))))
|
||
|
||
;; Tabulation and Tree-sitter config
|
||
(add-to-list 'auto-mode-alist '("\\.cpp\\'" . c++-mode))
|
||
|
||
;; (setq major-mode-remap-alist
|
||
;; '(
|
||
;; ;; (c-mode . c-ts-mode)
|
||
;; (bash-mode . bash-ts-mode)
|
||
;; ;; (cpp-mode . c++-ts-mode)
|
||
;; (asm-mode . asm-ts-mode)
|
||
;; (cmake-mode . cmake-ts-mode)
|
||
;; (c-sharp-mode . c-sharp-mode)
|
||
;; ;; (css-mode . css-ts-mode)
|
||
;; (bash-mode . bash-ts-mode)
|
||
;; (dockerfile-mode . dockerfile-ts-mode)
|
||
;; (elisp-mode . elisp-ts-mode)
|
||
;; (elm-mode . elm-ts-mode)
|
||
;; (gitcommit-mode . gitcommit-ts-mode)
|
||
;; (gitignore-mode . gitignore-ts-mode)
|
||
;; (git-rebase-mode . git-rebase-ts-mode)
|
||
;; (json-mode . json-ts-mode)
|
||
;; (latex-mode . latex-ts-mode)
|
||
;; (lua-mode . lua-ts-mode)
|
||
;; (make-mode . make-ts-mode)
|
||
;; (sql-mode . sql-ts-mode)
|
||
;; (csv-mode . csv-ts-mode)))
|
||
|
||
;; (customize-set-variable 'treesit-font-lock-level 2)
|
||
|
||
;; Projectile custom project types
|
||
;; .NET C# or F# projects
|
||
(projectile-register-project-type 'xdg-desktop-portal-hyprland '("hyprland.portal")
|
||
;;:project-file '("?*.csproj" "?*.fsproj")
|
||
:compile "ls"
|
||
:run "dotnet run"
|
||
:test "dotnet test")
|
||
|
||
(setq-default indent-tabs-mode t)
|
||
(setq-default tab-width 4) ; Assuming you want your tabs to be four spaces wide
|
||
(global-set-key (kbd "C-/") 'tab-to-tab-stop)
|
||
(defvaralias 'c-basic-offset 'tab-width)
|
||
(defvaralias 'c-ts-mode-indent-offset 'tab-width)
|
||
(defvaralias 'c++-ts-mode-indent-offset 'tab-width)
|
||
|
||
;;Close compilation buffer
|
||
(global-set-key [f10] (lambda () (interactive) (kill-buffer "*compilation*")))
|
||
|
||
;;Common lisp
|
||
(load (expand-file-name "~/.quicklisp/slime-helper.el"))
|
||
(setq inferior-lisp-program "sbcl")
|
||
|
||
;; Change *scratch* to org-mode + fixes for extreme notetaking action
|
||
(setq initial-major-mode 'org-mode)
|
||
(setq org-startup-truncated nil)
|
||
(with-eval-after-load "org" (define-key org-mode-map (kbd "C-j") nil))
|
||
;;(define-key org-mode-map (kbd "C-j") nil)
|
||
;;
|
||
(custom-set-variables
|
||
;; custom-set-variables was added by Custom.
|
||
;; If you edit it by hand, you could mess it up, so be careful.
|
||
;; Your init file should contain only one such instance.
|
||
;; If there is more than one, they won't work right.
|
||
'(package-selected-packages
|
||
'(projectile-ripgrep helm-projectile projectile ssh-agency tangotango-theme)))
|
||
(custom-set-faces
|
||
;; custom-set-faces was added by Custom.
|
||
;; If you edit it by hand, you could mess it up, so be careful.
|
||
;; Your init file should contain only one such instance.
|
||
;; If there is more than one, they won't work right.
|
||
)
|
||
(put 'dired-find-alternate-file 'disabled nil)
|
||
)
|
||
(custom-set-variables
|
||
;; custom-set-variables was added by Custom.
|
||
;; If you edit it by hand, you could mess it up, so be careful.
|
||
;; Your init file should contain only one such instance.
|
||
;; If there is more than one, they won't work right.
|
||
'(package-selected-packages
|
||
'(treemacs-tab-bar treemacs-persp treemacs-magit treemacs-icons-dired treemacs-projectile treemacs-evil treemacs sudo-edit benchmark-init projectile-ripgrep ripgrep helm-projectile projectile ssh-agency tangotango-theme))
|
||
'(ripgrep-arguments '("--follow"))
|
||
'(safe-local-variable-values
|
||
'((projectile-project-compilation-cmd . "latexmk")
|
||
(compilation-read-command)
|
||
(compilation-read-command . t))))
|
||
(custom-set-faces
|
||
;; custom-set-faces was added by Custom.
|
||
;; If you edit it by hand, you could mess it up, so be careful.
|
||
;; Your init file should contain only one such instance.
|
||
;; If there is more than one, they won't work right.
|
||
)
|
||
|
||
(load "~/.emacs.d/roleplay.el")
|