Skip to content

Commit 0475913

Browse files
author
Chen Bin
committed
yaml-mode optimization
1 parent 10cb5a9 commit 0475913

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lisp/init-evil.el

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,22 @@ COUNT, BEG, END, TYPE is used. If INCLUSIVE is t, the text object is inclusive.
382382
"Go to local definition or first occurrence of symbol in current buffer."
383383
:jump t
384384
:type exclusive
385-
(let* ((string (evil-find-symbol t))
386-
(search (format "\\_<%s\\_>" (regexp-quote string)))
385+
(let ((string (evil-find-symbol t))
386+
search
387387
ientry ipos)
388+
389+
;; left string "$" from variable name in some major modes
390+
(when (and (memq major-mode '(yaml-mode
391+
sh-mode
392+
conf-mode
393+
cmake-mode
394+
dockerfile-mode
395+
graphql-mode))
396+
(string-match "^\$[A-Za-z]" string))
397+
(setq string (substring string 1)))
398+
399+
(setq search (format "\\_<%s\\_>" (regexp-quote string)))
400+
388401
;; load imenu if available
389402
(my-ensure 'imenu)
390403

@@ -400,6 +413,7 @@ COUNT, BEG, END, TYPE is used. If INCLUSIVE is t, the text object is inclusive.
400413
((and (derived-mode-p 'js2-mode)
401414
(cl-intersection (my-what-face) '(rjsx-tag)))
402415
(js2-jump-to-definition))
416+
403417
((fboundp 'imenu--make-index-alist)
404418
(condition-case nil
405419
(setq ientry (imenu--make-index-alist))

lisp/init-misc.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,8 @@ It's also controlled by `my-lazy-before-save-timer'."
11351135

11361136
(with-eval-after-load 'yaml-mode
11371137
(setq yaml-imenu-generic-expression
1138-
'((nil "^\\(:?[0-9a-zA-Z_-]+\\):" 1))))
1138+
'((nil "^\\(:?[0-9a-zA-Z_-]+\\):" 1)
1139+
(nil "^ *\\([A-Z][0-9A-Z_-]+\\):" 1))))
11391140

11401141
;; {{ calendar setup
11411142
(with-eval-after-load 'calendar

0 commit comments

Comments
 (0)