The symbol detections in “symbols.scm” of the built-in Javascript Language omits literal objects among others.
So I made a regex language to explore the issue and manage to get it working. Then I move to do the same with tree-sitter. I got my language extension which is just the stock “tree-sitter-javascript” grammar.
I only worked on my “symbols.scm” and got the literal objects to be included in the symbol tree. Yet…
No matter what I try I can’t get the members like functions (“pair”) to be listed in the subtree. (I was able to do it in my regex version.)
Any pointer will be appreciated.
PS: I don’t plan to publish the language extension, I just wanted to work our what I wanted and send a new Feature Request to Nova.
; symbols.scm
; My code is on top of other queries...
; Literal object assignment
((assignment_expression
	left: [
	  (identifier) @name
	  (member_expression) @name
	]
	right: [
	  (object)
	  (object_pattern)
	] @subtree
  )
  (#set! role variable)
)
; Literal object declaration
(
	(comment)* @doc
	.
	(lexical_declaration
		(variable_declarator
			name: (identifier) @name
			value: [(object) (object_pattern)]
		) @subtree @_object.literal
	) 
	(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
	(#select-adjacent! @doc @_object.literal)
	(#set! role variable)
)
; Literal object declaration
(
	(comment)* @doc
	.
	(variable_declaration
		(variable_declarator
		name: (identifier) @name
		value: [(object) (object_pattern)]
		) @subtree @_object.literal
	)
	(#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$")
	(#select-adjacent! @doc @_object.literal)
	(#set! role variable)
)