0
0
mirror of https://github.com/vim/vim.git synced 2025-10-17 07:44:28 -04:00

patch 9.0.2128: runtime(swig): add syntax and filetype plugins

Add syntax and filetype plugins for SWIG (Simplified Wrapper Interface
Generator) description files.

The default syntax for .i files highlights comments in a reverse
color scheme which doesn't look well.  This syntax builds
on vim's c++ syntax by adding highlighting for common swig
directives and user defined directives.  For an alternative
syntax, see vimscript #1247 (which I found after writing this).

closes: #13562

Co-authored-by: Matěj Cepl <mcepl@cepl.eu>
Co-authored-by: Julien Marrec <julien.marrec@gmail.com>
Signed-off-by: Julien Marrec <julien.marrec@gmail.com>
Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Julien Marrec
2023-11-25 15:30:46 +01:00
committed by Christian Brabandt
parent e214692718
commit 2e31065a65
7 changed files with 163 additions and 9 deletions

View File

@@ -590,23 +590,27 @@ export def FTprogress_cweb()
endif
enddef
export def FTprogress_asm()
# These include the leading '%' sign
var ft_swig_keywords = '^\s*%\%(addmethods\|apply\|beginfile\|clear\|constant\|define\|echo\|enddef\|endoffile\|extend\|feature\|fragment\|ignore\|import\|importfile\|include\|includefile\|inline\|insert\|keyword\|module\|name\|namewarn\|native\|newobject\|parms\|pragma\|rename\|template\|typedef\|typemap\|types\|varargs\|warn\)'
# This is the start/end of a block that is copied literally to the processor file (C/C++)
var ft_swig_verbatim_block_start = '^\s*%{'
export def FTi()
if exists("g:filetype_i")
exe "setf " .. g:filetype_i
return
endif
# This function checks for an assembly comment the first ten lines.
# This function checks for an assembly comment or a SWIG keyword or verbatim block in the first 50 lines.
# If not found, assume Progress.
var lnum = 1
while lnum <= 10 && lnum < line('$')
while lnum <= 50 && lnum < line('$')
var line = getline(lnum)
if line =~ '^\s*;' || line =~ '^\*'
FTasm()
return
elseif line !~ '^\s*$' || line =~ '^/\*'
# Not an empty line: Doesn't look like valid assembly code.
# Or it looks like a Progress /* comment
break
elseif line =~ ft_swig_keywords || line =~ ft_swig_verbatim_block_start
setf swig
return
endif
lnum += 1
endwhile