close
The Wayback Machine - https://web.archive.org/web/20211118132146/https://www.tabnine.com/semantic

Semantic Completion

Semantic completion permits suggestions which make use of language-specific information.

Tabnine is language agnostic, so it relies on other software to provide semantic completions.
Any server which implements the Language Server Protocol can be used as a source of semantic completions.

Tabnine comes with default choices of language servers for many common languages. You can also override Tabnine’s defaults to use a language server of your choice (described later).

To get semantic completion working:
  1. Verify you are running Tabnine 1.0.5 or above by typing Tabnine::version in your text editor. If you’re running an earlier version, try restarting your editor.
  2. Type Tabnine::sem to enable semantic completion.
  3. If Tabnine notifies you of an error, try installing the semantic completion backend manually by following the link in the table. If you don’t see any message, then semantic completion is working.

If the above steps don't work, check that the language server works when you run it in your terminal. If it works in the terminal, but Tabnine can't find it, follow these steps:

  1. Assume for the sake of these instructions that you're trying to get go-langserver to work. Use which go-langserver in your terminal to find the absolute path to the language server.
  2. Type Tabnine::config_dir in your editor to find your configuration directory.
  3. Find the entry in <config_dir>/ExampleTabNine.toml corresponding to your language.
    In this case it is:
    [language.go]
    command = "go-langserver"
    args = ["-mode", "stdio", "-gocodecompletion"]
    install = [["go", "get", "-u", "github.com/sourcegraph/go-langserver"]]
  4. Create a file <config_dir>/TabNine.toml and paste the entry you found above into it, but replace the command field with the absolute path you found in step 1. (If you're on Windows, you'll need to escape the backslashes in the path, for example C:\Users\janedoe should be replaced with C:\\Users\\janedoe ).
  5. Type Tabnine::restart into your text editor.
JavaScript/TypeScript
npm install -g typescript-language-server
typescript-language-server --stdio

Project link: TypeScript Language Server

Python
pip install python-language-server
pyls

Project link: Python Language Server

C/C++
clangd

(manual installation)

Project link: cquery

Rust
rustup update
rustup component add rls rust-analysis rust-src
rls

Project link: Rust Language Server

Go
go get -u golang.org/x/tools/gopls
gopls serve

Project link: Go Language Server

Ruby
gem install solargraph
solargraph stdio

Project link: Solargraph

HTML
npm install -g vscode-html-languageserver-bin
html-languageserver --stdio

Project link: VS Code HTML Language Server

OCaml/Reason
npm install -g ocaml-language-server
ocaml-language-server --stdio

Project link: OCaml Language Server

Haskell
hie --lsp

(manual installation)

Project link: Haskell IDE Engine

Dart
pub global activate dart_language_server
dart_language_server

Project link: Dart Language Server

PureScript
npm install -g purescript-language-server
purescript-language-server --stdio

Project link: PureScript Language Server

CSS/SCSS
npm install -g vscode-css-languageserver-bin
css-languageserver --stdio

Project link: vscode-css-languageserver-bin

Custom configuration

Create a file called TabNine.toml in your Tabnine configuration directory. You can find your Tabnine configuration directory by typing Tabnine::config_dir into a file while Tabnine is running.

Here is an example TabNine.toml which uses ccls for C++ completion rather than the default choice of cquery. It also does the following:

  • Allows Tabnine to start 2 language servers to enable prefetching.
  • Configures Tabnine to wait for the language server to respond when the user types . (rather than returning Tabnine's results immediately and caching the server's response for future requests). This is enabled by default for both . and ::.
  • Waits 200 ms for the language server to respond when the user types . or :: (the default is 50 ms).
  • Prevents Tabnine from always preferring language server suggestions over other identifiers.
[language.cpp]
command = "ccls"
args = ["--init={\"cacheDirectory\":\"${project_root}/.ccls\"}"]
synchronous_triggers = ["."]
synchronous_timeout_ms = 200
num_server_instances = 2
always_prefer = false