aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwinwisely268 <winwisely268@gmail.com>2020-07-16 08:58:19 +0000
committerThomas Vigouroux <39092278+vigoux@users.noreply.github.com>2020-07-16 11:09:33 +0200
commitee4cd7b0fd6a0995f6bd18c32a95cb4dc248828f (patch)
treecbae8b09e71b1feea59763725c1aa69cf8c18ca5
parenthighlights: some fixes (diff)
downloadnvim-treesitter-ee4cd7b0fd6a0995f6bd18c32a95cb4dc248828f.tar
nvim-treesitter-ee4cd7b0fd6a0995f6bd18c32a95cb4dc248828f.tar.gz
nvim-treesitter-ee4cd7b0fd6a0995f6bd18c32a95cb4dc248828f.tar.bz2
nvim-treesitter-ee4cd7b0fd6a0995f6bd18c32a95cb4dc248828f.tar.lz
nvim-treesitter-ee4cd7b0fd6a0995f6bd18c32a95cb4dc248828f.tar.xz
nvim-treesitter-ee4cd7b0fd6a0995f6bd18c32a95cb4dc248828f.tar.zst
nvim-treesitter-ee4cd7b0fd6a0995f6bd18c32a95cb4dc248828f.zip
added textobject support for golang
-rw-r--r--queries/go/textobjects.scm37
1 files changed, 37 insertions, 0 deletions
diff --git a/queries/go/textobjects.scm b/queries/go/textobjects.scm
new file mode 100644
index 000000000..61b968f3b
--- /dev/null
+++ b/queries/go/textobjects.scm
@@ -0,0 +1,37 @@
+;; function textobject
+(function_declaration
+ body: (block)? @function.inner) @function.outer
+
+;; method as function textobject
+(method_declaration
+ body: (block)? @function.inner) @function.outer
+
+;; struct and interface declaration as class textobject?
+(type_declaration
+ (type_spec (type_identifier) (struct_type (field_declaration_list (_)?) @class.inner))) @class.outer
+
+(type_declaration
+ (type_spec (type_identifier) (interface_type (method_spec_list (_)?) @class.inner))) @class.outer
+
+;; struct literals as class textobject
+(composite_literal
+ (type_identifier)?
+ (struct_type (_))?
+ (literal_value (_)) @class.inner) @class.outer
+
+;; conditionals
+(if_statement
+ alternative: (_ (_) @conditional.inner)?) @conditional.outer
+
+(if_statement
+ consequence: (block)? @conditional.inner)
+
+(if_statement
+ condition: (_) @conditional.inner)
+
+;; blocks
+(_ (block) @block.inner) @block.outer
+;; statements
+(block (_) @statement.outer)
+;; comments
+(comment) @comment.outer