aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Driessen <vincent@datafox.nl>2010-08-18 14:11:51 +0200
committerVincent Driessen <vincent@datafox.nl>2010-08-18 14:11:51 +0200
commit3013d6afbe4ca23de1571579082d325b44fef4d5 (patch)
treeb6b9f01956a5be3f84ff80c5d9c147cfe0217177
downloadvim-rst-tables-3013d6afbe4ca23de1571579082d325b44fef4d5.tar.gz
vim-rst-tables-3013d6afbe4ca23de1571579082d325b44fef4d5.tar.bz2
vim-rst-tables-3013d6afbe4ca23de1571579082d325b44fef4d5.zip
Add initial files.
-rw-r--r--README.rst53
-rwxr-xr-xbuild.py18
-rw-r--r--ftplugin/rst_tables.vim34
-rw-r--r--src/base.vim28
-rw-r--r--src/rst_tables.py6
5 files changed, 139 insertions, 0 deletions
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..c1e77fc
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,53 @@
+Installation
+------------
+1. Install the following packages from PyPI:
+
+ - vim_bridge_: This is required for the vim plugin scripts, to call
+ directly into Python functions.
+
+2. Clone the git repository::
+
+ git clone git://github.com/nvie/vim-rst-tables.git
+ cd vim-rst-tables
+
+3. Copy the file ``ftplugin/rst_tables.vim`` to your ``~/.vim/ftplugin``
+ directory
+
+.. _vim_bridge: http://pypi.python.org/pypi/vim_bridge
+
+
+Usage
+-----
+1. Open a reStructuredText file
+2. Create some kind of table outline
+
+ .. code_block:: rst
+ This is paragraph text *before* the table.
+
+ Column 1 Column 2
+ Foo Put two (or more) spaces as a field separator.
+ Bar Even very very long lines like these are fine, as long as you do not put in line endings here.
+ Qux This is the last line.
+
+ This is paragraph text *after* the table.
+
+2. Put your cursor somewhere in the table.
+3. Press ``,,c`` (to create the table). The output will look something like
+ this:
+
+ .. code_block:: rst
+ This is paragraph text *before* the table.
+
+ +==========+=========================================================+
+ | Column 1 | Column 2 |
+ +==========+=========================================================+
+ | Foo | Put two (or more) spaces as a field separator. |
+ +----------+---------------------------------------------------------+
+ | Bar | Even very very long lines like these are fine, as long |
+ | | as you do not put in line endings here. |
+ +----------+---------------------------------------------------------+
+ | Qux | This is the last line. |
+ +----------+---------------------------------------------------------+
+
+ This is paragraph text *after* the table.
+
diff --git a/build.py b/build.py
new file mode 100755
index 0000000..a700549
--- /dev/null
+++ b/build.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+import os
+
+source_dir = 'src'
+output_dir = 'ftplugin'
+
+
+def build():
+ py_src = file(os.path.join(source_dir, 'rst_tables.py')).read()
+ vim_src = file(os.path.join(source_dir, 'base.vim')).read()
+ combined_src = vim_src.replace('__PYTHON_SOURCE__', py_src)
+ if not os.path.exists(output_dir):
+ os.mkdir(output_dir)
+ output_path = os.path.join(output_dir, 'rst_tables.vim')
+ file(output_path, 'w').write(combined_src)
+
+if __name__ == '__main__':
+ build()
diff --git a/ftplugin/rst_tables.vim b/ftplugin/rst_tables.vim
new file mode 100644
index 0000000..c847c70
--- /dev/null
+++ b/ftplugin/rst_tables.vim
@@ -0,0 +1,34 @@
+"
+" reStructuredText tables plugin
+" Language: Python (ft=python)
+" Maintainer: Vincent Driessen <vincent@datafox.nl>
+" Version: Vim 7 (may work with lower Vim versions, but not tested)
+" URL: http://github.com/nvie/vim-rst-tables
+"
+
+" Only do this when not done yet for this buffer
+if exists("g:loaded_rst_tables_ftplugin")
+ finish
+endif
+let loaded_rst_tables_ftplugin = 1
+
+python << endpython
+import vim
+import os
+import os.path
+from vim_bridge import bridged
+
+
+
+endpython
+
+" Add mappings, unless the user didn't want this.
+" The default mapping is registered, unless the user remapped it already.
+if !exists("no_plugin_maps") && !exists("no_rst_table_maps")
+ if !hasmapto('CreateTable(')
+ noremap <silent> <leader><leader>c :call CreateTable()<CR>
+ endif
+ if !hasmapto('ReformatTable(')
+ noremap <silent> <leader><leader>f :call ReformatTable()<CR>
+ endif
+endif
diff --git a/src/base.vim b/src/base.vim
new file mode 100644
index 0000000..fc30e05
--- /dev/null
+++ b/src/base.vim
@@ -0,0 +1,28 @@
+"
+" reStructuredText tables plugin
+" Language: Python (ft=python)
+" Maintainer: Vincent Driessen <vincent@datafox.nl>
+" Version: Vim 7 (may work with lower Vim versions, but not tested)
+" URL: http://github.com/nvie/vim-rst-tables
+"
+
+" Only do this when not done yet for this buffer
+if exists("g:loaded_rst_tables_ftplugin")
+ finish
+endif
+let loaded_rst_tables_ftplugin = 1
+
+python << endpython
+__PYTHON_SOURCE__
+endpython
+
+" Add mappings, unless the user didn't want this.
+" The default mapping is registered, unless the user remapped it already.
+if !exists("no_plugin_maps") && !exists("no_rst_table_maps")
+ if !hasmapto('CreateTable(')
+ noremap <silent> <leader><leader>c :call CreateTable()<CR>
+ endif
+ if !hasmapto('ReformatTable(')
+ noremap <silent> <leader><leader>f :call ReformatTable()<CR>
+ endif
+endif
diff --git a/src/rst_tables.py b/src/rst_tables.py
new file mode 100644
index 0000000..4fd8d0f
--- /dev/null
+++ b/src/rst_tables.py
@@ -0,0 +1,6 @@
+import vim
+import os
+import os.path
+from vim_bridge import bridged
+
+