diff options
author | Christian Clason <c.clason@uni-graz.at> | 2024-07-09 19:15:22 +0200 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2024-07-10 09:31:48 +0200 |
commit | 136c11ca22881ac64c074070c7fda501e89b6bea (patch) | |
tree | 63a9764cb5b5862c639b8b4742de62a2197a18f3 | |
parent | 158ffd646d18eb26ca7e04e9cb9110305577b9c8 (diff) | |
download | rneovim-136c11ca22881ac64c074070c7fda501e89b6bea.tar.gz rneovim-136c11ca22881ac64c074070c7fda501e89b6bea.tar.bz2 rneovim-136c11ca22881ac64c074070c7fda501e89b6bea.zip |
vim-patch:9.1.0550: filetype: antlr4 files are not recognized
Problem: filetype: antlr4 files are not recognized
Solution: Detect '*.g4' as antlr4 filetype, include a simple antlr4
syntax and filetype plugin (Yinzuo Jiang)
closes: vim/vim#15191
https://github.com/vim/vim/commit/4a7a4a3675b6ad90a525524ba4684925df212325
Co-authored-by: Yinzuo Jiang <jiangyinzuo@foxmail.com>
-rw-r--r-- | runtime/ftplugin/antlr4.vim | 14 | ||||
-rw-r--r-- | runtime/lua/vim/filetype.lua | 1 | ||||
-rw-r--r-- | runtime/syntax/antlr4.vim | 30 |
3 files changed, 45 insertions, 0 deletions
diff --git a/runtime/ftplugin/antlr4.vim b/runtime/ftplugin/antlr4.vim new file mode 100644 index 0000000000..610d5284fb --- /dev/null +++ b/runtime/ftplugin/antlr4.vim @@ -0,0 +1,14 @@ +" Vim filetype plugin +" Language: ANTLR4, ANother Tool for Language Recognition v4 <www.antlr.org> +" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com> +" Last Change: 2024 July 09 + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// +setlocal commentstring=//\ %s + +let b:undo_ftplugin = 'setl com< cms<' diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 18fa1ed658..83892ac290 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -190,6 +190,7 @@ local extension = { aidl = 'aidl', aml = 'aml', run = 'ampl', + g4 = 'antlr4', scpt = 'applescript', ino = 'arduino', pde = 'arduino', diff --git a/runtime/syntax/antlr4.vim b/runtime/syntax/antlr4.vim new file mode 100644 index 0000000000..33cc865ccc --- /dev/null +++ b/runtime/syntax/antlr4.vim @@ -0,0 +1,30 @@ +" Vim syntax file +" Language: ANTLR4, ANother Tool for Language Recognition v4 <www.antlr.org> +" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com> +" Last Change: 2024 July 09 + +" quit when a syntax file was already loaded +if exists("b:current_syntax") + finish +endif + +" Keywords. See https://github.com/antlr/antlr4/blob/4.13.1/doc/lexicon.md +syn keyword antlr4Include import +" https://github.com/antlr/antlr4/blob/4.13.1/doc/options.md +" https://github.com/antlr/antlr4/blob/4.13.1/doc/grammars.md +syn keyword antlr4Structure fragment lexer parser grammar options channels tokens mode +syn keyword antlr4Statement returns locals +syn keyword antlr4Exceptions throws catch finally + +" Comments. +syn keyword antlr4Todo contained TODO FIXME XXX NOTE +syn region antlr4Comment start="//" end="$" contains=antlr4Todo,@Spell +syn region antlr4Comment start="/\*" end="\*/" contains=antlr4Todo,@Spell + +hi def link antlr4Include Include +hi def link antlr4Structure Structure +hi def link antlr4Statement Statement +hi def link antlr4Exceptions Structure +hi def link antlr4Comment Comment + +let b:current_syntax = "antlr4" |