IMOKURI / apyrori.nvim

Auto imports for Python based on your current project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

apyrori.nvim

This repository is forked from here.

Auto 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.

Features

  • This 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 and adds that to the top of your file.
  • Alternatively, if there are multiple candidates, you can select one from the fuzzy finder using Telescope.
  • If there are no candidates, you can set default import statements to be displayed.
  • If there are no candidates, you can add an import statement entered by Telescope as it is.

Demo

demo

Prerequisite

Installation

use {
    "nvim-telescope/telescope.nvim",
    requires = {
        "nvim-lua/plenary.nvim",
        "IMOKURI/apyrori.nvim",
    },
}
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'

Plug 'IMOKURI/apyrori.nvim'

Setup

require("telescope").load_extension("apyrori")

Configurations

These configurations are optional.

vim.keymap.set("n", "<Leader>i", "<Cmd>Telescope apyrori<CR>")

require("apyrori").setup({
    -- True if there are multiple candidates and the most likely one is added.
    -- False if you want to manually select one of the candidates.
    -- Default is true.
    choose_most_likely = true,

    -- Import statements to be displayed if no candidates exist. Default is empty.
    default_imports = {
        "import numpy as np",
        "import pandas as pd",
    },
})

To Do

  • Consider mutiple line import sentence.

About

Auto imports for Python based on your current project

License:MIT License


Languages

Language:Lua 75.2%Language:Vim Script 11.9%Language:Python 9.1%Language:Makefile 3.8%