aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-07-29 02:03:18 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-07-29 20:50:07 +0200
commit28a681d37d320ec66b7dc1039795faa8b4b895a1 (patch)
tree5ec6111a4bbfad5d85ea569d303f22f81f905f45
parent80dda6892612de8405744b549aa2c2578a82a1b5 (diff)
downloadrneovim-28a681d37d320ec66b7dc1039795faa8b4b895a1.tar.gz
rneovim-28a681d37d320ec66b7dc1039795faa8b4b895a1.tar.bz2
rneovim-28a681d37d320ec66b7dc1039795faa8b4b895a1.zip
vim-patch:f0d58efc9dc4
Update runtime files. https://github.com/vim/vim/commit/f0d58efc9dc46be37c629cbc99b4125448ca39fd
-rw-r--r--runtime/autoload/tohtml.vim122
-rw-r--r--runtime/doc/indent.txt22
-rw-r--r--runtime/doc/motion.txt2
-rw-r--r--runtime/doc/options.txt11
-rw-r--r--runtime/doc/pattern.txt2
-rw-r--r--runtime/doc/syntax.txt12
-rw-r--r--runtime/doc/tagsrch.txt4
-rw-r--r--runtime/plugin/tohtml.vim137
-rw-r--r--runtime/syntax/2html.vim93
9 files changed, 244 insertions, 161 deletions
diff --git a/runtime/autoload/tohtml.vim b/runtime/autoload/tohtml.vim
index d972ad63fe..2d874c690d 100644
--- a/runtime/autoload/tohtml.vim
+++ b/runtime/autoload/tohtml.vim
@@ -1,6 +1,6 @@
" Vim autoload file for the tohtml plugin.
" Maintainer: Ben Fritz <fritzophrenic@gmail.com>
-" Last Change: 2013 Sep 03
+" Last Change: 2018 Nov 11
"
" Additional contributors:
"
@@ -544,12 +544,16 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
" add required javascript in reverse order so we can just call append again
" and again without adjusting {{{
- " insert script closing tag
- call append(style_start, [
- \ '',
- \ s:settings.use_xhtml ? '//]]>' : '-->',
- \ "</script>"
- \ ])
+ let s:uses_script = s:settings.dynamic_folds || s:settings.line_ids || !empty(s:settings.prevent_copy)
+
+ " insert script closing tag if needed
+ if s:uses_script
+ call append(style_start, [
+ \ '',
+ \ s:settings.use_xhtml ? '//]]>' : '-->',
+ \ "</script>"
+ \ ])
+ endif
" insert script which corrects the size of small input elements in
" prevent_copy mode. See 2html.vim for details on why this is needed and how
@@ -575,55 +579,61 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
\ '}'
\ ])
endif
- "
+
" insert javascript to get IDs from line numbers, and to open a fold before
" jumping to any lines contained therein
- call append(style_start, [
- \ " /* Always jump to new location even if the line was hidden inside a fold, or",
- \ " * we corrected the raw number to a line ID.",
- \ " */",
- \ " if (lineElem) {",
- \ " lineElem.scrollIntoView(true);",
- \ " }",
- \ " return true;",
- \ "}",
- \ "if ('onhashchange' in window) {",
- \ " window.onhashchange = JumpToLine;",
- \ "}"
- \ ])
- if s:settings.dynamic_folds
+ if s:settings.line_ids
+ call append(style_start, [
+ \ " /* Always jump to new location even if the line was hidden inside a fold, or",
+ \ " * we corrected the raw number to a line ID.",
+ \ " */",
+ \ " if (lineElem) {",
+ \ " lineElem.scrollIntoView(true);",
+ \ " }",
+ \ " return true;",
+ \ "}",
+ \ "if ('onhashchange' in window) {",
+ \ " window.onhashchange = JumpToLine;",
+ \ "}"
+ \ ])
+
+ if s:settings.dynamic_folds
+ call append(style_start, [
+ \ "",
+ \ " /* navigate upwards in the DOM tree to open all folds containing the line */",
+ \ " var node = lineElem;",
+ \ " while (node && node.id != 'vimCodeElement".s:settings.id_suffix."')",
+ \ " {",
+ \ " if (node.className == 'closed-fold')",
+ \ " {",
+ \ " /* toggle open the fold ID (remove window ID) */",
+ \ " toggleFold(node.id.substr(4));",
+ \ " }",
+ \ " node = node.parentNode;",
+ \ " }",
+ \ ])
+ endif
+ endif
+
+ if s:settings.line_ids
call append(style_start, [
\ "",
- \ " /* navigate upwards in the DOM tree to open all folds containing the line */",
- \ " var node = lineElem;",
- \ " while (node && node.id != 'vimCodeElement".s:settings.id_suffix."')",
- \ " {",
- \ " if (node.className == 'closed-fold')",
- \ " {",
- \ " /* toggle open the fold ID (remove window ID) */",
- \ " toggleFold(node.id.substr(4));",
- \ " }",
- \ " node = node.parentNode;",
+ \ "/* function to open any folds containing a jumped-to line before jumping to it */",
+ \ "function JumpToLine()",
+ \ "{",
+ \ " var lineNum;",
+ \ " lineNum = window.location.hash;",
+ \ " lineNum = lineNum.substr(1); /* strip off '#' */",
+ \ "",
+ \ " if (lineNum.indexOf('L') == -1) {",
+ \ " lineNum = 'L'+lineNum;",
+ \ " }",
+ \ " if (lineNum.indexOf('W') == -1) {",
+ \ " lineNum = 'W1'+lineNum;",
\ " }",
+ \ " var lineElem = document.getElementById(lineNum);"
\ ])
endif
- call append(style_start, [
- \ "",
- \ "/* function to open any folds containing a jumped-to line before jumping to it */",
- \ "function JumpToLine()",
- \ "{",
- \ " var lineNum;",
- \ " lineNum = window.location.hash;",
- \ " lineNum = lineNum.substr(1); /* strip off '#' */",
- \ "",
- \ " if (lineNum.indexOf('L') == -1) {",
- \ " lineNum = 'L'+lineNum;",
- \ " }",
- \ " if (lineNum.indexOf('W') == -1) {",
- \ " lineNum = 'W1'+lineNum;",
- \ " }",
- \ " lineElem = document.getElementById(lineNum);"
- \ ])
" Insert javascript to toggle matching folds open and closed in all windows,
" if dynamic folding is active.
@@ -648,11 +658,13 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{
\ ])
endif
- " insert script tag; javascript is always needed for the line number
- " normalization for URL hashes
- call append(style_start, [
- \ "<script type='text/javascript'>",
- \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"])
+ if s:uses_script
+ " insert script tag; javascript is always needed for the line number
+ " normalization for URL hashes
+ call append(style_start, [
+ \ "<script type='text/javascript'>",
+ \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"])
+ endif
" Insert styles from all the generated html documents and additional styles
" for the table-based layout of the side-by-side diff. The diff should take
@@ -767,7 +779,7 @@ func! tohtml#GetUserSettings() "{{{
if user_settings.no_pre == 0
call tohtml#GetOption(user_settings,
\ 'expand_tabs',
- \ &expandtab || &ts != 8 || user_settings.number_lines ||
+ \ &expandtab || &ts != 8 || &vts != '' || user_settings.number_lines ||
\ (user_settings.dynamic_folds && !user_settings.no_foldcolumn))
else
let user_settings.expand_tabs = 1
diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt
index 952033d1b8..721aa93442 100644
--- a/runtime/doc/indent.txt
+++ b/runtime/doc/indent.txt
@@ -600,14 +600,14 @@ the use of square and curly brackets, and otherwise by community convention.
These conventions are not universally followed, so the Clojure indent script
offers a few configurable options, listed below.
-If the current vim does not include searchpairpos(), the indent script falls
+If the current vim does not include |searchpairpos()|, the indent script falls
back to normal 'lisp' indenting, and the following options are ignored.
*g:clojure_maxlines*
-Set maximum scan distance of searchpairpos(). Larger values trade performance
-for correctness when dealing with very long forms. A value of 0 will scan
-without limits.
+Set maximum scan distance of |searchpairpos()|. Larger values trade
+performance for correctness when dealing with very long forms. A value of 0
+will scan without limits.
>
" Default
let g:clojure_maxlines = 100
@@ -933,14 +933,14 @@ given are the defaults. Note that the variables are set to an expression, so
that you can change the value of 'shiftwidth' later.
Indent after an open paren: >
- let g:pyindent_open_paren = '&sw * 2'
+ let g:pyindent_open_paren = 'shiftwidth() * 2'
Indent after a nested paren: >
- let g:pyindent_nested_paren = '&sw'
+ let g:pyindent_nested_paren = 'shiftwidth()'
Indent for a continuation line: >
- let g:pyindent_continue = '&sw * 2'
+ let g:pyindent_continue = 'shiftwidth() * 2'
-The method uses searchpair() to look back for unclosed parenthesis. This can
-sometimes be slow, thus it timeouts after 150 msec. If you notice the
+The method uses |searchpair()| to look back for unclosed parenthesis. This
+can sometimes be slow, thus it timeouts after 150 msec. If you notice the
indenting isn't correct, you can set a larger timeout in msec: >
let g:pyindent_searchpair_timeout = 500
@@ -1036,7 +1036,7 @@ Furthermore, setting the variable b:verilog_indent_width to change the
indenting width (default is 'shiftwidth'): >
let b:verilog_indent_width = 4
- let b:verilog_indent_width = &sw * 2
+ let b:verilog_indent_width = shiftwidth() * 2
In addition, you can turn the verbose mode for debug issue: >
@@ -1159,7 +1159,7 @@ VIM *ft-vim-indent*
For indenting Vim scripts there is one variable that specifies the amount of
indent for a continuation line, a line that starts with a backslash: >
- :let g:vim_indent_cont = &sw * 3
+ :let g:vim_indent_cont = shiftwidth() * 3
Three times shiftwidth is the default value.
diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt
index d5a123e3ea..eacd08760b 100644
--- a/runtime/doc/motion.txt
+++ b/runtime/doc/motion.txt
@@ -993,7 +993,7 @@ remembered. You can return to that position with the "''" and "``" command,
unless the line containing that position was changed or deleted. The
following commands are "jump" commands: "'", "`", "G", "/", "?", "n", "N",
"%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and the
-commands that start editing a new file.
+commands that start editing a new file.
*CTRL-O*
CTRL-O Go to [count] Older cursor position in jump list
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index f8a6ee4a48..4378e22117 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1935,7 +1935,7 @@ A jump table for the options with a short description can be found at |Q_op|.
diff library.
algorithm:{text} Use the specified diff algorithm with the
- internal diff engine. Currently supported
+ internal diff engine. Currently supported
algorithms are:
myers the default algorithm
minimal spend extra time to generate the
@@ -6217,10 +6217,11 @@ A jump table for the options with a short description can be found at |Q_op|.
'thesaurus' 'tsr' string (default "")
global or local to buffer |global-local|
List of file names, separated by commas, that are used to lookup words
- for thesaurus completion commands |i_CTRL-X_CTRL-T|. Each line in
- the file should contain words with similar meaning, separated by
- non-keyword characters (white space is preferred). Maximum line
- length is 510 bytes.
+ for thesaurus completion commands |i_CTRL-X_CTRL-T|.
+
+ Each line in the file should contain words with similar meaning,
+ separated by non-keyword characters (white space is preferred).
+ Maximum line length is 510 bytes.
To include a comma in a file name precede it with a backslash. Spaces
after a comma are ignored, otherwise spaces are included in the file
diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt
index 022dc5607e..4322364fca 100644
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -295,7 +295,7 @@ the "*" is under your right hand middle finger (search to the right and down).
*E956*
In very rare cases a regular expression is used recursively. This can happen
-when executing a pattern takes a long time and when checkig for messages on
+when executing a pattern takes a long time and when checking for messages on
channels a callback is invoked that also uses a pattern or an autocommand is
triggered. In most cases this should be fine, but if a pattern is in use when
it's used again it fails. Usually this means there is something wrong with
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 4564d84955..a377d57a5a 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -649,12 +649,12 @@ the rendered page generated by 2html.vim.
:let g:html_no_pre = 1
<
*g:html_expand_tabs*
-Default: 1 if 'tabstop' is 8, 'expandtab' is 0, and no fold column or line
- numbers occur in the generated HTML;
- 0 otherwise.
-When 0, <Tab> characters in the buffer text are replaced with an appropriate
+Default: 0 if 'tabstop' is 8, 'expandtab' is 0, 'vartabstop' is not in use,
+ and no fold column or line numbers occur in the generated HTML;
+ 1 otherwise.
+When 1, <Tab> characters in the buffer text are replaced with an appropriate
number of space characters, or &nbsp; references if |g:html_no_pre| is 1.
-When 1, if |g:html_no_pre| is 0 or unset, <Tab> characters in the buffer text
+When 0, if |g:html_no_pre| is 0 or unset, <Tab> characters in the buffer text
are included as-is in the generated HTML. This is useful for when you want to
allow copy and paste from a browser without losing the actual whitespace in
the source document. Note that this can easily break text alignment and
@@ -752,6 +752,8 @@ When 1, generate XHTML 1.0 instead (XML compliant HTML).
:let g:html_use_xhtml = 1
<
+ vim:tw=78:sw=4:ts=8:sts=4:ft=help:norl:ai:noet:
+
ABEL *abel.vim* *ft-abel-syntax*
ABEL highlighting provides some user-defined options. To enable them, assign
diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt
index a4526a7f2c..f63535af11 100644
--- a/runtime/doc/tagsrch.txt
+++ b/runtime/doc/tagsrch.txt
@@ -173,8 +173,8 @@ commands explained above the tag stack will look like this:
1 1 main 1 harddisk2:text/vim/test
2 1 FuncB 59 harddisk2:text/vim/src/main.c
-The gettagstack() function returns the tag stack of a specified window. The
-settagstack() function modifies the tag stack of a window.
+The |gettagstack()| function returns the tag stack of a specified window. The
+|settagstack()| function modifies the tag stack of a window.
*E73*
When you try to use the tag stack while it doesn't contain anything you will
diff --git a/runtime/plugin/tohtml.vim b/runtime/plugin/tohtml.vim
index b438dea811..0cd931eada 100644
--- a/runtime/plugin/tohtml.vim
+++ b/runtime/plugin/tohtml.vim
@@ -1,82 +1,33 @@
" Vim plugin for converting a syntax highlighted file to HTML.
" Maintainer: Ben Fritz <fritzophrenic@gmail.com>
-" Last Change: 2015 Sep 08
+" Last Change: 2018 Nov 11
"
" The core of the code is in $VIMRUNTIME/autoload/tohtml.vim and
" $VIMRUNTIME/syntax/2html.vim
"
-" TODO: {{{
-" * Options for generating the CSS in external style sheets. New :TOcss
-" command to convert the current color scheme into a (mostly) generic CSS
-" stylesheet which can be re-used. Alternate stylesheet support? Good start
-" by Erik Falor
-" ( https://groups.google.com/d/topic/vim_use/7XTmC4D22dU/discussion ).
-" * Add optional argument to :TOhtml command to specify mode (gui, cterm,
-" term) to use for the styling. Suggestion by "nacitar".
-" * Add way to override or specify which RGB colors map to the color numbers
-" in cterm. Get better defaults than just guessing? Suggestion by "nacitar".
-" * Disable filetype detection until after all processing is done.
-" * Add option for not generating the hyperlink on stuff that looks like a
-" URL? Or just color the link to fit with the colorscheme (and only special
-" when hovering)?
-" * Bug: Opera does not allow printing more than one page if uncopyable
-" regions is turned on. Possible solution: Add normal text line numbers with
-" display:none, set to display:inline for print style sheets, and hide
-" <input> elements for print, to allow Opera printing multiple pages (and
-" other uncopyable areas?). May need to make the new text invisible to IE
-" with conditional comments to prevent copying it, IE for some reason likes
-" to copy hidden text. Other browsers too?
-" * Bug: still a 1px gap throughout the fold column when html_prevent_copy is
-" "fn" in some browsers. Specifically, in Chromium on Ubuntu (but not Chrome
-" on Windows). Perhaps it is font related?
-" * Bug: still some gaps in the fold column when html_prevent_copy contains
-" 'd' and showing the whole diff (observed in multiple browsers). Only gaps
-" on diff lines though.
-" * Undercurl support via CSS3, with fallback to dotted or something:
-" https://groups.google.com/d/topic/vim_use/BzXA6He1pHg/discussion
-" * Redo updates for modified default foldtext (v11) when/if the patch is
-" accepted to modify it.
-" * Test case +diff_one_file-dynamic_folds+expand_tabs-hover_unfold
-" +ignore_conceal-ignore_folding+no_foldcolumn+no_pre+no_progress
-" +number_lines-pre_wrap-use_css+use_xhtml+whole_filler.xhtml
-" does not show the whole diff filler as it is supposed to?
-" * Bug: when 'isprint' is wrong for the current encoding, will generate
-" invalid content. Can/should anything be done about this? Maybe a separate
-" plugin to correct 'isprint' based on encoding?
-" * Check to see if the windows-125\d encodings actually work in Unix without
-" the 8bit- prefix. Add prefix to autoload dictionaries for Unix if not.
-" * Font auto-detection similar to
-" http://www.vim.org/scripts/script.php?script_id=2384 but for a variety of
-" platforms.
-" * Error thrown when sourcing 2html.vim directly when plugins are not loaded.
-" * Pull in code from http://www.vim.org/scripts/script.php?script_id=3113 :
-" - listchars support
-" - full-line background highlight
-" - other?
-" * Make it so deleted lines in a diff don't create side-scrolling (get it
-" free with full-line background highlight above).
-" * Restore open/closed folds and cursor position after processing each file
-" with option not to restore for speed increase.
-" * Add extra meta info (generation time, etc.)?
-" * Tidy up so we can use strict doctype in even more situations
-" * Implementation detail: add threshold for writing the lines to the html
-" buffer before we're done (5000 or so lines should do it)
-" * TODO comments for code cleanup scattered throughout
-"}}}
-
if exists('g:loaded_2html_plugin')
finish
endif
-let g:loaded_2html_plugin = 'vim7.4_v2'
+let g:loaded_2html_plugin = 'vim8.1_v1'
"
" Changelog: {{{
-" 7.4_v2 (this version): Fix error raised when converting a diff containing
+" 8.1_v1 (this version): Fix Bitbucket issue #6: Don't generate empty script
+" tag.
+" Fix Bitbucket issue #5: javascript should
+" declare variables with "var".
+" Fix Bitbucket issue #13: errors thrown sourcing
+" 2html.vim directly when plugins not loaded.
+" Fix Bitbucket issue #16: support 'vartabstop'.
+"
+" 7.4 updates: {{{
+" 7.4_v2 (Vim 7.4.0899): Fix error raised when converting a diff containing
" an empty buffer. Jan Stocker: allow g:html_font to
" take a list so it is easier to specfiy fallback
" fonts in the generated CSS.
" 7.4_v1 (Vim 7.4.0000): Fix modeline mangling for new "Vim:" format, and
" also for version-specific modelines like "vim>703:".
+"}}}
"
" 7.3 updates: {{{
" 7.3_v14 (Vim 7.3.1246): Allow suppressing line number anchors using
@@ -170,9 +121,69 @@ let g:loaded_2html_plugin = 'vim7.4_v2'
"}}}
"}}}
+" TODO: {{{
+" * Check the issue tracker:
+" https://bitbucket.org/fritzophrenic/vim-tohtml/issues?status=new&status=open
+" * Options for generating the CSS in external style sheets. New :TOcss
+" command to convert the current color scheme into a (mostly) generic CSS
+" stylesheet which can be re-used. Alternate stylesheet support? Good start
+" by Erik Falor
+" ( https://groups.google.com/d/topic/vim_use/7XTmC4D22dU/discussion ).
+" * Add optional argument to :TOhtml command to specify mode (gui, cterm,
+" term) to use for the styling. Suggestion by "nacitar".
+" * Add way to override or specify which RGB colors map to the color numbers
+" in cterm. Get better defaults than just guessing? Suggestion by "nacitar".
+" * Disable filetype detection until after all processing is done.
+" * Add option for not generating the hyperlink on stuff that looks like a
+" URL? Or just color the link to fit with the colorscheme (and only special
+" when hovering)?
+" * Bug: Opera does not allow printing more than one page if uncopyable
+" regions is turned on. Possible solution: Add normal text line numbers with
+" display:none, set to display:inline for print style sheets, and hide
+" <input> elements for print, to allow Opera printing multiple pages (and
+" other uncopyable areas?). May need to make the new text invisible to IE
+" with conditional comments to prevent copying it, IE for some reason likes
+" to copy hidden text. Other browsers too?
+" * Bug: still a 1px gap throughout the fold column when html_prevent_copy is
+" "fn" in some browsers. Specifically, in Chromium on Ubuntu (but not Chrome
+" on Windows). Perhaps it is font related?
+" * Bug: still some gaps in the fold column when html_prevent_copy contains
+" 'd' and showing the whole diff (observed in multiple browsers). Only gaps
+" on diff lines though.
+" * Undercurl support via CSS3, with fallback to dotted or something:
+" https://groups.google.com/d/topic/vim_use/BzXA6He1pHg/discussion
+" * Redo updates for modified default foldtext (v11) when/if the patch is
+" accepted to modify it.
+" * Test case +diff_one_file-dynamic_folds+expand_tabs-hover_unfold
+" +ignore_conceal-ignore_folding+no_foldcolumn+no_pre+no_progress
+" +number_lines-pre_wrap-use_css+use_xhtml+whole_filler.xhtml
+" does not show the whole diff filler as it is supposed to?
+" * Bug: when 'isprint' is wrong for the current encoding, will generate
+" invalid content. Can/should anything be done about this? Maybe a separate
+" plugin to correct 'isprint' based on encoding?
+" * Check to see if the windows-125\d encodings actually work in Unix without
+" the 8bit- prefix. Add prefix to autoload dictionaries for Unix if not.
+" * Font auto-detection similar to
+" http://www.vim.org/scripts/script.php?script_id=2384 but for a variety of
+" platforms.
+" * Pull in code from http://www.vim.org/scripts/script.php?script_id=3113 :
+" - listchars support
+" - full-line background highlight
+" - other?
+" * Make it so deleted lines in a diff don't create side-scrolling (get it
+" free with full-line background highlight above).
+" * Restore open/closed folds and cursor position after processing each file
+" with option not to restore for speed increase.
+" * Add extra meta info (generation time, etc.)?
+" * Tidy up so we can use strict doctype in even more situations
+" * Implementation detail: add threshold for writing the lines to the html
+" buffer before we're done (5000 or so lines should do it)
+" * TODO comments for code cleanup scattered throughout
+"}}}
+
" Define the :TOhtml command when:
" - 'compatible' is not set
-" - this plugin was not already loaded
+" - this plugin or user override was not already loaded
" - user commands are available. {{{
if !&cp && !exists(":TOhtml") && has("user_commands")
command -range=% -bar TOhtml :call tohtml#Convert2HTML(<line1>, <line2>)
diff --git a/runtime/syntax/2html.vim b/runtime/syntax/2html.vim
index ddc7819be2..4a2d1d3959 100644
--- a/runtime/syntax/2html.vim
+++ b/runtime/syntax/2html.vim
@@ -1,6 +1,6 @@
" Vim syntax support file
" Maintainer: Ben Fritz <fritzophrenic@gmail.com>
-" Last Change: 2015 Sep 08
+" Last Change: 2018 Nov 11
"
" Additional contributors:
"
@@ -633,6 +633,45 @@ if s:current_syntax == ''
let s:current_syntax = 'none'
endif
+" If the user is sourcing this script directly then the plugin version isn't
+" known because the main plugin script didn't load. In the usual case where the
+" user still has the full Vim runtime installed, or has this full plugin
+" installed in a package or something, then we can extract the version from the
+" main plugin file at it's usual spot relative to this file. Otherwise the user
+" is assembling their runtime piecemeal and we have no idea what versions of
+" other files may be present so don't even try to make a guess or assume the
+" presence of other specific files with specific meaning.
+"
+" We don't want to actually source the main plugin file here because the user
+" may have a good reason not to (e.g. they define their own TOhtml command or
+" something).
+"
+" If this seems way too complicated and convoluted, it is. Probably I should
+" have put the version information in the autoload file from the start. But the
+" version has been in the global variable for so long that changing it could
+" break a lot of user scripts.
+if exists("g:loaded_2html_plugin")
+ let s:pluginversion = g:loaded_2html_plugin
+else
+ if !exists("g:unloaded_tohtml_plugin")
+ let s:main_plugin_path = expand("<sfile>:p:h:h")."/plugin/tohtml.vim"
+ if filereadable(s:main_plugin_path)
+ let s:lines = readfile(s:main_plugin_path, "", 20)
+ call filter(s:lines, 'v:val =~ "loaded_2html_plugin = "')
+ if empty(s:lines)
+ let g:unloaded_tohtml_plugin = "unknown"
+ else
+ let g:unloaded_tohtml_plugin = substitute(s:lines[0], '.*loaded_2html_plugin = \([''"]\)\(\%(\1\@!.\)\+\)\1', '\2', '')
+ endif
+ unlet s:lines
+ else
+ let g:unloaded_tohtml_plugin = "unknown"
+ endif
+ unlet s:main_plugin_path
+ endif
+ let s:pluginversion = g:unloaded_tohtml_plugin
+endif
+
" Split window to create a buffer with the HTML file.
let s:orgbufnr = winbufnr(0)
let s:origwin_stl = &l:stl
@@ -721,7 +760,7 @@ endif
call extend(s:lines, [
\ ("<title>".expand("%:p:~")."</title>"),
\ ("<meta name=\"Generator\" content=\"Vim/".v:version/100.".".v:version%100.'"'.s:tag_close),
- \ ("<meta name=\"plugin-version\" content=\"".g:loaded_2html_plugin.'"'.s:tag_close)
+ \ ("<meta name=\"plugin-version\" content=\"".s:pluginversion.'"'.s:tag_close)
\ ])
call add(s:lines, '<meta name="syntax" content="'.s:current_syntax.'"'.s:tag_close)
call add(s:lines, '<meta name="settings" content="'.
@@ -807,12 +846,15 @@ if s:settings.use_css
endif
endif
-" insert script tag; javascript is always needed for the line number
-" normalization for URL hashes
-call extend(s:lines, [
- \ "",
- \ "<script type='text/javascript'>",
- \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"])
+let s:uses_script = s:settings.dynamic_folds || s:settings.line_ids || !empty(s:settings.prevent_copy)
+
+" insert script tag if needed
+if s:uses_script
+ call extend(s:lines, [
+ \ "",
+ \ "<script type='text/javascript'>",
+ \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"])
+endif
" insert javascript to toggle folds open and closed
if s:settings.dynamic_folds
@@ -849,8 +891,9 @@ if s:settings.line_ids
\ " if (lineNum.indexOf('L') == -1) {",
\ " lineNum = 'L'+lineNum;",
\ " }",
- \ " lineElem = document.getElementById(lineNum);"
+ \ " var lineElem = document.getElementById(lineNum);"
\ ])
+
if s:settings.dynamic_folds
call extend(s:lines, [
\ "",
@@ -940,12 +983,14 @@ if !empty(s:settings.prevent_copy)
\ ])
endif
-" insert script closing tag
-call extend(s:lines, [
- \ '',
- \ s:settings.use_xhtml ? '//]]>' : '-->',
- \ "</script>"
- \ ])
+" insert script closing tag if needed
+if s:uses_script
+ call extend(s:lines, [
+ \ '',
+ \ s:settings.use_xhtml ? '//]]>' : '-->',
+ \ "</script>"
+ \ ])
+endif
call extend(s:lines, ["</head>"])
if !empty(s:settings.prevent_copy)
@@ -1525,10 +1570,22 @@ while s:lnum <= s:end
if s:settings.expand_tabs
let s:offset = 0
let s:idx = stridx(s:expandedtab, "\t")
+ let s:tablist = split(&vts,',')
+ if empty(s:tablist)
+ let s:tablist = [ &ts ]
+ endif
+ let s:tabidx = 0
+ let s:tabwidth = 0
while s:idx >= 0
+ while s:startcol+s:idx > s:tabwidth + s:tablist[s:tabidx]
+ let s:tabwidth += s:tablist[s:tabidx]
+ if s:tabidx < len(s:tablist)-1
+ let s:tabidx = s:tabidx+1
+ endif
+ endwhile
if has("multi_byte_encoding")
if s:startcol + s:idx == 1
- let s:i = &ts
+ let s:i = s:tablist[s:tabidx]
else
if s:idx == 0
let s:prevc = matchstr(s:line, '.\%' . (s:startcol + s:idx + s:offset) . 'c')
@@ -1536,11 +1593,11 @@ while s:lnum <= s:end
let s:prevc = matchstr(s:expandedtab, '.\%' . (s:idx + 1) . 'c')
endif
let s:vcol = virtcol([s:lnum, s:startcol + s:idx + s:offset - len(s:prevc)])
- let s:i = &ts - (s:vcol % &ts)
+ let s:i = s:tablist[s:tabidx] - (s:vcol - s:tabwidth)
endif
let s:offset -= s:i - 1
else
- let s:i = &ts - ((s:idx + s:startcol - 1) % &ts)
+ let s:i = s:tablist[s:tabidx] - ((s:idx + s:startcol - 1) - s:tabwidth)
endif
let s:expandedtab = substitute(s:expandedtab, '\t', repeat(' ', s:i), '')
let s:idx = stridx(s:expandedtab, "\t")