From 4005608babe968b671d5cbded7c113a442ea9939 Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Fri, 7 Feb 2014 10:38:44 +0100 Subject: [PATCH] Follow the Vim 7.4 convention where to place python files. --- doc/UltiSnips.txt | 18 ++++-------------- plugin/UltiSnips.vim | 5 +++-- pylintrc | 2 +- {plugin => pythonx}/UltiSnips/__init__.py | 0 {plugin => pythonx}/UltiSnips/_diff.py | 0 {plugin => pythonx}/UltiSnips/_vim.py | 0 {plugin => pythonx}/UltiSnips/compatibility.py | 0 {plugin => pythonx}/UltiSnips/debug.py | 0 {plugin => pythonx}/UltiSnips/geometry.py | 0 {plugin => pythonx}/UltiSnips/indent_util.py | 0 {plugin => pythonx}/UltiSnips/snippet.py | 0 .../UltiSnips/snippet_dictionary.py | 0 .../UltiSnips/snippets_file_parser.py | 0 .../UltiSnips/tests/test_diff.py | 0 .../UltiSnips/tests/test_geometry.py | 0 .../UltiSnips/text_objects/__init__.py | 0 .../UltiSnips/text_objects/_base.py | 0 .../UltiSnips/text_objects/_escaped_char.py | 0 .../UltiSnips/text_objects/_lexer.py | 0 .../UltiSnips/text_objects/_mirror.py | 0 .../UltiSnips/text_objects/_parser.py | 0 .../UltiSnips/text_objects/_python_code.py | 0 .../UltiSnips/text_objects/_shell_code.py | 0 .../text_objects/_snippet_instance.py | 0 .../UltiSnips/text_objects/_tabstop.py | 0 .../UltiSnips/text_objects/_transformation.py | 0 .../UltiSnips/text_objects/_viml_code.py | 0 .../UltiSnips/text_objects/_visual.py | 0 {plugin => pythonx}/UltiSnips/vim_state.py | 0 29 files changed, 8 insertions(+), 17 deletions(-) rename {plugin => pythonx}/UltiSnips/__init__.py (100%) rename {plugin => pythonx}/UltiSnips/_diff.py (100%) rename {plugin => pythonx}/UltiSnips/_vim.py (100%) rename {plugin => pythonx}/UltiSnips/compatibility.py (100%) rename {plugin => pythonx}/UltiSnips/debug.py (100%) rename {plugin => pythonx}/UltiSnips/geometry.py (100%) rename {plugin => pythonx}/UltiSnips/indent_util.py (100%) rename {plugin => pythonx}/UltiSnips/snippet.py (100%) rename {plugin => pythonx}/UltiSnips/snippet_dictionary.py (100%) rename {plugin => pythonx}/UltiSnips/snippets_file_parser.py (100%) rename {plugin => pythonx}/UltiSnips/tests/test_diff.py (100%) rename {plugin => pythonx}/UltiSnips/tests/test_geometry.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/__init__.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_base.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_escaped_char.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_lexer.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_mirror.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_parser.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_python_code.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_shell_code.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_snippet_instance.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_tabstop.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_transformation.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_viml_code.py (100%) rename {plugin => pythonx}/UltiSnips/text_objects/_visual.py (100%) rename {plugin => pythonx}/UltiSnips/vim_state.py (100%) diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index af45cb6..8200cb1 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -296,16 +296,11 @@ alternative function IMAP_Jumpfunc('', 0) is called. For even more advanced usage, you can directly write python functions using UltiSnip's python modules. -The path to UltiSnip's python implementation is stored in the -g:UltiSnipsPythonPath variable which is set automatically on load. - Here is a small example funtion that expands a snippet: > function! s:Ulti_ExpandSnip() Python << EOF import sys, vim - new_path = vim.eval("expand('g:UltiSnipsPythonPath')") - sys.path.append(new_path) from UltiSnips import UltiSnips_Manager UltiSnips_Manager.expand() EOF @@ -945,15 +940,10 @@ wowHello World -> Hello World HELLO WORLD Python global functions can be stored in a python module and then imported. -This makes global functions easily accessible to all snippet files. - -First, add the directory modules are stored in to the python search path. For -example, add this line to your vimrc file. > - - py import sys; sys.path.append("/home/sirver/.vim/python") - -Now, import modules from this directory using a global snippet in your snippet -file > +This makes global functions easily accessible to all snippet files. Since Vim +7.4 you can just drop python files into ~/.vim/pythonx and you an import them +directly inside your snippets. For example to use +~/.vim/pythonx/my_snippets_helpers.py > global !p from my_snippet_helpers import * diff --git a/plugin/UltiSnips.vim b/plugin/UltiSnips.vim index 5caf3c7..002e6b5 100644 --- a/plugin/UltiSnips.vim +++ b/plugin/UltiSnips.vim @@ -283,9 +283,10 @@ endfunction " Expand our path exec g:_uspy "import vim, os, sys" -exec g:_uspy "new_path = vim.eval('expand(\":h\")')" +exec g:_uspy "new_path = os.path.abspath(os.path.join( + \ vim.eval('expand(\":h\")'), '..', 'pythonx'))" exec g:_uspy "vim.command(\"let g:UltiSnipsPythonPath = '%s'\" % new_path)" -exec g:_uspy "sys.path.append(new_path)" +exec g:_uspy "if not hasattr(vim, 'VIM_SPECIAL_PATH'): sys.path.append(new_path)" exec g:_uspy "from UltiSnips import SnippetManager" exec g:_uspy "UltiSnips_Manager = SnippetManager( \ vim.eval('g:UltiSnipsExpandTrigger'), diff --git a/pylintrc b/pylintrc index e0f6163..156e2b6 100644 --- a/pylintrc +++ b/pylintrc @@ -4,7 +4,7 @@ msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" # Python code to execute, usually for sys.path manipulation such as # pygtk.require(). -init-hook='import sys; sys.path.append("plugin/")' +init-hook='import sys; sys.path.append("pythonx/")' # Add files or directories to the blacklist. They should be base names, not # paths. diff --git a/plugin/UltiSnips/__init__.py b/pythonx/UltiSnips/__init__.py similarity index 100% rename from plugin/UltiSnips/__init__.py rename to pythonx/UltiSnips/__init__.py diff --git a/plugin/UltiSnips/_diff.py b/pythonx/UltiSnips/_diff.py similarity index 100% rename from plugin/UltiSnips/_diff.py rename to pythonx/UltiSnips/_diff.py diff --git a/plugin/UltiSnips/_vim.py b/pythonx/UltiSnips/_vim.py similarity index 100% rename from plugin/UltiSnips/_vim.py rename to pythonx/UltiSnips/_vim.py diff --git a/plugin/UltiSnips/compatibility.py b/pythonx/UltiSnips/compatibility.py similarity index 100% rename from plugin/UltiSnips/compatibility.py rename to pythonx/UltiSnips/compatibility.py diff --git a/plugin/UltiSnips/debug.py b/pythonx/UltiSnips/debug.py similarity index 100% rename from plugin/UltiSnips/debug.py rename to pythonx/UltiSnips/debug.py diff --git a/plugin/UltiSnips/geometry.py b/pythonx/UltiSnips/geometry.py similarity index 100% rename from plugin/UltiSnips/geometry.py rename to pythonx/UltiSnips/geometry.py diff --git a/plugin/UltiSnips/indent_util.py b/pythonx/UltiSnips/indent_util.py similarity index 100% rename from plugin/UltiSnips/indent_util.py rename to pythonx/UltiSnips/indent_util.py diff --git a/plugin/UltiSnips/snippet.py b/pythonx/UltiSnips/snippet.py similarity index 100% rename from plugin/UltiSnips/snippet.py rename to pythonx/UltiSnips/snippet.py diff --git a/plugin/UltiSnips/snippet_dictionary.py b/pythonx/UltiSnips/snippet_dictionary.py similarity index 100% rename from plugin/UltiSnips/snippet_dictionary.py rename to pythonx/UltiSnips/snippet_dictionary.py diff --git a/plugin/UltiSnips/snippets_file_parser.py b/pythonx/UltiSnips/snippets_file_parser.py similarity index 100% rename from plugin/UltiSnips/snippets_file_parser.py rename to pythonx/UltiSnips/snippets_file_parser.py diff --git a/plugin/UltiSnips/tests/test_diff.py b/pythonx/UltiSnips/tests/test_diff.py similarity index 100% rename from plugin/UltiSnips/tests/test_diff.py rename to pythonx/UltiSnips/tests/test_diff.py diff --git a/plugin/UltiSnips/tests/test_geometry.py b/pythonx/UltiSnips/tests/test_geometry.py similarity index 100% rename from plugin/UltiSnips/tests/test_geometry.py rename to pythonx/UltiSnips/tests/test_geometry.py diff --git a/plugin/UltiSnips/text_objects/__init__.py b/pythonx/UltiSnips/text_objects/__init__.py similarity index 100% rename from plugin/UltiSnips/text_objects/__init__.py rename to pythonx/UltiSnips/text_objects/__init__.py diff --git a/plugin/UltiSnips/text_objects/_base.py b/pythonx/UltiSnips/text_objects/_base.py similarity index 100% rename from plugin/UltiSnips/text_objects/_base.py rename to pythonx/UltiSnips/text_objects/_base.py diff --git a/plugin/UltiSnips/text_objects/_escaped_char.py b/pythonx/UltiSnips/text_objects/_escaped_char.py similarity index 100% rename from plugin/UltiSnips/text_objects/_escaped_char.py rename to pythonx/UltiSnips/text_objects/_escaped_char.py diff --git a/plugin/UltiSnips/text_objects/_lexer.py b/pythonx/UltiSnips/text_objects/_lexer.py similarity index 100% rename from plugin/UltiSnips/text_objects/_lexer.py rename to pythonx/UltiSnips/text_objects/_lexer.py diff --git a/plugin/UltiSnips/text_objects/_mirror.py b/pythonx/UltiSnips/text_objects/_mirror.py similarity index 100% rename from plugin/UltiSnips/text_objects/_mirror.py rename to pythonx/UltiSnips/text_objects/_mirror.py diff --git a/plugin/UltiSnips/text_objects/_parser.py b/pythonx/UltiSnips/text_objects/_parser.py similarity index 100% rename from plugin/UltiSnips/text_objects/_parser.py rename to pythonx/UltiSnips/text_objects/_parser.py diff --git a/plugin/UltiSnips/text_objects/_python_code.py b/pythonx/UltiSnips/text_objects/_python_code.py similarity index 100% rename from plugin/UltiSnips/text_objects/_python_code.py rename to pythonx/UltiSnips/text_objects/_python_code.py diff --git a/plugin/UltiSnips/text_objects/_shell_code.py b/pythonx/UltiSnips/text_objects/_shell_code.py similarity index 100% rename from plugin/UltiSnips/text_objects/_shell_code.py rename to pythonx/UltiSnips/text_objects/_shell_code.py diff --git a/plugin/UltiSnips/text_objects/_snippet_instance.py b/pythonx/UltiSnips/text_objects/_snippet_instance.py similarity index 100% rename from plugin/UltiSnips/text_objects/_snippet_instance.py rename to pythonx/UltiSnips/text_objects/_snippet_instance.py diff --git a/plugin/UltiSnips/text_objects/_tabstop.py b/pythonx/UltiSnips/text_objects/_tabstop.py similarity index 100% rename from plugin/UltiSnips/text_objects/_tabstop.py rename to pythonx/UltiSnips/text_objects/_tabstop.py diff --git a/plugin/UltiSnips/text_objects/_transformation.py b/pythonx/UltiSnips/text_objects/_transformation.py similarity index 100% rename from plugin/UltiSnips/text_objects/_transformation.py rename to pythonx/UltiSnips/text_objects/_transformation.py diff --git a/plugin/UltiSnips/text_objects/_viml_code.py b/pythonx/UltiSnips/text_objects/_viml_code.py similarity index 100% rename from plugin/UltiSnips/text_objects/_viml_code.py rename to pythonx/UltiSnips/text_objects/_viml_code.py diff --git a/plugin/UltiSnips/text_objects/_visual.py b/pythonx/UltiSnips/text_objects/_visual.py similarity index 100% rename from plugin/UltiSnips/text_objects/_visual.py rename to pythonx/UltiSnips/text_objects/_visual.py diff --git a/plugin/UltiSnips/vim_state.py b/pythonx/UltiSnips/vim_state.py similarity index 100% rename from plugin/UltiSnips/vim_state.py rename to pythonx/UltiSnips/vim_state.py