Move smartparens configs to modules
This commit is contained in:
parent
1c37aebd2e
commit
f9e488cb0c
11 changed files with 98 additions and 61 deletions
|
@ -237,6 +237,7 @@ enable multiple minor modes for the same regexp.")
|
|||
(add-hook 'evil-replace-state-exit-hook 'turn-on-smartparens-mode)
|
||||
|
||||
;; Auto-close more conservatively
|
||||
(sp-pair "'" nil :unless '(sp-point-after-word-p))
|
||||
(sp-pair "{" nil :post-handlers '(("||\n[i]" "RET") ("| " " "))
|
||||
:unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
(sp-pair "(" nil :post-handlers '(("||\n[i]" "RET") ("| " " "))
|
||||
|
@ -244,64 +245,12 @@ enable multiple minor modes for the same regexp.")
|
|||
(sp-pair "[" nil :post-handlers '(("| " " "))
|
||||
:unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
|
||||
(defun sp-point-in-string-p (id action context)
|
||||
(when (eq action 'insert)
|
||||
(sp-point-in-string)))
|
||||
|
||||
(defun sp-insert-yasnippet (id action context)
|
||||
(forward-char -1)
|
||||
(if (sp-point-after-bol-p id action context)
|
||||
(yas-expand-from-trigger-key)
|
||||
(forward-char)))
|
||||
|
||||
(sp-local-pair 'css-mode "/*" "*/" :post-handlers '(("[d-3]||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair '(sh-mode markdown-mode) "`" "`" :unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
(sp-local-pair 'markdown-mode "```" "```" :post-handlers '(("||\n[i]" "RET")) :unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
|
||||
(sp-local-pair '(scss-mode css-mode) "/*" "*/" :post-handlers '(("[d-3]||\n[i]" "RET") ("| " "SPC")))
|
||||
|
||||
(sp-with-modes '(sh-mode)
|
||||
(sp-local-pair "case" "" :when '(("SPC")) :post-handlers '((:add sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "if" "" :when '(("SPC")) :post-handlers '((:add sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "for" "" :when '(("SPC")) :post-handlers '((:add sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "elif" "" :when '(("SPC")) :post-handlers '((:add sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "while" "" :when '(("SPC")) :post-handlers '((:add sp-insert-yasnippet)) :actions '(insert)))
|
||||
|
||||
(sp-with-modes '(c-mode c++-mode objc-mode php-mode java-mode)
|
||||
(sp-local-pair "/*" "*/" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
|
||||
;; Doxygen blocks
|
||||
(sp-local-pair "/**" "*/" :post-handlers '(("||\n[i]" "RET") ("||\n[i]" "SPC")))
|
||||
(sp-local-pair "/*!" "*/" :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC"))))
|
||||
|
||||
(defun sp--org-skip-asterisk (ms mb me)
|
||||
(or (and (= (line-beginning-position) mb)
|
||||
(eq 32 (char-after (1+ mb))))
|
||||
(and (= (1+ (line-beginning-position)) me)
|
||||
(eq 32 (char-after me)))))
|
||||
|
||||
(sp-with-modes '(org-mode)
|
||||
(sp-local-pair "*" "*" :unless '(sp-point-after-word-p sp-point-at-bol-p) :skip-match 'sp--org-skip-asterisk)
|
||||
(sp-local-pair "_" "_" :unless '(sp-point-before-word-p sp-point-after-word-p))
|
||||
(sp-local-pair "/" "/" :unless '(sp-point-before-word-p sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
|
||||
(sp-local-pair "~" "~" :unless '(sp-point-before-word-p sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
|
||||
(sp-local-pair "=" "=" :unless '(sp-point-before-word-p sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
|
||||
|
||||
(sp-local-pair "\\[" "\\]" :post-handlers '(("| " "SPC")))
|
||||
(sp-local-pair "\\(" "\\)" :post-handlers '(("| " "SPC")))
|
||||
(sp-local-pair "$$" "$$" :post-handlers '((:add " | ")) :unless '(sp-point-at-bol-p))
|
||||
(sp-local-pair "{" nil))
|
||||
|
||||
;; Markup languages
|
||||
(sp-with-modes '(xml-mode nxml-mode php-mode)
|
||||
(sp-local-pair "<!--" "-->" :post-handlers '(("| " "SPC"))))
|
||||
(sp-with-modes '(web-mode php-mode)
|
||||
(sp-local-pair "<?" "?>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "<?php " " ?>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC"))))
|
||||
(sp-with-modes '(web-mode)
|
||||
(sp-local-pair "{{!--" "--}}" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "<%" "%>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "{!!" "!!}" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "{#" "#}" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))))
|
||||
(sp-local-pair "<!--" "-->" :post-handlers '(("| " "SPC")))))
|
||||
|
||||
(use-package help-fns+ ; Improved help commands
|
||||
:commands (describe-buffer describe-command describe-file
|
||||
|
|
11
core/defuns/defuns-smartparens.el
Normal file
11
core/defuns/defuns-smartparens.el
Normal file
|
@ -0,0 +1,11 @@
|
|||
;;; defuns-smartparens.el
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/sp-insert-yasnippet (id action context)
|
||||
(forward-char -1)
|
||||
(if (sp-point-after-bol-p id action context)
|
||||
(yas-expand-from-trigger-key)
|
||||
(forward-char)))
|
||||
|
||||
(provide 'defuns-smartparens)
|
||||
;;; defuns-smartparens.el ends here
|
10
modules/defuns/defuns-lua.el
Normal file
10
modules/defuns/defuns-lua.el
Normal file
|
@ -0,0 +1,10 @@
|
|||
;;; defuns-lua.el
|
||||
|
||||
;;;###autoload
|
||||
(defun narf-inf-lua ()
|
||||
(interactive)
|
||||
(lua-start-process "lua" "lua")
|
||||
(pop-to-buffer lua-process-buffer))
|
||||
|
||||
(provide 'defuns-lua)
|
||||
;;; defuns-lua.el ends here
|
|
@ -350,5 +350,12 @@ re-align the table if necessary. (Necessary because org-mode has a
|
|||
(end evil-visual-end))
|
||||
(org-insert-link nil link (when (and beg end) (buffer-substring-no-properties beg end)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun narf/sp-org-skip-asterisk (ms mb me)
|
||||
(or (and (= (line-beginning-position) mb)
|
||||
(eq 32 (char-after (1+ mb))))
|
||||
(and (= (1+ (line-beginning-position)) me)
|
||||
(eq 32 (char-after me)))))
|
||||
|
||||
(provide 'defuns-org)
|
||||
;;; defuns-org.el ends here
|
||||
|
|
|
@ -27,6 +27,18 @@
|
|||
c-tab-always-indent nil
|
||||
c-electric-flag nil)
|
||||
|
||||
(defun narf/sp-point-is-template-p (id action context)
|
||||
(and (sp-in-code-p id action context)
|
||||
(sp-point-after-word-p id action context)))
|
||||
|
||||
(sp-local-pair 'c++-mode "<" ">" :when '(narf/sp-point-is-template-p))
|
||||
(sp-with-modes '(c-mode c++-mode objc-mode java-mode)
|
||||
(sp-local-pair "/*" "*/" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
|
||||
;; Doxygen blocks
|
||||
(sp-local-pair "/**" "*/" :post-handlers '(("||\n[i]" "RET") ("||\n[i]" "SPC")))
|
||||
(sp-local-pair "/*!" "*/" :post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC"))))
|
||||
|
||||
;; C/C++ Settings
|
||||
(add-hook! (c-mode c++-mode)
|
||||
(electric-indent-local-mode +1)
|
||||
|
|
|
@ -4,18 +4,26 @@
|
|||
:mode "\\.lua$"
|
||||
:interpreter "lua"
|
||||
:init
|
||||
(define-repl! lua-mode narf-inf-lua)
|
||||
(define-repl! lua-mode narf/inf-lua)
|
||||
(add-hook! lua-mode 'flycheck-mode)
|
||||
(after! company-dict
|
||||
(add-to-list 'company-dict-minor-mode-list 'love-mode))
|
||||
|
||||
(add-hook! lua-mode
|
||||
(electric-indent-local-mode +1)
|
||||
(setq narf-electric-indent-words '("else" "end")))
|
||||
:config
|
||||
(sp-with-modes '(lua-mode)
|
||||
;; disable defaults
|
||||
(sp-local-pair "if" nil :actions :rem)
|
||||
(sp-local-pair "while" nil :actions :rem)
|
||||
(sp-local-pair "function" nil :actions :rem)
|
||||
|
||||
(defun narf-inf-lua ()
|
||||
(lua-start-process "lua" "lua")
|
||||
(pop-to-buffer lua-process-buffer)))
|
||||
(sp-local-pair "then " " end")
|
||||
(sp-local-pair "do " " end")
|
||||
(sp-local-pair "then" "end" :when '(("RET")) :post-handlers '("||\n[i]"))
|
||||
(sp-local-pair "do" "end" :when '(("RET")) :post-handlers '("||\n[i]"))
|
||||
|
||||
(sp-local-pair "function" "end" :post-handlers '((" |()\n[i]\n" "RET") ("|() " "SPC")))))
|
||||
|
||||
(define-minor-mode love-mode
|
||||
"Buffer local minor mode for Love2D"
|
||||
|
|
|
@ -194,7 +194,20 @@
|
|||
(define-text-object! "/" "/" "/")
|
||||
(define-text-object! "_" "_" "_")
|
||||
(define-text-object! "=" "=" "=")
|
||||
(define-text-object! "~" "~" "~")))
|
||||
(define-text-object! "~" "~" "~"))
|
||||
|
||||
;; smartparens config
|
||||
(sp-with-modes '(org-mode)
|
||||
(sp-local-pair "*" "*" :unless '(sp-point-after-word-p sp-point-at-bol-p) :skip-match 'narf/sp-org-skip-asterisk)
|
||||
(sp-local-pair "_" "_" :unless '(sp-point-before-word-p sp-point-after-word-p))
|
||||
(sp-local-pair "/" "/" :unless '(sp-point-before-word-p sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
|
||||
(sp-local-pair "~" "~" :unless '(sp-point-before-word-p sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
|
||||
(sp-local-pair "=" "=" :unless '(sp-point-before-word-p sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
|
||||
|
||||
(sp-local-pair "\\[" "\\]" :post-handlers '(("| " "SPC")))
|
||||
(sp-local-pair "\\(" "\\)" :post-handlers '(("| " "SPC")))
|
||||
(sp-local-pair "$$" "$$" :post-handlers '((:add " | ")) :unless '(sp-point-at-bol-p))
|
||||
(sp-local-pair "{" nil)))
|
||||
|
||||
(defun narf|org-keybinds ()
|
||||
(define-key org-mode-map (kbd "RET") nil)
|
||||
|
|
|
@ -23,6 +23,14 @@
|
|||
(load (concat php-extras-eldoc-functions-file ".el"))
|
||||
(message "PHP eldoc updated!"))))
|
||||
|
||||
(sp-with-modes '(php-mode)
|
||||
(sp-local-pair "/*" "*/" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "/**" "*/" :post-handlers '(("||\n[i]" "RET") ("||\n[i]" "SPC")))
|
||||
(sp-local-pair "<? " " ?>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC") ("| " "=")))
|
||||
(sp-local-pair "<?php " " ?>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "<?" "?>" :when '(("RET")) :post-handlers '("||\n[i]"))
|
||||
(sp-local-pair "<?php" "?>" :when '(("RET")) :post-handlers '("||\n[i]")))
|
||||
|
||||
(use-package php-refactor-mode
|
||||
:init
|
||||
(add-hook! php-mode '(turn-on-eldoc-mode emr-initialize php-refactor-mode))
|
||||
|
|
|
@ -24,7 +24,14 @@
|
|||
(require 'company-shell)
|
||||
|
||||
;; Fontify variables in strings
|
||||
(add-hook 'sh-mode-hook 'narf|sh-extra-font-lock-activate))
|
||||
(add-hook 'sh-mode-hook 'narf|sh-extra-font-lock-activate)
|
||||
|
||||
(sp-with-modes '(sh-mode)
|
||||
(sp-local-pair "case" "" :when '(("SPC")) :post-handlers '((:add narf/sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "if" "" :when '(("SPC")) :post-handlers '((:add narf/sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "for" "" :when '(("SPC")) :post-handlers '((:add narf/sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "elif" "" :when '(("SPC")) :post-handlers '((:add narf/sp-insert-yasnippet)) :actions '(insert))
|
||||
(sp-local-pair "while" "" :when '(("SPC")) :post-handlers '((:add narf/sp-insert-yasnippet)) :actions '(insert))))
|
||||
|
||||
(provide 'module-sh)
|
||||
;;; module-sh.el ends here
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
:init
|
||||
(add-hook! markdown-mode 'narf|enable-hard-wrap)
|
||||
:config
|
||||
(sp-local-pair 'markdown-mode "```" "```"
|
||||
:post-handlers '(("||\n[i]" "RET"))
|
||||
:unless '(sp-point-before-word-p sp-point-before-same-p))
|
||||
|
||||
(map! (:map markdown-mode-map
|
||||
"<backspace>" nil
|
||||
"<M-left>" nil
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
(setq-default css-indent-offset 2)
|
||||
(setq scss-compile-at-save nil)
|
||||
:config
|
||||
(sp-local-pair 'scss-mode "/*" "*/" :post-handlers '(("[d-3]||\n[i]" "RET") ("| " "SPC")))
|
||||
|
||||
(map! :map scss-mode-map
|
||||
:n "M-r" 'narf/web-refresh-browser
|
||||
(:leader
|
||||
|
@ -60,6 +62,12 @@
|
|||
(setq web-mode-enable-auto-pairing nil
|
||||
web-mode-enable-auto-quoting nil)
|
||||
:config
|
||||
(sp-with-modes '(web-mode)
|
||||
(sp-local-pair "{{!--" "--}}" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "<%" "%>" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "{!!" "!!}" :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))
|
||||
(sp-local-pair "{#" "#}" :post-handlers '(("||\n[i]" "RET") ("| " "SPC"))))
|
||||
|
||||
(after! web-beautify
|
||||
(add-hook! web-mode (setenv "jsbeautify_indent_size" "4"))
|
||||
(map! :map web-mode-map :m "gQ" 'web-beautify-html))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue