theNewDynamic / language-hugo-vscode

Adds syntax highlighting to Hugo files in VS Code
https://marketplace.visualstudio.com/items?itemName=budparr.language-hugo-vscode
Apache License 2.0
69 stars 20 forks source link
hugo snippets vscode

language-hugo README

Syntax highlighting and snippets for Hugo websites.

Features

Makes Hugo templating fit in with the rest of your HTML.

Includes 24 completion snippets for Go Template, see full list below.

Includes snippets for Hugo Shortcodes in Markdown and TOML file, list to come.

Template Snippets

Snippet Tab Trigger Output
Curlies x {{ }}
Dot xx {{ . }}
If if {{ if }} {{ end }}
If Inline ifi Same as above but inline
If/Else ife {{ if }} {{ else }} {{ end }}
If/Else if ifei {{ if }} {{ else if }} {{ end }}
With with {{ with }} {{ end }}
With/Else withe {{ with }} {{ else }} {{ end }}
Range range {{ range }} {{ end }}
Partial partial {{ partial "" . }}
partialCached partialc {{ partialCached "" . variant }}
Naked partial xpartial partial "" .
Block block {{ block "main" . }} {{ end }}
Block define define {{ define "block" }} {{ end }}
Scratch  scra {{ .Scratch.Set|Get|Add|SetInMap|Delete|GetSortedMapValues }}
String str {{ printf "Something about %s" . }}
printF  print  printf "%s|%v|%d|%x" .
Variable vars {{ $var := what }}
Return  ret  {{ return $return }}
Debug debug {{ printf "%#v" . }}
Error error {{ errorf "%#v" . }}
Comment comm {{/* */}}

Known Issues

For Hugo Shortcode snippets to work in your Markdown files, enable quickSuggestions in your User Settings

"[markdown]": {
  "editor.quickSuggestions": true
}

Release Notes

See the Changelog

Roadmap

Acknowledgments

Thank you to Matt Stratton for creating the Atom Language-hugo plugin, from which this borrows heavily.

Thank you to Steve Francia, Bjørn Erik and the Hugo community of contributors and users.