From 30e2d2898c48fe8b581d8001fabf9baabafc38c8 Mon Sep 17 00:00:00 2001 From: Dylan Byars Date: Tue, 31 May 2022 00:01:09 -0400 Subject: [PATCH] feat: add objects and arrays in javascript --- lua/nvim-gps/init.lua | 12 ++++++++++++ queries/javascript/nvimGPS.scm | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/lua/nvim-gps/init.lua b/lua/nvim-gps/init.lua index 8a8f1e8..59c42b6 100644 --- a/lua/nvim-gps/init.lua +++ b/lua/nvim-gps/init.lua @@ -43,6 +43,18 @@ local configs = {} local function setup_language_configs() configs = { + ["typescript"] = with_default_config({ + icons = { + ["array-name"] = ' ', + ["object-name"] = ' ', + } + }), + ["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) +