Skip to content

Commit

Permalink
Merge pull request #6549 from wxtim/deprecate.vim-syntax
Browse files Browse the repository at this point in the history
Remove vim.lang from syntax
  • Loading branch information
hjoliver authored Feb 3, 2025
2 parents 433e65f + 058c2c0 commit 4f11996
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 118 deletions.
1 change: 1 addition & 0 deletions changes.d/6549.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Removed cylc.vim - you should use https://github.com/cylc/cylc.vim instead.
115 changes: 0 additions & 115 deletions cylc/flow/etc/syntax/cylc.vim

This file was deleted.

13 changes: 11 additions & 2 deletions cylc/flow/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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': 'Obsolete- use https://github.com/cylc/cylc.vim',
}
API_KEY = 'api-key'

Expand All @@ -63,7 +64,15 @@ 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] == '!':
# Use ! to indicated that resource is deprecated:
resource = resource[1:]
write(parse(
f'<yellow> {resource} {" " * (max_len - len(resource))}'
f' # {desc}</yellow>'
))
else:
write(f' {resource} {" " * (max_len - len(resource))} # {desc}')
if headers:
write('\nTutorials:')
for tutorial in tutorials:
Expand Down
8 changes: 8 additions & 0 deletions cylc/flow/scripts/get_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,6 +75,13 @@ 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:
Expand Down
16 changes: 15 additions & 1 deletion tests/unit/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ def test_get_resources_one(tmpdir):

@pytest.mark.parametrize(
'resource',
list(RESOURCE_NAMES.keys()) + ['tutorial/runtime-tutorial']
[
r for r
in list(RESOURCE_NAMES.keys())
if r[0] != '!'
] + ['tutorial/runtime-tutorial']
)
def test_get_resources_all(resource, tmpdir):
get_resources(resource, tmpdir)
Expand Down Expand Up @@ -75,3 +79,13 @@ def test_backup(tmp_path, caplog):

new_abc = new / 'b' / 'c'
assert new_abc.exists()


def test_vim_deprecated():
"""It fails, returning a warning if user asks for obsolete syntax file
"""
output = run(
['cylc', 'get-resources', 'syntax/cylc.vim'],
capture_output=True
)
assert 'has been replaced' in output.stderr.decode()

0 comments on commit 4f11996

Please sign in to comment.