The '''LSP Client''' plugin allows [[CudaText]] to use the Microsoft LSP protocol with servers for many programming languages. If you have not Windows OS, it is required that Python 3.6 or newer is present on the system, otherwise you will see an error message box.

LSP Client adds several commands in a "Plugins / LSP Client" menu, though the functionality ultimately depends on if the LSP server supports them.
Some of the commands are:
* Auto-completion: integrated with CudaText command "Auto-completion menu" (in the Command Palette).
* Go to definition: integrated with CudaText command "Go to definition" (in the Command Palette, and in the editor context menu).
* Function signature help: integrated with CudaText command "Show function hint" (in the Command Palette).
[[File:cudatext-lsp-hover_.png|border|right|520px]]
* Hover: shows the tooltip when you hover mouse above identifiers. You need the Ctrl key pressed while you hover.
[[File:cudatext-lsp-refs.png|border|right|520px]]
* Find references: finds all locations where an identifier (under first caret) is used and shows menu with locations.
* Code linting: checking the correctness of the source code, places underlines and/or bookmarks on "incorrect lines". This feature is also implemented in [[CudaText_plugins#CudaLint|CudaLint]] and usually it works better/faster there.
* Document formatting: formatting of the source code by LSP server. This feature is also implemented in [[CudaText_plugins#CudaFormatter|CudaFormatter]] and usually it works better/faster there.

All LSP servers should have a homepage with description of their functions, and installation information.

In the server config "lsp_*.json", key "lexers", you need to specify the mapping between CudaText lexer names and LSP language names. For example, while CudaText lexer name is "Bash script", LSP language name is "bash", likewise while CudaText lexer name is "C#", LSP language name is "csharp".
<syntaxhighlight lang="json">{
  "lexers": {
    "C#": "csharp"
  },
  …
}</syntaxhighlight>

LSP Client also has the settings file, use menu item to open it: "Options / Settings-plugins / LSP Client".

== Troubleshooting using debug logs ==
You can enable LSP server debug logs, by adding key <code>"log_stderr": true</code> to the "settings/lsp_xxxx.json" server config. For example, for C++ lexer it will look like this:
<syntaxhighlight lang="json">{
  "lexers": {
    "C++": "cpp",
    "C": "c"
  },
  …
  "log_stderr": true,
}</syntaxhighlight>

[[File:cudatext-lsp-stderr.png|thumb|right]]
You need to show the CudaText's sidebar, then click the "LSP" sidebar icon (near the bottom) to show the LSP-panel with several buttons: Messages / Logs / stderr / Diagnostics. One of these buttons is "stderr".

== Supported programming languages ==
=== Python ===
==== python-lsp-server ====
: '''''[https://github.com/python-lsp/python-lsp-server python-lsp-server project homepage]'''''
Note that this is a fork of the older, unmaintained, project "PyLS". This server supports:
* Auto-completion
* Go to definition
* Function signature help
* Hover
* Find references
* Code linting
* Document formatting

Use "pip" to install the server: <syntaxhighlight lang="shell">pip install python-lsp-server</syntaxhighlight>
 
This will expose the command "pylsp" on your PATH. Confirm that installation succeeded by running: <syntaxhighlight lang="shell">pylsp --help</syntaxhighlight>

Create the file "[CudaText]/settings/lsp_py.json" with text like this:
<syntaxhighlight lang="json">{
  "lexers": {
    "Python": "python"
  },
  "cmd_windows": ["pylsp.exe"],
  "cmd_unix": ["pylsp"],
  "cmd_macos": ["pylsp"]
}</syntaxhighlight>

Open some Python script, and call some commands of LSP Client. It will run the server, and it should work.

Recent version of LSP Client supports fuzzy search in the auto-completion list. For Python server, fuzzy search needs additional option in the lsp_py.json:
<syntaxhighlight lang="json">{
  "lexers": {
    "Python": "python"
  },
  "cmd_windows": ["pylsp.exe"],
  "cmd_unix": ["pylsp"],
  "cmd_macos": ["pylsp"],

  "settings": {
    "pylsp": {
      "plugins": {
        "jedi_completion": { "fuzzy": true },
      }
    }
  }
}</syntaxhighlight>

Fuzzy search can be tested on this sample script, it must show auto-completion item "write" for "f.wi":

<syntaxhighlight lang="python">
f = open("a.txt", "w")
f.wi
</syntaxhighlight>

==== pyright ====
# Install the server: <syntaxhighlight lang="shell">pip install pyright</syntaxhighlight>
* On Windows, add folder of "pyright-langserver.exe" to system PATH.
* On Linux/Unix, get the full path of the program, we will use this path in the next step. <syntaxhighlight lang="shell">which pyright-langserver</syntaxhighlight>

It outputs on Ubuntu:

 /home/user/.local/bin/pyright-langserver

* On macOS, install pyright via PIP, not via Homebrew. On macOS, see what output you have after you call this command: "nodeenv env". If you see certificate error, try to fix it with the following command:

 /Applications/Python\ 3.10/Install\ Certificates.command

2. Create config (CudaText)/settings/lsp_pyright.json:

<syntaxhighlight lang="json">
{
  "lexers": {
    "Python": "python"
  },
  "cmd_windows": ["pyright-langserver.exe", "--stdio"],
  "cmd_unix": ["/home/user/.local/bin/pyright-langserver", "--stdio"],
  "cmd_macos": ["/Library/Frameworks/Python.framework/Versions/3.10/bin/pyright-langserver", "--stdio"],
  "log_stderr": true
}
</syntaxhighlight>

3. To disable type checking (which may be confusing), add key "settings" to the above config:

<syntaxhighlight lang="json">
  "settings": {
    "python.analysis": {
      "typeCheckingMode": "off"
    }
  }
</syntaxhighlight>

=== JavaScript/ReactJS ===
* Install lexer for ReactJS: "JavaScript Babel", from "Addons Manager".
* Install TypeScript and the LSP server. In Terminal:

 npm install -g typescript typescript-language-server

* Create CudaText LSP config: file "settings/lsp_js.json" with such content:
<syntaxhighlight lang="json">
{
    "name": "JavaScript",
    "lexers": {
        "JavaScript": "javascript",
        "JavaScript Babel": "javascriptreact"
    },
    "cmd_unix": [
        "typescript-language-server",
        "--stdio"
    ],
    "cmd_windows": [
        "typescript-language-server.cmd",
        "--stdio"
    ]
}
</syntaxhighlight>
This assumes that "typescript-language-server" is in the PATH (it is true on Ubuntu). For Windows, you need to find the folder of "typescript-language-server.cmd" and add it to PATH.

=== TypeScript ===
* Install TypeScript lexer from "Addons Manager".
* Install TypeScript and the LSP server. In Terminal:

 npm install -g typescript typescript-language-server

* Create CudaText LSP config: file "settings/lsp_ts.json" with such content:
<syntaxhighlight lang="json">
{
  "lexers": {
    "TypeScript": "typescript"
  },
  "cmd_unix": [
    "typescript-language-server", 
    "--stdio",
    "--log-level", "4"
  ],
  "cmd_windows": [
    "typescript-language-server.cmd",
    "--stdio",
    "--log-level", "4"
  ]
}
</syntaxhighlight>
This assumes that "typescript-language-server" is in the PATH (it is true on Ubuntu). For Windows, you need to find the folder of "typescript-language-server.cmd" and add it to PATH.

According to https://www.zeusedit.com/lsp/typescript.html, sometimes more complex config file may be needed.
Here it is on Ubuntu:
<syntaxhighlight lang="json">
{
  "lexers": {
    "TypeScript": "typescript"
  },
  "cmd_unix": [
    "typescript-language-server", 
    "--stdio", 
    "--log-level", "4",
    "--tsserver-log-verbosity=verbose",
    "--tsserver-path=/usr/local/lib/node_modules/typescript/lib/"
  ],
  "cmd_windows": [
    "typescript-language-server.cmd",
    "--stdio", 
    "--log-level", "4",
    "--tsserver-log-verbosity=verbose",
    "--tsserver-path=\"%APPDATA%\\npm\\node_modules\\typescript\\lib\\\""
  ]
}
</syntaxhighlight>

How did I get the last path? It may be different on different Linux'es. It is from the "node_modules" dir which contains the '''globally installed''' Node.js modules. I found it by running "which typescript-language-server", it gave "/usr/local/bin/typescript-language-server". Then I checked symlink target for "/usr/local/bin/typescript-language-server" - it points to the sub-dir of needed "node_modules".

Test the auto-completion on this "test.ts" file (with TypeScript lexer):

 document.body.g

=== C/C++ ===
Install one of the servers (clangd or ccls).

==== clangd ====
: '''''[https://clangd.llvm.org/installation.html clangd homepage]'''''
For Windows, you need the "clangd.exe" and "clang.exe" binaries. You can get them in two ways:
# '''Standalone (lightweight)'''
#* Download "clangd-windows-x.x.x.zip" from https://github.com/clangd/clangd/releases. Extract it and add the "bin" folder to your OS PATH.
# '''Via compiler suites''' (needed for full auto-completion and headers)
#* If you need clangd to correctly find your project headers and provide full auto-completion, it is better to get it via one of these tools:
#** '''LLVM Toolchain:''' Download the LLVM installer from the LLVM GitHub releases. During installation, select "Add LLVM to the system PATH".
#** '''MinGW/MSYS2:''' If you use MinGW, install the package "mingw-w64-x86_64-clang-tools-extra".
#** '''Visual Studio Build Tools:''' Download from: https://visualstudio.microsoft.com/downloads/ (scroll to "Tools for Visual Studio" → "Build Tools for Visual Studio").
#*** Run the installer and select the workload "Desktop development with C++".
#*** In the optional components, ensure these are checked:
#**** "C++ Clang tools for Windows"
#**** The latest MSVC toolset (e.g., MSVC v143 or similar).
#**** Windows SDK (usually selected by default).

==== ccls ====
* https://github.com/MaskRay/ccls/wiki/Build
* https://github.com/MaskRay/ccls/wiki/Install

To use the server in LSP Client, create a file "lsp_c.json" in the "settings" directory:
<syntaxhighlight lang="json">
{
  "lexers": {
    "C++": "cpp",
    "C": "c"
  },
  "cmd_unix": [
      "clangd",
  ],
  "cmd_windows": [
      "clangd",
  ],
}
</syntaxhighlight>

Replace "clangd" with "ccls" if it was chosen. Note that on some Linux systems, you might need to use a versioned command like "clangd-15".

You can test auto-completion on this sample file main.cpp:

<syntaxhighlight lang="cpp">
#include <string>
int main(){
    std::string aaa="aaa";
    aaa.    // <--- call auto-completion here after "."
}
</syntaxhighlight>

=== C# ===
First, install the C# lexer from "Plugins / Addons Manager / Install".

1. '''Download OmniSharp from the releases page:''' https://github.com/OmniSharp/omnisharp-roslyn/releases . For Windows 64-bit you may see two packages:

* "omnisharp-win-x64-net6.0.zip" '''(recommended)''' — '''modern .NET 6 build''' (recommended for SDK-style projects such as .NET Core / .NET 5 / .NET 6+). Use this for projects that build with <code>dotnet build</code>. Install .NET 6 SDK and ensure <code>dotnet</code> is on PATH (or set <code>DOTNET_ROOT</code> and <code>OMNISHARP_sdk_path</code> to the NET 6 SDK folder if you cannot change your PATH). Then use "omnisharp-win-x64-net6.0.zip". OmniSharp will use the MSBuild dll included in the .NET SDK. [https://github.com/OmniSharp/omnisharp-roslyn/issues/2339 GitHub].

* "omnisharp-win-x64.zip" — '''legacy .NET Framework/Mono build''' (for older non-SDK csproj formats or Unity projects). Full Framework projects require MSBuild/Mono to be available on the system. Install '''Visual Studio Build Tools''' (choose “.NET desktop build tools” in the installer) or a full Visual Studio on Windows, or install '''Mono''' on Linux/macOS. Then use the legacy OmniSharp build "omnisharp-win-x64.zip". [https://github.com/OmniSharp/omnisharp-vscode/issues/5120 GitHub].

'''Note for Windows 7 users:''' it is recommended to use "omnisharp-win-x64-net6.0.zip" too, but if you must use "omnisharp-win-x64.zip" then newer Visual Studio 2022 Build Tools may not support Windows 7. If you must remain on Windows 7, older OmniSharp release included a bundled <code>msbuild</code> ("omnisharp-win-x64.zip" v1.38.2) it works fine and does not need to have Visual Studio installed (you only need the Reference Assemblies of your targeted framework).

2. '''Install & configure:'''

* Unzip OmniSharp to a folder (for example "C:\OmniSharp"). No need to add OmniSharp to system PATH.

* Create LSP config file: (CudaText)/settings/lsp_cs.json:

<syntaxhighlight lang="json">
{
  "lexers": {
    "C#": "csharp"
  },
  "cmd_windows": [
    "C:\\OmniSharp\\OmniSharp.exe", "-lsp", "-z"
  ]
}
</syntaxhighlight>

Note that backslashes must be doubled (because of JSON format).

3. '''Test'''. To test that server works: create a file "test.cs" (with C# lexer active). Call auto-completion after "date.A".

<syntaxhighlight lang="csharp">
using System;

public class DateExample
{
	public static void Main()
	{
		DateTime  date;
		date.A
	}
}
</syntaxhighlight>

Important note. A CudaText project is necessary to enable LSP features. You must open your C# folder (containing the .sln or .csproj files) as a CudaText project for the LSP to function correctly.

=== CSS/SCSS/LESS ===
The CSS (and SCSS, LESS) server is not easy to install, so here is the instruction, from the author of LSP Client:

* Download the repository of VSCode: https://github.com/microsoft/vscode
* From the repository, get the folder "extensions/css-language-features/server" and enter in it.
* Replace the file "tsconfig.json" with content:
<syntaxhighlight lang="json">
{
    "compilerOptions": {
	    "target": "es2018",
	    "lib": [
		    "es2018"
	    ],
	    "module": "commonjs",
	    "strict": true,
	    "alwaysStrict": true,
	    "noImplicitAny": true,
	    "noImplicitReturns": true,
	    "noImplicitOverride": true,
	    "noUnusedLocals": true,
	    "noUnusedParameters": true,
	    "forceConsistentCasingInFileNames": true,
	    
	    "outDir": "./out"
    },
  "files": [
      "src/node/cssServerMain.ts"
  ]
}
</syntaxhighlight>

* Install dependencies and TypeScript. In Terminal:

 npm install
 npm install -g typescript

* Compile it. In Terminal:

 npx tsc

Server should be compiled.

Create config file (CudaText)/settings/lsp_css.json:
<syntaxhighlight lang="json">
{
    "name": "vsc-css",
    "lexers": {
    	"CSS": "css",
    	"SCSS": "scss",
    	"Sass": "sass",
    	"LESS": "less",
    },
    "cmd_unix": [
        "node",
        "path_to_server/server/out/node/cssServerMain.js",
        "--stdio"
    ]
}
</syntaxhighlight>

=== HTML ===
CudaText does not support built-in HTML auto-completion when caret is inside style="..." blocks.
But LSP server supports it.
Install server using Node.js:

 npm install --global vscode-html-ls-bin

Make config file (CudaText)/settings/lsp_html.json:
<syntaxhighlight lang="json">
{
    "lexers": {
    	"HTML": "html",
    },
    "cmd_windows": ["html-ls.cmd", "--stdio"],
    "cmd_unix": ["html-ls", "--stdio"]
}
</syntaxhighlight>

Make sure the script "html-ls" ("html-ls.cmd" on Windows) is in the PATH.

You may see wrong sorting of CSS properties in the auto-completion list, when auto-completion is called for CSS prop with dash char. To fix that, you need to remove dash char "-" from the "nonword_chars" option. Do it via lexer-specific config for HTML.

=== Java ===
'''Part 1. Information for Windows.'''

* Install lexer "Java" from Addons Manager.

* Install [https://www.oracle.com/java/technologies/downloads/#jdk19-windows Java SE Development Kit 19] or later. If you have usual Java (JRE) then better remove it first. Then run in Console: 

 java -version

It must show something like this:

 java version "19.0.1" 2022-10-18
 Java(TM) SE Runtime Environment (build 19.0.1+10-21)
 Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

* Download package "jdt-language-server-1.9.0-2022*.tar.gz" from [https://download.eclipse.org/jdtls/milestones/?d Eclipse JDT Language Server milestone builds] and extract it to "C:\Java\jdt-language-server".

* Create "C:\Java\jLSP.cmd" batch file with the following contents (edit if necessary):
<syntaxhighlight lang="batch">
@echo off
echo.
echo Usage: jLSP.cmd CacheDir
echo where "CacheDir" is an absolute path to your data directory. eclipse.jdt.ls stores workspace specific information in it. This should be unique per workspace/project.
echo.

:: language server installation folder (adjust to suit)
set Directory=C:/Java/jdt-language-server
:: language server jar file (update based on version file of jar)
set JarFile=%Directory%/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
:: language server config folder location
set Config=%Directory%/config_win

set CacheDir=%~1
echo Directory: %Directory%
echo   JarFile: %JarFile%
echo    Config: %Config%
echo  CacheDir: %CacheDir%

java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar %JarFile% -configuration %Config% --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data %CacheDir%
</syntaxhighlight>

* Create LSP config file: (CudaText)/settings/lsp_java.json:
<syntaxhighlight lang="json">
{
  "lexers": {
    "Java": "java"
  },
  "cmd_windows": ["C:\\Java\\jLSP.cmd", "./cache_for_proj1"]  
}
</syntaxhighlight>

Use testing file "test.java". Place caret on last code line after "System.g" and call auto-completion.
<syntaxhighlight lang="java">
public class Example {
	public static void main(String[] args) {
		System.g
	}
}
</syntaxhighlight>

'''Part 2. Information for Linux.'''

* Install lexer "Java" from Addons Manager.

* Install "Java SE Development Kit" from [https://www.oracle.com/java/technologies/downloads/#jdk19-linux Oracle website] or from OS package manager. If you have usual Java (JRE) then better remove it first.

On Ubuntu this command works (2022 year):

 sudo apt install openjdk-17-jre-headless 

Then run in Console: 

 java -version

It must show something like this:

 openjdk version "17.0.4" 2022-07-19
 OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-120.04)
 OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-120.04, mixed mode, sharing)

* Download package "jdt-language-server-1.9.0-2022*.tar.gz" from [https://download.eclipse.org/jdtls/milestones/?d Eclipse JDT Language Server milestone builds] and extract it to "~\jdt-language-server".

* Create "~\jLSP.sh" shell script with the following contents, and make it executable:
<syntaxhighlight lang="bash">
#!/bin/bash
echo
echo Usage: jLSP.sh CacheDir
echo where "CacheDir" is an absolute path to your data directory. eclipse.jdt.ls stores workspace specific information in it. This should be unique per workspace/project.
echo

# language server installation folder (adjust to suit)
Directory=~/jdt-language-server
# language server jar file (update based on version file of jar)
JarFile=$Directory/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
# language server config folder location
Config=$Directory/config_linux

CacheDir=$1
echo Directory: $Directory
echo   JarFile: $JarFile
echo    Config: $Config
echo  CacheDir: $CacheDir

java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar $JarFile -configuration $Config --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data $CacheDir
</syntaxhighlight>

* Create LSP config file: (CudaText)/settings/lsp_java.json:
<syntaxhighlight lang="json">
{
  "lexers": {
    "Java": "java",
  },
  "cmd_unix": ["~/jLSP.sh", "./cache_for_proj1"],
}
</syntaxhighlight>

Use testing file "test.java". Place caret on last code line after "System.g" and call auto-completion.
<syntaxhighlight lang="java">
public class Example {
	public static void main(String[] args) {
		System.g
	}
}
</syntaxhighlight>

=== Nim ===
Server from https://github.com/PMunch/nimlsp works good.

Config file (CudaText)/settings/lsp_nim.json:

<syntaxhighlight lang="json">
{
    "name": "nim-lsp",
    "lexers": {
        "Nim": "nim"
    },
    "cmd_unix": [
      "~/.nimble/bin/nimlsp"
    ]
}
</syntaxhighlight>

=== Rust ===
RLS server ( https://github.com/rust-lang/rls ) has been deprecated and is no longer supported. It has been replaced with Rust-analyzer. Users are encouraged to uninstall RLS and follow the instructions in the Rust-analyzer manual to install it.
User needs to download binary file for his system: https://github.com/rust-lang/rust-analyzer#quick-start

Create config (CudaText)/settings/lsp_rust.json:

<syntaxhighlight lang="json">
{
  "lexers": {
    "Rust": "rust"
  },
  "cmd_windows": ["rust-analyzer-x86_64-pc-windows-msvc.exe"],
  "cmd_unix": ["rust-analyzer-x86_64-unknown-linux-gnu"]
}
</syntaxhighlight>

=== AutoHotkey ===
* Download the repository of AutoHotkey2: https://github.com/thqby/vscode-autohotkey2-lsp
* Extract and enter the directory: "vscode-autohotkey2-lsp-main" 
* Install dependencies and TypeScript. In Terminal:

 npm install
 npm install -g typescript

* Enter the directory "server", and compile the server. In Terminal:

 npx tsc

Server should be compiled now. To use the server in LSP Client, create the file "lsp_ahk.json" in the "settings" with such content:
<syntaxhighlight lang="json">
{
    "name": "AutoHotkey2",
    "lexers": {
        "AutoHotkey": "ahk"
    },
    "cmd_unix": [
        "node",
        "path_to_server/server/out/server.js",
        "--stdio"
    ]
}
</syntaxhighlight>

=== Red ===
1) On Linux x64.

* Install Red. Download "red" binary, "chmod +x red", then copy it to PATH dir (/usr/bin on Ubuntu). Command "red" must work from Terminal. Red release 0.6.4 may give errors with the LSP server, so better install build from 30-Sep-2021.
* Install server from https://github.com/bitbegin/redlangserver, put the repo e.g. to ~/redlangserver.
* Create file "redlangserver.sh" and put it to some PATH dir. Content:

<syntaxhighlight lang="bash">
#!/bin/bash
red ~/redlangserver/server.red
</syntaxhighlight>

* Create file (CudaText)/settings/lsp_red.json with content:

<syntaxhighlight lang="json">
{
  "lexers": {
    "Red": "red"
  },
  "cmd_unix": ["redlangserver.sh"],
  "cmd_windows": ["c:\\red\\red.exe", "--cli", "c:\\red\\redlangserver\\server.red"]
}
</syntaxhighlight>

Server should work now. It gives: mouse hover tooltips (Ctrl + mouse hovering over names), go to definition.

2) On Windows 10 x64.

* Install Red to "c:\Red". Tested the build from 02-Oct-2021.
* Install server from https://github.com/bitbegin/redlangserver, put the repo to "c:\Red\redlangserver".
* Run once the command "c:\red\red.exe --cli", it will print "Compiling Red console..." with the big pause.
* Create file (CudaText)\settings\lsp_red.json with the same content as for Unix. Adjust path to Red folder, if needed.

Server should work now. It gives: mouse hover tooltips (Ctrl + mouse hovering over names), go to definition (works not always, logic when it works is unclear).

Note: don't create .bat or .cmd file with the "red.exe" calling, because it does not work in LSP Client for some reason. 

=== PHP ===
1. Install PHP, Composer. PHP versions 7.4.3 and 8.1 are OK. 

2. Install php-dom extension. php-dom extension is the only needed for this server to work, and it must be installed before you run "composer update".

3. Clone Git repo https://github.com/zobo/php-language-server , and get the full path to the file "php-language-server.php", it will be needed in the next step. See readme "Installation" part, you must do some steps with Composer first, e.g. "composer update" inside php-language-server directory. 

4. Create LSP config (CudaText)/settings/lsp_php.json:

<syntaxhighlight lang="json">
{
    "name": "PHP",
    "lexers": {
        "PHP": "php"
    },
    "tcp_port": 12345,
    "cmd_unix": [
      "php",
      "folder_of_server/bin/php-language-server.php",
      "--tcp-server=127.0.0.1:12345"
    ],
    "cmd_windows": [
      "php",
      "D:\\programm\\php\\php-language-server\\bin\\php-language-server.php",
      "--tcp-server=127.0.0.1:12345"
    ]
}
</syntaxhighlight>

Server should work now. It gives these features: https://github.com/zobo/php-language-server#features .

Auto-completion works, it is not working if you open .php file that is outside of current CudaText project directory.
In LSP Client config there is a parameter named "root_dir_source". For zobo's server to index .php files they must be inside this dir.
In CudaText Project Manager you must save your project file to your php project location, otherwise the root_dir will be wrong.

Note: on Windows, in rare cases hanging php.exe process can prevent LSP server from starting. If you see "ReadLoopError" in Console, try to kill all "php" processes and try again.

=== Bash shell ===
* Install Node.js, see readme here: https://github.com/nodesource/distributions/blob/master/README.md
* Install Bash server, see readme here: https://github.com/bash-lsp/bash-language-server
* Install Shellcheck from https://www.shellcheck.net/ - "We strongly recommend that you install shellcheck to enable linting"
* On Windows, maybe you need to add folder of "bash-language-server.cmd" to system PATH. 
* Create file (CudaText)/settings/lsp_bash.json with content:

<syntaxhighlight lang="json">
{
    "lexers": {
        "Bash script": "bash"
    },
    "cmd_windows": ["bash-language-server.cmd", "start"],    
    "cmd_unix": ["bash-language-server", "start"]
}
</syntaxhighlight>

=== D ===
First, install D lexer from "Addons Manager".

1. Install DLang into "C:\D", for example. For 64-bit compiler, add folder "C:\D\dmd2\windows\bin64" to system PATH. Check that "dmd" and "dub" commands run OK from Windows console.

2. Install the LSP server, run from console:

 dub fetch dls

This must show output like

 C:\D>dub fetch dls
 Fetching dls 0.26.2...
 Please note that you need to use `dub run <pkgname>` or add it to dependencies of your package to actually use/run it. dub does not do actual installation of packages outside of its own ecosystem.

3. Compile the LSP server, run from console:

 dub run dls:bootstrap

This must show output like

 C:\D>dub run dls:bootstrap
 Building package dls:bootstrap in C:\Users\user\AppData\Local\dub\packages\dls-0.26.2\dls\bootstrap\
 Running pre-generate commands for dls:i18n...
 Performing "debug" build using C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
 dls:protocol 0.26.2: building configuration "library"...
 dls:i18n 0.26.2: building configuration "library"...
 dls:bootstrap 0.26.2: building configuration "application"...
 Linking...
 Running ../Users/user/AppData/Local/dub/packages/dls-0.26.2/dls/bootstrap/dls_bootstrap.exe
 C:\Users\user\AppData\Local\dub\packages\.bin\dls-latest\dls.exe

Copy to clipboard the last printed filename with dls.exe.

4. Create the CudaText LSP config: (CudaText)/settings/lsp_d.json. The dls.exe filename is from the previous step. Note: backslashes must be doubled (because of JSON format).
<syntaxhighlight lang="json">
{
  "lexers": {
    "D": "dlang"
  },
  "cmd_windows": [
    "C:\\Users\\user\\AppData\\Local\\dub\\packages\\.bin\\dls-latest\\dls.exe", "--stdio"
  ]
}
</syntaxhighlight>

5. Create test file "test.d" (with lexer D). Test that auto-completion works after "b.":
<syntaxhighlight lang="d">
class A {int a; int a2;}
class B: A {int a3;}

void foo(B b)
{
 	b.
}
</syntaxhighlight>

=== Go ===
Install lexer Go from "Addons Manager".

1. Install Go. Make sure that Go binary is in the system PATH, and GOPATH variable is also set.

2. Install the LSP server:

 go install golang.org/x/tools/gopls@latest

In Ubuntu, this must create binary "gopls" in the folder "~/go/bin" (on Windows it may be "C:\Go\bin"), which is in the PATH. Check that "gopls" runs:

 gopls version

It must give output like:

 golang.org/x/tools/gopls v0.9.5
     golang.org/x/tools/gopls@v0.9.5 h1:F3TO5th6TUg40FHrpxZfMkMlVaaTmByeEvylgVHGH2A=

3. Create CudaText LSP config (CudaText)/settings/lsp_go.json:
<syntaxhighlight lang="json">
{
  "lexers": {
    "Go": "go"
  },
  "cmd_unix": [
    "gopls" 
  ],
  "cmd_windows": [
    "gopls.exe"
  ]
}
</syntaxhighlight>

4. See the content of GOPATH env variable, and create file "test.go" (with lexer Go) in that folder. Check that auto-completion works after "fmt.F":
<syntaxhighlight lang="go">
package aa
import ("fmt")

func main() {
  fmt.F
}
</syntaxhighlight>

=== Lua ===
1. Install server for the command line from https://github.com/sumneko/lua-language-server . Find the full path of the file "lua-language-server" ("lua-language-server.exe" on Windows).

2. Create LSP config (CudaText)/settings/lsp_lua.json:
<syntaxhighlight lang="json">
{
  "lexers": {
     "Lua": "lua"
  },
  "log_stderr": true,
  "cmd_windows": ["D:\\Programs\\lua-lsp\\bin\\lua-language-server.exe"],
  "cmd_unix": ["/path/to/lua-language-server"]
}
</syntaxhighlight>

=== Scala ===
Install lexer "Scala" from Addons Manager.
Information for Windows.

1. Install Coursier: https://get-coursier.io/docs/cli-installation

2. Install Metals. Make sure "metals.bat" is in the system PATH.

 cs install metals

3. Create LSP config file (CudaText)/settings/lsp_scala.json:
<syntaxhighlight lang="json">
{
  "lexers": {
    "Scala": "scala"
  },
  "cmd_windows": ["metals.bat"]
}
</syntaxhighlight>

Testing file for auto-completion:

 object Hello extends App {
     println("Hello, world")
 }

=== Fortran ===
Install lexer "Fortran" from Addons Manager.
Steps show how to use server on Linux (Ubuntu 20.04) with Python 3 installed.

1. Install the LSP server:

 pip install fortran-language-server

Check that command runs OK:

 fortls -?

And check its full path:

 which fortls

Here it prints: "/home/user/.local/bin/fortls". We will need that full path in the next step, because short program name "fortls" gave errors for me.

2. Create LSP config file: (CudaText)/settings/lsp_fortran.json:
<syntaxhighlight lang="json">
{
  "lexers": {
    "Fortran": "fortran"
  },
  "cmd_unix": [
      "/home/user/.local/bin/fortls" 
  ]
}
</syntaxhighlight>

3. Make test file "test.for" (with Fortran lexer). Test auto-completion after "CALL myv".
<syntaxhighlight lang="fortran">
PROGRAM myprog
USE test_free, ONLY: scaled_vector
TYPE(scaled_vector) :: myvec
CALL myv
END PROGRAM
</syntaxhighlight>

=== Markdown ===
1. Get precompiled Marksman LSP server from GitHub: https://github.com/artempyanykh/marksman/releases

2. On Windows, copy "marksman.exe" to some folder in PATH. On Linux, copy "marksman-linux" to this recommended folder in PATH: ~/.local/bin. Set executable permission for Linux binary.

 chmod +x marksman-linux

3. Create config file (CudaText)/settings/lsp_md.json:
<syntaxhighlight lang="json">
{
  "lexers": {
    "Markdown": "markdown"
  },
  "cmd_windows": ["marksman.exe"],
  "cmd_unix": ["marksman-linux"]
}
</syntaxhighlight>

Now auto-completion / goto-definition / hover-tooltip must work on this "test.md" file:
<syntaxhighlight lang="md">
[reference][abcd]
[reference][a123]

Some text.

[abcd]: url "title"
[a123]: url "title2"
</syntaxhighlight>

=== V ===
* Install V lexer (from "Addons Manager / Plugins / Install")
* Install V language
* Install v-analyzer binary from https://github.com/v-analyzer/v-analyzer to a folder (that is included in PATH)
* Create "lsp_v.json" in CudaText's "settings" folder with the following content:
<syntaxhighlight lang="json">
{
  "lexers": {
    "V": "v"
  },
  "cmd_windows": ["v-analyzer.exe"],
  "cmd_unix": ["v-analyzer"],
  "cmd_macos": ["v-analyzer"]
}
</syntaxhighlight>

=== Vale ===
Steps for Windows OS.

* Install Vale server. Add path of "vale-ls.exe" to system PATH.
* Create "lsp_vale.json" in CudaText's "settings" folder. Specify empty lexer name.
<syntaxhighlight lang="json">
{
    "lexers": {
        "": ""
    },
    
    "cmd_windows": ["vale-ls.exe"],
    "log_stderr": true,
    "settings": {
        "configPath": ""
    }
}
</syntaxhighlight>

* You need to put config file to %UserProfile% folder. For example: "C:\Users\john\.vale.ini".
* Do not forget to run: "vale sync".
* Vale server did not support filenames with spaces on Windows OS. To fix it, update Vale to 0.3.7 or newer.

=== Odin ===
Steps for Windows OS.

* Unzip Odin compiler zip-file into e.g. "C:\Odin". Add this folder to system PATH. Set environment variable ODIN_ROOT to this path.
* Unzip Odin LSP server zip-file into the same folder, so "ols.exe" is in the same folder as compiler "odin.exe".
* Install requirements which are needed for Odin.
* Create "lsp_odin.json" in CudaText's "settings" folder:
<syntaxhighlight lang="json">
{
  "lexers": {
    "Odin": "odin"
  },
  "cmd_windows": [ "C:/Odin/ols.exe" ]
}
</syntaxhighlight>
* Why full path in the "cmd_windows" line: to avoid LSP server log line 'cannot find builtin folder'. It is issue of the server.

Now you must create a CudaText project containing your Odin codes. It is mandatory, otherwise you will see CudaText console log line "LSP: Odin - process exited" and nothing will work. Create project, e.g. "c:\Work\tst.cuda-proj", and source code is "c:\Work\tst.odin" which must be added to the mentioned project. Example file "tst.odin":

<syntaxhighlight lang="odin">
package tst;

import "core:fmt";

main :: proc(){
	value: u128;
	using fmt;
	print()
}
</syntaxhighlight>

Folder "C:\Odin\base" must be also included to CudaText project, in order for LSP to work correctly. To do this, call context menu over Project Manager panel and call menu item "Root nodes / Add folder".

What must work now in the example file:

* Auto-completion
* Go to definition (editor's context-menu item)
* Show function-hint (Ctrl+Shift+Space inside function brackets, to show function signature)

Mouse-hover dialog is not working yet for some reason (it's enabled in server by default).


[[Category:CudaText]]
