From 16ad161c74eb07e231902a1563a877d6fb39c237 Mon Sep 17 00:00:00 2001 From: Dylan Byars Date: Thu, 2 Jun 2022 23:24:13 -0400 Subject: [PATCH] feat: objects and arrays in javascript --- lua/nvim-gps/init.lua | 6 ++++++ queries/javascript/nvimGPS.scm | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/lua/nvim-gps/init.lua b/lua/nvim-gps/init.lua index 8a8f1e8..d062e21 100644 --- a/lua/nvim-gps/init.lua +++ b/lua/nvim-gps/init.lua @@ -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"] = ' ', diff --git a/queries/javascript/nvimGPS.scm b/queries/javascript/nvimGPS.scm index 4214d43..0d36776 100644 --- a/queries/javascript/nvimGPS.scm +++ b/queries/javascript/nvimGPS.scm @@ -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) +