Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevanmilic/nvim-lspimport
Automatically resolves imports for undefined terms in neovim.
https://github.com/stevanmilic/nvim-lspimport
Last synced: about 2 months ago
JSON representation
Automatically resolves imports for undefined terms in neovim.
- Host: GitHub
- URL: https://github.com/stevanmilic/nvim-lspimport
- Owner: stevanmilic
- License: mit
- Created: 2023-11-06T09:52:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-20T16:45:57.000Z (5 months ago)
- Last Synced: 2024-07-31T20:38:27.930Z (4 months ago)
- Language: Lua
- Homepage:
- Size: 16.6 KB
- Stars: 57
- Watchers: 4
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-neovim - stevanmilic/nvim-lspimport - Automatically resolves imports for undefined terms. Useful with `pyright` language server. (LSP / (requires Neovim 0.5))
README
# LSP Import
Resolves imports for undefined terms by using LSP completion API. It's primary
usage is to support automatic imports for `pyright` language server.https://github.com/stevanmilic/nvim-lspimport/assets/6879030/5a7868e8-e09b-41e2-a5ec-bd2eacb9c1e0
## Installation
Using [lazy.nvim](https://github.com/folke/lazy.nvim):
```lua
{ "stevanmilic/nvim-lspimport" }
```## Configuration
Mappings are not set by default, hence it's required to set a mapping for resolving import:
```lua
vim.keymap.set("n", "a", require("lspimport").import, { noremap = true })
```Once mapping is set, jump on the line with an undefined term and execute
mapping to resolve import.## Supported language servers
- [pyright](https://github.com/microsoft/pyright) (python)
NOTE: In order for `pyright` to resolve an import, module containing it should
be used in the workspace; otherwise import won't be found. Hence the
auto-import feature works well in modules loaded with pre-loaded imports.
[Auto-imports are limited to only those symbols and modules that have been
imported somehwhere else in the
program.](https://github.com/microsoft/pyright/issues/967#issuecomment-679417083)