我发现 Igor 的答案中的 Colorer 插件很有趣,但我使用 .scss 文件扩展名,它仅适用于 .sass 文件。以下是使其支持 .scss 文件扩展名的方法:
首先正常安装插件。在 Eclipse 的帮助菜单中选择Install New software
并添加以下存储库:http://colorer.sf.net/eclipsecolorer
. 现在选择这个存储库,您应该会看到 Eclipse Colorer 安装选项。没有拖动安装选项AFAIK。
安装后,转到 Eclipse 插件目录中的 Colorer 插件文件夹。就我而言,这是eclipse/plugins/net.sf.colorer_0.9.9/
. 在那里你必须修改3个文件:
- colorer/hrc/common.jar
- 着色器/hrc/proto.hrc
- /plugin.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文件。
其它文件
现在,在第 37 行包含 scss 扩展/plugin.xml
:
extensions="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 文件的语法突出显示。