Semantic Completion

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

For example, this suggestion requires TabNine to infer that x is a string:

For information about the features TabNine provides once semantic completion is enabled, see this blog post.

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.
  5. Type TabNine::restart into your text editor.

LanguageCommandsProject link
JavaScript
npm install -g flow-bin
flow lsp
Flow
TypeScript
npm install -g typescript-language-server
typescript-language-server --stdio
TypeScript Language Server
Python
pip install python-language-server
pyls
Python Language Server
C/C++cquery --init={"cacheDirectory": "${project_root}/.cquery_cache"} (manual installation)cquery
Rust
rustup update
rustup component add rls-preview rust-analysis rust-src
rls
Rust Language Server
Go
go get -u github.com/sourcegraph/go-langserver
go-langserver -mode stdio -gocodecompletion
Go Language Server
Ruby
gem install solargraph
solargraph stdio
Solargraph
HTML
npm install -g vscode-html-languageserver-bin
html-languageserver --stdio
VS Code HTML Language Server
OCaml/Reason
npm install -g ocaml-language-server
ocaml-language-server --stdio
OCaml Language Server
Haskellhie --lsp (manual installation)Haskell IDE Engine
Dart
pub global activate dart_language_server
dart_language_server
Dart Language Server

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