From 6d4665f3dd5c40a612b2a3cada148642fadf488f Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 5 Oct 2022 00:11:46 +0100 Subject: [PATCH] fix(language/go): add tree-sitter query for highlighting struct properties The field_identifier type was recently removed from tree-sitter-go here: https://github.com/tree-sitter/tree-sitter-go/pull/71 This means that struct keys are no longer syntax highlighted as properties, which I dislike. Hence this new query targets the first element of a key/value pair, and marks the first element as a @property if it contains an identifier. I'm not sure if this undoes the goal of removing the field_identifier, but for now, it resolves my personal annoyance of struct keys not be highlighted as properties when creating a new instance of the struct. --- modules/languages/siren-golang.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/languages/siren-golang.el b/modules/languages/siren-golang.el index d6a5955f..3dd14f1d 100644 --- a/modules/languages/siren-golang.el +++ b/modules/languages/siren-golang.el @@ -79,6 +79,12 @@ (call_expression function: (identifier) @function.builtin (.match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$")) + ;; Highlight struct/block keys as properties after field_identifier was + ;; removed from the Go parser: + ;; https://github.com/tree-sitter/tree-sitter-go/pull/71 + (keyed_element + \. + (literal_element (identifier)) @property) ])) :config