patch 9.1.0998: filetype: TI assembly files are not recognized
Commit:
https://github.com/vim/vim/commit/4f73c07abff420bad9fa5befc2c284c00b984993
Author: Wu, Zhenyu <[email protected]>
Date: Wed Jan 8 20:20:06 2025 +0100
patch 9.1.0998: filetype: TI assembly files are not recognized
Problem: filetype: TI assembly files are not recognized
Solution: inspect '*.sa' and assembly files and detect TI assembly
files, include filetype plugin and syntax script for TI
assembly files (Wu, Zhenyu)
closes: #15827
Signed-off-by: Wu, Zhenyu <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/.github/MAINTAINERS b/.github/MAINTAINERS
index 80965385e..6052197de 100644
--- a/.github/MAINTAINERS
+++ b/.github/MAINTAINERS
@@ -292,6 +292,7 @@ runtime/ftplugin/tcsh.vim @dkearns
runtime/ftplugin/terraform.vim @JannoTjarks
runtime/ftplugin/tf.vim @ribru17
runtime/ftplugin/thrift.vim @jiangyinzuo
+runtime/ftplugin/tiasm.vim @Freed-Wu
runtime/ftplugin/tidy.vim @dkearns
runtime/ftplugin/tmux.vim @ericpruitt
runtime/ftplugin/toml.vim @averms
@@ -610,6 +611,7 @@ runtime/syntax/tcsh.vim @dkearns
runtime/syntax/teraterm.vim @k-takata
runtime/syntax/terraform.vim @gpanders
runtime/syntax/thrift.vim @jiangyinzuo
+runtime/syntax/tiasm.vim @Freed-Wu
runtime/syntax/tidy.vim @dkearns
runtime/syntax/tmux.vim @ericpruitt
runtime/syntax/toml.vim @averms
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index ce7f44fa6..f1e6ee272 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -3,7 +3,7 @@ vim9script
# Vim functions for file type detection
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
-# Last Change: 2024 May 23
+# Last Change: 2025 Jan 08
# Former Maintainer: Bram Moolenaar <[email protected]>
# These functions are moved here from runtime/filetype.vim to make startup
@@ -32,6 +32,10 @@ enddef
# This function checks for the kind of assembly that is wanted by the user, or
# can be detected from the first five lines of the file.
export def FTasm()
+ # tiasm uses `* commment`
+ if join(getline(1, 10), "
") =~ '\%(\%(^\|
\)\*\|Texas Instruments Incorporated\)'
+ setf tiasm
+ endif
# make sure b:asmsyntax exists
if !exists("b:asmsyntax")
b:asmsyntax = ""
@@ -1003,6 +1007,14 @@ export def SQL()
endif
enddef
+export def FTsa()
+ if join(getline(1, 4), "
") =~# '\%(^\|
\);'
+ setf tiasm
+ return
+ endif
+ setf sather
+enddef
+
# This function checks the first 25 lines of file extension "sc" to resolve
# detection between scala and SuperCollider.
# NOTE: We don't check for 'Class : Method', as this can easily be confused
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 737f88100..154ce79cb 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: The Vim Project <https://github.com/vim/vim>
-" Last Change: 2024 Dec 31
+" Last Change: 2025 Jan 08
" Former Maintainer: Bram Moolenaar <[email protected]>
" Listen very carefully, I will say this only once
@@ -2200,8 +2200,8 @@ au BufNewFile,BufRead *.sas setf sas
" Sass
au BufNewFile,BufRead *.sass setf sass
-" Sather
-au BufNewFile,BufRead *.sa setf sather
+" Sather, TI linear assembly
+au BufNewFile,BufRead *.sa call dist#ft#FTsa()
" Scala
au BufNewFile,BufRead *.scala setf scala
diff --git a/runtime/ftplugin/tiasm.vim b/runtime/ftplugin/tiasm.vim
new file mode 100644
index 000000000..13a3dc64f
--- /dev/null
+++ b/runtime/ftplugin/tiasm.vim
@@ -0,0 +1,18 @@
+" Vim filetype plugin file
+" Language: TI linear assembly language
+" Maintainer: Wu, Zhenyu <[email protected]>
+" Last Change: 2025 Jan 08
+
+if exists("b:did_ftplugin") | finish | endif
+let b:did_ftplugin = 1
+
+setlocal comments=:;
+setlocal commentstring=;\ %s
+
+let b:undo_ftplugin = "setl commentstring< comments<"
+
+if exists("loaded_matchit")
+ let b:match_words =
'^\s\+\.if\>:^\s\+\.elseif:^\s\+\.else\>:^\s\+\.endif\>,^\s\+\.group:^\s\+\.gmember:^\s\+\.endgroup,^\s\+\.loop:^\s\+\.break:^\s\+\.endloop,^\s\+\.macro:^\s\+\.mexit:^\s\+\.endm,^\s\+\.asmfunc:^\s\+\.endasmfunc,^\s\+\.c\?struct:^\s\+\.endstruct,^\s\+\.c\?union:^\s\+\.endunion,^\s\+\.c\?proc:^\s\+\.return:^\s\+\.endproc'
+ let b:match_ignorecase = 1
+ let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words"
+endif
diff --git a/runtime/syntax/tiasm.vim b/runtime/syntax/tiasm.vim
new file mode 100644
index 000000000..bdadc4a0a
--- /dev/null
+++ b/runtime/syntax/tiasm.vim
@@ -0,0 +1,102 @@
+" Vim syntax file
+" Language: TI linear assembly language
+" Document:
https://downloads.ti.com/docs/esd/SPRUI03B/#SPRUI03B_HTML/assembler-description.html
+" Maintainer: Wu, Zhenyu <[email protected]>
+" Last Change: 2025 Jan 08
+
+if exists("b:current_syntax")
+ finish
+endif
+
+syn case ignore
+
+" storage types
+syn match tiasmType "\.bits"
+syn match tiasmType "\.byte"
+syn match tiasmType "\.char"
+syn match tiasmType "\.cstring"
+syn match tiasmType "\.double"
+syn match tiasmType "\.field"
+syn match tiasmType "\.float"
+syn match tiasmType "\.half"
+syn match tiasmType "\.int"
+syn match tiasmType "\.long"
+syn match tiasmType "\.short"
+syn match tiasmType "\.string"
+syn match tiasmType "\.ubyte"
+syn match tiasmType "\.uchar"
+syn match tiasmType "\.uhalf"
+syn match tiasmType "\.uint"
+syn match tiasmType "\.ulong"
+syn match tiasmType "\.ushort"
+syn match tiasmType "\.uword"
+syn match tiasmType "\.word"
+
+syn match tiasmIdentifier "[a-z_][a-z0-9_]*"
+
+syn match tiasmDecimal "\<[1-9]\d*\>" display
+syn match tiasmOctal "\<0[0-7][0-7]\+\>\|\<[0-7]\+[oO]\>" display
+syn match tiasmHexadecimal
"\<0[xX][0-9a-fA-F]\+\>\|\<[0-9][0-9a-fA-F]*[hH]\>" display
+syn match tiasmBinary "\<0[bB][0-1]\+\>\|\<[01]\+[bB]\>" display
+
+syn match tiasmFloat "\<\d\+\.\d*\%(e[+-]\=\d\+\)\=\>" display
+syn match tiasmFloat "\<\d\%(e[+-]\=\d\+\)\>" display
+
+syn match tiasmCharacter "'.'\|''\|'[^']'"
+
+syn region tiasmString start="\"" end="\"" skip="\"\""
+
+syn match tiasmFunction "\$[a-zA-Z_][a-zA-Z_0-9]*\ze("
+
+syn keyword tiasmTodo contained TODO FIXME XXX NOTE
+syn region tiasmComment start=";" end="$" keepend
contains=tiasmTodo,@Spell
+syn match tiasmComment "^[*!].*" contains=tiasmTodo,@Spell
+syn match tiasmLabel "^[^ *!;][^ :]*"
+
+syn match tiasmInclude "\.include"
+syn match tiasmCond "\.if"
+syn match tiasmCond "\.else"
+syn match tiasmCond "\.endif"
+syn match tiasmMacro "\.macro"
+syn match tiasmMacro "\.endm"
+
+syn match tiasmDirective "\.[A-Za-z][0-9A-Za-z-_]*"
+
+syn case match
+
+hi def link tiasmLabel Label
+hi def link tiasmComment Comment
+hi def link tiasmTodo Todo
+hi def link tiasmDirective Statement
+
+hi def link tiasmInclude Include
+hi def link tiasmCond PreCondit
+hi def link tiasmMacro Macro
+
+if exists('g:tiasm_legacy_syntax_groups')
+ hi def link hexNumber Number
+ hi def link decNumber Number
+ hi def link octNumber Number
+ hi def link binNumber Number
+ hi def link tiasmHexadecimal hexNumber
+ hi def link tiasmDecimal decNumber
+ hi def link tiasmOctal octNumber
+ hi def link tiasmBinary binNumber
+else
+ hi def link tiasmHexadecimal Number
+ hi def link tiasmDecimal Number
+ hi def link tiasmOctal Number
+ hi def link tiasmBinary Number
+endif
+hi def link tiasmFloat Float
+
+hi def link tiasmString String
+hi def link tiasmStringEscape Special
+hi def link tiasmCharacter Character
+hi def link tiasmCharacterEscape Special
+
+hi def link tiasmIdentifier Identifier
+hi def link tiasmType Type
+hi def link tiasmFunction Function
+
+let b:current_syntax = "lineartiasm"
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index 8f2fb4fc9..6d64d9df6 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -676,7 +676,6 @@ def s:GetFilenameChecks(): dict<list<string>>
samba: ['smb.conf'],
sas: ['file.sas'],
sass: ['file.sass'],
- sather: ['file.sa'],
sbt: ['file.sbt'],
scala: ['file.scala'],
scheme: ['file.scm', 'file.ss', 'file.sld', 'file.stsg',
'any/local/share/supertux2/config', '.lips_repl_history'],
@@ -2331,6 +2330,22 @@ func Test_cmd_file()
filetype off
endfunc
+func Test_sa_file()
+ filetype on
+
+ call writefile([';* XXX-a.sa: XXX for TI C6000 DSP *;', '.no_mdep'],
'Xfile.sa')
+ split Xfile.sa
+ call assert_equal('tiasm', &filetype)
+ bwipe!
+
+ call writefile(['-- comment'], 'Xfile.sa')
+ split Xfile.sa
+ call assert_equal('sather', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
func Test_sig_file()
filetype on
diff --git a/src/version.c b/src/version.c
index 22efc7e6b..49a3523a2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 998,
/**/
997,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1tVbkh-00GPdc-Ip%40256bit.org.