Skip to content

Commit

Permalink
Recognize Nextflow files as Groovy files
Browse files Browse the repository at this point in the history
Nextflow is a domain specific language (DSL) implemented on top of the Groovy programming language
https://www.nextflow.io/
  • Loading branch information
Bond-009 committed Nov 4, 2024
1 parent b22c4f8 commit e61c7ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rouge/lexers/groovy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ class Groovy < RegexLexer
title "Groovy"
desc 'The Groovy programming language (http://www.groovy-lang.org/)'
tag 'groovy'
filenames '*.groovy', 'Jenkinsfile', '*.Jenkinsfile'
aliases 'nextflow', 'nf'
filenames '*.groovy', 'Jenkinsfile', '*.Jenkinsfile', '*.nf'
mimetypes 'text/x-groovy'

def self.detect?(text)
return true if text.shebang?(/groovy/)
return true if text.shebang?(/nextflow/)
end

def self.keywords
Expand Down
6 changes: 6 additions & 0 deletions spec/lexers/groovy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
assert_guess :filename => 'foo.groovy'
assert_guess :filename => 'Jenkinsfile'
assert_guess :filename => 'foo.Jenkinsfile'
assert_guess :filename => 'foo.nf'
end

it 'guesses by mimetype' do
assert_guess :mimetype => 'text/x-groovy'
end

it "guesses by source" do
assert_guess :source => "#!/usr/bin/env groovy"
assert_guess :source => "#!/usr/bin/env nextflow"
end
end
end

0 comments on commit e61c7ae

Please sign in to comment.