Fortran LSP Configuration

The details below describe how to install and configure the Fortran language server found here.
NOTE: This installation process assumes a full version of Python has been installed on the machine.
As the Zeus IDE also comes with a Python environment, 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 Start button, search for Anaconda Prompt (miniconda3) to open a command line prompt, run the following command to create Python virtual environment with the FortranLSP name:
    conda create --name FortranLSP python
  3. Activate the new FortranLSP virtual Python environment and run the pip command shown to install the language server:
    conda activate FortranLSP
    pip install fortran-language-server

  4. Check the installation by runing the fortls.exe -? command which should result in the following output:
    usage: fortls [-h] [--version] [--nthreads NTHREADS] [--notify_init]
                  [--symbol_skip_mem] [--incremental_sync]
                  [--autocomplete_no_prefix] [--lowercase_intrinsics]
                  [--use_signature_help] [--variable_hover]
                  [--preserve_keyword_order] [--enable_code_actions]
                  [--max_line_length MAX_LINE_LENGTH]
                  [--max_comment_line_length MAX_COMMENT_LINE_LENGTH]
                  [--debug_log] [--debug_parser] [--debug_diagnostics]
                  [--debug_symbols]
                  [--debug_workspace_symbols DEBUG_WORKSPACE_SYMBOLS]
                  [--debug_completion] [--debug_signature] [--debug_definition]
                  [--debug_hover] [--debug_implementation] [--debug_references]
                  [--debug_rename DEBUG_RENAME] [--debug_actions]
                  [--debug_filepath DEBUG_FILEPATH]
                  [--debug_rootpath DEBUG_ROOTPATH] [--debug_line DEBUG_LINE]
                  [--debug_char DEBUG_CHAR]


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 zFortranLSP.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 (IMPORTANT: This will need to be changed to suit)
set PATH=D:\Utilities\miniconda3\condabin\

:: Activate the FortranLSP virtual environment (IMPORTANT: The PATH details set two line earlier need to be correct for this to command work)
call conda activate FortranLSP

:: Echo the language server command line (NOTE: This output will show up in Zeus language server output)
echo fortls.exe

:: Run the language server (change to suit)
fortls.exe

:: Clean up on exit
echo call conda deactivate
call conda deactivate
IMPORTANT: The details found in this batch file will 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: zFortranLSP.cmd
   Directory:
IMPORTANT: The zFortranLSP.cmd used for the Program setting was not fully qualified, only because the batch file was saved to the Zeus installation folder. If this is not the case the full name will need to be used, of the folder will need to be found in the PATH.

Using the Language Server

To test the configuration create a simple test.f90 file and fire off an auto-complete request:
lsp fortran
In addition to code completion, code navigation, function signatures and document hover should also work.


Latest Version: Zeus 3.99c
Released: 3rd January 2025