diff options
author | Christian Clason <c.clason@uni-graz.at> | 2024-12-29 15:33:40 +0100 |
---|---|---|
committer | Christian Clason <ch.clason+github@icloud.com> | 2024-12-29 16:15:00 +0100 |
commit | 0e880b5612b0dece2863c70ee608971726ec5f2c (patch) | |
tree | f303925cfc09dddafc1a02f030fe504309b03f2b | |
parent | 493b6899ee898ec43217a8ae270b24bcc3b47281 (diff) | |
download | rneovim-0e880b5612b0dece2863c70ee608971726ec5f2c.tar.gz rneovim-0e880b5612b0dece2863c70ee608971726ec5f2c.tar.bz2 rneovim-0e880b5612b0dece2863c70ee608971726ec5f2c.zip |
vim-patch:9.1.0972: filetype: TI linker map files are not recognized
Problem: filetype: TI linker map files are not recognized
Solution: detect TI linker map files as lnkmap filetype
(Wu, Zhenyu)
References:
https://downloads.ti.com/docs/esd/SPRUI03A/Content/SPRUI03A_HTML/linker_description.html
closes: vim/vim#16324
https://github.com/vim/vim/commit/5113831d16c05f3a8b47da0c6f95a641d5fc7b2e
Co-authored-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
-rw-r--r-- | runtime/ftplugin/lnkmap.vim | 16 | ||||
-rw-r--r-- | runtime/lua/vim/filetype.lua | 2 | ||||
-rw-r--r-- | runtime/syntax/lnkmap.vim | 35 | ||||
-rw-r--r-- | test/old/testdir/test_filetype.vim | 19 |
4 files changed, 70 insertions, 2 deletions
diff --git a/runtime/ftplugin/lnkmap.vim b/runtime/ftplugin/lnkmap.vim new file mode 100644 index 0000000000..46fb070e71 --- /dev/null +++ b/runtime/ftplugin/lnkmap.vim @@ -0,0 +1,16 @@ +" Vim filetype plugin file +" Language: TI Linker map +" Document: https://downloads.ti.com/docs/esd/SPRUI03A/Content/SPRUI03A_HTML/linker_description.html +" Maintainer: Wu, Zhenyu <wuzhenyu@ustc.edu> +" Last Change: 2024 Dec 25 + +if exists("b:did_ftplugin") + finish +endif + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +let b:undo_ftplugin = "setl iskeyword<" + +setl iskeyword+=. diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index f267e5ef6f..ef77a560d8 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -736,7 +736,7 @@ local extension = { mk = detect.make, mak = detect.make, page = 'mallard', - map = 'map', + map = detect_line1('^%*+$', 'lnkmap', 'map'), mws = 'maple', mpl = 'maple', mv = 'maple', diff --git a/runtime/syntax/lnkmap.vim b/runtime/syntax/lnkmap.vim new file mode 100644 index 0000000000..a1d109ef0d --- /dev/null +++ b/runtime/syntax/lnkmap.vim @@ -0,0 +1,35 @@ +" Vim syntax file +" Language: TI Linker map +" Document: https://downloads.ti.com/docs/esd/SPRUI03A/Content/SPRUI03A_HTML/linker_description.html +" Maintainer: Wu, Zhenyu <wuzhenyu@ustc.edu> +" Last Change: 2024 Dec 25 + +if exists("b:current_syntax") + finish +endif + +syn match lnkmapTime ">> .*$" +syn region lnkmapHeadline start="^\*\+$" end="^\*\+$" +syn match lnkmapHeadline "^[A-Z][-A-Z0-9 ']*\ze\%(:\|$\)" +syn match lnkmapSectionDelim "^=\+$" +syn match lnkmapTableDelim "\%(^\|\s\)\zs---*\ze\%($\|\s\)" +syn match lnkmapNumber "\%(^\|\s\)\zs[0-9a-f]\+\ze\%($\|\s\)" +syn match lnkmapSections '\<\.\k\+\>' +syn match lnkmapFile '[^ =]\+\%(\.\S\+\)\+\>' +syn match lnkmapLibFile '[^ =]\+\.lib\>' +syn match lnkmapAttrib '\<[RWIX]\+\>' +syn match lnkmapAttrib '\s\zs--HOLE--\ze\%\(\s\|$\)' +syn keyword lnkmapAttrib UNINITIALIZED + + +hi def link lnkmapTime Comment +hi def link lnkmapHeadline Title +hi def link lnkmapSectionDelim PreProc +hi def link lnkmapTableDelim PreProc +hi def link lnkmapNumber Number +hi def link lnkmapSections Macro +hi def link lnkmapFile String +hi def link lnkmapLibFile Special +hi def link lnkmapAttrib Type + +let b:current_syntax = "lnkmap" diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 88dcef423a..75092f8ece 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -459,7 +459,6 @@ func s:GetFilenameChecks() abort \ 'mallard': ['file.page'], "\ 'man': ['file.man'], \ 'manconf': ['/etc/man.conf', 'man.config', 'any/etc/man.conf'], - \ 'map': ['file.map'], \ 'maple': ['file.mv', 'file.mpl', 'file.mws'], \ 'markdown': ['file.markdown', 'file.mdown', 'file.mkd', 'file.mkdn', 'file.mdwn', 'file.md'], \ 'masm': ['file.masm'], @@ -2765,6 +2764,24 @@ func Test_make_file() filetype off endfunc +func Test_map_file() + filetype on + + " TI linker map file + call writefile(['******************************************************************************', ' TMS320C6x Linker Unix v7.4.24 ', '******************************************************************************'], 'Xfile.map', 'D') + split Xfile.map + call assert_equal('lnkmap', &filetype) + bwipe! + + " TI linker map file + call writefile(['MAP', 'NAME "local-demo"', 'END'], 'Xfile.map', 'D') + split Xfile.map + call assert_equal('map', &filetype) + bwipe! + + filetype off +endfunc + func Test_org_file() filetype on |