Skip to content

Commit 47daedd

Browse files
committed
Allow to include project specific folders
1 parent 2f0d0a6 commit 47daedd

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This is powered by [Jedi](https://github.com/davidhalter/jedi).
1414
* Works with both :snake: Python 2 and 3
1515
* Watches whole package of the file you're currently editing
1616
* Configurable additional PATHs to include for completions (global for now)
17+
* You can include project specific folders by using $PROJECT variable in PATH configuration.
1718
* Highlights UPPERCASE_VARIABLES as constants according to PEP8
1819
* Highlights builtin functions and variables with special style
1920
* Prints first N characters of statement value while completing variables

‎lib/completion.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self):
3030
jedi.settings.add_bracket_after_function = kwargs.get(
3131
'addBracketAfterFunction', False)
3232

33-
for path in kwargs.get('extraPaths').split(','):
33+
for path in kwargs.get('extraPaths', []):
3434
if path and path not in sys.path:
3535
sys.path.insert(0, path)
3636

‎lib/main.coffee‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ module.exports =
2626
type: 'string'
2727
default: ''
2828
title: 'Extra PATH'
29-
description: 'Comma separated list of modules to additionally include for autocomplete.'
29+
description: '''Semicolon separated list of modules to additionally include for autocomplete.
30+
You can use $PROJECT variable here to include project specific folders like virtual environment.
31+
Note that it still should be valid python package.
32+
For example: $PROJECT/env/lib/python2.7/site-packages.
33+
'''
3034

3135
activate: (state) -> provider.constructor()
3236

‎lib/provider.coffee‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ module.exports =
88
console.debug 'Preparing python completions...'
99
@requests = {}
1010

11+
extraPaths = []
12+
for path in atom.config.get('autocomplete-python.extraPaths').split(';')
13+
for project in atom.project.getPaths()
14+
modified = path.replace('$PROJECT', project)
15+
if modified not in extraPaths
16+
extraPaths.push(modified)
17+
1118
args =
12-
'extraPaths': atom.config.get(
13-
'autocomplete-python.extraPaths'),
19+
'extraPaths': extraPaths,
1420
'useSnippets': atom.config.get(
1521
'autocomplete-python.useSnippets'),
1622
'caseInsensitiveCompletion': atom.config.get(

0 commit comments

Comments
 (0)