diff options
author | Christian Clason <c.clason@uni-graz.at> | 2025-03-15 09:53:43 +0100 |
---|---|---|
committer | Christian Clason <ch.clason+github@icloud.com> | 2025-03-15 10:26:56 +0100 |
commit | 9ef80352b6e8e18e002d3d2097c8bbd1d168fe40 (patch) | |
tree | 96f33613f9b4e2881eb889fb033ba02d89af4fc3 | |
parent | 1b1af8aae83e86a6d313d20682d9e02562e94edb (diff) | |
download | rneovim-9ef80352b6e8e18e002d3d2097c8bbd1d168fe40.tar.gz rneovim-9ef80352b6e8e18e002d3d2097c8bbd1d168fe40.tar.bz2 rneovim-9ef80352b6e8e18e002d3d2097c8bbd1d168fe40.zip |
vim-patch:96395e1: runtime(cs): Update C# runtime files
closes: vim/vim#16884
https://github.com/vim/vim/commit/96395e15125502e6c29bc93c58d688a2bdc31300
Co-authored-by: Nick Jensen <nickspoon@gmail.com>
-rw-r--r-- | runtime/doc/syntax.txt | 15 | ||||
-rw-r--r-- | runtime/ftplugin/cs.vim | 8 | ||||
-rw-r--r-- | runtime/syntax/cs.vim | 33 |
3 files changed, 51 insertions, 5 deletions
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 00486a49db..ae9dc67256 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -811,6 +811,21 @@ doesn't work for you, or you don't edit Progress at all, use this in your startup vimrc: > :let filetype_w = "cweb" +CSHARP *cs.vim* *ft-cs-syntax* + +C# raw string literals may use any number of quote marks to encapsulate the +block, and raw interpolated string literals may use any number of braces to +encapsulate the interpolation, e.g. > + + $$$""""Hello {{{name}}}"""" +< +By default, Vim highlights 3-8 quote marks, and 1-8 interpolation braces. +The maximum numbers of quotes and braces recognized can configured using the +following variables: + + Variable Default ~ + g:cs_raw_string_quote_count 8 + g:cs_raw_string_interpolation_brace_count 8 DART *dart.vim* *ft-dart-syntax* diff --git a/runtime/ftplugin/cs.vim b/runtime/ftplugin/cs.vim index ada71315e1..d40fe43ebc 100644 --- a/runtime/ftplugin/cs.vim +++ b/runtime/ftplugin/cs.vim @@ -2,8 +2,7 @@ " Language: C# " Maintainer: Nick Jensen <nickspoon@gmail.com> " Former Maintainer: Johannes Zellner <johannes@zellner.org> -" Last Change: 2022-11-16 -" 2024 Jan 14 by Vim Project (browsefilter) +" Last Change: 2025-03-14 " License: Vim (see :h license) " Repository: https://github.com/nickspoons/vim-cs @@ -21,8 +20,11 @@ setlocal formatoptions-=t formatoptions+=croql " Set 'comments' to format dashed lists in comments. setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,:// +setlocal commentstring=//\ %s -let b:undo_ftplugin = 'setl com< fo<' +setlocal cinoptions=J1 + +let b:undo_ftplugin = 'setl com< fo< cino<' if exists('loaded_matchit') && !exists('b:match_words') " #if/#endif support included by default diff --git a/runtime/syntax/cs.vim b/runtime/syntax/cs.vim index 104470ac4b..3ae6bfca8d 100644 --- a/runtime/syntax/cs.vim +++ b/runtime/syntax/cs.vim @@ -3,7 +3,7 @@ " Maintainer: Nick Jensen <nickspoon@gmail.com> " Former Maintainers: Anduin Withers <awithers@anduin.com> " Johannes Zellner <johannes@zellner.org> -" Last Change: 2022-11-16 +" Last Change: 2025-03-14 " Filenames: *.cs " License: Vim (see :h license) " Repository: https://github.com/nickspoons/vim-cs @@ -190,6 +190,18 @@ syn match csUnicodeNumber +\\U00\x\{6}+ contained contains=csUnicodeSpecifier di syn match csUnicodeSpecifier +\\[uUx]+ contained display syn region csString matchgroup=csQuote start=+"+ end=+"\%(u8\)\=+ end=+$+ extend contains=csSpecialChar,csSpecialError,csUnicodeNumber,@Spell + +for s:i in range(3, get(g:, "cs_raw_string_quote_count", 8)) + exe 'syn region csRawString' .. s:i .. ' matchgroup=csQuote start=+\z("\{' .. s:i .. '}\)+ end=+\z1+ oneline nextgroup=csRawStringError' .. s:i + exe 'syn region csRawString' .. s:i .. ' matchgroup=csQuote start=+\z("\{' .. s:i .. '}\)\s*$+ end=+^\s*\z1+ nextgroup=csRawStringError' .. s:i .. ' contains=csRawStringError' .. s:i + exe 'syn match csRawStringError' .. s:i .. ' /\%("\{' .. s:i .. '}\)\@' .. s:i .. '<="\+/ contained' + exe 'syn match csRawStringError' .. s:i .. ' /\S.\{-}\s*"\{' .. s:i .. '}"\@!/ contained' + + exe 'hi def link csRawString' .. s:i .. ' csString' + exe 'hi def link csRawStringError' .. s:i .. ' Error' +endfor +unlet s:i + syn match csCharacter "'[^']*'" contains=csSpecialChar,csSpecialCharError,csUnicodeNumber display syn match csCharacter "'\\''" contains=csSpecialChar display syn match csCharacter "'[^\\]'" display @@ -217,11 +229,26 @@ syn match csInterpolationAlignDel +,+ contained display syn match csInterpolationFormatDel +:+ contained display syn region csVerbatimString matchgroup=csQuote start=+@"+ end=+"\%(u8\)\=+ skip=+""+ extend contains=csVerbatimQuote,@Spell + +" Interpolated raw string literals +for s:i in range(1, get(g:, "cs_raw_string_interpolation_brace_count", 8)) + exe 'syn region csInterpolatedRawString' .. s:i .. ' matchgroup=csQuote start=+$\{' .. s:i .. '}\z("""\+\)+ end=+\z1+ extend contains=csInterpolation' .. s:i .. ',csInterpolationDelimiterError' .. s:i .. ',@Spell' + exe 'syn match csInterpolationDelimiterError' .. s:i .. ' "}\{' .. s:i .. '}" contained' + exe 'syn match csInterpolationDelimiterError' .. s:i .. ' "{\{' .. 2 * s:i .. ',}" contained' + exe 'syn match csInterpolationDelimiterError' .. s:i .. ' "}\{' .. 2 * s:i .. ',}" contained' + exe 'syn region csInterpolation' .. s:i .. ' matchgroup=csInterpolationDelimiter start=+\%({\{' .. s:i .. '}\)\@' .. s:i .. '<!{\{' .. s:i .. '}{\@!+ end=+}\@<!}\{' .. s:i .. '}\%(}\{' .. s:i .. '}\)\@!+' .. + \ ' keepend contained contains=@csAll,csBraced,csBracketed,csInterpolationAlign,csInterpolationFormat,csInterpolationDelimiterError' .. s:i + + exe 'hi def link csInterpolationDelimiterError' .. s:i .. ' Error' + exe 'hi def link csInterpolatedRawString' .. s:i .. ' csRawString' +endfor +unlet s:i + syn match csVerbatimQuote +""+ contained syn region csInterVerbString matchgroup=csQuote start=+$@"+ start=+@$"+ end=+"\%(u8\)\=+ skip=+""+ extend contains=csInterpolation,csEscapedInterpolation,csSpecialChar,csSpecialError,csUnicodeNumber,csVerbatimQuote,@Spell -syn cluster csString contains=csString,csInterpolatedString,csVerbatimString,csInterVerbString +syn cluster csString contains=csString,csInterpolatedString,csVerbatimString,csInterVerbString,csRawString syn cluster csLiteral contains=csBoolean,@csNumber,csCharacter,@csString,csNull @@ -282,6 +309,8 @@ hi def link csLogicSymbols Operator hi def link csSpecialError Error hi def link csSpecialCharError Error hi def link csString String +hi def link csRawString csString +hi def link csRawStringError Error hi def link csQuote String hi def link csInterpolatedString String hi def link csVerbatimString String |