2015-07-08 17:59:42 +01:00
|
|
|
;; Functions -------------------------------------------------
|
2016-11-28 11:06:35 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun disable-projectile ()
|
|
|
|
(interactive)
|
|
|
|
(projectile-global-mode nil))
|
2015-07-08 17:59:42 +01:00
|
|
|
|
|
|
|
;; Quick fix for company-mode and yasnippet clashing
|
|
|
|
(defun company-yasnippet-or-completion ()
|
|
|
|
(interactive)
|
|
|
|
(if (yas/expansion-at-point)
|
|
|
|
(progn (company-abort)
|
|
|
|
(yas/expand))
|
|
|
|
(company-complete-common)))
|
|
|
|
|
|
|
|
(defun yas/expansion-at-point ()
|
|
|
|
"Tested with v0.6.1. Extracted from `yas/expand-1'"
|
|
|
|
(first (yas/current-key)))
|
|
|
|
|
2015-09-24 14:51:21 +01:00
|
|
|
|
|
|
|
(defun eval-and-replace ()
|
|
|
|
"Replace the preceding sexp with its value."
|
|
|
|
(interactive)
|
|
|
|
(backward-kill-sexp)
|
|
|
|
(condition-case nil
|
|
|
|
(prin1 (eval (read (current-kill 0)))
|
|
|
|
(current-buffer))
|
|
|
|
(error (message "Invalid expression")
|
|
|
|
(insert (current-kill 0)))))
|
|
|
|
|
2016-11-21 08:19:35 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun enable-pt-search ()
|
|
|
|
(interactive)
|
|
|
|
(define-key projectile-mode-map (kbd "C-c p s s") 'projectile-pt)
|
|
|
|
(define-key projectile-mode-map (kbd "C-c p s r") 'pt-regexp))
|
|
|
|
|
2016-11-21 09:00:18 +00:00
|
|
|
|
2015-07-08 17:59:42 +01:00
|
|
|
;;;###autoload
|
|
|
|
(defun extension/development-initialize ()
|
|
|
|
"Development plugin initialization."
|
|
|
|
(message "Initializing 'development' extension.")
|
|
|
|
|
2018-03-19 15:11:59 +00:00
|
|
|
(ability project-config ()
|
|
|
|
"Makes projects configurable."
|
2018-03-21 20:59:39 +00:00
|
|
|
(require 'projects/configuration))
|
2018-03-19 15:11:59 +00:00
|
|
|
|
2016-11-21 10:44:37 +00:00
|
|
|
(ability bookmarks ()
|
2018-10-19 20:18:41 +01:00
|
|
|
|
2016-11-21 10:44:37 +00:00
|
|
|
(require 'bm)
|
|
|
|
|
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "M-p"
|
|
|
|
:description "Toggle bookmarks")
|
|
|
|
|
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "M-]"
|
|
|
|
:description "Jump to next bookmark")
|
|
|
|
|
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "M-["
|
|
|
|
:description "Jump to previous bookmark")
|
|
|
|
|
|
|
|
(global-set-key (kbd "M-p") 'bm-toggle)
|
2016-11-21 12:50:25 +00:00
|
|
|
(global-set-key (kbd "M-]") 'bm-next)
|
2016-11-21 10:44:37 +00:00
|
|
|
(global-set-key (kbd "M-[") 'bm-previous)
|
|
|
|
|
2018-10-19 20:18:41 +01:00
|
|
|
(setq bm-restore-repository-on-load t)
|
2016-11-21 10:44:37 +00:00
|
|
|
(setq bm-in-lifo-order t)
|
2016-11-21 11:41:20 +00:00
|
|
|
(setq bm-cycle-all-buffers t)
|
|
|
|
(setq-default bm-buffer-persistence t)
|
2018-10-19 20:18:41 +01:00
|
|
|
|
2016-11-21 11:41:20 +00:00
|
|
|
(setq bm-repository-file (locate-user-emacs-file "bm-repository"))
|
2018-10-19 20:18:41 +01:00
|
|
|
(add-hook' after-init-hook 'bm-repository-load)
|
|
|
|
(add-hook 'kill-buffer-hook #'bm-buffer-save)
|
|
|
|
;; Restoring bookmarks
|
|
|
|
(add-hook 'find-file-hooks #'bm-buffer-restore)
|
|
|
|
(add-hook 'after-revert-hook #'bm-buffer-restore)
|
|
|
|
|
|
|
|
;; The `after-revert-hook' is not necessary to use to achieve persistence,
|
|
|
|
;; but it makes the bookmark data in repository more in sync with the file
|
|
|
|
;; state. This hook might cause trouble when using packages
|
|
|
|
;; that automatically reverts the buffer (like vc after a check-in).
|
|
|
|
;; This can easily be avoided if the package provides a hook that is
|
|
|
|
;; called before the buffer is reverted (like `vc-before-checkin-hook').
|
|
|
|
;; Then new bookmarks can be saved before the buffer is reverted.
|
|
|
|
;; Make sure bookmarks is saved before check-in (and revert-buffer)
|
|
|
|
(add-hook 'vc-before-checkin-hook #'bm-buffer-save)
|
2016-11-21 11:41:20 +00:00
|
|
|
(add-hook 'kill-emacs-hook '(lambda nil
|
|
|
|
(bm-buffer-save-all)
|
|
|
|
(bm-repository-save))))
|
2016-11-21 10:44:37 +00:00
|
|
|
|
2018-04-26 19:51:58 +01:00
|
|
|
(ability imenu ()
|
|
|
|
"IMenu integration for FG42"
|
|
|
|
(require 'imenu)
|
|
|
|
(require 'imenu-list)
|
|
|
|
|
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "C-'"
|
|
|
|
:description "Toggle IMenu list which shows the symbol definitions based on major mode.")
|
|
|
|
|
|
|
|
(cheatsheet-add :group '--Development--
|
2018-04-26 20:12:33 +01:00
|
|
|
:key "C-<2>"
|
2018-04-26 19:51:58 +01:00
|
|
|
:description "Search for the definition of the symbol you want anywhere.")
|
|
|
|
|
|
|
|
;; (imenu-list-minor-mode)
|
|
|
|
(setq imenu-list-focus-after-activation t)
|
|
|
|
(setq imenu-list-auto-resize t)
|
|
|
|
(global-set-key (kbd "C-'") #'imenu-list-smart-toggle)
|
2018-04-26 20:12:33 +01:00
|
|
|
(global-set-key (kbd "C-<f2>") #'imenu-anywhere))
|
2018-10-04 15:52:41 +01:00
|
|
|
(global-set-key (kbd "<f13>") #'imenu-anywhere)
|
2018-07-20 08:54:39 +01:00
|
|
|
|
2018-04-26 19:51:58 +01:00
|
|
|
|
2017-06-09 01:01:28 +01:00
|
|
|
(ability parinfer ()
|
|
|
|
(add-hook 'emacs-lisp-mode-hook #'parinfer-mode))
|
|
|
|
|
2017-03-28 01:11:18 +01:00
|
|
|
(ability dumb-jump ()
|
|
|
|
"Easily jump to defination for most langs using ag"
|
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "M-g o"
|
|
|
|
:description "Jump to definition in another window")
|
|
|
|
(cheatsheet-add :group '--Development--
|
2017-04-24 10:06:17 +01:00
|
|
|
:key "C-u y or M-g j"
|
2017-03-28 01:11:18 +01:00
|
|
|
:description "Jump to definition in current buffer")
|
|
|
|
(cheatsheet-add :group '--Development--
|
2017-04-24 10:06:17 +01:00
|
|
|
:key "C-u i or M-g x"
|
2017-03-28 01:11:18 +01:00
|
|
|
:description "Jump to definition using an external tool")
|
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "M-g z"
|
|
|
|
:description "Jump to definition in another window using an external tool")
|
|
|
|
|
|
|
|
(require 'dumb-jump)
|
2018-04-26 19:51:58 +01:00
|
|
|
(dumb-jump-mode t)
|
2017-03-28 10:25:42 +01:00
|
|
|
(define-key dumb-jump-mode-map (kbd "M-g o") 'dumb-jump-go-other-window)
|
|
|
|
(define-key dumb-jump-mode-map (kbd "M-g j") 'dumb-jump-go)
|
2017-04-24 10:06:17 +01:00
|
|
|
(define-key dumb-jump-mode-map (kbd "C-u y") 'dumb-jump-go)
|
2017-03-28 10:25:42 +01:00
|
|
|
(define-key dumb-jump-mode-map (kbd "M-g x") 'dumb-jump-go-prefer-external)
|
2017-04-24 10:06:17 +01:00
|
|
|
(define-key dumb-jump-mode-map (kbd "C-u i") 'dumb-jump-go-prefer-external)
|
2017-03-28 10:25:42 +01:00
|
|
|
(define-key dumb-jump-mode-map (kbd "M-g z") 'dumb-jump-go-prefer-external-other-window))
|
2017-03-28 01:11:18 +01:00
|
|
|
|
2016-11-21 12:50:25 +00:00
|
|
|
(ability git ()
|
|
|
|
"A wonderful git interface for FG42"
|
2017-05-08 14:07:28 +01:00
|
|
|
|
2016-11-21 12:50:25 +00:00
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "C-x g"
|
|
|
|
:description "Rise up MAGIT. Git interface for FG42")
|
|
|
|
(global-set-key (kbd "C-x g") 'magit-status))
|
2017-03-28 10:25:42 +01:00
|
|
|
|
2018-10-04 15:52:41 +01:00
|
|
|
(ability github ()
|
|
|
|
"Github support"
|
|
|
|
(require 'magithub)
|
|
|
|
(magithub-feature-autoinject t))
|
|
|
|
|
2017-04-08 01:16:00 +01:00
|
|
|
;; (ability hl ()
|
|
|
|
;; "Highligh the current block of code. This ability may slows you down."
|
|
|
|
;; (require 'hl-sexp)
|
|
|
|
;; (add-hook 'prog-mode-hook #'hl-sexp-mode))
|
2015-11-02 12:50:18 +00:00
|
|
|
|
2015-07-08 17:59:42 +01:00
|
|
|
(ability code-completion ()
|
2015-07-08 18:38:40 +01:00
|
|
|
"Use company mode to provides a complete auto completion framwork."
|
2015-07-09 00:00:45 +01:00
|
|
|
(require 'company)
|
2015-07-08 17:59:42 +01:00
|
|
|
(global-company-mode t)
|
2015-07-09 00:00:45 +01:00
|
|
|
|
|
|
|
;; Bigger popup window
|
|
|
|
(setq company-tooltip-limit 20)
|
|
|
|
|
|
|
|
;; Align annotations to the right tooltip border
|
|
|
|
(setq company-tooltip-align-annotations 't)
|
|
|
|
|
|
|
|
;; Decrease delay before autocompletion popup shows
|
2015-07-09 10:11:54 +01:00
|
|
|
(setq company-idle-delay 0.1)
|
|
|
|
(setq company-minimum-prefix-length 2)
|
2015-07-09 00:00:45 +01:00
|
|
|
|
2017-04-07 14:22:10 +01:00
|
|
|
;; Start autpocompletion only after typing
|
2015-07-09 00:00:45 +01:00
|
|
|
(setq company-begin-commands '(self-insert-command))
|
|
|
|
|
|
|
|
;; Force complete file names on "C-c /" key
|
|
|
|
(global-set-key (kbd "C-c /") 'company-files)
|
|
|
|
|
|
|
|
(add-hook 'after-init-hook 'company-statistics-mode)
|
2017-04-07 14:22:10 +01:00
|
|
|
(define-key company-active-map "\t" 'company-yasnippet-or-completion)
|
|
|
|
|
2018-04-26 19:51:58 +01:00
|
|
|
(setq dabbrev-case-fold-search t)
|
2017-04-08 00:55:05 +01:00
|
|
|
|
2017-04-07 14:22:10 +01:00
|
|
|
(add-to-list 'company-backends 'company-dabbrev)
|
|
|
|
(add-to-list 'company-backends 'company-dabbrev-code))
|
2015-07-08 17:59:42 +01:00
|
|
|
|
|
|
|
(ability yas ()
|
2015-07-08 18:38:40 +01:00
|
|
|
"Snippet configuration."
|
2015-07-09 13:29:28 +01:00
|
|
|
|
|
|
|
(let ((snippet_home (concat (file-name-directory
|
2017-08-15 17:44:17 +01:00
|
|
|
(locate-library "yasnippet")) "snippets"))
|
2015-07-09 13:29:28 +01:00
|
|
|
(my_snippet (concat fg42-home "/lib/snippets")))
|
|
|
|
(setq yas-snippet-dirs (list my_snippet snippet_home)))
|
|
|
|
|
2015-07-08 17:59:42 +01:00
|
|
|
(yas-global-mode 1))
|
|
|
|
|
|
|
|
(ability project-management ()
|
2015-07-08 18:38:40 +01:00
|
|
|
"Ability to manage projects and project navigation."
|
2015-07-08 17:59:42 +01:00
|
|
|
(projectile-global-mode)
|
|
|
|
(setq projectile-enable-caching t))
|
|
|
|
|
2015-07-08 19:55:37 +01:00
|
|
|
(ability spell ()
|
2017-04-07 14:22:10 +01:00
|
|
|
"Check spell of any word using ispell. This ability may slows you down"
|
2015-07-22 08:13:20 +01:00
|
|
|
(global-set-key (kbd "<f2>") 'ispell-word)
|
2015-07-08 19:55:37 +01:00
|
|
|
(setq flyspell-issue-message-flg nil))
|
|
|
|
|
2015-07-09 14:08:58 +01:00
|
|
|
(ability diff-highlight ()
|
2015-07-08 19:55:37 +01:00
|
|
|
"Highlight the diffs based on VCS."
|
|
|
|
(add-hook 'prog-mode-hook 'turn-on-diff-hl-mode)
|
|
|
|
(add-hook 'vc-dir-mode-hook 'turn-on-diff-hl-mode))
|
|
|
|
|
2015-07-09 14:08:58 +01:00
|
|
|
(ability auto-pair ()
|
2015-07-08 19:55:37 +01:00
|
|
|
"Auto pair stuffs like brackets begin/ends etc."
|
2015-07-08 19:57:15 +01:00
|
|
|
;; TODO: use autopair mode if electric pair was not as good as autopair
|
2015-07-08 19:55:37 +01:00
|
|
|
(electric-pair-mode))
|
|
|
|
|
2018-04-19 13:45:36 +01:00
|
|
|
(ability yaml ()
|
|
|
|
"YAML editor."
|
|
|
|
(require 'yaml-mode)
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.sls\\'" . yaml-mode)))
|
|
|
|
|
2018-04-23 14:36:46 +01:00
|
|
|
(ability terraform ()
|
|
|
|
"Terraform editor."
|
|
|
|
(require 'terraform-mode)
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.tf\\'" . terraform-mode)))
|
|
|
|
|
2015-07-09 14:08:58 +01:00
|
|
|
(ability code-browser ()
|
|
|
|
"Adds the code browser to FG42."
|
2016-11-21 08:19:35 +00:00
|
|
|
(require 'neotree)
|
2017-04-08 00:55:05 +01:00
|
|
|
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
|
2016-11-21 08:36:34 +00:00
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "f8"
|
|
|
|
:description "Toggle project browser sidebar. See ProjectBrowser")
|
|
|
|
|
|
|
|
(cheatsheet-add :group '--ProjectBrowser--
|
|
|
|
:key "n"
|
|
|
|
:description "Next line")
|
|
|
|
(cheatsheet-add :group '--ProjectBrowser--
|
|
|
|
:key "p"
|
|
|
|
:description "Previous line")
|
|
|
|
(cheatsheet-add :group '--ProjectBrowser--
|
|
|
|
:key "g"
|
|
|
|
:description "Refresh the tree")
|
|
|
|
(cheatsheet-add :group '--ProjectBrowser--
|
|
|
|
:key "A"
|
|
|
|
:description "Maximize/Minimize the project browser")
|
|
|
|
(cheatsheet-add :group '--ProjectBrowser--
|
|
|
|
:key "H"
|
|
|
|
:description "Toggle display hidden files")
|
|
|
|
(cheatsheet-add :group '--ProjectBrowser--
|
|
|
|
:key "C-c C-n"
|
|
|
|
:description "Create a file or create a directory if filename ends with a '/'")
|
|
|
|
(cheatsheet-add :group '--ProjectBrowser--
|
|
|
|
:key "C-c C-d"
|
|
|
|
:description "Delete a file or a directory.")
|
|
|
|
(cheatsheet-add :group '--ProjectBrowser--
|
|
|
|
:key "C-c C-r"
|
|
|
|
:description "Rename a file or a directory.")
|
|
|
|
(cheatsheet-add :group '--ProjectBrowser--
|
|
|
|
:key "C-c C-c"
|
|
|
|
:description "Chande root directory.")
|
|
|
|
|
2016-11-21 08:19:35 +00:00
|
|
|
(global-set-key [f8] 'neotree-toggle))
|
|
|
|
|
2016-11-21 09:00:18 +00:00
|
|
|
(ability shell ()
|
|
|
|
"Eshell enhancements."
|
|
|
|
|
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "M-`'"
|
|
|
|
:description "Brings up the eshell")
|
|
|
|
|
|
|
|
(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.
|
|
|
|
'(shell-pop-default-directory "$HOME")
|
|
|
|
;;'(shell-pop-shell-type (quote ("ansi-term" "*ansi-term*" (lambda nil (ansi-term shell-pop-term-shell)))))
|
|
|
|
'(shell-pop-shell-type (quote ("eshell" "*shell*" (lambda nil (eshell shell-pop-term-shell)))))
|
|
|
|
;;'(shell-pop-term-shell "/bin/zsh")
|
|
|
|
'(shell-pop-term-shell "eshell")
|
2017-08-15 17:44:17 +01:00
|
|
|
|
2016-11-21 09:00:18 +00:00
|
|
|
'(shell-pop-window-size 30)
|
|
|
|
'(shell-pop-full-span t)
|
|
|
|
'(shell-pop-window-position "full"))
|
|
|
|
|
|
|
|
(require 'eshell-prompt-extras)
|
|
|
|
(with-eval-after-load "esh-opt"
|
|
|
|
(autoload 'epe-theme-lambda "eshell-prompt-extras")
|
|
|
|
(setq eshell-highlight-prompt nil
|
|
|
|
eshell-prompt-function 'epe-theme-lambda)))
|
|
|
|
|
2016-11-21 08:29:27 +00:00
|
|
|
(ability focus ()
|
|
|
|
"Provides means for focusing on code review."
|
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "M-x focus-mode"
|
|
|
|
:description "Highlights only the paragraph of code which you are reading for better focus."))
|
2016-11-21 08:19:35 +00:00
|
|
|
(ability pt ()
|
|
|
|
"Provides fast search ability via platinium search"
|
|
|
|
(require 'pt)
|
2016-11-21 08:22:49 +00:00
|
|
|
(cheatsheet-add :group '--Development--
|
2016-11-21 08:19:35 +00:00
|
|
|
:key "C-c p s s"
|
|
|
|
:description "Search within a project using pt. It's fast.")
|
|
|
|
|
2016-11-21 08:22:49 +00:00
|
|
|
(cheatsheet-add :group '--Development--
|
2016-11-21 08:19:35 +00:00
|
|
|
:key "C-c p s r"
|
|
|
|
:description "Search for a regexp in a project.")
|
2016-11-21 12:50:25 +00:00
|
|
|
(advice-add 'projectile-ag :around #'projectile-pt)
|
2016-11-21 08:19:35 +00:00
|
|
|
(add-hook 'projectile-mode-hook 'enable-pt-search))
|
2015-07-09 14:36:05 +01:00
|
|
|
|
2016-11-21 10:04:38 +00:00
|
|
|
(ability file-browser ()
|
|
|
|
"A ranger like file browser for FG42"
|
|
|
|
(cheatsheet-add :group '--Development--
|
|
|
|
:key "f7"
|
|
|
|
:description "A ranger like file browser for FG42")
|
|
|
|
(setq ranger-cleanup-eagerly t)
|
|
|
|
(setq ranger-show-dotfiles nil)
|
|
|
|
(global-set-key [f7] 'ranger))
|
|
|
|
|
2015-07-09 14:36:05 +01:00
|
|
|
(ability smart-mode-line ()
|
|
|
|
"Smarter modeline for FG42"
|
|
|
|
(setq sml/no-confirm-load-theme t)
|
|
|
|
(setq sml/theme 'respectful)
|
2017-04-08 11:29:01 +01:00
|
|
|
(sml/setup)))
|
2015-07-08 17:59:42 +01:00
|
|
|
|
|
|
|
(provide 'extensions/development/init)
|