From ae38d25d5c48b3d82f70b4a68f30ace14f1ab4cf Mon Sep 17 00:00:00 2001
From: Novus Nota <68142933+novusnota@users.noreply.github.com>
Date: Wed, 5 Mar 2025 07:21:32 +0100
Subject: [PATCH 1/2] feat: support Tact 1.6.0
And clean-up the readme, hiding the overly basic instructions and nudge
people towards using a language server
---
README.md | 16 ++++++++---
autoload/tact.vim | 67 ++++++++++++++++++++++++++++++++++++++++++++---
syntax/tact.vim | 8 ++++--
3 files changed, 82 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 39fad98..d1d4598 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,8 @@ Note, that you can [disable highlighting of identifiers](#highlighting), if you
## Installation
+
+
+### via Vundle
Click to see
@@ -138,7 +142,7 @@ Steps:
-### vim-plug
+### via vim-plug
Click to see
@@ -162,7 +166,7 @@ Steps:
-### lazy.nvim (Neovim-only)
+### via lazy.nvim (Neovim-only)
Click to see
@@ -185,6 +189,12 @@ Steps:
+### Language Server
+
+In addition, it's strongly recommended that a Tact language server be installed and set up.
+
+Get an official one here: [tact-language-server](https://github.com/tact-lang/tact-language-server).
+
## Configuration
### Completion
diff --git a/autoload/tact.vim b/autoload/tact.vim
index ebd2baa..8aa3ace 100644
--- a/autoload/tact.vim
+++ b/autoload/tact.vim
@@ -10,16 +10,25 @@
" stdlib_functions {{{2
let s:tact_stdlib_functions = {
- \ 'send(SendParameters{': 'Int'
+ \ 'send(SendParameters{': ''
+ \ , 'message(MessageParameters{': ''
+ \ , 'deploy(DeployParameters{': ''
+ \ , 'cashback(': ''
\ , 'sender()': 'Address'
\ , 'require(': ''
\ , 'now()': 'Int'
+ \ , 'curLt()': 'Int'
+ \ , 'blockLt()': 'Int'
\ , 'address(': 'Address'
\ , 'myBalance()': 'Int'
\ , 'myAddress()': 'Address'
\ , 'newAddress(': 'Address'
+ \ , 'emptyBasechainAddress()': 'BasechainAddress'
+ \ , 'newBasechainAddress(': 'BasechainAddress'
\ , 'contractAddress(': 'Address'
+ \ , 'contractBasechainAddress(': 'BasechainAddress'
\ , 'contractAddressExt(': 'Address'
+ \ , 'contractHash(': 'Int'
\ , 'emit(': ''
\ , 'cell(': 'Cell'
\ , 'ton(': 'Int'
@@ -43,19 +52,29 @@ let s:tact_stdlib_functions = {
\ , 'log2(': 'Int'
\ , 'pow(': 'Int'
\ , 'pow2(': 'Int'
+ \ , 'sign(': 'Int'
+ \ , 'sqrt(': 'Int'
+ \ , 'divc(': 'Int'
+ \ , 'muldivc(': 'Int'
+ \ , 'mulShiftRight(': 'Int'
+ \ , 'mulShiftRightRound(': 'Int'
+ \ , 'mulShiftRightCeil(': 'Int'
\ , 'throw(': ''
- \ , 'nativeThrowIf(': ''
- \ , 'nativeThrowUnless(': ''
+ \ , 'throwIf(': ''
+ \ , 'throwUnless(': ''
\ , 'getConfigParam(': 'Cell?'
\ , 'nativeRandomize(': ''
\ , 'nativeRandomizeLt()': ''
\ , 'nativePrepareRandom(': ''
\ , 'nativeRandom()': 'Int'
\ , 'nativeRandomInterval(': 'Int'
+ \ , 'getSeed()': 'Int'
+ \ , 'setSeed(': ''
\ , 'nativeReserve(': ''
\ , 'nativeSendMessage(': ''
\ , 'nativeSendMessageReturnForwardFee(': 'Int'
\ , 'gasConsumed()': 'Int'
+ \ , 'setGasLimit(': ''
\ , 'getComputeFee(': 'Int'
\ , 'getStorageFee(': 'Int'
\ , 'getForwardFee(': 'Int'
@@ -63,6 +82,7 @@ let s:tact_stdlib_functions = {
\ , 'getSimpleForwardFee(': 'Int'
\ , 'getOriginalFwdFee(': 'Int'
\ , 'myStorageDue()': 'Int'
+ \ , 'myCode()': 'Cell'
\ , 'parseStdAddress(': 'StdAddress'
\ , 'parseVarAddress(': 'VarAddress'
\ , 'slice(': 'Slice'
@@ -77,6 +97,7 @@ let s:tact_globals = {
\ , 'SendIgnoreErrors': 'Int'
\ , 'SendBounceIfActionFail': 'Int'
\ , 'SendDestroyIfZero': 'Int'
+ \ , 'SendDefaultMode': 'Int'
\ , 'SendRemainingValue': 'Int'
\ , 'SendRemainingBalance': 'Int'
\ , 'SendOnlyEstimateFee': 'Int'
@@ -84,6 +105,7 @@ let s:tact_globals = {
\ , 'StateInit{': 'StateInit'
\ , 'StdAddress{': 'StdAddress'
\ , 'VarAddress{': 'VarAddress'
+ \ , 'BasechainAddress{': 'BasechainAddress'
\ , 'ReserveExact': 'Int'
\ , 'ReserveAllExcept': 'Int'
\ , 'ReserveAtMost': 'Int'
@@ -95,7 +117,9 @@ let s:tact_globals = {
let s:tact_Map_methods = {
\ 'get(': ''
\ , 'set(': ''
- \ , 'del(': ''
+ \ , 'replace(': 'Bool'
+ \ , 'replaceGet(': ''
+ \ , 'del(': 'Bool'
\ , 'asCell()': 'Cell'
\ , 'isEmpty(': 'Bool'
\ , 'exists(': 'Bool'
@@ -117,6 +141,7 @@ let s:tact_StringBuilder_methods = {
let s:tact_String_methods = {
\ 'asComment()': 'Cell'
\ , 'asSlice()': 'Slice'
+ \ , 'hashData()': 'Int'
\ , 'fromBase64()': 'Slice'
\ }
@@ -135,17 +160,25 @@ let s:tact_Builder_methods = {
\ , 'storeBuilder(': 'Builder'
\ , 'storeSlice(': 'Builder'
\ , 'storeCoins(': 'Builder'
+ \ , 'storeVarUint16(': 'Builder'
+ \ , 'storeVarUint32(': 'Builder'
+ \ , 'storeVarInt16(': 'Builder'
+ \ , 'storeVarInt32(': 'Builder'
\ , 'storeAddress(': 'Builder'
\ , 'storeRef(': 'Builder'
\ , 'storeMaybeRef(': 'Builder'
+ \ , 'storeBasechainAddress(': 'Builder'
\ , 'refs()': 'Int'
\ , 'bits()': 'Int'
+ \ , 'depth()': 'Int'
\ , 'asSlice()': 'Slice'
\ , 'asCell()': 'Cell'
\ }
let s:tact_Cell_methods = {
\ 'beginParse()': 'Slice'
+ \ , 'depth()': 'Int'
+ \ , 'computeDataSize()': 'Int'
\ , 'hash()': 'Int'
\ , 'asSlice()': 'Slice'
\ }
@@ -161,16 +194,32 @@ let s:tact_Slice_methods = {
\ , 'loadBool(': 'Bool'
\ , 'loadBits(': 'Slice'
\ , 'preloadBits(': 'Slice'
+ \ , 'skipBits(': ''
+ \ , 'skipLastBits(': ''
+ \ , 'firstBits(': 'Slice'
+ \ , 'lastBits(': 'Slice'
\ , 'loadCoins()': 'Int'
+ \ , 'loadVarUint16(': 'Int'
+ \ , 'loadVarUint32(': 'Int'
+ \ , 'loadVarInt16(': 'Int'
+ \ , 'loadVarInt32(': 'Int'
\ , 'loadAddress(': 'Address'
\ , 'loadRef()': 'Cell'
+ \ , 'preloadRef()': 'Cell'
+ \ , 'loadMaybeRef()': 'Cell?'
+ \ , 'preloadMaybeRef()': 'Cell?'
\ , 'refs()': 'Int'
\ , 'bits()': 'Int'
+ \ , 'depth()': 'Int'
\ , 'empty()': 'Bool'
\ , 'dataEmpty()': 'Bool'
\ , 'refsEmpty()': 'Bool'
+ \ , 'computeDataSize()': 'Int'
\ , 'hash()': 'Int'
+ \ , 'hashData()': 'Int'
\ , 'asCell()': 'Cell'
+ \ , 'asAddress()': 'Address'
+ \ , 'asAddressUnsafe()': 'Address'
\ }
let s:tact_stdlib_deploy = [
@@ -245,6 +294,7 @@ let s:tact_types = [
" NOTE: Pre-computed the values, because producing them on the fly isn't very convenient in VimScript
let s:tact_native_types = [
\ 'int257', 'coins', 'remaining', 'bytes32', 'bytes64'
+ \ , 'varuint16', 'varuint32', 'varint16', 'varint32'
\ , 'int1', 'int2', 'int3', 'int4', 'int5', 'int6', 'int7', 'int8'
\ , 'int9', 'int10', 'int11', 'int12', 'int13', 'int14', 'int15', 'int16'
\ , 'int17', 'int18', 'int19', 'int20', 'int21', 'int22', 'int23', 'int24'
@@ -2094,6 +2144,15 @@ function! tact#Complete(findstart, base) abort
continue
endif
+ " TODO: can try add parsing for contract parameters on the same line
+ " but: a) it's not a frequent case and b) this is a very brittle
+ " parsing-ish approach, and I'd better just either rewrite this
+ " as a top-down parser generated from the grammar.gg definition
+ " or simply leave things as is for the time being.
+ "
+ " if anything — there's a smarter LS that supports way more edge-cases.
+ " see: https://github.com/tact-lang/tact-language-server
+
" parsing a field
if l:buf_line =~# '^\%(const\s\+\)\?\w\+\s*:'
" extract name
diff --git a/syntax/tact.vim b/syntax/tact.vim
index f044688..8c636b6 100644
--- a/syntax/tact.vim
+++ b/syntax/tact.vim
@@ -52,21 +52,25 @@ syn match tactOperator "=="
syn match tactOperator "<"
syn match tactOperator "<="
syn match tactOperator "<<"
+syn match tactOperator "<<="
syn match tactOperator ">"
syn match tactOperator ">="
syn match tactOperator ">>"
+syn match tactOperator ">>="
syn match tactOperator "\~"
syn match tactOperator "|"
syn match tactOperator "|="
syn match tactOperator "||"
+syn match tactOperator "||="
syn match tactOperator "&"
syn match tactOperator "&="
syn match tactOperator "&&"
+syn match tactOperator "&&="
syn match tactOperator "\^"
syn match tactOperator "\^="
syn keyword tactKeyword
\ as const let fun native primitive public extend self with in
- \ get abstract virtual override extends mutates inline initOf
+ \ get abstract virtual override extends mutates inline initOf codeOf
syn match tactKeyword "\:\@!"
syn match tactKeyword "\:\@!"
syn match tactKeyword "\:\@!"
@@ -100,7 +104,7 @@ syn match tactArrowRight "->"
" Types & Structures
syn keyword tactType
\ Int Bool Address Slice Cell Builder String StringBuilder
-syn match tactNativeType "\%(as\s\+\)\@<=\%(coins\|remaining\|bytes\%(32\|64\)\|int257\|u\?int\%(25[0-6]\|2[0-4][0-9]\|1\d\d\|[1-9]\d\?\)\)\>"
+syn match tactNativeType "\%(as\s\+\)\@<=\%(coins\|varu\?int\%(32\|16\)\|remaining\|bytes\%(32\|64\)\|int257\|u\?int\%(25[0-6]\|2[0-4][0-9]\|1\d\d\|[1-9]\d\?\)\)\>"
syn match tactGenericType
\ "\<\(map\|bounced\)\><\@=" nextgroup=tactGenericTypeBounds skipwhite
syn region tactGenericTypeBounds
From 160f9ac34fa23974ec7304daa0a3998e5c68823e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Wed, 5 Mar 2025 06:22:22 +0000
Subject: [PATCH 2/2] chore: auto-generate vimdoc via panvimdoc
---
doc/headless-readme.md | 16 ++++--
doc/tact.txt | 107 +++++------------------------------------
2 files changed, 26 insertions(+), 97 deletions(-)
diff --git a/doc/headless-readme.md b/doc/headless-readme.md
index ac7b933..57530fb 100644
--- a/doc/headless-readme.md
+++ b/doc/headless-readme.md
@@ -20,6 +20,8 @@ Note, that you can [disable highlighting of identifiers](#highlighting), if you
## Installation
+
+
+### via Vundle
Click to see
@@ -132,7 +136,7 @@ Steps:
-### vim-plug
+### via vim-plug
Click to see
@@ -156,7 +160,7 @@ Steps:
-### lazy.nvim (Neovim-only)
+### via lazy.nvim (Neovim-only)
Click to see
@@ -179,6 +183,12 @@ Steps:
+### Language Server
+
+In addition, it's strongly recommended that a Tact language server be installed and set up.
+
+Get an official one here: [tact-language-server](https://github.com/tact-lang/tact-language-server).
+
## Configuration
### Completion
diff --git a/doc/tact.txt b/doc/tact.txt
index 3540b9e..83d59ad 100644
--- a/doc/tact.txt
+++ b/doc/tact.txt
@@ -1,4 +1,4 @@
-*tact.txt* For Vim 8+ and Neovim >= 0.10.0 Last change: 2024 October 06
+*tact.txt* For Vim 8+ and Neovim >= 0.10.0 Last change: 2025 March 05
==============================================================================
Table of Contents *tact-table-of-contents*
@@ -39,97 +39,7 @@ you can |tact-disable-highlighting-of-identifiers|, if you want to :)
INSTALLATION *tact-installation*
-FIRST TIME IN VIM 8+? READ THIS! ~
-
-Click to see ~
-
-Assuming you don’t have any configuration in the `.vimrc` file, it’s nicer
-to setup some sane defaults first before using this (or any other) plugin.
-Also, the following mini-guide will use the built-in package management for Vim
-8+ and won’t introduce anything fancy.
-
-Steps: 1. Get yourself a Vim of version 8+ installed and make sure to have git
-installed and present on your path as well 2. Create a `~/.vimrc` file (or
-`~/_vimrc` if you’re on Windows) 3. Without such file there were sourced
-defaults by the Vim authors, but once it’s created, we have to put them back
-explicitly by adding those lines in and saving changes :w
-
->vim
- unlet! skip_defaults_vim
- source $VIMRUNTIME/defaults.vim
-<
-
-1. Whilewe’re here, let’s add some `tact.vim`-specific stuff in as well. This time save and quit as we no longer need to add anything (:wq):
-
->vim
- let g:tact_style_guide = 1 " Enabling default indentation style
-
- " the following is optional and added purely for your convenience:
- inoremap " Open completion menu on ctrl-space
-<
-
-Note: on macOS the `` is already bound in the system, so unless the
-terminal intercepts it you’ll have to use a different keybinding.
-
-1. It’s also nice to source in the extended defaults provided by the tpope/vim-sensible . To do so, let’s use the built-in package manager:
-
-On Linux, macOS or BSD:
-
->bash
- git clone "https://github.com/tpope/vim-sensible.git" ~/.vim/pack/tpope/start/sensible
-<
-
-On Windows, do this in PowerShell:
-
->powershell
- git clone 'https://github.com/tpope/vim-sensible.git' $HOME\vimfiles\pack\tpope\start\sensible
-<
-
-1. Finally, let’s install tact.vim
-
-OnLinux, macOS or BSD:
-
->bash
- git clone "https://github.com/tact-lang/tact.vim.git" ~/.vim/pack/tact-lang/start/tact
- vim -u NONE -c "helptags $HOME/.vim/pack/tact-lang/start/tact/doc" -c q
-<
-
-On Windows, do this in PowerShell:
-
->powershell
- git clone 'https://github.com/tact-lang/tact.vim.git' $HOME\vimfiles\pack\tact-lang\start\tact
- vim -u NONE -c 'helptags $HOME\vimfiles\pack\tact-lang\start\tact\doc' -c q
-<
-
-1. Start the Vim in the valid Tact project to be able to use `:Tact` command for easy compilation or simply provide any `.tact` file otherwise. Happy coding
-
-
-BUILT-INPACKAGE MANAGER IN VIM 8+ ~
-
-Click to see ~
-
-This is the recommended installation method if you use at least Vim 8 and you
-don’t use another package manager. More about Vim’s built-in package
-manager: `:help packages` .
-
-For Linux/macOS:
-
->sh
- git clone "https://github.com/tact-lang/tact.vim.git" ~/.vim/pack/tact-lang/start/tact
- vim -u NONE -c "helptags $HOME/.vim/pack/tact-lang/start/tact/doc" -c q
-<
-
-For Windows/PowerShell:
-
->powershell
- git clone 'https://github.com/tact-lang/tact.vim.git' $HOME\vimfiles\pack\tact-lang\start\tact
- vim -u NONE -c 'helptags $HOME\vimfiles\pack\tact-lang\start\tact\doc' -c q
-<
-
-Don’t forget to restart Vim after :)
-
-
-VUNDLE ~
+VIA VUNDLE ~
Click to see ~
@@ -150,7 +60,7 @@ Windows) by inserting the line that starts with `Plugin`
2. Run `:PluginInstall`.
-VIM-PLUG ~
+VIA VIM-PLUG ~
Click to see ~
@@ -171,7 +81,7 @@ Windows) by inserting the line that starts with `Plug`
2. Run `:PlugInstall`.
-LAZY.NVIM (NEOVIM-ONLY) ~
+VIA LAZY.NVIM (NEOVIM-ONLY) ~
Click to see ~
@@ -192,6 +102,15 @@ Steps: 1. Add `tact.vim` to your lazy.nvim setup in `~/.config/nvim/init.lua`
1. Run `:Lazy`.
+LANGUAGE SERVER ~
+
+In addition, it’s strongly recommended that a Tact language server be
+installed and set up.
+
+Get an official one here: tact-language-server
+.
+
+
CONFIGURATION *tact-configuration*