Link Search Menu Expand Document

IDE Support for TTCN-3

ntt gives your editor advanced language features like auto complete, go to definition, find all references etc.

ntt implements the language server protocol. This makes ntt a universal TTCN-3 language plugin for virtually any editor, like:

If you are using ntt with an editor not listed here please share your configuration with other users and create a pull request in GitHub against this markdown document.

For most editors or IDEs you have to install ntt manually at a place where your editor can find it. Check out the ntt install section for details.

Troubleshooting: Go to Definition does not work

Go to Definition works only for known TTCN-3 modules. Yet, there is no standard way of telling the language server where to look for TTCN-3 modules.

You should always open whole folders (Open > Folder) and not just single files (Open > File). The language server automatically recognizes all TTCN-3 from that opened folder. If your TTCN-3 test suite is organized across multiple folders, a test suite manifest file should be in the test suite’s root folder. When you open multiple folders (workspace), the first folder is considered the test suite root folder.

The command “TTCN-3: Show language server status” shows a list of all known TTCN-3 modules and will help to verify that all relevant modules are known by the language server

If you do not open the right folders, very little will work. This is the most common issue that we see. If you have suggestions on how to improve this, we’d love to hear from you.

The language server is still work in progress. Not all TTCN-3 semantic is implemented already, therefore some TTCN-3 structure might not work as expected:

  • Component Variables
  • Signatures
  • Dot Expressions (such as foo.bar)
  • Ambiguous Module Definitions (only the first hit is returned)

Visual Studio Code

Install the TTCN-3 extension for VS Code from the Visual Studio Marketplace. For additional details on installing extensions, see Extension Marketplace. The TTCN-3 extension is named TTCN-3 and it’s published by Nokia:

vscode TTCN-3 extension preview

ntt is still in beta and therefore disabled by default. Enable it by opening vscode settings and set ttcn3.useLanguageServer to true.

If you use an older version of this extension, ntt won’t be installed automatically. Either you install ntt manually or you update the TTCN-3 extension.

Vim 8

Example configuration using vim-plug and vim-lsp:

call plug#begin('~/.vim/plugged')

" Language Server Protocol Support
Plug 'prabirshrestha/async.vim' " Required for vim-lsp
Plug 'prabirshrestha/vim-lsp'   " Generic Language Protocol client
Plug 'mattn/vim-lsp-settings'   " Automatically install and configure language servers"

" For TTCN-3 syntax highlighting and to trigger vim-lsp-settings
Plug 'gustafj/vim-ttcn'

call plug#end()

Execute :PlugInstall to download and install all plugins. When you open a .ttcn3 source file syntax highlighting should work already and you will be prompted to execute :LspInstallServer for installing ntt.

Further vim-lsp recommends to map keys for your convenience:

function! s:on_lsp_buffer_enabled() abort
    setlocal omnifunc=lsp#complete
    setlocal signcolumn=yes
    if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
    nmap <buffer> gd <plug>(lsp-definition)
    nmap <buffer> gs <plug>(lsp-document-symbol-search)
    nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
    nmap <buffer> gr <plug>(lsp-references)
    nmap <buffer> gi <plug>(lsp-implementation)
    nmap <buffer> gt <plug>(lsp-type-definition)
    nmap <buffer> <leader>rn <plug>(lsp-rename)
    nmap <buffer> [g <Plug>(lsp-previous-diagnostic)
    nmap <buffer> ]g <Plug>(lsp-next-diagnostic)
    nmap <buffer> K <plug>(lsp-hover)

    let g:lsp_format_sync_timeout = 1000
    autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')

    " refer to doc to add more commands
endfunction

augroup lsp_install
    au!
    " call s:on_lsp_buffer_enabled only for languages that has the server registered.
    autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END

Emacs

First of all make sure ntt is manually installed.

Install lsp-mode from MELPA/ELPA and configure TTCN-3 support:

(use-package lsp-mode
  :hook ((ttcn-3-mode . lsp-deferred))
  :config
  (add-to-list 'lsp-language-id-configuration
    '(".*\\.ttcn3$" . "ttcn3"))
  (lsp-register-client
    (make-lsp-client :new-connection (lsp-stdio-connection '("ntt" "langserver"))
                     :activation-fn (lsp-activate-on "ttcn3")
                     :server-id 'ntt)))