├── .gitignore ├── addon-info.json ├── CHANGELOG.md ├── .travis.yml ├── plugin ├── commands.vim └── mappings.vim ├── CONTRIBUTING.md ├── vroom ├── setupvroom.vim └── main.vroom ├── instant └── flags.vim ├── README.md ├── doc └── syncopate.txt ├── autoload └── syncopate.vim └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags 2 | -------------------------------------------------------------------------------- /addon-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "syncopate", 3 | "description": "Syntax-highlighted copy-paste", 4 | "version": "0.2.0", 5 | "author": "Google", 6 | "repository": {"type": "git", "url": "git://github.com/google/vim-syncopate"}, 7 | "dependencies": { 8 | "maktaba": {"type": "git", "url": "git://github.com/google/vim-maktaba"} 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Current changes 2 | 3 | ## Features 4 | 5 | - New `'operatorfunc'` function `syncopate#ClipboardOperatorfunc()`, and default mapping `,<`. 6 | - This lets you do things like `,<>` mapping uses this instead of browser export 17 | * `:HtmlExport` renamed to `:SyncopateExportToBrowser` for clarity 18 | * Users can choose browser command with `browser` option (see `:help syncopate:browser`) 19 | 20 | ## Bugfixes 21 | 22 | * Syncopate failed in non-writable directories (#2) 23 | * HTML output was unreadable (yellow-on-white) when `t_Co=8` (#5) 24 | * Better handling of `'background'` option (important for `solarized` colorscheme) (#6) 25 | * Direct-to-clipboard was eliminating users' background colours (#16) 26 | 27 | # 0.1.0 28 | 29 | *2014-11-19* 30 | 31 | ## Features 32 | 33 | * `:HtmlExport` command exports to a browser tab 34 | * Optional mapping (default: `<>`) to run `:HtmlExport` 35 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | env: 3 | matrix: 4 | - CI_TARGET=vim MAKTABA_VERSION=1.9.0 5 | - CI_TARGET=vim MAKTABA_VERSION=master 6 | - CI_TARGET=neovim MAKTABA_VERSION=master 7 | before_script: 8 | - sudo apt-get update 9 | - sudo apt-get install python3-dev 10 | - if [ $CI_TARGET = vim ]; then 11 | sudo apt-get install vim-gnome; 12 | elif [ $CI_TARGET = neovim ]; then 13 | eval "$(curl -Ss https://raw.githubusercontent.com/neovim/bot-ci/master/scripts/travis-setup.sh) nightly-x64" && 14 | wget https://bootstrap.pypa.io/get-pip.py && 15 | sudo python3 get-pip.py --allow-external sudo && 16 | sudo pip3 install neovim; 17 | fi 18 | - wget https://github.com/google/vroom/releases/download/v0.12.0/vroom_0.12.0-1_all.deb 19 | - sudo dpkg -i ./vroom_0.12.0-1_all.deb 20 | - git clone -b ${MAKTABA_VERSION} https://github.com/google/vim-maktaba.git ../maktaba/ 21 | - git clone https://github.com/google/vim-glaive.git ../glaive/ 22 | services: 23 | - xvfb 24 | script: 25 | - '[ $CI_TARGET = neovim ] && VROOM_ARGS="--neovim" || VROOM_ARGS=""' 26 | - vroom $VROOM_ARGS --crawl ./vroom/ 27 | matrix: 28 | fast_finish: true 29 | allow_failures: 30 | - env: CI_TARGET=neovim MAKTABA_VERSION=master 31 | -------------------------------------------------------------------------------- /plugin/commands.vim: -------------------------------------------------------------------------------- 1 | " Copyright 2014 Google Inc. All rights reserved. 2 | " 3 | " Licensed under the Apache License, Version 2.0 (the "License"); 4 | " you may not use this file except in compliance with the License. 5 | " You may obtain a copy of the License at 6 | " 7 | " http://www.apache.org/licenses/LICENSE-2.0 8 | " 9 | " Unless required by applicable law or agreed to in writing, software 10 | " distributed under the License is distributed on an "AS IS" BASIS, 11 | " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | " See the License for the specific language governing permissions and 13 | " limitations under the License. 14 | 15 | " Maktaba boilerplate (which also prevents re-entry). 16 | let [s:plugin, s:enter] = maktaba#plugin#Enter(expand(':p')) 17 | if !s:enter 18 | finish 19 | endif 20 | 21 | 22 | "" 23 | " Export syntax-highlighted text, in HTML format, to a browser tab. 24 | command -nargs=0 -range=% SyncopateExportToBrowser 25 | \ ,call syncopate#ExportToBrowser() 26 | 27 | 28 | "" 29 | " Export syntax-highlighted text, in HTML format, to the clipboard. 30 | " Requires xclip to be installed on your system. 31 | command -nargs=0 -range=% SyncopateExportToClipboard 32 | \ ,call syncopate#ExportToClipboard() 33 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Want to contribute? Great! First, read this page (including the small print at the end). 2 | 3 | ### Before you contribute 4 | Before we can use your code, you must sign the 5 | [Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1) 6 | (CLA), which you can do online. The CLA is necessary mainly because you own the 7 | copyright to your changes, even after your contribution becomes part of our 8 | codebase, so we need your permission to use and distribute your code. We also 9 | need to be sure of various other things—for instance that you'll tell us if you 10 | know that your code infringes on other people's patents. You don't have to sign 11 | the CLA until after you've submitted your code for review and a member has 12 | approved it, but you must do it before we can put your code into our codebase. 13 | Before you start working on a larger contribution, you should get in touch with 14 | us first through the issue tracker with your idea so that we can help out and 15 | possibly guide you. Coordinating up front makes it much easier to avoid 16 | frustration later on. 17 | 18 | ### Code reviews 19 | All submissions, including submissions by project members, require review. We 20 | use Github pull requests for this purpose. 21 | 22 | ### The small print 23 | Contributions made by corporations are covered by a different agreement than 24 | the one above, the Software Grant and Corporate Contributor License Agreement. 25 | -------------------------------------------------------------------------------- /plugin/mappings.vim: -------------------------------------------------------------------------------- 1 | " Copyright 2014 Google Inc. All rights reserved. 2 | " 3 | " Licensed under the Apache License, Version 2.0 (the "License"); 4 | " you may not use this file except in compliance with the License. 5 | " You may obtain a copy of the License at 6 | " 7 | " http://www.apache.org/licenses/LICENSE-2.0 8 | " 9 | " Unless required by applicable law or agreed to in writing, software 10 | " distributed under the License is distributed on an "AS IS" BASIS, 11 | " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | " See the License for the specific language governing permissions and 13 | " limitations under the License. 14 | 15 | " Maktaba boilerplate (which also prevents re-entry). 16 | let [s:plugin, s:enter] = maktaba#plugin#Enter(expand(':p')) 17 | if !s:enter 18 | finish 19 | endif 20 | 21 | 22 | let s:prefix = s:plugin.MapPrefix('<') 23 | 24 | 25 | "" 26 | " Export syntax-highlighted text to a browser tab as HTML, using the current 27 | " syncopate settings. 28 | " 29 | " In visual mode, this only exports the selected text. 30 | let s:clipboard_map = s:prefix . '>' 31 | execute 'noremap ' s:clipboard_map 32 | \ ':SyncopateExportToClipboard' 33 | " noremap, followed by ounmap, makes the mapping valid in normal and visual 34 | " modes. 35 | execute 'ounmap' s:clipboard_map 36 | 37 | 38 | "" 39 | " 'operatorfunc' mapping, suitable for use with text objects. 40 | execute 'nnoremap ' s:prefix 41 | \ ':set operatorfunc=syncopate#ClipboardOperatorfuncg@' 42 | -------------------------------------------------------------------------------- /vroom/setupvroom.vim: -------------------------------------------------------------------------------- 1 | " Copyright 2015 Google Inc. All rights reserved. 2 | " 3 | " Licensed under the Apache License, Version 2.0 (the "License"); 4 | " you may not use this file except in compliance with the License. 5 | " You may obtain a copy of the License at 6 | " 7 | " http://www.apache.org/licenses/LICENSE-2.0 8 | " 9 | " Unless required by applicable law or agreed to in writing, software 10 | " distributed under the License is distributed on an "AS IS" BASIS, 11 | " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | " See the License for the specific language governing permissions and 13 | " limitations under the License. 14 | 15 | " This file is used from vroom scripts to bootstrap the syncopate plugin and 16 | " configure it to work properly under vroom. 17 | 18 | " Syncopate does not support compatible mode. 19 | set nocompatible 20 | 21 | " Install maktaba from local dir. 22 | let s:repo = expand(':p:h:h') 23 | let s:search_dir = fnamemodify(s:repo, ':h') 24 | " We'd like to use maktaba#path#Join, but maktaba doesn't exist yet. 25 | let s:slash = exists('+shellslash') && !&shellslash ? '\' : '/' 26 | for s:plugin_dirname in ['maktaba', 'vim-maktaba'] 27 | let s:bootstrap_path = join([s:search_dir, s:plugin_dirname, 'bootstrap.vim'], 28 | \ s:slash) 29 | if filereadable(s:bootstrap_path) 30 | execute 'source' s:bootstrap_path 31 | break 32 | endif 33 | endfor 34 | 35 | " Install the syncopate plugin. 36 | call maktaba#plugin#GetOrInstall(s:repo) 37 | 38 | " Install Glaive from local dir. 39 | for s:plugin_dirname in ['glaive', 'vim-glaive'] 40 | let s:bootstrap_path = 41 | \ maktaba#path#Join([s:search_dir, s:plugin_dirname, 'bootstrap.vim']) 42 | if filereadable(s:bootstrap_path) 43 | execute 'source' s:bootstrap_path 44 | break 45 | endif 46 | endfor 47 | 48 | " Force plugin/ files to load since vroom installs the plugin after 49 | " |load-plugins| time. 50 | call maktaba#plugin#Get('syncopate').Load() 51 | 52 | " Load :TOhtml command (dependency of syncopate), normally loaded automatically 53 | " at vim startup. 54 | runtime plugin/tohtml.vim 55 | 56 | " Support vroom's fake shell executable and don't try to override it to sh. 57 | call maktaba#syscall#SetUsableShellRegex('\v.* 28 | $ cat > $VROOM_TEMPFILE (command) 29 | ~ Syncopate exported the entire file. 30 | 31 | Now it's in the clipboard as rich colored text. The "let" keyword is highlighted 32 | in the appropriate color (from the default colorscheme). Other syntax is also 33 | there, highlighted in various other colors. 34 | 35 | :echomsg join(readfile($VROOM_TEMPFILE), '') 36 | ~ *let*x*empty*'foo'*?*1*:*2* (glob) 37 | 38 | 39 | 40 | You can also use :SyncopateExportToBrowser to send the rich colored text to a 41 | browser window instead of the clipboard. 42 | 43 | :set filetype=vim 44 | % echo 'Beam me up!' 45 | :SyncopateExportToBrowser 46 | ! sensible-browser (\S+) 2>.* 47 | $ cat \1 > $VROOM_TEMPFILE (command) 48 | 49 | :echomsg join(readfile($VROOM_TEMPFILE), '') 50 | ~ *echo*'Beam me up!'* (glob) 51 | 52 | It uses sensible-browser by default. You can override it to use any browser via 53 | the "browser" flag. This is a maktaba flag, configured using the :Glaive tool. 54 | 55 | :Glaive syncopate browser=google-chrome 56 | :SyncopateExportToBrowser 57 | ! google-chrome (\S+) 2>.* 58 | $ 59 | -------------------------------------------------------------------------------- /instant/flags.vim: -------------------------------------------------------------------------------- 1 | " Copyright 2014 Google Inc. All rights reserved. 2 | " 3 | " Licensed under the Apache License, Version 2.0 (the "License"); 4 | " you may not use this file except in compliance with the License. 5 | " You may obtain a copy of the License at 6 | " 7 | " http://www.apache.org/licenses/LICENSE-2.0 8 | " 9 | " Unless required by applicable law or agreed to in writing, software 10 | " distributed under the License is distributed on an "AS IS" BASIS, 11 | " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | " See the License for the specific language governing permissions and 13 | " limitations under the License. 14 | 15 | 16 | "" 17 | " @section Introduction, intro 18 | " @order intro standard-config config commands functions 19 | " Syncopate makes it very easy to share beautiful code in webmail windows, 20 | " Google Docs, etc. 21 | " 22 | " Use the @command(SyncopateExportToBrowser) command to open a new browser tab 23 | " with your buffer's contents, syntax highlighting and all. (If you're in 24 | " |visual-mode|, only the selected text will be exported.) Then you can 25 | " copy-paste from the browser tab into your intended destination. 26 | " 27 | " Use a keymapping for even more convenience (see @flag(plugin[mappings])). 28 | " The default mapping is "<>". So if your || is set to ",", 29 | " then the mapping ",<>" will run @command(SyncopateExportToBrowser) for you. 30 | " (Mnemonic: "<>" is reminiscent of HTML tags, and it triggers HTML output.) 31 | " 32 | " Syncopate will automatically switch to the default colorscheme before output, 33 | " since this tends to show up better (and be less error-prone!) on white 34 | " backgrounds. You can change this behaviour with the @flag(change_colorscheme) 35 | " and @flag(colorscheme) settings. In any case, Syncopate restores your 36 | " original colorscheme once it's finished. 37 | 38 | "" 39 | " @section Configuring with standard settings, standard-config 40 | " Syncopate is based on the built-in |convert-to-HTML| functionality, which 41 | " already has a wealth of configurable settings. We try to use these settings 42 | " wherever possible. (For additional, Syncopate-specific settings, see 43 | " @section(config).) 44 | " 45 | " For example: many people who use line numbers in vim do not want them in the 46 | " HTML output, since they would show up when recipients copy-paste the code into 47 | " an editor window. By default, HTML output includes line numbers whenever vim 48 | " does. To force them not to appear, use the @setting(html_number_lines) 49 | " setting: add > 50 | " let g:html_number_lines = 0 51 | " < to your vimrc. 52 | " 53 | " To browse all available settings, go to the first one 54 | " (@setting(html_diff_one_file)) and scroll down from there. 55 | 56 | " Maktaba boilerplate (which also prevents re-entry). 57 | let [s:plugin, s:enter] = maktaba#plugin#Enter(expand(':p')) 58 | if !s:enter 59 | finish 60 | endif 61 | 62 | 63 | "" 64 | " Use a different colorscheme for the HTML output. This can make the text more 65 | " readable. 66 | call s:plugin.Flag('change_colorscheme', 1) 67 | 68 | 69 | "" 70 | " The colorscheme to switch to for the HTML output. The default is "default", 71 | " since it shows up nicely on a white background (as in most webmail windows). 72 | " 73 | " This setting has no effect if @flag(change_colorscheme) is false. 74 | call s:plugin.Flag('colorscheme', 'default') 75 | 76 | 77 | "" 78 | " The browser command which @command(SyncopateExportToBrowser) will use. 79 | " 80 | " The default, "sensible-browser", only works on Debian-based systems (including 81 | " Ubuntu). It can be configured by the "update-alternatives" command. If you 82 | " don't want to do this (or if you're not using a Debian-based system), you will 83 | " need to set this flag for the browser export to work. 84 | call s:plugin.Flag('browser', 'sensible-browser') 85 | 86 | 87 | "" 88 | " Controls whether @command(SyncopateExportToClipboard) will clear the 89 | " background colour. 90 | " 91 | " This can be useful for copy-pasting into a destination (e.g., some talk 92 | " slides) whose background colour might be slightly different than the 93 | " background in the editor. 94 | call s:plugin.Flag('clear_bg', 0) 95 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # syncopate 2 | 3 | (**Syn**)tax (**cop**)y-p(**a**)s(**te**). 4 | 5 | ## What's it for? 6 | 7 | To make sharing beautiful code as frictionless as possible. 8 | 9 | Say you have a nicely syntax-highlighted buffer in vim. 10 | This plugin lets you open a browser tab with that buffer's contents, including the highlighting. 11 | If you copy-paste into a webmail window, a Google Doc, etc., the syntax highlighting stays intact. 12 | 13 | Best of all, it cleans up after itself: it won't clutter your directories with `.html` files. 14 | 15 | ## How do I install it? 16 | 17 | Depends on your plugin manager. 18 | 19 | Note that syncopate is a [maktaba](https://github.com/google/vim-maktaba) plugin, so you will need to install maktaba (if your plugin manager doesn't handle dependencies). 20 | If you want to configure the plugin, we strongly recommend installing [glaive](https://github.com/google/vim-glaive) as well. 21 | 22 | Here are instructions for Vundle, the most popular plugin manager. 23 | Add the following lines between your `call vundle#begin()` and `call vundle#end()` lines. 24 | 25 | ```vim 26 | " Dependency; required for vim-syncopate. 27 | Plugin google/vim-maktaba 28 | 29 | " Strongly recommended: easy configuration of maktaba plugins. 30 | Plugin google/vim-glaive 31 | 32 | Plugin google/vim-syncopate 33 | ``` 34 | 35 | Syncopate is expected to work on any platform vim supports, but the default 36 | configuration may not work on your system and direct-to-clipboard support hasn't 37 | been implemented for some platforms. Contributions welcome! 38 | 39 | ### xclip 40 | 41 | Syncopate requires `xclip` to manipulate the clipboard. In most cases, 42 | installing it from your package manager should just work. 43 | 44 | Arch Linux's official repository has an `xclip` (0.12.4) which is too old: it 45 | doesn't support `--target`. Arch users should install `xclip-svn` from AUR: 46 | 47 | ``` 48 | yaourt -S xclip-svn 49 | ``` 50 | 51 | ## How do I use it? 52 | 53 | ### Use the clipboard directly 54 | 55 | Use the `:SyncopateExportToClipboard` command. 56 | It populates the clipboard with the contents of your buffer (or just part of it, if you're in visual mode), including highlighting. 57 | You can then paste your beautiful code into a compose window (such as Gmail). 58 | 59 | Of course, it's even better with a keymapping, which you can enable using Glaive: 60 | 61 | ```vim 62 | " This line needs to go anywhere after 'call vundle#end()'. 63 | call glaive#Install() 64 | 65 | " Enable keymappings. 66 | Glaive syncopate plugin[mappings] 67 | ``` 68 | 69 | By default, syncopate's mappings all start with the prefix `<`. 70 | You can change the prefix by giving `plugin[mappings]` a value, like so: 71 | ```vim 72 | Glaive syncopate plugin[mappings]='qwer' 73 | ``` 74 | The following examples will assume you're using the default prefix, and that your [``](http://stackoverflow.com/questions/1764263/what-is-the-leader-in-a-vimrc-file) is `,`. 75 | 76 | - `,<` calls `:SyncopateExportToClipboard` on whatever motion you choose. 77 | (e.g., `,` calls `:SyncopateExportToClipboard` on the whole buffer (or your selection in visual mode). 79 | 80 | ### Put it in a browser window 81 | 82 | Alternatively, you can use the `:SyncopateExportToBrowser` command. 83 | It opens the HTML in a new browser tab, so you can select regions interactively. 84 | Syncopate automatically cleans up the HTML file after opening the tab. 85 | 86 | If you use `:SyncopateExportToBrowser`, be sure to copy with `Ctrl-C` (as opposed to mouse selection/middle-click); otherwise, the highlighting will not be retained. 87 | 88 | ## How do I configure it? 89 | 90 | There are a variety of syncopate-specific options: whether to change the colorscheme, which browser to use, etc. 91 | See `:help syncopate-config`. 92 | 93 | For everything else, use the built-in options for the `:TOhtml` command: `:help 2html.vim`. 94 | (Options are down below, starting at `:help g:html_diff_one_file`.) 95 | 96 | For example, the following line will exclude line numbers from the output, even if you use them in vim: 97 | 98 | ```vim 99 | let g:html_number_lines = 0 100 | ``` 101 | 102 | ## So how's this different from plain :TOhtml? 103 | 104 | Mainly convenience. 105 | Under the hood, `:SyncopateExportToClipboard` will: 106 | 107 | 1. Switch to the default `colorscheme` (it shows up better on white backgrounds). 108 | 2. Create the HTML version of your vim buffer. 109 | 3. Export it to the clipboard. 110 | 4. Restore your `colorscheme`, and any other settings it needed to change. 111 | 112 | Simply running `:TOhtml` only does the second step. 113 | In particular, the third step is difficult to remember how to do. 114 | Without it, `:TOhtml` usually involves tiresome saving-and-subsequently-deleting of HTML files, and fiddling with a browser. 115 | -------------------------------------------------------------------------------- /doc/syncopate.txt: -------------------------------------------------------------------------------- 1 | *syncopate.txt* Syntax-highlighted copy-paste 2 | Google *syncopate* 3 | 4 | ============================================================================== 5 | CONTENTS *syncopate-contents* 6 | 1. Introduction............................................|syncopate-intro| 7 | 2. Configuring with standard settings............|syncopate-standard-config| 8 | 3. Configuration..........................................|syncopate-config| 9 | 4. Commands.............................................|syncopate-commands| 10 | 5. Functions...........................................|syncopate-functions| 11 | 12 | ============================================================================== 13 | INTRODUCTION *syncopate-intro* 14 | 15 | Syncopate makes it very easy to share beautiful code in webmail windows, 16 | Google Docs, etc. 17 | 18 | Use the |:SyncopateExportToBrowser| command to open a new browser tab with 19 | your buffer's contents, syntax highlighting and all. (If you're in 20 | |visual-mode|, only the selected text will be exported.) Then you can 21 | copy-paste from the browser tab into your intended destination. 22 | 23 | Use a keymapping for even more convenience (see |syncopate:plugin[mappings]|). 24 | The default mapping is "<>". So if your || is set to ",", 25 | then the mapping ",<>" will run |:SyncopateExportToBrowser| for you. 26 | (Mnemonic: "<>" is reminiscent of HTML tags, and it triggers HTML output.) 27 | 28 | Syncopate will automatically switch to the default colorscheme before output, 29 | since this tends to show up better (and be less error-prone!) on white 30 | backgrounds. You can change this behaviour with the 31 | |syncopate:change_colorscheme| and |syncopate:colorscheme| settings. In any 32 | case, Syncopate restores your original colorscheme once it's finished. 33 | 34 | ============================================================================== 35 | CONFIGURING WITH STANDARD SETTINGS *syncopate-standard-config* 36 | 37 | Syncopate is based on the built-in |convert-to-HTML| functionality, which 38 | already has a wealth of configurable settings. We try to use these settings 39 | wherever possible. (For additional, Syncopate-specific settings, see 40 | |syncopate-config|.) 41 | 42 | For example: many people who use line numbers in vim do not want them in the 43 | HTML output, since they would show up when recipients copy-paste the code into 44 | an editor window. By default, HTML output includes line numbers whenever vim 45 | does. To force them not to appear, use the |g:html_number_lines| setting: add 46 | > 47 | let g:html_number_lines = 0 48 | < 49 | to your vimrc. 50 | 51 | To browse all available settings, go to the first one (|g:html_diff_one_file|) 52 | and scroll down from there. 53 | 54 | ============================================================================== 55 | CONFIGURATION *syncopate-config* 56 | 57 | This plugin uses maktaba flags for configuration. Install Glaive 58 | (https://github.com/google/glaive) and use the |:Glaive| command to configure 59 | them. 60 | 61 | *syncopate:change_colorscheme* 62 | Use a different colorscheme for the HTML output. This can make the text more 63 | readable. 64 | Default: 1 ` 65 | 66 | *syncopate:colorscheme* 67 | The colorscheme to switch to for the HTML output. The default is "default", 68 | since it shows up nicely on a white background (as in most webmail windows). 69 | 70 | This setting has no effect if |syncopate:change_colorscheme| is false. 71 | Default: 'default' ` 72 | 73 | *syncopate:browser* 74 | The browser command which |:SyncopateExportToBrowser| will use. 75 | 76 | The default, "sensible-browser", only works on Debian-based systems (including 77 | Ubuntu). It can be configured by the "update-alternatives" command. If you 78 | don't want to do this (or if you're not using a Debian-based system), you will 79 | need to set this flag for the browser export to work. 80 | Default: 'sensible-browser' ` 81 | 82 | *syncopate:clear_bg* 83 | Controls whether |:SyncopateExportToClipboard| will clear the background 84 | colour. 85 | 86 | This can be useful for copy-pasting into a destination (e.g., some talk 87 | slides) whose background colour might be slightly different than the 88 | background in the editor. 89 | Default: 0 ` 90 | 91 | *syncopate:plugin[commands]* 92 | Configures whether plugin/commands.vim should be loaded. 93 | Default: 1 ` 94 | 95 | *syncopate:plugin[mappings]* 96 | Configures whether plugin/mappings.vim should be loaded. 97 | Default: 0 ` 98 | 99 | ============================================================================== 100 | COMMANDS *syncopate-commands* 101 | 102 | :[range]SyncopateExportToBrowser *:SyncopateExportToBrowser* 103 | Export syntax-highlighted text, in HTML format, to a browser tab. 104 | 105 | :[range]SyncopateExportToClipboard *:SyncopateExportToClipboard* 106 | Export syntax-highlighted text, in HTML format, to the clipboard. Requires 107 | xclip to be installed on your system. 108 | 109 | ============================================================================== 110 | FUNCTIONS *syncopate-functions* 111 | 112 | syncopate#ClipboardOperatorfunc({type}) *syncopate#ClipboardOperatorfunc()* 113 | An operator function to integrate with text objects. 114 | 115 | We ignore the {type}, since 2html.vim only seems to work linewise. 116 | 117 | 118 | vim:tw=78:ts=8:ft=help:norl: 119 | -------------------------------------------------------------------------------- /autoload/syncopate.vim: -------------------------------------------------------------------------------- 1 | " Copyright 2014 Google Inc. All rights reserved. 2 | " 3 | " Licensed under the Apache License, Version 2.0 (the "License"); 4 | " you may not use this file except in compliance with the License. 5 | " You may obtain a copy of the License at 6 | " 7 | " http://www.apache.org/licenses/LICENSE-2.0 8 | " 9 | " Unless required by applicable law or agreed to in writing, software 10 | " distributed under the License is distributed on an "AS IS" BASIS, 11 | " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | " See the License for the specific language governing permissions and 13 | " limitations under the License. 14 | 15 | let s:plugin = maktaba#plugin#Get('syncopate') 16 | 17 | 18 | " Change vim settings to prepare for HTML export, and save the old values for 19 | " s:SyncopateRestoreSettings(). 20 | " 21 | " NOTE: Do not change this function without making a corresponding change in 22 | " s:SyncopateRestoreSettings(). 23 | function! s:SyncopateSaveAndChangeSettings() 24 | let l:change_colorscheme = maktaba#ensure#IsBool( 25 | \ s:plugin.Flag('change_colorscheme')) 26 | 27 | " For vim (as opposed to gvim), we will need to muck with 't_Co' to avoid 28 | " outputting really hideous/unreadable colors for HTML (which should always 29 | " have 256 colours available). 30 | let l:should_set_t_Co = !has('gui') 31 | 32 | " Save any settings we'll need to restore later. 33 | let l:setting_names = ['g:html_use_css'] 34 | if l:change_colorscheme 35 | call extend(l:setting_names, ['&background', 'g:colors_name']) 36 | endif 37 | if l:should_set_t_Co 38 | call extend(l:setting_names, ['&t_Co']) 39 | endif 40 | let l:settings = maktaba#value#SaveAll(l:setting_names) 41 | 42 | " Syncopate forces g:html_use_css to 0 (false). This outputs ugly deprecated 43 | " tags, but it's necessary to make sure the HTML shows up correctly in 44 | " email clients (which usually strip out