Skip to content

Files

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Latest commit

7203ca2 · Feb 18, 2025

History

History
233 lines (171 loc) · 7.43 KB

README.md

File metadata and controls

233 lines (171 loc) · 7.43 KB

Tact Language Server

This language server/extension provides support for the Tact programming language.

Features

  • Semantic syntax highlighting
  • Code completion with auto import, postfix completion, snippets, paths completion
  • Go to definition, implementation, type definition
  • Find all references, workspace symbol search, symbol renaming
  • Types and documentation on hover
  • Inlay hints for types and parameter names
  • On-the-fly inspections with quick fixes
  • Signature help inside calls, initOf and struct initialization
  • Lenses with implementation/reference counts
  • Building projects with Blueprint and Tact Template

Quick start

The easiest way to get started with Tact is to use VS Code or editors based on it:

  1. Install the Tact language extension in VS Code or in VS Code-based editors
  2. That's it!

Installation

VS Code / VSCodium / Cursor / Windsurf

  1. Get the latest .vsix file from releases, from VS Code marketplace or from Open VSX Registry
  2. In VS Code:
    • Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
    • Type "Install from VSIX"
    • Select the downloaded .vsix file
    • Reload VS Code

Other Editors

  1. Get the latest archive from releases:
    • tact-language-server-*.tar.gz for Linux/macOS
    • tact-language-server-*.zip for Windows
  2. Extract it to a convenient location
  3. Configure your editor to use the language server (see editor-specific instructions below)

Building from Source

If you want to build the language server yourself:

git clone https://github.com/tact-lang/tact-language-server
cd tact-language-server
yarn install
yarn build

For VS Code extension, additionally run:

yarn package

Editor Setup

Helix

  1. Make sure you have Helix installed and configured

  2. Add the following configuration to your ~/.config/helix/languages.toml:

    [[language]]
    name = "tact"
    language-servers = ["tact-language-server"]
    
    [language-server.tact-language-server]
    command = "node"
    args = ["path/to/language-server/dist/server.js", "--stdio"]
  3. Replace path/to/language-server with the actual path where you cloned the repository

  4. Restart Helix for changes to take effect

Neovim

Prerequisites:

Setup steps:

  1. Add tact.lua to your lua/lspconfig/server_configurations directory with the following content:

    local util = require 'lspconfig.util'
    
    return {
      default_config = {
        cmd = { 'node', '/absolute/path/to/language-server/dist/server.js', '--stdio' },
        filetypes = { 'tact' },
        root_dir = util.root_pattern('package.json', '.git'),
      },
      docs = {
        description = [[
          Tact Language Server
          https://github.com/tact-lang/tact-language-server
        ]],
        default_config = {
          root_dir = [[root_pattern("package.json", ".git")]],
        },
      },
    }
  2. Add the following to your init.lua:

    require'lspconfig'.tact.setup {}

Vim

Prerequisites:

  • Vim 8 or newer
  • Async LSP Client for Vim: vim-lsp
  • Plugin for Tact: tact.vim

Recommended, but not required:

Setup steps:

  1. Install the tact.vim if it isn't already installed. Prefer using a non-builtin plugin manager to easily get new updates.

  2. Install the vim-lsp plugin if it isn't already installed. For that, use vim-plug or the built-in package manager of Vim 8+, see :help packages.

  • If it wasn't installed before, you'll need to setup basic keybindings with the language client. Add the following to your ~/.vimrc (or ~/_vimrc if you're on Windows), or modify to your preferences:

    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)
        nnoremap <buffer> <expr><c-f> lsp#scroll(+4)
        nnoremap <buffer> <expr><c-d> lsp#scroll(-4)
    
        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
  1. Add the following to your ~/.vimrc (or ~/_vimrc if you're on Windows):

    if executable('node')
      au User lsp_setup call lsp#register_server({
            \ 'name': 'tact',
            \ 'cmd': {server_info->['node', '/absolute/path/to/language-server/dist/server.js', '--stdio']},
            \ 'allowlist': ['tact'],
            \ })
    endif

Sublime Text

  1. Install LSP package:

    • Open Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
    • Select "Package Control: Install Package"
    • Search for and select "LSP"
  2. Install the Tact package via Package Control for syntax highlighting

  3. Add the following configuration to your LSP settings (Preferences > Package Settings > LSP > Settings):

    {
        "clients": {
            "tact": {
                "enabled": true,
                "command": ["node", "path/to/language-server/dist/server.js", "--stdio"],
                "selector": "source.tact"
            }
        }
    }
  4. Create a new file with .tact extension to verify the setup

Troubleshooting

Common issues:

  • Path to the language server is incorrect
  • Node.js is not installed
  • Language server wasn't built properly

Logs Location

The language server generates logs that can help diagnose issues:

  • For standalone server: logs are written to dist/tact-language-server.log in the language server directory
  • For VS Code extension: logs can be found in:
    • Windows: %USERPROFILE%\.vscode\extensions\tact-[version]\dist\tact-language-server.log
    • macOS/Linux: ~/.vscode/extensions/tact-[version]/dist/tact-language-server.log

For more help, please open an issue.

License

MIT