summaryrefslogtreecommitdiff
path: root/emacs/init.el
diff options
context:
space:
mode:
authortmu <t.man.atl.2012@gmail.com>2023-04-07 09:50:30 -0700
committertmu <t.man.atl.2012@gmail.com>2023-04-07 09:50:30 -0700
commitc2235d1850722932b7fb9dcf5907bbcc040bb29c (patch)
treec6fbaaeb886ff0e5883545f6d495b82b8a4ec777 /emacs/init.el
parentc847e7677599d64838507787b75f8d3c9d988b78 (diff)
update
Diffstat (limited to 'emacs/init.el')
-rw-r--r--emacs/init.el322
1 files changed, 181 insertions, 141 deletions
diff --git a/emacs/init.el b/emacs/init.el
index 03fd126..c8955ab 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -5,29 +5,63 @@
;; 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.
+ '(comment-style 'extra-line)
'(custom-enabled-themes '(tmu-custom))
'(custom-safe-themes
- '("3d4e3644e237a95683daa73e397c4c0d1ae06bbaaf8040104232591a28bc1315" "12a07bc38295e4b06a8965db261f51ea7ea61fbf91b3ef41298bbb549d1d9403" default))
+ '("6dafb31ade9ff07229faaf05c41c2ae475c44731362b792f65f3930b1a2c9cfd" "dc77e008092a5a4aa6b6ed8e4826bebf8f2fb930a8de073bf7f458efd884cca8" "d1ff3e66028f9c527298580d2a64f9e3280f07f9e94d4dada72b67ef15069441" "3d4e3644e237a95683daa73e397c4c0d1ae06bbaaf8040104232591a28bc1315" "12a07bc38295e4b06a8965db261f51ea7ea61fbf91b3ef41298bbb549d1d9403" default))
+ '(ede-project-directories
+ '("/home/tmu/Desktop/eway/sway" "/home/tmu/Desktop/eway/cage" "/home/tmu/Desktop/eway/wlroots" "/home/tmu/Desktop/eway/comp" "/home/tmu/Desktop/eway"))
'(menu-bar-mode nil)
+ '(package-selected-packages
+ '(evil-snipe evil-surround markdown-preview-mode 2048-game evil ibuffer-project persp-mode-projectile-bridge persp-mode fish-mode spell-fu pyim chinese-conv esup buffer-move vertico flymake-diagnostic-at-point emms-state emms-player-simple-mpv eshell-fringe-status esh-help eshell-vterm vterm rustic benchmark-init ivy-prescient eat ivy-hydra ivy emms eyebrowse highlight dumb-jump volume workgroups async bongo hydra free-keys gxref fold-this simple-httpd xelb oauth2 imenu-anywhere popwin folding gdscript-mode))
'(scroll-bar-mode nil)
'(tool-bar-mode nil)
- '(transient-mark-mode nil))
-(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.
- )
+ '(transient-mark-mode nil)
+ '(whitespace-style
+ '(face trailing tabs lines-tail missing-newline-at-eof indentation space-after-tab space-before-tab tab-mark)))
+;; (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))
+
+(setq gc-cons-threshold most-positive-fixnum)
+
+(add-hook 'emacs-startup-hook
+ (lambda ()
+ (setq gc-cons-threshold (expt 2 23))))
+
+(require 'package)
+(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
+(package-initialize)
;; stuff I will always want
(electric-pair-mode 1)
(global-hl-line-mode 1)
-
-;; common hooks
-(add-hook 'text-mode-hook (lambda () (flyspell-mode 1)))
-(add-hook 'prog-mode-hook (lambda ()
- (hs-minor-mode 1)))
+(global-auto-revert-mode 1)
+
+;; spelling
+(require 'spell-fu)
+(setq ispell-personal-dictionary "/home/tmu/.aspell.en.pws")
+(add-hook 'text-mode-hook (lambda () (spell-fu-mode 1)))
+
+;; dictionaries
+(define-prefix-command 'dict-map)
+(global-set-key (kbd "M-l") 'dict-map)
+(define-keymap :full nil
+ :parent nil
+ :suppress nil
+ :keymap nil
+ :name "dict-map"
+ :prefix 'dict-map
+ (kbd "w") 'sdcv-search-input
+ (kbd "c") (lambda () (interactive)
+ (activate-input-method 'pyim)
+ (sdcv-search-input (read-from-minibuffer "Chinese Word: "
+ nil nil nil
+ nil nil t))
+ (activate-input-method nil)))
;; nice startup
(require 'iimage)
@@ -38,44 +72,34 @@
"))
(add-hook 'emacs-startup-hook (lambda ()
- (with-current-buffer "*scratch*"
- (iimage-mode 1))))
+ (with-current-buffer "*scratch*"
+ (iimage-mode 1))))
;; transparancy
-(add-to-list 'default-frame-alist '(alpha-background . 90)) ; For all new frames
+(add-to-list 'default-frame-alist '(alpha-background . 90)) ; For all new frames
(defun toggle-frame-transparency ()
"Toggle transparency."
(interactive)
(let ((alpha-transparency 90))
(if (eq alpha-transparency (frame-parameter nil 'alpha-background))
- (set-frame-parameter nil 'alpha-background 100)
+ (set-frame-parameter nil 'alpha-background 100)
(set-frame-parameter nil 'alpha-background alpha-transparency))))
-;; mode line stuff
-(require 'battery)
-(defun with-face (str &rest face-plist)
- (propertize str 'face face-plist))
-(defun make-mode-line-info-string ()
- "generates the mode line string that contains all the info to the right"
- (concat (format-time-string "%a, %b %+4Y-%0m-%0d ")
- (with-face (format-time-string "%R ")
- :weight 'bold)
- (with-face (format "<%03.2f> " (car (load-average 1)))
- :foreground "#da70d6")
- (with-face (let* ((mi (memory-info))
- (tm (float (car mi)))
- (fm (float (car (cdr mi))))
- (ts (float (car (cdr (cdr mi)))))
- (fs (float (car (cdr (cdr (cdr mi)))))))
- (format "{%.2f %.2f} " (- 1 (/ fm tm)) (- 1 (/ fs ts))))
- :foreground "#00ced1")
- (with-face (battery-format "[%b%p%%%%] " (and battery-status-function (funcall battery-status-function)))
- :weight 'bold)))
-(setq global-mode-string '("" (:eval (make-mode-line-info-string))))
-
;; custom func keybinds
-(global-unset-key (kbd "M-w"))
(global-set-key (kbd "M-w") 'copy-region-as-kill) ;;make copying not flash cursor
+(defun wrap-region-paren ()
+ "Wraps the region in parens.
+Similar to pressing ( with the region active."
+ (interactive)
+ (let ((beg (region-beginning))
+ (end (region-end)))
+ (save-excursion
+ (goto-char beg)
+ (insert "(")
+ (goto-char (+ end 1))
+ (insert ")")
+ )))
+(global-set-key (kbd "M-(") 'wrap-region-paren)
(defun zap-whitespace ()
"zaps the whitespace around the point in both directions"
(interactive)
@@ -87,53 +111,42 @@
(pop-mark)
(goto-char (mark))
(pop-mark))
-(global-unset-key (kbd "M-z"))
(global-set-key (kbd "M-z") 'zap-whitespace)
(defun wrap-sexp (&optional arg)
- "Wraps the following sexp in a pair of parens and places inside the new pair, with prefix arg do the same backwards, pushing the mark"
+ "Wraps the following sexp in a pair of parens.
+Places inside the new pair, with prefix arg do the same backwards, pushing the
+mark. Does the same of ARG number sexps if given"
(interactive "P")
(message "%s" arg)
(if arg
(progn
- (push-mark)
- (insert-pair -1 ?\( ?\)))
+ (push-mark)
+ (insert-pair -1 ?\( ?\)))
(insert-pair 1 ?\( ?\))))
(global-set-key (kbd "C-M-z") 'wrap-sexp)
;;move buffers between windows in a convient way
-(defun swap-buffer ()
- "Cycles the assignment of buffers to windows"
- (interactive)
- (cond ((one-window-p) (display-buffer (other-buffer)))
- ((let* ((buffer-a (current-buffer))
- (window-b (cadr (window-list)))
- (buffer-b (window-buffer window-b)))
- (set-window-buffer window-b buffer-a)
- (switch-to-buffer buffer-b)
- (other-window 1)))))
-;;replace shrink window
-(global-unset-key (kbd "C-x -"))
-(global-set-key (kbd "C-x -") 'swap-buffer)
+(require 'buffer-move)
+(global-set-key (kbd "C-x -") 'buf-move-right)
;; quick window switching
(global-set-key (kbd "M-o") 'other-window)
-(global-set-key (kbd "M-W") 'switch-to-buffer)
;; save/restore window config
(setq current-saved-layout ?0)
(seq-do (lambda (number)
- (let* ((string (int-to-string number))
- (char (string-to-char string))
- (key (kbd (concat "M-" string))))
- (global-unset-key key)
- (global-set-key key (lambda ()
- (interactive)
- (window-configuration-to-register current-saved-layout)
- (unless (window-configuration-p (car (get-register char)))
- (window-configuration-to-register char))
- (jump-to-register char)
- (setq current-saved-layout char)))))
- '(0 1 2 3 4 5 6 7 8 9))
+ (let* ((string (int-to-string number))
+ (char (string-to-char string))
+ (key (kbd (concat "M-" string))))
+ (global-unset-key key)
+ (global-set-key key (lambda ()
+ (interactive)
+ (window-configuration-to-register current-saved-layout)
+ (unless (window-configuration-p (car (get-register char)))
+ (window-configuration-to-register char))
+ (jump-to-register char)
+ (setq current-saved-layout char)))))
+ '(0 1 2 3 4 5 6 7 8 9))
;; get me a calculator
(global-unset-key (kbd "M-c"))
@@ -144,80 +157,82 @@
(global-set-key (kbd "M-k") 'kill-current-buffer)
(global-set-key (kbd "M-K") 'kill-buffer-and-window)
-;; compilation stuff
-(global-unset-key (kbd "M-m"))
-(global-unset-key (kbd "M-M"))
-(global-set-key (kbd "M-m") 'next-error)
-(global-set-key (kbd "M-M") 'recompile)
-
;; latex stuff
(require 'tex-mode)
(define-key latex-mode-map (kbd "C-c m") (lambda () (interactive)
- (insert "\\[\n\n\\]")
- (backward-char 3)))
-
-;; region folding
-(require 'fold-this)
-
-;; folding keybinds
-(defun fold-this-fold-forward (&optional arg)
- (interactive "p")
- (push-mark)
- (forward-sexp arg)
- (fold-this (mark) (point))
- (pop-mark))
-(defun fold-this-fold-backward (&optional arg)
- (interactive "p")
- (push-mark)
- (backward-sexp arg)
- (fold-this (point) (mark))
- (pop-mark))
-
-(define-prefix-command 'fold-map)
-(global-set-key (kbd "M-F") 'fold-map)
-
-(define-key fold-map (kbd "d") 'fold-this)
-;; (global-set-key (kbd "M-F d") 'fold-this)
-(define-key fold-map (kbd "e") 'fold-this-unfold-at-point)
-;; (global-set-key (kbd "M-F e") 'fold-this-unfold-at-point)
-(define-key fold-map (kbd "t") 'hs-toggle-hiding)
-;; (global-set-key (kbd "M-F t") 'hs-toggle-hiding)
-(define-key fold-map (kbd "f") 'fold-this-fold-forward)
-(define-key fold-map (kbd "b") 'fold-this-fold-backward)
+ (push-mark)
+ (insert "\\[\n\n\\]")
+ (indent-region (mark) (point))
+ (pop-mark)
+ (previous-line)
+ (indent-for-tab-command)
+ ))
+
+(add-hook 'tex-mode-hook (lambda ()
+ (setq-local compile-command
+ (concat "pdflatex " (shell-quote-argument (buffer-file-name))))
+ (add-hook 'after-save-hook 'recompile 0 t)))
;; better minibuffer complete
-(selectrum-mode 1)
-(savehist-mode)
-(setq selectrum-display-style '(horizontal))
-(setq selectrum-display-action '(display-buffer-in-side-window (side . bottom) (slot . -1)))
+(use-package vertico
+ :init
+ (vertico-mode)
+ (vertico-flat-mode)
+ (setq vertico-cycle t))
+
(use-package orderless
:ensure t
:custom
- (completion-styles '(orderless basic))
+ (completion-styles '(orderless partial-completion flex basic))
(orderless-matching-styles '(orderless-literal orderless-regexp orderless-prefixes))
- (orderless-skip-highlighting (lambda () selectrum-is-active))
- (selectrum-highlight-candidates-function #'orderless-highlight-matches))
+ ;; (orderless-skip-highlighting t)
+ ;; (selectrum-highlight-candidates-function #'orderless-highlight-matches)
+ )
;; better in-buffer completion
;; (require 'company)
;; (add-hook 'prog-mode-hook (lambda ()
-;; (company-mode 1)))
+;; (company-mode 1)))
;; (global-unset-key (kbd "M-/"))
;; (global-set-key (kbd "M-/") 'company-complete)
-;; exwm stuff
-;;(load "~/.emacs.d/exwm-pref.el")
-
;; mail stuff
-(load "~/.emacs.d/mail.el")
+(autoload 'mu4e "~/.emacs.d/mail.el" "mu4e stuff" t)
;; music
-(load "~/.emacs.d/bongo.el")
-(load "~/.emacs.d/youtube-dl.el")
-(load "~/.emacs.d/bongo-populate.el")
+;; (autoload 'youtube-dl-enqueue "~/.emacs.d/youtube-dl.el" "download from youtube" t)
+
+(emms-all)
+(require 'emms-info-native)
+(defun emms-file-info (track)
+ "Sets info of a track based on it's file name. Expects Artist - Album - Track.ext."
+ (when (emms-track-file-p track)
+ (let* ((file-name (emms-track-name track))
+ (tags (string-split (car (seq-reverse (string-split file-name "/"))) " - ")))
+ (emms-track-set track 'info-artist (car tags))
+ (emms-track-set track 'info-album (car (cdr tags)))
+ (emms-track-set track 'info-title (car (cdr (cdr tags)))))))
+
+(setq emms-player-list '(emms-player-mpv)
+ emms-info-functions '(emms-file-info)
+ emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find)
+
+(require 'emms-state)
+;; see single header, loaded AFTER this for more about emms-state
+
;; allow using emacsclient
-(server-start)
+(load "server")
+(unless (server-running-p) (server-start))
+
+;; mutli frame stuff
+(global-set-key (kbd "C-x C-C") 'save-buffers-kill-terminal)
+(global-set-key (kbd "C-x C-c") (lambda ()
+ (interactive)
+ (if (eq 1 (length (frame-list)))
+ ;; sole frame, exit
+ (save-buffers-kill-terminal)
+ (delete-frame))))
;; don't ask about killing buffers
(setq kill-buffer-query-functions (delq 'process-kill-buffer-query-function kill-buffer-query-functions))
@@ -225,29 +240,54 @@
;; don't ask about kill processes
(setq confirm-kill-processes nil)
-;; allow doing webpage startup
-(use-package edit-server
- :ensure t
- :commands edit-server-start
- :init (if after-init-time
- (edit-server-start)
- (add-hook 'after-init-hook
- #'(lambda() (edit-server-start))))
- :config (setq edit-server-new-frame-alist
- '((name . "Edit with Emacs FRAME")
- (top . 200)
- (left . 200)
- (width . 80)
- (height . 25)
- (minibuffer . t)
- (menu-bar-lines . t))))
-
-(load-file "~/.emacs.d/async-eval.el")
+(autoload 'async-eval "~/.emacs.d/async-eval.el" "evaluate in another emacs process" t)
(load-file "~/.emacs.d/project-stuff.el")
+(load-file "~/.emacs.d/single-header.el")
+
(put 'dired-find-alternate-file 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'list-timers 'disabled nil)
(put 'narrow-to-region 'disabled nil)
+;; no tabs
+(setq-default indent-tabs-mode nil)
+
+;; input method stuff
+(setq rime-translate-keybindings
+ '("C-f" "C-b" "C-n" "C-p" "C-g" "<left>" "<right>" "<up>" "<down>" "<prior>" "<next>" "<delete>"))
+(setq rime-share-data-dir "~/.local/share/fcitx5/rime")
+(setq rime-show-candidate 'popup)
+
+;; evil mode stuff
+(evil-mode 1)
+(define-key evil-motion-state-map (kbd "TAB") 'indent-for-tab-command)
+(setq evil-want-C-d-scroll nil
+ evil-want-C-w-delete nil
+ evil-disable-insert-state-bindings t)
+(use-package evil-surround
+ :ensure t
+ :config
+ (global-evil-surround-mode 1))
+(use-package evil-snipe
+ :ensure t
+ :config
+ (evil-snipe-mode +1)
+ (evil-snipe-override-mode +1)
+ (setq evil-snipe-scope 'buffer)
+ (evil-define-key 'visual evil-snipe-local-mode-map "z" 'evil-snipe-s)
+ (evil-define-key 'visual evil-snipe-local-mode-map "Z" 'evil-snipe-S))
+(define-key evil-insert-state-map (kbd "C-d") 'delete-char)
+(define-key evil-insert-state-map (kbd "C-e") 'move-end-of-line)
+(define-key evil-insert-state-map (kbd "C-a") 'move-beginning-of-line)
+(define-key evil-normal-state-map (kbd "M-.") 'xref-find-definitions)
+
+(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.
+ '(minibuffer-prompt ((t (:background "gray10" :foreground "cyan" :box nil :weight bold))))
+ '(vterm-color-blue ((t (:inherit ansi-color-bright-green)))))
+(put 'downcase-region 'disabled nil)