Skip to content

Commit

Permalink
Merge pull request #6 from peterk87/master
Browse files Browse the repository at this point in the history
Release 1.2.0 - Fix process output popup issue and add some snippets
  • Loading branch information
peterk87 authored Jan 8, 2025
2 parents 0bd5fd3 + a7a8077 commit f9c0f64
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ package-metadata.json
.ipynb_checkpoints/
*.ipynb
*.pickle
venv/
.venv/
11 changes: 10 additions & 1 deletion Nextflow.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ variables:
single_dollar_interpolation_identifier: (?:{{unicode_letter}}|[a-zA-Z_])(?:{{unicode_letter}}|[a-zA-Z0-9_])*
scope: source.nextflow
contexts:
# else-pop and immediately-pop from https://forum.sublimetext.com/t/syntax-definitions-how-to-force-pop-out-of-the-stack/36376/4
# convenience contexts for popping context off stack
else-pop:
- match: (?=\S)
pop: true
immediately-pop:
- match: ''
pop: true
main:
- match: ^(#!).+$\n
scope: comment.line.hashbang.nextflow
Expand Down Expand Up @@ -241,11 +249,12 @@ contexts:
- meta_scope: meta.evaluation.ternary.nextflow
- match: ":"
scope: keyword.operator.ternary.expression-separator.nextflow
- include: nextflow-code
- match: \}
pop: true
- match: $
pop: true
- include: nextflow-code
- include: else-pop
- match: "==~"
scope: keyword.operator.match.nextflow
- match: "=~"
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.2.0
9 changes: 9 additions & 0 deletions messages/1.2.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
=> 1.2.0

Added:

- snippets for process version YML and ch_versions mixing (ver), process modules config (withName)

Fixed:

- process popups hanging due to bad regex for getting output emit labels (https://github.com/nf-core/sublime/issues/5)
2 changes: 1 addition & 1 deletion messages/install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Thanks for using sublime-nextflow!

If you want more info or have any issues, please see the Github page at:

https://github.com/peterk87/sublime-nextflow
https://github.com/nf-core/sublime
10 changes: 7 additions & 3 deletions process_popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
regex_input_section = re.compile(r'\s*input:\s*')
regex_output_section = re.compile(r'\s*output:\s*')
# regex to find output channels with emit
regex_output_channel = re.compile(r'((?:.*,\s+)*.*),\s*emit:\s*(\w+)')
regex_output_channel = re.compile(r'(.*?),\s*emit:\s*(\w+)', re.DOTALL)

regex_take_section = re.compile(r'\s*take:\s*')
regex_emit_section = re.compile(r'\s*emit:\s*')
Expand Down Expand Up @@ -140,7 +140,8 @@ def find_wf_emit_section(text: str, start: int, end: int) -> int:

def get_output_channels(text: str, start: int, end: int) -> List[Tuple[str, str]]:
out = []
for m in regex_output_channel.finditer(text[start:end]):
t = text[start:end]
for m in regex_output_channel.finditer(t):
chan, emit = m.groups()
chan = ''.join(x.strip() for x in chan.split('\n'))
out.append((emit, chan))
Expand Down Expand Up @@ -178,6 +179,9 @@ def get_output_channel_emits(path: Path, proc_name: str) -> List[Tuple[str, str]
return []
proc_output_start = find_proc_output_section(text, proc_start, proc_end)
proc_output_start += proc_start
next_section_match = re.search(r'(when:|exec:|script:|stub:)', text[proc_output_start:])
if next_section_match:
proc_end = proc_output_start + next_section_match.start()
out = get_output_channels(text, proc_output_start, proc_end)
if not out:
out = output_section_lines(text, proc_output_start, proc_end)
Expand Down Expand Up @@ -341,7 +345,7 @@ def show_output_channel_popup(root_dir: Path, view: sublime.View, point: int) ->
output_channels_text = get_wf_emits(path, proc_name)
is_proc = False
if not output_channels_text:
window.status_message(f'No input channels in {proc_name}!')
window.status_message(f'No output channels in {proc_name}!')
else:
for path in root_dir.rglob('**/*.nf'):
output_channels_text = get_output_channel_emits(path, proc_name)
Expand Down
7 changes: 7 additions & 0 deletions snippets/nextflow-ch_versions-mix.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<snippet>
<content><![CDATA[
ch_versions = ch_versions.mix($1.out.versions${2:.first().ifEmpty(null)})$0
]]></content>
<tabTrigger>ver</tabTrigger>
<scope>source.nextflow meta.definition.workflow.nextflow</scope>
</snippet>
17 changes: 17 additions & 0 deletions snippets/nextflow-modules-config.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<snippet>
<content><![CDATA[
withName: '$1' {
ext.args = '$2'
publishDir = [
[
path: { "\${params.outdir}/$3" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
]
}
$0
]]></content>
<tabTrigger>withName</tabTrigger>
<scope>source.nextflow meta.block.nextflow</scope>
</snippet>
10 changes: 10 additions & 0 deletions snippets/nextflow-versions-yml.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<snippet>
<content><![CDATA[
cat <<-END_VERSIONS > versions.yml
"\${task.process}":
$1: \\\$($1 --version | sed 's/$1 //')$0
END_VERSIONS
]]></content>
<tabTrigger>ver</tabTrigger>
<scope>source.nextflow meta.definition.process.nextflow string.quoted.double.block.nextflow</scope>
</snippet>

0 comments on commit f9c0f64

Please sign in to comment.