Sublime Forum

SublimeLint (Realtime lint highlighting)

#25

For those interested, I have created a fork of Ryan’s excellent plugin. You can find my version at github.com/aroberge/sublimelint . I have not changed the readme file nor added any copyright information. I expect Ryan to implement some/all of the new functionality that I have added eventually. I reorganized the code significantly and changed quite a few names so that I could find it easier to read and understand; your mileage may vary.

The main addition, as compared with Ryan’s version is that one can use pylint - but not in realtime. pylint is quite slow, and I have it setup so that it is run on demand. NOTE that you need to have pylint already installed - unlike pyflakes which comes included with the plugin.

Some small differences:

  1. to enable the plugin to work by default, you need to set a user preference “sublime_linter” to true.
  2. you can turn on/off the linter via a command view.run_command(“linter_on”) (or “linter_off”) - even if you have not set a user preference before.
  3. To run a linter “once” (i.e. not always on in the background), you use
    view.run_command(“run_linter”, “linter”) where “linter” is one of “Python”, “PHP” or “pylint”
  4. If you run a linter via a command as in 3. above, the realtime linter is disabled. To reset it to its previous state (on or off…) AND to clear all visible “errors” you use the command
    view.run_command(“reset_linter”)

For some reason, the configuration file for pylint is not read in … I tried various options but could not get it to work. I’ve turned off a couple of things but you may find that pylint reports too many errors to your liking … I’ll try to improve upon it - but suggestions/patches are most welcome.

Also, I found that I simply could not use the subprocess approach used for the php linter (it could not find “pylint” …) and had to resort to importing the pylint module itself. Unfortunately, this means that if you want to work on the pylint plugin itself, you may have to quit Sublime Text and restart to see changes take place (unlike the situation for the other plugins, thanks to some very nice code originally written by Ryan).

0 Likes

#26

I don’t always install plugins, but when I do, they’re awesome like yours.

Great job.

0 Likes

#27

If you’re looking for PEP 8 highlighting, check my fork at github.com/Kronuz/SublimeLint It also improves a few things such as improved (less aggressive, CPU-wise) real time highlighting.

0 Likes

#28

like “goto symbol”?
I’m waiting to do anything really fancy with the python module till I finish switching to my own ast implementation: github.com/lunixbochs/sublimeli … /python.py

0 Likes

#29

I tried it, but it is not doing real time linting of python. I have pylint and pep8 installed. What am I missing?

When I run it from the console, I get the following error:

File "./sublimelint/modules/sublime_pylint.py", line 84, in run ValueError: invalid literal for int() with base 10: '53,0'

0 Likes

#30

@aparajita, instead of pylint, I use pyflakes and the pep8, in the python.py module. The error you’re getting probably comes from a misconfigured pylint (called by sublime_pylint.py)… you can try disabling pylint (and/or deleting the pylint command)

0 Likes

#31

This is working perfectly for me, thanks.

Is there a nicer way to highlighting the errors/text? It only seems to add a border, which is a bit hackish. No way to change the scope of the text and use the theme properly?

0 Likes

#32

There is no way to change the scope of text, that is determined by the syntax. If you pull the latest version of https://github.com/Kronuz/SublimeLint, I added support for setting the background/foreground of the offending lines themselves, not just an outline of the line. You can set those colors yourself by modifying the theme. This makes errors much more obvious. Soon there will also be support for going to the next/previous error.

0 Likes

#33

[quote=“aparajita”]

There is no way to change the scope of text, that is determined by the syntax. If you pull the latest version of https://github.com/Kronuz/SublimeLint, I added support for setting the background/foreground of the offending lines themselves, not just an outline of the line. You can set those colors yourself by modifying the theme. This makes errors much more obvious. Soon there will also be support for going to the next/previous error.[/quote]

Excellent, this is exactly what I was after. Thank you!

Is there a way to turn off the little X?

0 Likes

#34

Currently no. I’ll add it as a setting.

0 Likes

#35

Just a quick note ( i dont know if was here already, please forgive me i didn’t read all thread ):
On windows, you kind of need to add PHP directory to your PATH variables, otherwise php lint won’t work. On win7 you can do it like this:

Press win+pause. In the window that opened, pick “advanced system settings” from the sidebar. In the new window that opens pick “environment variables”. Double click on the PATH variable and, at the end of the string add the path to PHP dir
Don’t forget the semicolon!

Restart Sublime and enjoy this great plugin!

Probably you need to do the same for each language (Py, perl and so on).

0 Likes

#36

[quote=“aparajita”]

Currently no. I’ll add it as a setting.[/quote]

The latest version of this fork http://github.com/Kronuz/SublimeLint adds the following features:

  • You can now jump directly to the next/previous lint error using ctrl+super+e/ctrl+super+shift+e (OS X) or ctrl+alt+e/ctrl+alt+shift+e (Linux and Windows).

  • By default jumping to the next/previous error will wrap around, you can turn that on or off explicitly with the “sublimelint_wrap_find” setting.

  • Gutter marks are off by default. They can be turned on by setting the “sublimelint_gutter_marks” setting to true.

  • You can disable specific linters by including the language names in the “sublimelint_disable” setting array.

0 Likes

#37

Oh yeah, I forgot to mention that lint support has been added for Objective-J using a built-in capp_lint. I now have a customized ST2 port of the TextMate Cappuccino bundle available as well:

https://github.com/aparajita/Cappuccino-Sublime

0 Likes

#38

Linting no longer seems to work for me, with the latest version.

0 Likes

#39

Which language are you trying to lint, which fork of sublimelint?

0 Likes

#40

[quote=“aparajita”]

Which language are you trying to lint, which fork of sublimelint?[/quote]

I’m using github.com/Kronuz/SublimeLint.git

It was working a few days ago, so it is a recent thing.

0 Likes

#41

[quote=“rdougan”]

Which language are you trying to lint, which fork of sublimelint?

I’m using github.com/Kronuz/SublimeLint.git

It was working a few days ago, so it is a recent thing.[/quote]

There must be some error messages in the console. Try opening SublimeLint/sublimelint_plugin.py, save it, then see what the console says.

0 Likes

#42

Writing file /Users/Robert/Desktop/untitled.js with encoding UTF-8 Traceback (most recent call last): File "./sublime_plugin.py", line 147, in on_post_save File "./sublimelint_plugin.py", line 594, in on_post_save File "./sublimelint_plugin.py", line 302, in queue_linter File "./sublimelint_plugin.py", line 286, in select_linter TypeError: argument of type 'NoneType' is not utterable

0 Likes

#43

I fixed it myself by removing the check to see if the language is disabled. I’m not familiar enough with python to fix it properly…

0 Likes

#44

Change line 283 to:

disable = view.settings().get(‘sublimelint_disable’, ])

0 Likes