Add razor syntax, fixes #450

This commit is contained in:
Adam Stankiewicz
2020-03-02 01:03:15 +01:00
parent 16774887a3
commit e558a218c6
6 changed files with 110 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them. > One to rule them all, one to find them, one to bring them all and in the darkness bind them.
- It **won't affect your startup time**, as scripts are loaded only on demand\*. - It **won't affect your startup time**, as scripts are loaded only on demand\*.
- It **installs and updates 120+ times faster** than the <!--Package Count-->146<!--/Package Count--> packages it consists of. - It **installs and updates 120+ times faster** than the <!--Package Count-->147<!--/Package Count--> packages it consists of.
- Solid syntax and indentation support (other features skipped). Only the best language packs. - Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support). - All unnecessary files are ignored (like enormous documentation from php support).
- No support for esoteric languages, only most popular ones (modern too, like `slim`). - No support for esoteric languages, only most popular ones (modern too, like `slim`).
@@ -149,6 +149,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [racket](https://github.com/wlangstroth/vim-racket) (syntax, indent, ftplugin) - [racket](https://github.com/wlangstroth/vim-racket) (syntax, indent, ftplugin)
- [ragel](https://github.com/jneen/ragel.vim) (syntax) - [ragel](https://github.com/jneen/ragel.vim) (syntax)
- [raml](https://github.com/IN3D/vim-raml) (syntax, ftplugin) - [raml](https://github.com/IN3D/vim-raml) (syntax, ftplugin)
- [razor](https://github.com/adamclerk/vim-razor) (syntax, indent, ftplugin)
- [reason](https://github.com/reasonml-editor/vim-reason-plus) (syntax, indent) - [reason](https://github.com/reasonml-editor/vim-reason-plus) (syntax, indent)
- [rspec](https://github.com/keith/rspec.vim) (syntax) - [rspec](https://github.com/keith/rspec.vim) (syntax)
- [rst](https://github.com/marshallward/vim-restructuredtext) (syntax, indent, autoload, ftplugin) - [rst](https://github.com/marshallward/vim-restructuredtext) (syntax, indent, autoload, ftplugin)

1
build
View File

@@ -267,6 +267,7 @@ PACKS="
racket:wlangstroth/vim-racket racket:wlangstroth/vim-racket
ragel:jneen/ragel.vim ragel:jneen/ragel.vim
raml:IN3D/vim-raml raml:IN3D/vim-raml
razor:adamclerk/vim-razor
reason:reasonml-editor/vim-reason-plus reason:reasonml-editor/vim-reason-plus
rspec:keith/rspec.vim rspec:keith/rspec.vim
rst:marshallward/vim-restructuredtext rst:marshallward/vim-restructuredtext

View File

@@ -1174,6 +1174,13 @@ au BufRead,BufNewFile *.raml set ft=raml
augroup end augroup end
endif endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'razor') == -1
augroup filetypedetect
" razor, from razor.vim in adamclerk/vim-razor
autocmd BufNewFile,BufRead *.cshtml setf razor
augroup end
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'reason') == -1 if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'reason') == -1
augroup filetypedetect augroup filetypedetect
" reason, from reason.vim in reasonml-editor/vim-reason-plus " reason, from reason.vim in reasonml-editor/vim-reason-plus

30
ftplugin/razor.vim Normal file
View File

@@ -0,0 +1,30 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'razor') == -1
" Vim filetype plugin
" Language: LessCSS
" Author: Tim Pope <vimNOSPAM@tpope.org>
" Maintainer: Leonard Ehrenfried <leonard.ehrenfried@web.de>
" Last Change: 2011 Sep 30
" Only do this when not done yet for this buffer
:UltiSnipsAddFiletypes razor.html
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
"let b:undo_ftplugin = "setl cms< def< inc< inex< ofu< sua<"
"setlocal iskeyword+=-
"setlocal commentstring=//\ %s
"setlocal define=^\\s*\\%(@mixin\\\|=\\)
"setlocal includeexpr=substitute(v:fname,'\\%(.*/\\\|^\\)\\zs','_','')
"setlocal omnifunc=csscomplete#CompleteCSS
"setlocal suffixesadd=.less
"let &l:include = '^\s*@import\s\+\%(url(\)\=["'']\='
" vim:set sw=2:
endif

14
indent/razor.vim Normal file
View File

@@ -0,0 +1,14 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'razor') == -1
" Vim indent file
" Language: Razor
" Maintainer: Adam Clark <adamclerk@gmail.com>
" Last Change: 2013 Jan 24
if exists("b:did_indent")
finish
endif
runtime! indent/html.vim
runtime! indent/javscript.vim
endif

56
syntax/razor.vim Normal file
View File

@@ -0,0 +1,56 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'razor') == -1
if exists("b:current_syntax")
finish
endif
runtime! syntax/html.vim
"razor
syn cluster rBlocks add=rCodeBlock,rCodeLine,rComment,rInherits,rUsing
syn match rCodeLine "@[a-zA-Z0-9_\.()]*" containedin=ALLBUT,@rBlocks
syn region rCodeBlock start="@{" end="}" contains=@rcsAll containedin=ALLBUT,@rBlocks keepend
syn region rComment start="@\*" end="\*@" contains=rcsComment containedin=ALLBUT,@rBlocks keepend
"not recursive for namespaces with generic types
syn region rInherits start="^@inherits" end="$" containedin=ALLBUT,@rBlocks
syn match rNamespacedGenericType "\s\+\w\+\(\.\w\+\)*\(<\w\+\(\.\w\+\)*>\)\?" containedin=rInherits contained
syn region rUsing start="^@using " end="$" containedin=ALLBUT,@rBlocks
syn match rNamespace "\s\+\w\+\(\.\w\+\)*" containedin=rUsing contained
syn match rCodeInCodeBlock "[a-zA-Z]\+" containedin=rCodeBlock contained
"cs
syn keyword rcsType contained bool byte char decimal double float int
syn keyword rcsType contained long object sbyte short string uint ulong
syn keyword rcsType contained ushort void var
syn keyword rcsRepeat contained break continue do for foreach goto return
syn keyword rcsRepeat contained while yield
syn keyword rcsConditional contained if else switch
syn keyword rcsLabel contained case default
syn region rcsComment start="/\*" end="\*/" contained
syn match rcsComment "//.*$" contained
syn cluster rcsAll add=rcsType,rcsRepeat,rcsConditional,rcsLabel,rcsComment
"Highlighting
"cs
hi def link rcsType Type
hi def link rcsRepeat Repeat
hi def link rcsConditional Conditional
hi def link rcsLabel Label
hi def link rcsComment Comment
"razor
hi def link rCodeLine Special
hi def link rComment Comment
hi def link rInherits Preproc
hi def link rNamespacedGenericType Type
hi def link rUsing Preproc
hi def link rNamespace Type
let b:current_syntax = "razor"
endif