dotfiles/vim/after/queries/go/textobjects.scm

29 lines
788 B
Scheme

;; key/value-like types. Works with struct values, struct definitions and parameter value/type pairs:
;;
;; @keyed_element.outer => key and value
;; @keyed_element.inner => value
(keyed_element (_) . (_) @keyed_element.inner) @keyed_element.outer
(field_declaration type: (_) @keyed_element.inner) @keyed_element.outer
(parameter_declaration type: (_) @keyed_element.inner) @keyed_element.outer
;; return statement
(return_statement (_) @return)
;; functions and methods with an optional preceeding comment:
;;
;; TODO: comment only matches a single line.
((
(comment)? @_start
.
(method_declaration) @_end
) (make-range! "function_with_comment" @_start @_end))
((
(comment)? @_start
.
(function_declaration) @_end
) (make-range! "function_with_comment" @_start @_end))