diff --git a/emacs/.emacs.d/config/init-terraform.el b/emacs/.emacs.d/config/init-terraform.el index d8c88ed..df443fe 100644 --- a/emacs/.emacs.d/config/init-terraform.el +++ b/emacs/.emacs.d/config/init-terraform.el @@ -16,12 +16,11 @@ (block (treesit-node-top-level current-node "block")) (capture (when block (treesit-query-capture block - '((block (identifier) @id (:match "^\\(data\\|resource\\)$" @id) - (string_lit (_) (template_literal) @name (_)))))))) - (->> (-take 2 capture) - (-map (lambda (r) - (let ((key (if (eq (car r) 'id) 'type (car r)))) - (cons key (treesit-node-text (cdr r) t)))))))) + '((block (identifier) @type (:match "^\\(data\\|resource\\)$" @type) + (string_lit (_) (template_literal) @name (_))))))) + (capture (let ((-compare-fn (lambda (a b) (eq (car a) (car b))))) + (-distinct capture)))) + (-map (lambda (r) (cons (car r) (treesit-node-text (cdr r) t))) capture))) (defun terraform-block-metadata-at-point () (terraform-block-metadata-at-pos (point)))