literate.vim


Ⅰ. 插件描述

Vim plugin for the Literate programming tool

Ⅱ. 基本信息

创建日期:  2015-07-04
使用用户:  5
Github星:  17
插件作者:  Zachary Yedidia

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'zyedidia/literate-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'zyedidia/literate-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'zyedidia/literate-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/zyedidia/literate.vim

Ⅳ. 文档说明

# Literate.vim

This is a vim plugin for the [Literate] (https://github.com/zyedidia/Literate) programming system.

See the Literate Manual for how to use it.

This plugin provides all sorts of niceties like syntax highlighting (it correctly syntax highlights the language embedded in code blocks using information from the @code_type), and keybindings to let you jump between code blocks. Also, if you have Syntastic or Neomake installed then this plugin will report errors from inside vim. If you use the @compiler feature of Literate, this plugin will even report compiler errors from any compiler or linter (like gcc, pyflakes, jshint...).

This plugin also integrates with Tagbar.

When you first open a .lit file, vim will syntax highlight commands like @code_type, and @title... correctly, but it will not syntax highlight the embedded code blocks right away. This is because when you opened the empty file, the code type was not defined, so vim was unable to know what language you are using. You can execute :e to reload the syntax highlighting (make sure the file is saved) once you have defined the codetype with the @code_type command.

Installation

To install, just use your favorite plugin manager:

Vundle:

Plugin 'zyedidia/literate.vim'

To get the most out of the plugin you should also install either Neomake or Syntastic:

Plugin 'scrooloose/syntastic'
" Or
Plugin 'benekastah/neomake'

You can also get ctags integration by installing Tagbar (you also need exuberant ctags installed):

Plugin 'majutsushi/tagbar'

Then add the following to your ~/.ctags file:

--langdef=literate
--langmap=literate:+.lit
--regex-literate=/^@s[ \t]+(.+)/\1/s,section/i
--regex-literate=/^---[ \t](.+)/\1/c,code/i
--regex-literate=/@{(.*)}/\1/i,includes/i

Mappings

Literate.vim has three mappings:

  • <C-]> lets you jump to a code block definition from a code block use and back. If your cursor is on @{block name} and you press <C-]>, your cursor will jump to the next use/definition and vice versa.
  • <leader>c will use lit (make sure it's in your PATH) to compile only the code for the current file and open it in a new window. Just make sure that the output file has the same basename as the lit file (and the @code_type is defined).
  • <leader>h will use lit to compile only html and run open on it to open in a web browser.

These are just default mappings and can be remapped in your .vimrc:

let g:literate_find_codeblock = "<C-]>"
let g:literate_open_code = "<leader>c"
let g:literate_open_html = "<leader>h"

添加新评论