{"id":13896568,"url":"https://github.com/tjdevries/apyrori.nvim","last_synced_at":"2025-10-29T08:32:19.898Z","repository":{"id":96938702,"uuid":"249444135","full_name":"tjdevries/apyrori.nvim","owner":"tjdevries","description":"Auto imports for Python based on your current project","archived":false,"fork":false,"pushed_at":"2021-02-19T01:54:51.000Z","size":53,"stargazers_count":22,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T05:51:12.643Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","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/tjdevries.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}},"created_at":"2020-03-23T13:51:23.000Z","updated_at":"2025-01-15T01:56:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"b91eaf29-8e8a-408c-8620-78eb551489a5","html_url":"https://github.com/tjdevries/apyrori.nvim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tjdevries/apyrori.nvim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjdevries%2Fapyrori.nvim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjdevries%2Fapyrori.nvim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjdevries%2Fapyrori.nvim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjdevries%2Fapyrori.nvim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tjdevries","download_url":"https://codeload.github.com/tjdevries/apyrori.nvim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjdevries%2Fapyrori.nvim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281588589,"owners_count":26526989,"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-10-29T02:00:06.901Z","response_time":59,"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":[],"created_at":"2024-08-06T18:03:00.553Z","updated_at":"2025-10-29T08:32:19.508Z","avatar_url":"https://github.com/tjdevries.png","language":"Lua","funding_links":[],"categories":["Lua"],"sub_categories":[],"readme":"# apyrori.nvim\n\nAuto imports for Python based on your current project. The name is a pun on _a priori_. It's not a great pun, but it's a pun nonetheless.\n\n## How it works\n\nIt's pretty simple and it's pretty dumb, and that's why it works so great.\n\nWhen you're working on a large project, you've probably imported the thing you want to import somewhere before.\nThis plugin simply looks at all the places you've imported the word under your cursor, picks the most likely (A.K.A. most frequent) import\nand adds that to the top of your file.\n\n### Gif Example\n\n![simple_example](./media/simple_edit.svg)\n\n### Example in code\n\nFor example:\n\n```python\n# FILE: my_package/foo.py\n\nfrom my_package.services import MagicRequests\n\n...\n```\n\nNow you're editing a new file, and you haven't imported `MagicRequests` yet. If you type out what you want to import and invoke `\u003cplug\u003eApyroriInsert`,\nthe file will go from:\n\n```python\n# FILE: my_package/bar.py\n\nclass MySweetSummerChild(MagicRequests):\n    pass\n```\n\nto\n\n```python\n# FILE: my_package/bar.py\n\nfrom my_package.services import MagicRequests\n\nclass MySweetSummerChild(MagicRequests):\n    pass\n```\n\nAnother benefit is that when you're doing type annotations for Python, it is SO annoying to always pick `from typing import List` from all the other places that define `List`. This way you just standardize it across your project.\n\n## Installation\n\nCurrent default setup uses ripgrep, so you should install that. Otherwise see `Advanced Configuration`\n\nOtherwise you can just install as normal.\n\n```vim\n\" Used for running jobs in lua\nPlug 'nvim-lua/plenary.nvim'\n\n\" Actual plugin\nPlug 'tjdevries/apyrori.nvim'\n```\n## Usage\n\n```vim\n\" You may want to put this within a python only part of your config.\nnmap \u003cM-i\u003e \u003cplug\u003eApyroriInsert\n```\n\n## Advanced Configuration\n\n`apyrori.nvim` uses lua to do the configuration, so anywhere you have lua you can do the following:\n\n```lua\nrequire('apyrori.config').new(\n  'name_of_configuration',\n  {\n    command='grep',\n\n    args = function(text)\n        return {'the', 'commands', 'to', 'send', 'to', 'command'}\n    end,\n\n    -- results: the results of running the commands. Split on new lines\n    -- counts: the counts of the various different import styles. Most common will be used.\n    parser  = function(results, counts)\n      for _, result in ipairs(results) do\n        local split_result = require('apyrori.util').string_split(result, \":\", 4)\n        local value = split_result[4]\n\n        if counts[value] == nil then\n          counts[value] = 0\n        end\n\n        counts[value] = counts[value] + 1\n      end\n    end\n  },\n  true\n)\n\n```\n\nYou can see it in action here:\n\nhttps://asciinema.org/a/4gKqKLPnSSQWQzWEcjveoIY0v\n\n\n### To Do\n\n- [ ] Make a pop up for \"contested\" imports, so you can choose one easily\n    - This is sort of done\n- [ ] Make a pop up for \"unknown\" imports, so you can just type something and it will drop it at the top of your file\n- [ ] Make a way to add \"default\" imports, so even if your project doesn't have them, we can add them anyways\n- [ ] Make a \"fuzzy\" importer, and you can choose from  a similar popup as the contested one\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjdevries%2Fapyrori.nvim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftjdevries%2Fapyrori.nvim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjdevries%2Fapyrori.nvim/lists"}