├── .gitignore
├── LICENSE
├── README.md
├── autoload
├── readme_viewer.vim
└── readme_viewer
│ ├── dein.vim
│ ├── dpp.vim
│ ├── jetpack.vim
│ ├── minpac.vim
│ └── plug.vim
├── denops
├── @ddu-kinds
│ └── readme_viewer.ts
└── @ddu-sources
│ └── readme_viewer.ts
├── doc
└── readme_viewer.txt
├── img
└── screenshot.gif
├── lua
└── readme_viewer.lua
├── plugin
└── readme_viewer.vim
└── test
├── dein
└── test.vimrc
├── dpp
├── config.ts
└── test.vimrc
├── minpac
└── test.vimrc
├── packer
└── test.vimrc
├── plug
└── test.vimrc
└── test.vim
/.gitignore:
--------------------------------------------------------------------------------
1 | test/cache/*
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Hibiki
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vim-readme-viewer
2 |
3 | Please read [help](doc/readme_viewer.txt) for details.
4 |
5 | > 📖 Viewing plugin's README easily like vim help
6 |
7 | 
8 |
9 |
10 | * [vim-readme-viewer](#vim-readme-viewer)
11 | * [About](#about)
12 | * [Why use this?](#why-use-this)
13 | * [Features](#features)
14 | * [Installation](#installation)
15 | * [dein.vim](#deinvim)
16 | * [dpp.vim](#dppvim)
17 | * [vim-plug](#vim-plug)
18 | * [minpac](#minpac)
19 | * [packer.nvim](#packernvim)
20 | * [vim-jetpack](#vim-jetpack)
21 | * [Tips](#tips)
22 | * [General](#general)
23 | * [vim-plug](#vim-plug-1)
24 | * [packer.nvim](#packernvim-1)
25 | * [ddu.vim](#dduvim)
26 | * [TODO](#todo)
27 | * [Introduced Articles](#introduced-articles)
28 | * [License](#license)
29 |
30 |
31 | Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)
32 |
33 | ## About
34 |
35 | vim-readme-viewer help you to view some installed plugins' README(.md) file
36 | easily like vim help file. Viewing vim help file is very easy. Only
37 | `:help {topic}`! This plugin usage is also easy. If you are using
38 | [dein.vim](https://github.com/Shougo/dein.vim), please try:
39 |
40 | ```vim
41 | :DeinReadme dein.vim
42 | :DeinReadme vim-readme-viewer
43 | " ... and other plugins
44 | ```
45 |
46 | If you are using other plugin managers, please try:
47 |
48 | ```vim
49 | :DppReadme vim-readme-viewer
50 | :PlugReadme vim-readme-viewer " for vim-plug
51 | :PackReadme vim-readme-viewer " for minpac
52 | :PackerReadme vim-readme-viewer " for packer.nvim
53 | :JetpackReadme vim-readme-viewer " for vim-jetpack
54 | " ... and other plugins
55 | ```
56 |
57 | ## Why use this?
58 |
59 | Vim help file is very useful and viewing it is very easy. However, some plugins,
60 | which is special such as colorschemes or tiny plugins, sometimes don't have vim
61 | help file. So, when you want to custom those plugins, you have to read README.md
62 | or look at plugins' inside code. It is not good for you because you have to do
63 | it outside vim.
64 |
65 | ## Features
66 |
67 | - Support many plugin managers
68 | - [dein.vim](https://github.com/Shougo/dein.vim)
69 | - [dpp.vim](https://github.com/Shougo/dpp.vim)
70 | - [vim-plug](https://github.com/junegunn/vim-plug)
71 | - [minpac](https://github.com/k-takata/minpac)
72 | - [packer.nvim](https://github.com/wbthomason/packer.nvim)
73 | - [vim-jetpack](https://github.com/tani/vim-jetpack)
74 | - Include fuzzy finders source
75 | - [ddu.vim](https://github.com/Shougo/ddu.vim) (**experimental** feature)
76 |
77 | ## Installation
78 |
79 | ### [dein.vim](https://github.com/Shougo/dein.vim)
80 |
81 | with vim script:
82 |
83 | ```vim
84 | let g:readme_viewer#plugin_manager = 'dein.vim'
85 | call dein#add('4513ECHO/vim-readme-viewer', {'on_cmd': 'DeinReadme'})
86 | ```
87 |
88 | with toml:
89 |
90 | ```toml
91 | [[plugins]]
92 | repo = '4513ECHO/vim-readme-viewer'
93 | on_cmd = ['DeinReadme']
94 | hook_add = '''
95 | let g:readme_viewer#plugin_manager = 'dein.vim'
96 | '''
97 | ```
98 |
99 | ### [dpp.vim](https://github.com/Shougo/dpp.vim)
100 |
101 | Depends on your liking configuration.
102 |
103 | ### [vim-plug](https://github.com/junegunn/vim-plug)
104 |
105 | ```vim
106 | let g:readme_viewer#plugin_manager = 'vim-plug'
107 | Plug '4513ECHO/vim-readme-viewer', { 'on': 'PlugReadme' }
108 | ```
109 |
110 | ### [minpac](https://github.com/k-takata/minpac)
111 |
112 | ```vim
113 | let g:readme_viewer#plugin_manager = 'minpac'
114 | call minpac#add('4513ECHO/vim-readme-viewer')
115 | ```
116 |
117 | ### [packer.nvim](https://github.com/wbthomason/packer.nvim)
118 |
119 | ```lua
120 | use {
121 | '4513ECHO/vim-readme-viewer',
122 | opt = true,
123 | cmd = 'PackerReadme',
124 | config = function()
125 | vim.g['readme_viewer#plugin_manager'] = 'packer.nvim'
126 | end
127 | }
128 | ```
129 |
130 | ### [vim-jetpack](https://github.com/tani/vim-jetpack)
131 |
132 | ```vim
133 | let g:readme_viewer#plugin_manager = 'vim-jetpack'
134 | Jetpack '4513ECHO/vim-readme-viewer', { 'on': 'JetpackReadme' }
135 | ```
136 |
137 | ## Tips
138 |
139 | ### General
140 |
141 | Basically vim-readme-viewer automatically judge your using plugin manager.
142 | However, it sometimes may fail. I recommend that you set manually
143 | `g:readme_viewer#plugin_manager` to plugin manager.
144 |
145 | ```vim
146 | let g:readme_viewer#plugin_manager = 'vim-plug' " for vim-plug
147 | let g:readme_viewer#plugin_manager = 'minpac' " for minpac
148 | ```
149 |
150 | ### vim-plug
151 |
152 | On default, vim-plug is not register itself as a plugin. So, vim-readme-viewer
153 | cannot open vim-plug's README.md. If you want to view vim-plug's README.md, you
154 | register vim-plug as a plugin.
155 |
156 | ```vim
157 | Plug 'junegunn/vim-plug'
158 | ```
159 |
160 | ### packer.nvim
161 |
162 | - `:PackerReadme` require that executing `:PackerCompile`. If you don't execute
163 | it, `vim-readme-viewer` throws error.
164 | - plugin's path data is sometimes empty. See also
165 | [wbthomason/packer.vim#765](https://github.com/wbthomason/packer.nvim/issues/765).
166 |
167 | ### ddu.vim
168 |
169 | Usage examples:
170 |
171 | ```vim
172 | " Set kind default action
173 | call ddu#custom#pathch_global({
174 | \ 'kindOptions': {
175 | \ 'readme_viewer': {
176 | \ 'defaultAction': 'open',
177 | \ }}})
178 | " Use readme_viewer source.
179 | call ddu#start({'sources': [{'name': 'readme_viewer'}]})
180 | ```
181 |
182 | ## TODO
183 |
184 | - Improve README.md and doc/readme_viewer.txt
185 | - [ ] add new functions to doc/readme_viewer.txt
186 | - Support other plugin managers
187 | - [ ] runtimepath based plugin manager
188 | - [ ] buildin package system based plugin manager
189 | - [x] [dein.vim](https://github.com/Shougo/dein.vim)
190 | - [ ] [dpp.vim](https://github.com/Shougo/dpp.vim)
191 | - [x] [vim-plug](https://github.com/junegunn/vim-plug)
192 | - [x] [minpac](https://github.com/k-takata/minpac)
193 | - [x] [packer.nvim](https://github.com/wbthomason/packer.nvim)
194 |
195 | ## Introduced Articles
196 |
197 | If you wrote an article about the plugin, please send me Pull-Request 😃
198 |
199 | - [インストールしたプラグインのREADME.mdをお手軽に見れるvim-readme-viewer作った](https://zenn.dev/4513echo/articles/2021-12-04-vim-readme-viewer)
200 | (Japanese)
201 | - [vim-readme-viewerの対象をfzfで選択するコマンドを作った](https://zenn.dev/kawarimidoll/articles/316023e5b61d00)
202 | (Japanese)
203 |
204 | ## License
205 |
206 | MIT License
207 |
--------------------------------------------------------------------------------
/autoload/readme_viewer.vim:
--------------------------------------------------------------------------------
1 | let s:plugin_managers = {
2 | \ 'dein.vim': 'dein',
3 | \ 'dpp.vim': 'dpp',
4 | \ 'vim-plug': 'plug',
5 | \ 'minpac': 'mimpac',
6 | \ 'packer.nvim': 'packer',
7 | \ 'vim-jetpack': 'jetpack',
8 | \ }
9 |
10 | let s:plugin_manager = s:plugin_managers[g:readme_viewer#plugin_manager]
11 |
12 | function! readme_viewer#open(args, mods) abort
13 | if g:readme_viewer#plugin_manager ==# 'dein.vim' || exists('*dein#begin')
14 | let funcname = 'readme_viewer#dein#open'
15 | elseif g:readme_viewer#plugin_manager ==# 'dpp.vim' || exists('*dpp#make_state')
16 | let funcname = 'readme_viewer#dpp#open'
17 | elseif g:readme_viewer#plugin_manager ==# 'vim-plug' || exists('*plug#begin')
18 | let funcname = 'readme_viewer#plug#open'
19 | elseif g:readme_viewer#plugin_manager ==# 'minpac' || exists('*minpac#init')
20 | let funcname = 'readme_viewer#minpac#open'
21 | elseif g:readme_viewer#plugin_manager ==# 'vim-jetpack' || exists('*jetpack#begin')
22 | let funcname = 'readme_viewer#jetpack#open'
23 | else
24 | call readme_viewer#error('Plugin manager cannot be detected')
25 | return
26 | endif
27 |
28 | return call(funcname, [a:args, a:mods])
29 | endfunction
30 |
31 | function! readme_viewer#completion(ArgLead, CmdLine, CursorPos) abort
32 | if g:readme_viewer#plugin_manager ==# 'dein.vim' || exists('*dein#begin')
33 | let funcname = 'readme_viewer#dein#completion'
34 | elseif g:readme_viewer#plugin_manager ==# 'dpp.vim' || exists('*dpp#make_state')
35 | let funcname = 'readme_viewer#dpp#completion'
36 | elseif g:readme_viewer#plugin_manager ==# 'vim-plug' || exists('*plug#begin')
37 | let funcname = 'readme_viewer#plug#completion'
38 | elseif g:readme_viewer#plugin_manager ==# 'minpac' || exists('*minpac#init')
39 | let funcname = 'readme_viewer#minpac#completion'
40 | elseif g:readme_viewer#plugin_manager ==# 'vim-jetpack' || exists('*jetpack#begin')
41 | let funcname = 'readme_viewer#jetpack#completion'
42 | else
43 | call readme_viewer#error('Plugin manager cannot be detected')
44 | return []
45 | endif
46 |
47 | return call(funcname, [a:ArgLead, a:CmdLine, a:CursorPos])
48 | endfunction
49 |
50 | function! readme_viewer#open_buffer(path, name, ...) abort
51 | let mods = a:0 > 0 ? a:1 : ''
52 | let open_help_buffer = get(g:, 'readme_viewer#open_help_buffer', v:true)
53 | let open_command = get(g:, 'readme_viewer#open_command', 'new')
54 | let readme = get(globpath(a:path, '\creadme*', v:false, v:true), 0, '')
55 | if !filereadable(readme)
56 | call readme_viewer#error('README file does not exists in this plugin')
57 | return
58 | endif
59 | if open_help_buffer
60 | helpclose
61 | endif
62 | execute mods 'keepalt' open_command readme
63 | if open_help_buffer
64 | setlocal buftype=help
65 | endif
66 | setlocal noswapfile nobuflisted readonly nomodified nomodifiable
67 | let normalized_name = substitute(
68 | \ fnamemodify(a:name, ':r'),
69 | \ '\v\c^%(n?vim|dps)[_-]|[_-]n?vim$', '', 'g')
70 | let b:readme_data = {
71 | \ 'path': a:path, 'name': a:name,
72 | \ 'normalized_name': normalized_name,
73 | \ }
74 | doautocmd User ReadmeOpen
75 | endfunction
76 |
77 | function! readme_viewer#get(...) abort
78 | return a:0 > 0
79 | \ ? readme_viewer#{s:plugin_manager}#get(a:1)
80 | \ : readme_viewer#{s:plugin_manager}#get()
81 | endfunction
82 |
83 | function! readme_viewer#open(plugin, mods) abort
84 | call readme_viewer#{s:plugin_manager}#open(a:plugin, a:mods)
85 | endfunction
86 |
87 | function! readme_viewer#error(msg, ...) abort
88 | echohl ErrorMsg
89 | echomsg '[readme-viewer]:' a:msg join(a:000)
90 | echohl None
91 | endfunction
92 |
93 |
--------------------------------------------------------------------------------
/autoload/readme_viewer/dein.vim:
--------------------------------------------------------------------------------
1 |
2 | function! readme_viewer#dein#open(plugin, mods) abort
3 | let plugin = readme_viewer#dein#get(a:plugin)
4 | if empty(plugin)
5 | call readme_viewer#error('Cannot find plugin name:', a:plugin)
6 | return
7 | endif
8 | call readme_viewer#open_buffer(plugin.path, plugin.name, a:mods)
9 | endfunction
10 |
11 | function! readme_viewer#dein#get(...) abort
12 | let plugins = a:0 > 0 ? dein#get(a:1) : dein#get()
13 | if empty(plugins)
14 | return {}
15 | endif
16 | if a:0 > 0
17 | return {'path': plugins.path, 'name': plugins.name}
18 | else
19 | return map(plugins, { _, val -> {'path': val.path, 'name': val.name} })
20 | endif
21 | endfunction
22 |
23 | function! readme_viewer#dein#completion(ArgLead, CmdLine, CursorPos) abort
24 | if exists('*matchfuzzy')
25 | if empty(a:ArgLead)
26 | return sort(keys(dein#get()))
27 | else
28 | return matchfuzzy(sort(keys(dein#get())), a:ArgLead)
29 | endif
30 | else
31 | return filter(sort(keys(dein#get())), {_, val -> val =~? a:ArgLead})
32 | endif
33 | endfunction
34 |
35 |
--------------------------------------------------------------------------------
/autoload/readme_viewer/dpp.vim:
--------------------------------------------------------------------------------
1 |
2 | function! readme_viewer#dpp#open(plugin, mods) abort
3 | let plugin = readme_viewer#dpp#get(a:plugin)
4 | if empty(plugin)
5 | call readme_viewer#error('Cannot find plugin name:', a:plugin)
6 | return
7 | endif
8 | call readme_viewer#open_buffer(plugin.path, plugin.name, a:mods)
9 | endfunction
10 |
11 | function! readme_viewer#dpp#get(...) abort
12 | let plugins = a:0 > 0 ? dpp#get(a:1) : dpp#get()
13 | if empty(plugins)
14 | return {}
15 | endif
16 | if a:0 > 0
17 | return {'path': plugins.path, 'name': plugins.name}
18 | else
19 | return map(plugins, { _, val -> {'path': val.path, 'name': val.name} })
20 | endif
21 | endfunction
22 |
23 | function! readme_viewer#dpp#completion(ArgLead, CmdLine, CursorPos) abort
24 | if exists('*matchfuzzy')
25 | if empty(a:ArgLead)
26 | return sort(keys(dpp#get()))
27 | else
28 | return matchfuzzy(sort(keys(dpp#get())), a:ArgLead)
29 | endif
30 | else
31 | return filter(sort(keys(dpp#get())), {_, val -> val =~? a:ArgLead})
32 | endif
33 | endfunction
34 |
35 |
--------------------------------------------------------------------------------
/autoload/readme_viewer/jetpack.vim:
--------------------------------------------------------------------------------
1 |
2 | function! readme_viewer#jetpack#open(plugin, mods) abort
3 | let plugin = readme_viewer#jetpack#get(a:plugin)
4 | if empty(plugin)
5 | call readme_viewer#error('Cannot find plugin name:', a:plugin)
6 | return
7 | endif
8 | call readme_viewer#open_buffer(plugin.path, plugin.name, a:mods)
9 | endfunction
10 |
11 | function! readme_viewer#jetpack#get(...) abort
12 | let plugins = a:0 > 0 ? jetpack#get(a:1) : jetpack#names()
13 | if empty(plugins)
14 | return {}
15 | endif
16 | if a:0 > 0
17 | return {'path': plugins.path, 'name': plugins.name}
18 | else
19 | let dict = {}
20 | for pkg in plugins
21 | let info = jetpack#get(pkg)
22 | call extend(dict, {info.name: {
23 | \ 'path': info.path,
24 | \ 'name': info.name,
25 | \ }})
26 | endfor
27 | return dict
28 | endif
29 | endfunction
30 |
31 | function! readme_viewer#jetpack#completion(ArgLead, CmdLine, CursorPos) abort
32 | if exists('*matchfuzzy')
33 | if empty(a:ArgLead)
34 | return sort(jetpack#names())
35 | else
36 | return matchfuzzy(sort(jetpack#names()), a:ArgLead)
37 | endif
38 | else
39 | return filter(sort(jetpack#names()),
40 | \ {_, val -> val =~? a:ArgLead})
41 | endif
42 | endfunction
43 |
44 |
--------------------------------------------------------------------------------
/autoload/readme_viewer/minpac.vim:
--------------------------------------------------------------------------------
1 |
2 | function! readme_viewer#minpac#open(plugin, mods) abort
3 | let plugin = readme_viewer#minpac#get(a:plugin)
4 | if empty(plugin)
5 | call readme_viewer#error('Cannot find plugin name:', a:plugin)
6 | return
7 | endif
8 | call readme_viewer#open_buffer(plugin.path, plugin.name, a:mods)
9 | endfunction
10 |
11 | function! readme_viewer#minpac#get(...) abort
12 | let plugins = a:0 > 0 ? minpac#getpluginfo(a:1) : minpac#getpluglist()
13 | if empty(plugins)
14 | return {}
15 | endif
16 | if a:0 > 0
17 | return {'path': plugins.dir, 'name': plugins.name}
18 | else
19 | return map(plugins, { _, val -> {'path': val.dir, 'name': val.name} })
20 | endif
21 | endfunction
22 |
23 | function! readme_viewer#minpac#completion(ArgLead, CmdLine, CursorPos) abort
24 | if exists('*matchfuzzy')
25 | if empty(a:ArgLead)
26 | return sort(keys(minpac#getpluglist()))
27 | else
28 | return matchfuzzy(sort(keys(minpac#getpluglist())), a:ArgLead)
29 | endif
30 | else
31 | return filter(sort(keys(minpac#getpluglist())),
32 | \ {_, val -> val =~? a:ArgLead})
33 | endif
34 | endfunction
35 |
36 |
--------------------------------------------------------------------------------
/autoload/readme_viewer/plug.vim:
--------------------------------------------------------------------------------
1 |
2 | function! readme_viewer#plug#open(plugin, mods) abort
3 | let plugin = readme_viewer#plug#get(a:plugin)
4 | if empty(plugin)
5 | call readme_viewer#error('Cannot find plugin name:', a:plugin)
6 | return
7 | endif
8 | call readme_viewer#open_buffer(plugin.path, plugin.name, a:mods)
9 | endfunction
10 |
11 | function! readme_viewer#plug#get(...) abort
12 | let plugins = a:0 > 0 ? get(g:plugs, a:1, {}) : g:plugs
13 | if empty(plugins)
14 | return {}
15 | endif
16 | if a:0 > 0
17 | return {'path': plugins.dir, 'name': a:1}
18 | else
19 | return map(copy(plugins), { key, val -> {'path': val.dir, 'name': key} })
20 | endif
21 | endfunction
22 |
23 | function! readme_viewer#plug#completion(ArgLead, CmdLine, CursorPos) abort
24 | if exists('*matchfuzzy')
25 | if empty(a:ArgLead)
26 | return sort(keys(g:plugs))
27 | else
28 | return matchfuzzy(sort(keys(g:plugs)), a:ArgLead)
29 | endif
30 | else
31 | return filter(sort(keys(g:plugs)), {_, val -> val =~? a:ArgLead})
32 | endif
33 | endfunction
34 |
35 |
--------------------------------------------------------------------------------
/denops/@ddu-kinds/readme_viewer.ts:
--------------------------------------------------------------------------------
1 | import type { ActionArguments } from "https://deno.land/x/ddu_vim@v0.12.2/base/kind.ts";
2 | import {
3 | ActionFlags,
4 | BaseKind,
5 | } from "https://deno.land/x/ddu_vim@v0.12.2/types.ts";
6 |
7 | export interface ActionData {
8 | name: string;
9 | }
10 |
11 | type Params = Record;
12 |
13 | export class Kind extends BaseKind {
14 | actions: Record<
15 | string,
16 | (args: ActionArguments) => Promise
17 | > = {
18 | open: async (args) => {
19 | for (const item of args.items) {
20 | const action = item?.action as ActionData;
21 | const name = action.name;
22 | await args.denops.call("readme_viewer#open", name, "");
23 | }
24 |
25 | return Promise.resolve(ActionFlags.None);
26 | },
27 | };
28 |
29 | params(): Params {
30 | return {};
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/denops/@ddu-sources/readme_viewer.ts:
--------------------------------------------------------------------------------
1 | import type { GatherArguments } from "https://deno.land/x/ddu_vim@v0.12.2/base/source.ts";
2 | import type { Item } from "https://deno.land/x/ddu_vim@v0.12.2/types.ts";
3 | import { BaseSource } from "https://deno.land/x/ddu_vim@v0.12.2/types.ts";
4 | import { ensureObject } from "https://deno.land/x/unknownutil@v1.1.4/mod.ts";
5 | import type { ActionData } from "../@ddu-kinds/readme_viewer.ts";
6 |
7 | type Params = Record;
8 |
9 | interface PluginData {
10 | path: string;
11 | name: string;
12 | }
13 |
14 | export class Source extends BaseSource {
15 | kind = "readme_viewer";
16 |
17 | gather(args: GatherArguments): ReadableStream- []> {
18 | return new ReadableStream({
19 | async start(controller) {
20 | const plugins = await args.denops.call("readme_viewer#get");
21 | ensureObject(plugins);
22 | controller.enqueue(
23 | Object.values(plugins).map((i) => {
24 | return {
25 | word: i.name,
26 | action: {
27 | name: i.name,
28 | },
29 | } as Item;
30 | }),
31 | );
32 | controller.close();
33 | },
34 | });
35 | }
36 |
37 | params(): Params {
38 | return {};
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/doc/readme_viewer.txt:
--------------------------------------------------------------------------------
1 | *readme-viewer.txt* Viewing plugin's README(.md) easily like vim help
2 |
3 | Author: Hibiki
4 | License: MIT License
5 | URL: https://github.com/4513ECHO/vim-readme-viewer
6 | Last change: 2023 May 16
7 |
8 | ==============================================================================
9 | CONTENTS *readme-viewer-contents*
10 |
11 | Introduction |readme-viewer-introdution|
12 | Interface |readme-viewer-interface|
13 | Commands |readme-viewer-commands|
14 | Functions |readme-viewer-functions|
15 | Variables |readme-viewer-variables|
16 | Autocommands |readme-viewer-autocommands|
17 | About |readme-viewer-about|
18 |
19 | ==============================================================================
20 | INTRODUCTION *readme-viewer-introdution*
21 |
22 | *readme-viewer* or *vim-readme-viewer* help you to view some installed plugins'
23 | README(.md) file easily like vim help file. Viewing vim help file is very easy.
24 | Only `:help {topic}`! This plugin usage is also easy. If you are using
25 | |dein.vim|, please try:
26 | >
27 | :DeinReadme dein.vim
28 | :DeinReadme vim-readme-viewer
29 |
30 | If you are using other plugin managers, please try:
31 |
32 | >
33 | :PlugReadme vim-readme-viewer " for vim-plug
34 | :PackReadme vim-readme-viewer " for minpac
35 | :PackerReadme vim-readme-viewer " for packer.nvim
36 |
37 | Note: Basically vim-readme-viewer automatically judge your using plugin
38 | manager. However, it sometimes may fail. I recommend that you set manually
39 | |g:readme_viewer#plugin_manager| to plugin manager.
40 |
41 | >
42 | let g:readme_viewer#plugin_manager = 'dein.vim' " for dein.vim
43 | let g:readme_viewer#plugin_manager = 'dpp.vim' " for dpp.vim
44 | let g:readme_viewer#plugin_manager = 'vim-plug' " for vim-plug
45 | let g:readme_viewer#plugin_manager = 'minpac' " for minpac
46 | let g:readme_viewer#plugin_manager = 'packer.nvim' " for packer.nvim
47 | let g:readme_viewer#plugin_manager = 'vim-jetpack' " for vim-jetpack"
48 |
49 | Note: On default, vim-plug is not register itself as a plugin. So,
50 | vim-readme-viewer cannot open vim-plug's README.md. If you want to view
51 | vim-plug's README.md, you register vim-plug as a plugin.
52 | >
53 | Plug 'junegunn/vim-plug'
54 |
55 | Note: This plugin is working with |dein.vim|, |dpp|, |vim-plug|, |minpac|,
56 | |jetpack| and |packer.nvim| now.
57 |
58 | ==============================================================================
59 | INTERFACE *readme-viewer-interface*
60 |
61 | ------------------------------------------------------------------------------
62 | COMMANDS *readme-viewer-commands*
63 |
64 | :ReadmeOpen {plugin} *:ReadmeOpen*
65 | Open {plugin}'s README file. The command detects plugin manager
66 | automatically.
67 |
68 | :DeinReadme {plugin} *:DeinReadme*
69 | :DppReadme {plugin} *:DppReadme*
70 | :PlugReadme {plugin} *:PlugReadme*
71 | :PackReadme {plugin} *:PackReadme*
72 | :PackerReadme {plugin} *:PackerReadme*
73 | :JetpackReadme {plugin} *:JetpackReadme*
74 | Open {plugin}'s README file. |g:readme_viewer#plugin_manager| defines
75 | the command you can use. Please see it.
76 |
77 | :ReadmeHelp *:ReadmeHelp*
78 | Open current buffer plugin on |:help|. It sometimes fails when the
79 | plugin doesn't have itself help file.
80 |
81 | :ReadmeDir *:ReadmeDir*
82 | Open. It is same as `:edit %:p:h` . It is useful when you use some
83 | filer plugins. (e.g. |netrw|)
84 |
85 | ------------------------------------------------------------------------------
86 | FUNCTIONS *readme-viewer-functions*
87 |
88 | *readme_viewer#dein#get()*
89 | *readme_viewer#dpp#get()*
90 | *readme_viewer#plug#get()*
91 | *readme_viewer#minpac#get()*
92 | *readme_viewer#jetpack#get()*
93 | readme_viewer#{plugin-manager}#get([{plugin-name}])
94 | Get the plugin information dictionary. If you omit {plugin-name},
95 | vim-readme-viewer will return the all of plugins directory. Its key is
96 | the plugin name and its value is the plugin information dictionary.
97 |
98 | readme_viewer#get([{plugin-name}]) *readme_viewer#get()*
99 | Get the plugin information dictionary. It is alias of current plugin
100 | manager's `get` function. Please see above.
101 |
102 | *readme_viewer#dein#open()*
103 | *readme_viewer#dpp#open()*
104 | *readme_viewer#plug#open()*
105 | *readme_viewer#minpac#open()*
106 | *readme_viewer#jetpack#open()*
107 | readme_viewer#{plugin-manager}#open({plugin}, {mods})
108 | Open {plugin}'s README file. {mods} is command modifiers. (e.g.
109 | "vertical topleft")
110 |
111 | readme_viewer#open({plugin}, {mods}) *readme_viewer#open()*
112 | Open {plugin}'s README file. {mods} is command modifiers. It is alias
113 | of current plugin manager's `open` function. Please see above.
114 |
115 | *readme_viewer#open_buffer()*
116 | readme_viewer#open_buffer({path}, {name} [, {mods}])
117 | Open {plugin}'s README file. {mods} is command modifiers. (e.g.
118 | "vertical topleft") Difference from |readme_viewer#open()| is to
119 | handle error or not.
120 |
121 | ------------------------------------------------------------------------------
122 | VARIABLES *readme-viewer-variables*
123 |
124 | g:readme_viewer#plugin_manager *g:readme_viewer#plugin_manager*
125 | string (default: empty)
126 | Your using plugin manager. This variable controls command you can use.
127 | If you omit it, vim-readme-viewer automatically judge your using
128 | plugin manager. I recommend that you set it manually.
129 | value command~
130 | "|dein.vim|" |:DeinReadme|
131 | "|dpp|.vim" |:DppReadme|
132 | "|vim-plug|" |:PlugReadme|
133 | "|minpac|" |:PackReadme|
134 | "|packer.nvim|" |:PackerReadme|
135 | "|vim-jetpack|" |:JetpackReadme|
136 |
137 | b:readme_data *b:readme_data*
138 | dict
139 | Information of current buffer plugin. It is useful to custom this
140 | plugin.
141 |
142 | key value~
143 | path plugin installed directory
144 | (e.g. `/home/user/.vim/plugged/vim-readme-viewer`)
145 | name plugin name (e.g. `vim-readme-viewer`)
146 | normalized_name normalized plugin name
147 | (e.g. `readme-viewer`, `dein`, `packer`)
148 |
149 | g:readme_viewer#open_help_buffer *g:reame_viewer#open_help_buffer*
150 | boolean (default: |v:true|)
151 | Configure README buffer's motion. If you don't set this variables,
152 | README buffer's 'buftype' is setted "help". Please see also
153 | |special-buffers|.
154 |
155 | g:readme_viewer#no_mappings *g:readme_viewer#no_mappings*
156 | boolean (default: |v:false|)
157 | Disable buffer local mappings when README is opened. If you don't set
158 | this variables, you can use `q` to close README window.
159 |
160 | g:readme_viewer#no_buffer_commands *g:readme_viewer#no_buffer_commands*
161 | boolean (default: |v:false|)
162 | Disable buffer local commands when README is opened. If you don't set
163 | this variables, you can use |:ReadmeHelp| and |:ReadmeDir|.
164 |
165 | ------------------------------------------------------------------------------
166 | AUTOCOMMANDS *readme-viewer-autocommands*
167 |
168 | ReadmeOpen *ReadmeOpen*
169 | Invoked when a README is opened. It is useful to configure some
170 | buffer local mappings and commands.
171 |
172 | ==============================================================================
173 | ABOUT *readme-viewer-about*
174 |
175 | |vim-readme-viewer| is developed by Hibiki(4513ECHO) and licensed under the
176 | MIT License. Visit the project page for the latest version:
177 |
178 | https://github.com/4513ECHO/vim-readme-viewer
179 |
180 | ==============================================================================
181 | vim:tw=78:ts=8:ft=help:norl:noet:fen:
182 |
--------------------------------------------------------------------------------
/img/screenshot.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/4513ECHO/vim-readme-viewer/f13692cabde3129f35758b94d5798f5c9c1ab49a/img/screenshot.gif
--------------------------------------------------------------------------------
/lua/readme_viewer.lua:
--------------------------------------------------------------------------------
1 | local readme_viewer = {}
2 |
3 | -- packer.nvim
4 |
5 | readme_viewer.packer = function(plugin, mods)
6 | if _G.packer_plugins == nil then
7 | vim.fn['readme_viewer#error'](
8 | '_G.packer_plugins is undefined yet. Did you forget :PackerCompile?'
9 | )
10 | return
11 | end
12 | local plugin_data = _G.packer_plugins[plugin]
13 | if plugin_data == nil then
14 | vim.fn['readme_viewer#error']('Cannot find plugin name:', plugin)
15 | return
16 | end
17 | if plugin_data.path == nil then
18 | vim.fn['readme_viewer#error']('Plugins path is emtpy')
19 | return
20 | end
21 | vim.fn['readme_viewer#open_buffer'](plugin_data.path, plugin, mods)
22 | end
23 |
24 | readme_viewer.packer_completion = function(ArgLead, _, _)
25 | if _G.packer_plugins == nil then
26 | return ""
27 | end
28 | local completion_list = vim.tbl_filter(function(name)
29 | return vim.startswith(name, ArgLead)
30 | end, vim.tbl_keys(_G.packer_plugins))
31 | table.sort(completion_list)
32 | return completion_list
33 | end
34 |
35 | return readme_viewer
36 |
--------------------------------------------------------------------------------
/plugin/readme_viewer.vim:
--------------------------------------------------------------------------------
1 |
2 | if exists('g:loaded_readme_viewer') || &cp
3 | finish
4 | endif
5 | let g:loaded_readme_viewer = v:true
6 |
7 | let s:save_cpo = &cpo
8 | set cpo&vim
9 |
10 | let g:readme_viewer#plugin_manager = get(g:,
11 | \ 'readme_viewer#plugin_manager', '')
12 |
13 | if g:readme_viewer#plugin_manager ==# 'dein.vim' || exists('*dein#begin')
14 | command! -nargs=1 -bar -complete=customlist,readme_viewer#dein#completion
15 | \ DeinReadme call readme_viewer#dein#open(, )
16 | elseif g:readme_viewer#plugin_manager ==# 'dpp.vim' || exists('*dpp#make_state')
17 | command! -nargs=1 -bar -complete=customlist,readme_viewer#plug#completion
18 | \ DppReadme call readme_viewer#dpp#open(, )
19 | elseif g:readme_viewer#plugin_manager ==# 'vim-plug' || exists('*plug#begin')
20 | command! -nargs=1 -bar -complete=customlist,readme_viewer#plug#completion
21 | \ PlugReadme call readme_viewer#plug#open(, )
22 | elseif g:readme_viewer#plugin_manager ==# 'minpac' || exists('*minpac#init')
23 | command! -nargs=1 -bar -complete=customlist,readme_viewer#minpac#completion
24 | \ PackReadme call readme_viewer#minpac#open(, )
25 | elseif g:readme_viewer#plugin_manager ==# 'vim-jetpack' || exists('*jetpack#begin')
26 | command! -nargs=1 -bar -complete=customlist,readme_viewer#jetpack#completion
27 | \ JetpackReadme call readme_viewer#jetpack#open(, )
28 | endif
29 | command! -nargs=1 -bar -complete=customlist,readme_viewer#completion
30 | \ ReadmeOpen call readme_viewer#open(, )
31 |
32 | if has('nvim')
33 | if g:readme_viewer#plugin_manager ==# 'packer.nvim' || exists(':PackerInstall')
34 | command! -nargs=1 -bar -complete=customlist,v:lua.require'readme_viewer'.packer_completion
35 | \ PackerReadme lua require('readme_viewer').packer(, )
36 | endif
37 | endif
38 |
39 | augroup readme_viewer
40 | autocmd!
41 | autocmd User ReadmeOpen :
42 | if !get(g:, 'readme_viewer#no_mappings', v:false)
43 | autocmd User ReadmeOpen
44 | \ nnoremap q q
45 | endif
46 | if !get(g:, 'readme_viewer#no_buffer_commands', v:false)
47 | autocmd User ReadmeOpen
48 | \ command! -buffer -bar ReadmeHelp
49 | \ execute 'help' b:readme_data.normalized_name
50 | autocmd User ReadmeOpen
51 | \ command! -buffer -bar ReadmeDir
52 | \ edit %:p:h
53 | endif
54 | augroup END
55 |
56 | let &cpo = s:save_cpo
57 | unlet s:save_cpo
58 |
--------------------------------------------------------------------------------
/test/dein/test.vimrc:
--------------------------------------------------------------------------------
1 | set nocompatible
2 |
3 | let s:cache = expand(':p:h') .. '/cache/dein'
4 | let s:repo_dir = s:cache .. '/repos/github.com/Shougo/dein.vim'
5 | let g:readme_viewer#plugin_manager = 'dein.vim'
6 |
7 | if &runtimepath !~# s:cache
8 | if !isdirectory(s:repo_dir)
9 | execute '!git clone https://github.com/Shougo/dein.vim'
10 | \ '--depth 1' s:repo_dir
11 | endif
12 | execute 'set runtimepath^=' .. s:repo_dir
13 | endif
14 |
15 | call dein#begin(s:cache)
16 |
17 | call dein#add('Shougo/dein.vim')
18 | call dein#add('4513ECHO/vim-readme-viewer')
19 |
20 | call dein#end()
21 |
--------------------------------------------------------------------------------
/test/dpp/config.ts:
--------------------------------------------------------------------------------
1 | import {
2 | BaseConfig,
3 | ConfigReturn,
4 | ContextBuilder,
5 | Dpp,
6 | Plugin,
7 | } from "https://deno.land/x/dpp_vim@v0.0.9/types.ts";
8 | import { Denops } from "https://deno.land/x/dpp_vim@v0.0.9/deps.ts";
9 |
10 | export class Config extends BaseConfig {
11 | override async config(args: {
12 | denops: Denops;
13 | contextBuilder: ContextBuilder;
14 | basePath: string;
15 | dpp: Dpp;
16 | }): Promise {
17 | args.contextBuilder.setGlobal({
18 | protocols: ["git"],
19 | });
20 |
21 | const pluginList = [
22 | {
23 | lazy: false,
24 | repo: "Shougo/dpp.vim",
25 | name: "dpp.vim",
26 | },
27 | {
28 | lazy: false,
29 | repo: "Shougo/dpp-ext-installer",
30 | name: "dpp-ext-installer",
31 | },
32 | {
33 | lazy: false,
34 | repo: "Shougo/dpp-protocol-git",
35 | name: "dpp-protocol-git",
36 | },
37 | {
38 | lazy: false,
39 | repo: "vim-denops/denops.vim",
40 | name: "denops.vim",
41 | },
42 | {
43 | lazy: false,
44 | repo: "yasunori0418/vim-readme-viewer",
45 | name: "vim-readme-viewer",
46 | rev: "feat-dpp_support"
47 | },
48 | ] as Plugin[];
49 |
50 | return {
51 | plugins: pluginList,
52 | };
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/test/dpp/test.vimrc:
--------------------------------------------------------------------------------
1 | set nocompatible
2 |
3 | let s:cache = expand(':p:h') . '/cache/dpp'
4 | let s:config = expand(':p:h') . '/config.ts'
5 | let s:repos = [
6 | \ 'Shougo/dpp.vim',
7 | \ 'Shougo/dpp-ext-installer',
8 | \ 'Shougo/dpp-protocol-git',
9 | \ 'vim-denops/denops.vim',
10 | \ ]
11 | let g:readme_viewer#plugin_manager = 'dpp.vim'
12 |
13 | if &runtimepath !~# s:cache
14 | for repo in s:repos
15 | let repo_path = s:cache . '/repos/github.com/' . repo
16 | if !isdirectory(repo_path)
17 | execute '!git clone https://github.com/' . repo
18 | \ '--depth 1 ' . repo_path
19 | endif
20 | execute 'set runtimepath^=' . repo_path
21 | endfor
22 | endif
23 |
24 | if dpp#min#load_state(s:cache)
25 | call dpp#make_state(s:cache, s:config)
26 | augroup dpp_init
27 | autocmd!
28 | autocmd User Dpp:makeStatePost echomsg 'dpp make_state() is done'
29 | augroup END
30 | endif
31 |
--------------------------------------------------------------------------------
/test/minpac/test.vimrc:
--------------------------------------------------------------------------------
1 | set nocompatible
2 |
3 | let s:cache = expand(':p:h') .. '/cache/minpac'
4 | let s:repo_dir = s:cache .. '/pack/minpac/opt/minpac'
5 | let g:readme_viewer#plugin_manager = 'minpac'
6 |
7 | if &packpath !~# s:cache
8 | if !isdirectory(s:repo_dir)
9 | execute '!git clone https://github.com/k-takata/minpac'
10 | \ '--depth 1' s:repo_dir
11 | endif
12 | execute 'set packpath^=' .. s:cache
13 | endif
14 |
15 | packadd minpac
16 |
17 | call minpac#init()
18 |
19 | call minpac#add('k-takata/minpac', {'type': 'opt'})
20 | call minpac#add('4513ECHO/vim-readme-viewer')
21 |
22 | packloadall
23 |
--------------------------------------------------------------------------------
/test/packer/test.vimrc:
--------------------------------------------------------------------------------
1 | set nocompatible
2 |
3 | let s:cache = expand(':p:h') .. '/cache/packer'
4 | let s:repo_dir = s:cache .. '/pack/packer/opt/packer.nvim'
5 | let g:readme_viewer#plugin_manager = 'packer.nvim'
6 |
7 | if &packpath !~# s:cache
8 | if !isdirectory(s:repo_dir)
9 | execute '!git clone https://github.com/wbthomason/packer.nvim'
10 | \ '--depth 1' s:repo_dir
11 | endif
12 | execute 'set packpath^=' .. s:cache
13 | endif
14 |
15 | lua << ENDLUA
16 | vim.cmd [[packadd packer.nvim]]
17 |
18 | return require('packer').startup(function(use)
19 | use { 'wbthomason/packer.nvim', opt = true }
20 | use '4513ECHO/vim-readme-viewer'
21 | end)
22 | ENDLUA
23 |
24 |
--------------------------------------------------------------------------------
/test/plug/test.vimrc:
--------------------------------------------------------------------------------
1 | set nocompatible
2 |
3 | let s:cache = expand(':p:h') .. '/cache/plug'
4 | let s:repo_file = s:cache .. '/autoload/plug.vim'
5 | let g:readme_viewer#plugin_manager = 'vim-plug'
6 |
7 |
8 | if &runtimepath !~# s:cache
9 | if !filereadable(s:repo_file)
10 | execute '!curl -fL --create-dirs -o' s:repo_file
11 | \ 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
12 | endif
13 | execute 'set runtimepath^=' .. s:cache
14 | endif
15 |
16 | call plug#begin(s:cache)
17 |
18 | Plug 'junegunn/vim-plug'
19 | Plug '4513ECHO/vim-readme-viewer'
20 |
21 | call plug#end()
22 |
--------------------------------------------------------------------------------
/test/test.vim:
--------------------------------------------------------------------------------
1 | let s:root = expand(':p:h')
2 | let s:tasks = json_decode(join(readfile(s:root .. '/tasks.json')))
3 |
4 |
--------------------------------------------------------------------------------