Sublime Forum

CodeIntel ported from Open Komodo Editor

#81

@dsarch, that is great! What’s the architecture you compiled it for? is it 32 or 64 bytes? Can you compile both architectures? …my email is german dot mb at gmail, please send it over. Thank you!

I have now noticed that other bug that suddenly started to happen for me too… but I have been really busy these days to dig into it. I’ll soon try to fix that issue, which is causing master’s head to fail, and I’ll report back. In the mean time, I made a git tag for SublimeCodeIntel repo, for when the old binaries were working for Windows and Linux (named it version 1.0). I’ll try to start maintaining a CHANGELOG file too.

0 Likes

#82

Brilliant news! This thing is amazing!

0 Likes

#83

Gives me this error -

Reloading plugin /Users/Pravin/Library/Application Support/Sublime Text 2/Packages/CodeIntel/python_codeintel.py Traceback (most recent call last): File "./sublime_plugin.py", line 57, in reload_plugin File "./python_codeintel.py", line 86, in <module> from codeintel2.common import * File "/Users/Pravin/Library/Application Support/Sublime Text 2/Packages/CodeIntel/libs/codeintel2/common.py", line 76, in <module> import SilverCity File "/Users/Pravin/Library/Application Support/Sublime Text 2/Packages/CodeIntel/libs/SilverCity/__init__.py", line 19, in <module> LanguageInfo.do_registration() File "/Users/Pravin/Library/Application Support/Sublime Text 2/Packages/CodeIntel/libs/SilverCity/LanguageInfo.py", line 116, in do_registration import CSS File "/Users/Pravin/Library/Application Support/Sublime Text 2/Packages/CodeIntel/libs/SilverCity/CSS.py", line 42, in <module> class CSSHTMLGenerator(HTMLGenerator.SimpleHTMLGenerator, CSSHandler): File "/Users/Pravin/Library/Application Support/Sublime Text 2/Packages/CodeIntel/libs/SilverCity/CSS.py", line 50, in CSSHTMLGenerator def generate_html(self, file, buffer, lexer = CSSLexer()): File "/Users/Pravin/Library/Application Support/Sublime Text 2/Packages/CodeIntel/libs/SilverCity/CSS.py", line 26, in __init__ _CSSLexerTemplate.__init__(self, properties) File "/Users/Pravin/Library/Application Support/Sublime Text 2/Packages/CodeIntel/libs/SilverCity/CSS.py", line 17, in __init__ WordList(Keywords.css_properties_3), AttributeError: 'module' object has no attribute 'css_properties_3'

0 Likes

#84

@pravim, i posted a fix in the thread (i guess it was in the page 9), it is working fine for me there.

0 Likes

#85

@kronuz,

Done =)

Sent to your email, if you prefer, i can send a pull request on github also.

EDIT: Just sent a pull request with the updated libs (confirmed working on a i386 linux machine, i did not test the x86_64 but i dont see where it could fail)

Thanks for all your work in SublimeCodeIntel.

0 Likes

#86

Hi,

Apologies if this has been asked before, but is it possible to reference packages in Python eggs in the pythonExtraPaths configuration?

I tried the following in .codeintel/config in a project:

{
    "Python": {
        "python": "/usr/local/bin/python2.6",
        "pythonExtraPaths": 
              "/Users/optilude/Development/Plone/Optilux/second-edition/src/optilux.policy",
              "/Users/optilude/Development/Plone/Optilux/second-edition/src/optilux.cinemacontent",
              "/Users/optilude/Development/Plone/Optilux/second-edition/src/optilux.theme",
              "/Users/optilude/.buildout/eggs/Zope2-2.13.8-py2.6.egg",
              "/Users/optilude/.buildout/eggs/zope.testing-3.9.6-py2.6.egg",
              "/Users/optilude/.buildout/eggs/zope.site-3.9.2-py2.6.egg",
              "/Users/optilude/.buildout/eggs/zope.publisher-3.12.6-py2.6.egg",
              "/Users/optilude/.buildout/eggs/zope.processlifetime-1.0-py2.6.egg",
              "/Users/optilude/.buildout/eggs/zope.interface-3.6.3-py2.6-macosx-10.6-x86_64.egg",
              "/Users/optilude/.buildout/eggs/zope.component-3.9.5-py2.6.egg",
              ...
            ]
    }
}

But the packages in those eggs are not picked up. Note that those are all unzipped eggs, and most of them contain namespace packages.

Cheers,
Martin

0 Likes

#87

Hi @kronuz,

+1 for @optilude request, it is great when working in Zope/Plone projects.

Also, great to see you here @optilude, im anxious for your Plone4 book (bought it already in packetpub) =)

All the best !

0 Likes

#88

Okay, I upgraded SublimeCodeIntel to fix “the issue”. Please pull from github :smile:

Thanks to dsarch we now have working binaries for linux again! …only Windows to go.

@dsarch, I merged your pull request, however recently a new file was changed in scintilla (LexPerl.cxx) so a new linux build will be eventually necessary. I hope it’s not much difficult to compile there… could you outline the missing steps? like how you built python with UCS-4 and other bits? (as to include it somewhere in the README)

Regarding the eggs, how would that work? I don’t work much with eggs or .pth files …please if anyone knows exactly how they should be supported, explain and I’ll try to add support for it :wink:

0 Likes

#89

Hello @kronuz,

Done, updated the libs and pushed to github again.

Thanks !

0 Likes

#90

[quote=“Kronuz”]
Regarding the eggs, how would that work? I don’t work much with eggs or .pth files …please if anyone knows exactly how they should be supported, explain and I’ll try to add support for it :wink:[/quote]

Let me try to show you with a buildout.

First, download the file at gist.github.com/1140588 and save it in a new directory as buildout.cfg.

Then go into this directory and run:

$ python bootstrap.py
$ bin/buildout

At this point, you’ll have an ‘eggs’ directory with some files in it and a ‘bin/mkrelease’. This will look a bit like this:

#!/usr/local/bin/python2.6

import sys
sys.path[0:0] = 
    '/Users/optilude/tmp/testbuild/eggs/jarn.mkrelease-3.1-py2.6.egg',
    '/Users/optilude/tmp/testbuild/eggs/lazy-1.0-py2.6.egg',
    '/Users/optilude/tmp/testbuild/eggs/setuptools_git-0.4.2-py2.6.egg',
    '/Users/optilude/tmp/testbuild/eggs/setuptools_hg-0.2.1-py2.6.egg',
    '/Users/optilude/tmp/testbuild/eggs/distribute-0.6.19-py2.6.egg',
    ]

import jarn.mkrelease.mkrelease

if __name__ == '__main__':
    jarn.mkrelease.mkrelease.main()

This is a wrapper script that mangles sys.path with the “working set” of eggs, inserting those eggs directly on sys.path, before executing the main function. If you look at the items it adds to the path, they are directories with Python packages and modules and an EGG-INFO directory with egg metadata.

Note that in some cases (e.g. eggs/jarn.mkrelease-3.1-py2.6.egg/jarn/init.py) these will use setuptools/distribute namespace packages (with some boilerplate in init.py). Assuming setuptools is on sys.path, it should deal with these as sys.path is searched when modules are imported.

Another approach to get some test eggs would be to use virtualenv. For example:

$ virtualenv eggtest
$ cd eggtest
$ bin/easy_install jarn.mkrelease

At this point, we have in lib/python2.6/site-packages an easy-install.pth that looks like this:

import sys; sys.__plen = len(sys.path)
./distribute-0.6.10-py2.6.egg
./pip-0.7.2-py2.6.egg
./jarn.mkrelease-3.1-py2.6.egg
./lazy-1.0-py2.6.egg
./setuptools_git-0.4.2-py2.6.egg
./setuptools_hg-0.2.1-py2.6.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)

These .egg files are the same as the ones found in the eggs/ directory in the buildout. In this case, we rely on the scanning of .pth files in site-packages to tell Python to add the *.egg directories to sys.path, but the end result is the same.

Now, I tried to use a .codeintel/config like this:

{
    "Python": {
        "python": "/usr/local/bin/python2.6",
        "pythonExtraPaths": 
            "/Users/optilude/tmp/testbuild/eggs/jarn.mkrelease-3.1-py2.6.egg",
            "/Users/optilude/tmp/testbuild/eggs/lazy-1.0-py2.6.egg",
            "/Users/optilude/tmp/testbuild/eggs/setuptools_git-0.4.2-py2.6.egg",
            "/Users/optilude/tmp/testbuild/eggs/setuptools_hg-0.2.1-py2.6.egg",
            "/Users/optilude/tmp/testbuild/eggs/distribute-0.6.19-py2.6.egg"
        ]
    }
}

Unfortunately, this didn’t work (e.g. I couldn’t get import completion from the jarn namespace except when actually in a module inside jarn.mkrelease).

Ultimately, what I’d like to do is to write a buildout recipe that spits out such a file when buildout is run. However, the above doesn’t work. I saw some explicit code referencing .egg files and skipping them, but even commenting this out, it didn’t work. I tried to understand how the path loading works in the codeintel package, but I failed. :wink:

Martin

0 Likes

#91

Actually… I think the manually constructed list of .egg paths works, but the problem is that it doesn’t support namespace packages.

I tried with a much bigger set of eggs (a full Plone 4.1 buildout with some development tools), and discovered:

  • Eggs not using namespace packages work (e.g. I can import from ‘feedparser’)

  • For eggs using namespace packages, the first one listed (e.g. zope.i18nmessageid) works, but subsequent ones (e.g. zope.site) does not

If you want to test something like this, try using this buildout.cfg:

[buildout]
extends =
    http://dist.plone.org/release/4.1/versions.cfg
parts = instance

[instance]
recipe = plone.recipe.zope2instance
user = admin:admin
eggs = Plone

The script with paths is now in bin/instance.

Cheers,
Martin

0 Likes

#92

Mmm… I’ve spent a couple of hours trying to understand where the imports are actually made and evaluated, so as to try to see how to make it respect namespace packages, but I can’t really understand it (and debugging plugins without pdb is a pain). If anyone can give some insight into where the imports and sys.path scanning are happening and how they’re used, that may be useful.

Martin

0 Likes

#93

[quote=“sublimator”]Not sure what your trying to do atm but I don’t think Sublime even ships with distutils letalone setuptools/distribute required for namespace packages to work.
[/quote]

Which Python interpreter does it use? I assumed it was /usr/bin/python, but maybe not?

I tried to make this work on OS X, but installing it was a pain (it doesn’t support 64-bit Python). I got it running, but then couldn’t figure out how to set a breakpoint that was actually triggered.

[quote]

Are you talking something specific to the CodeIntel plugin or … ?[/quote]

Let’s say I type “from zope.”. When I press “.” the CodeIntel plugin starts looking for completions, i.e. modules and packages inside the zope package. Right now, it seems to take the first thing it can find (usually “zope.i18n” on my system). Somehow, it needs to realise there are lots of other things inside “zope.”.

Looking at the blobs in ~/.codeintel/db, I’m pretty sure it actually finds all the relevant packages and modules when the ‘pythonExtraPaths’ list lists a bunch of .egg directories. The problem has to be in the way it does the search over the database.

Martin

0 Likes

#94

Are you sure? On OS X at least, I can do this in the console:

>>> import sys
>>> sys.executable
'/usr/bin/python'
>>> sys.path
'/Users/optilude/Library/Application Support/Sublime Text 2/Packages/SublimeCodeIntel/libs', '/Library/Python/2.6/site-packages/mr.igor-1.2-py2.6.egg', '/Library/Python/2.6/site-packages/pyflakes-0.4.0-py2.6.egg', '/Library/Python/2.6/site-packages/docutils-0.7-py2.6.egg', '/Library/Python/2.6/site-packages/ZopeSkel-2.17-py2.6.egg', '/Library/Python/2.6/site-packages/Cheetah-2.2.1-py2.6-macosx-10.6-universal.egg', '/Library/Python/2.6/site-packages/PasteScript-1.7.3-py2.6.egg', '/Library/Python/2.6/site-packages/PasteDeploy-1.3.3-py2.6.egg', '/Library/Python/2.6/site-packages/Paste-1.7.4-py2.6.egg', '/Library/Python/2.6/site-packages/zc.buildout-1.5.0b2-py2.6.egg', '/Library/Python/2.6/site-packages/pip-0.7.2-py2.6.egg', '/Library/Python/2.6/site-packages/python_subunit-0.0.6-py2.6.egg', '/Library/Python/2.6/site-packages/testtools-0.9.5-py2.6.egg', '/Library/Python/2.6/site-packages/junitxml-0.5-py2.6.egg', '/Library/Python/2.6/site-packages/distribute-0.6.15-py2.6.egg', '/Library/Python/2.6/site-packages/Sphinx-1.0.7-py2.6.egg', '/Library/Python/2.6/site-packages/Jinja2-2.5.5-py2.6.egg', '/Library/Python/2.6/site-packages/Pygments-1.4-py2.6.egg', '/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.6/site-packages', '/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.6/site-packages/wx-2.8-mac-unicode', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Python/2.6/site-packages', '/usr/local/lib/wxPython-unicode-2.8.12.1/lib/python2.6', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode', '.']
>>> import setuptools

As I said, though, my suspicion has shifted away from an ability to actually import stuff towards the algorithm used to match the contents of ~/.codeintel/db/* during an autocomplete when there are multiple blobs that have the same namespace package prefix.

Martin

0 Likes

#95

Good to see you’ve got binaries compiled! I’m still having the same error as before, however, on Fedora Core 64-bit. I get: “ImportError: Could not find a suitable _SilverCity binary for your platform and architecture.” Am I missing any steps?

0 Likes

#96

Hello,

Can you update your repository (git pull origin master) ? I just updated for x86_64 libs (the ones in the repo did not work for some reason on Archlinux x86_64).

These libs (.so) fixes it (it is working great on Archlinux x86_64 here).

Thanks !

0 Likes

#97

Hmm, I tried that, and I still get the same error. I’d build it here, but this is a machine I don’t have root access to.

0 Likes

#98

Hey guys,

This package seems awesome.

I have however, found a bug (or feature). I downloaded CodeIntel directly from Github using Mercurial with the hg-git extension and couldn’t get CodeIntel to work (just kept saying it was building the cache–“don’t despair”). I left the package working for 6 hours and it still had not finished.

By now, almost despairing, I decided to see if there were any permission issues (I’m running Windows 7 Ultimate x64), so I ran SysInternals ProcMon to see what was going on. I found thousands of requests to the folder: “C:.git\refs\heads\master”.

Just to see what would happen I created that folder tree it was looking for and CodeIntel IMMEDIATELY started to work (thought there are still errors coming up in the Sublime Text 2 console.

I have filed a bug report / issue on Github at: https://github.com/Kronuz/SublimeCodeIntel/issues/17

I hope this helps someone else out :smile:

0 Likes

#99

Can someone please help me? This looks awesome (like… my dream), but I can’t get it working right. Basically it doesn’t respond at all or do any IntelliSense like in this video. Also, I can press certain key combinations or click on keywords and the Sublime status bar will say: “Info: Updating Indexes… The first time this can take a while. Do not despair!” It will say that for hours, so I don’t think it’s actually fetching or updating anything.

I’m on Vista 32-bit. I downloaded the zip and put the contents into: C:\Users\aple\AppData\Roaming\Sublime Text 2\Packages\SublimeCodeIntel (I renamed the folder in the zip from Kronuz-SublimeCodeIntel-6f24b08 to SublimeCodeIntel - is that okay?)

Here is my configuration file: http://pastie.org/2396560

I read here that you’re supposed to update this config file to point to relevant libraries for the languages you want, but I’m not really sure what to put in there. I know the …/Contents/MacOS path is wrong, but I’m not sure where to get these libraries or where to put them on my hard drive (I know… I suck).

Basically I want these libraries with IntelliSense: CSS, jQuery, JS, PHP, WordPress & Drupal (if they exist), Python 2, Python 3, and Django.

Any help with getting this all setup would tickle me to death. I’ve read through this entire thread and looked other places for help, but just can’t figure it out. Thanks a lot guys. Just discovered ST2 and once I get this plugin working, I’ll never switch IDE’s again. :smile:

0 Likes

#100

Same problem here, windows7 home premium 64bits, freeze on updating indexes and cpu goes to 80%.

0 Likes