summaryrefslogtreecommitdiffstats
path: root/runtime/autoload
diff options
context:
space:
mode:
authorJulien Marrec <julien.marrec@gmail.com>2023-11-25 15:30:46 +0100
committerChristian Brabandt <cb@256bit.org>2023-11-25 15:30:46 +0100
commit2e31065a650015892179e520038bf2083a9519b6 (patch)
tree11606cc1f0564adcb22bbbb52f5954aa6b049ee8 /runtime/autoload
parente214692718d6a997a0540fc688e1417564416f80 (diff)
patch 9.0.2128: runtime(swig): add syntax and filetype pluginsv9.0.2128
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>
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/dist/ft.vim18
1 files changed, 11 insertions, 7 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 2958f45d0a..53c56f6b52 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -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