{"id":15657870,"url":"https://github.com/willothy/leptos.nvim","last_synced_at":"2025-07-11T11:35:20.738Z","repository":{"id":195919327,"uuid":"693957233","full_name":"willothy/leptos.nvim","owner":"willothy","description":"Experimental Lua/Nvim bindings for the leptos-reactive rust crate","archived":false,"fork":false,"pushed_at":"2023-09-22T03:41:19.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T02:23:34.256Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/willothy.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":"2023-09-20T03:37:51.000Z","updated_at":"2023-09-22T02:31:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"19637fa7-6a57-4564-b5fc-f73d9c8dc481","html_url":"https://github.com/willothy/leptos.nvim","commit_stats":null,"previous_names":["willothy/leptos.nvim"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/willothy/leptos.nvim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fleptos.nvim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fleptos.nvim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fleptos.nvim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fleptos.nvim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/willothy","download_url":"https://codeload.github.com/willothy/leptos.nvim/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/willothy%2Fleptos.nvim/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264795838,"owners_count":23665241,"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":[],"created_at":"2024-10-03T13:10:03.281Z","updated_at":"2025-07-11T11:35:20.713Z","avatar_url":"https://github.com/willothy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# leptos.nvim\n\nExperimental Lua/Neovim wrapper for [`leptos_reactive`](https://github.com/leptos-rs/leptos).\n\n## Installation\n\nWith `lazy.nvim`\n\n```lua\n_ = {\n  \"willothy/leptos.nvim\",\n  event = \"VeryLazy\"\n}\n```\n\nWith other package managers, ensure to specify `just build` as the build script.\n\n## Example usage\n\nCount stars for a github repo using `gh api` and `jq`, reactively update a buffer as stdout is read.\n\n```lua\n-- this example relies on nui.nvim for rendering\nlocal Text = require(\"nui.text\")\nlocal Line = require(\"nui.line\")\n\nlocal rx = require(\"leptos\")\n\n---@param user string?\nlocal function count_stars(user)\n  -- create the window\n  user = user or vim.env.USER\n  local width = math.max(12, #user + 2)\n  local buf, win = vim.lsp.util.open_floating_preview({}, \"\", {\n    focus = true,\n    focusable = true,\n    wrap = true,\n    width = width,\n    height = 1,\n    border = \"single\",\n    title = user,\n    title_pos = \"center\",\n  })\n\n  -- create the signals that will handle state\n  local total = rx.create_signal(0)\n  local err = rx.create_signal()\n\n  -- this will run whenever `total` or `err` are updated\n  rx.create_effect(function()\n    -- signals will be automatically subscribed to the running effect\n    local val = total.get()\n    local star\n    -- check for errors\n    if err.get() then\n      val = Text(err.get())\n      star = Text(\"\", \"DiagnosticError\")\n    else\n      val = Text(tostring(val))\n      star = Text(\"\", \"DiagnosticWarn\")\n    end\n    -- check that the window can fit the text\n    if (val:length() + 2) \u003e width then\n      width = val:length() + 2\n      local config = vim.api.nvim_win_get_config(win)\n      config.width = val:length() * 2\n      vim.api.nvim_win_set_config(win, config)\n    end\n    -- construct the text object\n    local lpad =\n      Text(string.rep(\" \", math.floor((width - val:length()) / 2) - 1))\n    local line = Line({ lpad, star, Text(\" \"), val })\n    -- render to the buffer\n    if vim.api.nvim_buf_is_valid(buf) then\n      vim.bo[buf].modifiable = true\n      line:render(buf, -1, 1)\n      vim.bo[buf].modifiable = false\n    end\n  end)\n\n  -- buffer for received data\n  local buffer = \"\"\n\n  vim.system({\n    \"gh\",\n    \"api\",\n    \"-X\",\n    \"GET\",\n    \"/users/\" .. user .. \"/repos\",\n    \"--paginate\",\n    \"-F\",\n    \"per_page=10\", -- only 10 repos per-page\n    \"--jq\",\n    \".[].stargazers_count\", -- use jq to retrieve the star count for each repo\n  }, {\n    text = true,\n    -- Incrementally update the total star count as pages are received from the API\n    stdout = function(e, data)\n      if e then\n        err.set(e)\n        return\n      end\n      if not data then\n        return\n      end\n      -- keep all of the data for json decoding\n      buffer = buffer .. data\n      local num = vim\n        .iter(vim.split(data, \"\\n\"))\n        :map(tonumber)\n        :fold(0, function(acc, num)\n          return acc + num\n        end)\n      -- Update tables in-place, or return a new value to update by value\n      --\n      -- This is equivalent to calling get() and set(), with the exception of\n      -- table signals, which can be mutated in place.\n      total.update(function(t)\n        return (t or 0) + num\n      end)\n    end,\n  }, function(obj)\n    -- Handle errors by setting the error signal\n    if obj.code ~= 0 or #obj.stderr ~= 0 then\n      local output = vim.json.decode(buffer)\n      err.set(output.message)\n    end\n  end)\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillothy%2Fleptos.nvim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillothy%2Fleptos.nvim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillothy%2Fleptos.nvim/lists"}