Skip to content

Commit

Permalink
paredit -> (lispy + awesome-pair)
Browse files Browse the repository at this point in the history
  • Loading branch information
JJPandari committed Jul 8, 2019
1 parent dc3efd6 commit 60a314a
Show file tree
Hide file tree
Showing 20 changed files with 169 additions and 122 deletions.
3 changes: 2 additions & 1 deletion init.el
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@
(require 'init-git)

(require 'init-lsp)
(require 'init-dumbjump)
(require 'init-jump)
;; (require 'init-compile)
(require 'init-text)
(require 'init-org)
(require 'init-markdown)
(require 'init-csv)
Expand Down
6 changes: 1 addition & 5 deletions modes/init-buffer.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ if prefix argument ARG is given, switch to it in an other, possibly new window."
(let ((exists (get-buffer "*scratch*")))
(if arg
(switch-to-buffer-other-window (get-buffer-create "*scratch*"))
(switch-to-buffer (get-buffer-create "*scratch*")))
(when (and (not exists)
(not (eq major-mode dotspacemacs-scratch-mode))
(fboundp dotspacemacs-scratch-mode))
(funcall dotspacemacs-scratch-mode))))
(switch-to-buffer (get-buffer-create "*scratch*")))))

;;----------------------------------------------------------------------------
;; switch to last buffer
Expand Down
8 changes: 7 additions & 1 deletion modes/init-editing-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@
kill-ring-max 200
recentf-max-saved-items 1000)

(after-init (electric-pair-mode 1)) ;; this is global

(use-package aggressive-indent
:hook (after-init . aggressive-indent-global-mode))
;; TODO 'aggressive-indent-dont-indent-if: in web-mode indent others but not html

(require 'recentf)
(add-to-list 'recentf-exclude (list "/tmp/" "/ssh:" "COMMIT_EDITMSG\\'"
(recentf-expand-file-name package-user-dir)))
(recentf-expand-file-name package-user-dir)))

(after-init (transient-mark-mode 1))

Expand Down
74 changes: 62 additions & 12 deletions modes/init-evil.el
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@

)


(use-package evil-visualstar
:demand t
:config
(global-evil-visualstar-mode t))


(use-package evil-exchange
:demand t
Expand Down Expand Up @@ -196,6 +190,15 @@
:init
(evil-ediff-init))


(use-package evil-numbers
:commands (evil-numbers/inc-at-pt evil-numbers/dec-at-pt)
:init
(general-define-key
:states '(normal)
"+" 'evil-numbers/inc-at-pt
"-" 'evil-numbers/dec-at-pt))


(push (expand-file-name "targets" jester-submodules-dir) load-path)
(require 'targets)
Expand Down Expand Up @@ -236,6 +239,9 @@
;; Set initial states for modes.
;;----------------------------------------------------------------------------
(evil-set-initial-state 'debugger-mode 'motion)
;; special mode is for viewing info, e.g. "q" is bound to quit,
;; but it's normal state there so we lose the bindings. Use motion state.
(evil-set-initial-state 'special-mode 'motion)

;; TODO not work
(add-hook! 'snippet-mode-hook (when (string-equal (buffer-name) "+new-snippet+")
Expand Down Expand Up @@ -276,25 +282,30 @@
(general-define-key
:states '(normal)
"Q" "@q"
"gJ" 'jester/evil-join-no-whitespace
"C-o" 'goto-last-change
"C-i" 'goto-last-change-reverse)
"gJ" 'jester/evil-join-no-whitespace)

(general-define-key
:states '(normal)
:keymaps '(text-mode-map
conf-mode-map
prog-mode-map

messages-buffer-mode-map

comint-mode-map
inferior-emacs-lisp-mode-map

org-mode-map
markdown-mode-map

gitconfig-mode-map
diff-mode-map)
"<return>" 'switch-to-buffer)

(general-define-key
:states '(visual)
"*" 'jester/evil-visual-search-forward
"#" 'jester/evil-visual-search-backward
;; TODO not working
"<" (lambda! (call-interactively 'evil-shift-left) (evil-visual-restore))
">" (lambda! (call-interactively 'evil-shift-right) (evil-visual-restore))
Expand All @@ -317,10 +328,9 @@

(general-define-key
:states '(normal motion)
"*" (lambda! (evil-search-word-forward 1 t))
"#" (lambda! (evil-search-word-backward 1 t))
"*" 'jester/evil-normal-search-forward
"#" 'jester/evil-normal-search-backward
"C-q" (lambda! (evil-ex-nohighlight)
(when (fboundp 'jester/clear-all-hi-lock) (jester/clear-all-hi-lock))
(when (fboundp 'symbol-overlay-remove-all) (symbol-overlay-remove-all))))

(general-define-key
Expand Down Expand Up @@ -365,5 +375,45 @@
(general-define-key
"C-h p" 'describe-package)

;;----------------------------------------------------------------------------
;; Some functions.
;;----------------------------------------------------------------------------
(evil-define-command jester/evil-normal-search-forward (&optional count)
"Search symbol under point forward."
:repeat nil
(interactive "p")
(evil-search-word-forward (or count 1) t))

(evil-define-command jester/evil-normal-search-backward (&optional count)
"Search symbol under point backward."
:repeat nil
(interactive "p")
(evil-search-word-backward (or count 1) t))

(evil-define-command jester/evil-visual-search-forward ()
"Search the region forward."
:repeat nil
(interactive)
(jester/evil-visual-search t))

(evil-define-command jester/evil-visual-search-backward ()
"Search the region backward."
:repeat nil
(interactive)
;; move point to the start of region to jump past the current occurence
(when (eql (point) (region-end))
(exchange-point-and-mark))
(jester/evil-visual-search nil))

(defun jester/evil-visual-search (forward)
"Search the region."
(let ((string (buffer-substring-no-properties (region-beginning) (region-end))))
(deactivate-mark)
(evil-push-search-history string forward)
;; pushed to `regexp-search-ring'
(isearch-update-ring string evil-regexp-search)
(setq isearch-forward forward)
(evil-search string forward)))


(provide 'init-evil)
5 changes: 3 additions & 2 deletions modes/init-exec-path.el
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
:config
(dolist (var '("GOPATH" "SSH_AGENT_PID" "GPG_AGENT_INFO" "LANG" "LC_CTYPE" "SSH_AUTH_SOCK"))
(add-to-list 'exec-path-from-shell-variables var)))
(dolist (var '("SSH_AGENT_PID" "GPG_AGENT_INFO" "LANG" "LC_CTYPE" "SSH_AUTH_SOCK"
"GOPATH" "MVN_HOME" "JAVA_HOME"))
(push var exec-path-from-shell-variables)))

(provide 'init-exec-path)
44 changes: 0 additions & 44 deletions modes/init-face.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
display-line-numbers-type 'relative
display-line-numbers-current-absolute t)

(after-init (electric-pair-mode 1)) ;; this is global
(after-init (electric-indent-mode 1))
(after-init (global-prettify-symbols-mode 1))

(maybe-require-package 'list-unicode-display)
Expand All @@ -35,48 +33,6 @@
(use-package all-the-icons
:demand t)

;;----------------------------------------------------------------------------
;; highlight region with hi-lock
;;----------------------------------------------------------------------------
;; (general-define-key
;; :states '(normal visual motion)
;; :keymaps '(prog-mode-map markdown-mode-map)
;; "<tab>" 'jester/toggle-highlight-at-point)
;; (jester/with-leader
;; "h i" 'hi-lock-find-patterns
;; "h l" 'highlight-lines-matching-regexp
;; "h p" 'highlight-phrase
;; "h r" 'highlight-regexp
;; "h s" 'highlight-symbol-at-point
;; "h u" 'unhighlight-regexp
;; "h b" 'hi-lock-write-interactive-patterns)

;; (defun jester/toggle-highlight-at-point ()
;; "Toggle highlight at point (region or symbol)."
;; (interactive)
;; (require 'hi-lock)
;; (let ((hi-regexp-list (mapcar #'car hi-lock-interactive-patterns))
;; (hi-regexp-at-pt (jester/regexp-at-point))
;; (hi-lock-auto-select-face t))
;; (if (member hi-regexp-at-pt hi-regexp-list)
;; (unhighlight-regexp hi-regexp-at-pt)
;; (highlight-phrase hi-regexp-at-pt (hi-lock-read-face-name)))
;; (deactivate-mark)))

;; (defun jester/clear-all-hi-lock ()
;; "clear all highlight."
;; (interactive)
;; (let ((hi-regexp-list (mapcar #'car hi-lock-interactive-patterns)))
;; (mapcar 'unhighlight-regexp hi-regexp-list)))

;; (defun jester/regexp-at-point ()
;; "if region active, return the region,
;; otherwise return regexp like \"\\\\_<sym\\\\_>\" for the symbol at point."
;; (if (region-active-p)
;; (buffer-substring-no-properties
;; (region-beginning) (region-end))
;; (format "\\_<%s\\_>" (thing-at-point 'symbol t))))

;;----------------------------------------------------------------------------
;; highlight region with symbol-overlay
;;----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions modes/init-git.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"g s" 'magit-status
"g d" 'magit-diff-buffer-file
"g r" 'diff-hl-revert-hunk
"g l" 'magit-log
;; "a" ≈ "actions"
"g a" 'magit-dispatch-popup)
:commands (magit-status magit-diff-buffer-file magit-dispatch-popup)
Expand Down
1 change: 1 addition & 0 deletions modes/init-hydra.el
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
;; TODO hydra for git-timemachine

(provide 'init-hydra)
12 changes: 8 additions & 4 deletions modes/init-ivy.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
completing-read-function 'ivy-completing-read)
(general-define-key
:keymaps 'ivy-switch-buffer-map
"M-k" 'ivy-switch-buffer-kill))
"M-k" 'ivy-switch-buffer-kill)
;; TODO
(jester/with-major-leader 'ivy-occur-mode-map
"w" 'ivy-wgrep-change-to-wgrep-mode
"," 'wgrep-finish-edit
"a" 'wgrep-exit))

(use-package counsel
:demand t
Expand All @@ -31,7 +36,6 @@
"s B" (lambda! (swiper-all (jester/region-or-symbol)))
"i u" 'counsel-unicode-char)

;; TODO install wgrep
(general-define-key
"M-x" 'counsel-M-x
"M-y" 'counsel-yank-pop
Expand All @@ -41,8 +45,8 @@

(dolist (that-ivy-map
'(ivy-mode-map ivy-switch-buffer-map ivy-minibuffer-map
counsel-mode-map counsel-describe-map counsel-find-file-map counsel-ag-map
swiper-map swiper-all-map))
counsel-mode-map counsel-describe-map counsel-find-file-map counsel-ag-map
swiper-map swiper-all-map))
(general-define-key
:keymaps that-ivy-map
"M-d" #'backward-word
Expand Down
9 changes: 9 additions & 0 deletions modes/init-javascript.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
js2-mode-show-strict-warnings nil
js2-bounce-indent-p nil)

;; "_" as word so company completes kabeb-case
(modify-syntax-entry ?_ "w" js2-mode-syntax-table)

(general-define-key
:states '(normal)
:keymaps 'js2-mode-map
Expand All @@ -22,24 +25,30 @@
(add-hook! 'js2-mode-hook
(setq mode-name (all-the-icons-icon-for-mode major-mode :height 0.8 :v-adjust 0)))


(use-package js2-refactor
:hook (js2-mode . js2-refactor-mode)
:config
(jester/with-major-leader 'js2-mode-map
"r" (lambda! (counsel-M-x "^js2r- "))))


(use-package js-doc
:after js2-mode)

;; (maybe-require-package 'typescript-mode)


(use-package skewer-mode
:init
(setq httpd-port 9871)
:hook js2-mode
:config
(jester/with-major-leader 'js2-mode-map
"e" 'skewer-eval-last-expression)
(evil-set-initial-state 'skewer-error-mode 'motion))


;; https://emacs-china.org/t/javascript/7860?u=jjpandari
(defun jester/js2r-toggle-object-property-access-style ()
"Convert the string at point into a template string."
Expand Down
2 changes: 1 addition & 1 deletion modes/init-dumbjump.el → modes/init-jump.el
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
:commands (dumb-jump-go))


(provide 'init-dumbjump)
(provide 'init-jump)
11 changes: 5 additions & 6 deletions modes/init-lisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
(add-hook 'jester/theme-mode-hook 'rainbow-mode)
(add-hook 'help-mode-hook 'rainbow-mode))

(when (maybe-require-package 'aggressive-indent)
(after-load 'aggressive-indent
;; Can be prohibitively slow with very long forms
(add-to-list 'jester/theme-mode-hook (lambda () (aggressive-indent-mode -1)) t))

Expand Down Expand Up @@ -140,11 +140,12 @@
"C-;" (lambda! (insert ";; ")))

(use-package lispyville
:bind (("M-r" . lispy-raise) ("H-r" . lispy-raise-some))
:init
(add-hook! (emacs-lisp-mode lisp-mode) (flycheck-mode -1))
;; load it everywhere
;; :hook (prog-mode . lispyville-mode)
:hook ((emacs-lisp-mode lisp-mode) . lispyville-mode)
:init
(add-hook! (emacs-lisp-mode lisp-mode) (flycheck-mode -1))
:config
(lispyville-set-key-theme
'(operators
Expand All @@ -170,9 +171,7 @@
(jester/with-leader
","
(general-predicate-dispatch 'evil-indent
(memq major-mode '(emacs-lisp-mode lisp-mode)) 'lispyville-prettify))

)
(memq major-mode '(emacs-lisp-mode lisp-mode)) 'lispyville-prettify)))

(use-package macrostep
:commands macrostep-expand)
Expand Down
9 changes: 0 additions & 9 deletions modes/init-misc.el
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@

(jester/with-leader "o d" 'browse-file-directory)

;; comint
(general-define-key
:states '(insert emacs)
:keymaps 'comint-mode-map
"C-d" 'backward-char
"C-b" 'comint-delchar-or-maybe-eof
"C-r" 'comint-history-isearch-backward
"C-l" 'comint-clear-buffer)

;; re-builder
(general-define-key
:states '(normal)
Expand Down
Loading

0 comments on commit 60a314a

Please sign in to comment.