[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode ae32a8b 071/496: Add basic imenu support
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode ae32a8b 071/496: Add basic imenu support |
Date: |
Sun, 29 Aug 2021 11:33:10 -0400 (EDT) |
branch: elpa/swift-mode
commit ae32a8b9ad0becb0f89bf065022094738153b1b5
Author: Chris Barrett <chris.d.barrett@me.com>
Commit: Chris Barrett <chris.d.barrett@me.com>
Add basic imenu support
Fixes #14
---
swift-mode.el | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/swift-mode.el b/swift-mode.el
index b0ffb2a..84faaff 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -274,6 +274,25 @@ Returns the column number as an integer."
(cons (rx bow "import" eow (+ space) (group (+ word)))
(list 1 font-lock-string-face)))))
+;;; Imenu
+
+(defun swift-mode--mk-regex-for-def (keyword)
+ "Make a regex matching the identifier introduced by KEYWORD."
+ (let ((ident (rx (any word nonascii "_") (* (any word nonascii digit "_")))))
+ (rx-to-string `(and bow ,keyword eow (+ space) (group (regexp ,ident)))
+ t)))
+
+(defvar swift-mode--imenu-generic-expression
+ (list
+ (list "Functions" (swift-mode--mk-regex-for-def "func") 1)
+ (list "Classes" (swift-mode--mk-regex-for-def "class") 1)
+ (list "Enums" (swift-mode--mk-regex-for-def "enum") 1)
+ (list "Protocols" (swift-mode--mk-regex-for-def "protocol") 1)
+ (list "Structs" (swift-mode--mk-regex-for-def "struct") 1)
+ (list "Constants" (swift-mode--mk-regex-for-def "let") 1)
+ (list "Variables" (swift-mode--mk-regex-for-def "var") 1))
+ "Value for `imenu-generic-expression' in swift-mode.")
+
;;; Mode definition
;; HACK: This syntax table is lifted directly from `rust-mode'. There may be
@@ -308,6 +327,8 @@ Returns the column number as an integer."
:group 'swift
:syntax-table swift-mode-syntax-table
(setq-local font-lock-defaults swift-mode--font-lock-defaults)
+ (setq-local imenu-generic-expression swift-mode--imenu-generic-expression)
+
(setq-local comment-start "// ")
(setq-local comment-end "")
(setq-local tab-width swift-indent-offset)
- [nongnu] elpa/swift-mode 8e69064 034/496: Mention package.el as an installation option, (continued)
- [nongnu] elpa/swift-mode 8e69064 034/496: Mention package.el as an installation option, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cfb3a6f 045/496: Setup some basic code style conventions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7ea5f66 059/496: Fix markdown formatting typo, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cd0aa34 072/496: Adding flycheck plugin for syntax check with swift cli, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 14c6bdd 079/496: Add swift repl commands to mode map, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1dfb1a5 110/496: Add indent rules for function declaration with attributes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 1a1d81c 125/496: Improve font-lock regex for string interpolation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 4059bc1 135/496: Add dot(.) to the allowed symbols inside string interpolation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 88a83ad 145/496: Apply DECSPEC token class only for functions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode fc009b5 069/496: Add font locking for indentation tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ae32a8b 071/496: Add basic imenu support,
ELPA Syncer <=
- [nongnu] elpa/swift-mode d02e2dc 024/496: Update contributors, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode fc64626 156/496: Merge pull request #56 from ap4y/fix_flycheck_issues, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9cf667c 159/496: Start work on 0.4, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode cba4538 161/496: Merge pull request #61 from ckruse/fix_55, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 5611c0f 164/496: Updated syntax: a lot of attributes moved to keywords, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 250e8e4 172/496: Merge pull request #67 from jmibanez/fix-flycheck-and-byte-compilation-bug, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a6267eb 189/496: Improve indentation for the function definitions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 782378c 214/496: Correct regex in lexer for the "default" keyword, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c38b721 216/496: Support default values for arguments in function declaration, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2cb54c9 222/496: Make grammar for if statement a bit more precise, ELPA Syncer, 2021/08/29