Skip to content

Instantly share code, notes, and snippets.

Last active September 2, 2023 13:03
  • Star 72 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
My minimal Emacs config

;; Automatically generated
 ;; 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.
 '(anzu-cons-mode-line-p nil)
 '(mouse-wheel-progressive-speed nil)
 '(mouse-wheel-scroll-amount (quote (1 ((shift) . 5) ((control)))))
    (company-lsp emojify web-mode tide tss doom-modeline quickrun org-bullets lsp-ui flycheck-rust spaceline-all-the-icons spaceline flycheck-inline lsp-rust f lsp-mode rust-mode pdf-tools company js2-mode diff-hl editorconfig general which-key helm doom-themes evil use-package)))
 '(send-mail-function (quote smtpmail-send-it)))
 ;; 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.
 '(default ((t (:inherit nil :stipple nil :background "#212121" :foreground "#eeffff" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 110 :width normal :foundry "nil" :family "Iosevka"))))
 '(font-lock-constant-face ((t (:foreground "#C792EA"))))
 '(font-lock-keyword-face ((t (:foreground "#2BA3FF" :slant italic))))
 '(font-lock-preprocessor-face ((t (:inherit bold :foreground "#2BA3FF" :slant italic :weight normal))))
 '(font-lock-string-face ((t (:foreground "#C3E88D"))))
 '(font-lock-type-face ((t (:foreground "#FFCB6B"))))
 '(font-lock-variable-name-face ((t (:foreground "#FF5370"))))
 '(helm-rg-active-arg-face ((t (:foreground "LightGreen"))))
 '(helm-rg-file-match-face ((t (:foreground "LightGreen" :underline t))))
 '(helm-rg-preview-line-highlight ((t (:background "LightGreen" :foreground "black"))))
 '(mode-line ((t (:background "#191919" :box nil))))
 '(mode-line-inactive ((t (:background "#282828" :foreground "#5B6268" :box nil))))
 '(term ((t (:foreground "#fafafa")))))
;; OrgMode Configs
(setq org-return-follows-link t)
(setq org-html-validation-link nil)
(setq org-todo-keywords
'((sequence "TODO" "WORKING" "HOLD" "|" "DONE")))
(setq org-todo-keyword-faces
'(("TODO" . "blue")
("WORKING" . "yellow")
("HOLD" . "red")
("DONE" . "green")))
(use-package org-bullets
:ensure t
(add-hook 'org-mode-hook (lambda ()
(org-bullets-mode 1)
;; Cochin font only available on macOS, AFAIK
(setq buffer-face-mode-face '(:family "Cochin" :height 140))
(set-frame-parameter (selected-frame) 'background-mode 'light)
(set-face-foreground 'default "#333333" (selected-frame))
(set-face-background 'default "#fafafa" (selected-frame))
;; (hide-mode-line-mode 1)


Font: Iosevka-11

;; Package configs
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives '(("org" . "")
("gnu" . "")
("melpa" . "")))
;; Bootstrap `use-package`
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(let ((path (shell-command-to-string ". ~/.bash_profile; echo -n $PATH")))
(setenv "PATH" path)
(setq exec-path
(split-string-and-unquote path ":")
;; Some term enhancement
(defadvice term-sentinel (around my-advice-term-sentinel (proc msg))
(if (memq (process-status proc) '(signal exit))
(let ((buffer (process-buffer proc)))
(kill-buffer buffer))
(ad-activate 'term-sentinel)
(defadvice ansi-term (before force-bash)
(interactive (list "/bin/zsh")))
(ad-activate 'ansi-term)
;; Other configs
(setq make-backup-files nil)
(setq auto-save-default nil)
;; Splash Screen
(setq inhibit-startup-screen t)
(setq initial-scratch-message ";; Happy Hacking")
;; Show matching parens
(setq show-paren-delay 0)
(show-paren-mode 1)
;; Paragraph movement
(global-set-key (kbd "s-j") 'forward-paragraph)
(global-set-key (kbd "s-k") 'backward-paragraph)
;; Keybinding for term mode
(add-hook 'term-mode
(lambda () (global-set-key (kbd "s-v") 'term-paste)))
;; OrgMode Configs
(setq org-html-validation-link nil)
(setq org-todo-keywords
'((sequence "TODO" "WORKING" "HOLD" "|" "DONE")))
(setq org-todo-keyword-faces
'(("TODO" . "blue")
("WORKING" . "yellow")
("HOLD" . "red")
("DONE" . "green")))
;; UI configurations
(scroll-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(menu-bar-mode -1)
(global-linum-mode 1)
(add-to-list 'default-frame-alist '(font . "Iosevka-11"))
(add-to-list 'default-frame-alist '(height . 24))
(add-to-list 'default-frame-alist '(width . 80))
;; Vim mode
(use-package evil
:ensure t
(evil-mode 1))
(use-package evil-escape
:ensure t
(setq-default evil-escape-key-sequence "jk")
(evil-escape-mode 1))
;; Anzu for search matching
(use-package anzu
:ensure t
(global-anzu-mode 1)
(global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp)
(global-set-key [remap query-replace] 'anzu-query-replace))
;; Theme
(use-package doom-themes
:ensure t
(load-theme 'doom-one t))
;; Helm
(use-package helm
:ensure t
(setq helm-M-x-fuzzy-match t
helm-mode-fuzzy-match t
helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t
helm-locate-fuzzy-match t
helm-semantic-fuzzy-match t
helm-imenu-fuzzy-match t
helm-completion-in-region-fuzzy-match t
helm-candidate-number-list 80
helm-split-window-in-side-p t
helm-move-to-line-cycle-in-source t
helm-echo-input-in-header-line t
helm-autoresize-max-height 0
helm-autoresize-min-height 20)
(helm-mode 1))
;; RipGrep
(use-package helm-rg :ensure t)
;; Projectile
(use-package projectile
:ensure t
(setq projectile-require-project-root nil)
(projectile-mode 1))
;; Helm Projectile
(use-package helm-projectile
:ensure t
(setq helm-projectile-fuzzy-match t)
;; All The Icons
(use-package all-the-icons :ensure t)
;; NeoTree
(use-package neotree
:ensure t
(setq neo-theme (if (display-graphic-p) 'icons 'arrow)))
;; Which Key
(use-package which-key
:ensure t
(setq which-key-separator " ")
(setq which-key-prefix-prefix "+")
;; Custom keybinding
(use-package general
:ensure t
:config (general-define-key
:states '(normal visual insert emacs)
:prefix "SPC"
:non-normal-prefix "M-SPC"
"/" '(helm-projectile-rg :which-key "ripgrep")
"TAB" '(switch-to-prev-buffer :which-key "previous buffer")
"SPC" '(helm-M-x :which-key "M-x")
"pf" '(helm-projectile-find-file :which-key "find files")
"pp" '(helm-projectile-switch-project :which-key "switch project")
"pb" '(helm-projectile-switch-to-buffer :which-key "switch buffer")
"pr" '(helm-show-kill-ring :which-key "show kill ring")
;; Buffers
"bb" '(helm-mini :which-key "buffers list")
;; Window
"wl" '(windmove-right :which-key "move right")
"wh" '(windmove-left :which-key "move left")
"wk" '(windmove-up :which-key "move up")
"wj" '(windmove-down :which-key "move bottom")
"w/" '(split-window-right :which-key "split right")
"w-" '(split-window-below :which-key "split bottom")
"wx" '(delete-window :which-key "delete window")
"qz" '(delete-frame :which-key "delete frame")
"qq" '(kill-emacs :which-key "quit")
;; NeoTree
"ft" '(neotree-toggle :which-key "toggle neotree")
;; Others
"at" '(ansi-term :which-key "open terminal")
;; Fancy titlebar for MacOS
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(ns-appearance . dark))
(setq ns-use-proxy-icon nil)
(setq frame-title-format nil)
;; Flycheck
(use-package flycheck
:ensure t
:init (global-flycheck-mode))
;; LSP
(use-package lsp-mode
:ensure t
(add-hook 'prog-major-mode #'lsp-prog-major-mode-enable))
(use-package lsp-ui
:ensure t
(add-hook 'lsp-mode-hook 'lsp-ui-mode))
;; Company mode
(use-package company
:ensure t
(setq company-minimum-prefix-length 3)
(setq company-auto-complete nil)
(setq company-idle-delay 0)
(setq company-require-match 'never)
(setq company-frontends
(setq tab-always-indent 'complete)
(defvar completion-at-point-functions-saved nil)
(global-company-mode 1)
(define-key company-active-map (kbd "TAB") 'company-complete-common-or-cycle)
(define-key company-active-map (kbd "<tab>") 'company-complete-common-or-cycle)
(define-key company-active-map (kbd "S-TAB") 'company-select-previous)
(define-key company-active-map (kbd "<backtab>") 'company-select-previous)
(define-key company-mode-map [remap indent-for-tab-command] 'company-indent-for-tab-command)
(defun company-indent-for-tab-command (&optional arg)
(interactive "P")
(let ((completion-at-point-functions-saved completion-at-point-functions)
(completion-at-point-functions '(company-complete-common-wrapper)))
(indent-for-tab-command arg)))
(defun company-complete-common-wrapper ()
(let ((completion-at-point-functions completion-at-point-functions-saved))
(use-package company-lsp
:ensure t
(push 'company-lsp company-backends))
;; Powerline
(use-package spaceline
:ensure t
(setq powerline-default-separator 'slant)
;; Language Supports ;;
;; JavaScript
(use-package js2-mode
:ensure t
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)))
(use-package tern :ensure t)
;; Rust
(use-package rust-mode
:ensure t
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)))
(use-package lsp-rust
:ensure t
(setq lsp-rust-rls-command '("rustup" "run" "nightly" "rls"))
(add-hook 'rust-mode-hook #'lsp-rust-enable)
(add-hook 'rust-mode-hook #'flycheck-mode))
;; Typescript
(use-package typescript-mode
:ensure t
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode)))
;; LSP for JavaScript and TypeScript
(use-package lsp-javascript-typescript
:ensure t
(add-to-list 'js-mode-hook #'lsp-javascript-typescript-enable)
(add-to-list 'typescript-mode-hook #'lsp-javascript-typescript-enable))
;; Auto-generated
Copy link

"pf" '(helm-find-file :which-key "find files") did not work for me.
"pf" '(helm-find-files :which-key "find files") did.

Albeit, I've changed mine to "ff".

Copy link

huytd commented Jul 2, 2018

Yeah, it should be files not file, my bad :D I also switched to helm-projectile-find-file already.

Copy link

curtisault commented Jul 2, 2018

Last night I found out how to increase/decrease font size so i added the following:

"ti"  '(text-scale-increase :which-key "text scale increase")
"td"  '(text-scale-decrease :which-key "text scale decrease")

Copy link

dogayuksel commented Jul 5, 2018

which build of emacs is this?
Version 26.1-2 from emacsformacosx doesn't have ns-use-proxy-icon variable.
And setting frame-title-format nil doesn't work consistently.

Copy link

huytd commented Jul 5, 2018

I use the latest version on brew. Or you can use railwaycat's emacmacport.

Copy link

helm-projectile-find-file seems to take forever. I've even tried to enable caching and that doesn't seem to help. Have you had this experience?

Copy link

huytd commented Jul 30, 2018

How big is your project is? did you try decrease the helm-candidate-number-list?

My config works well with a project has 22982 directories and 123601 files (according to tree)

Copy link

I bumped down the candidate number to 25. However, I switched to using projectile-find-file 👌

This works really fast for me.

Copy link

shackra commented Jul 31, 2018

isn't Tide superseded by lsp-mode and company-lsp?

Copy link

benwtks commented Aug 2, 2018

Which part makes powerline look how it does in

Copy link

ghost commented Aug 2, 2018

I'm getting the error Invalid read syntax: ). Am I doing something wrong? Everything seems to be working just fine! I saved init.el as a raw file and haven't modified it at all.

Copy link

huytd commented Aug 13, 2018

@shackra I didn't try lsp-mode with typescript yet :D

@Watkins it's doom-modeline

@StevenSeiden probably there is an extra paren somewhere, I'll find sometime to fix it

Copy link

huytd commented Aug 16, 2018

@StevenSeiden: problem fixed :D

Copy link

zachschultz commented May 23, 2019

When I try to use "/" '(helm-projectile-rg :which-key "ripgrep" and press SPC-/ in a project and type two chars, I get the error: Error running timer: (error "Candidates function 'helm-rg--make-process' should run a process")

(not sure if you even look at this anymore, but thanks for the guide and config file anyways!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment