Recent Changes - Search:

Home Page


Linux (via apt / rpm )
Linux wxWidgets
Release Notes


Build CodeLite

Debug CodeLite Linux
Building Clang
Build wxWidgets (MSW)
Coding Guidelines
Create a Plugin


What is Language Server?

From the Language Server WebSite: The Language Server Protocol (LSP) is used between the IDE and a language smartness provider (the server) to integrate features like auto complete, go to definition, find all references and alike into the tool

Auto detection

Starting with CodeLite 14, CodeLite supports auto scanning and configuring of clangd (the C++ code completion provider) and pyls (python language server) To do this:

clangd for Windows

clangd for Linux / macOS

  • Install clangd, On Ubuntu this is usually part of the package clang-tools, so type: sudo apt-get install clang-tools-9 (or if you have another different version of clang-tools, install it)
    • From CodeLite's menu bar, go to: Plugins -> Language Server -> Settings and click Scan button

Manual configuration of LSP

  • From the main menu go to : Plugins / Language Server / Settings. You will then be presented with this dialog:
  • Clicking on the 'Add' button will open the following dialog:
  • Name A unique name that identifies this Language Server, e.g. 'C++ by clangd'
  • Executable This is the server binary to execute. For server which relies on an external interpreter, such as node or php, put here the path to the interpreter binary (e.g. /usr/bin/php or /usr/bin/node)
  • Arguments Arguments to pass to the Executable field
  • Working directory The executable working directory (can be left empty)
  • Languages A semicolon list of languages supported by this LSP. Click the '...' button to get a list of all supported languages
  • Connection string Most of the LSP supports 2 methods of connectivity:
    • STDIO - the LSP is accepting requests over stdin and sends back the reply through stdout
    • TCP/IP - the LSP is accepting connections over sockets using TCP/IP. In this case, you should set the connection string in the form of tcp://<HOST>:<PORT>, for example tcp:// Note that CodeLite is always configured to be the client and the LSP is the server
  • Priority Multiple LSPs can be configured to handle the same language. Moreover, CodeLite provides an internal completion providers for C++/PHP and Nodejs. Setting the priority determines which provider will be called first in the chain.

The table below describes the default priority given for the builtin code-completion providers:

Provider Language Priority
C++ by ctags C/C++ 75
PHP plugin PHP 50
WebTools XML 50
WebTools CSS 50
WebTools JavaScript 50

Looking at the above table, if you want to configure clangd as a new C++ LSP you need to set its priority to a value higher than 75

Configuring clangd

clangd is the C++ LSP created and maintained by the LLVM team (the creators of the clang compiler). In order for clangd be able to provide code assistance, it needs to know how to compile the source file. clang uses a special file named compile_commands.json which can be generated in two ways:

  • If you are using CMake to build a project, it will do that for you EITHER by running CMake like this:
     cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 /path/to/src
OR by adding this line to the main CMakeLists.txt file:
  • If you are using CodeLite's default build system, CodeLite will generate this file automatically for you each time you trigger a build.

One problem worth mentioning is that clangd does not detect changes in this file. So if you add new file to a project, you will need to do the following:

  • Build the project so that CodeLite will regenerate an up-to-date version of the compile_commands.json file and it will restart clangd automatically for you

External links

Edit - History - Print - Recent Changes - Search
Page last modified on March 30, 2020, at 10:27 PM