Skip to content

Commit 4aa630e

Browse files
committed
Make sure vim-misc is installed, politely complain if it isn't
1 parent 4cb3c4c commit 4aa630e

4 files changed

Lines changed: 83 additions & 55 deletions

File tree

addon-info.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"vim_script_nr": 2252, "dependencies": {"vim-misc": {}}, "homepage": "http://peterodding.com/code/vim/publish", "name": "vim-publish"}

autoload/xolox/publish.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Last Change: August 19, 2013
44
" URL: http://peterodding.com/code/vim/publish/
55

6-
let g:xolox#publish#version = '1.7.13'
6+
let g:xolox#publish#version = '1.7.14'
77

88
function! xolox#publish#resolve_files(directory, pathnames) " {{{1
99
" Create a dictionary that maps the fully resolved pathnames of the files to

doc/publish.txt

Lines changed: 67 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
*publish.txt* Publish hyperlinked, syntax highlighted source code with Vim
22

33
===============================================================================
4-
*publish-contents*
54
Contents ~
65

7-
1. Introduction |publish-introduction|
8-
2. Installation & usage |publish-installation-usage|
9-
3. Publishing to a remote location (website)
10-
4. Contact |publish-contact|
11-
5. License |publish-license|
6+
1. Introduction |publish-introduction|
7+
2. Installation & usage |publish-installation-usage|
8+
3. Publishing to a remote location (website) |publishing-to-remote-location|
9+
4. Contact |publish-contact|
10+
5. License |publish-license|
11+
6. References |publish-references|
1212

1313
===============================================================================
14-
*publish-introduction*
14+
*publish-introduction*
1515
Introduction ~
1616

17-
The Vim text editor includes the script |2html.vim| which can be used to convert
18-
a syntax highlighted buffer in Vim to an HTML document that, when viewed in a
19-
web browser, should look exactly the same. After using that script for a while
20-
and discovering the excellent Exuberant Ctags [1] I wondered "Wouldn't it be
21-
nice to have those tags converted to hyperlinks when I publish source code as
22-
HTML?".
17+
The Vim text editor includes the script |2html.vim| which can be used to
18+
convert a syntax highlighted buffer in Vim to an HTML document that, when
19+
viewed in a web browser, should look exactly the same. After using that script
20+
for a while and discovering the excellent Exuberant Ctags [1] I wondered
21+
_"Wouldn't it be nice to have those tags converted to hyperlinks when I publish
22+
source code as HTML?"_.
2323

2424
After several attempts I managed a working prototype, but it was quite rough
2525
around the edges and I didn't really have the time or interest to clean it up.
@@ -29,91 +29,105 @@ wondering what the result looks like, I've published the plug-in source code
2929
[2] as a demonstration.
3030

3131
===============================================================================
32-
*publish-installation-usage*
32+
*publish-installation-usage*
3333
Installation & usage ~
3434

35-
Unzip the most recent ZIP archive [3] file inside your Vim profile directory
36-
(usually this is '~/.vim' on UNIX and '%USERPROFILE%\vimfiles' on Windows),
37-
restart Vim and execute the command ':helptags ~/.vim/doc' (use ':helptags
38-
~\vimfiles\doc' instead on Windows). As an example we'll publish the plug-in
39-
using itself. First create a tags file that contains entries for the files you
40-
want to publish using a shell command such as:
41-
>
42-
$ ctags -Rf ~/.publish_tags ~/.vim/
35+
_Please note that the vim-publish plug-in requires my vim-misc plug-in which is
36+
separately distributed._
37+
38+
Unzip the most recent ZIP archives of the vim-publish [3] and vim-misc [4]
39+
plug-ins inside your Vim profile directory (usually this is '~/.vim' on UNIX
40+
and '%USERPROFILE%\vimfiles' on Windows), restart Vim and execute the command
41+
':helptags ~/.vim/doc' (use ':helptags ~\vimfiles\doc' instead on Windows). If
42+
you prefer you can also use Pathogen [5], Vundle [6] or a similar tool to
43+
install & update the vim-publish [7] and vim-misc [8] plug-ins using a local
44+
clone of the git repository.
4345

46+
As an example we'll publish the plug-in using itself. First create a tags file
47+
that contains entries for the files you want to publish using a shell command
48+
such as:
49+
>
50+
$ ctags -Rf ~/.publish_tags ~/.vim/
51+
<
4452
If this doesn't work because |ctags| isn't installed you can download it from
4553
the Exuberant Ctags homepage [1], or if you're running Debian/Ubuntu you can
4654
install it by executing the following shell command:
4755
>
48-
$ sudo apt-get install exuberant-ctags
49-
56+
$ sudo apt-get install exuberant-ctags
57+
<
5058
The plug-in needs an up-to-date tags file so that it can create hyperlinks
5159
between the published files. Now start Vim and write a script that registers
5260
the tags file you just created and calls the function 'Publish()' as follows:
5361
>
54-
:set tags=~/.publish_tags
55-
:let sources = '/home/peter/.vim'
56-
:let target = 'sftp://peterodding.com/code/vim/profile'
57-
:call Publish(sources, target, [
58-
\ 'autoload/xolox/escape.vim',
59-
\ 'autoload/xolox/path.vim',
60-
\ 'autoload/publish.vim',
61-
\ 'plugin/publish.vim',
62-
\ ])
63-
64-
Change the 'sources' and 'target' variables to reflect your situation, save
65-
the script as '~/publish_test.vim' and try it in Vim by executing the command
62+
:set tags=~/.publish_tags
63+
:let sources = '/home/peter/.vim'
64+
:let target = 'sftp://peterodding.com/code/vim/profile'
65+
:call Publish(sources, target, [
66+
\ 'autoload/xolox/escape.vim',
67+
\ 'autoload/xolox/path.vim',
68+
\ 'autoload/publish.vim',
69+
\ 'plugin/publish.vim',
70+
\ ])
71+
<
72+
Change the 'sources' and 'target' variables to reflect your situation, save the
73+
script as '~/publish_test.vim' and try it in Vim by executing the command
6674
':source ~/publish_test.vim'. If everything goes well Vim will be busy for a
6775
moment and after that you will find a bunch of syntax highlighted, interlinked
6876
HTML documents in the 'target' directory!
6977

7078
===============================================================================
79+
*publishing-to-remote-location*
7180
Publishing to a remote location (website) ~
7281

7382
As you can see from the example above it's possible to publish files directly
7483
to your web server using the |netrw| plug-in that's bundled with Vim, simply by
75-
starting the 'target' path with 'sftp://'. All you need for this to work is
76-
the ability to establish SCP [4] connections to your server. There are however
77-
two disadvantages to remote publishing over SFTP [5]:
84+
starting the 'target' path with 'sftp://'. All you need for this to work is the
85+
ability to establish SCP [9] connections to your server. There are however two
86+
disadvantages to remote publishing over SFTP [10]:
7887

79-
- The 'publish.vim' plug-in can't automatically create directories on the
88+
1. The 'publish.vim' plug-in can't automatically create directories on the
8089
remote side, which means you'll have to do so by hand -- very bothersome.
8190

82-
- It can take a while to publish a dozen files because a new connection is
91+
2. It can take a while to publish a dozen files because a new connection is
8392
established for every file that's uploaded to the remote location.
8493

8594
As a workaround to both of these issues the 'publish.vim' plug-in will
86-
automatically use rsync [6] when both the local and remote system have it
95+
automatically use rsync [11] when both the local and remote system have it
8796
installed. This cuts the time to publish to a remote location in half and
8897
enables the plug-in to automatically create directories on the remote side.
8998

9099
===============================================================================
91-
*publish-contact*
100+
*publish-contact*
92101
Contact ~
93102

94103
If you have questions, bug reports, suggestions, etc. the author can be
95104
contacted at peter@peterodding.com. The latest version is available at
96-
http://peterodding.com/code/vim/publish/ and http://github.com/xolox/vim-publish.
97-
If you like the script please vote for it on Vim Online [7].
105+
http://peterodding.com/code/vim/publish/ and http://github.com/xolox/vim-
106+
publish. If you like the script please vote for it on Vim Online [12].
98107

99108
===============================================================================
100-
*publish-license*
109+
*publish-license*
101110
License ~
102111

103-
This software is licensed under the MIT license [8]. Š 2013 Peter Odding
112+
This software is licensed under the MIT license [13]. Š 2013 Peter Odding
104113
<peter@peterodding.com>.
105114

106115
===============================================================================
107-
*publish-references*
116+
*publish-references*
108117
References ~
109118

110119
[1] http://ctags.sourceforge.net/
111120
[2] http://peterodding.com/code/vim/profile/plugin/publish.vim
112121
[3] http://peterodding.com/code/vim/downloads/publish.zip
113-
[4] http://en.wikipedia.org/wiki/Secure_copy
114-
[5] http://en.wikipedia.org/wiki/SSH_file_transfer_protocol
115-
[6] http://en.wikipedia.org/wiki/rsync
116-
[7] http://www.vim.org/scripts/script.php?script_id=2252
117-
[8] http://en.wikipedia.org/wiki/MIT_License
122+
[4] http://peterodding.com/code/vim/downloads/misc.zip
123+
[5] http://www.vim.org/scripts/script.php?script_id=2332
124+
[6] https://github.com/gmarik/vundle
125+
[7] https://github.com/xolox/vim-publish
126+
[8] https://github.com/xolox/vim-misc
127+
[9] http://en.wikipedia.org/wiki/Secure_copy
128+
[10] http://en.wikipedia.org/wiki/SSH_file_transfer_protocol
129+
[11] http://en.wikipedia.org/wiki/rsync
130+
[12] http://www.vim.org/scripts/script.php?script_id=2252
131+
[13] http://en.wikipedia.org/wiki/MIT_License
118132

119133
vim: ft=help

plugin/publish.vim

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim plug-in
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: September 4, 2011
3+
" Last Change: August 19, 2013
44
" URL: http://peterodding.com/code/vim/publish/
55

66
" Support for automatic update using the GLVS plug-in.
@@ -11,6 +11,19 @@ if &cp || exists('g:loaded_publish')
1111
finish
1212
endif
1313

14+
" Make sure vim-misc is installed.
15+
try
16+
" The point of this code is to do something completely innocent while making
17+
" sure the vim-misc plug-in is installed. We specifically don't use Vim's
18+
" exists() function because it doesn't load auto-load scripts that haven't
19+
" already been loaded yet (last tested on Vim 7.3).
20+
call type(g:xolox#misc#version)
21+
catch
22+
echomsg "Warning: The vim-publish plug-in requires the vim-misc plug-in which seems not to be installed! For more information please review the installation instructions in the readme (also available on the homepage and on GitHub). The vim-publish plug-in will now be disabled."
23+
let g:loaded_publish = 1
24+
finish
25+
endtry
26+
1427
if !exists('g:publish_omit_dothtml')
1528
let g:publish_omit_dothtml = 0
1629
endif

0 commit comments

Comments
 (0)