{"id":15199834,"url":"https://github.com/charlespascoe/vim-go-syntax","last_synced_at":"2025-10-28T14:30:37.894Z","repository":{"id":65355378,"uuid":"561910439","full_name":"charlespascoe/vim-go-syntax","owner":"charlespascoe","description":"Fast, 'tree-sitter'-like Vim Syntax Highlighting for Go","archived":false,"fork":false,"pushed_at":"2024-12-23T17:25:46.000Z","size":1042,"stargazers_count":52,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-08T07:29:23.960Z","etag":null,"topics":["go","go-syntax","golang","vim","vim-syntax","vim-syntax-highlight","vim-syntax-highlighting"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charlespascoe.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-04T19:20:51.000Z","updated_at":"2025-01-18T01:00:11.000Z","dependencies_parsed_at":"2023-12-09T17:32:10.081Z","dependency_job_id":"29c030f6-0286-4fb5-b010-d063428cf77e","html_url":"https://github.com/charlespascoe/vim-go-syntax","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlespascoe%2Fvim-go-syntax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlespascoe%2Fvim-go-syntax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlespascoe%2Fvim-go-syntax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlespascoe%2Fvim-go-syntax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charlespascoe","download_url":"https://codeload.github.com/charlespascoe/vim-go-syntax/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238662633,"owners_count":19509639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","go-syntax","golang","vim","vim-syntax","vim-syntax-highlight","vim-syntax-highlighting"],"created_at":"2024-09-28T02:03:18.516Z","updated_at":"2025-10-28T14:30:36.500Z","avatar_url":"https://github.com/charlespascoe.png","language":"Vim Script","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fast, 'tree-sitter'-like Vim Syntax Highlighting for Go\n\n`vim-go-syntax` provides fast and feature-rich Vim syntax highlighting for Go,\nwith results comparable to tree-sitter in Neovim.\n\n\u003e **Feedback is welcome!** This syntax is still fairly new and I'd like feedback\n\u003e or issues to improve it. Please see if there's already an issue open or create\n\u003e a new one.\n\nSyntax highlighting can make reading code easier by using colour to convey\nadditional information. Existing Vim syntax definitions aren't able to to\ncorrectly highlight key parts of the syntax, which motivated me to write\n`vim-go-syntax` from the ground up using the Go language specification. Not only\ndoes it fix many of the shortfalls of existing syntax definitions, it's more\nthan 2x faster even with _all_ features enabled!\n\n\u003ca href=\"Syntax%20Comparison.png?raw=true\" target=\"_blank\"\u003e\n\u003cimg\n    src=\"Syntax%20Comparison.png\"\n    title=\"Syntax Comparison; vim-go on the left, vim-go-syntax on the right\"\n/\u003e\n\u003c/a\u003e\n\nComparison of `vim-go` (left) with `vim-go-syntax` (right) using my colour\nscheme; see `:help group-name` to see how your colour scheme highlights Vim's\ndefault syntax groups. Most syntax highlighting features can be disabled if\nyou'd prefer - see [Configuration](#configuration).\n\n## Key Features\n\nKey features compared to `vim-go` and the built-in Vim syntax:\n\n- **Correctly display user-defined types and packages**\n    - E.g in structs, struct literals, parameters, slices, maps, `var`/`const`\n      declarations, type parameters, type assertions, type switches, `make()`,\n      `new()`, etc.\n- **Correctly highlights imported package names**\n- **Godoc highlighting in `vim-go`**\n- **More customisable [Configuration](#configuration)**\n- **Vastly more fine-grained highlighting**\n- **Parentheses, Braces, and Brackets highlighted and individually configurable**\n    - E.g. struct and function braces can be different\n- **Correctly highlight functions**, including:\n    - User-defined types and packages in receiver, parameters, and return types\n    - Multiline parameters/return values, including successive parameters of the\n      same type\n    - Identifier/type differentiation in function types (e.g. `func (int,\n      MyType)` vs `func (a, b MyType)`) and return types\n- **Correctly handle generics:**\n    - Type parameters and their constraints (including user-defined types) are\n      highlighted correctly\n    - User-defined types in type arguments are highlighted correctly\n    - Type arguments don't break function call or struct value highlighting\n- **Multiline field chains**, even with comments\n- **Correct use of Vim's syntax groups**\n    - More consistent with syntax definitions of other languages. See `:help\n      group-name` to see your current colour scheme (or `:help :hi` to create\n      your own).\n- Many other small improvements, including labels, embedded types, invalid rune\n  error highlighting, and better string behaviour.\n\n## Configuration\n\nListed in the table below are various options that can be used to customise\nhighlighting. These can be set at any time before the syntax is loaded, usually\nyour `.vimrc` is best.\n\nEach option can be:\n\n- A `1` or a `0` to enable/disable the highlighting. For example:\n\n```vim\nlet g:go_highlight_parens = 0\nlet g:go_highlight_fields = 1\n```\n\n- A syntax group name; see '`:help group-name`' to see what default groups are\n  available and how your colour scheme styles them. For example, to make\n  function calls look like types:\n\n```vim\nlet g:go_highlight_function_calls = 'Type'\n```\n\n- A highlight description; see '`:help hi`' for syntax and options. For example,\n  to make type parameters blue and italic:\n\n```vim\nlet g:go_highlight_type_parameters = 'ctermfg=4 cterm=italic'\n```\n\nIf you want even more customisation, you can override the default highlighting\nby adding custom highlighting rules to `~/.vim/after/syntax/go.vim` (you'll need\nto create this file first). The previous configuration examples could also be\nachieved like this:\n\n```vim\n\" ~/.vim/after/syntax/go.vim\n\nhi clear goParens\n\nhi link goField Identifier\n\nhi link goFuncCall Type\n\nhi goTypeParam ctermfg=4 cterm=italic\n```\n\nSee `syntax/go.vim` for the names of all syntax and\nhighlight groups.\n\nSummary of options (see below table for descriptions):\n\n| Configuration Option                         | Default     | Default Group |\n| -------------------------------------------- | ----------- | ------------- |\n| `g:go_highlight_braces`                      | **Enabled** | `Delimiter`   |\n| `g:go_highlight_brackets`                    | **Enabled** | `Delimiter`   |\n| `g:go_highlight_builtins`                    | **Enabled** | `Special`     |\n| `g:go_highlight_comma`                       |   Disabled  | `Delimiter`   |\n| `g:go_highlight_dot`                         | **Enabled** | `Operator`    |\n| `g:go_highlight_fields`                      |   Disabled  | `Identifier`  |\n| `g:go_highlight_format_strings`              | **Enabled** | `SpecialChar` |\n| `g:go_highlight_format_string_errors`        |   Disabled  | `Error`       |\n| `g:go_highlight_functions`                   | **Enabled** | `Function`    |\n| `g:go_highlight_function_parens`             | **Enabled** | `Delimiter`   |\n| `g:go_highlight_function_braces`             | **Enabled** | `Delimiter`   |\n| `g:go_highlight_function_calls`              | **Enabled** | `Function`    |\n| `g:go_highlight_function_call_parens`        | **Enabled** | `Delimiter`   |\n| `g:go_highlight_generate_tags`               | **Enabled** | `PreProc`     |\n| `g:go_highlight_rune_literal_error`          | **Enabled** | `Error`       |\n| `g:go_highlight_labels`                      | **Enabled** | `Label`       |\n| `g:go_highlight_map_brackets`                | **Enabled** | `Delimiter`   |\n| `g:go_highlight_operators`                   | **Enabled** | `Operator`    |\n| `g:go_highlight_function_parameters`         | **Enabled** | `Identifier`  |\n| `g:go_highlight_parens`                      | **Enabled** | `Delimiter`   |\n| `g:go_highlight_semicolon`                   |   Disabled  | `Delimiter`   |\n| `g:go_highlight_short_variable_declarations` | **Enabled** | `Identifier`  |\n| `g:go_highlight_slice_brackets`              | **Enabled** | `Delimiter`   |\n| `g:go_highlight_format_strings`              | **Enabled** | `SpecialChar` |\n| `g:go_highlight_struct_type_fields`          |   Disabled  | `Identifier`  |\n| `g:go_highlight_struct_tags`                 | **Enabled** | `PreProc`     |\n| `g:go_highlight_struct_fields`               |   Disabled  | `Identifier`  |\n| `g:go_highlight_types`                       | **Enabled** | `Type`        |\n| `g:go_highlight_type_parameters`             | **Enabled** | `Identifier`  |\n| `g:go_highlight_variable_assignments`        |   Disabled  | `Special`     |\n| `g:go_highlight_variable_declarations`       | **Enabled** | `Identifier`  |\n\n\n- `g:go_highlight_braces`\n    - All braces (`{}`). More specific brace options (e.g.\n  `g:go_highlight_function_braces`) will take precedence over this option.\n- `g:go_highlight_brackets`\n    - All brackets (`[]`). More specific bracket options (e.g.\n      `g:go_highlight_map_brackets`) will take precedence over this option.\n- `g:go_highlight_builtins`\n    - Highlight built-in functions differently from other functions.\n- `g:go_highlight_comma`\n    - Commas.\n- `g:go_highlight_dot`\n    - Dot operators, e.g. the dot in `foo.bar()`\n- `g:go_highlight_fields`\n    - Fields in expressions, e.g. `bar` in\n  `foo.bar = 123`\n- `g:go_highlight_format_strings`\n    - Format strings, e.g. `\"Hello, %s\"`.\n- `g:go_highlight_format_string_errors`\n    - Invalid format strings. Currently only zero index in format strings, e.g.\n      `fmt.Sprintf(\"%[0]d\", 123)` which should be `fmt.Sprintf(\"%[1]d\", 123)`.\n- `g:go_highlight_functions`\n    - Function declaration names, e.g. `foo` in `func foo() { }`. Also applies\n      to method names.\n- `g:go_highlight_function_parens`\n    - Parentheses around parameter list and receiver type.\n- `g:go_highlight_function_braces`\n    - The braces of the function block.\n- `g:go_highlight_function_calls`\n    - Function calls. Turning this off does not affect other syntax elements\n      (e.g. generics, function call parentheses).\n- `g:go_highlight_function_call_parens`\n    - The parentheses of a function call.\n- `g:go_highlight_generate_tags`\n    - Generate comments, e.g. `//go:generate ...`. Turning this off makes them\n      look like regular comments.\n- `g:go_highlight_rune_literal_error`\n    - Invalid rune literals.\n- `g:go_highlight_labels`\n    - User-defined labels.\n- `g:go_highlight_map_brackets`\n    - The brackets in map types, e.g.\n  `map[string]int`.\n- `g:go_highlight_operators`\n    - Operators including assignment, e.g. `+`, `-`, `\u0026\u0026`, `||`, `=`, `:=`, etc.\n- `g:go_highlight_function_parameters`\n    - Parameter names, e.g. `bar` in `func\n  foo(bar int)`\n- `g:go_highlight_parens`\n    - All parentheses. More specific parenthesis options (e.g.\n      `g:go_highlight_function_parens`) will take precedence.\n- `g:go_highlight_semicolon`\n    - Semicolons.\n- `g:go_highlight_short_variable_declarations`\n    - Highlight the names of new variables defined by the declaration syntax,\n      e.g. `a` and `b` in `a, b := foo()`.\n- `g:go_highlight_slice_brackets`\n    - The brackets in slice types, e.g. `[]string`.\n- `g:go_highlight_format_strings`\n    - Format placeholders in in format strings, e.g. `%s` in `fmt.Printf(\"%s\",\n      foo)`\n- `g:go_highlight_struct_type_fields`\n    - Field names in struct types, e.g. `Bar` in `type Foo struct { Bar int }`\n- `g:go_highlight_struct_tags`\n    - Struct tags, the backtick-delimited strings in structs, e.g. `` `json:bar` ``\n      in ``struct { Bar int `json:\"bar\"` }``.\n- `g:go_highlight_struct_fields`\n    - Field names in struct literals, e.g. `Bar` in `f := Foo{ Bar: 123 }`.\n- `g:go_highlight_types`\n    - Type declaration names, e.g. `Foo` in `type Foo struct { Bar int }`. Even\n      with this option off, types parameters etc. will still be highlighted\n      as types.\n- `g:go_highlight_type_parameters`\n    - Type parameter names in type parameter lists, e.g. the `T` in the brackets\n      of `type Foo[T] { Bar T }`; the `T` in the struct will be highlighted as a\n      type.\n- `g:go_highlight_variable_assignments`\n    - Variable names in assignments, e.g. `a` and `b` in `a, b = foo()`.\n- `g:go_highlight_variable_declarations`\n    - Names in `var` or `const` assignments, e.g. `a` in `var a []string`. Also\n      applies to short variable declarations (i.e. `:=`) unless\n      `g:go_highlight_short_variable_declarations` is set.\n\nOther configuration options:\n\n- `g:go_fold_decl_blocks` (default: 1)\n    - Fold `var` and `const` declaration blocks.\n- `g:go_fold_function_blocks` (default: 1)\n    - Fold function blocks.\n- `g:go_fold_struct_blocks` (default: 1)\n    - Fold struct blocks.\n- `g:go_fold_interface_blocks` (default: 1)\n    - Fold interface blocks.\n- `g:go_syntax_fold` (default: 1)\n    - Global fold setting. If set to 0, all folding is disabled. If set to 1,\n      each respective `g:go_fold_*` option is used.\n\n## Caveats\n\n- Type arguments to types and functions are limited to at most three nested\n  generic types, e.g. `val := Type1[Type2[Type3[Foo]]]{ ... }`. The number of\n  arguments at each level is unlimited, e.g. `Type1[Type2[A, B, C, ...]]`\n- The type parameters of a generic type embedded within a struct (that is, the\n  `A,B,C` in `struct { Foo[A,B,C] }`) can't be spread across multiple lines,\n  though this is very uncommon in practical use.\n- Structs literals (`MyStruct{...}`) can't have a space between the name and the\n  braces, despite the fact that Go permits this.\n- Type conversion (`MyType(someVal)`) is highlighted like a function call\n- A slice or map literal whose type is a function with multiple return values\n  and the type is not in parentheses (e.g. `[]func(a, b int) (c, d Foo){ f1, f2,\n  f3 }`) is technically valid Go code, but the `Foo` type will not be highlighted\n  correctly.\n    - This can easily be avoided by wrapping the type in parentheses to make it\n      clear (e.g. `[](func(a, b int) (c, d Foo)){ f1, f2, f3 }`, which is\n      highlighted correctly), or preferably use a named type to make the code\n      easier to read (e.g. `type MyFunc func(a, b int) (c, d Foo)`, and then use\n      `[]MyFunc{ f1, f2, f3 }`, all of which will be highlighted correctly).\n- `iota` is matched in any expression. While not ideal, this currently avoids\n  complex restructuring of the syntax code or performance degradation. It may be\n  worth revisiting this at some point.\n\n## What's Next\n\n- [ ] Possibly integrate with `vim-go` to get actual type information to\n  highlight things like type conversion correctly\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlespascoe%2Fvim-go-syntax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharlespascoe%2Fvim-go-syntax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlespascoe%2Fvim-go-syntax/lists"}