From 3a2a4a8e599bee3cad870b12651755e955d2a493 Mon Sep 17 00:00:00 2001 From: PyvesB Date: Sun, 22 Nov 2020 10:59:43 +0000 Subject: [PATCH] Add support for embedded Ruby --- .../grammar/erb.tmLanguage.json | 151 ++++++++++++++++++ eclipse-solargraph-plugin/icon/erb-editor.png | Bin 0 -> 423 bytes .../erb-configuration.json | 31 ++++ ...iguration.json => ruby-configuration.json} | 0 eclipse-solargraph-plugin/plugin.xml | 44 ++++- eclipse-solargraph-plugin/snippet/sample.erb | 6 + 6 files changed, 230 insertions(+), 2 deletions(-) create mode 100644 eclipse-solargraph-plugin/grammar/erb.tmLanguage.json create mode 100644 eclipse-solargraph-plugin/icon/erb-editor.png create mode 100644 eclipse-solargraph-plugin/language-configuration/erb-configuration.json rename eclipse-solargraph-plugin/language-configuration/{language-configuration.json => ruby-configuration.json} (100%) create mode 100644 eclipse-solargraph-plugin/snippet/sample.erb diff --git a/eclipse-solargraph-plugin/grammar/erb.tmLanguage.json b/eclipse-solargraph-plugin/grammar/erb.tmLanguage.json new file mode 100644 index 0000000..0a1d88c --- /dev/null +++ b/eclipse-solargraph-plugin/grammar/erb.tmLanguage.json @@ -0,0 +1,151 @@ +{ + "name": "HTML (Ruby - ERB)", + "scopeName": "text.html.erb", + "fileTypes": ["rhtml", "html.erb"], + "injections": { + "text.html.erb - (meta.embedded.block.erb | meta.embedded.line.erb | meta.tag | comment), L:meta.tag, L:source.js.embedded.html": { + "patterns": [ + { + "begin": "(^\\s*)(?=<%+#(?![^%]*%>))", + "beginCaptures": { + "0": { + "name": "punctuation.whitespace.comment.leading.erb" + } + }, + "end": "(?!\\G)(\\s*$\\n)?", + "endCaptures": { + "0": { + "name": "punctuation.whitespace.comment.trailing.erb" + } + }, + "patterns": [ + { + "include": "#comment" + } + ] + }, + { + "begin": "(^\\s*)(?=<%(?![^%]*%>))", + "beginCaptures": { + "0": { + "name": "punctuation.whitespace.embedded.leading.erb" + } + }, + "end": "(?!\\G)(\\s*$\\n)?", + "endCaptures": { + "0": { + "name": "punctuation.whitespace.embedded.trailing.erb" + } + }, + "patterns": [ + { + "include": "#tags" + } + ] + }, + { + "include": "#comment" + }, + { + "include": "#tags" + } + ] + } + }, + "patterns": [ + { + "include": "text.html.basic" + } + ], + "repository": { + "comment": { + "patterns": [ + { + "begin": "<%+#", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.begin.erb" + } + }, + "end": "%>", + "endCaptures": { + "0": { + "name": "punctuation.definition.comment.end.erb" + } + }, + "name": "comment.block.erb" + } + ] + }, + "tags": { + "patterns": [ + { + "begin": "<%+(?!>)[-=]?(?![^%]*%>)", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.erb" + } + }, + "contentName": "source.ruby.embedded.erb", + "end": "-?%>", + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.erb" + }, + "1": { + "name": "source.ruby" + } + }, + "name": "meta.embedded.block.erb", + "patterns": [ + { + "captures": { + "1": { + "name": "punctuation.definition.comment.erb" + } + }, + "match": "(#).*?(?=-?%>)", + "name": "comment.line.number-sign.erb" + }, + { + "include": "source.ruby" + } + ] + }, + { + "begin": "<%+(?!>)[-=]?", + "beginCaptures": { + "0": { + "name": "punctuation.section.embedded.begin.erb" + } + }, + "contentName": "source.ruby.embedded.erb", + "end": "-?%>", + "endCaptures": { + "0": { + "name": "punctuation.section.embedded.end.erb" + }, + "1": { + "name": "source.ruby" + } + }, + "name": "meta.embedded.line.erb", + "patterns": [ + { + "captures": { + "1": { + "name": "punctuation.definition.comment.erb" + } + }, + "match": "(#).*?(?=-?%>)", + "name": "comment.line.number-sign.erb" + }, + { + "include": "source.ruby" + } + ] + } + ] + } + } +} diff --git a/eclipse-solargraph-plugin/icon/erb-editor.png b/eclipse-solargraph-plugin/icon/erb-editor.png new file mode 100644 index 0000000000000000000000000000000000000000..5f9510a405952283d242b1af8e15187377c5c07e GIT binary patch literal 423 zcmV;Y0a*TtP)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ-ElET{RCwB?lfOy>K@i5j`(v5|B{|M2*hoMQ#KOjB@J$4pC|LOnwt{bA;6%hu zFk&Z)7(@imMpD=Xz1+-L=gQ!7i%#`*D4r9=*}X8q1z0|3ATwOKkL RA{qby002ovPDHLkV1jJ+sY(C< literal 0 HcmV?d00001 diff --git a/eclipse-solargraph-plugin/language-configuration/erb-configuration.json b/eclipse-solargraph-plugin/language-configuration/erb-configuration.json new file mode 100644 index 0000000..91a7600 --- /dev/null +++ b/eclipse-solargraph-plugin/language-configuration/erb-configuration.json @@ -0,0 +1,31 @@ +{ + "comments": { + "blockComment": [ "<%#", "%>" ] + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["<", ">"] + ], + "autoClosingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"], + ["`", "`"], + ["<", ">"], + ["%", "%"] + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"], + ["`", "`"], + ["<", ">"], + ["%", "%"] + ] +} diff --git a/eclipse-solargraph-plugin/language-configuration/language-configuration.json b/eclipse-solargraph-plugin/language-configuration/ruby-configuration.json similarity index 100% rename from eclipse-solargraph-plugin/language-configuration/language-configuration.json rename to eclipse-solargraph-plugin/language-configuration/ruby-configuration.json diff --git a/eclipse-solargraph-plugin/plugin.xml b/eclipse-solargraph-plugin/plugin.xml index 792077d..05323ed 100644 --- a/eclipse-solargraph-plugin/plugin.xml +++ b/eclipse-solargraph-plugin/plugin.xml @@ -31,6 +31,13 @@ name="Gemfile" priority="high"> + + @@ -42,6 +49,10 @@ contentTypeId="io.github.pyvesb.eclipse_solargraph.gemfile" editorId="org.eclipse.ui.genericeditor.GenericEditor"> + + @@ -58,6 +69,10 @@ contentType="io.github.pyvesb.eclipse_solargraph.gemfile" id="io.github.pyvesb.eclipse_solargraph"> + + @@ -69,6 +84,10 @@ path="grammar/gemfile.tmLanguage.json" scopeName="source.ruby.gemfile"> + + @@ -77,6 +96,10 @@ contentTypeId="io.github.pyvesb.eclipse_solargraph.gemfile" scopeName="source.ruby.gemfile"> + + @@ -88,6 +111,10 @@ class="org.eclipse.tm4e.ui.text.TMPresentationReconciler" contentType="io.github.pyvesb.eclipse_solargraph.gemfile"> + + @@ -99,16 +126,24 @@ icon="icon/ruby-editor.png" contentType="io.github.pyvesb.eclipse_solargraph.gemfile"> + + + path="language-configuration/ruby-configuration.json"> + path="language-configuration/ruby-configuration.json"> + + + + diff --git a/eclipse-solargraph-plugin/snippet/sample.erb b/eclipse-solargraph-plugin/snippet/sample.erb new file mode 100644 index 0000000..46ed635 --- /dev/null +++ b/eclipse-solargraph-plugin/snippet/sample.erb @@ -0,0 +1,6 @@ + + + +

Hello, <%= user.first_name %>.

+ +