From 908f2ad3c9a52240b93bd0ba79394fc959d9deb8 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Mon, 18 Feb 2019 23:04:46 +0530 Subject: [PATCH] init.el: Update emacs configuration Nuke LSP. That shit does not work. Signed-off-by: Sanchayan Maity --- init.el | 297 ++++++++++++++++++++++++++------------------------------ 1 file changed, 138 insertions(+), 159 deletions(-) diff --git a/init.el b/init.el index 4a1dca6..89c6ec5 100644 --- a/init.el +++ b/init.el @@ -1,32 +1,11 @@ ;;; init.el --- Initialization file for emacs ;;; Commentary: Emacs startup file --- initialization file for emacs -(require 'package) +(setq + custom-file (concat user-emacs-directory ".emacs-customize.el") + require-final-newline t) -(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) - -;; 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))) - ad-do-it - (kill-buffer buffer)) - ad-do-it)) -(ad-activate 'term-sentinel) - -(defadvice ansi-term (before force-bash) - (interactive (list "/usr/bin/fish"))) -(ad-activate 'ansi-term) +;; Track emacs load time +(defconst emacs-start-time (current-time)) ;; Other configs (setq make-backup-files nil) @@ -39,46 +18,44 @@ ;; 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"))) +(electric-pair-mode 1) ;; UI configurations (if (display-graphic-p) (progn (tool-bar-mode -1) - (scroll-bar-mode -1) - ) - ) -(tooltip-mode -1) -(menu-bar-mode -1) + (scroll-bar-mode -1))) +(tooltip-mode -1) +(menu-bar-mode -1) (global-linum-mode 1) +;; Font configurations (add-to-list 'default-frame-alist '(font . "Iosevka-14")) (add-to-list 'default-frame-alist '(height . 24)) (add-to-list 'default-frame-alist '(width . 80)) -;; Vim mode -(use-package evil - :ensure t - :config - (evil-mode 1)) +;;; Package Management +(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)) +(eval-when-compile + (require 'use-package)) + +;; always download all packages if not already downloaded +(setq use-package-always-ensure t) +;; keep stats about packages +(setq use-package-compute-statistics t) +; no longer included with use-package by default +(use-package diminish) (use-package auto-package-update :ensure t :config @@ -86,6 +63,45 @@ auto-package-update-interval 4) (auto-package-update-maybe)) +;; Restart emacs from within emacs +(use-package restart-emacs + :ensure t) + +;; Theme +(use-package doom-themes + :ensure t + :config + (load-theme 'doom-molokai t)) + +;; Auto enforced consistence +(use-package editorconfig + :diminish "↹" + :init + (setq auto-mode-alist + (cl-union auto-mode-alist + '(("\\.editorconfig\\'" . editorconfig-conf-mode) + ("editorconfig\\'" . editorconfig-conf-mode)))) + :config + (editorconfig-mode 1)) + +(use-package smartparens + :hook ((prog-mode-hook) . smartparens-mode) + :config + (require 'smartparens-config)) + +(use-package aggressive-indent + :diminish "⇉" + :config + (global-aggressive-indent-mode t)) + +(use-package fzf + :ensure t) + +;; Vim mode +(use-package evil + :ensure t + :config + (evil-mode 1)) (use-package evil-escape :ensure t :init @@ -103,12 +119,6 @@ (global-set-key [remap query-replace] 'anzu-query-replace)) -;; Theme -(use-package doom-themes - :ensure t - :config - (load-theme 'doom-molokai t)) - ;; Helm (use-package helm :ensure t @@ -129,10 +139,8 @@ helm-autoresize-min-height 20) :config (helm-mode 1)) - ;; RipGrep (use-package helm-rg :ensure t) - ;; Projectile (use-package projectile :ensure t @@ -140,7 +148,6 @@ (setq projectile-require-project-root nil) :config (projectile-mode 1)) - ;; Helm Projectile (use-package helm-projectile :ensure t @@ -148,7 +155,6 @@ (setq helm-projectile-fuzzy-match t) :config (helm-projectile-on)) - ;; Helm Gtags (use-package helm-gtags :defer t @@ -161,16 +167,17 @@ helm-gtags-use-input-at-cursor t helm-gtags-pulse-at-cursor t) (add-hook 'c-mode-hook 'helm-gtags-mode))) +(defun helm-gtags-dwim-other-window () + ;; Enable helm-gtags-dwim in the other window + (interactive) + (let ((helm-gtags--use-otherwin t) + (split-height-threshold nil) + (split-width-threshold 140)) + (helm-gtags-dwim))) ;; All The Icons (use-package all-the-icons :ensure t) -;; NeoTree -(use-package neotree - :ensure t - :init - (setq neo-theme (if (display-graphic-p) 'icons 'arrow))) - ;; Which Key (use-package which-key :ensure t @@ -180,47 +187,6 @@ :config (which-key-mode)) -;; Restart emacs from within emacs -(use-package restart-emacs - :ensure t) - -;; For Haskell & Rust Support -(use-package haskell-mode - :ensure t - :custom - (haskell-stylish-on-save t) - (haskell-process-suggest-remove-import-lines t)) -(use-package lsp-mode - :ensure t - :commands lsp) -(use-package lsp-ui - :ensure t - :after lsp-mode - :hook - ((lsp-mode . lsp-ui-mode) - (lsp-ui-mode . lsp-ui-peek-mode) - (haskell-mode . lsp-haskell-enable) - (haskell-mode . flycheck-mode) - (rust-mode . lsp-rust-enable) - (rust-mode . flycheck-mode) - (python-mode . lsp-python-enable) - (python-mode . flycheck-mode) - )) -(use-package company-lsp - :commands company-lsp - :config - (push 'company-lsp company-backends)) - -(use-package lsp-haskell - :defer t - :ensure t - :config - (setq lsp-haskell-process-path-hie "hie-wrapper")) - -(use-package rust-mode - :defer t - :ensure t) - ;; Git Support (use-package magit :defer t @@ -252,6 +218,15 @@ ;; Custom keybinding (use-package general :ensure t + :init + (setq general-override-states '(insert + emacs + hybrid + normal + visual + motion + operator + replace)) :config (general-define-key :states '(normal visual insert emacs) :prefix "SPC" @@ -261,6 +236,7 @@ "TAB" '(switch-to-prev-buffer :which-key "previous buffer") "SPC" '(helm-M-x :which-key "M-x") + "ff" '(fzf :which-key "fuzzy file search") "pf" '(helm-projectile-find-file :which-key "find files") "pp" '(helm-projectile-switch-project @@ -282,8 +258,6 @@ "qz" '(delete-frame :which-key "delete frame") "qq" '(kill-emacs :which-key "quit") "qr" '(restart-emacs :which-key "restart emacs") - ;; NeoTree - "ft" '(neotree-toggle :which-key "toggle neotree") ;; Others "at" '(ansi-term :which-key "open terminal") ;; Gtags @@ -329,8 +303,8 @@ "gU" '(magit-unstage-file "magit unstage file") "g/" '(helm-git-grep :which-key "open helm git grep") "g*" '(helm-git-grep-at-point - :which-key "open helm git grep at point") - )) + :which-key "open helm git grep at point"))) + ;; Fancy titlebar for MacOS (add-to-list 'default-frame-alist '(ns-transparent-titlebar . t)) @@ -348,7 +322,9 @@ ;; Company mode (use-package company :ensure t + :diminish "⇥" :init + (add-hook 'after-init-hook 'global-company-mode) (setq company-minimum-prefix-length 3) (setq company-auto-complete nil) (setq company-idle-delay 0) @@ -376,9 +352,13 @@ (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)) - (company-complete-common)))) + (defun company-complete-common-wrapper () + (let ((completion-at-point-functions completion-at-point-functions-saved)) + (company-complete-common)))) + +(use-package company-quickhelp + :init + (company-quickhelp-mode 1)) ;; Powerline (use-package spaceline @@ -391,47 +371,46 @@ (spaceline-toggle-buffer-size-off) (spaceline-toggle-evil-state-on)) -;;;;;;;;;;;;;;;;;;;;;;; -;; Language Supports ;; -;;;;;;;;;;;;;;;;;;;;;;; +;; Language Support +(use-package company-ghci + :defer t + :config + (push 'haskell-mode-hook 'company-mode) + :hook + ((haskell-interactive-mode . company-mode))) +(use-package haskell-mode + :defer t + :config + (push 'company-ghci company-backends) + :hook + ((haskell-mode . hindent-mode) + (haskell-mode . company-mode)) + :custom + ((haskell-stylish-on-save t) + (haskell-process-suggest-remove-import-lines t))) +(use-package flycheck-haskell + :defer t + :hook + (haskell-mode . flycheck-haskell-setup)) +(use-package intero + :defer t + :config + (intero-global-mode 1)) +(use-package hindent + :defer t) +(use-package hlint-refactor + :defer t) -;;; C -(defun c-lineup-arglist-tabs-only (ignored) - "Line up argument lists by tabs, not spaces" - (let* ((anchor (c-langelem-pos c-syntactic-element)) - (column (c-langelem-2nd-pos c-syntactic-element)) - (offset (- (1+ column) anchor)) - (steps (floor offset c-basic-offset))) - (* (max steps 1) - c-basic-offset))) - -(add-hook 'c-mode-common-hook - (lambda () - ;; Add kernel style - (c-add-style - "linux-tabs-only" - '("linux" (c-offsets-alist - (arglist-cont-nonempty - c-lineup-gcc-asm-reg - c-lineup-arglist-tabs-only)))))) - -(add-hook 'c-mode-hook - (lambda () - (let ((filename (buffer-file-name))) - ;; Enable kernel mode for the appropriate files - (when (and filename - (string-match (expand-file-name "~/ged4k/linux-xlnx") - filename)) - (setq indent-tabs-mode t) - (setq show-trailing-whitespace t) - (c-set-style "linux-tabs-only"))))) - -(defun helm-gtags-dwim-other-window () - ;; Enable helm-gtags-dwim in the other window - (interactive) - (let ((helm-gtags--use-otherwin t) - (split-height-threshold nil) - (split-width-threshold 140)) - (helm-gtags-dwim))) +(use-package rust-mode + :defer t + :ensure t + :config + (setq rust-format-on-save t)) +(use-package racer + :ensure t + :hook + ((rust-mode . racer-mode) + (racer-mode . eldoc-mode) + (racer-mode . company-mode))) ;;; init.el ends