From d27716c09bc26287576c8e86b777f20963d6c74c Mon Sep 17 00:00:00 2001 From: qvalentin Date: Sun, 22 Sep 2024 13:47:23 +0200 Subject: [PATCH 1/2] fix(gotmpl): cleanup queries highlights are now upstreamed to https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/gotmpl/highlights.scm --- queries/gotmpl/highlights.scm | 85 ----------------------------------- queries/gotmpl/injections.scm | 2 - 2 files changed, 87 deletions(-) delete mode 100644 queries/gotmpl/highlights.scm diff --git a/queries/gotmpl/highlights.scm b/queries/gotmpl/highlights.scm deleted file mode 100644 index 8a09ba560..000000000 --- a/queries/gotmpl/highlights.scm +++ /dev/null @@ -1,85 +0,0 @@ -; Copyright: https://github.com/ngalaiko/tree-sitter-go-template -; Identifiers - -[ - (field) - (field_identifier) -] @property - -(variable) @variable - -; Function calls - -(function_call - function: (identifier) @function) - -(method_call - method: (selector_expression - field: (field_identifier) @method)) - -; Operators - -"|" @operator -":=" @operator - -; Builtin functions - -((identifier) @function.builtin - (#match? @function.builtin "^(and|call|html|index|slice|js|len|not|or|print|printf|println|urlquery|eq|ne|lt|ge|gt|ge)$")) - -; Delimiters - -"." @punctuation.delimiter -"," @punctuation.delimiter - -"{{" @punctuation.bracket -"}}" @punctuation.bracket -"{{-" @punctuation.bracket -"-}}" @punctuation.bracket -")" @punctuation.bracket -"(" @punctuation.bracket - -; Keywords - -[ - "else" - "else if" - "if" - "with" -] @conditional - -[ - "range" - "end" - "template" - "define" - "block" -] @keyword - -; Literals - -[ - (interpreted_string_literal) - (raw_string_literal) - (rune_literal) -] @string - -(escape_sequence) @string.special - -[ - (int_literal) - (float_literal) - (imaginary_literal) -] @number - -[ - (true) - (false) -] @boolean - -[ - (nil) -] @constant.builtin - -(comment) @comment -(ERROR) @error diff --git a/queries/gotmpl/injections.scm b/queries/gotmpl/injections.scm index 4d15dbac5..c96793728 100644 --- a/queries/gotmpl/injections.scm +++ b/queries/gotmpl/injections.scm @@ -1,5 +1,3 @@ -(text) @yaml - ((text) @injection.content (#set! injection.language "html") (#set! injection.combined)) From a04f62110a5c044547f5b34f35fdd08b5254e4cb Mon Sep 17 00:00:00 2001 From: qvalentin Date: Sun, 22 Sep 2024 13:48:33 +0200 Subject: [PATCH 2/2] docs(gotmpl): update tree-sitter instructions As gotmpl is now upstreamed to https://github.com/nvim-treesitter/nvim-treesitter --- README.md | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 96551a42f..33a8d6f8a 100644 --- a/README.md +++ b/README.md @@ -1176,39 +1176,20 @@ local cfg = require'go.lsp'.config() -- config() return the go.nvim gopls setup require('lspconfig').gopls.setup(cfg) ``` -## Highlighting for gomod, gosum, gohtmltmpl, gotmpl, gotexttmpl +## Highlighting for gomod, gosum, gohtmltmpl, gotmpl -You can install treesitter parser for gomod and gosum +You can install tree-sitter parsers for gomod, gosum and gotmpl ```vim -:TSInstall gomod gosum -``` - -As for go template, the plugin has not been merge to treeistter master yet, you need to install -[treesitter-go-template](https://github.com/ngalaiko/tree-sitter-go-template) - -```lua -local parser_config = require'nvim-treesitter.parsers'.get_parser_configs() -parser_config.gotmpl = { - install_info = { - url = "https://github.com/ngalaiko/tree-sitter-go-template", - files = {"src/parser.c"} - }, - filetype = "gotmpl", - used_by = {"gohtmltmpl", "gotexttmpl", "gotmpl", "yaml"} -} -``` - -And run - -```vim -:TSInstall gotmpl +:TSInstall gomod gosum gotmpl ``` The plugin injects the tmpl to html syntax so you should see this: ![image](https://github.com/ray-x/go.nvim/assets/1681295/7d11eb96-4803-418b-b056-336163ed492b) +To get highlighting for other templated languages check out the docs of [tree-sitter-go-template](https://github.com/ngalaiko/tree-sitter-go-template). + ## Integrate null-ls ### The plugin provides: