init.el: Update emacs configuration

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2019-02-21 13:10:57 +05:30
parent 40a2db43ff
commit 61abe49789

121
init.el
View file

@ -40,7 +40,8 @@
(setq package-archives
'(("org" . "http://orgmode.org/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
("melpa" . "https://melpa.org/packages/")
("local" . ,(expand-file-name "~/spacelpa/packages/"))))
(package-initialize)
;; Bootstrap `use-package`
@ -60,7 +61,7 @@
:ensure t
:config
(setq auto-package-update-delete-old-versions t
auto-package-update-interval 4)
auto-package-update-interval 14)
(auto-package-update-maybe))
;; Restart emacs from within emacs
@ -167,13 +168,6 @@
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)
@ -287,24 +281,95 @@
:which-key "show stack of visited locations")
"mgu" '(helm-gtags-update-tags
:which-key "create tag db")
;; Git key bindings
"gc" '(magit-clone :which-key "magit clone")
"gff" '(magit-find-file :which-key "magit find file")
;; Magit key bindings
"gc" '(magit-clone
:which-key "magit clone")
"gff" '(magit-find-file
:which-key "magit find file")
"gfl" '(magit-log-buffer-file
:which-key "magit log buffer file")
"gfd" '(magit-diff-buffer-file-popup
:which-key "magit diff buffer file popup")
"gi" '(magit-init :which-key "magit initialize")
"gi" '(magit-init
:which-key "magit initialize")
"gL" '(magit-list-repositories
:which-key "magit list repositories")
"gm" '(magit-dispatch-popup "magit dispatch popup")
"gs" '(magit-status "open Magit status buffer")
"gS" '(magit-stage-file "magit stage file")
"gU" '(magit-unstage-file "magit unstage file")
"g/" '(helm-git-grep :which-key "open helm git grep")
"gm" '(magit-dispatch-popup
:which-key "magit dispatch popup")
"gs" '(magit-status
:which-key "open Magit status buffer")
"gS" '(magit-stage-file
:which-key "magit stage file")
"gU" '(magit-unstage-file
:which-key "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")
;; Haskell bindings
"mf" '(hindent-reformat-decl
:which-key "format declaration using hindent")
"mF" '(haskell-mode-stylish-buffer
:which-key "format buffer using haskell stylish")
"mgg" '(intero-goto-definition
:which-key "goto definition or tag")
"mhi" '(intero-info
:which-key "get info for identifier under cursor")
"mht" '(intero-type-at
:which-key "get type of identifier under cursor")
"mrs" '(intero-apply-suggestions)
"msb" '(intero-repl-load
:which-key "load/reload current buffer in repl")
"mic" '(intero-cd
:which-key "change directory in backend process")
"mid" '(intero-devel-reload
:which-key "reload module DevelMain")
"mik" '(intero-destroy
:which-key "stop current process & kill its associated")
"mil" '(intero-list-buffers
:which-key "list hidden process buffers created")
"mir" '(intero-restart
:which-key "restart process with same config")
"mit" '(intero-targets
:which-key "set targets to use for stack ghci")
"msc" nil
"mhT" '(haskell-intero/insert-type)
"mss" '(haskell-intero/display-repl
:which-key "show repl without switching")
"msS" '(haskell-intero/pop-to-repl
:which-key "show and switch to repl")
"mrb" '(hlint-refactor-refactor-buffer
:which-key "apply all hlint suggestions")
"mrr" '(hlint-refactor-refactor-at-point
:which-key "apply hlint suggestion under cursor")))
;; custom functions
(defun haskell-intero/insert-type ()
(interactive)
(intero-type-at :insert))
(defun haskell-intero/display-repl (&optional prompt-options)
(interactive "P")
(let ((buffer (intero-repl-buffer prompt-options)))
(unless (get-buffer-window buffer 'visible)
(display-buffer buffer))))
(defun haskell-intero/pop-to-repl (&optional prompt-options)
(interactive "P")
(pop-to-buffer (intero-repl-buffer prompt-options)))
(defun haskell-intero//preserve-focus (f &rest args)
(let ((buffer (current-buffer)))
(apply f args)
(pop-to-buffer buffer)))
(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)))
;; Fancy titlebar for MacOS
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
@ -375,27 +440,27 @@
(use-package company-ghci
:defer t
:config
(push 'haskell-mode-hook 'company-mode)
(push 'company-ghci company-backends)
:hook
((haskell-interactive-mode . company-mode)))
((haskell-mode . company-mode)
(haskell-interactive-mode . company-mode)))
(use-package haskell-mode
:defer t
:init
(electric-indent-mode 0)
:config
(push 'company-ghci company-backends)
:hook
((haskell-mode . hindent-mode)
(haskell-mode . company-mode))
(haskell-mode . company-mode)
(haskell-mode . interactive-haskell-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))
:hook
(haskell-mode . intero-mode))
(use-package hindent
:defer t)
(use-package hlint-refactor