From df1f8a60cf55689ccd46a537c948405c395a5019 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 29 May 2026 08:51:55 +0800 Subject: [PATCH] vim-patch:9.2.0551: filetype: Tolk files are not recognized Problem: filetype: Tolk files are not recognized Solution: Detect *.tolk files as tolk filetype, include a syntax and filetype plugin (redavy) Tolk is a new-generation language for writing smart contracts on TON blockchain, which is vim/vim#1 in speed among other chains. Reference: https://docs.ton.org/blockchain-basics/tolk/overview closes: vim/vim#20320 https://github.com/vim/vim/commit/b9bba99712907c6c2f7139aa3bd3739a100d6a58 Co-authored-by: redavy --- runtime/ftplugin/tolk.vim | 22 ++++++++++++++++++ runtime/lua/vim/filetype.lua | 1 + runtime/syntax/tolk.vim | 37 ++++++++++++++++++++++++++++++ test/old/testdir/test_filetype.vim | 1 + 4 files changed, 61 insertions(+) create mode 100644 runtime/ftplugin/tolk.vim create mode 100644 runtime/syntax/tolk.vim diff --git a/runtime/ftplugin/tolk.vim b/runtime/ftplugin/tolk.vim new file mode 100644 index 0000000000..f1339b7b6c --- /dev/null +++ b/runtime/ftplugin/tolk.vim @@ -0,0 +1,22 @@ +" Vim filetype plugin file +" Language: Tolk +" Maintainer: redavy +" Upstream: https://github.com/redavy/vim-tolk +" Last Update: 24 May 2026 + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +setlocal commentstring=//\ %s + +if get(g:, 'tolk_recommended_style', get(g:, 'recommended_style', 1)) + setlocal tabstop=2 + setlocal shiftwidth=2 + setlocal expandtab + setlocal softtabstop=2 + setlocal cindent +endif + +let b:undo_ftplugin = "setlocal commentstring< tabstop< shiftwidth< expandtab< softtabstop< cindent<" diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index a10c5c80c2..af27e53fec 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1350,6 +1350,7 @@ local extension = { tiltfile = 'tiltfile', tla = 'tla', tli = 'tli', + tolk = 'tolk', toml = 'toml', tpp = 'tpp', treetop = 'treetop', diff --git a/runtime/syntax/tolk.vim b/runtime/syntax/tolk.vim new file mode 100644 index 0000000000..ce3ffc678f --- /dev/null +++ b/runtime/syntax/tolk.vim @@ -0,0 +1,37 @@ +" Vim syntax file +" Language: Tolk +" Maintainer: redavy +" Upstream: https://github.com/redavy/vim-tolk +" Last Update: 28 May 2026 + +if exists("b:current_syntax") + finish +endif + +" Keywords +syn keyword tolkKeyword do if as fun asm get try var val lazy +syn keyword tolkKeyword else enum true tolk const false throw +syn keyword tolkKeyword redef while catch return assert import +syn keyword tolkKeyword global repeat contract mutate struct +syn keyword tolkKeyword match type null void never + +" Strings +syn region tolkString start=+"+ end=+"+ +syn region tolkString start=+'+ end=+'+ + +" Numbers +syn match tolkNumber "\<[0-9]\+\>" +syn match tolkNumber "\<0[xX][0-9a-fA-F]\+\>" +syn match tolkNumber "\<[0-9]\+\.[0-9]\+\>" + +" Comments +syn match tolkComment "//.*$" +syn region tolkComment start="/\*" end="\*/" + +" Highlights +hi link tolkKeyword Keyword +hi link tolkString String +hi link tolkNumber Number +hi link tolkComment Comment + +let b:current_syntax = "tolk" diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index fa4d96247a..eb9e38c917 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -903,6 +903,7 @@ func s:GetFilenameChecks() abort \ 'tla': ['file.tla'], \ 'tli': ['file.tli'], \ 'tmux': ['tmuxfile.conf', '.tmuxfile.conf', '.tmux-file.conf', '.tmux.conf', 'tmux-file.conf', 'tmux.conf', 'tmux.conf.local'], + \ 'tolk': ['file.tolk'], \ 'toml': ['file.toml', 'uv.lock', 'Gopkg.lock', 'Pipfile', '/home/user/.cargo/config', '.black', \ 'any/containers/containers.conf', 'any/containers/containers.conf.d/file.conf', \ 'any/containers/containers.conf.modules/file.conf', 'any/containers/containers.conf.modules/any/file.conf',