Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

feat: add objects and arrays in javascript #107

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lua/nvim-gps/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ local configs = {}

local function setup_language_configs()
configs = {
["javascript"] = with_default_config({
icons = {
["array-name"] = ' ',
["object-name"] = ' ',
}
}),
["json"] = with_default_config({
icons = {
["array-name"] = ' ',
Expand Down
36 changes: 36 additions & 0 deletions queries/javascript/nvimGPS.scm
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,39 @@
((field_definition
property: (property_identifier) @method-name
value: (arrow_function)) @scope-root)

; object literal
((variable_declarator
name: (identifier) @object-name
value: (object)) @scope-root)

; object literal modification
((assignment_expression
left: (identifier) @object-name
right: (object)) @scope-root)

; nested objects
((pair
key: (property_identifier) @object-name
value: (_)) @scope-root)

; nested objects with computed_property_name e.g. { [bar] : true }
((pair
key: (computed_property_name) @object-name
value: (_)) @scope-root)

; object property modification
((assignment_expression
left: (member_expression) @object-name
right: (object)) @scope-root)

; array
((variable_declarator
name: (identifier) @array-name
value: (array)) @scope-root)

; array modification
((assignment_expression
left: (identifier) @array-name
right: (array)) @scope-root)