Skip to content

Commit 85db012

Browse files
committed
v3.0.0-beta released
1 parent b6ad116 commit 85db012

File tree

9 files changed

+501
-128
lines changed

9 files changed

+501
-128
lines changed

Main.sublime-menu

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
"caption": "Preferences",
4+
"children": [
5+
{
6+
"caption": "Package Settings",
7+
"children": [
8+
{
9+
"caption": "SublimeCodeIntel",
10+
"children": [
11+
{
12+
"args": {
13+
"file": "${packages}/SublimeCodeIntel/SublimeCodeIntel.sublime-settings"
14+
},
15+
"caption": "Settings \u2013 Default",
16+
"command": "open_file"
17+
},
18+
{
19+
"args": {
20+
"file": "${packages}/User/SublimeCodeIntel.sublime-settings"
21+
},
22+
"caption": "Settings \u2013 User",
23+
"command": "open_file"
24+
}
25+
],
26+
"id": "sublimecodeintel"
27+
}
28+
],
29+
"id": "package-settings",
30+
"mnemonic": "P"
31+
}
32+
],
33+
"id": "preferences",
34+
"mnemonic": "n"
35+
}
36+
]

README.rst

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ Code intelligence plugin ported from `Open Komodo Editor <http://www.openkomodo.
55

66
Supports all the languages Komodo Editor supports for Code Intelligence (CIX, CodeIntel2):
77

8-
JavaScript, Mason, XBL, XUL, RHTML, SCSS, Python, HTML, Ruby, Python3, XML, Sass, XSLT, Django, HTML5, Perl, CSS, Twig, Less, Smarty, Node.js, Tcl, TemplateToolkit, PHP.
8+
JavaScript, Mason, XBL, XUL, RHTML, SCSS, Python, HTML, Ruby, Python3, XML,
9+
Sass, XSLT, Django, HTML5, Perl, CSS, Twig, Less, Smarty, Node.js, Tcl,
10+
TemplateToolkit, PHP, Golang.
911

1012
Provides the following features:
1113

@@ -78,38 +80,10 @@ It just works!
7880

7981
Configuring
8082
-----------
81-
For adding additional library paths (django and extra libs paths for Python or extra paths to look for .js files for JavaScript for example), either add those paths as folders to your project, or create an optional codeintel configuration file in your home or in your project's root.
82-
83-
Configuration files (``~/.codeintel/config`` or ``project_root/.codeintel/config``). All configurations are optional. Example::
84-
85-
{
86-
"PHP": {
87-
"php": '/usr/bin/php',
88-
"phpExtraPaths": [],
89-
"phpConfigFile": 'php.ini'
90-
},
91-
"JavaScript": {
92-
"javascriptExtraPaths": []
93-
},
94-
"Perl": {
95-
"perl": "/usr/bin/perl",
96-
"perlExtraPaths": []
97-
},
98-
"Ruby": {
99-
"ruby": "/usr/bin/ruby",
100-
"rubyExtraPaths": []
101-
},
102-
"Python": {
103-
"python": '/usr/bin/python',
104-
"pythonExtraPaths": []
105-
},
106-
"Python3": {
107-
"python": '/usr/bin/python3',
108-
"pythonExtraPaths": []
109-
}
110-
}
111-
112-
Additional settings can be configured in the User File Settings:
83+
For adding additional library paths (django and extra libs paths for Python or
84+
extra paths to look for .js files for JavaScript for example), either add those
85+
paths as folders to your Sublime Text project, or modify SublimeCodeIntel
86+
User settings. User settings can be configured in the User File Settings:
11387

11488
Do NOT edit the default SublimeCodeIntel settings. Your changes will be lost when SublimeCodeIntel is updated. ALWAYS edit the user SublimeCodeIntel settings by selecting "Preferences->Package Settings->SublimeCodeIntel->Settings - User". Note that individual settings you include in your user settings will **completely** replace the corresponding default setting, so you must provide that setting in its entirety.
11589

@@ -197,7 +171,7 @@ sure you are ready for the upcoming version of SublimeCodeIntel:
197171
What's New
198172
----------
199173

200-
v3.0.0 (unreleased, alpha):
174+
v3.0.0 (unreleased, beta):
201175

202176
+ Uses CodeIntel as an OOP command and package.
203177
Needs to install CodeIntel with pip: `pip install codeintel`

SublimeCodeIntel.py

Lines changed: 89 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,53 @@
2828
"""
2929
from __future__ import absolute_import, unicode_literals, print_function
3030

31-
VERSION = "3.0.0"
32-
33-
codeintel_syntax_map = {
34-
"Python Django": "Python",
35-
}
36-
37-
3831
import os
3932
import sys
4033

4134
__file__ = os.path.normpath(os.path.abspath(__file__))
4235
__path__ = os.path.dirname(__file__)
4336

44-
python_sitelib_path = os.path.normpath(__path__)
37+
python_sitelib_path = os.path.join(os.path.normpath(__path__), 'libs')
4538
if python_sitelib_path not in sys.path:
4639
sys.path.insert(0, python_sitelib_path)
4740

41+
42+
VERSION = "3.0.0"
43+
44+
DEFAULT_SETTINGS = {
45+
'codeintel_live': True,
46+
'codeintel_disabled_languages': [],
47+
'codeintel_oop_command': '/usr/local/bin/codeintel',
48+
'codeintel_log_levels': ['WARNING'],
49+
'codeintel_prefs': {
50+
'codeintel_max_recursive_dir_depth': 10,
51+
'codeintel_scan_files_in_project': True,
52+
'codeintel_selected_catalogs': [],
53+
'defaultHTML5Decl': '-//W3C//DTD HTML 5//EN',
54+
'defaultHTMLDecl': '-//W3C//DTD HTML 5//EN',
55+
'javascriptExtraPaths': '',
56+
'nodejsDefaultInterpreter': '',
57+
'nodejsExtraPaths': '',
58+
'perl': '',
59+
'perlExtraPaths': '',
60+
'php': '',
61+
'phpConfigFile': '',
62+
'phpExtraPaths': '',
63+
'python': '',
64+
'python3': '',
65+
'python3ExtraPaths': '',
66+
'pythonExtraPaths': '',
67+
'ruby': '',
68+
'rubyExtraPaths': '',
69+
},
70+
'codeintel_env': dict(os.environ),
71+
}
72+
73+
codeintel_syntax_map = {
74+
"Python Django": "Python",
75+
}
76+
77+
4878
import re
4979
import logging
5080
import textwrap
@@ -56,13 +86,10 @@
5686

5787
from codeintel import CodeIntel, CodeIntelBuffer
5888

89+
settings = None
5990
logger_name = 'CodeIntel'
6091
logger = logging.getLogger(logger_name)
61-
logger.setLevel(logging.INFO) # INFO
62-
63-
handler = logging.StreamHandler(sys.stderr)
64-
handler.setFormatter(logging.Formatter("%(name)s: %(levelname)s: %(message)s"))
65-
logger.handlers = [handler]
92+
logger.setLevel(logging.WARNING) # WARNING
6693

6794

6895
class CodeIntelHandler(object):
@@ -175,6 +202,8 @@ def pos2bytes(self, content, pos):
175202
def guess_language(self, view, path):
176203
lang = os.path.splitext(os.path.basename(view.settings().get('syntax')))[0]
177204
lang = codeintel_syntax_map.get(lang, lang)
205+
if lang in settings.get('codeintel_disabled_languages'):
206+
return None
178207
return lang
179208

180209
def buf_from_view(self, view):
@@ -231,24 +260,12 @@ def buf_from_view(self, view):
231260
rubyExtraPaths = extra_paths
232261

233262
buf.prefs = {
234-
'codeintel_max_recursive_dir_depth': 10,
235-
'codeintel_scan_files_in_project': True,
236-
'codeintel_selected_catalogs': [],
237-
'defaultHTML5Decl': '-//W3C//DTD HTML 5//EN',
238-
'defaultHTMLDecl': '-//W3C//DTD HTML 5//EN',
239263
'javascriptExtraPaths': javascriptExtraPaths,
240-
'nodejsDefaultInterpreter': '',
241264
'nodejsExtraPaths': nodejsExtraPaths,
242-
'perl': '',
243265
'perlExtraPaths': perlExtraPaths,
244-
'php': '',
245-
'phpConfigFile': '',
246266
'phpExtraPaths': phpExtraPaths,
247-
'python': '',
248-
'python3': '',
249267
'python3ExtraPaths': python3ExtraPaths,
250268
'pythonExtraPaths': pythonExtraPaths,
251-
'ruby': '',
252269
'rubyExtraPaths': rubyExtraPaths,
253270
}
254271

@@ -473,6 +490,9 @@ def on_modified(self, view):
473490
if not view_sel:
474491
return
475492

493+
if not settings.get('codeintel_live'):
494+
return
495+
476496
sel = view_sel[0]
477497
pos = sel.end()
478498
current_char = view.substr(sublime.Region(pos - 1, pos))
@@ -545,5 +565,48 @@ def run(self, edit, block=False):
545565
window.open_file(previous_location, sublime.ENCODED_POSITION)
546566

547567

568+
def plugin_loaded():
569+
"""Restores user settings."""
570+
global ci, settings
571+
572+
settings_name = 'SublimeCodeIntel'
573+
settings = sublime.load_settings(settings_name + '.sublime-settings')
574+
settings.clear_on_change(settings_name)
575+
settings.add_on_change(settings_name, plugin_loaded)
576+
577+
for setting, default in DEFAULT_SETTINGS.items():
578+
value = settings.get(setting)
579+
if isinstance(default, dict):
580+
new_value = default.copy()
581+
if value and isinstance(value, dict):
582+
new_value.update(value)
583+
elif value is not None:
584+
new_value = value
585+
else:
586+
new_value = default
587+
if value != new_value:
588+
settings.set(setting, new_value)
589+
590+
if ci.mgr and ci.mgr.is_alive():
591+
ci.mgr.set_global_environment(
592+
env=settings.get('codeintel_env'),
593+
prefs=settings.get('codeintel_prefs'),
594+
)
595+
else:
596+
ci.activate(
597+
reset_db_as_necessary=False,
598+
oop_command=settings.get('codeintel_oop_command'),
599+
log_levels=settings.get('codeintel_log_levels'),
600+
env=settings.get('codeintel_env'),
601+
prefs=settings.get('codeintel_prefs'),
602+
)
603+
604+
548605
ci = CodeIntel()
549-
ci.activate()
606+
607+
# ST3 features a plugin_loaded hook which is called when ST's API is ready.
608+
#
609+
# We must therefore call our init callback manually on ST2. It must be the last
610+
# thing in this plugin (thanks, beloved contributors!).
611+
if not int(sublime.version()) > 3000:
612+
plugin_loaded()

SublimeCodeIntel.sublime-settings

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
SublimeCodeIntel default settings
3+
*/
4+
{
5+
"codeintel_live": true,
6+
"codeintel_disabled_languages": [],
7+
"codeintel_oop_command": "/usr/local/bin/codeintel",
8+
"codeintel_log_levels" : ["WARNING"],
9+
"codeintel_prefs" : {
10+
"codeintel_max_recursive_dir_depth": 10,
11+
"codeintel_scan_files_in_project": true,
12+
"codeintel_selected_catalogs": [],
13+
"defaultHTML5Decl": "-//W3C//DTD HTML 5//EN",
14+
"defaultHTMLDecl": "-//W3C//DTD HTML 5//EN",
15+
"javascriptExtraPaths": "",
16+
"nodejsDefaultInterpreter": "",
17+
"nodejsExtraPaths": "",
18+
"perl": "",
19+
"perlExtraPaths": "",
20+
"php": "",
21+
"phpConfigFile": "",
22+
"phpExtraPaths": "",
23+
"python": "",
24+
"python3": "",
25+
"python3ExtraPaths": "",
26+
"pythonExtraPaths": "",
27+
"ruby": "",
28+
"rubyExtraPaths": "",
29+
},
30+
"codeintel_env": {}
31+
}

0 commit comments

Comments
 (0)