Python LSP Configuration

The details below describe how to install and configure the Python language server found here.
This language server requires a working version of Python and uses Jedi to implement the server.
As the Zeus IDE also comes with a Python environment and it too uses Jedi for the default auto-complete, a separate Python environment is needed to run the language server.

Creating a Python Environment

In this example the Miniconda software is used to create virtual Python environment to run the language server as per the steps given below:
  1. Download and install Miniconda found here.
  2. Using the Windows command line, run the following command to create Python virtual environment with the PythonLSP name:
    conda create --name PythonLSP python=3.10.13
    NOTE: In testing, this language server did not seem to run correctly using the latest version of Python, hence the reason an earlier 3.10.13 version is used instead. To list other possible Python versions run this search command line:
    conda search python
  3. Activate the new PythonLSP virtual Python environment and run the pip command shown to install the language server:
    conda activate PythonLSP
    pip install python-language-server

  4. With the software installed test the installation by running pyls -h at the command line prompt, which should result in the following output:
    (PythonLSP) C:\Users\Your User Name>pyls -h
    usage: pyls [-h] [--tcp] [--host HOST] [--port PORT] [--check-parent-process]
                [--log-config LOG_CONFIG | --log-file LOG_FILE] [-v]
    
    Python Language Server
    
    options:
      -h, --help            show this help message and exit
      --tcp                 Use TCP server instead of stdio
      --host HOST           Bind to this address
      --port PORT           Bind to this port
      --check-parent-process
                            Check whether parent process is still alive using os.kill(ppid, 0) and auto shut down language
                            server process when parent process is not alive.Note that this may not work on a Windows
                            machine.
      --log-config LOG_CONFIG
                            Path to a JSON file containing Python logging config.
      --log-file LOG_FILE   Redirect logs to the given file instead of writing to stderr.Has no effect if used with --log-
                            config.
      -v, --verbose         Increase verbosity of log output, overrides log config file

Language Server Batch File

Since we need to run the language server using the newly created Python environment, the easiest way to do this is via a batch file.
Create the following zPythonLSP.cmd batch file, taking note of the folder location of the file, as that information will be needed in a later configuration step.
Another option is putting this batch file in the Zeus IDE installation folder, as any file found in location will be automatically found by the Zeus IDE.
NOTE: The comments found in the batch file describe what each line of the batch is actually doing.
@echo off

:: Remove the Zeus IDE Python installation environment details
set PYTHONHOME=
set PYTHONPATH=

:: This is the location of the miniconda installation bin folder (change to suit)
set PATH=D:\Utilities\miniconda3\condabin\

:: Activate the PythonLSP virtual environment (the PATH details from the earlier line are needed to make this command work)
call conda activate PythonLSP

:: Echo the language server command line (this helps with debugging and can be changed to suit based on the pyls help shown earlier)
echo pyls.exe --log-file=%temp%\python_lsp.log --verbose

:: Run the language server writing the log details to the temp folder (change to suit)
pyls.exe --log-file=%temp%\python_lsp.log --verbose

:: Clean up on exit
echo call conda deactivate
call conda deactivate
NOTE: The details found in this batch file may need to be adjusted to suit. For example the installation folder used for miniconda will need to be adjusted. Also if a different name is used for the Python virtual environment, that too will need to be adjusted.

Zeus IDE Configuration

Start Zeus IDE and use the Options, Document Types menu to edit the Python document type and in the Language Server panel apply the following configuration settings:
Program Type: Batch
     Program: zPythonLSP.cmd
   Directory: NOTE: This is the folder location of the zLSP.cmd file. If the file was saved to the Zeus IDE installation folder, this can be left blank

Using the Language Server

To test the configuration create a simple test.py file and fire off an auto-complete request:
lsp python


Latest Version: Zeus 3.99b
Released: 29th October 2024