Skip to content

Instantly share code, notes, and snippets.

@genmeblog
Last active Mar 29, 2022
Embed
What would you like to do?
Emacs config
;;
(setq gc-cons-threshold 10000000)
;; Restore after startup
(add-hook 'after-init-hook
(lambda ()
(setq gc-cons-threshold 1000000)
(message "gc-cons-threshold restored to %S"
gc-cons-threshold)))
;; package management
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")
("elpa" . "https://elpa.gnu.org/packages/")))
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(setq load-prefer-newer t)
(require 'use-package)
;; auto install when necessary
(setq use-package-always-ensure t)
;; backups and other internal files should be
(use-package no-littering)
(setq auto-save-file-name-transforms
`((".*" ,(no-littering-expand-var-file-name "auto-save/") t)))
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p "~/.emacs.d/custom.el")
(load "~/.emacs.d/custom.el"))
(save-place-mode 1)
(setq save-place-file (concat user-emacs-directory "places"))
(setq recentf-save-file (concat user-emacs-directory ".recentf"))
(use-package recentf
:config (recentf-mode 1)
:custom ((recentf-max-menu-items 40)))
;; gui / global
(setq inhibit-startup-screen t)
(tool-bar-mode -1)
(column-number-mode t)
(global-display-line-numbers-mode t)
(size-indication-mode t)
(delete-selection-mode t)
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq visible-bell t)
(scroll-bar-mode -1)
(setq-default frame-title-format "%b (%f)")
(global-prettify-symbols-mode +1)
(display-time-mode 1)
(defalias 'yes-or-no-p 'y-or-n-p)
(set-face-attribute 'default nil :font "RobotoMono Nerd Font" :height 100 :weight 'light)
(set-face-attribute 'bold nil :font "RobotoMono Nerd Font" :height 100 :weight 'medium)
(set-face-attribute 'italic nil :font "BlexMono Nerd Font" :height 100 :weight 'light :slant 'italic)
(set-fontset-font t 'unicode (font-spec :name "RobotoMono Nerd Font" :size 10) nil)
(use-package unicode-fonts
:custom (unicode-fonts-skip-font-groups '(low-quality-glyphs))
;; :config (unicode-fonts-setup)
)
(use-package solarized-theme)
(use-package jazz-theme)
(setq tsl/light-theme 'solarized-selenized-light)
(setq tsl/dark-theme 'jazz)
(use-package doom-themes
:config
(setq doom-themes-enable-bold t
doom-themes-enable-italic t)
(load-theme tsl/light-theme t)
(doom-themes-visual-bell-config)
(doom-themes-neotree-config)
(setq doom-themes-treemacs-theme "doom-atom")
(doom-themes-treemacs-config))
;; (setq frame-background-mode 'dark)
(use-package all-the-icons)
(use-package doom-modeline
:init (doom-modeline-mode 1)
:custom ((doom-modeline-height 15)
(doom-modeline-buffer-file-name-style 'truncate-all)
(doom-modeline-minor-modes t)))
(use-package which-key
:diminish which-key-mode
:config (which-key-mode)
:custom ((which-key-idle-delay 1.0)
(which-key-enable-extended-define-key t)))
(use-package paredit
:config (paredit-mode 1))
(use-package adjust-parens
:config (adjust-parens-mode 1))
(use-package rainbow-delimiters
:config (rainbow-delimiters-mode 1))
(use-package paren
:custom ((show-paren-delay 0))
:config
(set-face-background 'show-paren-match "#ffaaaa")
(show-paren-mode 1))
(use-package rainbow-mode
:config
(rainbow-mode 1))
(use-package general)
(use-package restart-emacs)
(use-package math-preview
:custom ((math-preview-command "/home/tsl/node_modules/math-preview/math-preview.js")
(math-preview-scale 1.0))
:bind (("C-c m p" . 'math-preview-all)
("C-c m c" . 'math-preview-clear-all)
("C-c m ." . 'math-preview-at-point)
("C-c m /" . 'math-preview-clear-at-point)))
(use-package ivy
:init
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq ivy-use-selectable-prompt t)
(setq ivy-re-builders-alist
'((t . ivy--regex-fuzzy)))
)
(use-package counsel
:custom
(counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
:config
(counsel-mode 1))
(use-package ivy-rich
:after ivy
:init (ivy-rich-mode 1))
(use-package ivy-prescient
:after counsel
:custom (ivy-prescient-enable-filtering nil)
:config
;; Uncomment the following line to have sorting remembered across sessions!
;; (prescient-persist-mode 1)
(ivy-prescient-mode 1))
(setq ivy-re-builders-alist '((t . ivy--regex-fuzzy)))
(use-package expand-region
:bind ("C-@" . er/expand-region))
(use-package multiple-cursors
:bind (("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)
("C-c C-<" . mc/mark-all-like-this)))
(use-package helpful
:commands (helpful-callable helpful-variable helpful-command helpful-key)
:custom
(counsel-describe-function-function #'helpful-callable)
(counsel-describe-variable-function #'helpful-variable)
:bind
([remap describe-function] . counsel-describe-function)
([remap describe-command] . helpful-command)
([remap describe-variable] . counsel-describe-variable)
([remap describe-key] . helpful-key))
(use-package hydra
:config (require 'hydra))
(use-package ivy-hydra
:after (ivy hydra))
(use-package company
:bind (:map company-active-map
("<tab>" . company-complete-selection))
:custom
(company-minimum-prefix-length 1)
(company-idle-delay 0.0)
:config
(global-company-mode 1))
(use-package company-flx
:config (company-flx-mode 1))
(use-package company-box
:hook (company-mode . company-box-mode))
(use-package projectile
:diminish projectile-mode
:config (projectile-mode 1)
:custom ((projectile-completion-system 'ivy))
:bind-keymap
("C-c p" . projectile-command-map)
:init
(setq projectile-switch-project-action #'projectile-dired))
(use-package counsel-projectile
:after projectile
:config (counsel-projectile-mode 1))
(use-package project-explorer
:bind (("C-x p" . project-explorer-toggle)))
(use-package magit
:commands magit-status)
(use-package dired
:ensure nil
:commands (dired dired-jump)
:bind (("C-x C-j" . dired-jump))
:custom ((dired-listing-switches "-agho --group-directories-first")))
(use-package dired-single
:commands (dired dired-jump))
(use-package dired-ranger)
(use-package dired-collapse)
(use-package dired-rainbow)
(use-package all-the-icons-dired
:hook (dired-mode . all-the-icons-dired-mode))
(use-package all-the-icons-ivy-rich)
(use-package uniquify
:ensure nil
:init
(setq uniquify-buffer-name-style 'post-forward))
(use-package yasnippet
:config (yas-global-mode 1))
(use-package ivy-yasnippet)
(use-package ace-window
:bind (("M-]" . ace-window))
:config (ace-window-display-mode 1))
(use-package paradox
:config (paradox-enable))
(use-package anzu
:config (global-anzu-mode 1))
(use-package move-text
:init
(move-text-default-bindings))
(use-package aggressive-indent)
(use-package diminish)
(use-package minions
:config (minions-mode 1))
(use-package default-text-scale
:config (default-text-scale-mode))
;; R
(use-package ess)
(use-package poly-R)
;; treemacs
(use-package treemacs-all-the-icons)
(use-package treemacs)
(use-package treemacs-projectile)
(use-package treemacs-magit)
;; clojure
(use-package flycheck)
(use-package flycheck-clj-kondo)
(use-package clojure-mode
:config (require 'flycheck-clj-kondo))
(use-package cider
:custom ((cider-eldoc-display-context-dependent-info t)
(cider-repl-pop-to-buffer-on-connect 'display-only)
(cider-overlays-use-font-lock t)
(cider-repl-buffer-size-limit 60000)))
(use-package clj-refactor)
(use-package clojure-mode-extra-font-locking)
(use-package sayid)
(use-package cljr-ivy)
(use-package clojure-snippets)
(use-package ivy-clojuredocs
:bind (:map clojure-mode-map
(("C-c d" . ivy-clojuredocs-at-point))))
(use-package clj-decompiler)
;; lsp
(use-package lsp-mode
:hook ((clojure-mode . lsp))
:custom ((lsp-lens-enable t)
(lsp-enable-indentation nil)
(read-process-output-max (* 1024 1024))
(lsp-clojure-custom-server-command '("/home/tsl/clojure-lsp"))
(lsp-keymap-prefix "C-c l"))
:config (dolist (m '(clojure-mode
clojurec-mode
clojurescript-mode
clojurex-mode))
(add-to-list 'lsp-language-id-configuration `(,m . "clojure")))
(lsp-enable-which-key-integration))
(use-package lsp-ui :commands lsp-ui-mode)
(use-package lsp-treemacs)
(use-package lsp-ivy)
(use-package iedit
:bind (("C-c ;" . iedit-mode)) )
(global-prettify-symbols-mode +1)
(autoload 'iimage-mode "iimage" "Support Inline image minor mode." t)
(autoload 'turn-on-iimage-mode "iimage" "Turn on Inline image minor mode." t)
(autoload 'zap-up-to-char "misc"
"Kill up to, but not including ARGth occurrence of CHAR." t)
(defun toggle-comment-on-line ()
"comment or uncomment current line"
(interactive)
(comment-or-uncomment-region (line-beginning-position) (line-end-position)))
(defun prev-window ()
(interactive)
(other-window -1))
(general-define-key
"M-z" 'zap-up-to-char
"C-<tab>" 'indent-relative
"C-x C-b" 'counsel-ibuffer
"C-s" 'swiper
"C-r" 'isearch-backward-regexp
"C-M-s" 'isearch-forward
"C-M-r" 'isearch-backward
"C-." 'company-complete
"C-c t l" (lambda () (interactive) (load-theme tsl/light-theme t))
"C-c t d" (lambda () (interactive) (load-theme tsl/dark-theme t))
"C-;" 'toggle-comment-on-line
"C-M-<next>" 'other-window
"C-M-<prior>" 'prev-window)
(add-hook 'prog-mode-hook (lambda () (setq indent-tabs-mode nil)))
(add-hook 'prog-mode-hook 'rainbow-mode)
(add-hook 'prog-mode-hook 'paredit-mode)
(add-hook 'prog-mode-hook 'eldoc-mode)
(add-hook 'prog-mode-hook 'adjust-parens-mode)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(add-hook 'prog-mode-hook 'show-paren-mode)
(add-hook 'prog-mode-hook 'subword-mode)
(add-hook 'prog-mode-hook 'hs-minor-mode)
(add-hook 'prog-mode-hook 'aggressive-indent-mode)
(add-hook 'prog-mode-hook 'turn-on-iimage-mode)
(add-hook 'clojure-mode-hook 'flycheck-mode)
(add-hook 'clojure-mode-hook
(lambda ()
(push '("defn" . ) prettify-symbols-alist)
(push '("def" . ?≡) prettify-symbols-alist)))
(add-hook 'clojure-mode-hook 'cider-mode)
(add-hook 'clojure-mode-hook (lambda ()
(eval-after-load 'cider
'(progn
(require 'clj-decompiler)
(clj-decompiler-setup)
(clj-refactor-mode 1)
(cljr-add-keybindings-with-prefix "C-c C-m")))))
(setq cider-repl-pop-to-buffer-on-connect t)
;; When there's a cider error, show its buffer and switch to it
(setq cider-show-error-buffer t)
(setq cider-auto-select-error-buffer t)
;; Where to store the cider history.
(setq cider-repl-history-file "~/.emacs.d/cider-history")
;; Wrap when navigating history.
(setq cider-repl-wrap-history t)
;; Use clojure mode for other extensions
(add-to-list 'auto-mode-alist '("\\.edn$" . clojure-mode))
(add-to-list 'auto-mode-alist '("\\.boot$" . clojure-mode))
(add-to-list 'auto-mode-alist '("\\.cljs.*$" . clojure-mode))
(add-to-list 'auto-mode-alist '("lein-env" . enh-ruby-mode))
(eval-after-load 'clojure-mode
'(sayid-setup-package))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment