Skip to content

Commit d1ee48c

Browse files
committed
Added options to give more control over rope paths
* Ability to override rope project root and .ropeproject folder * Added path argument to `PymodeRopeNewProject` which skips prompt * Options added: 'pymode_rope_project_root', 'pymode_rope_ropefolder'
1 parent 2f15f3d commit d1ee48c

File tree

6 files changed

+59
-12
lines changed

6 files changed

+59
-12
lines changed

Changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Changelog
44
* Get fold's expression symbol from &fillchars;
55
* Fixed error when setting g:pymode_breakpoint_cmd (expobrain);
66
* Fixed code running;
7+
* Ability to override rope project root and .ropeproject folder
8+
* Added path argument to `PymodeRopeNewProject` which skips prompt
9+
10+
* Options added:
11+
'pymode_rope_project_root', 'pymode_rope_ropefolder'
712

813

914
## 2013-12-04 0.7.8b

autoload/pymode/rope.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fun! pymode#rope#regenerate() "{{{
8383
endfunction "}}}
8484

8585

86-
fun! pymode#rope#new() "{{{
86+
fun! pymode#rope#new(...) "{{{
8787
PymodePython rope.new()
8888
endfunction "}}}
8989

doc/pymode.txt

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ Turn on the rope script *'g:pymode_rope'*
354354
.ropeproject Folder ~
355355
*.ropeproject*
356356

357-
*:PymodeRopeNewProject* -- Open new Rope project in current working directory
357+
*:PymodeRopeNewProject* [<path>] -- Open new Rope project in the given path
358358
*:PymodeRopeRegenerate* -- Regenerate the project cache
359359

360360
Rope uses a folder inside projects for holding project configuration and data.
@@ -371,8 +371,9 @@ Currently it is used for things such as:
371371
* It can be used to save information about object inferences.
372372
* It can be used to save a global name cache, which is used for auto-import.
373373

374-
If `.ropeproject` is not found in the current directory, rope will look
375-
recursively for it in parent folders.
374+
By default, if `.ropeproject` is not found in the current directory, rope will
375+
look recursively for it in parent folders.
376+
376377
Warning: If rope finds `.ropeproject` in a parent dir, it will use it with
377378
all its child directories, which may slow scanning down (because of many,
378379
possibly unrelated, files)
@@ -382,6 +383,23 @@ Enable searching for |.ropeproject| in parent directories
382383
>
383384
let g:pymode_rope_lookup_project = 1
384385
386+
You can also manually set the rope project directory. If not specified rope will
387+
use the current directory.
388+
*'g:pymode_rope_project_root'*
389+
>
390+
let g:pymode_rope_project_root = ""
391+
392+
393+
The location of the `.ropeproject` folder may also be overridden if you wish to
394+
keep it outside of your project root. The rope library treats this folder as a
395+
project resource, so the path will always be relative to your proejct root (a
396+
leading '/' will be ignored). You may use `'..'` path segments to place the
397+
folder outside of your project root.
398+
*'g:pymode_rope_ropefolder'*
399+
>
400+
let g:pymode_rope_ropefolder='.ropeproject'
401+
402+
385403
386404
Show documentation for element under cursor ~
387405

@@ -646,6 +664,10 @@ Solutions:
646664
- Set |'g:pymode_rope_lookup_project'| to 0 for prevent searching in parent
647665
dirs.
648666

667+
You may also set |'g:pymode_rope_project_root'| to manually specify the project
668+
root path.
669+
670+
649671

650672
Pylint check is very slow
651673
-------------------------

ftplugin/python/pymode.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ if g:pymode_rope
177177
inoremap <silent> <buffer> . .<C-R>=pymode#rope#complete_on_dot()<CR>
178178
end
179179

180-
command! -buffer PymodeRopeNewProject call pymode#rope#new()
180+
command! -buffer -nargs=? PymodeRopeNewProject call pymode#rope#new(<f-args>)
181181
command! -buffer PymodeRopeUndo call pymode#rope#undo()
182182
command! -buffer PymodeRopeRedo call pymode#rope#redo()
183183
command! -buffer PymodeRopeRenameModule call pymode#rope#rename_module()

plugin/pymode.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ call pymode#default('g:pymode_rope', 1)
151151
" System plugin variable
152152
call pymode#default('g:pymode_rope_current', '')
153153

154+
" Configurable rope project root
155+
call pymode#default('g:pymode_rope_project_root', '')
156+
157+
" Configurable rope project folder (always relative to project root)
158+
call pymode#default('g:pymode_rope_ropefolder', '.ropeproject')
159+
154160
" If project hasnt been finded in current working directory, look at parents directory
155161
call pymode#default('g:pymode_rope_lookup_project', 1)
156162

pymode/rope.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,16 @@ def regenerate():
233233

234234
def new():
235235
""" Create a new project. """
236-
root = env.var('input("Enter project root: ", getcwd())')
237-
prj = project.Project(projectroot=root)
236+
root = None
237+
if env.var('a:0') != '0':
238+
root = env.var('a:1')
239+
else:
240+
default = env.var('g:pymode_rope_project_root')
241+
if not default:
242+
default = env.var('getcwd()')
243+
root = env.var('input("Enter project root: ", "%s")' % default)
244+
ropefolder = env.var('g:pymode_rope_ropefolder')
245+
prj = project.Project(projectroot=root, ropefolder=ropefolder)
238246
prj.close()
239247
env.message("Project is opened: %s" % root)
240248

@@ -291,12 +299,18 @@ def get_ctx(*args, **kwargs):
291299
if resources.get(path):
292300
return resources.get(path)
293301

294-
project_path = env.curdir
295-
env.debug('Look ctx', project_path)
296-
if env.var('g:pymode_rope_lookup_project', True):
297-
project_path = look_ropeproject(project_path)
302+
project_path = env.var('g:pymode_rope_project_root')
303+
if project_path:
304+
project_path = env.curdir
305+
env.debug('Look ctx', project_path)
306+
if env.var('g:pymode_rope_lookup_project', True):
307+
project_path = look_ropeproject(project_path)
298308

299-
ctx = projects.get(project_path)
309+
if not os.path.exists(project_path):
310+
env.error("Rope project root not exist: %s" % project_path)
311+
ctx = None
312+
else:
313+
ctx = projects.get(project_path)
300314
if not ctx:
301315
projects[project_path] = ctx = cls(path, project_path)
302316
resources[path] = ctx

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy