Skip to content

Latest commit

 

History

History
282 lines (272 loc) · 8.03 KB

configuration.archive.org

File metadata and controls

282 lines (272 loc) · 8.03 KB

#+TITLE Configuration

Initial package installation

Setup remote package sources

(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)
;(package-refresh-contents)

Install use-package if not present

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

*

Define desired packages in alphabetical order

(use-package all-the-icons :ensure t :config
  (use-package all-the-icons-dired :ensure t :config
    (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
  )
)
(use-package company :ensure t :config
  (use-package company-quickhelp :ensure t)
  (global-company-mode)
  (company-quickhelp-mode)
)
(use-package evil
  :ensure t
  :init
    (setq evil-want-keybinding nil)
  :config
    (evil-mode 1))
(use-package evil-collection :after evil :ensure t :config
  (setq evil-collection-company-use-tng nil)
  (evil-collection-init)
)
(use-package evil-matchit :ensure t)
(use-package evil-surround :ensure t :config (global-evil-surround-mode 1))
(use-package flycheck :ensure t :config
  (global-flycheck-mode)
)
(use-package hcl-mode :ensure t :mode "\\.tf\\'")
(use-package helm :ensure t :config
  (use-package helm-company :ensure t)
  (use-package helm-projectile :ensure t)
  (helm-mode)
)
(use-package inf-ruby :ensure t :mode "\\.rb\\'" :config
  (autoload 'inf-ruby-minor-mode "inf-ruby" "Run an inferior Ruby process" t)
  (add-hook 'enh-ruby-mode-hook 'inf-ruby-minor-mode)
)
(use-package lsp-mode :ensure t
  :hook (prog-mode . lsp)
  :config
  (use-package lsp-ui :ensure t :config
    (setq lsp-prefer-flymake nil)
    (add-hook 'lsp-mode-hook 'lsp-ui-mode)
  )
  (use-package company-lsp :ensure t :config
    (push 'company-lsp company-backends)
  )
)
(use-package magit :ensure t)
(use-package markdown-mode :mode "\\.md\\'" :ensure t)
(use-package monokai-theme :ensure t :config
  (load-theme 'monokai t)
)
(use-package projectile :ensure t :config
  (projectile-mode)
)
(use-package rainbow-delimiters :ensure t :config
  (add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
)
(use-package rg :ensure t)
(use-package robe :mode "\\.rb\\'" :ensure t :config
  (add-hook 'enh-ruby-mode-hook 'robe-mode)
  (push 'company-robe company-backends)
)
(use-package spaceline :ensure t :config
  (spaceline-emacs-theme)
  (spaceline-helm-mode)
)
(use-package tide :ensure t
  :after (typescript-mode company flycheck)
  :hook (
    (typescript-mode . tide-setup)
    (typescript-mode . tide-hl-identifier-mode)
    (before-save . tide-format-before-save)
  )
)
(use-package web-mode :defer t :ensure t :config
  (add-to-list 'auto-mode-alist '("\\.js[x]\\'" . web-mode))
  (setq web-mode-content-types-alist '(("jsx" . "\\.js[x]?\\'")))
)
(use-package writegood-mode :ensure t)
(use-package yaml-mode :mode "\\.yml\\'" :ensure t)
(use-package yasnippet :ensure t)
(use-package enh-ruby-mode :mode "\\.rb\\'" :ensure t :config
    (add-to-list 'auto-mode-alist
		 '("\\(?:\\.rb\\|ru\\|rake\\|thor\\|jbuilder\\|gemspec\\|podspec\\|/\\(?:Gem\\|Rake\\|Cap\\|Thor\\|Vagrant\\|Guard\\|Pod\\)file\\)\\'" . enh-ruby-mode))
)

Utility functions

Behavior configuration

Initial server

(require 'server)
(unless (server-running-p) (server-start))

Temp file taming

(setq
   backup-by-copying t      ; don't clobber symlinks
   backup-directory-alist
    '(("." . "~/.emacs_saves"))    ; don't litter my fs tree
   delete-old-versions t
   kept-new-versions 6
   kept-old-versions 2
   version-control t)       ; use versioned backups

Row and column visualization

(global-hl-line-mode)

Tab taming

(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq-default tab-stop-list (number-sequence 2 120 2))
(setq-default js-indent-level 2)
(setq web-mode-markup-indent-offset 2)
(setq ruby-deep-indent-paren nil)

Projectile

(setq projectile-enable-caching t)

Scroll bars

(scroll-bar-mode -1)

Menu bars

(menu-bar-mode -1)

Org Mode

(setq org-src-fontify-natively t)
(setq org-directory "~/Dropbox/Documents/Notes")
(setq org-default-notes-file (concat org-directory "capture.org"))

Dired taming

(put 'dired-find-alternate-file 'disabled nil)
(add-hook 'dired-mode-hook (lambda () (dired-hide-details-mode 1)))

Disable blink

'(blink-cursor-mode nil)

Wrap on full words

(global-visual-line-mode t)

RSpec mode

(setq-default rspec-use-chruby t)

Remove trailing whitespace

(add-hook 'before-save-hook 'delete-trailing-whitespace)

Always refresh buffers

(global-auto-revert-mode t)

Open files directly from symlinks

(setq vc-follow-symlinks t)

Change yes-no to y-n

(defalias 'yes-or-no-p 'y-or-n-p)

Turn off downcasing from company

(setq-default company-dabbrev-downcase nil)
(setq-default company-dabbrev-ignore-case t)
(setq-default company-dabbrev-code-ignore-case t)
(setq-default company-irony-ignore-case 'smart)
(setq completion-ignore-case 1)

Company accept autocomplete on keypress

(setq-default company-auto-complete t)

Company delay before auto complete

(setq-default company-idle-delay 0.1)

Line numbers

(setq-default display-line-numbers (quote relative))
(add-hook 'prog-mode-hook #'display-line-numbers-mode)

clangd results limit

(setq-default lsp-clients-clangd-args (quote ("-limit-results=15")))

Evil

Config

(setq-default evil-shift-width 2)

Bindings

General

(define-key evil-normal-state-map (kbd "C-u") 'evil-scroll-up)
(evil-define-minor-mode-key 'normal 'robe-mode "C-:" 'robe-jump)

Helm

(evil-ex-define-cmd "bls" 'helm-buffers-list)
(evil-ex-define-cmd "[me]ta" 'helm-M-x)
(define-key evil-insert-state-map (kbd "C-k") 'helm-company)
(define-key evil-normal-state-map (kbd "C-j") 'helm-buffers-list)
(global-set-key (kbd "M-x") 'helm-M-x)

Magit

(evil-ex-define-cmd "[Gp]ush" 'magit-push-implicitly)
(evil-ex-define-cmd "[Gs]tatus" 'magit-status)
(evil-ex-define-cmd "[Gc]ommit" 'magit-commit)

Projectile

(evil-ex-define-cmd "ff" 'helm-projectile)
(evil-ex-define-cmd "prg" 'rg-project)

Leader setup

(defvar ro/leader-map (make-sparse-keymap))
(define-key evil-normal-state-map (kbd "SPC") ro/leader-map)
(define-key ro/leader-map (kbd "b") 'helm-buffers-list)
(define-key ro/leader-map (kbd "f") 'helm-projectile)
(define-key ro/leader-map (kbd "w") 'save-buffer)

Major mode disable

(evil-set-initial-state 'artist-mode 'emacs)

OS-specific configuration

(when (eq system-type 'darwin)
  (set-face-attribute 'default nil :family "Inconsolata")
  (set-face-attribute 'default nil :height 240)
)

(when (eq system-type 'windows-nt)
  (set-face-attribute 'default nil :family "Consolas")
  (set-face-attribute 'default nil :height 180)
  (setq markdown-command "pandoc")
)

(when (eq system-type 'gnu/linux)
  (set-face-attribute 'default nil :height 180)
)