Skip to main content

Minimal Python language server based on Jedi

Project description

Italian Swirls 🍝

Minimal Python language server, based on Jedi and pygls.

It works on the subset of versions supported by both Jedi and pygls, so in its current set of dependencies:

  • Python 3.8 at least
  • Python 3.12 at most

Supported features:

LSP method Description
textDocument/completion Complete
textDocument/definition Go to definition
textDocument/typeDefinition Go to type definition
textDocument/hover Show documentation
textDocument/references Show references
textDocument/rename Renaming symbols and files

Install

You can either clone and build the server package from this repository, or install it from PyPI:

pip install italianswirls

The only dependencies are pygls and Jedi.

Because Jedi is able to detect which environment it is installed in and which environment is the project you're working on in, you do not need to install in every virtualenv where it might be handy; a global user (or root) installation should be sufficient to work regardless of your current virtualenv.

Refer to your client documentation on how to setup a server. Yes I have no idea how to do it for your editor, except if it's Neovim and you use nvim-lspconfig, then you can add something like that to your init:

require('lspconfig.configs').italianswirls = {
  default_config = {
    cmd = { 'italianswirls' },
    filetypes = { 'python' },
    root_dir = require('lspconfig.util').root_pattern(
      unpack({ 'pyproject.toml', 'setup.cfg' })
    ),
    single_file_support = true,
  },
  docs = {
    description = "“Is this a Star Wars reference?” Language Server",
    default_config = {
      root_dir = "vim's starting directory",
    },
  },
}

-- using a previously defined on_attach function…
lspconfig.italianswirls.setup { on_attach = on_attach }

Development

The project uses Poetry for dependency management and packaging.

poetry install            # install deps in a virtualenv
poetry run italianswirls  # run the LS but it may be impractical to test
poetry build              # build to wheel

About

Why?

General-purpose servers (e.g. pyls, py-lsp) try to do too much and break stuff too often for me. Locking Neovim when I press tab, crashes of all kind, LspRestart failing. Also I like my linting and formatting done by dedicated tools such as nvim-lint and Conform.

Other Jedi-based servers (e.g. jedi-language-server) seem to focus on coc-nvim and frequently fail on Neovim's native LSP client for me. I tried to fix jedi-language-server several times when it failed me but I thought it could be fun to try pygls to redo it as small and simple as I can. And running a Node server to get Python completions? No way. That said, jedi-language-server is a good project and if you're fine with coc-nvim you should definitely check it out. Lots of the code here is stolen inspired from this project.

Is it usable for me?

Try it. It was a small project for my own usage but it's been surprisingly reliable over the years now. That said, I do not program in Python professionally since some times now so I do not have the same strict requirements as before regarding to my tools.

Why the name?

Take the string “Is this a Star Wars reference?” Language Server, compress it to ITASWRLS and expand it back to Italian Swirls. Italian dishes are made of few elements that work well together. Enough questions!

License

GPLv3.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

italianswirls-1.1.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

italianswirls-1.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file italianswirls-1.1.1.tar.gz.

File metadata

  • Download URL: italianswirls-1.1.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.2 Linux/6.9.10+bpo-amd64

File hashes

Hashes for italianswirls-1.1.1.tar.gz
Algorithm Hash digest
SHA256 4bdda081ad7600c40a40a472bc21ada760c23508a98274695d7a7ec17da295db
MD5 ab6a83754f051bef520e99255b8ef38e
BLAKE2b-256 b4258617b640c6e933f8db702df914461cbd2a9d80cc06ec3ad0162324c72db2

See more details on using hashes here.

File details

Details for the file italianswirls-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: italianswirls-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.2 Linux/6.9.10+bpo-amd64

File hashes

Hashes for italianswirls-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed922a2fea1cddb7e3d66549b23c6972f787cd0ad08df6b82b9d32eaf51b21d6
MD5 03cf9e52a1d45aa09bbac574c9297c21
BLAKE2b-256 c52eede30f22cfb42c4254d6431fea173e0a05faeb36d0212b00878b30ced0ef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page