Created
July 8, 2020 16:00
-
-
Save midhunkrishna/cc5213f4917688a38a8ae11087bfb179 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Override Emacs Internals | |
(defun smarter-move-beginning-of-line (arg) | |
"In Emacs there are two essential commands when you have to | |
go the beginning of a line - move-beginning-of-line(bound to C-a) | |
and back-to-indentation(bound to M-m). The first takes you to the first | |
column of a line and the latter takes you the first non-whitespace | |
character on a line. | |
Move point back to indentation of beginning of line. | |
Move point to the first non-whitespace character on this line. | |
If point is already there, move to the beginning of the line. | |
Effectively toggle between the first non-whitespace character and | |
the beginning of the line. | |
If ARG is not nil or 1, move forward ARG - 1 lines first. If | |
point reaches the beginning or end of the buffer, stop there." | |
(interactive "^p") | |
(setq arg (or arg 1)) | |
;; Move lines first | |
(when (/= arg 1) | |
(let ((line-move-visual nil)) | |
(forward-line (1- arg)))) | |
(let ((orig-point (point))) | |
(back-to-indentation) | |
(when (= orig-point (point)) | |
(move-beginning-of-line 1)))) | |
;; remap C-a to `smarter-move-beginning-of-line' | |
(global-set-key [remap move-beginning-of-line] | |
'smarter-move-beginning-of-line) | |
;; windmove | |
(global-set-key (kbd "C-c <left>") 'windmove-left) | |
(global-set-key (kbd "C-c <right>") 'windmove-right) | |
(global-set-key (kbd "C-c <up>") 'windmove-up) | |
(global-set-key (kbd "C-c <down>") 'windmove-down) | |
;; Minimal UI | |
(scroll-bar-mode -1) | |
(tool-bar-mode -1) | |
(tooltip-mode -1) | |
(menu-bar-mode -1) | |
(add-to-list 'default-frame-alist '(font . "mononoki-16")) | |
(add-to-list 'default-frame-alist '(height . 24)) | |
(add-to-list 'default-frame-alist '(width . 80)) | |
;; Package configs | |
(require 'package) | |
(setq package-enable-at-startup nil) | |
(setq package-archives '(("org" . "http://orgmode.org/elpa/") | |
("gnu" . "http://elpa.gnu.org/packages/") | |
("melpa" . "https://melpa.org/packages/"))) | |
(package-initialize) | |
;; Bootstrap `use-package` | |
(unless (package-installed-p 'use-package) | |
(package-refresh-contents) | |
(package-install 'use-package)) | |
(require 'use-package) | |
(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. | |
'(package-selected-packages | |
(quote | |
(esh-autosuggest groovy-mode dashboard undo-fu markdown-mode whitespace-cleanup-mode magit exec-path-from-shell smartparens slim-mode enh-ruby-mode doom-modeline json-mode rjsx-mode web-mode drag-stuff multiple-cursors beacon-mode rainbow-mode avy counsel helm neotree all-the-icons projectile which-key doom-themes use-package)))) | |
(custom-set-faces | |
;; 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. | |
) | |
;; Theme | |
(use-package doom-themes | |
:ensure t | |
:config | |
(load-theme 'doom-one t)) | |
;; Ivy | |
(use-package counsel | |
:ensure t | |
:init | |
(global-set-key (kbd "C-x /") 'counsel-rg) | |
(global-set-key (kbd "C-x C-f") 'counsel-find-file) | |
(global-set-key (kbd "C-x C-n") 'counsel-fzf) | |
(global-set-key (kbd "C-s") 'swiper-isearch) | |
(global-set-key (kbd "M-x") 'counsel-M-x) | |
(global-set-key (kbd "M-y") 'counsel-yank-pop) | |
(global-set-key (kbd "C-x b") 'ivy-switch-buffer) | |
(global-set-key (kbd "C-c v") 'ivy-push-view) | |
(global-set-key (kbd "C-c V") 'ivy-pop-view) | |
:config | |
(ivy-mode 1)) | |
;; jump to multiple character | |
(use-package avy | |
:ensure t | |
:init | |
(global-set-key (kbd "C-:") 'avy-goto-char-2) | |
) | |
;; Multiple Cursors | |
(use-package multiple-cursors | |
:ensure t | |
:init | |
(global-set-key (kbd "C->") 'mc/mark-next-like-this) | |
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) | |
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this) | |
) | |
;; drag stuff | |
(use-package drag-stuff | |
:ensure t | |
:config | |
(drag-stuff-mode t) | |
(drag-stuff-global-mode 1) | |
(drag-stuff-define-keys) | |
) | |
;; Which Key | |
(use-package which-key | |
:ensure t | |
:init | |
(setq which-key-separator " ") | |
(setq which-key-prefix-prefix "+") | |
:config | |
(which-key-mode 1)) | |
;; Projectile | |
(use-package projectile | |
:ensure t | |
:config | |
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map) | |
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) | |
(projectile-mode +1)) | |
;; All The Icons | |
(use-package all-the-icons :ensure t) | |
;; NeoTree | |
(use-package neotree | |
:ensure t | |
:init | |
(global-set-key [f8] 'neotree-toggle) | |
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))) | |
(use-package rainbow-mode | |
:ensure t | |
) | |
;; 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) | |
;; Show matching parens | |
(setq show-paren-delay 0) | |
(show-paren-mode 1) | |
;; Load PATH | |
;; - For some reason, this slows down emacs startup | |
;; - Need to debug why that is the case | |
(let ((path (shell-command-to-string "/usr/local/bin/bash --login -c 'echo $PATH'"))) | |
(setenv "PATH" path) | |
(setq exec-path | |
(append | |
(split-string-and-unquote path ":") | |
exec-path))) | |
;; doom mode line | |
(use-package doom-modeline | |
:ensure t | |
:init | |
(doom-modeline-mode 1) | |
) | |
;; Utility line numbers | |
(global-linum-mode 1) | |
;; Utility paranthesis | |
(use-package smartparens | |
:ensure t | |
:config | |
(smartparens-global-mode t) | |
) | |
;; Utility Whitespace cleaning | |
(use-package whitespace-cleanup-mode | |
:ensure t | |
:config | |
(add-hook 'ruby-mode-hook 'whitespace-cleanup-mode) | |
(add-hook 'js-mode-hook 'whitespace-cleanup-mode) | |
(add-hook 'web-mode-hook 'whitespace-cleanup-mode) | |
(add-hook 'markdown-mode-hook 'whitespace-cleanup-mode) | |
) | |
;; Utility Eshell | |
(use-package esh-autosuggest | |
;; :hook (eshell-mode . esh-autosuggest-mode) | |
;; If you have use-package-hook-name-suffix set to nil, uncomment and use the | |
;; line below instead: | |
:hook (eshell-mode-hook . esh-autosuggest-mode) | |
:ensure t) | |
;; Utility Undo | |
(use-package undo-fu | |
:ensure t | |
:config | |
(global-unset-key (kbd "C-z")) | |
(global-set-key (kbd "C-z") 'undo-fu-only-undo) | |
(global-set-key (kbd "C-S-z") 'undo-fu-only-redo) | |
) | |
;; Language Modes | |
(use-package slim-mode | |
:ensure t | |
:config | |
(add-to-list 'auto-mode-alist '("\\.slim$" . slim-mode)) | |
) | |
(use-package enh-ruby-mode | |
:ensure t | |
:init | |
(autoload 'enh-ruby-mode "enh-ruby-mode" "Major mode for ruby files" t) | |
(add-to-list 'auto-mode-alist '("\\.rb$" . enh-ruby-mode)) | |
(add-to-list 'interpreter-mode-alist '("ruby" . enh-ruby-mode)) | |
) | |
(use-package json-mode | |
:ensure t | |
) | |
(use-package rjsx-mode | |
:ensure t | |
:init | |
(add-to-list 'auto-mode-alist '("\\.js\\'" . rjsx-mode)) | |
) | |
(use-package web-mode | |
:ensure t | |
:init | |
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) | |
) | |
(use-package markdown-mode | |
:ensure t | |
:commands (markdown-mode gfm-mode) | |
:mode (("README\\.md\\'" . gfm-mode) | |
("\\.md\\'" . markdown-mode) | |
("\\.markdown\\'" . markdown-mode)) | |
:init (setq markdown-command "multimarkdown")) | |
(use-package groovy-mode | |
:ensure t | |
) | |
;; Git Porcelain | |
(use-package magit | |
:ensure t | |
) | |
;; Custom Set Variables | |
(setq counsel-async-filter-update-time 100000) | |
(setq js-indent-level 2) | |
(setq ring-bell-function 'ignore) ;; disable bells | |
(setq make-backup-files nil) ;; disable backup files | |
(setq inhibit-startup-screen t) ;; Do not show startup screen | |
(setq explicit-shell-file-name "/usr/local/bin/bash") ;; default program ansi term | |
;; env | |
(setenv "FZF_DEFAULT_COMMAND" | |
"fd --type file --follow --hidden --exclude .git --exclude node_modules") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment