Giter VIP home page Giter VIP logo

sublime-levels's Introduction

Levels

SublimeText plugin for scope context coloring. Inspired by Douglas Crockford idea

By Sasha Mazurov ([email protected])

Supported languages

  • JavaScript: Uses my eslevels and V8 Python binding — PyV8

How to install

WARNING: this plugin may not work at all in some OSes since it written in JavaScript and uses PyV8 and Google V8 binaries to run.

  • Use Package Control: Preferences -> Package Control -> Install Package - > Levels

or

  • Clone or download git repo into your packages folder (In SublimeText Preferences->Browse Packages... menu item to open this folder):

WARNING: When plugin is installed, it will automatically download required PyV8 binary so you have to wait a bit (see Loading PyV8 binary message on status bar). If you experience issues with automatic PyV8 loader, try to install it manually.

Available commands

  • Enable scope context coloring: Levels: Update Ctrl+Shift+L

  • Restore original coloring: Levels: Off Ctrl+Shift+O

  • The code is automatically colored after a save action.

Options

  • The live coloring mode is switched off by default (the current plugin version works slow for large scripts). You can enable it in settings by "live": true.

  • Javascript coloring support two modes: "mini" - highlight only "important" language constructions and "full" - highlight whole scopes. You can set this options by changing javascript_mode value in settings.

Mini mode

Theme customization

By default the plugin use a modified version of the default theme Solarized (Light). If you want to use your favorite theme, you need to add new scope coloring rules like in plugin's Levels-light.hidden-tmTheme:

    <dict>
            <key>name</key>
            <string>Level0</string>
            <key>scope</key>
            <string>level0</string>
            <key>settings</key>
            <dict>
                <key>foreground</key>
                <string>#FDF6E3</string>
            </dict>
        </dict>
    ...
        <dict>
            <key>name</key>
            <string>Level9</string>
            <key>scope</key>
            <string>level9</string>
            <key>settings</key>
            <dict>
                <key>foreground</key>
                <string>#cf9369</string>
            </dict>
        </dict>

, and update color_scheme value in plugin settings (applied only for scope coloring mode) or in default user settings.

Known issues.

Eslevels library

If you would like to be sure that your coloring problem is in eslevels and not in this plugin you can check your code on this page. If you have the same problems there then it means that the problem is in Eslevels library (or in your code)

Credits

sublime-levels's People

Contributors

mazurov avatar varemenos avatar

Stargazers

Glenn 'devalias' Grant avatar  avatar Justin Missingham avatar Milind Mishra avatar  avatar Qdigital avatar Raul Melo avatar Carlos Guimaraes avatar Burak Özkırdeniz avatar Brandon Coleman avatar Corbin Crutchley avatar Aravinthan.K avatar Gonçalo Mendes Cabrita avatar Theophilus Omoregbee avatar Gabriel Valdivia avatar Francois Bouet avatar ladershowitz avatar zacklocx avatar  avatar Chetan Sachdev avatar Maciej Sawicki avatar Arunas Ivanauskas avatar Andy avatar Ali Torki avatar Hugo avatar Ardiansyah avatar Norman Sue avatar Lucas Azzola avatar Jesse McIntosh avatar Strider avatar Aria avatar Diogo Felix avatar Adrian Li avatar Sergei Senchilo avatar Josh Buchea avatar Tyler avatar Gethin Oakes avatar Andrew Gerst avatar Chris avatar Paulo Torrens avatar Stefan avatar Gordon Buhler avatar Alex Lambiris avatar jon ⚝ avatar Stein avatar  avatar Ejaaz Merali avatar Stu Kabakoff avatar GT Deng avatar Angus H. avatar B.E. Henriksen avatar Andre Asselin avatar Ashar avatar Ye Wang avatar Nguyen Thong avatar Honza Černý avatar Aleksej avatar clojj avatar Андрей Листочкин (Andrei Listochkin) avatar jero avatar William Falk-Wallace avatar Ivan Ablogin avatar Dan Rasmuson avatar Basuke Suzuki avatar J. avatar Luke Plaster avatar Prince John Wesley avatar Senthil Porunan avatar Amr Elsayed avatar Jiri Spac avatar Harish avatar Christian Bromann avatar Ian Walker-Sperber avatar  avatar Cristhian Valencia B. avatar Eugene Chernyshov avatar Oleksandr Nikitin avatar Laurent Villeneuve avatar Eric Lawrence avatar Marius Lundgård avatar Karthick Manoharan avatar  avatar Monk Town avatar Jordan avatar John Henry avatar Justin Makeig avatar Jonathan Tan avatar Gabriel Dumitrescu avatar Nima Hemmati avatar Mohammad Reza Taesiri avatar Mohammad Sadegh Khoeini avatar Behrang Norouzinia avatar Emily Marigold Klassen avatar Michał Lipiński avatar Daniil Pintjuk avatar Buck O'Leary avatar Bob Cao avatar Armando avatar  avatar PPxu avatar

Watchers

 avatar Marcelo Ramos avatar Rakhmad Azhari avatar  avatar James Cloos avatar Krister Kari avatar Ilia Akhmadullin avatar Harsh Singh avatar Chris avatar Ivan Ablogin avatar  avatar

sublime-levels's Issues

CoffeeScript...

Sorry, I have to say the 'C' word here, I just wondered if there might be any chance this will get applied for CoffeeScript?

Self is not colored properly

Self is correctly colored green the first time. Then the second time it turns yellow. I'm guessing it's a js-lint thing.
Selection_055

Plugin broken on this code, but works in online demo

I am able to run this plugin on simple code, but when I tried it on a bit more complex of code, it breaks.

This is the code in question:

"use strict";

var stockTickerUI = {

	updateStockElems: function foo(stockInfoChildElemList,data) {
		var getDataVal = curry( reverseArgs( prop ), 2 )( data );
		var extractInfoChildElemVal = pipe(
			getClassName,
			curry( stripPrefix )( /\bstock-/i ),
			getDataVal
		);
		var orderedDataVals =
			map( extractInfoChildElemVal )( stockInfoChildElemList );
		var elemsValsTuples =
			filterOut( function updateValueMissing([infoChildElem,val]){
				return val === undefined;
			} )
			( zip( stockInfoChildElemList, orderedDataVals ) );

		// !!SIDE EFFECTS!!
		compose( each, spreadArgs )( setDOMContent )
		( elemsValsTuples );
	}

};

As far as I can tell, there's nothing weird or unsupported about that code. In fact, it highlights fine in the online demo:

screen shot 2017-11-29 at 8 56 14 am

However, using the plugin in my ST3, it fails to do any highlighting. I see the following error in the ST3/mac console:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "levels_plugin in /Users/ABCXYZ/Library/Application Support/Sublime Text 3/Installed Packages/Levels.sublime-package", line 176, in run
  File "levels_plugin in /Users/ABCXYZ/Library/Application Support/Sublime Text 3/Installed Packages/Levels.sublime-package", line 135, in update_view
  File "/Users/ABCXYZ/Library/Application Support/Sublime Text 3/Installed Packages/Levels.sublime-package/levels/js.py", line 98, in run
PyV8.JSError: JSError: Error: Line 15: Unexpected token [ (  @ 3859 : 18 )  ->             throw e;

What's wrong, why is it failing to highlight on my code?


Actually, in addition to this failure to parse my code, the plugin gets into a totally broken state:

  1. It switches the color scheme, and then fails, and does no highlighting. In other words, in this error state, it's not gracefully turning itself back off and undoing the color scheme.

  2. Once it's "broken" like this, I can't even turn the plugin back off. Ctrl+Shift+O and the command palette entry Levels: Off both are unresponsive and don't turn off the plugin to restore the color scheme.

  3. The only way to restore my correct color scheme is to close the tab and re-open that file.

I would expect that if the plugin has any error at all, whether that be internal or whether it be simply failing to parse the code, it should stay in a disabled state, and probably give some sort of error message or indication of what went wrong.

It should not break in the current way, which leaves it hung and unresponsive to any further commands.

Support for for..of loops

If my code contains any for..of loops, I get an "unexpected identifier" error in the console and no code is colored. If I swap the 'of' to 'in' everything colorizes fine (though of course the code breaks..)

Both types of loops work fine in the eslevels test page.

The plugin does not work from zipped package (sublime-package) in ST3

I've just updated Package Control from git and found that Package Control now store files only as sublime-package in "Installed Packages" folder and don't unpack it to Packages. The plugin does not work now from archive. So we could not install it with the new version of Package Control in ST3 (use manual installation). Reference to issue #4.

Make Globals Standout

Hey, I use Levels often while coding, switching back and forth to ensure my variable scopes are all correct. Probably the biggest issue in Javascript with scope that I see is people forgetting the var keyword, defaulting a variable to global. With the initial color scheme in Levels you actually can't see this, as global variables are set to have the same color as the background.

To fix this, what I normally do is change the Level-1 foreground to a high contrast color for the theme, for example:

levels

Think this would be a sensible change to make to the github repo, so everyone can see globals easily?

Coffeescript

Are plans in the works to have this plugin work with Coffee Script?

levels has to be activated each time I open a file

Not sure if this is the intended behavior, but it's a little annoying to have to activate the plugin all the time. BTW I'm running ST3, and I don't see any errors in the console when using the plugin.

Use user's theme by default instead of Solarized (Light)

First of all, thanks for the plugin 👍

I would like the plugin to use the theme that the user has defined in the ST settings by default. Currently I have to go and manually add the theme I want Levels to use instead of Solarized (Light).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.