将 Haml 和 Sass 与 Eclipse 结合使用
题
是否有任何 Eclipse 插件可以添加语法突出显示和其他编辑细节 哈姆尔 和 萨斯?谷歌搜索似乎只指向一个 lucky-dip.net 上的死项目.
笔记:我最感兴趣的是Sass。仅使用 Sass 的解决方案(或类似的东西,例如 较少的)在 Eclipse 中会满足我的需要。
另外,我正在使用 Eclipse 的 App Engine 插件为 Google App Engine (Java) 进行开发。因此,切换到另一个 IDE 并不是一个选择。
更新: 所以我现在使用语法突出显示 帕斯卡的回答 我已经安装了 红宝石 和 罗盘 将 sass 编译成 css。
不过我知道 sass 的语法将在 2.4 中发生变化 所以我仍然想让 Aptana 附带的 Haml 和 Sass 编辑器来工作。当我尝试使用它们时,它们抛出异常并且不会显示文件。我很想知道这是因为我错误配置了 Aptana 还是编辑器中的实际错误。
我也会是 非常 对任何与 Ecplise 集成的 Sass 编译方式感兴趣,这样我就不必运行与它分开的东西。(或者将 Sass/Compass 放入 Ecplise 构建过程中的一种方法。)
解决方案
嗯,那又怎样呢 阿普塔纳?根据 Aptana/Eclipse 中的 Haml/Saas 语法突出显示 博客文章:
最近,我一直在使用 哈姆尔 在 我的一些 Rails 项目。它只是 使您的视图简洁易读。我遇到的一个问题是语法 在我最喜欢的 IDE 中突出显示, 阿普塔纳工作室. 。哈姆尔 语法 突出显示支持 已停止 不久前,更多问题已经 在 Aptana 最近更新后提出。
经过一番研究,我发现了一个 由 Max Kostovetski 发布的解决方案 Haml Google 群组成员。现在,到 步骤:
- 将以下文件下载到您的硬盘:>
- 从
阿普塔纳Eclipse“窗口”菜单,选择“首选项...”- 在首选项窗口中,选择“编辑器”>“通用文本”
- 按“添加...”添加新的文件扩展名:
*.haml
和*.sass
- 对于每个新扩展,单击它并按“浏览...”自 选择正确的词法分析器文件 (
*.lxr
)- 对于着色,按“导入...”导入
*.col
文件- 按“确定”
- 欣赏哈姆尔美景
附:请参阅原始博客文章,因为它提供了最新的链接。
笔记: 这可以与 Aptana RadRails Eclipse 插件 以及阿普塔纳工作室
更新: 在撰写本文时,RadRails 和 Studio 似乎支持 Haml 和 Sass,因此现在可能无需执行上述步骤。
要在 Eclipse 中以“集成”方式编译 SaaS,您也许可以使用 外部工具 (运行 > 外部工具)。另一个更详细的选项是添加“程序生成器“到你的项目的 建设者 就像这样 博客文章. 。当然,所描述的解决方案需要适应 Saas,但其背后的原则似乎适用。警告:我自己没有实现它,这只是一个想法,我什至不确定它是否有意义。
其他提示
请注意,最新 EclipseColorer 实际同时支持HAML&SASS。这可能是一个很好的选择的选择,如果你不需要一个全功能的Aptana IDE,但只是在寻找一个编辑器。
EclipseColorer还为您提供更好的语法混入支持:其他语言里面HAML的突出相对于它们的语法(红宝石,JavaScript的,CSS,甚至SASS混入)
虽然它不会出现有任何HAML或SASS语法荧光笔然而,你可能要考虑通过一些可用的插件做同时也带动VIM(它确实有HAML语法高亮支持)到Eclipse的东西线。 Eclim 可能是一种可能性(虽然我没有用它 - 只是试图提供其他的替代品)。
另一个选项是把一个已经存在的Eclipse语法突出显示插件和添加语法突出显示的Sass和/或HAML。类似的的Eclipse Colorer 可能是值得研究的。
我知道这是一个老问题,但对于任何新SASS和Compass喜欢我,我刚刚安装的Aptana Studio中3,现在有.scss,.sass和.haml支持。享受。
集锦引起太多的问题对我来说,所以很多搜索后(这打开了这个线程),我发现 LiClipseText( https://marketplace.eclipse.org/content/liclipsetext )
有提供,除其他事项外,语法高亮SASS / SCSS文件的插件。它似乎工作,并且有“语法高亮(LiClipse,基于TextMate的或SublimeText)”,所以很可能是相当配置的(我还没有与它周围的出场不多,但基本的语法高亮显示功能的工作对我来说,这是不是更Eclipse的WST CSS编辑器可以对SCSS文件执行)。
有商业LiClipse插件( HTTPS的开源编辑器组件://marketplace.eclipse。组织/内容/ liclipse ),我还没有使用。
我发现 Igor 的答案中的 Colorer 插件很有趣,但我使用 .scss 文件扩展名,它仅适用于 .sass 文件。以下是如何使其支持 .scss 文件扩展名:
首先像平常一样安装插件。选择 Install New software
在 Eclipse 的“帮助”菜单中添加以下存储库: http://colorer.sf.net/eclipsecolorer
. 。现在选择这个存储库,您应该会看到 Eclipse Colorer 安装选项。据我所知,没有拖动安装选项。
安装后,转到 Eclipse 插件目录中的 Colorer 插件文件夹。就我而言,那就是 eclipse/plugins/net.sf.colorer_0.9.9/
. 。在那里你必须修改 3 个文件:
- 着色器/hrc/common.jar
- 着色器/hrc/proto.hrc
- /插件.xml
在执行以下任何操作之前,请备份文件夹中的所有文件,以便在出现问题时恢复它们。
修改common.jar
将 common.jar 解压到空文件夹中。这可以像任何普通的 tar.gz 文件一样完成。解压后,您必须修改其中的 2 个文件:
重复第 53 行和 53 行 inet/haml.hrc
并将其更改为scss。结果应该如下所示:
<block start='/^((\s\s)*):(sass)/' end='/^\M (\s*$|\y1\s)?! /ix' region='def:Insertion' region01='def:Outlined'
region00='def:PairStart' region10='def:PairEnd' content-priority='low' scheme='sass:sass'/>
<block start='/^((\s\s)*):(scss)/' end='/^\M (\s*$|\y1\s)?! /ix' region='def:Insertion' region01='def:Outlined'
region00='def:PairStart' region10='def:PairEnd' content-priority='low' scheme='scss:scss'/>
现在复制 inet/sass.hrc
到 inet/scss.hrc
并更改相关行。所结果的 scss.hrc
应该像下面这样:
<?xml version="1.0" encoding='Windows-1251'?>
<!DOCTYPE hrc PUBLIC "-//Cail Lomecb//DTD Colorer HRC take5//EN"
"http://colorer.sf.net/2003/hrc.dtd">
<hrc version="take5" xmlns="http://colorer.sf.net/2003/hrc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://colorer.sf.net/2003/hrc http://colorer.sf.net/2003/hrc.xsd">
<type name="scss">
<annotation>
<documentation>
SCSS Sassy CSS
</documentation>
<contributors><![CDATA[
Igor Russkih irusskih at gmail dot com
]]></contributors>
</annotation>
<region name="ClassSelector" parent="def:TypeKeyword"/>
<region name="IDSelector" parent="def:Keyword"/>
<region name="IncludeMixin" parent="def:Label"/>
<scheme name='PropertyNames'>
<regexp match="/(\$)([\w\d\-]+)/" region='def:Var'/>
<inherit scheme='css:PropertyNames'/>
</scheme>
<scheme name="PropertyWrapper">
<block start="/~/" end="/(:|\s|$)/" scheme="PropertyNames" region10="def:Symbol"/>
<regexp match="/(\$)([\w\d\-]+)/" region='def:Var'/>
<inherit scheme="css:Property"/>
</scheme>
<scheme name="scss">
<!-- property value after colon -->
<block start="/\M([\$\w\d\-]+)\s*(:)/" end="/\M([\x22\x27]|$)/"
scheme="PropertyWrapper" region02="def:Symbol"
/>
<block start="/(:)\s*\M([\w\d\-]+)?/" end="/\M([\x22\x27]|$)/"
scheme="PropertyWrapper" region02="def:Symbol"
/>
<regexp match="/^ \s* \M[\.\#\=\@\!] (?{def:Outlined}[\w\d\-]+ ) /x" />
<regexp match="/ \. (?{ClassSelector}[\w\d\-]+ ) /x" />
<regexp match="/ \# (?{IDSelector}[\w\d\-]+ ) /x" />
<regexp match="/ [\=\+] (?{IncludeMixin}[\w\d\-]+ ) /x" />
<regexp match="/[\(\)'"]/" region='def:Symbol'/>
<regexp match="/\/\/.*$/" region='def:Comment'/>
<regexp match="/\@(import|extend|mixin)/" region='def:Keyword'/>
</scheme>
</type>
</hrc>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is the Colorer Library.
-
- The Initial Developer of the Original Code is
- Igor Russkih <irusskih at gmail dot com>
- Portions created by the Initial Developer are Copyright (C) 2010
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
之后,在提取 common.jar 的文件夹中运行以下命令以重新创建 jar 文件:
jar cf common.jar *
然后用这个文件替换原来的jar文件。
其他文件
现在,将 scss 扩展包含在 /plugin.xml
第 37 行:
扩展名=“xml、xsd、xsl、dtd、hrc、hrd、html、htm、xhtml、rhtml、erb、yml、haml、sass、scss、css、asp、aspx、jsp、fo、svg、dbk、docbook、jhtml” ,jspf,php,php3,php4,phtml,sgm,sgml,shtm,shtml"
最后,复制第 200-203 行 colorer/hrc/proto.hrc
. 。结果应该如下所示:
<prototype name="sass" group="inet" description="SASS">
<location link="jar:common.jar!inet/sass.hrc"/>
<filename>/\.(sass)$/i</filename>
</prototype>
<prototype name="scss" group="inet" description="SCSS">
<location link="jar:common.jar!inet/scss.hrc"/>
<filename>/\.(scss)$/i</filename>
</prototype>
重新启动 Eclipse 后,您应该可以看到 .scss 文件的语法高亮显示。