diff options
Diffstat (limited to '.emacs.d')
| -rw-r--r-- | .emacs.d/config.el | 74 | ||||
| -rw-r--r-- | .emacs.d/dracula-custom-theme.el | 52 | ||||
| -rw-r--r-- | .emacs.d/functions.el | 49 | ||||
| -rw-r--r-- | .emacs.d/init.el | 14 | ||||
| -rw-r--r-- | .emacs.d/keybinds.el | 14 | ||||
| -rw-r--r-- | .emacs.d/packages.el | 330 |
6 files changed, 533 insertions, 0 deletions
diff --git a/.emacs.d/config.el b/.emacs.d/config.el new file mode 100644 index 0000000..5e57a07 --- /dev/null +++ b/.emacs.d/config.el @@ -0,0 +1,74 @@ +(add-hook 'text-mode-hook 'display-line-numbers-mode) +(add-hook 'prog-mode-hook 'display-line-numbers-mode) +(add-hook 'emacs-startup-hook 'startup/revert-file-name-handler-alist) +(add-hook 'emacs-startup-hook 'startup/reset-gc) + +(show-paren-mode 1) +(tool-bar-mode -1) +(menu-bar-mode -1) +(scroll-bar-mode -1) +(global-prettify-symbols-mode t) +(electric-pair-mode t) +(global-hl-line-mode t) +(recentf-mode 1) +(savehist-mode 1) +(global-auto-revert-mode 1) + +(set-frame-parameter (selected-frame) 'alpha '(80 . 80)) +(add-to-list 'default-frame-alist '(alpha .(80 . 80))) + +(defvar startup/file-name-handler-alist file-name-handler-alist) + +(defalias 'open 'find-file-other-window) +(defalias 'clean 'eshell/clear-scrollback) +(defalias 'yes-or-no-p 'y-or-n-p) + +;; Make emacs startup faster +(setq gc-cons-threshold 402653184 + gc-cons-percentage 0.6) + +(setq-default major-mode 'text-mode) + +(setq inhibit-startup-message t) +(setq x-select-enable-clipboard t) +(setq make-backup-files nil) +(setq scroll-conservatively 100) +(setq ring-bell-function 'ignore) +(setq history-length 25) +(setq global-auto-revert-non-file-buffers t) + +(setq-default tab-width 4) +(setq-default standard-indent 4) +(setq c-basic-offset tab-width) +(setq-default electric-indent-inhibit t) +(setq-default indent-tabs-mode t) +(setq backward-delete-char-untabify-method 'nil) + + +(setq electric-pair-pairs '( + (?\{ . ?\}) + (?\( . ?\)) + (?\[ . ?\]) + (?\" . ?\") + )) + +(setq use-package-always-defer t) + +(setq eshell-prompt-regexp "^[^αλ\n]*[αλ] ") +(setq eshell-prompt-function + (lambda nil + (concat + (if (string= (eshell/pwd) (getenv "HOME")) + (propertize "~" 'face `(:foreground "#99CCFF")) + (replace-regexp-in-string + (getenv "HOME") + (propertize "~" 'face `(:foreground "#99CCFF")) + (propertize (eshell/pwd) 'face `(:foreground "#99CCFF")))) + (if (= (user-uid) 0) + (propertize " α " 'face `(:foreground "#FF6666")) + (propertize " λ " 'face `(:foreground "#A6E22E")))))) + +(setq eshell-highlight-prompt nil) +(setq file-name-handler-alist nil) + +(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) diff --git a/.emacs.d/dracula-custom-theme.el b/.emacs.d/dracula-custom-theme.el new file mode 100644 index 0000000..6f1d11b --- /dev/null +++ b/.emacs.d/dracula-custom-theme.el @@ -0,0 +1,52 @@ +(deftheme dracula-custom + "Created 2022-11-27.") + +(custom-theme-set-faces + 'dracula-custom + '(default ((t (:family "Hack Nerd Font" :foundry "SRC" :width normal :height 113 :weight normal :slant normal :underline nil :overline nil :extend nil :strike-through nil :box nil :inverse-video nil :foreground "#F8F8F2" :background "#262626" :stipple nil :inherit nil)))) + '(cursor ((t (:background "#ccccc7")))) + '(fixed-pitch ((t (:family "Monospace")))) + '(variable-pitch ((((type w32)) (:foundry "outline" :family "Arial")) (t (:family "Sans Serif")))) + '(escape-glyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown")))) + '(homoglyph ((((background dark)) (:foreground "cyan")) (((type pc)) (:foreground "magenta")) (t (:foreground "brown")))) + '(minibuffer-prompt ((t (:weight bold :foreground "#ff79c6")))) + '(highlight ((t (:foreground "#ccccc7" :background "#464752")))) + '(region ((t (:extend t :inherit (match))))) + '(shadow ((t (:foreground "#6272a4")))) + '(secondary-selection ((((class color) (min-colors 88) (background light)) (:extend t :background "yellow1")) (((class color) (min-colors 88) (background dark)) (:extend t :background "SkyBlue4")) (((class color) (min-colors 16) (background light)) (:extend t :background "yellow")) (((class color) (min-colors 16) (background dark)) (:extend t :background "SkyBlue4")) (((class color) (min-colors 8)) (:extend t :foreground "black" :background "cyan")) (t (:inverse-video t)))) + '(trailing-whitespace ((t (:background "#ffb86c")))) + '(font-lock-builtin-face ((t (:slant italic :foreground "#8be9fd")))) + '(font-lock-comment-delimiter-face ((t (:inherit (shadow))))) + '(font-lock-comment-face ((t (:inherit (shadow))))) + '(font-lock-constant-face ((t (:foreground "#bd93f9")))) + '(font-lock-doc-face ((t (:foreground "#6272a4")))) + '(font-lock-doc-markup-face ((t (:inherit (font-lock-constant-face))))) + '(font-lock-function-name-face ((t (:weight bold :foreground "#50fa7b")))) + '(font-lock-keyword-face ((t (:foreground "#ff79c6" :weight bold)))) + '(font-lock-negation-char-face ((t (:foreground "#8be9fd")))) + '(font-lock-preprocessor-face ((t (:foreground "#ffb86c")))) + '(font-lock-regexp-grouping-backslash ((t (:foreground "#8be9fd")))) + '(font-lock-regexp-grouping-construct ((t (:foreground "#bd93f9")))) + '(font-lock-string-face ((t (:foreground "#f1fa8c")))) + '(font-lock-type-face ((t (:inherit (font-lock-builtin-face))))) + '(font-lock-variable-name-face ((t (:foreground "#d8a5f8" :weight bold)))) + '(font-lock-warning-face ((t (:background "#373844" :inherit (warning))))) + '(button ((t (:inherit (link))))) + '(link ((t (:underline (:color foreground-color :style line) :foreground "#8be9fd")))) + '(link-visited ((default (:inherit (link))) (((class color) (background light)) (:foreground "magenta4")) (((class color) (background dark)) (:foreground "violet")))) + '(fringe ((t (:foreground "#b6b6b2" :background "#282a36")))) + '(header-line ((t (:inherit 'mode-line)))) + '(tooltip ((t (:foreground "#f8f8f2" :background "#44475a")))) + '(mode-line ((t (:box (:line-width (1 . 1) :color "#44475a" :style nil) :inverse-video nil :foreground "#f8f8f2" :background "#44475a")))) + '(mode-line-buffer-id ((t (:weight bold)))) + '(mode-line-emphasis ((t (:weight bold)))) + '(mode-line-highlight ((((supports :box t) (class color) (min-colors 88)) (:box (:line-width (2 . 2) :color "grey40" :style released-button))) (t (:inherit (highlight))))) + '(mode-line-inactive ((t (:box (:line-width (1 . 1) :color "#373844" :style nil) :inverse-video nil :foreground "#b6b6b2" :background "#282a36")))) + '(isearch ((t (:weight bold :inherit (match))))) + '(isearch-fail ((t (:foreground "#282a36" :background "#ffb86c")))) + '(lazy-highlight ((t (:foreground "#e2e2dc" :background "#373844")))) + '(match ((t (:foreground "#282a36" :background "#f1fa8c")))) + '(next-error ((t (:inherit (region))))) + '(query-replace ((t (:inherit (isearch)))))) + +(provide-theme 'dracula-custom) diff --git a/.emacs.d/functions.el b/.emacs.d/functions.el new file mode 100644 index 0000000..cc86002 --- /dev/null +++ b/.emacs.d/functions.el @@ -0,0 +1,49 @@ +(defun startup/revert-file-name-handler-alist () + (setq file-name-handler-alist startup/file-name-handler-alist)) + +(defun startup/reset-gc () + (setq gc-cons-threshold 16777216 + gc-cons-percentage 0.1)) + +(defun split-and-follow-horizontally () + (interactive) + (split-window-below) + (balance-windows) + (other-window 1)) + +(defun split-and-follow-vertically () + (interactive) + (split-window-right) + (balance-windows) + (other-window 1)) + +(defun toggle-transparency() + (interactive) + (let ((alpha (frame-parameter nil 'alpha))) + (set-frame-parameter + nil 'alpha + (if (eql (cond ((numberp alpha) alpha) + ((numberp (cdr alpha)) (cdr alpha)) + ;; Also handle undocumented (<active> <inactive>) form. + ((numberp (cadr alpha)) (cadr alpha))) + 100) + '(80 . 80) '(100 . 100))))) + +(defun eshell/sudo-open (filename) + "Open a file as root in Eshell." + (let ((qual-filename (if (string-match "^/" filename) + filename + (concat (expand-file-name (eshell/pwd)) "/" filename)))) + (switch-to-buffer + (find-file-noselect + (concat "/sudo::" qual-filename))))) + +(defun eshell-other-window () + "Create or visit an eshell buffer." + (interactive) + (if (not (get-buffer "*eshell*")) + (progn + (split-window-sensibly (selected-window)) + (other-window 1) + (eshell)) + (switch-to-buffer-other-window "*eshell*"))) diff --git a/.emacs.d/init.el b/.emacs.d/init.el new file mode 100644 index 0000000..6079b3d --- /dev/null +++ b/.emacs.d/init.el @@ -0,0 +1,14 @@ +(load "~/.emacs.d/packages" nil t) +(load "~/.emacs.d/functions" nil t) +(load "~/.emacs.d/keybinds" nil t) +(load "~/.emacs.d/config" nil t) + +(server-start) +(set-default-file-modes #o700) + +;; Load Witchmacs theme +(load-theme 'Witchmacs t) + +;; Move customization variables to a separate file and load it +(setq custom-file (locate-user-emacs-file "custom-vars.el")) +(load custom-file 'noerror 'nomessage) diff --git a/.emacs.d/keybinds.el b/.emacs.d/keybinds.el new file mode 100644 index 0000000..e0fa2ed --- /dev/null +++ b/.emacs.d/keybinds.el @@ -0,0 +1,14 @@ +;; Control X +(global-set-key (kbd "C-x 2") 'split-and-follow-horizontally) +(global-set-key (kbd "C-x 3") 'split-and-follow-vertically) + +;; Super +(global-set-key (kbd "s-C-<left>") 'shrink-window-horizontally) +(global-set-key (kbd "s-C-<right>") 'enlarge-window-horizontally) +(global-set-key (kbd "s-C-<down>") 'shrink-window) +(global-set-key (kbd "s-C-<up>") 'enlarge-window) +(global-set-key (kbd "<s-C-return>") 'eshell-other-window) + +;; Control C +(global-set-key (kbd "C-c r") 'recentf-open-files) +(global-set-key (kbd "C-c t") 'toggle-transparency) diff --git a/.emacs.d/packages.el b/.emacs.d/packages.el new file mode 100644 index 0000000..3e84067 --- /dev/null +++ b/.emacs.d/packages.el @@ -0,0 +1,330 @@ +;; Initialize melpa repo +(require 'package) +(setq package-enable-at-startup nil) +(add-to-list 'package-archives + '("melpa" . "https://melpa.org/packages/")) +(package-initialize) + +;; Initialize use-package +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) +(use-package org + :config + (add-hook 'org-mode-hook 'org-indent-mode) + (add-hook 'org-mode-hook + '(lambda () + (visual-line-mode 1)))) + +(use-package org-indent + :diminish org-indent-mode) + +(use-package htmlize + :ensure t) + +(use-package auto-package-update + :defer nil + :ensure t + :config + (setq auto-package-update-delete-old-versions t) + (setq auto-package-update-hide-results t) + (auto-package-update-maybe)) + +(use-package diminish + :ensure t) + +(use-package spaceline + :ensure t) + +(use-package powerline + :ensure t + :init + (spaceline-spacemacs-theme) + :hook + ('after-init-hook) . 'powerline-reset) + +(use-package dashboard + :ensure t + :defer nil + :preface + (defun update-config () + "Update Witchmacs to the latest version." + (interactive) + (let ((dir (expand-file-name user-emacs-directory))) + (if (file-exists-p dir) + (progn + (message "Witchmacs is updating!") + (cd dir) + (shell-command "git pull") + (message "Update finished. Switch to the messages buffer to see changes and then restart Emacs")) + (message "\"%s\" doesn't exist." dir)))) + + (defun create-scratch-buffer () + "Create a scratch buffer" + (interactive) + (switch-to-buffer (get-buffer-create "*scratch*")) + (lisp-interaction-mode)) + :config + (dashboard-setup-startup-hook) + (setq dashboard-items '((recents . 5))) + (setq dashboard-banner-logo-title "W I T C H M A C S - The cutest Emacs distribution!") + (setq dashboard-startup-banner "~/.emacs.d/marivector.png") + (setq dashboard-center-content t) + (setq dashboard-show-shortcuts nil) + (setq dashboard-set-init-info t) + (setq dashboard-init-info (format "%d packages loaded in %s" + (length package-activated-list) (emacs-init-time))) + (setq dashboard-set-footer nil) + (setq dashboard-set-navigator t) + (setq dashboard-navigator-buttons + `(;; line1 + ((,nil + "Witchmacs on github" + "Open Witchmacs' github page on your browser" + (lambda (&rest _) (browse-url "https://github.com/snackon/witchmacs")) + 'default) + (nil + "Witchmacs crash course" + "Open Witchmacs' introduction to Emacs" + (lambda (&rest _) (find-file "~/.emacs.d/Witcheat.org")) + 'default) + (nil + "Update Witchmacs" + "Get the latest Witchmacs update. Check out the github commits for changes!" + (lambda (&rest _) (update-config)) + 'default) + ) + ;; line 2 + ((,nil + "Open scratch buffer" + "Switch to the scratch buffer" + (lambda (&rest _) (create-scratch-buffer)) + 'default) + (nil + "Open config.el" + "Open Witchmacs' configuration file for easy editing" + (lambda (&rest _) (find-file "~/.emacs.d/config.el")) + 'default) + (nil + "Open init.el" + "Open init file" + (lambda (&rest _) (find-file "~/.emacs.d/init.el")) + 'default))))) + + +;(insert (concat +; (propertize (format "%d packages loaded in %s" +; (length package-activated-list) (emacs-init-time)) +; 'face 'font-lock-comment-face))) +; +;(dashboard-center-line) + +(use-package which-key + :ensure t + :diminish which-key-mode + :init + (which-key-mode)) + +(use-package swiper + :ensure t + :bind ("C-s" . 'swiper)) + +(use-package evil + :ensure t + :defer nil + :init + (setq evil-want-keybinding nil) + (setq evil-want-C-u-scroll t) + :config + (evil-mode 1)) + +;(use-package evil-collection +; :after evil +; :ensure t +; :config +; (evil-collection-init)) + +(use-package beacon + :ensure t + :diminish beacon-mode + :init + (beacon-mode 1)) + +(use-package avy + :ensure t + :bind + ("M-s" . avy-goto-char)) + +(use-package switch-window + :ensure t + :config + (setq switch-window-input-style 'minibuffer) + (setq switch-window-increase 4) + (setq switch-window-threshold 2) + (setq switch-window-shortcut-style 'qwerty) + (setq switch-window-qwerty-shortcuts + '("a" "s" "d" "f" "j" "k" "l")) + :bind + ([remap other-window] . switch-window)) + +(use-package ido + :init + (ido-mode 1) + :config + (setq ido-enable-flex-matching nil) + (setq ido-create-new-buffer 'always) + (setq ido-everywhere t)) + +(use-package ido-vertical-mode + :ensure t + :init + (ido-vertical-mode 1)) +; This enables arrow keys to select while in ido mode. If you want to +; instead use the default Emacs keybindings, change it to +; "'C-n-and-C-p-only" +(setq ido-vertical-define-keys 'C-n-C-p-up-and-down) + +(use-package async + :ensure t + :init + (dired-async-mode 1)) + +(use-package page-break-lines + :ensure t + :diminish (page-break-lines-mode visual-line-mode)) + +(use-package undo-tree + :ensure t + :diminish undo-tree-mode) + +(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 (executable-find "python3") 3 0) + treemacs-deferred-git-apply-delay 0.5 + treemacs-display-in-side-window t + treemacs-eldoc-display t + treemacs-file-event-delay 5000 + treemacs-file-follow-delay 0.2 + treemacs-follow-after-init t + treemacs-git-command-pipe "" + treemacs-goto-tag-strategy 'refetch-index + treemacs-indentation 2 + treemacs-indentation-string " " + treemacs-is-never-other-window nil + treemacs-max-git-entries 5000 + treemacs-missing-project-action 'ask + 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-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-show-cursor nil + treemacs-show-hidden-files t + treemacs-silent-filewatch nil + treemacs-silent-refresh nil + treemacs-sorting 'alphabetic-desc + treemacs-space-between-root-nodes t + treemacs-tag-follow-cleanup t + treemacs-tag-follow-delay 1.5 + treemacs-width 30) + (treemacs-resize-icons 11) + + (treemacs-follow-mode t) + (treemacs-filewatch-mode t) + (treemacs-fringe-indicator-mode t) + (pcase (cons (not (null (executable-find "git"))) + (not (null (executable-find "python3")))) + (`(t . t) + (treemacs-git-mode 'deferred)) + (`(t . _) + (treemacs-git-mode 'simple)))) + :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 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-icons-dired + :after treemacs dired + :ensure t + :config (treemacs-icons-dired-mode)) + +(use-package magit + :ensure t) + +(use-package eldoc + :diminish eldoc-mode) + +(use-package abbrev + :diminish abbrev-mode) + +(use-package company + :ensure t + :diminish (meghanada-mode company-mode irony-mode) + :config + (setq company-idle-delay 0) + (setq company-minimum-prefix-length 3) + (define-key company-active-map (kbd "M-n") nil) + (define-key company-active-map (kbd "M-p") nil) + (define-key company-active-map (kbd "C-n") #'company-select-next) + (define-key company-active-map (kbd "C-p") #'company-select-previous) + (define-key company-active-map (kbd "SPC") #'company-abort) + :hook + ((java-mode c-mode c++-mode) . company-mode)) + +(use-package yasnippet + :ensure t + :diminish yas-minor-mode + :hook + ((c-mode c++-mode) . yas-minor-mode) + :config + (yas-reload-all)) + +(use-package yasnippet-snippets + :ensure t) + +(use-package company-c-headers + :defer nil + :ensure t) + +(use-package company-irony + :defer nil + :ensure t + :config + (setq company-backends '((company-c-headers + company-dabbrev-code + company-irony)))) +(use-package irony + :defer nil + :ensure t + :config + :hook + ((c++-mode c-mode) . irony-mode) + ('irony-mode-hook) . 'irony-cdb-autosetup-compile-options) + +(use-package meghanada + :ensure t + :defer nil + :config + (add-hook 'java-mode-hook + (lambda () + (meghanada-mode t))) + (setq meghanada-java-path "java") + (setq meghanada-maven-path "mvn")) |
