dotfiles/.emacs

564 lines
21 KiB
Plaintext
Executable File

;;------------------------------------------------------------------------------
;; ᚳᚻᚪᚱᛚᛖᛋ ᛣᚱᚪᛚᚪᛈᛈ ᛖᛗᚪᚳᛋ ᛋᛖᛏᛏᛁᛝᛋ
;; * Зонгор * ᛣᚩᛝᚩᚱ *
;;------------------------------------------------------------------------------
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
;; install packages automatically if not already present on your
;; system to be global for all packages
(require 'use-package-ensure)
(setq use-package-always-ensure t)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
(global-set-key [f11] 'toggle-frame-fullscreen)
(global-set-key (kbd "C-s") 'ripgrep-regexp)
(global-set-key (kbd "C-,") 'move-to-previous-window)
(global-set-key (kbd "C-.") 'move-to-next-window)
(global-set-key (kbd "M-i") 'xref-find-definitions)
(global-set-key (kbd "C-M-i") 'xref-pop-marker-stack)
;; Auto-insert braces. Has some counter-intuitive behaviour, unfortunately.
(electric-pair-mode 1)
(setf electric-pair-skip-self nil)
(set-frame-font "Fira Code 11")
;; setup fira code font ligatures
(let ((alist '((33 . ".\\(?:\\(?:\\(?:!\\.\\|!\\)\\|\\(?:==\\|=\\)\\)\\)") ;; !
(35 . ".\\(?:\\(?:[!(:={]\\|\\(?:#\\(?:##\\|#\\)\\|#\\)\\|\\?\\|\\[\\|\\(?:_(\\|_\\)\\)\\)") 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; ?
(70 . ".\\(?:l\\)") ;; F
(84 . ".\\(?:l\\)") ;; T
(91 . ".\\(?:\\(?::]\\||\\)\\)") ;; [
(92 . ".\\(?:/\\)") ;; \
(93 . ".\\(?:#\\)") ;; ]
(94 . ".\\(?:=\\)") ;; ^
(95 . ".\\(?:\\(?:_\\||_\\)\\)") ;; _
(102 . ".\\(?:l\\)") ;; f
(119 . ".\\(?:ww\\)") ;; w
(123 . ".\\(?:|\\)") ;; {
(124 . ".\\(?:\\(?:[>}]\\|\\(?:->\\|-\\)\\|\\(?:=>\\|=\\)\\|]\\|\\(?:|\\(?:[=>]\\|-\\||>\\)\\||\\)\\)\\)") ;; |
(126 . ".\\(?:\\(?:[=>@]\\|-\\|\\(?:~>\\|~\\)\\)\\)"))))
(dolist (char-regexp alist)
(set-char-table-range composition-function-table (car char-regexp)
`([,(cdr char-regexp) 0 font-shape-gstring]))))
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(show-paren-mode 1)
(blink-cursor-mode 0)
(set-cursor-color "#ffffff")
(defun move-to-previous-window ()
"Move to previous window."
(interactive)
(if (= (count-windows) 1)
(other-frame 1)
(select-window (previous-window))))
(defun move-to-next-window ()
"Move to next window."
(interactive)
(if (= (count-windows) 1)
(other-frame 1)
(select-window (next-window))))
(defun comment-eclipse ()
(interactive)
(let ((start (line-beginning-position))
(end (line-end-position)))
(when (or (not transient-mark-mode) (region-active-p))
(setq start (save-excursion
(goto-char (region-beginning))
(beginning-of-line)
(point))
end (save-excursion
(goto-char (region-end))
(end-of-line)
(point))))
(comment-or-uncomment-region start end)))
(use-package evil
:ensure t
:init
(setq evil-want-keybinding nil)
(setq evil-want-integration t) ;; This is optional since it's already set to t by default.
:config
(evil-mode 1)
;; :q should kill the current buffer rather than quitting emacs entirely
(evil-ex-define-cmd "q" 'kill-this-buffer)
;; Need to type out :quit to close emacs
(evil-ex-define-cmd "quit" 'evil-quit)
(define-key evil-normal-state-map (kbd "C-\\") 'comment-eclipse)
(define-key evil-normal-state-map (kbd "u") 'undo-tree-undo)
(define-key evil-normal-state-map (kbd "q") 'undo-tree-redo)
(define-key evil-normal-state-map (kbd "w") 'evil-backward-word-begin)
(define-key evil-normal-state-map (kbd "H") 'evil-first-non-blank)
(define-key evil-normal-state-map (kbd "L") 'evil-end-of-line)
(define-key evil-normal-state-map (kbd "K") 'backward-paragraph)
(define-key evil-normal-state-map (kbd "J") 'forward-paragraph)
(define-key evil-normal-state-map (kbd "C-x l") 'list-buffers)
(define-key evil-normal-state-map (kbd "C-M-u") 'eval-buffer)
(define-key evil-normal-state-map (kbd "C-M-p") 'compile)
(define-key evil-normal-state-map (kbd "M-/") 'dabbrev-expand)
(define-key evil-normal-state-map (kbd "C-,") 'move-to-previous-window)
(define-key evil-normal-state-map (kbd "C-.") 'move-to-next-window)
(define-key evil-normal-state-map (kbd "C-M-\\") 'format-all-buffer)
;; (evil-define-key 'normal Buffer-menu-mode-map (kbd "RET") )
(evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter)
(evil-define-key 'normal neotree-mode-map (kbd "SPC") 'neotree-quick-look)
(evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide)
(evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter)
(evil-define-key 'normal neotree-mode-map (kbd "g") 'neotree-refresh)
(evil-define-key 'normal neotree-mode-map (kbd "n") 'neotree-next-line)
(evil-define-key 'normal neotree-mode-map (kbd "p") 'neotree-previous-line)
(evil-define-key 'normal neotree-mode-map (kbd "A") 'neotree-stretch-toggle)
(evil-define-key 'normal neotree-mode-map (kbd "H") 'neotree-hidden-file-toggle))
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init))
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook))
(use-package doom-themes
:ensure t
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-monokai-classic t)
;; Enable custom neotree theme (all-the-icons must be installed!)
(doom-themes-neotree-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
(use-package solaire-mode
:config
(solaire-global-mode +1))
(use-package all-the-icons
:if (display-graphic-p))
(use-package nerd-icons)
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1))
(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-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 nil)
(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))
(use-package centaur-tabs
:init
(setq centaur-tabs-enable-key-bindings t)
:config
(setq centaur-tabs-style "bar"
centaur-tabs-height 32
centaur-tabs-set-icons t
centaur-tabs-show-new-tab-button t
centaur-tabs-set-modified-marker t
centaur-tabs-show-navigation-buttons t
centaur-tabs-set-bar 'under
centaur-tabs-show-count nil
;; centaur-tabs-label-fixed-length 15
;; centaur-tabs-gray-out-icons 'buffer
;; centaur-tabs-plain-icons t
x-underline-at-descent-line t
centaur-tabs-left-edge-margin nil)
(centaur-tabs-change-fonts (face-attribute 'default :font) 110)
(centaur-tabs-headline-match)
;; (centaur-tabs-enable-buffer-alphabetical-reordering)
;; (setq centaur-tabs-adjust-buffer-order t)
(centaur-tabs-mode t)
(setq uniquify-separator "/")
(setq uniquify-buffer-name-style 'forward)
(defun centaur-tabs-buffer-groups ()
"`centaur-tabs-buffer-groups' control buffers' group rules.
Group centaur-tabs with mode if buffer is derived from `eshell-mode' `emacs-lisp-mode' `dired-mode' `org-mode' `magit-mode'.
All buffer name start with * will group to \"Emacs\".
Other buffer group by `centaur-tabs-get-group-name' with project name."
(list
(cond
;; ((not (eq (file-remote-p (buffer-file-name)) nil))
;; "Remote")
((or (string-equal "*" (substring (buffer-name) 0 1))
(memq major-mode '(magit-process-mode
magit-status-mode
magit-diff-mode
magit-log-mode
magit-file-mode
magit-blob-mode
magit-blame-mode
)))
"Emacs")
((derived-mode-p 'prog-mode)
"Editing")
((derived-mode-p 'dired-mode)
"Dired")
((memq major-mode '(helpful-mode
help-mode))
"Help")
((memq major-mode '(org-mode
org-agenda-clockreport-mode
org-src-mode
org-agenda-mode
org-beamer-mode
org-indent-mode
org-bullets-mode
org-cdlatex-mode
org-agenda-log-mode
diary-mode))
"OrgMode")
(t
(centaur-tabs-get-group-name (current-buffer))))))
:hook
(dashboard-mode . centaur-tabs-local-mode)
(term-mode . centaur-tabs-local-mode)
(calendar-mode . centaur-tabs-local-mode)
(org-agenda-mode . centaur-tabs-local-mode)
:bind
("C-<prior>" . centaur-tabs-backward)
("C-<next>" . centaur-tabs-forward)
("C-S-<prior>" . centaur-tabs-move-current-tab-to-left)
("C-S-<next>" . centaur-tabs-move-current-tab-to-right)
(:map evil-normal-state-map
("g t" . centaur-tabs-forward)
("g T" . centaur-tabs-backward)))
(use-package undo-tree
:config (global-undo-tree-mode 1)
:diminish undo-tree-mode)
(use-package format-all
:hook ((format-all-mode-hook . format-all-ensure-formatter)))
(use-package rainbow-delimiters
:hook ((prog-mode-hook . rainbow-delimiters-mode)))
(use-package dumb-jump
:hook ((xref-backend-functions . dumb-jump-xref-activate)))
(use-package elfeed
:config
(global-set-key (kbd "C-x w") 'elfeed)
(setq elfeed-feeds
'(("https://programming.dev/feeds/c/rust.xml?sort=Active" programming)
("https://programming.dev/feeds/c/gamedev.xml?sort=Active" programming)
("https://hexbear.net/feeds/c/programming.xml?sort=Active" programming)
("https://programming.dev/feeds/c/golang.xml?sort=Active" programming)
("https://programming.dev/feeds/c/programming.xml?sort=Active" programming)
("https://xkcd.com/atom.xml" webcomic)
("https://www.existentialcomics.com/rss.xml" webcomic)
("https://hackaday.com/blog/feed/" hack)
("https://itsfoss.com/feed/" linux)
("https://lemmy.ml/feeds/c/linux.xml?sort=Active" linux os)
("https://lemmy.ml/feeds/c/raspberrypi.xml?sort=Active" os)
("http://git.9front.org/plan9front/plan9front/HEAD/feed.rss" os plan9)
("https://lemmy.ml/feeds/c/opensource.xml?sort=Active" os)
("https://lemmy.ml/feeds/c/linux_gaming.xml?sort=Active" games linux)
("https://steamcommunity.com/groups/GrabFreeGames/rss/" games)
("https://hexbear.net/feeds/c/news.xml?sort=Active" news)
("https://feeds.npr.org/1001/rss.xml" news)
("https://www.scmp.com/rss/91/feed" news)
("https://www.currentaffairs.org/feed" news)
("https://itsgoingdown.org/feed" news)
("http://feeds.ancientfaith.com/AmonSul" podcast)
("https://feeds.transistor.fm/the-magnificast" podcast)
("https://anchor.fm/s/c38df04/podcast/rss" podcast)
("https://yogpod.libsyn.com/rss" podcast)
("https://revolutionspodcast.libsyn.com/rss" podcast)
("https://feeds.acast.com/public/shows/5e7b777ba085cbe7192b0607" podcast)
("https://www.omnycontent.com/d/playlist/aaea4e69-af51-495e-afc9-a9760146922b/48da3539-5da0-41ed-a1c3-aac50170b88f/f7810480-e2d3-4be5-a559-aac50170b8a6/podcast.rss" podcast)
("https://feeds.soundcloud.com/users/soundcloud:users:672423809/sounds.rss" podcast)
("https://www.omnycontent.com/d/playlist/aaea4e69-af51-495e-afc9-a9760146922b/4a3ca742-9a68-4850-a727-ab790176c0e9/d04153b0-fc4c-4191-ab18-ab790179c563/podcast.rss" podcast)
("https://feeds.soundcloud.com/users/soundcloud:users:211911700/sounds.rss" podcast)
("https://access.acast.com/rss/5fd1001d81367d4cb41fe325/Q6BVQ6VF" podcast)
("https://feeds.npr.org/344098539/podcast.xml" podcast))))
(use-package projectile
:ensure t
:init
(projectile-mode +1)
:bind (:map projectile-mode-map
("s-p" . projectile-command-map)
("C-c p" . projectile-command-map)))
(use-package ivy
:init (ivy-mode 1))
(use-package org-modern
:config
(setq
;; Edit settings
org-auto-align-tags nil
org-tags-column 0
org-catch-invisible-edits 'show-and-error
org-special-ctrl-a/e t
org-insert-heading-respect-content t
;; Org styling, hide markup etc.
org-hide-emphasis-markers t
org-pretty-entities t
org-ellipsis "…"
;; Agenda styling
org-agenda-tags-column 0
org-agenda-block-separator ?─
org-agenda-time-grid
'((daily today require-timed)
(800 1000 1200 1400 1600 1800 2000)
" ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")
org-agenda-current-time-string
"◀── now ─────────────────────────────────────────────────")
:init
(add-hook 'org-mode-hook #'org-modern-mode)
(add-hook 'org-mode-hook (lambda ()
(setq buffer-face-mode-face '(:family "Fira Code" :height 100))
(buffer-face-mode)))
(add-hook 'org-agenda-finalize-hook #'org-modern-agenda))
(use-package restclient)
(use-package markdown-mode
:ensure t
:mode ("README\\.md\\'" . gfm-mode)
:init (setq markdown-command "multimarkdown"))
(use-package docker
:ensure t
:bind ("C-c d" . docker))
(use-package docker-compose-mode)
(use-package web-mode
:config
(add-to-list 'auto-mode-alist '("\\.jsx?$" . web-mode))
(setq web-mode-content-types-alist '(("jsx" . "\\.js[x]?\\'"))))
(use-package typescript-mode)
(use-package tide
:ensure t
:after (typescript-mode company flycheck)
:hook ((typescript-mode . tide-setup)
(typescript-mode . tide-hl-identifier-mode)
(before-save . tide-format-before-save)))
(use-package uxntal-mode)
(use-package hy-mode)
(use-package lua-mode)
(use-package elm-mode)
(use-package go-mode)
(use-package rust-mode)
(use-package cargo)
(use-package ccls
:ensure t
:init (setq ccls-executable "/usr/bin/ccls")
:hook ((c-mode c++-mode objc-mode cuda-mode) .
(lambda () (require 'ccls) (lsp))))
(use-package lsp-mode
:commands (lsp lsp-deferred)
:init
(setq lsp-keymap-prefix "C-c l")
:hook
((go-mode) . lsp)
((rust-mode) . lsp))
(use-package lsp-ui
:hook (lsp-mode . lsp-ui-mode)
:config
(setq lsp-ui-doc-enable t))
(use-package sly
:ensure t
:config
(setq inferior-lisp-program "sbcl"))
(use-package vterm
:ensure t)
(use-package dash)
(use-package column-enforce-mode)
(use-package desktop)
(use-package magit)
(use-package magit-lfs
:ensure t
:pin melpa)
(use-package forge
:after magit)
(use-package ripgrep)
(use-package git-gutter
:ensure t
:init (global-git-gutter-mode t))
(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.
'(inhibit-startup-screen t)
'(neo-theme 'icons))
(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.
)