Home Download Buy Blog Forum Support

Sublimelint + Highlight code remarks plugin

Sublimelint + Highlight code remarks plugin

Postby aroberge on Mon Mar 07, 2011 3:47 am

A major update has been done to my sublimelint plugin (previously forked from linuxbochs's version) which now includes a highlighter for user notes (inspired by the version from theblacklion).

From the help file (available from the console, as described below):
Code: Select all
SublimeLint help
=================

SublimeLint is a plugin intended to support "lint" programs, highlighting
lines of code which are deemed to contain (potential) errors. It also
supports highlighting special user notes (for example: TODO) so that they
can be quickly located.

To enable a background linter to run by default
(provided one exists for the language/syntax the file being viewed), set
the user preference "sublimelint" to true.   If you find that this slows
down the UI too much, you can unset this user preference (or set it to
false) and use the special commands (described below) to run it only
on demand.


Color: user notes
------------------

To customize the color used for highlighting user notes, add the following
to your theme (adapting the color to your liking):
        <dict>
            <key>name</key>
            <string>Sublimelint UserNotes</string>
            <key>scope</key>
            <string>sublimelint.notes</string>
            <key>settings</key>
            <dict>
                <key>foreground</key>
                <string>#FFFFAA</string>
            </dict>
        </dict>

Color: lint "errors"
--------------------

The color used to outline lint errors is the invalid.illegal scope
which should normally be defined in your default theme.

==================================================================

The following information is extracted dynamically from the source
code files and *should* be reflecting accurately all the available
options:
------------------------------------------------------------------

* view.run_command("lint", "user notes")
        Turns background linter off and highlight user notes.

        User notes are "words" that can be specified as a user preference named "my_notes".
        If no user preferences has been set, the following will be assumed:
        my_notes = ['TODO', 'README']

* view.run_command("lint", "PHP")
        Turns background linter off and runs the default PHP linter
        (php - l, assumed to be on $PATH) on current view.

* view.run_command("lint", "Python")
        Turns background linter off and runs the default Python linter
        (pyflakes) on current view.

* view.run_command("lint", "pylint")
        Turns background linter off and runs pylint on current view.

* view.run_command("lint"):
        Displays information about how to use this plugin
       
* view.run_command("lint", "help"):
        Displays information about how to use this plugin
       
* view.run_command("lint", "reset")
        Removes existing lint marks and restore (if needed) the settings
        so that the relevant "background" linter can run.
       
* view.run_command("lint", "on")
        Turns background linter on.
       
* view.run_command("lint", "off")
        Turns background linter off.
       


The code is available from https://github.com/aroberge/sublimelint. User feedback is always welcome.
aroberge
 
Posts: 21
Joined: Sat Feb 12, 2011 1:03 am

Re: Sublimelint + Highlight code remarks plugin

Postby theblacklion on Mon Mar 07, 2011 4:04 pm

Hi :),

I think, the notes plugin should just do nothing by default. I say this because you combined two functionalities into one big plugin which makes it complicated to separate them. As you can guess, I use my own highlighter. Now I want to use your linter integration and eventually run into a conflict.

Regards,
Oktay.

PS Are there improvement/feature requests for my highlighter to support your needs better? I really think, we should not mix each others functionalities but instead improve both. At some points we might also think about points where both plugins would nearly work hand in hand.

UPDATE I've looked into your code a bit and have seen, that the notes plugin would only activate if the syntax contains the string "user notes". That's perfectly fine for me. But I still think that this could be implemented otherwise ;).
theblacklion
 
Posts: 67
Joined: Sat Feb 05, 2011 10:07 pm
Location: Hannover, Germany

Re: Sublimelint + Highlight code remarks plugin

Postby aroberge on Mon Mar 07, 2011 4:42 pm

theblacklion wrote: edited quote: I think, the notes plugin should just do nothing by default. I say this because you combined two functionalities into one big plugin which makes it complicated to separate them. As you can guess, I use my own highlighter. Now I want to use your linter integration and eventually run into a conflict.

UPDATE I've looked into your code a bit and have seen, that the notes plugin would only activate if the syntax contains the string "user notes". That's perfectly fine for me. But I still think that this could be implemented otherwise ;).

PS Are there improvement/feature requests for my highlighter to support your needs better? I really think, we should not mix each others functionalities but instead improve both. At some points we might also think about points where both plugins would nearly work hand in hand.

Parts of the reason why I am writing/releasing these plugins is to explore various ways to do things - for fun.

One of my goals is to have plugins very easily configurable, including the possibility to disable/enable them via user settings - if possible without having to edit other files (like themes) which can not be done temporarily via a user command of the type view.settings().set("blah", "foo").... Rather than asking a plugin-developer to implement a given feature, I'd rather try to do it myself if I can. If someone backports a given feature to an original plugin, I feel vindicated! ;-)

While highlighting code remarks and "linting" are two distinct features, they share a common infrastructure (formating regions of code to have them stand out) which is why I integrating them in one plugin.

Another of my goal is to try to write very readable code [meaning no regular expressions if possible! ;-)], so that others can adapt it easily. I still have some rewriting to do of the plugin as it exists but I am relatively happy with it (hence the public announcement). One thing I'm particularly happy with (others may not agree...) is the "automated" help feature.

As for specific improvement for your highlighter, I would need to take a closer look at the code. After spending a bit of time grokking the regular expression used, I decided to put it aside and just implement the functionality that I needed. I would need to have another look at what your plugin does to be able to comment more meaningfully - something I might be able to do later today.
aroberge
 
Posts: 21
Joined: Sat Feb 12, 2011 1:03 am

Re: Sublimelint + Highlight code remarks plugin

Postby theblacklion on Mon Mar 07, 2011 6:02 pm

I'm not against exploring things and having fun. I'm not against variations/forks. It's just that I have experienced a lot of moments where things got forked and never joined again. This results in people having trouble to decide what the better variant for them might be. In a company this may result in a increased amount of support work necessary for maintaining all the forks. Thus I've learned rather not to publish forks early but rather talk to the author if it could be merged or a fork/variant is really necessary. Often things have been merged and improved the original code nicely.
This is why I'm so sensitive on these things - hope you forgive me ;).

In terms of the automated help feature - I think, I don't get it. Where can I see it?

It would be nice if you could take some time reviewing my code. I'm currently also exploring how to evolve the plugin into something more universal. One conflict I've already found is that it doesn't work with orgmode like it was. Thus I've reduced the amount the regex would eat. At this point I'm happy about any suggestions I can get.

Anyway - thanks for your work so far - the background linter works nicely as it should. No problems so far.
theblacklion
 
Posts: 67
Joined: Sat Feb 05, 2011 10:07 pm
Location: Hannover, Germany

Re: Sublimelint + Highlight code remarks plugin

Postby aroberge on Mon Mar 07, 2011 7:12 pm

theblacklion wrote:In terms of the automated help feature - I think, I don't get it. Where can I see it?


Typing view.run_command("lint") or view.run_command("lint", "help") brings up a new tab displaying all the available help. This help file/tab is generated by extracting a number of selected docstrings and specially named variables ("description" in various modules). Think of this as a more targeted version of the usual Python help() function, but designed to combine the relevant information from a number of related modules.
aroberge
 
Posts: 21
Joined: Sat Feb 12, 2011 1:03 am

Re: Sublimelint + Highlight code remarks plugin

Postby theblacklion on Mon Mar 07, 2011 8:38 pm

aroberge wrote:Typing view.run_command("lint") or view.run_command("lint", "help") brings up a new tab displaying all the available help. This help file/tab is generated by extracting a number of selected docstrings and specially named variables ("description" in various modules). Think of this as a more targeted version of the usual Python help() function, but designed to combine the relevant information from a number of related modules.


Ah - neat :)
theblacklion
 
Posts: 67
Joined: Sat Feb 05, 2011 10:07 pm
Location: Hannover, Germany


Return to Plugin Announcements

Who is online

Users browsing this forum: Google [Bot] and 9 guests