This guide describes how to set up syntax highlighting and language server (LSP) features for the T programming language in various editors.
Syntax highlighting provides basic color coding for keywords,
operators, strings, and T-specific features like NSE variables
($column) and foreign code blocks
(<{ r_code }>).
Copy the ftdetect file:
mkdir -p ~/.vim/ftdetect
cp editors/vim/ftdetect/t.vim ~/.vim/ftdetect/t.vimCopy the syntax file:
mkdir -p ~/.vim/syntax
cp editors/vim/syntax/t.vim ~/.vim/syntax/t.vimRestart Vim. Files ending in .t will now have syntax
highlighting.
Add the emacs/ directory to your
load-path in init.el:
(add-to-list 'load-path "/path/to/tlang/editors/emacs")
(require 't-mode)Any .t file will now automatically open in
t-mode.
editors/vscode/t-lang folder to your VS Code
extensions directory:
~/.vscode/extensions/%USERPROFILE%\.vscode\extensions\The T language server provides advanced features like: - Autocompletion: Suggests functions, variables, and columns. - Diagnostics: Real-time syntax and basic semantic error reporting. - Hover Information: Shows types and documentation for variables and functions.
When you install the t-lang package via Nix (or use
nix develop), the t-lsp binary is
automatically added to your path. This binary is pre-configured with all
necessary dependencies.
nvim-lspconfig)Add this to your init.lua:
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
if not configs.tlang then
configs.tlang = {
default_config = {
cmd = { "t-lsp" },
filetypes = {'t'},
root_dir = lspconfig.util.root_pattern('tproject.toml', '.git'),
settings = {},
}
}
end
lspconfig.tlang.setup{}coc.nvim)Add this to your :CocConfig:
{
"languageserver": {
"tlang": {
"command": "t-lsp",
"filetypes": ["t"],
"rootPatterns": ["tproject.toml", ".git"]
}
}
}eglot)Add the following to your init.el:
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(t-mode . ("t-lsp"))))
;; Automatically start eglot when opening a .t file
(add-hook 't-mode-hook 'eglot-ensure)
If you are developing T itself, you can rebuild the LSP server with:
nix build .#defaultThe binary will be located at result/bin/t-lsp.