Skip to content

Commit 4f11996

Browse files
authored
Merge pull request #6549 from wxtim/deprecate.vim-syntax
Remove vim.lang from syntax
2 parents 433e65f + 058c2c0 commit 4f11996

File tree

5 files changed

+35
-118
lines changed

5 files changed

+35
-118
lines changed

changes.d/6549.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed cylc.vim - you should use https://github.com/cylc/cylc.vim instead.

cylc/flow/etc/syntax/cylc.vim

Lines changed: 0 additions & 115 deletions
This file was deleted.

cylc/flow/resources.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
"""Extract named resources from the cylc.flow package."""
1818

19+
from ansimarkup import parse
1920
from contextlib import suppress
2021
from pathlib import Path
2122
from random import choice
@@ -39,10 +40,10 @@
3940
RESOURCE_NAMES = {
4041
'syntax/cylc-mode.el': 'Emacs syntax highlighting.',
4142
'syntax/cylc.lang': 'Gedit (gtksourceview) syntax highlighting.',
42-
'syntax/cylc.vim': 'Vim syntax highlighting.',
4343
'syntax/cylc.xml': 'Kate syntax highlighting.',
4444
'cylc-completion.bash': 'Bash auto-completion for Cylc commands.',
4545
'cylc': 'Cylc wrapper script.',
46+
'!syntax/cylc.vim': 'Obsolete- use https://github.com/cylc/cylc.vim',
4647
}
4748
API_KEY = 'api-key'
4849

@@ -63,7 +64,15 @@ def list_resources(write=print, headers=True):
6364
write('Resources:')
6465
max_len = max(len(res) for res in RESOURCE_NAMES)
6566
for resource, desc in RESOURCE_NAMES.items():
66-
write(f' {resource} {" " * (max_len - len(resource))} # {desc}')
67+
if resource[0] == '!':
68+
# Use ! to indicated that resource is deprecated:
69+
resource = resource[1:]
70+
write(parse(
71+
f'<yellow> {resource} {" " * (max_len - len(resource))}'
72+
f' # {desc}</yellow>'
73+
))
74+
else:
75+
write(f' {resource} {" " * (max_len - len(resource))} # {desc}')
6776
if headers:
6877
write('\nTutorials:')
6978
for tutorial in tutorials:

cylc/flow/scripts/get_resources.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import sys
4343

4444
from cylc.flow import LOG
45+
from cylc.flow.exceptions import CylcError
4546
import cylc.flow.flags
4647
from cylc.flow.loggingutil import set_timestamps
4748
from cylc.flow.option_parsers import CylcOptionParser as COP
@@ -74,6 +75,13 @@ def get_option_parser():
7475

7576
@cli_function(get_option_parser)
7677
def main(parser, opts, resource=None, tgt_dir=None):
78+
# Intercept requests for syntax/cylc.vim:
79+
if resource == "syntax/cylc.vim":
80+
raise CylcError(
81+
'syntax/cylc.vim has been replaced by '
82+
'https://github.com/cylc/cylc.vim'
83+
)
84+
7785
if cylc.flow.flags.verbosity < 2:
7886
set_timestamps(LOG, False)
7987
if not resource or opts.list:

tests/unit/test_resources.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ def test_get_resources_one(tmpdir):
4040

4141
@pytest.mark.parametrize(
4242
'resource',
43-
list(RESOURCE_NAMES.keys()) + ['tutorial/runtime-tutorial']
43+
[
44+
r for r
45+
in list(RESOURCE_NAMES.keys())
46+
if r[0] != '!'
47+
] + ['tutorial/runtime-tutorial']
4448
)
4549
def test_get_resources_all(resource, tmpdir):
4650
get_resources(resource, tmpdir)
@@ -75,3 +79,13 @@ def test_backup(tmp_path, caplog):
7579

7680
new_abc = new / 'b' / 'c'
7781
assert new_abc.exists()
82+
83+
84+
def test_vim_deprecated():
85+
"""It fails, returning a warning if user asks for obsolete syntax file
86+
"""
87+
output = run(
88+
['cylc', 'get-resources', 'syntax/cylc.vim'],
89+
capture_output=True
90+
)
91+
assert 'has been replaced' in output.stderr.decode()

0 commit comments

Comments
 (0)