Better JavaScript
Fixes to Sublime Text's JavaScript symbol list
Details
Installs
- Total 34K
- Win 18K
- Mac 10K
- Linux 6K
Dec 21 | Dec 20 | Dec 19 | Dec 18 | Dec 17 | Dec 16 | Dec 15 | Dec 14 | Dec 13 | Dec 12 | Dec 11 | Dec 10 | Dec 9 | Dec 8 | Dec 7 | Dec 6 | Dec 5 | Dec 4 | Dec 3 | Dec 2 | Dec 1 | Nov 30 | Nov 29 | Nov 28 | Nov 27 | Nov 26 | Nov 25 | Nov 24 | Nov 23 | Nov 22 | Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 3 | 0 | 3 | 0 | 1 | 2 | 0 | 0 | 1 | 1 | 1 | 3 | 0 | 1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 2 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 1 |
Mac | 0 | 0 | 0 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
Readme
- Source
- raw.githubusercontent.com
Sublime Better Javascript
This package is an improved version of Sublime Text's JavaScript package, focused mainly on improving symbol navigation.
The default JavaScript language definition in Sublime Text has quirky symbol identification, and fills your symbols list with noise like anonymous functions, object instantiation, and even calls to console.log().
This project fixes Sublime so only named function definitions and function prototype attributes show up in the symbol list. It also fixes how these symbols are displayed in the symbol list, so that only the function names are shown.
This package has been tested on Sublime Text 2 and 3.
Installing
Install via package control (search for 'Better JavaScript').
Alternatively, cd
to you Sublime packages directory, then:
git clone git@github.com:int3h/sublime-better-javascript.git 'Sublime Better JavaScript'
Refreshing the symbols of existing files
In some cases, especially with Sublime Text 3, the symbols list of files that have been previously opened may not refresh with the improved symbols.
The most reliable way I've found to fix this is to close all open JavaScript files and quit Sublime (it's important that all JS files are closed when Sublime exits.) Then delete the Index
and Cache
subdirectories in your Sublime user data directory (the parent of the Packages
directory.) In Mac OS X, I've also had to delete ~/Library/Caches/com.sublimetext.3 (or com.sublimetext.2).
Uninstalling
Before uninstalling Better JavaScript, be sure close all open JavaScript/JSON files, and remove “JavaScript” from the “ignored_packages” list in your Sublime user settings. You can now safely uninstall the Better JavaScript package.
It's normal to see a few errors from Sublime about not being able to find syntax files. Just exit Sublime and re-open it, and everything should be fixed.
Details
The default JavaScript.tmLanguage makes some… odd decisions on what namespace to put certain tokens in. Specifically, it puts a lot of tokens in the entity.name.* namespaces that probably shouldn't be.
There is a file, Symbol List Banned.tmPreferences
, in the JavaScript package which ostensibly is supposed to filter out some specific sub-namespaces from the symbols list, but it doesn't really work. I modified Symbol List Banned.tmPreferences
to specifically match object instantiation and console.log calls, and set them to not show up in the symbol list.
I also modified Symbol List Function.tmPreferences
to do additional processing of function names with regexes, to strip out extraneous characters (like “function” and “= function()”) before showing them in the symbol list. An additional file, Symbol List Prototype.tmPreferences
, was added to include function prototype attributes in the symbol list.