Skip to content

Commit 16cc100

Browse files
authored
feat: support Tact 1.6.0 (#46)
1 parent e21d9ee commit 16cc100

File tree

5 files changed

+108
-106
lines changed

5 files changed

+108
-106
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Note, that you can [disable highlighting of identifiers](#highlighting), if you
2626

2727
## Installation
2828

29+
<!--
30+
2931
### First time in Vim 8+? Read this!
3032
3133
<details>
@@ -114,7 +116,9 @@ Don't forget to restart Vim after :)
114116
115117
</details>
116118
117-
### Vundle
119+
-->
120+
121+
### via Vundle
118122

119123
<details>
120124
<summary>Click to see</summary>
@@ -138,7 +142,7 @@ Steps:
138142

139143
</details>
140144

141-
### vim-plug
145+
### via vim-plug
142146

143147
<details>
144148
<summary>Click to see</summary>
@@ -162,7 +166,7 @@ Steps:
162166

163167
</details>
164168

165-
### lazy.nvim (Neovim-only)
169+
### via lazy.nvim (Neovim-only)
166170

167171
<details>
168172
<summary>Click to see</summary>
@@ -185,6 +189,12 @@ Steps:
185189

186190
</details>
187191

192+
### Language Server
193+
194+
In addition, it's strongly recommended that a Tact language server be installed and set up.
195+
196+
Get an official one here: [tact-language-server](https://github.com/tact-lang/tact-language-server).
197+
188198
## Configuration
189199

190200
### Completion

autoload/tact.vim

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,25 @@
1010

1111
" stdlib_functions {{{2
1212
let s:tact_stdlib_functions = {
13-
\ 'send(SendParameters{': 'Int'
13+
\ 'send(SendParameters{': ''
14+
\ , 'message(MessageParameters{': ''
15+
\ , 'deploy(DeployParameters{': ''
16+
\ , 'cashback(': ''
1417
\ , 'sender()': 'Address'
1518
\ , 'require(': ''
1619
\ , 'now()': 'Int'
20+
\ , 'curLt()': 'Int'
21+
\ , 'blockLt()': 'Int'
1722
\ , 'address(': 'Address'
1823
\ , 'myBalance()': 'Int'
1924
\ , 'myAddress()': 'Address'
2025
\ , 'newAddress(': 'Address'
26+
\ , 'emptyBasechainAddress()': 'BasechainAddress'
27+
\ , 'newBasechainAddress(': 'BasechainAddress'
2128
\ , 'contractAddress(': 'Address'
29+
\ , 'contractBasechainAddress(': 'BasechainAddress'
2230
\ , 'contractAddressExt(': 'Address'
31+
\ , 'contractHash(': 'Int'
2332
\ , 'emit(': ''
2433
\ , 'cell(': 'Cell'
2534
\ , 'ton(': 'Int'
@@ -43,26 +52,37 @@ let s:tact_stdlib_functions = {
4352
\ , 'log2(': 'Int'
4453
\ , 'pow(': 'Int'
4554
\ , 'pow2(': 'Int'
55+
\ , 'sign(': 'Int'
56+
\ , 'sqrt(': 'Int'
57+
\ , 'divc(': 'Int'
58+
\ , 'muldivc(': 'Int'
59+
\ , 'mulShiftRight(': 'Int'
60+
\ , 'mulShiftRightRound(': 'Int'
61+
\ , 'mulShiftRightCeil(': 'Int'
4662
\ , 'throw(': ''
47-
\ , 'nativeThrowIf(': ''
48-
\ , 'nativeThrowUnless(': ''
63+
\ , 'throwIf(': ''
64+
\ , 'throwUnless(': ''
4965
\ , 'getConfigParam(': 'Cell?'
5066
\ , 'nativeRandomize(': ''
5167
\ , 'nativeRandomizeLt()': ''
5268
\ , 'nativePrepareRandom(': ''
5369
\ , 'nativeRandom()': 'Int'
5470
\ , 'nativeRandomInterval(': 'Int'
71+
\ , 'getSeed()': 'Int'
72+
\ , 'setSeed(': ''
5573
\ , 'nativeReserve(': ''
5674
\ , 'nativeSendMessage(': ''
5775
\ , 'nativeSendMessageReturnForwardFee(': 'Int'
5876
\ , 'gasConsumed()': 'Int'
77+
\ , 'setGasLimit(': ''
5978
\ , 'getComputeFee(': 'Int'
6079
\ , 'getStorageFee(': 'Int'
6180
\ , 'getForwardFee(': 'Int'
6281
\ , 'getSimpleComputeFee(': 'Int'
6382
\ , 'getSimpleForwardFee(': 'Int'
6483
\ , 'getOriginalFwdFee(': 'Int'
6584
\ , 'myStorageDue()': 'Int'
85+
\ , 'myCode()': 'Cell'
6686
\ , 'parseStdAddress(': 'StdAddress'
6787
\ , 'parseVarAddress(': 'VarAddress'
6888
\ , 'slice(': 'Slice'
@@ -77,13 +97,15 @@ let s:tact_globals = {
7797
\ , 'SendIgnoreErrors': 'Int'
7898
\ , 'SendBounceIfActionFail': 'Int'
7999
\ , 'SendDestroyIfZero': 'Int'
100+
\ , 'SendDefaultMode': 'Int'
80101
\ , 'SendRemainingValue': 'Int'
81102
\ , 'SendRemainingBalance': 'Int'
82103
\ , 'SendOnlyEstimateFee': 'Int'
83104
\ , 'SendParameters{': 'SendParameters'
84105
\ , 'StateInit{': 'StateInit'
85106
\ , 'StdAddress{': 'StdAddress'
86107
\ , 'VarAddress{': 'VarAddress'
108+
\ , 'BasechainAddress{': 'BasechainAddress'
87109
\ , 'ReserveExact': 'Int'
88110
\ , 'ReserveAllExcept': 'Int'
89111
\ , 'ReserveAtMost': 'Int'
@@ -95,7 +117,9 @@ let s:tact_globals = {
95117
let s:tact_Map_methods = {
96118
\ 'get(': ''
97119
\ , 'set(': ''
98-
\ , 'del(': ''
120+
\ , 'replace(': 'Bool'
121+
\ , 'replaceGet(': ''
122+
\ , 'del(': 'Bool'
99123
\ , 'asCell()': 'Cell'
100124
\ , 'isEmpty(': 'Bool'
101125
\ , 'exists(': 'Bool'
@@ -117,6 +141,7 @@ let s:tact_StringBuilder_methods = {
117141
let s:tact_String_methods = {
118142
\ 'asComment()': 'Cell'
119143
\ , 'asSlice()': 'Slice'
144+
\ , 'hashData()': 'Int'
120145
\ , 'fromBase64()': 'Slice'
121146
\ }
122147

@@ -135,17 +160,25 @@ let s:tact_Builder_methods = {
135160
\ , 'storeBuilder(': 'Builder'
136161
\ , 'storeSlice(': 'Builder'
137162
\ , 'storeCoins(': 'Builder'
163+
\ , 'storeVarUint16(': 'Builder'
164+
\ , 'storeVarUint32(': 'Builder'
165+
\ , 'storeVarInt16(': 'Builder'
166+
\ , 'storeVarInt32(': 'Builder'
138167
\ , 'storeAddress(': 'Builder'
139168
\ , 'storeRef(': 'Builder'
140169
\ , 'storeMaybeRef(': 'Builder'
170+
\ , 'storeBasechainAddress(': 'Builder'
141171
\ , 'refs()': 'Int'
142172
\ , 'bits()': 'Int'
173+
\ , 'depth()': 'Int'
143174
\ , 'asSlice()': 'Slice'
144175
\ , 'asCell()': 'Cell'
145176
\ }
146177

147178
let s:tact_Cell_methods = {
148179
\ 'beginParse()': 'Slice'
180+
\ , 'depth()': 'Int'
181+
\ , 'computeDataSize()': 'Int'
149182
\ , 'hash()': 'Int'
150183
\ , 'asSlice()': 'Slice'
151184
\ }
@@ -161,16 +194,32 @@ let s:tact_Slice_methods = {
161194
\ , 'loadBool(': 'Bool'
162195
\ , 'loadBits(': 'Slice'
163196
\ , 'preloadBits(': 'Slice'
197+
\ , 'skipBits(': ''
198+
\ , 'skipLastBits(': ''
199+
\ , 'firstBits(': 'Slice'
200+
\ , 'lastBits(': 'Slice'
164201
\ , 'loadCoins()': 'Int'
202+
\ , 'loadVarUint16(': 'Int'
203+
\ , 'loadVarUint32(': 'Int'
204+
\ , 'loadVarInt16(': 'Int'
205+
\ , 'loadVarInt32(': 'Int'
165206
\ , 'loadAddress(': 'Address'
166207
\ , 'loadRef()': 'Cell'
208+
\ , 'preloadRef()': 'Cell'
209+
\ , 'loadMaybeRef()': 'Cell?'
210+
\ , 'preloadMaybeRef()': 'Cell?'
167211
\ , 'refs()': 'Int'
168212
\ , 'bits()': 'Int'
213+
\ , 'depth()': 'Int'
169214
\ , 'empty()': 'Bool'
170215
\ , 'dataEmpty()': 'Bool'
171216
\ , 'refsEmpty()': 'Bool'
217+
\ , 'computeDataSize()': 'Int'
172218
\ , 'hash()': 'Int'
219+
\ , 'hashData()': 'Int'
173220
\ , 'asCell()': 'Cell'
221+
\ , 'asAddress()': 'Address'
222+
\ , 'asAddressUnsafe()': 'Address'
174223
\ }
175224

176225
let s:tact_stdlib_deploy = [
@@ -245,6 +294,7 @@ let s:tact_types = [
245294
" NOTE: Pre-computed the values, because producing them on the fly isn't very convenient in VimScript
246295
let s:tact_native_types = [
247296
\ 'int257', 'coins', 'remaining', 'bytes32', 'bytes64'
297+
\ , 'varuint16', 'varuint32', 'varint16', 'varint32'
248298
\ , 'int1', 'int2', 'int3', 'int4', 'int5', 'int6', 'int7', 'int8'
249299
\ , 'int9', 'int10', 'int11', 'int12', 'int13', 'int14', 'int15', 'int16'
250300
\ , 'int17', 'int18', 'int19', 'int20', 'int21', 'int22', 'int23', 'int24'
@@ -2094,6 +2144,15 @@ function! tact#Complete(findstart, base) abort
20942144
continue
20952145
endif
20962146

2147+
" TODO: can try add parsing for contract parameters on the same line
2148+
" but: a) it's not a frequent case and b) this is a very brittle
2149+
" parsing-ish approach, and I'd better just either rewrite this
2150+
" as a top-down parser generated from the grammar.gg definition
2151+
" or simply leave things as is for the time being.
2152+
"
2153+
" if anything — there's a smarter LS that supports way more edge-cases.
2154+
" see: https://github.com/tact-lang/tact-language-server
2155+
20972156
" parsing a field
20982157
if l:buf_line =~# '^\%(const\s\+\)\?\w\+\s*:'
20992158
" extract name

doc/headless-readme.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Note, that you can [disable highlighting of identifiers](#highlighting), if you
2020

2121
## Installation
2222

23+
<!--
24+
2325
### First time in Vim 8+? Read this!
2426
2527
<details>
@@ -108,7 +110,9 @@ Don't forget to restart Vim after :)
108110
109111
</details>
110112
111-
### Vundle
113+
-->
114+
115+
### via Vundle
112116

113117
<details>
114118
<summary>Click to see</summary>
@@ -132,7 +136,7 @@ Steps:
132136

133137
</details>
134138

135-
### vim-plug
139+
### via vim-plug
136140

137141
<details>
138142
<summary>Click to see</summary>
@@ -156,7 +160,7 @@ Steps:
156160

157161
</details>
158162

159-
### lazy.nvim (Neovim-only)
163+
### via lazy.nvim (Neovim-only)
160164

161165
<details>
162166
<summary>Click to see</summary>
@@ -179,6 +183,12 @@ Steps:
179183

180184
</details>
181185

186+
### Language Server
187+
188+
In addition, it's strongly recommended that a Tact language server be installed and set up.
189+
190+
Get an official one here: [tact-language-server](https://github.com/tact-lang/tact-language-server).
191+
182192
## Configuration
183193

184194
### Completion

0 commit comments

Comments
 (0)