Sublime Forum

CodeIntel ported from Open Komodo Editor

#1

I have the first version of the CodeIntel2 ported from Komodo to Sublime Text 2 (Mac OS X only at the moment… maybe someone’s willing to compile the needed modules for other platforms, let me know)

You need only to untar the file into Packages and that’s it… as you start writing, you’ll get “code intellisense” suggestions. I’l still working on finding out how to do the “Jump to symbol declaration”… and Sublime needs more flexible ways to display menus (with icons perhaps and different fonts)… as well as advanced tooltips, so that I can show function calls with parameters information and documentation.

*UPDATE: Older files removed. Get the plugin from GitHub:

http://github.com/Kronuz/SublimeCodeIntel

Don’t despair! The first time you use it it needs to build some indexes and it can take more than a few seconds (around six in my configuration).

Please let me know how it goes for you.

EDIT: I added a screencast at Jing for showing the features off:
screencast.com/t/wXFuTAvDRg

Kronuz.

0 Likes

Selectively trigger commands on user input
#2

New improved version now with “Jump to Definition” working!

*UPDATE: Older files removed. Get the plugin from GitHub:

I created a github repository to keep the plugin and make it easier for you to download just whatever changed between releases:
http://github.com/Kronuz/SublimeCodeIntel

0 Likes

#3

The above links are now obsolete, get the latest from my github. Many improvements have been worked out (including the mouse click for jumping to symbol definitions) and it’s now everything is working much much better. I’d say it’s pretty much ready now :smiley:

Full code intellisense, function tips and go to definitions in Sublime!

Please, report any bugs, suggestions or thoughts.

0 Likes

#4

Holy crap dude, this is wonderful.

Possible bug (or maybe I’m just misunderstanding something): Whenever I’m inside a function, I seem to be getting a lot of Warning: eval <blah blah blah> in the status bar, and only sometimes the actual function information. Is this a config problem?

EDIT: I’m also getting similar errors when trying to use the jump to definition stuff on functions:

Warning: eval 'functionname' <blah blah blah>
0 Likes

#5

@paulstraw, Please pull the new version from github. This one logs errors and stuff to ~/.codeintel/codeintel.log. Please try it and post the logs somewhere if you feel you’ve found a problem. Thank you for your feedback. :smile:

0 Likes

#6

Now it doesn’t seem to be working at all. I’m getting errors like this in ~/.codeintel/codeintel.log:

codeintel: ERROR: evaluating 'someFunction' at filename.js#123: could not resolve first part of 'someFunction'
codeintel.db: INFO: updating <catalog zone>: 1 catalog dir(s)
codeintel.db: WARNING: the following catalog selections didn't match any loaded API catalog: 'Mozilla Toolkit', 'Ext_30'
0 Likes

#7

@paulstraw, pull again and try the new changes I made. By checking the log, there doesn’t seem to be a problem.

This line is normal, it states that “someFunction” definition wasn’t found:

codeintel: ERROR: evaluating 'someFunction' at filename.js#123: could not resolve first part of 'someFunction'

This line says it couldn’t find a couple catalogs:

codeintel.db: WARNING: the following catalog selections didn't match any loaded API catalog: 'Mozilla Toolkit', 'Ext_30'

I’ll check further into this if you send me a sample file with the problem and the logs you’re getting. Please first pull again as I fixed some issues.

0 Likes

#8

The problem is that ‘someFunction’ exists though (I just changed the function name in that snippet).

After playing with it a bit more, it seems the problem may be that CodeIntel is having trouble/doesn’t support traversing directories. In the attached example, I can’t get usingObject.js to see things from someObject (inside someObject.js), but if I move it out of ./subfolder (and let the index rebuild), it works fine. The same problem seems to happen when someObject is inside ./subfolder and usingObject is outside.

Uhh, hopefully that’s clear. I’m tired.
codeIntelTest.zip (2.4 KB)

0 Likes

#9

@paulstraw, I have made some changes that fix some other edge problems so please pull the most recent code… But here, the problem is really not a problem, it’s just a matter of misconfiguration… with javascript you just use files, and each file needs to be located somehow. Since it doesn’t have an “import” command, it’s impossible to know where the files are located by just guessing (files could be anywhere in your hard drive). So you must tell where all the directories containing javascript files are. You do this by creating a ‘.codeintel’ folder and a configuration file called ‘config’ in either your home directory (~/.codeintel/config) or your project root directory (codeIntelTest/.codeintel/config) and adding the paths there:

{
	"JavaScript": {
		"javascriptExtraPaths": 
			"subfolder",
			"/some/other/weird/absolute/subfolder",
			"some/relative/subfolder/to/the/project",
			"~/some/subfolder/in/your/home/directory"
		]
	}
}

Basically what that says is that for language “JavaScript”, you want some additional paths to be added, that contain more javascript files that will be used, by setting “javascriptExtraPaths”. It adds the project folder itself to the extra paths, as wel as some extra “subfolder” directories.

In this particular case, the file “config” is not really needed, as CodeIntel will search inside the project’s root folder for JavaScript files in up to 10 levels… however, you must still flag the root of your project by adding an empty folder named “.codeintel”. That alone should solve the problems you were having. For your example, simply create the directory called “codeIntelTest/.codeintel”, and then it’ll work as expected.

0 Likes

#10

Ah, yeah, that did the trick. Would there be any way for you to autogenerate that folder if it doesn’t exist? Seems like it would make sense, no?

Either way, thanks for your help, appreciate it! Fantastic, very useful plugin.

0 Likes

#11

Everyone, I just added the binaries to support Linux (32 and 64 bits) and Windows (32 bits only) …still really untested, we need people testing those platforms, anyone plz?

@paulstraw: Well, the problem there is it’s impossible to know where your project root is. If you open a file, and no .codeintel is found above it, it will now at least use the directory the file you opened as the root… but that’s far from perfect.

0 Likes

#12

Hi @kronuz,

How did you built the binaries ?

Im using archlinux (which uses python 2.7) how can i build these binaries here ?

Thanks for this wonderful plugin !

0 Likes

#13

Hmm. After pulling the latest version, it seems to have stopped working. Here’s all I’m getting in the log:

Catalogs for 'JavaScript': dojo, Ext_30, HTML5, jQuery, MochiKit, Mozilla Toolkit, Prototype, XBL, YUI

================================================================================
Starting CodeIntel for /somefile.js@1234 [JavaScript] (defns)
Catalogs for 'JavaScript': dojo, Ext_30, HTML5, jQuery, MochiKit, Mozilla Toolkit, Prototype, XBL, YUI

Nothing appears in ~/.codeintel/db and the “Updating indexes” message just sits there in Sublime (for over 30 minutes so far). Tried removing the folder in Packages as well as ~/.codeintel and re-cloned the repo with the same results.

0 Likes

#14

@dsarch, It’s in the src directory. You need to build those libraries and get the two .so files (_SilverCity.so and ciElementTree.so). Use the provided patches to parch the files… It’d be running something like this to compile the libs:

tar xzf scintilla210.tgz
cd scintilla
cat ../scintilla*.patch | patch -sup1
cd ..

tar xzf SilverCity-0.9.7.tar.gz
cd SilverCity-0.9.7
cat ../SilverCity*.patch | patch -sup1
python setup.py build
cd ..

tar xzf cElementTree-1.0.5-20051216.tar.gz
cd cElementTree-1.0.5-20051216
cat ../cElementTree-1.0.5-20051216.patch/*.patch | patch -sup1
python setup.py build
cd ..

find . -type f -name _SilverCity.so -exec cp {} ../libs/_local_arch \;
find . -type f -name ciElementTree.so -exec cp {} ../libs/_local_arch \;

rm -rf cElementTree-1.0.5-20051216
rm -rf SilverCity-0.9.7
rm -rf scintilla

…or pull the new version and go to the src directory and do “./build.sh”. That will build both files (hopefully) and copy them to “Package/SublimeCodeIntel/libs/_local_arch/”… Then you need to zip those files and send them over, along with the information of your plataform. It should work afterwords with no further changes. Let me know how it goes for you! :smiley:

0 Likes

#15

@paulstraw, Can you please pull the latest and try again please. Post the full log somewhere and the configuration file(s) if it’s still failing.

0 Likes

#16

Hi @Kronuz,

It built everything great !

After building the libs, i did this:

cd SublimeCodeIntel
cp -R libs python_codeintel.py ~/.config/sublime-text-2/Packages/User

Then i cannot start sublime-text anymore, giving me this error:

$ sublime-text 
Fatal Python error: Interpreter not initialized (version mismatch?)

Do you a hint on how to debug this ?

Thanks a lot for all effort !

0 Likes

#17

@dsarch, unfortunately no… I have no idea what the problem might be :frowning: …perhaps Sublime in linux ships with it’s own python binary and libraries? (most likely) being that the case, you’d have to compile everything again against the same version shipped within Sublime. Though I’m not sure it ships with the header files and development libraries.

Maybe @jps can give us some direction in this regard if he sees this thread… Jon, are you around? :smiley:

0 Likes

#18

[quote=“Kronuz”]Everyone, I just added the binaries to support Linux (32 and 64 bits) and Windows (32 bits only) …still really untested, we need people testing those platforms, anyone plz?
[/quote]

Thanks for your work.
Is it possible to have a 64 bits Windows build ? I haven’t any C compiler on my PC so not any chance to build it myself.
SilverCity is available from http://www.lfd.uci.edu/~gohlke/pythonlibs/ but not elementtree.
It’s probably possible to use the xml.etree package that come with the Python 2.6 from ST2 but it take some work to change all the call to cielementtree.

Someone could help us poor Windows 7 64 bits users ? Thanks.

0 Likes

#19

@bizoo, unfortunately, no… they’re both patched version (SilverCity and cElementTree)… so any binaries you find won’t work :frowning:
it should be pretty easy to build, however I don’t have a windows box to do the build at the moment. Maybe someone else is willing and able to make those binaries available.

0 Likes

#20

I really love this plugin. Unfortunately it has some problems to get my javascript namespaces (dojo style) right. This wouldn’t be an issue if it wouldn’t auto insert them. Maybe the new feature from build 2066 could help here?
“The auto_complete command now takes an optional disable_auto_insert argument”

0 Likes