dotfiles/.emacs

550 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)
(setq browse-url-browser-function 'eww-browse-url)
;; C-x SPC -- box select kode
(global-set-key [f10] 'toggle-frame-fullscreen)
(global-set-key (kbd "C-s") 'ripgrep-regexp)
(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 . ".\\(?:\\(?:[!(:={]\\|\\(?:#\\(?:##\\|#\\)\\|#\\)\\|\\?\\|\\[\\|\\(?:_(\\|_\\)\\)\\)") ;; #
(36 . ".\\(?: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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 exec-path-from-shell
:init
(exec-path-from-shell-initialize))
(use-package undo-tree
:config (global-undo-tree-mode 1)
:diminish undo-tree-mode)
(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-region-or-buffer))
(use-package format-all
:commands format-all-mode
:hook (prog-mode . format-all-mode)
:config
(setq-default format-all-formatters
'(("C" (astyle "--mode=c"))
("Shell" (shfmt "-i" "4" "-ci")))))
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init))
(use-package all-the-icons)
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook))
(use-package doom-themes
:ensure t
:config
(setq doom-themes-enable-bold t
doom-themes-enable-italic t)
(load-theme 'doom-monokai-classic t)
;; (load-theme 'mazarbul t)
(doom-themes-org-config))
(use-package solaire-mode
:config
(solaire-global-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)
(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 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 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
:config
(setq company-minimum-prefix-length 1
company-idle-delay 0.0))
(use-package company
:ensure t
:config (global-company-mode t))
(use-package ivy
:init (ivy-mode 1))
(use-package which-key
:ensure t
:config
(which-key-mode))
(use-package column-enforce-mode
:init
(global-column-enforce-mode))
(use-package magit
:ensure t
:bind (
("C-x g" . magit-status)))
(use-package magit-lfs
:ensure t
:pin melpa)
(use-package forge
:after magit)
(use-package git-gutter
:ensure t
:init (global-git-gutter-mode t))
(require 'display-line-numbers)
(defcustom display-line-numbers-exempt-modes
'(vterm-mode eshell-mode shell-mode term-mode ansi-term-mode)
"Major modes on which to disable line numbers."
:group 'display-line-numbers
:type 'list
:version "green")
;;(global-display-line-numbers-mode)
(use-package markdown-mode
:ensure t
:mode ("README\\.md\\'" . gfm-mode)
:init (setq markdown-command "multimarkdown"))
(use-package org-modern
:init
(global-org-modern-mode))
(use-package docker
:ensure t
:bind ("C-c d" . docker))
(use-package docker-compose-mode)
(use-package json-mode
:ensure t)
(use-package web-mode
:ensure t
:config
(setq web-mode-markup-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-css-indent-offset 2)
:mode (("\\.js\\'" . web-mode)
("\\.jsx\\'" . web-mode)
("\\.ts\\'" . web-mode)
("\\.tsx\\'" . web-mode)
("\\.html\\'" . web-mode))
:commands web-mode)
(modify-syntax-entry ?` "\"" js-mode-syntax-table)
(use-package prettier-js
:ensure t)
(add-hook 'web-mode-hook #'(lambda ()
(enable-minor-mode
'("\\.jsx?\\'" . prettier-js-mode))
(enable-minor-mode
'("\\.tsx?\\'" . prettier-js-mode))))
(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
: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 (
(elm-mode . lsp-deferred)
(go-mode . lsp-deferred)
(rust-mode . lsp-deferred)
(web-mode . lsp-deferred)
(lsp-mode . lsp-enable-which-key-integration)))
(use-package lsp-ui :commands lsp-ui-mode)
(use-package company-lsp :commands company-lsp)
(use-package lsp-treemacs :commands lsp-treemacs-errors-list)
(use-package verb)
(use-package sly
:ensure t
:config
(setq inferior-lisp-program "sbcl"))
(use-package vterm
:ensure 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.
'(custom-safe-themes
'("5409f053b500223bdcc4d4214986b4b57a55529b1e4659d6c48049751f1be43b" "f5f80dd6588e59cfc3ce2f11568ff8296717a938edd448a947f9823a4e282b66" "02d422e5b99f54bd4516d4157060b874d14552fe613ea7047c4a5cfa1288cf4f" "8d8207a39e18e2cc95ebddf62f841442d36fcba01a2a9451773d4ed30b632443" "be84a2e5c70f991051d4aaf0f049fa11c172e5d784727e0b525565bb1533ec78" default))
'(inhibit-startup-screen t))
;; Must be used *after* the theme is loaded
(custom-set-faces
;; electric buffer list
`(cm-electric-emacs-buffer-mode-face ((t (:foreground ,(doom-color 'violet)))))
`(cm-electric-c-buffer-mode-face ((t (:foreground ,(doom-color 'blue)))))
`(cm-electric-cm-dir-face ((t (:foreground ,(doom-color 'magenta)))))
`(cm-electric-custom-dir-face ((t (:foreground ,(doom-color 'orange)))))
`(cm-electric-emacs-face ((t (:inherit cm-electric-custom-dir-face))))
`(cm-electric-profile-dir-face ((t (:foreground ,(doom-color 'yellow)))))
`(cm-electric-buffer-mode-face ((t (:foreground ,(doom-color 'violet)))))
`(cm-electric-cet-dir-face ((t (:foreground ,(doom-color 'violet)))))
`(cm-electric-root-face ((t (:foreground ,(doom-color 'violet)))))
`(cm-electric-fundamental-face ((t (:foreground ,(doom-color 'violet)))))
`(cm-electric-rs-file-face ((t (:foreground ,(doom-color 'violet))))))