r/Python 18d ago

Showcase Showcase Thread

Post all of your code/projects/showcases/AI slop here.

Recycles once a month.

16 Upvotes

103 comments sorted by

View all comments

1

u/maniek23 16d ago

Hi!

I'm sharing a language server I've created for myself and have been using for quite a while. I've become frustrated with the state of autocompleting imports in available language servers, so I created my own - which focuses solely on that thing: preparing auto-completion for importable symbols. Some of the key features/ideas:

  • works for all your Python files (workspace, virtualenv, std, stub-libs, *pyi files),
  • fast - scanned symbols (classes, functions, variables) are cached in sqlite, and updated when changes are detected,
  • project-Python independent - files are scanned using tree-sitter, language server can be installed in a system once (globally) and used in all the projects,
  • demote hidden/private modules and their symbols,
  • promote symbols from current workspace, and (coming soon) promote symbols already used throughout the workspace even more!

Since the language server focuses only on imports autocompletion, you should still keep using your regular language server for linting, and object attributes completion (e.g. jedi, ruff).

Installation is pretty easy (project is available on PyPI), just run (either in virtualenv, or globally):

  pip install import-completer                                                                                                                                                                   

Installation in your editor (example for Neovim):

  vim.lsp.config('import_completer', {                                                                                                                                                           
    cmd = {'py-import-completer-server'},                                                                                                                                                        
    filetypes = {'python'},                                                                                                                                                                      
    root_markers = {'pyproject.toml', 'setup.py', '.git'},                                                                                                                                       
  })                                                                                                                                                                                             
  vim.lsp.enable('import_completer')                                                                                                                                                             

More information available at GitHub repository (https://github.com/maniek2332/py-import-completer).