{"id":13439120,"url":"https://github.com/draivin/hsnips","last_synced_at":"2026-02-18T20:32:13.101Z","repository":{"id":42058771,"uuid":"211788813","full_name":"draivin/hsnips","owner":"draivin","description":"HyperSnips: a powerful snippet engine for VS Code, inspired by vim's UltiSnips","archived":false,"fork":false,"pushed_at":"2024-01-10T23:58:08.000Z","size":248,"stargazers_count":177,"open_issues_count":62,"forks_count":36,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-02-17T05:26:50.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/draivin.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-09-30T06:17:14.000Z","updated_at":"2026-02-15T13:27:33.000Z","dependencies_parsed_at":"2024-01-11T01:30:11.137Z","dependency_job_id":null,"html_url":"https://github.com/draivin/hsnips","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/draivin/hsnips","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/draivin%2Fhsnips","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/draivin%2Fhsnips/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/draivin%2Fhsnips/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/draivin%2Fhsnips/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/draivin","download_url":"https://codeload.github.com/draivin/hsnips/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/draivin%2Fhsnips/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29594259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T18:54:29.675Z","status":"ssl_error","status_checked_at":"2026-02-18T18:50:50.517Z","response_time":162,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-07-31T03:01:11.302Z","updated_at":"2026-02-18T20:32:13.068Z","avatar_url":"https://github.com/draivin.png","language":"TypeScript","funding_links":[],"categories":["HarmonyOS","others"],"sub_categories":["Windows Manager"],"readme":"# HyperSnips\n\n![](./images/welcome.gif)\n\nHyperSnips is a snippet engine for vscode heavily inspired by vim's\n[UltiSnips](https://github.com/SirVer/ultisnips).\n\n## Usage\n\nTo use HyperSnips you create `.hsnips` files on a directory which depends on your platform:\n\n- Windows: `%APPDATA%\\Code\\User\\globalStorage\\draivin.hsnips\\hsnips\\(language).hsnips`\n- Mac: `$HOME/Library/Application Support/Code/User/globalStorage/draivin.hsnips/hsnips/(language).hsnips`\n- Linux: `$HOME/.config/Code/User/globalStorage/draivin.hsnips/hsnips/(language).hsnips`\n\nYou can open this directory by running the command `HyperSnips: Open snippets directory`.\nThis directory may be customized by changing the setting `hsnips.hsnipsPath`.\nIf this setting starts with `~` or `${workspaceFolder}`, then it will be replaced with\nyour home directory or the current workspace folder, respectively.\n\nThe file should be named based on the language the snippets are meant for (e.g. `latex.hsnips`\nfor snippets which will be available for LaTeX files).\nAdditionally, you can create an `all.hsnips` file for snippets that should be available on all languages.\n\n### Snippets file\n\nA snippets file is a file with the `.hsnips` extension, the file is composed of two types of blocks:\nglobal blocks and snippet blocks.\n\nGlobal blocks are JavaScript code blocks with code that is shared between all the snippets defined\nin the current file. They are defined with the `global` keyword, as follows:\n\n```lua\nglobal\n// JavaScript code\nendglobal\n```\n\nSnippet blocks are snippet definitions. They are defined with the `snippet` keyword, as follows:\n\n```lua\ncontext expression\nsnippet trigger \"description\" flags\nbody\nendsnippet\n```\n\nwhere the `trigger` field is required and the fields `description` and `flags` are optional.\n\n### Trigger\n\nA trigger can be any sequence of characters which does not contain a space, or a regular expression\nsurrounded by backticks (`` ` ``).\n\n### Flags\n\nThe flags field is a sequence of characters which modify the behavior of the snippet, the available\nflags are the following:\n\n- `A`: Automatic snippet expansion - Usually snippets are activated when the `tab` key is pressed,\n  with the `A` flag snippets will activate as soon as their trigger matches, it is specially useful\n  for regex snippets.\n\n- `i`: In-word expansion\\* - By default, a snippet trigger will only match when the trigger is\n  preceded by whitespace characters. A snippet with this option is triggered regardless of the\n  preceding character, for example, a snippet can be triggered in the middle of a word.\n\n- `w`: Word boundary\\* - With this option the snippet trigger will match when the trigger is a word\n  boundary character. Use this option, for example, to permit expansion where the trigger follows\n  punctuation without expanding suffixes of larger words.\n\n- `b`: Beginning of line expansion\\* - A snippet with this option is expanded only if the\n  tab trigger is the first word on the line. In other words, if only whitespace precedes the tab\n  trigger, expand.\n\n- `M`: Multi-line mode - By default, regex matches will only match content on the current line, when\n  this option is enabled the last `hsnips.multiLineContext` lines will be available for matching.\n\n\\*: This flag will only affect snippets which have non-regex triggers.\n\n### Snippet body\n\nThe body is the text that will replace the trigger when the snippet is expanded, as in usual\nsnippets, the tab stops `$1`, `$2`, etc. are available.\n\nThe full power of HyperSnips comes when using JavaScript interpolation: you can have code blocks\ninside your snippet delimited by two backticks (` `` `) that will run when the snippet is expanded,\nand every time the text in one of the tab stops is changed.\n\n### Code interpolation\n\nInside the code interpolation, you have access to a few special variables:\n\n- `rv`: The return value of your code block, the value of this variable will replace the code block\n  when the snippet is expanded.\n- `t`: An array containing the text within the tab stops, in the same order as the tab stops are\n  defined in the snippet block. You can use it to dynamically change the snippet content.\n- `m`: An array containing the match groups of your regular expression trigger, or an empty array if\n  the trigger is not a regular expression.\n- `w`: A URI string of the currently opened workspace, or an empty string if no workspace is open.\n- `path`: A URI string of the current document. (untitled documents have the scheme `untitled`)\n\nAdditionally, every variable defined in one code block will be available in all the subsequent code\nblocks in the snippet.\n\nThe `require` function can also be used to import NodeJS modules.\n\n### Context matching\n\nOptionally, you can have a `context` line before the snippet block, it is followed by any javascript\nexpression, and the snippet is only available if the `context` expression evaluates to `true`.\n\nInside the `context` expression you can use the `context` variable, which has the following type:\n\n```ts\ninterface Context {\n  scopes: string[];\n}\n```\nHere, `scopes` stands for the TextMate scopes at the current cursor position, which can be viewed by\nrunning the `Developer: Inspect Editor Tokens and Scopes` command in `vscode`.\n\nAs an example, here is an automatic LaTeX snippet that only expands when inside a math block:\n\n```lua\nglobal\nfunction math(context) {\n    return context.scopes.some(s =\u003e s.startsWith(\"meta.math\"));\n}\nendglobal\n\ncontext math(context)\nsnippet inv \"inverse\" Ai\n^{-1}\nendsnippet\n```\n\n## Examples\n\n- Simple snippet which greets you with the current date and time\n\n```lua\nsnippet dategreeting \"Gives you the current date!\"\nHello from your hsnip at ``rv = new Date().toDateString()``!\nendsnippet\n```\n\n- Box snippet as shown in the gif above\n\n```lua\nsnippet box \"Box\" A\n``rv = '┌' + '─'.repeat(t[0].length + 2) + '┐'``\n│ $1 │\n``rv = '└' + '─'.repeat(t[0].length + 2) + '┘'``\nendsnippet\n```\n\n- Snippet to insert the current filename\n\n```lua\nsnippet filename \"Current Filename\"\n``rv = require('path').basename(path)``\nendsnippet\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdraivin%2Fhsnips","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdraivin%2Fhsnips","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdraivin%2Fhsnips/lists"}