Home Download Buy Blog Forum Support

SublimeLint (Realtime lint highlighting)

SublimeLint (Realtime lint highlighting)

Postby lunixbochs on Sun Jan 30, 2011 3:27 am

This plugin checks for errors in your code *while you write it*. It requires a fairly new beta of Sublime Text X or 2 (after Jon included thread/set_timeout support).

It currently has a rather featureful, platform-agnostic plugin for Python lint highlighting, and a basic PHP plugin which just runs "php -l" and highlights the error line if it finds one.

It's pretty fast. It outlines all lines with errors, and underlines the specific error(s) on each line.
It shouldn't slow down the UI, even with large files (there's a current bug which might cause this sentence to be incorrect, most especially with php lint on windows, but it should be fixed very soon)

It's not perfect.
It fails to underline the actual problem in a few places, like after the first line of multiline function arguments.
It recalculates the entire file after any changes are made instead of just the modified scope.
It chokes on Python parsing errors (completely invalid syntax will underline the offset provided by Python and give the error, but no other errors will be shown until you fix the syntax error)
Fixes for all of these are planned in a future update - I'm working on my own ast parser with scope awareness, real line/column offsets, simpler code, more checked cases, and faster parsing.

However... even the current iteration is infinitely better than waiting till you run/test the code to see errors.
Image

See the project on GitHub
Download the latest GitHub master

You just need to put the file sublimelint_plugin.py and the folder sublimelint directly inside:
  • OS X: ~/Library/Application Support/Sublime Text 2/Packages/User/
  • Windows: %APPDATA%/Sublime Text 2/Packages/User/
  • Linux: ~/.Sublime Text 2/Packages/User/

edit: sentence revisions, added text for php
Last edited by lunixbochs on Sat Apr 09, 2011 7:16 pm, edited 6 times in total.
lunixbochs
 
Posts: 91
Joined: Fri Oct 08, 2010 10:18 pm

Re: SublimeFlakes (Inline realtime Python lint)

Postby jps on Sun Jan 30, 2011 4:06 am

Looks cool! I'll take a look at including the parser module under Linux.

Sublime Text 2 only acquires the GIL when it's calling into Python directly, all other times Python threads are allowed to run. As a consequence of this, the the only thread-safe API function is sublime.set_timeout(), which schedules a function to be run by the main thread.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: SublimeFlakes (Inline realtime Python lint)

Postby marksteve on Sun Jan 30, 2011 4:18 am

Tried it out in Windows 7 64bit. Works like a charm ;)
marksteve
 
Posts: 43
Joined: Thu Sep 30, 2010 6:44 am

Re: SublimeFlakes (Inline realtime Python lint)

Postby lunixbochs on Sun Jan 30, 2011 5:41 am

the 1.x plugin used set_timeout but that implementation seemed to be pretty laggy on 2.
the current thread method works really well speed-wise on my macbook air (which is probably the near the slowest machine sublime will run on sans a netbook)

I only have problems with really long files (this 2k+ python file lines lags sometimes) - I probably won't be able to fix this until I finish my own ast where I have control over more things and can just regenerate a single scope at a time.

even with this huge file, it only looks like I get crashing after reloading the module itself a few times
lunixbochs
 
Posts: 91
Joined: Fri Oct 08, 2010 10:18 pm

Re: SublimeFlakes (Inline realtime Python lint)

Postby Iorlas on Sun Jan 30, 2011 6:20 am

Tried at Ubuntu Linux 10.10. No chances.
Best result with "export PYTHONPATH=/home/iorlas/apps/Sublime\ Text\ 2" + "ln -s /usr/lib/python2.6/lib-dynload/parser.so parser.so" in app dir:
Reloading plugin /home/iorlas/.Sublime Text 2/Packages/User/sublimeflakes.py
Traceback (most recent call last):
File "/home/iorlas/apps/Sublime Text 2/sublime_plugin.py", line 34, in reload_plugin
m = __import__(modulename)
File "./sublimeflakes.py", line 2, in <module>
import os, sys, compiler, re
File ".\compiler\__init__.py", line 27, in <module>
File ".\compiler\transformer.py", line 29, in <module>
ImportError: /home/iorlas/apps/Sublime Text 2/parser.so: undefined symbol: _Py_ZeroStruct

This is symbol, which can be found in the core lib of python or in python itself.
Using find, grep and objdump, i've found this files to prove this thoughts:
/usr/lib/wingide4.0/bin/PyCore/python: file format elf64-x86-64
/usr/lib/python2.6/config/libpython2.6.so: file format elf64-x86-64

I dont know what is "ZeroStruct", but it's suppose to be a something, what needs to be in core => need to wait for program developer. Anyway, we need to wait for "the Creator Voice".
Also, it is so dangerous to see that on linux:
>File ".\compiler\__init__.py"

It can be easier, if "somebody" will open sources or start to work with community.
Iorlas
 
Posts: 13
Joined: Sun Jan 30, 2011 5:47 am

Re: SublimeFlakes (Inline realtime Python lint)

Postby jps on Sun Jan 30, 2011 10:46 am

Version 20110130 of Sublime Text 2 should now allow the parser module to be imported on all platforms.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: SublimeFlakes (Inline realtime Python lint)

Postby Iorlas on Sun Jan 30, 2011 11:56 am

jps wrote:Version 20110130 of Sublime Text 2 should now allow the parser module to be imported on all platforms.

Yay! Now "flakes" works perfectly. Waiting an author of plugin for new version and "flakes".
Iorlas
 
Posts: 13
Joined: Sun Jan 30, 2011 5:47 am

Re: SublimeFlakes (Inline realtime Python lint)

Postby lunixbochs on Sun Jan 30, 2011 1:33 pm

Iorlas wrote:Also, it is so dangerous to see that on linux:
>File ".\compiler\__init__.py"
that's a python module (which comes with python itself) for byte-compiling python code. don't know how you find that dangerous - python itself does this already every time you run a script.
Iorlas wrote:Waiting an author of plugin for new version and "flakes".
not sure what you mean by this
lunixbochs
 
Posts: 91
Joined: Fri Oct 08, 2010 10:18 pm

Re: SublimeFlakes (Inline realtime Python lint)

Postby Iorlas on Sun Jan 30, 2011 2:32 pm

lunixbochs wrote:
Iorlas wrote:Also, it is so dangerous to see that on linux:
>File ".\compiler\__init__.py"
that's a python module (which comes with python itself) for byte-compiling python code. don't know how you find that dangerous - python itself does this already every time you run a script.
Iorlas wrote:Waiting an author of plugin for new version and "flakes".
not sure what you mean by this

Oh, it is due breaking of bold in quotes :C I mean a back-slashes in the path. I see a 4 lines: 2 with slashes and 2 with back-slashes, but all of 'em as python native error message +_+

>Waiting an author of plugin for new version
We want more features, we want stable version, i mean.
>and "flakes".
I call features of SublimeFlakes as "flakes", just a joke :lol:
Iorlas
 
Posts: 13
Joined: Sun Jan 30, 2011 5:47 am

Re: SublimeFlakes (Inline realtime Python lint)

Postby zeeg on Tue Feb 01, 2011 9:30 pm

Ive started working on a fork of this. I'm awaiting a response from the author, but if I don't hear back from him I'll go ahead and setup a GitHub repo which includes the changes.

So far I've swapped it to use a newer/faster version of PyFlakes (which we maintain at DISQUS), and I'm working on better integration of the actual errors so it's a bit more visible. I believe Sublime Text 2's API isnt quite fully fleshed out yet, so it's likely that this wont be too much better until it is.
zeeg
 
Posts: 2
Joined: Mon Jan 31, 2011 9:25 pm

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 4 guests