I've started working with MeteorJS, which requires Handlebars templates to end with *.html.
You can't use *.hbs, or Meteor will throw an error.
I'd like to simply use *.hbs.html, so Meteor won't raise an exception, and I'll get the syntax highlighting for Handlebars simultaneously. How can I customize Sublime to recognize *.hbs.html as Handlebars syntax?
UPDATE:
Here's my code for ApplySyntax (not working yet):
"syntaxes": [
{
"name": "Handlebars",
"match": "all",
"rules": [
{"file_name": ".hbs.html$"}
]
}
]
Try this in ApplySyntax:
"syntaxes": [
{
"name": "Handlebars/Handlebars",
"extensions": ["hbs.html"]
}
]
The key is in the name - you need to specify the name of the package AND the path to the .tmLanguage file (extension excluded) within that package. I think it's in the root of the Handlebars package in this case, so this should work.
If you need other extensions just add them to that array, or if you need more complex matching you can use regular expressions as outlined in the other answer (or a combination of both).
By default Sublime Text only uses the last extension part to detect syntax, in your case, it's html.
There's a plugin called ApplySyntax that can detect syntax by any part of the filename, like hbs.html, apart from other things - see the default settings file for examples.
The ApplySyntax configuration should look like
"syntaxes": [
{
"name": "Handlebars",
"rules": [
{"file_name": ".*\\.hbs\\.html$"}
]
}
]
I was able to get this working without any extra packages. I'm using Sublime Text 3 Build 3126.
Open the file whose syntax you want to change
Go to View → Syntax → Open all with current extension as → select the appropriate syntax
Preferences → Settings - Syntax Specific
Change the extension as appropriate, for example:
{
"extensions":
[
"hbs.html"
]
}
Save the syntax settings file
Related
I have tried editing my user Sublime Linter settings to:
"linters":
{
"flake8": {
"args": ["--ignore W503"],
},
}
However, this has not gotten rid of the error flags.
First you probably want --extend-ignore and not --ignore
second, your arguments are malformed, you're telling flake8 to ignore the W503 code (note the space at the beginning)
Here's how you could configure sublime to do what you want:
I have tried editing my user Sublime Linter settings to:
"linters":
{
"flake8": {
"args": ["--extend-ignore", "W503"],
},
}
though I'd suggest instead to configure flake8 via its config file:
[flake8]
extend-ignore = W503
note that you shouldn't need that, since W503 is part of the default ignore set
disclaimer: I'm the current flake8 maintainer
I have a project in which I'm using standard as the default linter, according to sublimeLinter documentation y need to create a .sublime-project file with the following info:
{
"folders":
[
{
"path": "."
}
],
"SublimeLinter":
{
"linters":
{
"jshint": {
"disable": true
}
}
}
}
however this isn't working, I've tried using both disable and #disable, created a .sublimelinterrc file with the same info, also tried with a .sublime-workspacefile, didn't worked, created a .jshintignore... didnt work.
Until now, the only thing that has worked is using this line in top of the file // jshint ignore: start but I don't want to write this in every single file, I want to disable it for all the project. Any idea of how can I do it?
As mentioned by OdatNurd the file won't do nothing by itself, it has to be loaded through the sublime project option in menu.
There is a newer, easier syntax for this. In your sublime project file add the following under settings.
{
"settings":
{
"SublimeLinter.linters.jshint.disable": true
}
}
After an hour+ on Google, I can't believe I haven't found any answers or questions to this. I'm using the SublimeLinter-contrib-eslint package in Sublime Text 3. Is there a way to force SublimeLinter to lint a whole project instead of just one file?
I have a semi-large client-side project with a lot of separate files, and obviously, these files share variables across the window. However, by default, SublimeLinter only lints a single file, so it throws errors that '<variable>' is not defined (no-undef) when another file defines it and '<variable>' is defined but never used (no-unused-vars) when other files use it.
In my .eslintrc, I can set these global variables like this:
"globals": {
"m": true,
"app": true
},
I could also do this in each file, which is arguably good practice anyway:
var m = m || {};
var app = app || {};
But these methods do not fix the unused variable errors.
The best solution I've come up with is to force SublimeLinter to lint the entire directory rather than the individual file. I can't figure out a way to do this though.
I tried turning on the chdir setting in SublimeLinter's user settings:
{
"user": {
...
"linters": {
"eslint": {
"#disable": false,
"args": [],
"excludes": [],
"chdir": "${project}"
}
},
...
}
}
But ^this just sets the $PWD when running eslint, not the arguments passed to eslint.
So is there a way to force SublimeLinter to lint an entire directory (or the whole project)? Is there a better solution to this problem that I haven't thought of? Maybe I'm just spoiled by go fmt.
I'm trying to configure sublimelinter, specifically jshint on my Mac. On my windows version of SublimeText there is the following section in SublimeLinter.sublime-settings
"jshint_options":
{
// To fix column positions for JSHint errors you may want to add `"indent": 1` to your
// **User** "jshint_options". This issue affects users with tabs for indentation.
// This fix was reverted due to a conflict with using the `"white": true` option.
// "indent": 1,
"evil": true,
"regexdash": true,
"browser": true,
"wsh": true,
"trailing": true,
"sub": true
},
When I view the file on my Mac this section doesn't exist, is there a place to edit these option on the Mac version without a separate settings file? Or a global settings file for jshint?
I've been digging through similar questions but haven't found a clear solution.
Update:
Actually it doesn't seem to catch any errors at all when using it on the console. My javascript file doesn't end in .js how can I configure it to look at different extensions? I can't find it in the docs.
There's another way to set options globally, without using ".jshintrc" files.
1) create a file with any name (e.g. "jshint.conf"). my file is:
{
"globals": { "$": false },
"globalstrict": true,
"devel": true
}
2) put it anywhere. in my case it is: "c:\Users\Smith\AppData\Roaming\Sublime Text 3\Packages\User\"
3) make the next reference in section "jshint"->"args" of sublime-linter user setting (user/SublimeLinter.sublime-settings):
{
"user": {
"linters": {
"jshint": {
"args": [
"--config", "c:\\Users\\Smith\\AppData\\Roaming\\Sublime Text 3\\Packages\\User\\jshint.conf"
]
}
}
}
}
4) Enjoy!
In general I would recommend against configuring JSHint system-wide. It's usually safer to create a .jshintrc file for each project your work on because it's likely they will have different JSHint requirements.
The jshint_options SublimeLinter setting you mention in your question is from the old version of SublimeLinter, which has recently been reworked to have a simple plugin architecture. The JSHint plugin (which I assume you are using, since the settings you tried didn't work) makes the same recommendation:
You can configure jshint options in the way you would from the command line, with .jshintrc files.
The added benefit of this approach is that you can commit the .jshintrc file to your repository and ensure that anyone who works on the project is working with the same JSHint rules, rather than their own system-wide settings.
I'm trying to install behat + mink (on kohana framework, not symfony, I'm putting behat into the modules folder - I'm writting this just in case, but I guess that's not what causes my problem).
I am having the same search.feature file as it is in behat documentation, I'm changing features/bootstrap class into the:
<?php
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;
/**
* Features context.
*/
class FeatureContext extends MinkContext
{
}
And when I type "behat" in the CLI I get the following error: Call to a member function getSession() on a non object in .....RawMinkContext.php on line 80.
I've read somewhere that it's the behat.yml file which causes this error. I think the right thing to do is to create new behat.yml file in the root of the installed behat folder and put this code inside:
default:
extensions:
Behat\MinkExtension\Extension:
base_url: http://wikipedia.org
goutte: ~
selenium2: ~
paths:
features: features
bootstrap: features/bootstrap
annotations:
paths:
features: features/annotations
closures:
paths:
features: features/closures
But of couse it gives me the same error. I've tried a lot of configurations: copying only extensions part, changing default into context, copying the same content into three other behat.yml files (vendor/behat/behat, and vendor/behat/monk, and vendor/behat/monk-ententions) - none works.
Can someone tell me what's the right way to set this? Maybe someone here also had problems with that...
BTW. When I installed behat withough goutte, only with selenium2 driver, I was getting errors that goutte is not installed. But when I installed it with goutte, I was getting errors that there's no fabpot/goutte directory (or fapbot/, I don't remember, but I guess it was the first one :D), so I deleted everything and reinstalled behat with the following composer.json file, maybe this also has something to do with this error:
{
"name": "behat/mink-browserkit-driver",
"description": "Symfony2 BrowserKit driver for Mink framework",
"keywords": ["Symfony2", "testing", "browser"],
"homepage": "http://mink.behat.org/",
"type": "mink-driver",
"license": "MIT",
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "ever.zet#gmail.com",
"homepage": "http://everzet.com"
}
],
"require": {
"php": ">=5.3.1",
"symfony/browser-kit": ">=2.0.0,<2.2.0",
"symfony/dom-crawler": ">=2.0.0,<2.2.0",
"behat/behat": "2.4.*#stable",
"behat/mink": "1.4.*#stable",
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*"
},
"minimum-stability": "dev",
"autoload": {
"psr-0": {
"Behat\\Mink\\Driver": "src/"
}
},
"config": {
"bin-dir": "bin/"
}
}
The recommended way to install Behat+Mink for anything, not just Kohana, is via Composer. See http://docs.behat.org/quick_intro.html for instructions. The autoload clause you have in your composer.json is not required.
As for your modules attempt, KO3.2 does not yet have the ability to load PSR-0 and so putting it in modules will not allow it to be loaded correctly.
Don't randomly copy your behat.yml - you only need one copy in your project root. If you are worried, you can explicitly load your behat.yml via bin/behat -c /path/to/behat.yml
With your composer.json set up correctly to have mink dependencies, you can then just do bin/behat -dl to verify mink works.
You can then do bin/behat --init to create your features filestructure.
This will create a FeatureContext which overrides Mink's definitions, so add
require_once __DIR__.'/../../vendor/autoload.php';
and change the class definition to:
class FeatureContext extends Behat\MinkExtension\Context\MinkContext
in your features/bootstrap/FeatureContext.php file.
Everything should work as expected now. I recently did a Behat+Mink+KO3 setup, feel free to see how I did it here: https://github.com/Moult/Eadrax/commit/b5dd813c92b82aea29eea13b5a30bae170aa57e6