Skip to content

Commit

Permalink
[Lisp] Add variable definitions to Symbol List
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Feb 10, 2024
1 parent 9ea3e0f commit 99a24ee
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 2 deletions.
55 changes: 54 additions & 1 deletion Lisp/Lisp.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,60 @@ contexts:
# https://www.lispworks.com/documentation/HyperSpec/Body/s_let_l.htm
- match: (?i:let\*?){{break}}
scope: keyword.declaration.variable.lisp
set: expect-lists-list
set: variable-declaration-list
# https://www.lispworks.com/documentation/lw445/CLHS/Body/m_defcon.htm
- match: (?i:defconstant){{break}}
scope: meta.declaration.lisp keyword.declaration.constant.lisp
set: constant-declaration-name
# https://www.lispworks.com/documentation/HyperSpec/Body/m_defpar.htm
- match: (?i:defparameter|defvar){{break}}
scope: meta.declaration.lisp keyword.declaration.variable.lisp
set: variable-declaration-name

variable-declaration-list:
- meta_include_prototype: false
- match: \(
scope: punctuation.section.parens.begin.lisp
set: variable-declaration-list-body
- include: comments
- include: else-pop

variable-declaration-list-body:
- meta_scope: meta.parens.lisp
- match: \(
scope: punctuation.section.parens.begin.lisp
push:
- paren-body
- variable-declaration-name
- match: '{{identifier}}'
scope: meta.declaration.lisp variable.other.lisp
captures:
1: punctuation.definition.symbol.begin.lisp
2: punctuation.definition.symbol.end.lisp
- include: comments
- include: paren-end

constant-declaration-name:
- meta_content_scope: meta.declaration.lisp
- match: '{{identifier}}'
scope: meta.declaration.lisp constant.other.lisp
captures:
1: punctuation.definition.symbol.begin.lisp
2: punctuation.definition.symbol.end.lisp
pop: 1
- include: comments
- include: else-pop

variable-declaration-name:
- meta_content_scope: meta.declaration.lisp
- match: '{{identifier}}'
scope: meta.declaration.lisp variable.other.lisp
captures:
1: punctuation.definition.symbol.begin.lisp
2: punctuation.definition.symbol.end.lisp
pop: 1
- include: comments
- include: else-pop

###[ OTHER DECLARATIONS ]######################################################

Expand Down
17 changes: 17 additions & 0 deletions Lisp/Symbol List - Variables.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>
source.lisp meta.declaration constant.other,
source.lisp meta.declaration variable.other
</string>
<key>settings</key>
<dict>
<key>showInSymbolList</key>
<integer>1</integer>
<key>showInIndexedSymbolList</key>
<integer>0</integer>
</dict>
</dict>
</plist>
36 changes: 35 additions & 1 deletion Lisp/tests/syntax_test_lisp.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,40 @@
; ^^^^^^^^^ keyword.operator.logical.lisp
; ^^^^^^^^^^^^^^^ variable.other.lisp
;########################
; VARIABLE DECLARATIONS #
;########################
(defconstant +name+ value "documentation")
; <- meta.parens.lisp punctuation.section.parens.begin.lisp
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.parens.lisp
;^^^^^^^^^^^^^^^^^^ meta.declaration.lisp
;^^^^^^^^^^^ keyword.declaration.constant.lisp
; ^^^^^^ constant.other.lisp
; ^^^^^ variable.other.lisp
; ^^^^^^^^^^^^^^^ meta.string.lisp string.quoted.double.lisp
; ^ punctuation.section.parens.end.lisp
(defparameter *name* value "documentation")
; <- meta.parens.lisp punctuation.section.parens.begin.lisp
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.parens.lisp
;^^^^^^^^^^^^^^^^^^^ meta.declaration.lisp
;^^^^^^^^^^^^ keyword.declaration.variable.lisp
; ^^^^^^ variable.other.lisp
; ^^^^^ variable.other.lisp
; ^^^^^^^^^^^^^^^ meta.string.lisp string.quoted.double.lisp
; ^ punctuation.section.parens.end.lisp
(defvar *name* value "documentation")
; <- meta.parens.lisp punctuation.section.parens.begin.lisp
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.parens.lisp
;^^^^^^^^^^^^^ meta.declaration.lisp
;^^^^^^ keyword.declaration.variable.lisp
; ^^^^^^ variable.other.lisp
; ^^^^^ variable.other.lisp
; ^^^^^^^^^^^^^^^ meta.string.lisp string.quoted.double.lisp
; ^ punctuation.section.parens.end.lisp
;##############################
; LOCAL FUNCTION DECLARATIONS #
;##############################
Expand Down Expand Up @@ -2350,7 +2384,7 @@
; ^ meta.parens.lisp - meta.parens meta.parens
;^^^ keyword.declaration.variable.lisp
; ^ punctuation.section.parens.begin.lisp
; ^^^^^ variable.other.lisp
; ^^^^^ meta.declaration.lisp variable.other.lisp
; ^ punctuation.section.parens.begin.lisp
; ^^^^^ variable.other.lisp
; ^ punctuation.section.parens.begin.lisp
Expand Down

0 comments on commit 99a24ee

Please sign in to comment.