Sublime Forum

Sublimelint + Highlight code remarks plugin

#1

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]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):

name
Sublimelint UserNotes
scope
sublimelint.notes
settings

foreground
#FFFFAA

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.
    [/code]

The code is available from https://github.com/aroberge/sublimelint. User feedback is always welcome.

0 Likes

#2

Hi :smile:,

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 :wink:.

0 Likes

#3

[quote=“theblacklion”] 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 :wink:.

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.
[/quote]

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! :wink:

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! :wink:], 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.

0 Likes

#4

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 :wink:.

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.

0 Likes

#5

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.

0 Likes

#6

Ah - neat :smile:

0 Likes