diff --git a/runtime/ftplugin/racket.vim b/runtime/ftplugin/racket.vim index 52768d67f5..b8004a93af 100644 --- a/runtime/ftplugin/racket.vim +++ b/runtime/ftplugin/racket.vim @@ -3,7 +3,7 @@ " Maintainer: D. Ben Knoble " Previous Maintainer: Will Langstroth " URL: https://github.com/benknoble/vim-racket -" Last Change: 2024 Jun 01 +" Last Change: 2025 Aug 09 if exists("b:did_ftplugin") finish @@ -39,7 +39,7 @@ if !exists("no_plugin_maps") && !exists("no_racket_maps") " "press ENTER or type a command to continue" " We avoid the annoyance of having to hit enter by remapping K directly. function s:RacketDoc(word) abort - execute 'silent !raco docs --' shellescape(a:word) + execute 'silent !raco docs --' shellescape(a:word, v:true) redraw! endfunction nnoremap RacketDoc :call RacketDoc(expand('')) diff --git a/runtime/indent/racket.vim b/runtime/indent/racket.vim index 2bab3f3bed..d978970d59 100644 --- a/runtime/indent/racket.vim +++ b/runtime/indent/racket.vim @@ -3,7 +3,7 @@ " Maintainer: D. Ben Knoble " Previous Maintainer: Will Langstroth " URL: https://github.com/benknoble/vim-racket -" Last Change: 2024 Nov 12 +" Last Change: 2025 Aug 09 if exists("b:did_indent") finish @@ -16,6 +16,7 @@ if has('vim9script') endif setlocal lispwords+=module,module*,module+,parameterize,parameterize*,let-values,let*-values,letrec-values,local +setlocal lispwords+=splicing-let,splicing-letrec,splicing-let-values,splicing-letrec-values,splicing-local,splicing-parameterize setlocal lispwords+=define/contract setlocal lispwords+=λ setlocal lispwords+=with-handlers @@ -50,7 +51,7 @@ setlocal lispwords+=fresh,run,run*,project,conde,condu " loops setlocal lispwords+=for,for/list,for/fold,for*,for*/list,for*/fold,for/or,for/and,for*/or,for*/and -setlocal lispwords+=for/hash,for/hasheq,for/hasheqv,for/sum,for/flvector,for*/flvector,for/vector,for*/vector,for*/sum,for*/hash,for*/hasheq,for*/hasheqv +setlocal lispwords+=for/hash,for/hasheq,for/hasheqv,for/sum,for/flvector,for*/flvector,for/vector,for*/vector,for/fxvector,for*/fxvector,for*/sum,for*/hash,for*/hasheq,for*/hasheqv setlocal lispwords+=for/async setlocal lispwords+=for/set,for*/set setlocal lispwords+=for/first,for*/first diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim index dfebf547b1..4f5bac05b9 100644 --- a/runtime/syntax/python.vim +++ b/runtime/syntax/python.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Python " Maintainer: Zvezdan Petkovic -" Last Change: 2025 Jul 17 +" Last Change: 2025 Aug 10 " Credits: Neil Schemenauer " Dmitry Vasiliev " Rob B @@ -97,7 +97,8 @@ endif syn keyword pythonStatement False None True syn keyword pythonStatement as assert break continue del global syn keyword pythonStatement lambda nonlocal pass return with yield -syn keyword pythonStatement class def nextgroup=pythonFunction skipwhite +syn keyword pythonStatement class nextgroup=pythonClass skipwhite +syn keyword pythonStatement def nextgroup=pythonFunction skipwhite syn keyword pythonConditional elif else if syn keyword pythonRepeat for while syn keyword pythonOperator and in is not or @@ -123,20 +124,21 @@ syn match pythonDecoratorName "@\s*\h\%(\w\|\.\)*" display contains=pythonDeco " Single line multiplication. syn match pythonMatrixMultiply \ "\%(\w\|[])]\)\s*@" - \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue + \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonClass,pythonFunction,pythonDoctestValue \ transparent " Multiplication continued on the next line after backslash. syn match pythonMatrixMultiply \ "[^\\]\\\s*\n\%(\s*\.\.\.\s\)\=\s\+@" - \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue + \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonClass,pythonFunction,pythonDoctestValue \ transparent " Multiplication in a parenthesized expression over multiple lines with @ at " the start of each continued line; very similar to decorators and complex. syn match pythonMatrixMultiply \ "^\s*\%(\%(>>>\|\.\.\.\)\s\+\)\=\zs\%(\h\|\%(\h\|[[(]\).\{-}\%(\w\|[])]\)\)\s*\n\%(\s*\.\.\.\s\)\=\s\+@\%(.\{-}\n\%(\s*\.\.\.\s\)\=\s\+@\)*" - \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonFunction,pythonDoctestValue + \ contains=ALLBUT,pythonDecoratorName,pythonDecorator,pythonClass,pythonFunction,pythonDoctestValue \ transparent +syn match pythonClass "\h\w*" display contained syn match pythonFunction "\h\w*" display contained syn match pythonComment "#.*$" contains=pythonTodo,@Spell @@ -163,25 +165,25 @@ syn region pythonFString \ start=+\cF\z(['"]\)+ \ end="\z1" \ skip="\\\\\|\\\z1" - \ contains=pythonEscape,pythonUnicodeEscape,@Spell + \ contains=pythonFStringField,pythonFStringSkip,pythonEscape,pythonUnicodeEscape,@Spell syn region pythonFString \ matchgroup=pythonTripleQuotes \ start=+\cF\z('''\|"""\)+ \ end="\z1" \ keepend - \ contains=pythonEscape,pythonUnicodeEscape,pythonSpaceError,pythonDoctest,@Spell + \ contains=pythonFStringField,pythonFStringSkip,pythonEscape,pythonUnicodeEscape,pythonSpaceError,pythonDoctest,@Spell syn region pythonRawFString \ matchgroup=pythonQuotes \ start=+\c\%(FR\|RF\)\z(['"]\)+ \ end="\z1" \ skip="\\\\\|\\\z1" - \ contains=@Spell + \ contains=pythonFStringField,pythonFStringSkip,@Spell syn region pythonRawFString \ matchgroup=pythonTripleQuotes \ start=+\c\%(FR\|RF\)\z('''\|"""\)+ \ end="\z1" \ keepend - \ contains=pythonSpaceError,pythonDoctest,@Spell + \ contains=pythonFStringField,pythonFStringSkip,pythonSpaceError,pythonDoctest,@Spell " Bytes syn region pythonBytes @@ -207,6 +209,24 @@ syn region pythonRawBytes \ end="\z1" \ keepend +" F-string replacement fields +" +" - Matched parentheses, brackets and braces are ignored +" - A bare # is ignored to end of line +" - A bare = (surrounded by optional whitespace) enables debugging +" - A bare ! prefixes a conversion field +" - A bare : begins a format specification +" - Matched braces inside a format specification are ignored +" +syn region pythonFStringField + \ matchgroup=pythonFStringDelimiter + \ start=/{/ + \ skip=/([^)]*)\|\[[^]]*]\|{[^}]*}\|#.*$/ + \ end=/\%(\s*=\s*\)\=\%(!\a\)\=\%(:\%({[^}]*}\|[^}]*\)\+\)\=}/ + \ contained +" Doubled braces and Unicode escapes are not replacement fields +syn match pythonFStringSkip /{{\|\\N{/ transparent contained contains=NONE + syn match pythonEscape +\\[abfnrtv'"\\]+ contained syn match pythonEscape "\\\o\{1,3}" contained syn match pythonEscape "\\x\x\{2}" contained @@ -279,7 +299,7 @@ if !exists("python_no_builtin_highlight") syn keyword pythonBuiltin tuple type vars zip __import__ " avoid highlighting attributes as builtins syn match pythonAttribute /\.\h\w*/hs=s+1 - \ contains=ALLBUT,pythonBuiltin,pythonFunction,pythonAsync + \ contains=ALLBUT,pythonBuiltin,pythonClass,pythonFunction,pythonAsync \ transparent endif @@ -336,7 +356,7 @@ if !exists("python_no_doctest_highlight") if !exists("python_no_doctest_code_highlight") syn region pythonDoctest \ start="^\s*>>>\s" end="^\s*$" - \ contained contains=ALLBUT,pythonDoctest,pythonFunction,@Spell + \ contained contains=ALLBUT,pythonDoctest,pythonClass,pythonFunction,@Spell syn region pythonDoctestValue \ start=+^\s*\%(>>>\s\|\.\.\.\s\|"""\|'''\)\@!\S\++ end="$" \ contained @@ -360,6 +380,7 @@ hi def link pythonInclude Include hi def link pythonAsync Statement hi def link pythonDecorator Define hi def link pythonDecoratorName Function +hi def link pythonClass Structure hi def link pythonFunction Function hi def link pythonComment Comment hi def link pythonTodo Todo @@ -373,6 +394,7 @@ hi def link pythonQuotes String hi def link pythonTripleQuotes pythonQuotes hi def link pythonEscape Special hi def link pythonUnicodeEscape pythonEscape +hi def link pythonFStringDelimiter Special if !exists("python_no_number_highlight") hi def link pythonNumber Number endif diff --git a/runtime/syntax/racket.vim b/runtime/syntax/racket.vim index 7dcca6082c..e9b70a1b0c 100644 --- a/runtime/syntax/racket.vim +++ b/runtime/syntax/racket.vim @@ -4,7 +4,7 @@ " Previous Maintainer: Will Langstroth " URL: https://github.com/benknoble/vim-racket " Description: Contains all of the keywords in #lang racket -" Last Change: 2024 Apr 14 +" Last Change: 2025 Aug 09 " Initializing: if exists("b:current_syntax") @@ -534,21 +534,21 @@ syntax match racketContainedNumberError "\<#[ei]#[ei]" syntax match racketContainedNumberError "\<#[xdob]#[xdob]" " start with the simpler sorts -syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdleft][-+]\?\d\+#*\)\?\>" contains=racketContainedNumberError syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\d\+/\d\+\>" contains=racketContainedNumberError syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\d\+/\d\+[-+]\d\+\(/\d\+\)\?i\>" contains=racketContainedNumberError " different possible ways of expressing complex values -syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?i\>" contains=racketContainedNumberError -syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?[-+]\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?i\>" contains=racketContainedNumberError -syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\(inf\|nan\)\.[0f][-+]\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?i\>" contains=racketContainedNumberError -syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?[-+]\(inf\|nan\)\.[0f]i\>" contains=racketContainedNumberError -syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?@[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?\>" contains=racketContainedNumberError -syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\(inf\|nan\)\.[0f]@[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?\>" contains=racketContainedNumberError -syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?@[-+]\(inf\|nan\)\.[0f]\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdleft][-+]\?\d\+#*\)\?i\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdleft][-+]\?\d\+#*\)\?[-+]\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?i\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\(inf\|nan\)\.[0f][-+]\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdleft][-+]\?\d\+#*\)\?i\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdleft][-+]\?\d\+#*\)\?[-+]\(inf\|nan\)\.[0f]i\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdleft][-+]\?\d\+#*\)\?@[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdlef][-+]\?\d\+#*\)\?\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\(inf\|nan\)\.[0f]@[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdleft][-+]\?\d\+#*\)\?\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[dobie]\)\{0,2}[-+]\?\(\d\+\|\d\+#*\.\|\d*\.\d\+\)#*\(/\d\+#*\)\?\([sdleft][-+]\?\d\+#*\)\?@[-+]\(inf\|nan\)\.[0f]\>" contains=racketContainedNumberError " hex versions of the above (separate because of the different possible exponent markers) -syntax match racketNumber "\<\(#x\|#[ei]#x\|#x#[ei]\)[-+]\?\(\x\+\|\x\+#*\.\|\x*\.\x\+\)#*\(/\x\+#*\)\?\([sl][-+]\?\x\+#*\)\?\>" +syntax match racketNumber "\<\(#x\|#[ei]#x\|#x#[ei]\)[-+]\?\(\x\+\|\x\+#*\.\|\x*\.\x\+\)#*\(/\x\+#*\)\?\([slt][-+]\?\x\+#*\)\?\>" syntax match racketNumber "\<\(#x\|#[ei]#x\|#x#[ei]\)[-+]\?\x\+/\x\+\>" syntax match racketNumber "\<\(#x\|#[ei]#x\|#x#[ei]\)[-+]\?\x\+/\x\+[-+]\x\+\(/\x\+\)\?i\>" @@ -561,9 +561,9 @@ syntax match racketNumber "\<\(#x\|#[ei]#x\|#x#[ei]\)[-+]\(inf\|nan\)\.[0f]@[ syntax match racketNumber "\<\(#x\|#[ei]#x\|#x#[ei]\)[-+]\?\(\x\+\|\x\+#*\.\|\x*\.\x\+\)#*\(/\x\+#*\)\?\([sl][-+]\?\x\+#*\)\?@[-+]\(inf\|nan\)\.[0f]\>" " these work for any radix -syntax match racketNumber "\<\(#[xdobie]\)\{0,2}[-+]\(inf\|nan\)\.[0f]i\?\>" contains=racketContainedNumberError -syntax match racketNumber "\<\(#[xdobie]\)\{0,2}[-+]\(inf\|nan\)\.[0f][-+]\(inf\|nan\)\.[0f]i\>" contains=racketContainedNumberError -syntax match racketNumber "\<\(#[xdobie]\)\{0,2}[-+]\(inf\|nan\)\.[0f]@[-+]\(inf\|nan\)\.[0f]\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[xdobie]\)\{0,2}[-+]\(inf\|nan\)\.[0ft]i\?\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[xdobie]\)\{0,2}[-+]\(inf\|nan\)\.[0ft][-+]\(inf\|nan\)\.[0f]i\>" contains=racketContainedNumberError +syntax match racketNumber "\<\(#[xdobie]\)\{0,2}[-+]\(inf\|nan\)\.[0ft]@[-+]\(inf\|nan\)\.[0f]\>" contains=racketContainedNumberError syntax keyword racketBoolean #t #f #true #false #T #F