Vim Tips Wiki
(Update the build.vim example to support additional whitespace in Makefile var definition lines.)
(→‎Comments: use -S for a script of ex-commands)
Line 51: Line 51:
   
 
==Comments==
 
==Comments==
  +
Since all the commands in <tt>build.vim</tt> are ex-commands, you could source it with <tt>-S</tt> rather than <tt>-s</tt>, and dispense with the colons at the start of all lines. I would move the last command (to close Vim) out of the script and to a <tt>-cq</tt> argument at the end of the command line though (maybe making it so that the exclamation mark isn't needed if all goes well), to make the script easier to run from within a running Vim.
  +
* {{help|-s}}
  +
* {{help|-S}}
  +
--[[User:Tonymec|Tonymec]] 01:57, September 11, 2009 (UTC)

Revision as of 01:57, 11 September 2009

Tip 1601 Printable Monobook Previous Next

created August 14, 2008 · complexity basic · author Mahlonsmith · version 7.0


If you're a plugin developer, your plugin has multiple files (which should be the case since you're distributing documentation too, right?), and want to distribute everything as a nice little bundled package, then you should become familar with Charles Campbell's VimBall plugin.

You can use a Makefile and a series of Vim commands to automatically update your project's vimball on changes, for a sort of poor-man Vim automated build.

The Makefile should look something like this:

PLUGIN = specky

SOURCE = syntax/rdoc.vim
SOURCE += syntax/specrun.vim
SOURCE += doc/specky.txt
SOURCE += plugin/specky.vim

${PLUGIN}.vba: ${SOURCE}
	vim --cmd 'let g:plugin_name="${PLUGIN}"' -s build.vim

install:
	rsync -Rv ${SOURCE} ${HOME}/.vim/

clean:
	rm ${PLUGIN}.vba

Include each file that is part of your plugin as a SOURCE line. (This example is from the specky plugin.)

The 'vim -s build.vim' command loads Vim directives from a file. Here's the file I use to create the Vimball.

:let g:vimball_home = "."
:e Makefile
:v/^SOURCE/d
:%s/^SOURCE\s\++\?=\s\+//
:execute '%MkVimball!' . g:plugin_name
:q!

This says to parse the SOURCE lines out of the Makefile, and feed them to a vimball. The resulting file (in this example) will be called "specky.vba". As you add (or remove) files, you can just update the Makefile -- no need to change anything else.

In this fashion, as you update your code, you can just type "make", and have a packaged up Vimball that is ready for distribution.

Comments

Since all the commands in build.vim are ex-commands, you could source it with -S rather than -s, and dispense with the colons at the start of all lines. I would move the last command (to close Vim) out of the script and to a -cq argument at the end of the command line though (maybe making it so that the exclamation mark isn't needed if all goes well), to make the script easier to run from within a running Vim.

--Tonymec 01:57, September 11, 2009 (UTC)