From 9ef80352b6e8e18e002d3d2097c8bbd1d168fe40 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 15 Mar 2025 09:53:43 +0100 Subject: 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 --- runtime/doc/syntax.txt | 15 +++++++++++++++ runtime/ftplugin/cs.vim | 8 +++++--- 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 " Former Maintainer: Johannes Zellner -" 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 " Former Maintainers: Anduin Withers " Johannes Zellner -" 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 .. '