Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 1.0

Vim Django stable release. If you have any issues please email me or create a new issue on github.com/cwood/vim-django. It would be greatly appreciated!
  • Loading branch information...
commit 0fbb40d1fd09379772cd561135d16385e7335a42 1 parent 71b0ae9
@cwood cwood authored committed
View
25 README.markdown
@@ -1,10 +1,10 @@
Vim-Django
===============================================================================
-Vim-Django is a vim script that helps manage a django app. It has wrapping's
-for the ``django-admin.py``, your projects ``manage.py`` and some helper
-commands. It also has some quick ways to find templates, edit related files
-in a app, create new apps, and help manage django while using Vim.
+Vim-Django is a ViM script that helps manage a django app(s). It has wrapping's
+for the ``django-admin.py``, your projects ``manage.py`` and some helper
+commands. It also has some quick ways to find templates, edit related files
+in a app, create new apps, and help manage django while using ViM.
Commands
@@ -31,11 +31,11 @@ Mappings
-------------------------------------------------------------------------------
There are mappings for easily editing related django files while working on a
-app. They all can be changed if you dont like how they are currently mapped.
-There are mappins for (v|views), (u|urls), (a|admin),
+app. They all can be changed if you don't like how they are currently mapped.
+There are mappings for (v|views), (u|urls), (a|admin),
and (t|tests). If you want to remap these you can call the function
``django#apps#edit('name_of_file.py', 'split')`` and it will open up
-the file it fineds in a split.
+the file it fines in a split.
Configuration
@@ -45,7 +45,7 @@ Configuration
``g:django_activate_virtualenv`` when true will activate a virtualenv that
starts with the same name. An example being. colinbits, is the site, and the
-virtuale env being colinbits.com.
+virtualenv being colinbits.com.
Custom Activation of Projects
@@ -75,6 +75,15 @@ I recommend using pathogen or vundle to install this script. Else, you can
put the ``django.vim`` in the plug-ins directory. This script does require
python to be compiled in.
+Example .vimrc
+------------------------------------------------------------------------------
+```vim
+let g:django_projects = '~/Projects' "Sets all projects under project
+let g:django_project_container = 'source' "Inside of these folders look for source
+let g:django_activate_virtualenv = 1 "Try to activate the associated virtualenv
+let g:django_activate_nerdtree = 1 "Try to open nerdtree at the project root.
+```
+
Screen shots
-------------------------------------------------------------------------------
View
4 autoload/django.vim
@@ -1,4 +0,0 @@
-" django.vim - A bangin' interface for ViM and Django
-" Maintainer: Colin Wood <cwood06@gmail.com>
-" Version: 0.2.0a
-" License: Same as ViM. see http://www.gnu.org/licenses/vim-license.txt
View
2  autoload/django/apps.vim
@@ -28,7 +28,7 @@ function! django#apps#edit(file_prefix, open_as)
" models. Since this can be a __init__ file inside of the models.py.
" Should check both for a file_prefix.py and a folder called file_prefix.
let current_app_directory = fnamemodify(expand('%:p'), ':h')
- let python_files = split(globpath(current_app_directory, '**/'.a:file_prefix))
+ let python_files = split(globpath(current_app_directory, '*/'.a:file_prefix))
if len(python_files) == 1
let only_file = python_files[0]
call django#utils#vim_open(only_file, a:open_as)
View
14 autoload/django/completions.vim
@@ -99,12 +99,14 @@ EOB
endfunction
function! django#completions#projectscomplete(prefix, ...)
- " TODO: Make me faster!
- let file_regex = '**/settings.py'
- let arg_regex = 'v:val =~ "'.a:prefix.'"'
- let all_settings_files = split(globpath(g:django_projects, file_regex))
+ if exists('g:django_project_container')
+ let file_regex = '*/'.g:django_project_container.'/*/settings.py'
+ else
+ let file_regex = '**/settings.py'
+ endif
+ let all_settings_files = split(globpath(g:django_projects, file_regex))
let all_projects = []
for setting_file in all_settings_files
@@ -114,9 +116,11 @@ function! django#completions#projectscomplete(prefix, ...)
if a:prefix == ''
return all_projects
+ else
+ let arg_regex = 'v:val =~ "'.a:prefix.'"'
+ return filter(copy(all_projects), arg_regex)
endif
- return filter(copy(all_projects), arg_regex)
endfunction
function! django#completions#installed_apps(prefix, ...)
View
9 autoload/django/project.vim
@@ -13,15 +13,16 @@ endif
function! django#project#activate(project)
- let file_regex = '**/'.a:project.'/settings.py'
- let file = split(globpath(g:django_projects, file_regex))[0]
- let g:project_directory = fnamemodify(file, ':h:h')
+ let file_regex = a:project.'/settings.py'
+ let file = findfile(file_regex, g:django_projects.'**')
+ let g:project_directory = fnamemodify(file, ':p:h:h')
let g:project_name = a:project
if exists('g:django_activate_virtualenv')
if exists('g:virtualenv_loaded') && g:django_activate_virtualenv == 1
for env in virtualenv#names(a:project)
call virtualenv#activate(env)
+ break
endfor
else
echoerr 'VirtualEnv not installed. Not activating.'
@@ -33,10 +34,10 @@ function! django#project#activate(project)
exec ':NERDTree '.g:project_directory
else
echoerr "NERDTree not installed. Can not open."
+ endif
endif
exec 'set path+='.expand(g:project_directory)
-
call ActivateProject(a:project)
endfunction
View
20 doc/tags
@@ -0,0 +1,20 @@
+ActivateProject vim-django.txt /*ActivateProject*
+DjangoAdmin vim-django.txt /*DjangoAdmin*
+DjangoCreateApp vim-django.txt /*DjangoCreateApp*
+DjangoManage vim-django.txt /*DjangoManage*
+DjangoProjectActivate vim-django.txt /*DjangoProjectActivate*
+django-commands vim-django.txt /*django-commands*
+django-configruation vim-django.txt /*django-configruation*
+django-contents vim-django.txt /*django-contents*
+django-custom-setup vim-django.txt /*django-custom-setup*
+django-editing-related vim-django.txt /*django-editing-related*
+django-extenions vim-django.txt /*django-extenions*
+django-introduction vim-django.txt /*django-introduction*
+django-keymappings vim-django.txt /*django-keymappings*
+django-thank-contribute vim-django.txt /*django-thank-contribute*
+django-vim-global-vars vim-django.txt /*django-vim-global-vars*
+g:django_activate_nerdtree vim-django.txt /*g:django_activate_nerdtree*
+g:django_activate_virtualenv vim-django.txt /*g:django_activate_virtualenv*
+g:django_project_container vim-django.txt /*g:django_project_container*
+g:project_directory vim-django.txt /*g:project_directory*
+vim-django.txt vim-django.txt /*vim-django.txt*
View
7 doc/vim-django.txt
@@ -44,6 +44,12 @@ corresponding virtual environment. The virtual environment must start with
the same name as your project does. An example being: colinbits is my django
project; this will activate the colinbits.com virtualenv.
+*g:django_project_container* is used when autocompleting django projects.
+If you use a complex project organization structure. This can come in handy
+for making autocompletions faster. For example. If you have a
+project_name.something/source/django_project. You could set
+g:django_projects_container and it will look for your source directory.
+
==============================================================================
Keymappings *django-keymappings*
@@ -115,6 +121,7 @@ Thank You & Contributing *django-thank-contribute*
Thanks for using my little plug-in. I plan on adding more features as I need
them. If there is something you would like to see in this script feel free
to add a issue at the Github project.
+
It is located at https://github.com/cwood/vim-django. Also feel free to
fork it and send in a pull request. I love seeing people using my code.
View
1  ftplugin/python.vim
@@ -4,7 +4,6 @@ function! s:CreateRelatedMappingsPerFile(filename)
for method in methods
execute 'nmap r'.a:filename[:0].method[:0].' :call django#apps#edit("'.a:filename.'", "'.method.'")<CR>'
endfor
-
endfunction
call s:CreateRelatedMappingsPerFile('models.py')
View
85 plugin/.ropeproject/config.py
@@ -0,0 +1,85 @@
+# The default ``config.py``
+
+
+def set_prefs(prefs):
+ """This function is called before opening the project"""
+
+ # Specify which files and folders to ignore in the project.
+ # Changes to ignored resources are not added to the history and
+ # VCSs. Also they are not returned in `Project.get_files()`.
+ # Note that ``?`` and ``*`` match all characters but slashes.
+ # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
+ # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
+ # '.svn': matches 'pkg/.svn' and all of its children
+ # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
+ # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
+ prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject',
+ '.hg', '.svn', '_svn', '.git']
+
+ # Specifies which files should be considered python files. It is
+ # useful when you have scripts inside your project. Only files
+ # ending with ``.py`` are considered to be python files by
+ # default.
+ #prefs['python_files'] = ['*.py']
+
+ # Custom source folders: By default rope searches the project
+ # for finding source folders (folders that should be searched
+ # for finding modules). You can add paths to that list. Note
+ # that rope guesses project source folders correctly most of the
+ # time; use this if you have any problems.
+ # The folders should be relative to project root and use '/' for
+ # separating folders regardless of the platform rope is running on.
+ # 'src/my_source_folder' for instance.
+ #prefs.add('source_folders', 'src')
+
+ # You can extend python path for looking up modules
+ #prefs.add('python_path', '~/python/')
+
+ # Should rope save object information or not.
+ prefs['save_objectdb'] = True
+ prefs['compress_objectdb'] = False
+
+ # If `True`, rope analyzes each module when it is being saved.
+ prefs['automatic_soa'] = True
+ # The depth of calls to follow in static object analysis
+ prefs['soa_followed_calls'] = 0
+
+ # If `False` when running modules or unit tests "dynamic object
+ # analysis" is turned off. This makes them much faster.
+ prefs['perform_doa'] = True
+
+ # Rope can check the validity of its object DB when running.
+ prefs['validate_objectdb'] = True
+
+ # How many undos to hold?
+ prefs['max_history_items'] = 32
+
+ # Shows whether to save history across sessions.
+ prefs['save_history'] = True
+ prefs['compress_history'] = False
+
+ # Set the number spaces used for indenting. According to
+ # :PEP:`8`, it is best to use 4 spaces. Since most of rope's
+ # unit-tests use 4 spaces it is more reliable, too.
+ prefs['indent_size'] = 4
+
+ # Builtin and c-extension modules that are allowed to be imported
+ # and inspected by rope.
+ prefs['extension_modules'] = []
+
+ # Add all standard c-extensions to extension_modules list.
+ prefs['import_dynload_stdmods'] = True
+
+ # If `True` modules with syntax errors are considered to be empty.
+ # The default value is `False`; When `False` syntax errors raise
+ # `rope.base.exceptions.ModuleSyntaxError` exception.
+ prefs['ignore_syntax_errors'] = False
+
+ # If `True`, rope ignores unresolvable imports. Otherwise, they
+ # appear in the importing namespace.
+ prefs['ignore_bad_imports'] = False
+
+
+def project_opened(project):
+ """This function is called after opening the project"""
+ # Do whatever you like here!
View
1  plugin/.ropeproject/globalnames
@@ -0,0 +1 @@
+�}q.
View
1  plugin/.ropeproject/history
@@ -0,0 +1 @@
+�]q(]q]qe.
View
8 plugin/.ropeproject/objectdb
@@ -0,0 +1,8 @@
+�}q(U~/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/options.py}q(U"BaseModelAdmin._declared_fieldsetscrope.base.oi.memorydb
+ScopeInfo
+q)�q}qUinstanceqUdefinedqU~/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/options.pyUBaseModelAdminq���Ubuiltinq Ulistq
+(h Utupleq Unoneq �q (h UdictqUbuiltinUstr�qUunknown�qtt�s}q�bUModelAdmin._mediah)�q}qhhU~/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/options.pyU
+ModelAdminq���hhUv/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/forms/widgets.pyUMediaq��s}q�buUy/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/utils/functional.py}qUupdate_wrapperqh)�q}q((hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.index�h h thU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�(hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU�/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/contenttypes/views.pyUshortcutq�h h thU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�(hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.password_change�h h thU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�(hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.i18n_javascript�h h thU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�(hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.logout�h h thU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�(hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.password_change_done�h h thU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�(hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.app_index�h h thU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�u}q�bsU{/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/conf/urls/defaults.py}q(Uurlqh)�q}q ((hhU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�h h h thhUz/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/core/urlresolvers.pyURegexURLPatternq!��(hhU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�h hh thhUz/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/core/urlresolvers.pyh!��u}q"�bUpatternsq#h)�q$}q%(hhhUz/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/core/urlresolvers.pyh!��hhUz/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/core/urlresolvers.pyh!��hhUz/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/core/urlresolvers.pyh!��hhUz/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/core/urlresolvers.pyh!��hhUz/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/core/urlresolvers.pyh!��hhUz/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/core/urlresolvers.pyh!��hhUz/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/core/urlresolvers.pyh!��th h
+h �s}q&�buU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.py}q'(UAdminSite.get_urls.wraph)�q(}q)(hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.index�h �hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.app_index�h �hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.logout�h �hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.i18n_javascript�Uunknown�q*�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU�/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/contenttypes/views.pyh�h �hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.password_change_done�h*�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.password_change�h*�hU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyUAdminSite.get_urls.wrap.wrapper�u}q+�bUAdminSite.get_urlsh)�q,}q-hhU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyU AdminSiteq.���h h
+h �s}q/�bUAdminSite.urlsh)�q0}q1hhU|/Users/cwood06/Projects/wowredskins.com/virtualenv-wowredskins.com/lib/python2.7/site-packages/django/contrib/admin/sites.pyh.���(h h h h
+h �hhts}q2�buUH/Users/cwood06/Projects/wowredskins.com/source/apps/clubmembers/admin.py}u.
View
8 plugin/django.vim
@@ -1,6 +1,6 @@
" django.vim - A bangin' interface for ViM and Django
" Maintainer: Colin Wood <cwood06@gmail.com>
-" Version: 0.2.0a
+" Version: 1.0.0rc
" License: Same as ViM. see http://www.gnu.org/licenses/vim-license.txt
@@ -13,6 +13,8 @@ if !exists('g:django_projects')
" Where the projects are stored at. Will start from this
" root and search down for all someapp.settings files
let g:django_projects = expand('~/Projects')
+else
+ let g:django_projects = expand(g:django_projects)
endif
if !isdirectory(g:django_projects)
@@ -28,8 +30,10 @@ if !exists('g:django_app_templates')
let g:django_app_templates = expand('~/.templates/apps')
endif
-
command! -nargs=? -complete=customlist,django#completions#managmentcommands DjangoManage call django#commands#manage(<q-args>)
command! -nargs=1 -complete=customlist,django#completions#projectscomplete DjangoProjectActivate call django#project#activate(<q-args>)
command! -nargs=? -complete=customlist,django#completions#managmentcommands DjangoAdmin call django#commands#admin(<q-args>)
command! -nargs=? -complete=customlist,django#completions#pypath DjangoCreateApp call django#apps#create_app(<q-args>)
+
+command! DjangoCollectStaticLink call django#commands#manage('collectstatic --noinput --link')
+command! DjangoSyncDb call django#commands#manage('syncdb')
Please sign in to comment.
Something went wrong with that request. Please try again.