init.el: Update emacs configuration

Nuke LSP. That shit does not work.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2019-02-18 23:04:46 +05:30
parent 988222400d
commit 908f2ad3c9

297
init.el
View file

@ -1,32 +1,11 @@
;;; init.el --- Initialization file for emacs ;;; init.el --- Initialization file for emacs
;;; Commentary: Emacs startup file --- 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) ;; Track emacs load time
(setq package-archives (defconst emacs-start-time (current-time))
'(("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)
;; Other configs ;; Other configs
(setq make-backup-files nil) (setq make-backup-files nil)
@ -39,46 +18,44 @@
;; Show matching parens ;; Show matching parens
(setq show-paren-delay 0) (setq show-paren-delay 0)
(show-paren-mode 1) (show-paren-mode 1)
(electric-pair-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 ;; UI configurations
(if (display-graphic-p) (if (display-graphic-p)
(progn (progn
(tool-bar-mode -1) (tool-bar-mode -1)
(scroll-bar-mode -1) (scroll-bar-mode -1)))
) (tooltip-mode -1)
) (menu-bar-mode -1)
(tooltip-mode -1)
(menu-bar-mode -1)
(global-linum-mode 1) (global-linum-mode 1)
;; Font configurations
(add-to-list 'default-frame-alist '(font . "Iosevka-14")) (add-to-list 'default-frame-alist '(font . "Iosevka-14"))
(add-to-list 'default-frame-alist '(height . 24)) (add-to-list 'default-frame-alist '(height . 24))
(add-to-list 'default-frame-alist '(width . 80)) (add-to-list 'default-frame-alist '(width . 80))
;; Vim mode ;;; Package Management
(use-package evil (require 'package)
:ensure t (setq package-enable-at-startup nil)
:config (setq package-archives
(evil-mode 1)) '(("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 (use-package auto-package-update
:ensure t :ensure t
:config :config
@ -86,6 +63,45 @@
auto-package-update-interval 4) auto-package-update-interval 4)
(auto-package-update-maybe)) (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 (use-package evil-escape
:ensure t :ensure t
:init :init
@ -103,12 +119,6 @@
(global-set-key [remap query-replace] (global-set-key [remap query-replace]
'anzu-query-replace)) 'anzu-query-replace))
;; Theme
(use-package doom-themes
:ensure t
:config
(load-theme 'doom-molokai t))
;; Helm ;; Helm
(use-package helm (use-package helm
:ensure t :ensure t
@ -129,10 +139,8 @@
helm-autoresize-min-height 20) helm-autoresize-min-height 20)
:config :config
(helm-mode 1)) (helm-mode 1))
;; RipGrep ;; RipGrep
(use-package helm-rg :ensure t) (use-package helm-rg :ensure t)
;; Projectile ;; Projectile
(use-package projectile (use-package projectile
:ensure t :ensure t
@ -140,7 +148,6 @@
(setq projectile-require-project-root nil) (setq projectile-require-project-root nil)
:config :config
(projectile-mode 1)) (projectile-mode 1))
;; Helm Projectile ;; Helm Projectile
(use-package helm-projectile (use-package helm-projectile
:ensure t :ensure t
@ -148,7 +155,6 @@
(setq helm-projectile-fuzzy-match t) (setq helm-projectile-fuzzy-match t)
:config :config
(helm-projectile-on)) (helm-projectile-on))
;; Helm Gtags ;; Helm Gtags
(use-package helm-gtags (use-package helm-gtags
:defer t :defer t
@ -161,16 +167,17 @@
helm-gtags-use-input-at-cursor t helm-gtags-use-input-at-cursor t
helm-gtags-pulse-at-cursor t) helm-gtags-pulse-at-cursor t)
(add-hook 'c-mode-hook 'helm-gtags-mode))) (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 ;; All The Icons
(use-package all-the-icons :ensure t) (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 ;; Which Key
(use-package which-key (use-package which-key
:ensure t :ensure t
@ -180,47 +187,6 @@
:config :config
(which-key-mode)) (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 ;; Git Support
(use-package magit (use-package magit
:defer t :defer t
@ -252,6 +218,15 @@
;; Custom keybinding ;; Custom keybinding
(use-package general (use-package general
:ensure t :ensure t
:init
(setq general-override-states '(insert
emacs
hybrid
normal
visual
motion
operator
replace))
:config (general-define-key :config (general-define-key
:states '(normal visual insert emacs) :states '(normal visual insert emacs)
:prefix "SPC" :prefix "SPC"
@ -261,6 +236,7 @@
"TAB" '(switch-to-prev-buffer "TAB" '(switch-to-prev-buffer
:which-key "previous buffer") :which-key "previous buffer")
"SPC" '(helm-M-x :which-key "M-x") "SPC" '(helm-M-x :which-key "M-x")
"ff" '(fzf :which-key "fuzzy file search")
"pf" '(helm-projectile-find-file "pf" '(helm-projectile-find-file
:which-key "find files") :which-key "find files")
"pp" '(helm-projectile-switch-project "pp" '(helm-projectile-switch-project
@ -282,8 +258,6 @@
"qz" '(delete-frame :which-key "delete frame") "qz" '(delete-frame :which-key "delete frame")
"qq" '(kill-emacs :which-key "quit") "qq" '(kill-emacs :which-key "quit")
"qr" '(restart-emacs :which-key "restart emacs") "qr" '(restart-emacs :which-key "restart emacs")
;; NeoTree
"ft" '(neotree-toggle :which-key "toggle neotree")
;; Others ;; Others
"at" '(ansi-term :which-key "open terminal") "at" '(ansi-term :which-key "open terminal")
;; Gtags ;; Gtags
@ -329,8 +303,8 @@
"gU" '(magit-unstage-file "magit unstage file") "gU" '(magit-unstage-file "magit unstage file")
"g/" '(helm-git-grep :which-key "open helm git grep") "g/" '(helm-git-grep :which-key "open helm git grep")
"g*" '(helm-git-grep-at-point "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 ;; Fancy titlebar for MacOS
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t)) (add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
@ -348,7 +322,9 @@
;; Company mode ;; Company mode
(use-package company (use-package company
:ensure t :ensure t
:diminish ""
:init :init
(add-hook 'after-init-hook 'global-company-mode)
(setq company-minimum-prefix-length 3) (setq company-minimum-prefix-length 3)
(setq company-auto-complete nil) (setq company-auto-complete nil)
(setq company-idle-delay 0) (setq company-idle-delay 0)
@ -376,9 +352,13 @@
(completion-at-point-functions '(company-complete-common-wrapper))) (completion-at-point-functions '(company-complete-common-wrapper)))
(indent-for-tab-command arg))) (indent-for-tab-command arg)))
(defun company-complete-common-wrapper () (defun company-complete-common-wrapper ()
(let ((completion-at-point-functions completion-at-point-functions-saved)) (let ((completion-at-point-functions completion-at-point-functions-saved))
(company-complete-common)))) (company-complete-common))))
(use-package company-quickhelp
:init
(company-quickhelp-mode 1))
;; Powerline ;; Powerline
(use-package spaceline (use-package spaceline
@ -391,47 +371,46 @@
(spaceline-toggle-buffer-size-off) (spaceline-toggle-buffer-size-off)
(spaceline-toggle-evil-state-on)) (spaceline-toggle-evil-state-on))
;;;;;;;;;;;;;;;;;;;;;;; ;; Language Support
;; Language Supports ;; (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 (use-package rust-mode
(defun c-lineup-arglist-tabs-only (ignored) :defer t
"Line up argument lists by tabs, not spaces" :ensure t
(let* ((anchor (c-langelem-pos c-syntactic-element)) :config
(column (c-langelem-2nd-pos c-syntactic-element)) (setq rust-format-on-save t))
(offset (- (1+ column) anchor)) (use-package racer
(steps (floor offset c-basic-offset))) :ensure t
(* (max steps 1) :hook
c-basic-offset))) ((rust-mode . racer-mode)
(racer-mode . eldoc-mode)
(add-hook 'c-mode-common-hook (racer-mode . company-mode)))
(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)))
;;; init.el ends ;;; init.el ends