Package: jedi-language-server
Jedi Language ServerAPythonLanguage Serverpowered by the latest version ofJedi.InstallationSome frameworks, like coc-jedi and vscode-python, will install and managejedi-language-serverfor you. If you're setting up manually, you can run the following from your command line (bash / zsh):pipinstall-Ujedi-language-serverAlternatively (and preferably), usepipxto keepjedi-language-serverand its dependencies isolated from your other Python dependencies. Don't worry, jedi is smart enough to figure out which Virtual environment you're currently using!Editor SetupThe following instructions show how to usejedi-language-serverwith your development tooling. The instructions assume you have already installedjedi-language-server.Vim / NeovimUsers may choose 1 of the following options:Neovim's native LSP client. Seeherefor an example configuration.coc.nvimwithcoc-jedi.ALE.vim-lsp.Note: this list is non-exhaustive. If you know of a great choice not included in this list, please submit a PR!EmacsUsers may choose one of the following options:lsp-jedi.eglotNote: this list is non-exhaustive. If you know of a great choice not included in this list, please submit a PR!Visual Studio Code (vscode)Starting from theOctober 2021 release, set thepython.languageServersetting toJedito usejedi-language-server.See:https://github.com/pappasam/jedi-language-server/issues/50#issuecomment-781101169Configurationjedi-language-serversupports the followinginitializationOptions:{"initializationOptions":{"codeAction":{"nameExtractVariable":"jls_extract_var","nameExtractFunction":"jls_extract_def"},"completion":{"disableSnippets":false,"resolveEagerly":false,"ignorePatterns":[]},"diagnostics":{"enable":false,"didOpen":true,"didChange":true,"didSave":true},"hover":{"enable":true,"disable":{"class":{"all":false,"names":[],"fullNames":[]},"function":{"all":false,"names":[],"fullNames":[]},"instance":{"all":false,"names":[],"fullNames":[]},"keyword":{"all":false,"names":[],"fullNames":[]},"module":{"all":false,"names":[],"fullNames":[]},"param":{"all":false,"names":[],"fullNames":[]},"path":{"all":false,"names":[],"fullNames":[]},"property":{"all":false,"names":[],"fullNames":[]},"statement":{"all":false,"names":[],"fullNames":[]}}},"jediSettings":{"autoImportModules":[],"caseInsensitiveCompletion":true,"debug":false},"markupKindPreferred":"markdown","workspace":{"extraPaths":[],"environmentPath":"/path/to/venv/bin/python","symbols":{"ignoreFolders":[".nox",".tox",".venv","__pycache__","venv"],"maxSymbols":20}}}}The different sections of the InitializationOptions are explained below, in detail. Section headers use a.to separate nested JSON-object keys.markupKindPreferredThe preferred MarkupKind for alljedi-language-servermessages that takeMarkupContent.type:stringaccepted values:"markdown","plaintext"If omitted,jedi-language-serverdefaults to the client-preferred configuration. If there is no client-preferred configuration, jedi language server users"plaintext".jediSettings.autoImportModulesModules that jedi will directly import without analyzing. Improves autocompletion but loses goto definition.type:string[]default:[]If you're noticing that modules likenumpyandpandasare taking a super long time to load, and you value completions / signatures over goto definition, I recommend using this option like this:{"jediSettings":{"autoImportModules":["numpy","pandas"]}}jediSettings.caseInsensitiveCompletionCompletions are by default case-insensitive. Set tofalseto make completions case-sensitive.type:booleandefault:true{"jediSettings":{"caseInsensitiveCompletion":false}}jediSettings.debugPrint jedi debugging messages to stderr.type:booleandefault:false{"jediSettings":{"debug":false}}codeAction.nameExtractFunctionFunction name generated by the 'extract_function' codeAction.type:stringdefault:"jls_extract_def"codeAction.nameExtractVariableVariable name generated by the 'extract_variable' codeAction.type:stringdefault:"jls_extract_var"completion.disableSnippetsIf your language client supportsCompletionItemsnippets but you don't like them, disable them by setting this option totrue.type:booleandefault:falsecompletion.resolveEagerlyReturn all completion results in initial completion request. Set totrueif your language client does not supportcompletionItem/resolve.type:booleandefault:falsecompletion.ignorePatternsA list of regular expressions. If any regular expression in ignorePatterns matches a completion's name, that completion item is not returned to the client.type:string[]default:[]In general, you should prefer the default value for this option. Jedi is very good at filtering values for end users. That said, there are situations where IDE developers, or some programmers in some code bases, may want to filter some completions by name. This flexible interface is provided to accommodate these advanced use cases. If you have one of these advanced use cases, see below for some example patterns (and their corresponding regular expression).All Private NamesMatchesNon-Matches_hello,__world__dunder__Regular Expression:^_{1,3}$|^_[^_].*$|^__.*(?<!__)$Only private mangled namesMatchesNon-Matches__world_hello,__dunder__Regular Expression:^_{2,3}$|^__.*(?<!__)$Only dunder namesMatchesNon-Matches__dunder___hello,__worldRegular Expression:^__.*?__$All names beginning with underscoreMatchesNon-Matches_hello,__world,__dunder__regularRegular Expression:^_.*$diagnostics.enableEnables (or disables) diagnostics provided by Jedi.type:booleandefault:truediagnostics.didOpenWhen diagnostics are enabled, run on document opentype:booleandefault:truediagnostics.didChangeWhen diagnostics are enabled, run on in-memory document change (eg, while you're editing, without needing to save to disk)type:booleandefault:truediagnostics.didSaveWhen diagnostics are enabled, run on document save (to disk)type:booleandefault:truehover.enableEnable (or disable) all hover text. If set tofalse, will cause the hover method not to be registered to the language server.type:booleandefault:truehover.disable.*The following options are available under this prefix:hover.disable.class.allhover.disable.class.nameshover.disable.class.fullNameshover.disable.function.allhover.disable.function.nameshover.disable.function.fullNameshover.disable.instance.allhover.disable.instance.nameshover.disable.instance.fullNameshover.disable.keyword.allhover.disable.keyword.nameshover.disable.keyword.fullNameshover.disable.module.allhover.disable.module.nameshover.disable.module.fullNameshover.disable.param.allhover.disable.param.nameshover.disable.param.fullNameshover.disable.path.allhover.disable.path.nameshover.disable.path.fullNameshover.disable.property.allhover.disable.property.nameshover.disable.property.fullNameshover.disable.statement.allhover.disable.statement.nameshover.disable.statement.fullNameshover.disable.[jedi-type].allDisable all hover text of jedi-type specified.type:booldefault:falsehover.disable.[jedi-type].namesDisable hover text identified by name in list of jedi-type specified.type:string[]default:[]hover.disable.[jedi-type].fullNamesDisable hover text identified by the fully qualified name in list of jedi-type specified. If no fully qualified name can be found,jedi-language-serverwill default to the name to prevent any unexpected behavior for users (relevant for jedi types like keywords that don't have full names).type:string[]default:[]workspace.extraPathsAdd additional paths for Jedi's analysis. Useful with vendor directories, packages in a non-standard location, etc. You probably won't need to use this, but you'll be happy it's here when you need it!type:string[]default:[]Non-absolute paths are relative to your project root. For example, let's say your Python project is structured like this:├── funky
│   └── haha.py
├── poetry.lock
├── pyproject.toml
├── test.pyAssume thatfunky/haha.pycontains 1 line,x = 12, and your build system does some wizardry that makeshahaimportable just likeosorpathlib. In this example, if you want to have this same non-standard behavior withjedi-language-server, put the following in yourcoc-settings.json:{"workspace":{"extraPaths":["funky"]}}When editingtest.py, you'll get completions, goto definition, and all other lsp features for the linefrom haha import ....Again, you probably don't need this.workspace.environmentPathThe Python executable path, typically the path of a virtual environment.type:stringIf omitted, defaults to the active Python environment.workspace.symbols.maxSymbolsMaximum number of symbols returned by a call toworkspace/symbols.type:numberdefault: 20{"workspace":{"symbols":{"maxSymbols":20}}}A value less than or equal to zero removes the maximum and allowsjedi-language-serverto return all workplace symbols found by jedi.workspace.symbols.ignoreFoldersPerformance optimization that sets names of folders that are ignored forworkspace/symbols.type:string[]default:[".nox", ".tox", ".venv", "__pycache__", "venv"]{"workspace":{"symbols":{"ignoreFolders":["hello","world"]}}}If you manually set this option, it overrides the default. Setting it to an empty array will result in no ignored folders.DiagnosticsDiagnostics are provided by Python's built-incompilefunction.If you would like additional diagnostics, we recommend using other tools (likediagnostic-language-server) to complementjedi-language-server.Code FormattingAgain, we recommend that you usediagnostic-language-server. It also supports code formatting.Command line usagejedi-language-servercan be run directly from the command line.$jedi-language-server--helpusage: jedi-language-server [-h] [--version] [--tcp] [--ws] [--host HOST] [--port PORT] [--log-file LOG_FILE] [-v]If testing sending requests over stdio manually from the command line, you must include Windows-style line endings:\r\n. For an example, from within this project, run the following:$jedi-language-server<./example-initialization-request.txtINFO:pygls.server:Starting IO server...If testing interactively, be sure to manually insert carriage returns. Although this may differ between shell environments, within most bash terminals, you can explicitly insert the required line endings by typing<C-v><C-m>, which will insert a^M. See:$jedi-language-server2>logsContent-Length: 1062^M^M...Technical capabilitiesjedi-language-server aims to support Jedi's capabilities and expose them through the Language Server Protocol. It supports the following Language Server capabilities:Language FeaturescompletionItem/resolvetextDocument/codeAction(refactor.inline, refactor.extract)textDocument/completiontextDocument/declarationtextDocument/definitiontextDocument/documentHighlighttextDocument/documentSymboltextDocument/typeDefinitiontextDocument/hovertextDocument/publishDiagnosticstextDocument/referencestextDocument/renametextDocument/signatureHelpworkspace/symbolText Synchronization (for diagnostics)textDocument/didChangetextDocument/didOpentextDocument/didSaveLocal DevelopmentTo build and run this project from source:DependenciesInstall the following tools manually:PoetryGNU MakeRecommendedasdfGet source codeForkthis repository and clone the fork to your development machine:gitclonehttps://github.com/<YOUR-USERNAME>/jedi-language-servercdjedi-language-serverSet up development environmentmakesetupAutomatically format filesmakefixRun testsmakelint
maketypecheck
maketestsInspirationPalantir'spython-language-serverinspired this project. In fact, for consistency's sake, many of python-language-server's CLI options are used as-is injedi-language-server.Unlike python-language-server,jedi-language-server:Usespyglsinstead of creating its own low-level Language Server Protocol bindingsSupports one powerful 3rd party static analysis / completion / refactoring library: Jedi. By only supporting Jedi, we can focus on supporting all Jedi features without exposing ourselves to too many broken 3rd party dependencies (I'm looking at you,rope).Is supremely simple because of its scope constraints. Leave complexity to the Jedimaster. If the force is strong with you, please submit a PR!ArticlesPython in VS Code Improves Jedi Language Server SupportWritten bySamuel Roeca