Skip to content

Added options to give more control over rope paths #433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
* Get fold's expression symbol from &fillchars;
* Fixed error when setting g:pymode_breakpoint_cmd (expobrain);
* Fixed code running;
* 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'


## 2013-12-04 0.7.8b
Expand Down
2 changes: 1 addition & 1 deletion autoload/pymode/rope.vim
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fun! pymode#rope#regenerate() "{{{
endfunction "}}}


fun! pymode#rope#new() "{{{
fun! pymode#rope#new(...) "{{{
PymodePython rope.new()
endfunction "}}}

Expand Down
28 changes: 25 additions & 3 deletions doc/pymode.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ Turn on the rope script *'g:pymode_rope'*
.ropeproject Folder ~
*.ropeproject*

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

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

If `.ropeproject` is not found in the current directory, rope will look
recursively for it in parent folders.
By default, if `.ropeproject` is not found in the current directory, rope will
look recursively for it in parent folders.

Warning: If rope finds `.ropeproject` in a parent dir, it will use it with
all its child directories, which may slow scanning down (because of many,
possibly unrelated, files)
Expand All @@ -382,6 +383,23 @@ Enable searching for |.ropeproject| in parent directories
>
let g:pymode_rope_lookup_project = 1

You can also manually set the rope project directory. If not specified rope will
use the current directory.
*'g:pymode_rope_project_root'*
>
let g:pymode_rope_project_root = ""


The location of the `.ropeproject` folder may also be overridden if you wish to
keep it outside of your project root. The rope library treats this folder as a
project resource, so the path will always be relative to your proejct root (a
leading '/' will be ignored). You may use `'..'` path segments to place the
folder outside of your project root.
*'g:pymode_rope_ropefolder'*
>
let g:pymode_rope_ropefolder='.ropeproject'



Show documentation for element under cursor ~

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

You may also set |'g:pymode_rope_project_root'| to manually specify the project
root path.



Pylint check is very slow
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion ftplugin/python/pymode.vim
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ if g:pymode_rope
inoremap <silent> <buffer> . .<C-R>=pymode#rope#complete_on_dot()<CR>
end

command! -buffer PymodeRopeNewProject call pymode#rope#new()
command! -buffer -nargs=? PymodeRopeNewProject call pymode#rope#new(<f-args>)
command! -buffer PymodeRopeUndo call pymode#rope#undo()
command! -buffer PymodeRopeRedo call pymode#rope#redo()
command! -buffer PymodeRopeRenameModule call pymode#rope#rename_module()
Expand Down
6 changes: 6 additions & 0 deletions plugin/pymode.vim
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ call pymode#default('g:pymode_rope', 1)
" System plugin variable
call pymode#default('g:pymode_rope_current', '')

" Configurable rope project root
call pymode#default('g:pymode_rope_project_root', '')

" Configurable rope project folder (always relative to project root)
call pymode#default('g:pymode_rope_ropefolder', '.ropeproject')

" If project hasnt been finded in current working directory, look at parents directory
call pymode#default('g:pymode_rope_lookup_project', 1)

Expand Down
28 changes: 21 additions & 7 deletions pymode/rope.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,16 @@ def regenerate():

def new():
""" Create a new project. """
root = env.var('input("Enter project root: ", getcwd())')
prj = project.Project(projectroot=root)
root = None
if env.var('a:0') != '0':
root = env.var('a:1')
else:
default = env.var('g:pymode_rope_project_root')
if not default:
default = env.var('getcwd()')
root = env.var('input("Enter project root: ", "%s")' % default)
ropefolder = env.var('g:pymode_rope_ropefolder')
prj = project.Project(projectroot=root, ropefolder=ropefolder)
prj.close()
env.message("Project is opened: %s" % root)

Expand Down Expand Up @@ -291,12 +299,18 @@ def get_ctx(*args, **kwargs):
if resources.get(path):
return resources.get(path)

project_path = env.curdir
env.debug('Look ctx', project_path)
if env.var('g:pymode_rope_lookup_project', True):
project_path = look_ropeproject(project_path)
project_path = env.var('g:pymode_rope_project_root')
if project_path:
project_path = env.curdir
env.debug('Look ctx', project_path)
if env.var('g:pymode_rope_lookup_project', True):
project_path = look_ropeproject(project_path)

ctx = projects.get(project_path)
if not os.path.exists(project_path):
env.error("Rope project root not exist: %s" % project_path)
ctx = None
else:
ctx = projects.get(project_path)
if not ctx:
projects[project_path] = ctx = cls(path, project_path)
resources[path] = ctx
Expand Down