From 0475913071cf09d41b17d552543bdfec72033f2c Mon Sep 17 00:00:00 2001 From: Chen Bin Date: Fri, 29 Nov 2024 15:09:07 +1100 Subject: [PATCH] yaml-mode optimization --- lisp/init-evil.el | 18 ++++++++++++++++-- lisp/init-misc.el | 3 ++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lisp/init-evil.el b/lisp/init-evil.el index 83ed0a724..55f5a887b 100644 --- a/lisp/init-evil.el +++ b/lisp/init-evil.el @@ -382,9 +382,22 @@ COUNT, BEG, END, TYPE is used. If INCLUSIVE is t, the text object is inclusive. "Go to local definition or first occurrence of symbol in current buffer." :jump t :type exclusive - (let* ((string (evil-find-symbol t)) - (search (format "\\_<%s\\_>" (regexp-quote string))) + (let ((string (evil-find-symbol t)) + search ientry ipos) + + ;; left string "$" from variable name in some major modes + (when (and (memq major-mode '(yaml-mode + sh-mode + conf-mode + cmake-mode + dockerfile-mode + graphql-mode)) + (string-match "^\$[A-Za-z]" string)) + (setq string (substring string 1))) + + (setq search (format "\\_<%s\\_>" (regexp-quote string))) + ;; load imenu if available (my-ensure 'imenu) @@ -400,6 +413,7 @@ COUNT, BEG, END, TYPE is used. If INCLUSIVE is t, the text object is inclusive. ((and (derived-mode-p 'js2-mode) (cl-intersection (my-what-face) '(rjsx-tag))) (js2-jump-to-definition)) + ((fboundp 'imenu--make-index-alist) (condition-case nil (setq ientry (imenu--make-index-alist)) diff --git a/lisp/init-misc.el b/lisp/init-misc.el index 6ea12e64d..6366a84ad 100644 --- a/lisp/init-misc.el +++ b/lisp/init-misc.el @@ -1135,7 +1135,8 @@ It's also controlled by `my-lazy-before-save-timer'." (with-eval-after-load 'yaml-mode (setq yaml-imenu-generic-expression - '((nil "^\\(:?[0-9a-zA-Z_-]+\\):" 1)))) + '((nil "^\\(:?[0-9a-zA-Z_-]+\\):" 1) + (nil "^ *\\([A-Z][0-9A-Z_-]+\\):" 1)))) ;; {{ calendar setup (with-eval-after-load 'calendar