{"id":13761068,"url":"https://github.com/gpanders/nvim-moonwalk","last_synced_at":"2026-03-02T21:37:09.424Z","repository":{"id":41423391,"uuid":"393840618","full_name":"gpanders/nvim-moonwalk","owner":"gpanders","description":"Use any language that compiles to Lua in your Neovim configuration","archived":false,"fork":false,"pushed_at":"2022-04-12T21:04:56.000Z","size":52,"stargazers_count":73,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-25T01:07:45.713Z","etag":null,"topics":["fennel","lua","moonscript","neovim","neovim-plugin","teal"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gpanders.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}},"created_at":"2021-08-08T02:53:40.000Z","updated_at":"2025-05-16T00:22:10.000Z","dependencies_parsed_at":"2022-09-02T14:30:57.734Z","dependency_job_id":null,"html_url":"https://github.com/gpanders/nvim-moonwalk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gpanders/nvim-moonwalk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpanders%2Fnvim-moonwalk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpanders%2Fnvim-moonwalk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpanders%2Fnvim-moonwalk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpanders%2Fnvim-moonwalk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gpanders","download_url":"https://codeload.github.com/gpanders/nvim-moonwalk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpanders%2Fnvim-moonwalk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273530608,"owners_count":25122021,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["fennel","lua","moonscript","neovim","neovim-plugin","teal"],"created_at":"2024-08-03T13:01:37.029Z","updated_at":"2026-03-02T21:37:04.384Z","avatar_url":"https://github.com/gpanders.png","language":"Lua","readme":"# moonwalk\n\nmoonwalk allows you to use any language that compiles to Lua anywhere in your\nNeovim configuration.\n\n## Demo\n\n**init.lua**:\n\n```lua\nrequire(\"moonwalk\").add_loader(\"fnl\", function(src)\n    return require(\"fennel\").compileString(src)\nend)\n```\n\n**fnl/hello.fnl**:\n\n```fennel\n(print \"Hello world\")\n```\n\nOpen Neovim and run `:lua require(\"hello\")`.\n\n**after/ftplugin/lua.fnl**:\n\n```fennel\n(set vim.bo.expandtab true)\n(set vim.bo.shiftwidth 17)\n```\n\nOpen `init.lua` in Neovim and confirm that `:set expandtab?` shows `true` and\n`:set shiftwidth?` shows `17`.\n\n## How does it work?\n\nmoonwalk inserts a shim into the Lua package loader that transparently compiles\nsource files into Lua. The compilation is cached and will not be repeated\nunless the source file changes.\n\nThis means that the cost of compilation is only paid once: future invocations\nwill execute as fast as native Lua.\n\nmoonwalk intercepts `:source` and `:runtime` commands for files with the\nextensions you provide. This allows you to use any language anywhere you can\nuse a `.vim` or `.lua` file natively (with a couple of exceptions, see\n[caveats](#caveats)) such as `plugin`, `ftplugin`, or `indent` files.\n\n## Configuration\n\nThe only requirement is a function that can transform a string of the source\nlanguage code into Lua. For example, with Fennel:\n\n```lua\nrequire(\"moonwalk\").add_loader(\"fnl\", function(src, path)\n    return require(\"fennel\").compileString(src, { filename = path })\nend)\n```\n\nThe provided function can also take an optional second parameter `path` with\nthe full path of the file being compiled.\n\nOnce `add_loader` is called, any files with the extension provided found under\na `plugin` directory on the user's `'runtimepath'` are sourced. You can also\n`require()` files found under any `{ext}` directories on your `'runtimepath'`,\nwhere `{ext}` is the first argument to `add_loader`. For example, if you add a\nloader for Teal with `add_loader(\"tl\", function(src) ... end)` you can\n`require()` any `*.tl` files within a `tl` directory on your `'runtimepath'`\n(just as you can `require()` `*.lua` files within a `lua` directory).\n\nThis also works with `plugin` and `ftplugin` files. For example, you can\nconfigure how Neovim works with C files by creating\n`~/.config/nvim/after/ftplugin/c.fnl` with the contents:\n\n```fennel\n(set vim.bo.expandtab false)\n(set vim.bo.shiftwidth 8)\n```\n\nThe examples above use Fennel, but so long as you can define a function that\ntransforms the source into Lua, you can use any source language you want,\nincluding custom DSLs!\n\n### Options\n\nThe `add_loader` function takes an optional table as its third argument with\nthe following keys:\n\n* `dir`: Directory to use in the `'runtimepath'` to find modules for this\n  loader (for example, Lua modules are found under the `lua` directory). The\n  default is the extension passed as the first argument to `add_loader`, e.g.\n  if the file extension is \"tl\" then script files will be searched for under\n  the `tl` directory.\n\n## Caveats\n\n* moonwalk is minimal by design: the only thing it provides is the shim\n  infrastructure. Users must provide their transformation functions themselves\n  (see the [wiki][wiki] for some user-contributed examples).\n\n* The `:colorscheme` command won't work natively with alternative languages,\n  since it does not go through the `SourceCmd` autocommand. There are a couple\n  of ways to get around this:\n\n  1. If you are already using an `init.lua` file, you can simply write your\n     colorscheme file as a script and then `require()` it rather than using the\n     `:colorscheme` command.\n  2. If you are using an `init.vim` file you can create a stub colorscheme file\n     that `require()`s your actual colorscheme file. See an example\n     here: [stub][], [colors][].\n\n[wiki]: https://github.com/gpanders/nvim-moonwalk/wiki\n[stub]: https://github.com/gpanders/dotfiles/blob/6ba3d5e54b1b3ce4c6e74165bf51d8c832a1dd6d/.config/nvim/colors/base16-eighties.vim\n[colors]: https://github.com/gpanders/dotfiles/blob/6ba3d5e54b1b3ce4c6e74165bf51d8c832a1dd6d/.config/nvim/fnl/colors/base16-eighties.fnl\n\n## FAQ\n\n### Why is this useful?\n\nIt's not, but it's fun.\n\n### What is the performance impact?\n\nShort answer: marginal.\n\nLong answer:\n\nCompiling languages into Lua takes a non-trivial amount of time, but this is\nonly done once so you shouldn't worry about it. Once the source file is\ncompiled it is cached until the source file changes again. Future invocations\nare (nearly) as fast as using Lua directly.\n\nIt is only *nearly* as fast because the custom loader that moonwalk inserts is\nat the end of Lua's `package.loaders` table. This means that when you\n`require()` a module written in an extension language Lua has to iterate\nthrough the other package loaders first before it finally gets to moonwalk.\nmoonwalk also has to do a few things in order to determine whether or not the\nsource file has changed such as checking file modification times. However, this\nprocess takes on the order of microseconds, so don't sweat it too much.\n\nThe other performance impact comes from searching for runtime files in the\ngiven extension language. On startup, moonwalk runs (essentially) the following\ncommand:\n\n```vim\n:runtime! plugin/**/*.{ext}\n```\n\nwhere `{ext}` is the provided extension (e.g. `moon`, `tl`, etc.). Searching\nthrough the runtime path recursively takes a few milliseconds, so if you are a\nstartuptime junkie you may notice this. moonwalk takes measures to speed up\nthis process as much as possible, but there is a ceiling on how fast this can\nbe done.\n\n## Prior Art\n\n* moonwalk is heavily inspired by [hotpot.nvim][]. Hotpot works only with\n  Fennel but provides far more features than moonwalk.\n* [aniseed][] is another plugin that provides Fennel support for Neovim, along\n  with an entire standard library and utility functions.\n\n[hotpot.nvim]: https://github.com/rktjmp/hotpot.nvim\n[aniseed]: https://github.com/Olical/aniseed\n\n## Contributing\n\nIf you extend Neovim with an extension language other than Fennel, please let\nme know so I can include some of those entries in the [examples](#examples).\n\nThe wiki is publicy editable. If you think you have a useful contribution,\nplease share it!\n\nFile issues in the [GitHub issue tracker][issues]. Changes can be sent as\n[`git-send-email`][git-send-email] patches to\n[~gpanders/public-inbox@lists.sr.ht][public-inbox] or as a GitHub pull request.\n\n[issues]: https://github.com/gpanders/nvim-moonwalk/issues\n[git-send-email]: https://git-send-email.io\n[public-inbox]: mailto:~gpanders/public-inbox@lists.sr.ht\n\n## License\n\n[GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)\n","funding_links":[],"categories":["Utility","Lua"],"sub_categories":["Cursorline"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpanders%2Fnvim-moonwalk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgpanders%2Fnvim-moonwalk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpanders%2Fnvim-moonwalk/lists"}