This telescope displays callable names in workspace. After searching a callable name you want, if you press <enter>, it inserts a import statement to top of buffer. If you press <tab>, it inserts a import statement to top of buffer, and type the callable name at cursor position.
- It doesn't use treesitter, lsp.
- It need ripgrep, telescope.nvim, vim-isort.
- It supports only class, function.
Plug 'fisadev/vim-isort'
Plug 'nvim-telescope/telescope.nvim'
Plug 'ok97465/telescope-py-importer.nvim'require('telescope').load_extension('py_importer')
-- Optional: configure behavior
require('telescope').extensions.py_importer.setup({
search = {
globs_include = { "*.py" },
globs_exclude = { ".venv/**", "venv/**", "__pycache__/**", "build/**", "dist/**" },
include_async_functions = true,
include_variables = true,
},
insert = {
docstring_scan_lines = 30,
import_scan_lines = 80,
put_mode = 'c', -- characterwise put for symbol name
isort_command = 'Isort',
-- header_markers are auto-detected from isort config when available
-- Supported files: pyproject.toml, .isort.cfg, setup.cfg, tox.ini
-- If none found, defaults below are used. In all cases, "# %% Import" is enforced.
header_markers = {
"# %% Import",
"# Standard library imports",
"# Local imports",
"# Third party imports",
},
},
path = {
collapse_dunder_init = true, -- map pkg/__init__.py -> pkg
},
})require 'telescope'.extensions.py_importer.workspace({layout_config={prompt_position="top"}, sorting_strategy="ascending"})- Errors are reported via
vim.notifywith the titletelescope-py-importer.- Missing ripgrep: ensure
rgis in yourPATH. - Insert failures: buffer may be unmodifiable; check
:set ma.
- Missing ripgrep: ensure
- isort command errors: set
insert.isort_command = nilto disable. - You can enable verbose notifications by checking
:messages. - Header markers: When an isort config exists, import section headings
(e.g.,
import_heading_stdlib) are read and matched as# <heading>. If no config is found, the defaults above are used.# %% Import는 항상 포함됩니다.
