Mercurial > vim
changeset 35300:062a50be417d v9.1.0453
patch 9.1.0453: filetype: rasi files are not recognized
Commit: https://github.com/vim/vim/commit/280e5b13ca568ed592a894140bf1ac74356f4b33
Author: Pierrick Guillaume <pierguill@gmail.com>
Date: Fri May 31 12:00:49 2024 +0200
patch 9.1.0453: filetype: rasi files are not recognized
Problem: filetype: rasi files are not recognized
Solution: regonize '*.rasi' files as rasi filetype,
include a filetype and syntax plugin
(Pierrick Guillaume)
ported from: https://github.com/Fymyte/rasi.vim
closes: #14821
Signed-off-by: Pierrick Guillaume <pierguill@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 31 May 2024 12:15:05 +0200 |
parents | 2cc507d1afa2 |
children | d3014dce4053 |
files | .github/MAINTAINERS runtime/doc/syntax.txt runtime/filetype.vim runtime/ftplugin/rasi.vim runtime/syntax/rasi.vim src/testdir/test_filetype.vim src/version.c |
diffstat | 7 files changed, 340 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/.github/MAINTAINERS +++ b/.github/MAINTAINERS @@ -209,6 +209,7 @@ runtime/ftplugin/python.vim @tpict runtime/ftplugin/qb64.vim @dkearns runtime/ftplugin/qml.vim @ChaseKnowlden runtime/ftplugin/racket.vim @benknoble +runtime/ftplugin/rasi.vim @fymyte runtime/ftplugin/readline.vim @dkearns runtime/ftplugin/rescript.vim @ribru17 runtime/ftplugin/routeros.vim @zainin @@ -479,6 +480,7 @@ runtime/syntax/racket.vim @benknoble runtime/syntax/raml.vim @in3d runtime/syntax/rapid.vim @KnoP-01 runtime/syntax/ratpoison.vim @trapd00r +runtime/syntax/rasi.vim @fymyte runtime/syntax/rc.vim @chrisbra runtime/syntax/rcs.vim @hdima runtime/syntax/rebol.vim @mrdubya
--- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 9.1. Last change: 2024 May 24 +*syntax.txt* For Vim version 9.1. Last change: 2024 May 31 VIM REFERENCE MANUAL by Bram Moolenaar @@ -3048,6 +3048,13 @@ To highlight R code in knitr chunk heade let rrst_syn_hl_chunk = 1 +RASI *rasi.vim* *ft-rasi-syntax* + +Rasi stands for Rofi Advanced Style Information. It is used by the program +|rofi| to style the rendering of the search window. The language is heavily +inspired by CSS stylesheet. Files with the following extensions are recognized +as rasi files: .rasi. + READLINE *readline.vim* *ft-readline-syntax* The readline library is primarily used by the BASH shell, which adds quite a
--- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: The Vim Project <https://github.com/vim/vim> -" Last Change: 2024 May 23 +" Last Change: 2024 May 31 " Former Maintainer: Bram Moolenaar <Bram@vim.org> " Listen very carefully, I will say this only once @@ -3150,6 +3150,9 @@ au BufNewFile,BufRead yarn.lock setf y " Zathurarc au BufNewFile,BufRead zathurarc setf zathurarc +" Rofi stylesheet +au BufNewFile,BufRead *.rasi setf rasi + " If the GUI is already running, may still need to install the Syntax menu. " Don't do it when the 'M' flag is included in 'guioptions'. if has("menu") && has("gui_running")
new file mode 100644 --- /dev/null +++ b/runtime/ftplugin/rasi.vim @@ -0,0 +1,25 @@ +" Vim filetype plugin file +" Language: RASI +" Maintainer: Pierrick Guillaume <pierguill@gmail.com> +" Last Change: 2024 May 21 + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +let b:undo_ftplugin = "setl com< cms< isk< inc<" + +setlocal comments=s1:/*,mb:*,ex:*/ +setlocal commentstring=//\ %s +setlocal iskeyword+=- + +let &l:include = '^\s*@import\s\+\%(url(\)\=' + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: ts=8
new file mode 100644 --- /dev/null +++ b/runtime/syntax/rasi.vim @@ -0,0 +1,298 @@ +" Vim syntax file +" Language: rasi (Rofi Advanced Style Information) +" Maintainer: Pierrick Guillaume <pierguill@gmail.com> +" Last Change: 2024 May 21 +" +" Syntax support for rasi config file + +" This file is based on syntax defined in rofi-theme man page +" https://man.archlinux.org/man/community/rofi/rofi-theme.5.en + +if exists('b:current_syntax') + finish +endif +let b:current_syntax = 'rasi' + +" String {{{ +syn region rasiString start=+"+ skip=+\\"+ end=+"+ oneline contained +syn match rasiCharacter +L\='[^\\]'+ contained + +syn cluster rasiPropertyVals add=rasiString,rasiCharacter +" }}} + +" Integer/Real {{{ +syn match rasiNumber display contained '[+-]\?\d\+\(\.\d\+\)\?' + +syn cluster rasiPropertyVals add=rasiNumber +" }}} + +" Boolean {{{ +syn keyword rasiBool contained true false + +syn cluster rasiPropertyVals add=rasiBool +" }}} + +" Image {{{ +syn match rasiInvImage display contained 'url([^)]*)' +syn keyword rasiImageK contained url linear-gradient + +syn match rasiImage display contained transparent 'url(\s*"\([^"]\|\\"\)\+"\(\s*,\s*\(none\|both\|width\|height\)\)\?\s*)' contains=rasiImageScale,rasiString,rasiImageK +syn keyword rasiImageScale contained none both width height + +syn match rasiImage display contained transparent 'linear-gradient(\s*\(\(top\|left\|right\|bottom\)\s*,\s*\)\?[^,)]\+\s*\(,\s*[^,)]\+\s*\)\+)' contains=rasiImageDirection,@rasiColors,rasiImageK +syn keyword rasiImageDirection contained top left right bottom + +syn match rasiImage display contained transparent 'linear-gradient(\s*\d\+\(rad\|grad\|deg\)\s*,\s*[^,)]\+\s*\(,\s*[^,)]\+\s*\)\+)' contains=rasiImageUnit,@rasiColor,@rasiInvColor,rasiNumber,rasiImageK +syn match rasiImageUnit display contained '\(rad\|grad\|deg\)\>' + +syn cluster rasiPropertyVals add=rasiInvImage,rasiImage +" }}} + +" Reference {{{ +syn match rasiReference display contained '@[a-zA-Z0-9-]\+' + +syn keyword rasiVarReferenceK contained var + +syn match rasiInvVarReference display contained 'var([^)]*)' +syn match rasiVarReference display contained transparent 'var(\s*[a-zA-Z0-9-]\+\s*,\s*\(\a\+\s*([^)]*)\)\?[^),]*)' contains=rasiVarReferenceK,rasiPropertyIdRef,@rasiPropertyVals +syn match rasiPropertyIdRef display contained '\a[a-zA-Z0-9-]*' + +syn cluster rasiPropertyVals add=rasiReference,rasiInvVarReference,rasiVarReference +" }}} + +" Env variable {{{ +syn match rasiInvEnv display contained '${[^}]*}' +syn match rasiEnv display contained '${\w\+}'hs=s+2,he=e-1 + +syn keyword rasiEnvVarK contained env + +syn match rasiInvEnvVar display contained 'env([^)]*)' +syn match rasiEnvVar display contained transparent 'env(\s*\w\+\s*,\s*\(\a\+([^)]*)\)\?[^),]*)' contains=rasiEnvVarK,rasiEnvRef,@rasiPropertyVals +syn match rasiEnvRef display contained '\a\w*' + +syn cluster rasiPropertyVals add=rasiEnv,rasiInvEnv,rasiInvEnvVar,rasiEnvVar +" }}} + +" Color {{{ +syn keyword rasiColorK contained rgb[a] hsl[a] hwb[a] cmyk + +syn match rasiHexColor display contained '#\x\{3,4}' +syn match rasiHexColor display contained '#\x\{6}' +syn match rasiHexColor display contained '#\x\{8}' +syn match rasiInvHexColor display contained '#\x\{5}\X'he=e-1,me=e-1 +syn match rasiInvHexColor display contained '#\x\{7}\X'he=e-1,me=e-1 + +syn match rasiInvRGBColor display contained 'rgb\(a\)\?([^)]*)' +syn match rasiRGBColor display contained transparent 'rgb\(a\)\?(\s*\d\+\s*\(%\)\?\s*,\(\s*\d\+\s*\(%\)\?\s*\){2}\(,\s*\(\d\(\.\d*\)\?\|\d\{,3}%\)\s*\)\?)' contains=rasiColorK,rasiNumber,rasiDistance + +syn match rasiInvHSLColor display contained 'h\(sl\|wb\)\(a\)\?([^)]*)' +syn match rasiHSLColor display contained transparent 'h\(sl\|wb\)\(a\)\?(\s*\d\+\(\.\d*\)\?\(deg\|rad\|grad\|turn\)\?\s*\(,\s*\(\d\(\.\d*\)\?\|\d\{,3}%\)\s*\)\{2,3})' contains=rasiColorK,rasiNumber,rasiDistance + + +"this matches doesn't works properly (too long ?) +syn match rasiInvCMYKColor display contained 'cmyk([^)]*)' +syn match rasiCMYKColor display contained transparent 'cmyk(\s*\(\d\(\.\d*\)\?\|\d\{,3}%\)\s*\(,\s*\(\d\(\.\d*\)\?\|\d\{,3}%\)\s*\)\{3,4})' contains=rasiColorK,rasiNumber,rasiDistance + +syn case ignore +syn keyword rasiNamedColor contained + \ AliceBlue AntiqueWhite Aqua Aquamarine Azure Beige Bisque Black BlanchedAlmond Blue + \ BlueViolet Brown BurlyWood CadetBlue Chartreuse Chocolate Coral CornflowerBlue Cornsilk + \ Crimson Cyan DarkBlue DarkCyan DarkGoldenRod DarkGray DarkGrey DarkGreen DarkKhaki DarkMagenta + \ DarkOliveGreen DarkOrange DarkOrchid DarkRed DarkSalmon DarkSeaGreen Dark SlateBlue + \ DarkSlateGray DarkSlateGrey DarkTurquoise DarkViolet DeepPink DeepSkyBlue DimGray DimGrey + \ DodgerBlue FireBrick FloralWhite ForestGreen Fuchsia Gainsboro GhostWhite Gold GoldenRod + \ Gray Grey Green GreenYellow HoneyDew HotPink IndianRed Indigo Ivory Khaki Lavender + \ LavenderBlush LawnGreen LemonChiffon LightBlue LightCoral LightCyan LightGoldenRodYellow + \ LightGray LightGrey LightGreen LightPink LightSalmon LightSeaGreen LightSkyBlue LightSlateGray + \ LightSlateGrey LightSteelBlue LightYellow Lime LimeGreen Linen Magenta Maroon MediumAquaMarine + \ MediumBlue MediumOrchid MediumPurple MediumSeaGreen MediumSlateBlue MediumSpringGreen + \ MediumTurquoise MediumVioletRed MidnightBlue MintCream MistyRose Moccasin NavajoWhite Navy + \ OldLace Olive OliveDrab Orange OrangeRed Orchid PaleGoldenRod PaleGreen PaleTurquoise + \ PaleVioletRed PapayaWhip PeachPuff Peru Pink Plum PowderBlue Purple RebeccaPurple Red + \ RosyBrown RoyalBlue SaddleBrown Salmon SandyBrown SeaGreen SeaShell Sienna Silver SkyBlue + \ SlateBlue SlateGray SlateGrey Snow SpringGreen SteelBlue Tan Teal Thistle Tomato Turquoise + \ Violet Wheat White WhiteSmoke Yellow YellowGreen transparent[] "uses `[]` to escape keyword + +syn cluster rasiColors add=rasiHexColor,rasiRGBColor,rasiHSLColor,rasiCMYKColor,rasiNamedColor +syn cluster rasiColors add=rasiInvHexColor,rasiInvRGBColor,rasiInvHSLColor,rasiInvCMYKColor + +syn cluster rasiPropertyVals add=@rasiColors +" }}} + +" Text-Style {{{ +syn keyword rasiTextStyle contained bold italic underline strikethrough none + +syn cluster rasiPropertyVals add=rasiTextStyle +" }}} + +" Line-Style {{{ +syn keyword rasiLineStyle contained dash solid + +syn cluster rasiPropertyVals add=rasiLineStyle +" }}} + +" Distance {{{ +syn match rasiDistanceUnit display contained '\(px\|em\|ch\|%\|mm\)' + +syn match rasiInvDistance display contained '[+-]\?\d\+\.\d\+\(px\|mm\)' +syn match rasiDistance display contained transparent '[-+]\?\d\+\(px\|mm\)' contains=rasiDistanceUnit,rasiNumber +syn match rasiDistance display contained transparent '[+-]\?\d\+\(\.\d\+\)\?\(em\|ch\|%\)' contains=rasiDistanceUnit,rasiNumber + +syn keyword rasiDistanceCalc contained calc nextgroup=rasiDistanceCalcBody +syn region rasiDistanceCalcBody display contained start=+(+ end=+)+ contains=rasiDistanceCalcOp,rasiDistance,rasiInvDistance +syn match rasiDistanceCalcOp display contained '\(+\|-\|/\|\*\|%\|min\|max\)' + +syn cluster rasiPropertyVals add=rasiInvDistance,rasiDistance,rasiDistanceCalc +" }}} + +" Position {{{ +syn keyword rasiPosition contained center east north west south + +syn cluster rasiPropertyVals add=rasiPosition +" }}} + +" Orientation {{{ +syn keyword rasiOrientation contained horizontal vertical + +syn cluster rasiPropertyVals add=rasiOrientation +" }}} + +" Cursor {{{ +syn keyword rasiCursor contained default pointer text + +syn cluster rasiPropertyVals add=rasiCursor +" }}} + +" Keyword List {{{ +syn region rasiKeywordList contained start=+\[+ end=+\]+ contains=rasiPropertyIdRef + +syn cluster rasiPropertyVals add=rasiKeywordList +" }}} + +" Inherit {{{ +syn keyword rasiInherit contained inherit children + +syn cluster rasiPropertyVals add=rasiInherit +" }}} + +syn match rasiGlobalImport display '^\s*@\(import\|theme\)' nextgroup=rasiString skipwhite + +" Section {{{ +" syn region rasiSection transparent start='^[^{]\+{'me=e-1 end='}' contains=rasiSectionOpenning,rasiSectionContent +syn match rasiSectionOpenning transparent '^[^{]\+{'me=e-1 contains=rasiGlobalSection,rasiWidgetName,rasiGlobalMedia nextgroup=rasiThemeSectionContent +" syn match rasiThemeInnerSectionOpenning transparent '^[^:${]\+{'me=e-1 contains=rasiWidgetName nextgroup=rasiThemeInnerSectionContent contained + +syn match rasiGlobalMedia display contained '^\s*@media' nextgroup=rasiInvMediaBody,rasiMediaBody skipwhite +syn match rasiInvMediaBody display contained '([^)]*)' +syn match rasiMediaBody display contained '(\s*[a-z-]\+\s*:\s*\d\+\(px\|mm\)\?\s*)' contains=rasiMediaK,rasiNumber,rasiDistance +syn keyword rasiMediaK contained min-width max-width min-height max-height min-aspect-ratio max-aspect-ratio monitor-id + +syn match rasiGlobalSection display contained '^*' +syn match rasiWidgetName display contained '[a-zA-Z0-9-]\+' nextgroup=rasiVisibleMod skipwhite + +syn keyword rasiVisibleMod contained normal selected alternate nextgroup=rasiVisibleMod,rasiStateWrapper skipwhite +syn match rasiStateWrapper display contained transparent '\.\(normal\|active\|urgent\)' contains=rasiState +syn keyword rasiState contained normal active urgent + + +syn region rasiThemeSectionContent transparent start="{" end="}" contains=rasiProperty,rasiComment,rasiCommentL,rasiSectionOpenning contained +" syn region rasiThemeInnerSectionContent transparent start="{" end="}" contains=rasiProperty,rasiComment,rasiCommentL,rasiThemeInnerSectionOpenning contained + +syn match rasiProperty transparent '^\s*\S\+\s*:.*;\s*$' keepend contained contains=rasiPropertyId,rasiInvPropertyId,rasiPropertyVal,rasiComment,rasiCommentL +syn match rasiInvPropertyId '^\([^:]\&[^/]\{2}\)*:'me=e-1 contained +syn match rasiPropertyId '^\s*[0-9a-zA-Z-]\+\s*:'me=e-1 contained +syn match rasiInvPropertyVal ':[^;];\s*\S\+\s*$'ms=s+1,hs=s+1 +syn match rasiPropertyVal ':\s*[^;]\+;\s*$'ms=s+1,hs=s+1 contained contains=@rasiPropertyVals +" }}} + +" Comment {{{ +syn cluster rasiCommentGroup contains=rasiTodo,rasiBadContinuation + +syn region rasiCommentL start="//" skip="\\$" end="$" keepend contains=@rasiCommentGroup,@Spell +syn region rasiComment start="/\*" end="\*/" contains=@rasiCommentGroup,rasiCommentStartError,@Spell fold extend + +syn match rasiCommentError display '\*/' + +syn keyword rasiTodo contained TODO FIXME XXX NOTE + +if exists("rasi_minlines") + let b:rasi_minlines = rasi_minlines +else + let b:rasi_minlines = 50 +endif +exec "syn sync ccomment rasiComment minlines=" . b:rasi_minlines +" }}} + + + +" Highlighting: {{{ +hi def link rasiError Error + +hi def link rasiTodo Todo +hi def link rasiComment Comment +hi def link rasiCommentStart rasiComment +hi def link rasiCommentL rasiComment +hi def link rasiCommentError rasiError + +hi def link rasiString String +hi def link rasiNumber Number +hi def link rasiBool Boolean + +hi def link rasiImageK Function +hi def link rasiImageScale Keyword +hi def link rasiImageDirection Keyword +hi def link rasiImageUnit Type +hi def link rasiInvImage rasiError + +hi def link rasiHexColor Number +hi def link rasiColorK Function +hi def link rasiNamedColor Number +hi def link rasiInvColor rasiError +hi def link rasiInvHexColor rasiInvColor +hi def link rasiInvRGBColor rasiInvColor +hi def link rasiInvHSLColor rasiInvColor +hi def link rasiInvCMYKColor rasiInvColor + +hi def link rasiTextStyle Keyword +hi def link rasiLineStyle Keyword + +hi def link rasiDistanceUnit Type +hi def link rasiDistanceCalc Function +hi def link rasiDistanceCalcOp Operator +hi def link rasiInvDistance rasiError + +hi def link rasiPosition Keyword +hi def link rasiOrientation Keyword +hi def link rasiCursor Keyword + +hi def link rasiReference Identifier +hi def link rasiPropertyIdRef Identifier +hi def link rasiVarReferenceK Function +hi def link rasiInvVarReference rasiError + +hi def link rasiEnv Identifier +hi def link rasiEnvRef Identifier +hi def link rasiEnvVarK Function +hi def link rasiInvEnv rasiError +hi def link rasiInvEnvVar rasiError + +hi def link rasiWidgetName StorageClass +hi def link rasiGlobalSection StorageClass +hi def link rasiVisibleMod Type +hi def link rasiState Tag + +hi def link rasiInherit Identifier + +hi def link rasiGlobalImport Include + +hi def link rasiGlobalMedia Preproc +hi def link rasiMediaK Keyword +hi def link rasiInvMediaBody rasiError + +hi def link rasiPropertyId Identifier +hi def link rasiInvProperty rasiError +hi def link rasiInvPropertyId rasiError +hi def link rasiInvPropertyVal rasiError +" }}} + +" vim:ts=8