From feb0752c95fdc5ecde25b8bea7eeea739384cad8 Mon Sep 17 00:00:00 2001 From: Tim Pillinger Date: Fri, 10 Jan 2025 10:36:54 +0000 Subject: [PATCH] Remove vim.lang from syntax Point users of Cylc Get Resources to the new cylc.vim plugin. --- cylc/flow/etc/syntax/cylc.vim | 115 ----------------------------- cylc/flow/resources.py | 12 ++- cylc/flow/scripts/get_resources.py | 9 +++ 3 files changed, 19 insertions(+), 117 deletions(-) delete mode 100644 cylc/flow/etc/syntax/cylc.vim diff --git a/cylc/flow/etc/syntax/cylc.vim b/cylc/flow/etc/syntax/cylc.vim deleted file mode 100644 index 13784d37473..00000000000 --- a/cylc/flow/etc/syntax/cylc.vim +++ /dev/null @@ -1,115 +0,0 @@ -" Syntax highlighting for Cylc files. -" Author: Hilary Oliver, 2011-2014 -" see :help syntax -"______________________________________________________________________ -" -"INSTRUCTIONS FOR USE -" -" 1) Put this file in $HOME/.vim/syntax/ directory. -" -" 2) Put the following in $HOME/.vimrc for file type recognition -" (without the leading "| characters): -" -"|augroup filetype -"| au! BufRead,BufnewFile *suite*.rc set filetype=cylc -"| au! BufRead,BufnewFile *.cylc set filetype=cylc -"|augroup END -" -" 3) If you want to open files with syntax folds initially open, then -" also add the following line to your $HOME/.vimrc file: -" -"|if has("folding") | set foldlevelstart=99 | endif -" -" 4) Cylc syntax is linked to standard vim highlighting groups below (e.g. -" comments: 'hi def link cylcComment Comment'). These can be customized in -" your .vimrc file for consistent highlighting across file types, e.g.: -" -"|hi Statement guifg=#22a8e3 gui=bold -"|hi Normal guifg=#9096a4 -"|hi Comment guifg=#ff6900 -"|hi Type guifg=#28d45b gui=bold" -" -"______________________________________________________________________ - -" syncing from start of file is best, but may be slow for large files: -syn sync fromstart - -set foldmethod=syntax -syn region myFold start='\_^ *\[\[\[\(\w\| \)' end='\ze\_^ *\[\{1,3}\(\w\| \)' transparent fold -syn region myFold start='\_^ *\[\[\(\w\| \)' end='\ze\_^ *\[\{1,2}\(\w\| \)' transparent fold -syn region myFold start='\_^ *\[\(\w\| \)' end='\_^ *\ze\[\(\w\| \)' transparent fold - -" note contained items are only recognized inside containing items -syn match lineCon "\\$" -syn match badLineCon "\\ \+$" -syn match trailingWS " \+\(\n\)\@=" - -syn region jinja2Block start='{%' end='%}' -syn region jinja2Print start='{{' end='}}' -syn region jinja2Comment start='{#' end='#}' - -syn region empy start='@\[' end=']' -syn region empy start='@{' end='}' -syn region empy start='@(' end=')' - -syn region cylcSection start='\[' end='\]' contains=trailingWS,lineCon,badLineCon,jinja2Block,jinja2Print,jinja2Comment,empy -syn region cylcSection start='\[\[' end='\]\]' contains=trailingWS,lineCon,badLineCon,jinja2Block,jinja2Print,jinja2Comment,empy -syn region cylcSection start='\[\[\[' end='\]\]\]' contains=trailingWS,lineCon,badLineCon,jinja2Block,jinja2Print,jinja2Comment,empy - -syn match cylcItem ' *\zs\(\w\|+\|\/\| \|\-\)*\> *=\@=' -syn match cylcEquals '=' - -syn match trigger /=>/ contained -syn match xtrigger /@[a-zA-Z0-9_-]*/ contained -syn match parameter /<[^>]*>/ contained -syn match output /:[a-zA-Z0-9_-]*\>/ contained -syn match suicide /\!\w\+/ contained -syn match offset /\[.\{-}\]/ contained -syn match optional /?/ contained - -"file inclusion: -syn match cylcInclude '%include *\(\w\|"\| \|\-\|\/\|\.\)*' -"inlined file markers: -syn match cylcInclude '\_^!\{1,}' -syn match cylcInclude '.*\(START INLINED\|END INLINED\).*' - -syn match cylcToDo /[Tt][Oo][Dd][Oo]/ -syn match cylcToDo /[Ff][Ii][Xx][Mm][Ee]/ - -syn match empyVariable /@[a-zA-Z0-9]\+/ -syn match empyComment /@#.*/ contains=trailingWS,cylcToDo,lineCon,badLineCon -syn match cylcComment /#.*/ contains=trailingWS,cylcToDo,lineCon,badLineCon,jinja2Block,jinja2Print,jinja2Comment,empy - -syn region cylcString start=+'+ skip=+\\'+ end=+'+ contains=trailingWS,lineCon,badLineCon,jinja2Block,jinja2Print,jinja2Comment,empy,cylcToDo -syn region cylcString start=+"+ skip=+\\"+ end=+"+ contains=trailingWS,lineCon,badLineCon,jinja2Block,jinja2Print,jinja2Comment,empy,cylcToDo -syn region cylcString start=+=\@<= *"""+ end=+"""+ contains=trailingWS,lineCon,badLineCon,jinja2Block,jinja2Print,jinja2Comment,empy,empyComment,cylcComment,optional,trigger,output,suicide,offset,cylcToDo,xtrigger,parameter -syn region cylcString start=+=\@<= *'''+ end=+'''+ contains=trailingWS,lineCon,badLineCon,jinja2Block,jinja2Print,jinja2Comment,empy,empyComment,cylcComment,optional,trigger,output,suicide,offset,cylcToDo,xtrigger,parameter - -"de-emphasize strings as quoting is irrelevant in cylc -hi def link cylcString Normal - -hi def link cylcSection Statement -hi def link cylcItem Type -hi def link cylcComment Comment - -hi def link lineCon Constant -hi def link badLineCon Error -hi def link trailingWS Underlined - -hi def link cylcToDo Todo -hi def link cylcInclude Include -hi def link jinja2Block PreProc -hi def link jinja2Print PreProc -hi def link jinja2Comment Comment -hi def link empy PreProc -hi def link empyComment CursorColumn -hi def link empyVariable PreProc -hi def link cylcEquals LineNr -hi def link output Identifier -hi def link suicide Special -hi def link offset Special -hi def link trigger Constant -hi def link optional Type - -hi def link xtrigger Function -hi def link parameter Function diff --git a/cylc/flow/resources.py b/cylc/flow/resources.py index 956ec27e8aa..73d2a85ad0a 100644 --- a/cylc/flow/resources.py +++ b/cylc/flow/resources.py @@ -16,6 +16,7 @@ """Extract named resources from the cylc.flow package.""" +from ansimarkup import parse from contextlib import suppress from pathlib import Path from random import choice @@ -39,10 +40,10 @@ RESOURCE_NAMES = { 'syntax/cylc-mode.el': 'Emacs syntax highlighting.', 'syntax/cylc.lang': 'Gedit (gtksourceview) syntax highlighting.', - 'syntax/cylc.vim': 'Vim syntax highlighting.', 'syntax/cylc.xml': 'Kate syntax highlighting.', 'cylc-completion.bash': 'Bash auto-completion for Cylc commands.', 'cylc': 'Cylc wrapper script.', + '!syntax/cylc.vim': 'Deprecated - use https://github.com/cylc/cylc.vim', } API_KEY = 'api-key' @@ -63,7 +64,14 @@ def list_resources(write=print, headers=True): write('Resources:') max_len = max(len(res) for res in RESOURCE_NAMES) for resource, desc in RESOURCE_NAMES.items(): - write(f' {resource} {" " * (max_len - len(resource))} # {desc}') + if resource[0] == '!': + resource = resource[1:] + write(parse( + f' {resource} {" " * (max_len - len(resource))}' + f' # {desc}' + )) + else: + write(f' {resource} {" " * (max_len - len(resource))} # {desc}') if headers: write('\nTutorials:') for tutorial in tutorials: diff --git a/cylc/flow/scripts/get_resources.py b/cylc/flow/scripts/get_resources.py index 75d497d714b..97d5bded55b 100755 --- a/cylc/flow/scripts/get_resources.py +++ b/cylc/flow/scripts/get_resources.py @@ -42,6 +42,7 @@ import sys from cylc.flow import LOG +from cylc.flow.exceptions import CylcError import cylc.flow.flags from cylc.flow.loggingutil import set_timestamps from cylc.flow.option_parsers import CylcOptionParser as COP @@ -74,6 +75,14 @@ def get_option_parser(): @cli_function(get_option_parser) def main(parser, opts, resource=None, tgt_dir=None): + + # Intercept requests for syntax/cylc.vim: + if resource == "syntax/cylc.vim": + raise CylcError( + 'syntax/cylc.vim has been replaced by ' + 'https://github.com/cylc/cylc.vim' + ) + if cylc.flow.flags.verbosity < 2: set_timestamps(LOG, False) if not resource or opts.list: