mirror of
https://github.com/Foltik/dotfiles
synced 2024-11-27 21:19:51 -05:00
Better parens handling
This commit is contained in:
parent
4df609364f
commit
7aba8637b6
@ -728,250 +728,267 @@ Define some *useful* helper functions
|
|||||||
|
|
||||||
(add-hook 'prog-mode-hook #'whitespace-mode)
|
(add-hook 'prog-mode-hook #'whitespace-mode)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** Smart Parentheses
|
*** Parentheses
|
||||||
smartparens handles parens for languages that aren't lispy,
|
**** Smartparens
|
||||||
and paredit handles the rest.
|
[[https://github.com/Fuco1/smartparens][Smartparens]] handles parens for languages that aren't lispy.
|
||||||
Keybinds in =M-x sp-cheat-sheet=.
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package paredit
|
(use-package smartparens
|
||||||
:diminish
|
:diminish
|
||||||
:commands enable-paredit-mode)
|
:commands smartparens-mode
|
||||||
|
|
||||||
(use-package smartparens
|
|
||||||
:diminish
|
|
||||||
:commands smartparens-strict-mode
|
|
||||||
:config
|
:config
|
||||||
(require 'smartparens-config))
|
(require 'smartparens-config))
|
||||||
|
|
||||||
(use-package evil-smartparens
|
|
||||||
:hook (smartparens-enabled . evil-smartparens-mode))
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** Smart Parentheses Modes
|
**** ParEdit
|
||||||
Picks a suitable parenthesis editing mode for the
|
And [[https://www.emacswiki.org/emacs/ParEdit][ParEdit]] handles the rest.
|
||||||
current major mode when entering any prog-mode.
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defun foltz-paren-mode ()
|
(use-package paredit
|
||||||
(if (member major-mode
|
:diminish
|
||||||
'(emacs-lisp-mode
|
:commands enable-paredit-mode)
|
||||||
lisp-mode
|
|
||||||
lisp-interaction-mode
|
|
||||||
scheme-mode))
|
|
||||||
(enable-paredit-mode)
|
|
||||||
(smartparens-strict-mode)))
|
|
||||||
|
|
||||||
(add-hook 'prog-mode-hook #'foltz-paren-mode)
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** ws-butler
|
**** Evil-Cleverparens
|
||||||
|
[[https://github.com/luxbock/evil-cleverparens][Evil-Cleverparens]] adds additional features to Evil all about
|
||||||
|
working with sexps, including keeping parens balanced when
|
||||||
|
using commands like =dd=.
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package evil-cleverparens
|
||||||
|
:diminish
|
||||||
|
:commands evil-cleverparens-mode)
|
||||||
|
#+END_SRC
|
||||||
|
**** Activation
|
||||||
|
Pick a suitable parenthesis editing mode for the
|
||||||
|
current major mode when entering any prog-mode derivative.
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(defun jf-paren-mode ()
|
||||||
|
(if (member major-mode '(emacs-lisp-mode
|
||||||
|
lisp-mode
|
||||||
|
lisp-interaction-mode
|
||||||
|
scheme-mode))
|
||||||
|
(enable-paredit-mode)
|
||||||
|
(smartparens-mode)))
|
||||||
|
|
||||||
|
(add-hook 'prog-mode-hook #'jf-paren-mode)
|
||||||
|
#+END_SRC
|
||||||
|
*** Whitespace
|
||||||
|
**** ws-butler
|
||||||
Unobtrusively cleans up whitespace before EOLs
|
Unobtrusively cleans up whitespace before EOLs
|
||||||
as you edit, stopping the noisy commits generated
|
as you edit, stopping the noisy commits generated
|
||||||
from blanket trimming entire files.
|
from blanket trimming entire files.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package ws-butler
|
(use-package ws-butler
|
||||||
:hook (prog-mode . ws-butler-mode))
|
:hook (prog-mode . ws-butler-mode))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** pretty-mode
|
*** pretty-mode
|
||||||
[[https://github.com/pretty-mode/pretty-mode][Redisplay parts of the Emacs buffer as pretty symbols.]]
|
[[https://github.com/pretty-mode/pretty-mode][pretty-mode]] redisplays parts of the Emacs buffer as pretty symbols.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package pretty-mode
|
(use-package pretty-mode
|
||||||
:hook (prog-mode . pretty-mode)
|
:hook (prog-mode . pretty-mode)
|
||||||
:config
|
:config
|
||||||
(pretty-deactivate-groups
|
(pretty-deactivate-groups '(:arithmetic
|
||||||
'(:equality :sub-and-superscripts))
|
:sub-and-superscripts))
|
||||||
(pretty-activate-groups
|
(pretty-activate-groups '(:equality
|
||||||
'(:greek :arithmetic-nary
|
:ordering
|
||||||
:ordering :ordering-double :ordering-triple
|
:ordering-double
|
||||||
:arrows :arrows-twoheaded :punctuation :logic :sets)))
|
:ordering-triple
|
||||||
|
:arrows
|
||||||
|
:arrows-twoheaded
|
||||||
|
:punctuation
|
||||||
|
:logic
|
||||||
|
:sets)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** prettify-symbols-mode
|
*** Prettify-Symbols-Mode
|
||||||
Built into emacs since 24.1
|
Allows custom unicode replacement of symbols. Fill in the gaps where
|
||||||
|
pretty-mode left off.
|
||||||
|
**** Python
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(add-hook 'python-mode-hook 'prettify-symbols-mode)
|
(defun jf-prettify-python ()
|
||||||
(add-hook 'python-mode-hook (lambda ()
|
(dolist (pair '(;; Syntax
|
||||||
(mapc (lambda (pair) (push pair prettify-symbols-alist))
|
("in" . #x2208)
|
||||||
'(;; Syntax
|
("not in" . #x2209)
|
||||||
("in" . #x2208)
|
("return" . #x27fc)
|
||||||
("not in" . #x2209)
|
("yield" . #x27fb)
|
||||||
("return" . #x27fc)
|
("for" . #x2200)
|
||||||
("yield" . #x27fb)
|
;; Base Types
|
||||||
("for" . #x2200)
|
("int" . #x2124)
|
||||||
;; Base Types
|
("float" . #x211d)
|
||||||
("int" . #x2124)
|
("str" . #x1d54a)
|
||||||
("float" . #x211d)
|
("True" . #x1d54b)
|
||||||
("str" . #x1d54a)
|
("False" . #x1d53d)))
|
||||||
("True" . #x1d54b)
|
(push pair prettify-symbols-alist)))
|
||||||
("False" . #x1d53d)))))
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
*** Column 80 Highlight
|
(add-hook 'python-mode-hook #'prettify-symbols-mode)
|
||||||
Add a hotkey for highlighting column 80
|
(add-hook 'python-mode-hook #'jf-prettify-python)
|
||||||
and activate it in =prog-mode=
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(use-package fill-column-indicator
|
|
||||||
:init
|
|
||||||
(setq fci-rule-use-dashes t)
|
|
||||||
(setq fci-rule-column 80)
|
|
||||||
:general)
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Checkers
|
** Checkers
|
||||||
*** Flycheck
|
*** Flycheck
|
||||||
Flycheck does syntax highlighting in a few languages
|
Flycheck highlights syntax errors in a few languages.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package flycheck
|
(use-package flycheck
|
||||||
:hook (prog-mode . flycheck-mode))
|
:hook (prog-mode . flycheck-mode))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
*** Column 80 Highlight
|
||||||
|
Add a hotkey for highlighting column 80
|
||||||
|
and activate it in =prog-mode=
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package fill-column-indicator
|
||||||
|
:init
|
||||||
|
(setq fci-rule-use-dashes t)
|
||||||
|
(setq fci-rule-column 80)
|
||||||
|
:general
|
||||||
|
(jf-major-def
|
||||||
|
:keymaps 'prog-mode-map
|
||||||
|
"8" 'fci-mode))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
** Completion
|
** Completion
|
||||||
*** Company
|
*** Company
|
||||||
company auto-completes stuff in the buffer,
|
Company auto-completes stuff in the buffer, and company-quickhelp shows
|
||||||
company-quickhelp shows documentation popups
|
documentation popups when idling on a completion candidate.
|
||||||
when idling on a completion candidate.
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package company
|
(use-package company
|
||||||
:defer t
|
:hook (prog-mode . company-mode)
|
||||||
:hook ((prog-mode cdlatex-mode) . company-mode)
|
|
||||||
:general
|
:general
|
||||||
(:keymaps 'company-active-map
|
(:keymaps 'company-active-map
|
||||||
"C-SPC" 'company-abort)
|
"C-SPC" 'company-abort)
|
||||||
|
|
||||||
:custom
|
:custom
|
||||||
(company-maximum-prefix-length 2)
|
(company-maximum-prefix-length 2)
|
||||||
(company-idle-delay 0.2 "Decrease idle delay"))
|
(company-idle-delay 0.2 "Decrease idle delay"))
|
||||||
|
|
||||||
(use-package company-quickhelp
|
(use-package company-quickhelp
|
||||||
:after company
|
:after company
|
||||||
:hook (company-mode . company-quickhelp-mode))
|
:hook (company-mode . company-quickhelp-mode))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Snippets
|
** Snippets
|
||||||
Yasnippet adds support for custom snippets
|
Yasnippet adds support for custom snippets
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package yasnippet
|
(use-package yasnippet
|
||||||
:commands yas-minor-mode
|
|
||||||
:hook (prog-mode . yas-minor-mode)
|
:hook (prog-mode . yas-minor-mode)
|
||||||
:custom
|
:custom
|
||||||
(yas-snippet-dirs
|
(yas-snippet-dirs
|
||||||
'("~/.emacs.d/snippets"
|
'("~/.emacs.d/snippets"
|
||||||
"~/.emacs.d/elpa/yasnippet-snippets-0.6/snippets")))
|
"~/.emacs.d/elpa/yasnippet-snippets-0.6/snippets")))
|
||||||
;;;(use-package yasnippet-snippets)
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** Debugging
|
** Debugging
|
||||||
*** Realgud
|
*** Realgud
|
||||||
[[https://github.com/realgud/realgud][Realgud]] is a modular frontend for many debuggers
|
[[https://github.com/realgud/realgud][Realgud]] is a modular frontend for many debuggers, right in Emacs.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package realgud
|
(use-package realgud
|
||||||
:commands
|
:commands
|
||||||
(realgud:gdb
|
(realgud:gdb
|
||||||
realgud:lldb
|
realgud:lldb
|
||||||
realgud:node-inspect
|
realgud:node-inspect
|
||||||
realgud:pdb
|
realgud:pdb
|
||||||
realgud:trepan3k))
|
realgud:trepan3k))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** RMSBolt
|
*** RMSbolt
|
||||||
|
[[https://github.com/emacsmirror/rmsbolt][RMSbolt]] Shows disassembly in a buffer next to code, highlighting relevant regions.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package rmsbolt
|
(use-package rmsbolt
|
||||||
:commands rmsbolt-mode)
|
:commands rmsbolt-mode)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Git
|
** Git
|
||||||
*** magit
|
*** Magit
|
||||||
It's magic git!
|
It's magic git!
|
||||||
Keybinds [[https://github.com/emacs-evil/evil-magit][here]]
|
Keybinds [[https://github.com/emacs-evil/evil-magit][here]]
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package magit
|
(use-package magit
|
||||||
:general)
|
:general
|
||||||
|
(jf-git-def
|
||||||
|
"b" 'magit-blame-addition
|
||||||
|
"B" 'magit-blame-reverse
|
||||||
|
"s" 'magit-status))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
It's *evil* magic git!
|
It's *evil* magic git!
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package evil-magit
|
(use-package evil-magit
|
||||||
:after (evil magit))
|
:after (evil magit))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** forge
|
*** Forge
|
||||||
Magic GitHub facilities for git forges such as GitHub and GitLab!
|
Magic GitHub facilities for git forges such as GitHub and GitLab!
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package forge
|
(use-package forge
|
||||||
:after magit
|
:after magit
|
||||||
:init
|
:preface
|
||||||
(setq foltz-forge-hosts
|
(defvar jf-lcsr-git-host
|
||||||
'(("git.lcsr.rutgers.edu" "git.lcsr.rutgers.edu/api/v4" "git.lcsr.rutgers.edu" forge-gitlab-repository)))
|
'("git.lcsr.rutgers.edu" "git.lcsr.rutgers.edu/api/v4" "git.lcsr.rutgers.edu" forge-gitlab-repository))
|
||||||
:config
|
:config
|
||||||
(setq forge-alist (append forge-alist foltz-forge-hosts)))
|
(setq forge-alist (append forge-alist (list jf-lcsr-git-host))))
|
||||||
|
#+END_SRC
|
||||||
|
*** Smeargle
|
||||||
|
Highlights regions in files by last update time.
|
||||||
|
Older regions are more whitey and newer regions are more blacky.
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package smeargle
|
||||||
|
:general
|
||||||
|
(jf-git-def
|
||||||
|
"H t" 'smeargle
|
||||||
|
"H h" 'smeargle-commits
|
||||||
|
"H c" 'smeargle-clear))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Projects
|
** Projects
|
||||||
Projectile provides project-level features like
|
Projectile provides project-level features like
|
||||||
make shortcuts and file switching
|
make shortcuts and file switching
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package projectile
|
(use-package projectile
|
||||||
:init
|
:defer t
|
||||||
(defun foltz-projectile-neotree () "Open NeoTree in the project root"
|
:preface
|
||||||
(interactive)
|
(defvar jf-projects-path "~/Documents/dev")
|
||||||
(let
|
|
||||||
((project-dir (projectile-project-root))
|
|
||||||
(file-name (buffer-file-name)))
|
|
||||||
(neotree-toggle)
|
|
||||||
(if project-dir
|
|
||||||
(if (neo-global--window-exists-p)
|
|
||||||
(progn
|
|
||||||
(neotree-dir project-dir)
|
|
||||||
(neotree-find file-name))))))
|
|
||||||
|
|
||||||
(defun foltz-projectile-discover-projects (directory) "Add projects in dir to projectile cache"
|
:general
|
||||||
(interactive
|
(jf-leader-def
|
||||||
(list (read-directory-name "Starting directory: ")))
|
"p" '(:keymap projectile-command-map))
|
||||||
(let ((subdirs (directory-files directory t)))
|
|
||||||
(mapcar (lambda (dir)
|
|
||||||
(when
|
|
||||||
(and
|
|
||||||
(file-directory-p dir)
|
|
||||||
(not (member (file-name-nondirectory dir) '(".." "."))))
|
|
||||||
(let ((default-directory dir) (projectile-cached-project-root dir))
|
|
||||||
(when (projectile-project-p)
|
|
||||||
(projectile-add-known-project (projectile-project-root))))))
|
|
||||||
subdirs)))
|
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(projectile-mode 1)
|
(projectile-mode 1)
|
||||||
(foltz-projectile-discover-projects "~/Documents/dev")
|
;; Discover projects in jf-projects-path
|
||||||
:general
|
(let ((subdirs (directory-files jf-projects-path t)))
|
||||||
(:keymaps 'projectile-command-map
|
(dolist (dir subdirs)
|
||||||
"t" 'foltz-projectile-neotree)
|
(unless (member (file-name-nondirectory dir) '(".." "."))
|
||||||
|
(when (file-directory-p dir)
|
||||||
|
(let ((default-directory dir)
|
||||||
|
(projectile-cached-project-root dir))
|
||||||
|
(when (projectile-project-p)
|
||||||
|
(projectile-add-known-project (projectile-project-root))))))))
|
||||||
|
|
||||||
:custom
|
:custom
|
||||||
(projectile-completion-system 'ivy)
|
(projectile-completion-system 'ivy)
|
||||||
(projectile-project-search-path '("~/Documents/dev")))
|
(projectile-project-search-path (list jf-projects-path)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Tools
|
|
||||||
** Languages
|
** Languages
|
||||||
*** Fish
|
*** Fish
|
||||||
Beter editing of scripts for the fish shell
|
Mode for editing of scripts for the fish shell.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package fish-mode
|
(use-package fish-mode
|
||||||
:mode "\\.fish\\'")
|
:mode "\\.fish\\'")
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** Markdown
|
*** Markdown
|
||||||
|
Mode for editing markdown.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package markdown-mode
|
(use-package markdown-mode
|
||||||
:mode "\\.md\\'")
|
:mode "\\.md\\'")
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Python
|
*** Python
|
||||||
Jedi for autocompletion sources
|
Jedi for autocompletion sources in python-mode.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package company-jedi
|
(use-package company-jedi
|
||||||
:company python-mode)
|
:company python-mode)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Javascript
|
*** Javascript
|
||||||
[[https://github.com/mooz/js2-mode][js2-mode]] improves the default js mode. Keybindings in [[https://github.com/emacs-evil/evil-collection/blob/master/evil-collection-js2-mode.el][this file]].
|
[[https://github.com/mooz/js2-mode][js2-mode]] improves the default js mode.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package js2-mode
|
(use-package js2-mode
|
||||||
:mode "\\.js\\'"
|
:mode "\\.js\\'"
|
||||||
:interpreter "node")
|
:interpreter "node")
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
*** Web
|
||||||
*** Web-dev
|
|
||||||
Web-mode should give everything you need for a web-dev major mode.
|
Web-mode should give everything you need for a web-dev major mode.
|
||||||
Company integration is done with company-web
|
Company integration is done with company-web.
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package web-mode
|
(use-package web-mode
|
||||||
:mode ("\\.html\\'"
|
:mode ("\\.html\\'"
|
||||||
"\\.php\\'"
|
"\\.php\\'"
|
||||||
"\\.blade\\.")
|
"\\.blade\\.")
|
||||||
|
Loading…
Reference in New Issue
Block a user