Skip to content

Instantly share code, notes, and snippets.

@ansxor
Last active January 11, 2021 21:19
Show Gist options
  • Save ansxor/b0d9da755df1853e1f468b2b508e6e26 to your computer and use it in GitHub Desktop.
Save ansxor/b0d9da755df1853e1f468b2b508e6e26 to your computer and use it in GitHub Desktop.
emacs config

Sue Emacs Configuration

Packages

Respositories

(require 'package)
(setq package-enable-at-startup nil)

(setq package-archives '(("ELPA"  . "http://tromey.com/elpa/")
			     ("gnu"   . "http://elpa.gnu.org/packages/")
			     ("melpa" . "https://melpa.org/packages/")
			     ("org" . "https://orgmode.org/elpa/")))
(package-initialize)

straight.el

(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))

use-package

(straight-use-package 'use-package)
(require 'use-package)
(setq straight-use-package-by-default t)
(require 'use-package-ensure)
(setq use-package-always-ensure t)

Miscellaneous

Get rid of awful errors

(setq warning-minimum-level :emergency)

Garbage Collection

(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024))

Disable running processes prompt

(setq confirm-kill-processes nil)

Disable start menu

(setq initial-startup-screen nil)
(setq initial-scratch-message ";; hiya answer owo")

Disable lock files

(setq create-lockfiles nil)

Store backups somewhere else

(setq backup-directory-alist '(("." . "~/.emacs.d/backup")))

Appearance

Fix GUI Clutter

(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(setq frame-resize-pixelwise t)
(setq ring-bell-function 'ignore)

all-the-icons

(use-package all-the-icons)

Default tab length

(setq-default tab-width 4)

Theme

Doom Theme

 (use-package doom-themes
   :disabled
	:config
	(setq doom-themes-enable-bold t
		  doom-themes-enable-italic t)
	(load-theme 'doom-gruvbox)
	(setq doom-themes-treemacs-theme "doom-colors")
	(doom-themes-treemacs-config)

	(doom-themes-org-config))

Moe Theme

 (use-package moe-theme
	:config (moe-dark))

Modeline

 (use-package doom-modeline
   :disabled
	:ensure t
	:init (doom-modeline-mode 1))

Column Numbers

(column-number-mode 1)

Minions

 (use-package minions
	:config (minions-mode 1))

Font

(add-to-list 'default-frame-alist '(font . "DejaVu Sans Mono-13"))
(set-face-attribute 'default t :font "DejaVu Sans Mono-13")
(set-face-attribute 'default nil :font "DejaVu Sans Mono-13")
(set-frame-font "DejaVu Sans Mono-13" nil t)

Ligatures

Global Minor Modes

Helm

 (use-package helm
	:defer
	:config (helm-mode 1)
	:bind (("M-x" . #'helm-M-x)
		   ("C-x r b" . #'helm-filtered-bookmarks)
		   ("C-x C-f" . #'helm-find-files)
		   ("C-x b" . #'helm-mini)))

Helm Swoop

 (use-package helm-swoop
   :defer
	:config
	(setq helm-swoop-use-fuzzy-match t)
	:bind (("M-i" . #'helm-swoop)))

Helm Icons

 (use-package helm-icons
   :disabled
	:config (helm-icons-enable))

Helm Posframe

 (use-package helm-posframe
   :disabled
	:config
	(setq helm-posframe-poshandler
		  #'posframe-poshandler-window-center)
	(setq helm-posframe-width 100)
	(setq helm-posframe-parameters
		  '((left-fringe . 10)
			(right-fringe . 10)))
	(helm-posframe-enable))

EVIL (Vim Keybinds)

 (use-package evil
	:init
	(setq evil-want-integration t)
	(setq evil-want-keybinding nil)
	(setq evil-want-C-i-jump nil)
	:config
	(evil-mode 1))

EVIL Keybind Collection

 (use-package evil-collection
	:init
	(setq evil-collection-setup-minibuffer t)
	:config 
	(evil-collection-init))

YaSnippet

 (use-package yasnippet
   :defer
	:hook ((prog-mode latex-mode org-mode) . yas-minor-mode))

Default snippets

 (use-package yasnippet-snippets
	:after (yasnippet))

Beacon

 (use-package beacon
	:config (beacon-mode t))

which-key

 (use-package which-key
	:config (which-key-mode t))

delete-selection

(delete-selection-mode +1)

avy

 (use-package avy
	:config (avy-setup-default)
	:bind (("M-g c" . avy-goto-char)
		   ("M-g g" . avy-goto-line)
		   ("M-g w" . avy-goto-word-1)))

Treemacs

 (use-package treemacs
	:defer
	:config
	(treemacs-follow-mode t)
	(treemacs-filewatch-mode t)
	(treemacs-fringe-indicator-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)))
	:bind (("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)))

Projectile Integration

 (use-package treemacs-projectile
	:after treemacs)

Selectric

(use-package selectric-mode)

Programming Minor Modes

Company

 (use-package company
	:hook (prog-mode . company-mode)
	:defer t
	:custom
	(company-idle-delay 0)
	(company-minimum-prefix-length 1)
	(company-selection-wrap-around t))

Projectile

 (use-package projectile
	:config (projectile-mode t)
	:bind (("C-x p" . projectile-command-map)))

Helm integration

 (use-package helm-projectile
   :disabled
	:config
	(helm-projectile-on))

Line numbers

(add-hook 'prog-mode-hook 'display-line-numbers-mode)

Rainbow Delimiters

 (use-package rainbow-delimiters
   :defer
	:hook (prog-mode . rainbow-delimiters-mode))

dtrt-indent

 (use-package dtrt-indent
   :defer
	:hook (prog-mode . dtrt-indent-mode))

smart-parens

 (use-package smartparens
   :defer
	:hook (prog-mode . smartparens-mode)
	:config (require 'smartparens-config))

EVIL Integration

 (use-package evil-smartparens
	:defer
	:config (add-hook 'smartparens-enabled-hook #'evil-smartparens-mode))

Impatient Mode

HTTPD Dependency

 (use-package simple-httpd
	:config (httpd-start))

Install

 (use-package impatient-mode
	:after (simple-httpd))

Wrapper to open current buffer in browser

 (defun answer-config/impatient-in-the-browser ()
	(interactive)
	(browse-url (format "http://localhost:8080/imp/live/%s/" (current-buffer))))

Highlight Current Line

(add-hook 'prog-mode-hook 'hl-line-mode)
(add-hook 'ibuffer-mode-hook ' hl-line-mode)

Indent guides

 (use-package highlight-indent-guides
   :defer
	:hook (prog-mode . highlight-indent-guides-mode)
	:config (setq-default highlight-indent-guides-method 'bitmap))

LSP

 (use-package lsp-mode
	:defer
	:config
	(setq lsp-enable-on-type-formatting nil))

LSP UI

 (use-package lsp-ui
	:after (lsp)
	:defer
	:config
	(setq lsp-ui-doc-enable nil
		  lsp-ui-sideline-enable nil))

Column lines

;; (add-hook 'prog-mode-hook 'display-fill-column-indicator-mode)

Aggressive Indent

 (use-package aggressive-indent
   :disabled
   :defer
	:hook (prog-mode . aggressive-indent-mode))

FlyCheck

 (use-package flycheck
   :defer
	:hook (prog-mode . flycheck-mode))

Visual Line Mode

(add-hook 'org-mode-hook 'visual-line-mode)

org-mode

Disable Adaptive Indent

(setq-default org-adapt-indentation nil)

Variable sized headers

(custom-set-faces
  '(org-document-title ((t (:inherit outline-1 :height 1.44))))
  '(org-level-1 ((t (:inherit outline-1 :height 1.3))))
  '(org-level-2 ((t (:inherit outline-2 :height 1.1))))
  '(org-level-3 ((t (:inherit outline-3 :height 1.0)))))

Bullets

 (use-package org-superstar
	:hook (org-mode . org-superstar-mode))

Visual Line Mode

(add-hook 'org-mode-hook 'visual-line-mode)

HTMLize

(use-package htmlize)

Treesitter

 (use-package tree-sitter
	:disabled)
 (use-package tree-sitter-langs
	:disabled)

Major Modes

AutoHotKey

(use-package ahk-mode)

Web

Web-mode

 (use-package web-mode
	:mode ("\\.phtml\\'" "\\.tpl\\.php\\'" "\\.jsp\\'" "\\.as[cp]x\\'"
		   "\\.erb\\'" "\\.mustache\\'" "\\.djhtml\\'" "\\.jst.ejs\\'"
		   "\\.html?\\'")
	:hook (web-mode . lsp)
	:config
	(add-hook 'web-mode-hook '(lambda () (impatient-mode t)))
	:bind (("<f5>" . answer-config/impatient-in-the-browser)))

Emmet

 (use-package emmet-mode
	:after (web-mode)
	:hook (sqml-mode web-mode css-mode))

JavaScript

 (setq lsp-clients-typescript-log-verbosity "log")
 (add-hook 'js-mode-hook #'lsp)
 (require 'cl)
 (with-eval-after-load 'lsp-clients
	(cl-nsubst '(nconc (list "/usr/local/bin/node" "--unhandled-rejections=strict" (lsp-package-path 'typescript-language-server)) (cons "--tsserver-path" (cons (lsp-package-path 'typescript) lsp-clients-typescript-server-args)))
			   '(cons (lsp-package-path 'typescript-language-server) (cons "--tsserver-path" (cons (lsp-package-path 'typescript) lsp-clients-typescript-server-args)))
			   (lsp--client-new-connection (gethash 'ts-ls lsp-clients))
			   :test 'equal))

Python

 (use-package lsp-python-ms
	:after (lsp)
	:hook (python-mode . lsp-deferred)
	:custom
	(lsp-python-auto-install-server t))

Dashboard

 (use-package page-break-lines)
 (use-package dashboard
	:custom
	(dashboard-set-heading-icons t)
	(dashboard-set-file-icons t)
	(dashboard-set-footer t)
	(dashboard-items '((recents . 5)
					   (bookmarks . 5)
					   (projects . 5)
					   (agenda . 5)))
	(dashboard-footer-messages '(
								 "are you doing well today? .w. if not, maybe you should sleep more or listen to some music. -w-"
								 "remember that alone time is important, answer."
								 "please slow down. i know you want to go fast, but i want the best of your work. :<"
								 "you might not be done today and that's okay!"
								 "i love you~"
								 "use m-x doctor if you need someone to talk to. :3"
								 "oh, we're already working? .w."))

	(dashboard-banner-logo-title "hiya!~")
	:config
	(setq inhibit-startup-message t)
	(dashboard-setup-startup-hook))

Powershell

(use-package powershell)

Restart Emacs

(use-package restart-emacs)

shell-pop

 (use-package shell-pop
	:config
	;; fixes a bug where frames will swap randomly
	(push (cons "\\*shell\\*" display-buffer--same-window-action) display-buffer-alist)
	:bind (("C-`" . shell-pop)))

SLIME (LISP)

 (use-package slime
	:config
	(setq inferior-lisp-program "sbcl")
	(slime-setup '(slime-fancy slime-quicklisp slime-asdf)))

org-babel support

(require 'ob-lisp)

Magit

 (use-package magit
	:bind (("C-x g" . magit-status)))

C/C++

 (use-package ccls
	:hook ((c-mode c++-mode objc-mode cuda-mode) .
		   (lambda () (require 'ccls) (lsp))))

org-babel support

(org-babel-do-load-languages
 'org-babel-load-languages '((C. t)))

EMMS

 (use-package emms
	:config
	(require 'emms-setup)
	(emms-all)
	(emms-default-players)
	(setq emms-mode-line-format "%s")
	(setq emms-source-file-default-directory "~/Music/"))

Qmake Mode

 (use-package qt-pro-mode
	:ensure t
	:mode ("\\.pro\\'" "\\.pri\\'"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment