Closed sman591 closed 6 years ago
This must be fixed via the selector. Currently we have 'source.ruby - text.html'. We probably also need to deselect haml files.
Can you check which main selector haml files use?
I can confirm the multiple executions bug, but not the one with the incorrect lint errors. Output for one of my haml files:
SublimeLinter: sublime_linter.py:250: Delay buffer 25 for 0.0s
SublimeLinter: linter.py:886: Checking lint mode background vs lint reason on_load
SublimeLinter: #1 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #2 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #3 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #4 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #1 linter.py:1262: Running ...
SublimeLinter: #2 linter.py:1262: Running ...
SublimeLinter: #3 linter.py:1262: Running ...
SublimeLinter: #4 linter.py:1262: Running ...
SublimeLinter: #5 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #5 linter.py:1262: Running ...
SublimeLinter: #6 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #6 linter.py:1262: Running ...
SublimeLinter: #7 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #8 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #7 linter.py:1262: Running ...
SublimeLinter: #8 linter.py:1262: Running ...
SublimeLinter: #9 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #9 linter.py:1262: Running ...
SublimeLinter: #10 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #10 linter.py:1262: Running ...
SublimeLinter: #11 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #11 linter.py:1262: Running ...
SublimeLinter: #12 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #12 linter.py:1262: Running ...
SublimeLinter: #13 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #13 linter.py:1262: Running ...
SublimeLinter: #14 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #14 linter.py:1262: Running ...
SublimeLinter: #15 linter.py:906: 'rubocop' is linting 'index.html.haml'
SublimeLinter: #15 linter.py:1262: Running ...
SublimeLinter: sublime_linter.py:444: Linting buffer 25 took 10.14s
Can you check which main selector haml files use?
If you tell me how to check that I'll gladly do.
Tools > Developer > Show Scope Name
will open a popup. Make sure the cursor is at the first char of the buffer.
If file starts with a Ruby statement: text.haml meta.line.ruby.haml
If file starts with a Haml expression: text.haml meta.tag.haml punctuation.definition.tag.haml
So I guess setting selector to source.ruby - text.html - text.haml
is what you want.
Please, do a PR and test it, I don't use haml and thus can't do a functional test.
I can confirm the multiple executions bug, but not the one with the incorrect lint errors.
@LeEnno if you add a Ruby error to your Haml, does the error get displayed by SublimeLinter?
I thought this linter originally worked for catching Ruby errors within Haml too, but I could be wrong.
@LeEnno if you add a Ruby error to your Haml, does the error get displayed by SublimeLinter?
No.
Please, do a PR and test it, I don't use haml and thus can't do a functional test.
I'll gladly do, just need some further assistance. I have 0 experience in Python or Sublime development, so please forgive my cluelessness.
.sublime-package
file out of the linter.py
file?.sublime-package
file as a package? Simply add it to Packages/User
?@braver to take it from here. I'm 🏥 🤒
@LeEnno Well, to test this a PR isn't really necessary, we just need confirmation that setting the selector to source.ruby - text.html - text.haml
solves the problem. For that, you can just set the "selector"
setting for this specific linter: http://www.sublimelinter.com/en/stable/linter_settings.html#selector
If this results in the expected behaviour, ie. it lints ruby but not haml, let me know and I can just update the plugin to make that the default.
If you want to know more about developing packages for Sublime Text, some pointers:
A .sublime-package
is really just a zip file that's used as a delivery mechanism. Package Control puts them in "Installed Packages". If you want to make your own package/plugin you can put your files in a subdirectory in "Packages" and ST will read that (i.e. you don't have to zip them into a .sublime-package
file). So, "User" is also a package. You use that directory for settings and overrides, not for developing packages.
More info in https://code.tutsplus.com/tutorials/how-to-create-a-sublime-text-2-plugin--net-22685 and https://www.sublimetext.com/docs/3/
Just tested the manual selector override and it works! Doesn't run the rubocop linter at all for .html.haml
files. I've since installed haml-lint to properly lint haml.
Doesn't run the rubocop linter at all for .html.haml files
Does it still run for ruby?
@braver Thanks a lot for your explanation 👍
I can confirm that changing the selector to source.ruby - text.html - text.haml
makes rubocop stop linting .html.haml
files.
.rb
files still get linted by rubocop.
Thanks all!
When saving a change to a file, it appears SublimeLinter kicks off multiple, duplicate executions rubocop for HAML files.
For example, when I save a one-line file change to a HAML file, the Sublime Text console shows:
(with
"debug": true
)Not only does this kick off duplicate rubocop lints, it emits entirely incorrect lint errors such as:
For almost ever line of haml: