From b8df28ed380ec6c425bc4dbb99dd22322d06a652 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Tue, 26 Sep 2023 20:03:48 +0900 Subject: [PATCH] Add ext-lazy --- autoload/dpp/ext/lazy.vim | 443 ++++++++++++++++++++++++++++++++++++++ autoload/dpp/source.vim | 4 +- denops/@dpp-exts/lazy.ts | 63 ++++++ denops/dpp/app.ts | 6 +- denops/dpp/base/config.ts | 7 +- denops/dpp/context.ts | 1 + denops/dpp/deps.ts | 6 +- denops/dpp/dpp.ts | 47 +++- denops/dpp/types.ts | 1 + doc/dpp-ext-lazy.txt | 55 +++++ doc/dpp-ext-toml.txt | 2 +- doc/dpp.txt | 104 ++++++++- 12 files changed, 725 insertions(+), 14 deletions(-) create mode 100644 autoload/dpp/ext/lazy.vim create mode 100644 denops/@dpp-exts/lazy.ts create mode 100644 doc/dpp-ext-lazy.txt diff --git a/autoload/dpp/ext/lazy.vim b/autoload/dpp/ext/lazy.vim new file mode 100644 index 0000000..9fff7c8 --- /dev/null +++ b/autoload/dpp/ext/lazy.vim @@ -0,0 +1,443 @@ +function! dpp#ext#lazy#_source(plugins) abort + let plugins = dpp#util#_convert2list(a:plugins) + if plugins->empty() + return [] + endif + + if plugins[0]->type() != v:t_dict + let plugins = dpp#util#_convert2list(a:plugins) + \ ->map({ _, val -> g:dpp#_plugins->get(val, {}) }) + endif + + let rtps = dpp#util#_split_rtp(&runtimepath) + const index = rtps->index(dpp#util#_get_runtime_path()) + if index < 0 + return [] + endif + + let sourced = [] + for plugin in plugins + \ ->filter({ _, val -> + \ !(val->empty()) && !val.sourced && val.rtp !=# '' + \ && (!(v:val->has_key('if')) || v:val.if->eval()) + \ && v:val.path->isdirectory() + \ }) + call s:source_plugin(rtps, index, plugin, sourced) + endfor + + const filetype_before = 'autocmd FileType'->execute() + let &runtimepath = dpp#util#_join_rtp(rtps, &runtimepath, '') + + call dpp#util#_call_hook('source', sourced) + + " Reload script files. + for plugin in sourced + for directory in ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'] + \ ->filter({ _, val -> (plugin.rtp .. '/' .. val)->isdirectory() }) + \ ->map({ _, val -> plugin.rtp .. '/' .. val }) + if directory =~# 'ftdetect' + if !(plugin->get('merge_ftdetect')) + execute 'augroup filetypedetect' + endif + endif + let files = (directory .. '/**/*.vim')->glob(v:true, v:true) + if has('nvim') + let files += (directory .. '/**/*.lua')->glob(v:true, v:true) + endif + for file in files + execute 'source' file->fnameescape() + endfor + if directory =~# 'ftdetect' + execute 'augroup END' + endif + endfor + + if !has('vim_starting') + let augroup = plugin->get('augroup', plugin.normalized_name) + let events = ['VimEnter', 'BufRead', 'BufEnter', + \ 'BufWinEnter', 'WinEnter'] + if has('gui_running') && &term ==# 'builtin_gui' + call add(events, 'GUIEnter') + endif + for event in events + if ('#' .. augroup .. '#' .. event)->exists() + silent execute 'doautocmd' augroup event + endif + endfor + + " Register for lazy loaded denops plugin + if (plugin.rtp .. '/denops')->isdirectory() + for name in 'denops/*/main.ts' + \ ->globpath(plugin.rtp, v:true, v:true) + \ ->map({ _, val -> val->fnamemodify(':h:t')}) + \ ->filter({ _, val -> !denops#plugin#is_loaded(val) }) + + if denops#server#status() ==# 'running' + " NOTE: denops#plugin#register() may be failed + silent! call denops#plugin#register(name, #{ mode: 'skip' }) + endif + + if plugin->get('denops_wait', v:true) + call denops#plugin#wait(name) + redraw + endif + endfor + endif + endif + endfor + + const filetype_after = 'autocmd FileType'->execute() + + const is_reset = s:is_reset_ftplugin(sourced) + if is_reset + " NOTE: filetype plugins must be reset to load new ftplugins + call s:reset_ftplugin() + endif + + if (is_reset || filetype_before !=# filetype_after) && &l:filetype !=# '' + " Recall FileType autocmd + let &l:filetype = &l:filetype + endif + + if !has('vim_starting') + call dpp#util#_call_hook('post_source', sourced) + endif + + return sourced +endfunction + +function! dpp#ext#lazy#_on_default_event(event) abort + let lazy_plugins = dpp#util#_get_lazy_plugins() + let plugins = [] + + let path = ''->expand() + " For ":edit ~". + if path->fnamemodify(':t') ==# '~' + let path = '~' + endif + let path = dpp#util#_expand(path) + + for filetype in &l:filetype->split('\.') + let plugins += lazy_plugins->copy() + \ ->filter({ _, val -> val->get('on_ft', []) + \ ->index(filetype) >= 0 }) + endfor + + let plugins += lazy_plugins->copy() + \ ->filter({ _, val -> !(val->get('on_path', [])->copy() + \ ->filter({ _, val -> path =~? val })->empty()) }) + let plugins += lazy_plugins->copy() + \ ->filter({ _, val -> + \ !(val->has_key('on_event')) && val->has_key('on_if') + \ && val.on_if->eval() }) + + call s:source_events(a:event, plugins) +endfunction +function! dpp#ext#lazy#_on_event(event, plugins) abort + let lazy_plugins = dpp#util#_get_plugins(a:plugins) + \ ->filter({ _, val -> !val.sourced }) + if lazy_plugins->empty() + execute 'autocmd! dpp-events' a:event + return + endif + + let plugins = lazy_plugins->copy() + \ ->filter({ _, val -> + \ !(val->has_key('on_if')) || val.on_if->eval() }) + call s:source_events(a:event, plugins) +endfunction +function! s:source_events(event, plugins) abort + if empty(a:plugins) + return + endif + + const prev_autocmd = ('autocmd ' .. a:event)->execute() + + call dpp#ext#lazy#_source(a:plugins) + + const new_autocmd = ('autocmd ' .. a:event)->execute() + + if a:event ==# 'InsertCharPre' + " Queue this key again + call feedkeys(v:char) + let v:char = '' + else + if '#BufReadCmd'->exists() && a:event ==# 'BufNew' + " For BufReadCmd plugins + silent doautocmd BufReadCmd + endif + if ('#' .. a:event)->exists() && prev_autocmd !=# new_autocmd + execute 'doautocmd ' a:event + elseif ('#User#' .. a:event)->exists() + execute 'doautocmd User' a:event + endif + endif +endfunction + +function! dpp#ext#lazy#_on_func(name) abort + const function_prefix = a:name->substitute('[^#]*$', '', '') + if function_prefix =~# '^dpp#' + \ || (function_prefix =~# '^vital#' && + \ function_prefix !~# '^vital#vital#') + return + endif + + call dpp#ext#lazy#_source(dpp#util#_get_lazy_plugins() + \ ->filter({ _, val -> + \ function_prefix->stridx(val.normalized_name.'#') == 0 + \ || val->get('on_func', [])->index(a:name) >= 0 })) +endfunction + +function! dpp#ext#lazy#_on_lua(name) abort + if g:dpp#_called_lua->has_key(a:name) + return + endif + + " Only use the root of module name. + const mod_root = a:name->matchstr('^[^./]\+') + + " Prevent infinite loop + let g:dpp#_called_lua[a:name] = v:true + + call dpp#ext#lazy#_source(dpp#util#_get_lazy_plugins() + \ ->filter({ _, val -> + \ val->get('on_lua', [])->index(mod_root) >= 0 })) +endfunction + +function! dpp#ext#lazy#_on_pre_cmd(name) abort + call dpp#ext#lazy#_source( + \ dpp#util#_get_lazy_plugins() + \ ->filter({ _, val -> copy(val->get('on_cmd', [])) + \ ->map({ _, val2 -> tolower(val2) }) + \ ->index(a:name) >= 0 + \ || a:name->tolower() + \ ->stridx(val.normalized_name->tolower() + \ ->substitute('[_-]', '', 'g')) == 0 })) +endfunction + +function! dpp#ext#lazy#_on_cmd(command, name, args, bang, line1, line2) abort + call dpp#source(a:name) + + if (':' .. a:command)->exists() != 2 + call dpp#util#_error(printf('command %s is not found.', a:command)) + return + endif + + const range = (a:line1 == a:line2) ? '' : + \ (a:line1 == "'<"->line() && a:line2 == "'>"->line()) ? + \ "'<,'>" : a:line1 .. ',' .. a:line2 + + try + execute range.a:command.a:bang a:args + catch /^Vim\%((\a\+)\)\=:E481/ + " E481: No range allowed + execute a:command.a:bang a:args + endtry +endfunction + +function! dpp#ext#lazy#_on_map(mapping, name, mode) abort + const cnt = v:count > 0 ? v:count : '' + + const input = s:get_input() + + const sourced = dpp#source(a:name) + if sourced->empty() + " Prevent infinite loop + silent! execute a:mode.'unmap' a:mapping + endif + + if a:mode ==# 'v' || a:mode ==# 'x' + call feedkeys('gv', 'n') + elseif a:mode ==# 'o' && v:operator !=# 'c' + const save_operator = v:operator + call feedkeys("\", 'in') + + " Cancel waiting operator mode. + call feedkeys(save_operator, 'imx') + endif + + call feedkeys(cnt, 'n') + + if a:mode ==# 'o' && v:operator ==# 'c' + " NOTE: This is the dirty hack. + execute s:mapargrec(a:mapping .. input, a:mode)->matchstr( + \ ':\zs.*\ze') + else + let mapping = a:mapping + while mapping =~# '<[[:alnum:]_-]\+>' + let mapping = mapping->substitute('\c', + \ g:->get('mapleader', '\'), 'g') + let mapping = mapping->substitute('\c', + \ g:->get('maplocalleader', '\'), 'g') + let ctrl = mapping->matchstr('<\zs[[:alnum:]_-]\+\ze>') + execute 'let mapping = mapping->substitute( + \ "<' .. ctrl .. '>", "\<' .. ctrl .. '>", "")' + endwhile + + if a:mode ==# 't' + call feedkeys('i', 'n') + endif + call feedkeys(mapping .. input, 'm') + endif + + return '' +endfunction + +function! dpp#ext#lazy#_dummy_complete(arglead, cmdline, cursorpos) abort + const command = a:cmdline->matchstr('\h\w*') + if (':' .. command)->exists() == 2 + " Remove the dummy command. + silent! execute 'delcommand' command + endif + + " Load plugins + call dpp#ext#lazy#_on_pre_cmd(tolower(command)) + + return a:arglead +endfunction + +function! s:source_plugin(rtps, index, plugin, sourced) abort + if a:plugin.sourced || a:sourced->index(a:plugin) >= 0 + \ || (a:plugin->has_key('if') && !(a:plugin.if->eval())) + return + endif + + call insert(a:sourced, a:plugin) + + let index = a:index + + " NOTE: on_source must sourced after depends + for on_source in dpp#util#_get_lazy_plugins() + \ ->filter({ _, val -> + \ val->get('on_source', []) ->index(a:plugin.name) >= 0 + \ }) + if s:source_plugin(a:rtps, index, on_source, a:sourced) + let index += 1 + endif + endfor + + " Load dependencies + for name in a:plugin->get('depends', []) + if !(g:dpp#_plugins->has_key(name)) + call dpp#util#_error(printf( + \ 'Plugin "%s" depends "%s" but it is not found.', + \ a:plugin.name, name)) + continue + endif + + if !a:plugin.lazy && g:dpp#_plugins[name].lazy + call dpp#util#_error(printf( + \ 'Not lazy plugin "%s" depends lazy "%s" plugin.', + \ a:plugin.name, name)) + continue + endif + + if s:source_plugin(a:rtps, index, g:dpp#_plugins[name], a:sourced) + let index += 1 + endif + endfor + + let a:plugin.sourced = 1 + + if a:plugin->has_key('dummy_commands') + for command in a:plugin.dummy_commands + silent! execute 'delcommand' command[0] + endfor + let a:plugin.dummy_commands = [] + endif + + if a:plugin->has_key('dummy_mappings') + for map in a:plugin.dummy_mappings + silent! execute map[0].'unmap' map[1] + endfor + let a:plugin.dummy_mappings = [] + endif + + if !a:plugin.merged || a:plugin->get('local', 0) + call insert(a:rtps, a:plugin.rtp, index) + if (a:plugin.rtp .. '/after')->isdirectory() + call dpp#util#_add_after(a:rtps, a:plugin.rtp .. '/after') + endif + endif + + if g:->get('dpp#lazy_rplugins', v:false) && !g:dpp#_loaded_rplugins + \ && (a:plugin.rtp .. '/rplugin')->isdirectory() + " Enable remote plugin + unlet! g:loaded_remote_plugins + + runtime! plugin/rplugin.vim + + let g:dpp#_loaded_rplugins = v:true + endif +endfunction +function! s:reset_ftplugin() abort + const filetype_state = 'filetype'->execute() + + if 'b:did_indent'->exists() || 'b:did_ftplugin'->exists() + filetype plugin indent off + endif + + if filetype_state =~# 'plugin:ON' + silent! filetype plugin on + endif + + if filetype_state =~# 'indent:ON' + silent! filetype indent on + endif +endfunction +function! s:get_input() abort + let input = '' + const termstr = '' + + call feedkeys(termstr, 'n') + + while 1 + let char = getchar() + let input ..= (char->type() == v:t_number) ? char->nr2char() : char + + let idx = input->stridx(termstr) + if idx >= 1 + let input = input[: idx - 1] + break + elseif idx == 0 + let input = '' + break + endif + endwhile + + return input +endfunction + +function! s:is_reset_ftplugin(plugins) abort + if &l:filetype ==# '' + return 0 + endif + + for plugin in a:plugins + let ftplugin = plugin.rtp .. '/ftplugin/' .. &l:filetype + let after = plugin.rtp .. '/after/ftplugin/' .. &l:filetype + let check_ftplugin = !(['ftplugin', 'indent', + \ 'after/ftplugin', 'after/indent',] + \ ->filter({ _, val -> printf('%s/%s/%s.vim', + \ plugin.rtp, val, &l:filetype)->filereadable() + \ || printf('%s/%s/%s.lua', + \ plugin.rtp, val, &l:filetype)->filereadable() + \ })->empty()) + if check_ftplugin + \ || ftplugin->isdirectory() || after->isdirectory() + \ || (ftplugin .. '_*.vim')->glob(v:true) !=# '' + \ || (after .. '_*.vim')->glob(v:true) !=# '' + \ || (ftplugin .. '_*.lua')->glob(v:true) !=# '' + \ || (after .. '_*.lua')->glob(v:true) !=# '' + return 1 + endif + endfor + return 0 +endfunction +function! s:mapargrec(map, mode) abort + let arg = a:map->maparg(a:mode) + while arg->maparg(a:mode) !=# '' + let arg = arg->maparg(a:mode) + endwhile + return arg +endfunction diff --git a/autoload/dpp/source.vim b/autoload/dpp/source.vim index c3dc0d4..1df5164 100644 --- a/autoload/dpp/source.vim +++ b/autoload/dpp/source.vim @@ -28,7 +28,7 @@ function dpp#autoload#_source(plugins) abort const filetype_before = 'autocmd FileType'->execute() let &runtimepath = dpp#util#_join_rtp(rtps, &runtimepath, '') - call dpp#call_hook('source', sourced) + call dpp#util#_call_hook('source', sourced) " Reload script files. for plugin in sourced @@ -100,7 +100,7 @@ function dpp#autoload#_source(plugins) abort endif if !has('vim_starting') - call dpp#call_hook('post_source', sourced) + call dpp#util#_call_hook('post_source', sourced) endif return sourced diff --git a/denops/@dpp-exts/lazy.ts b/denops/@dpp-exts/lazy.ts new file mode 100644 index 0000000..d367cc3 --- /dev/null +++ b/denops/@dpp-exts/lazy.ts @@ -0,0 +1,63 @@ +import { Actions, BaseExt, Plugin } from "../dpp/types.ts"; + +type Params = Record; + +type MakeStateArgs = { + plugins: Plugin[]; +}; + +const StateLines = [ + "augroup dpp", + " autocmd FuncUndefined *", + " \\ : if ''->expand()->stridx('remote#') != 0", + " \\ | call dpp#ext#lazy#_on_func(''->expand())", + " \\ | endif", + " autocmd BufRead *? call dpp#ext#lazy#_on_default_event('BufRead')", + " autocmd BufNew,BufNewFile *? call dpp#ext#lazy#_on_default_event('BufNew')", + " autocmd VimEnter *? call dpp#ext#lazy#_on_default_event('VimEnter')", + " autocmd FileType *? call dpp#ext#lazy#_on_default_event('FileType')", + " autocmd BufWritePost *.lua,*.vim,*.toml,vimrc,.vimrc", + " \\ call dpp#util#_check_vimrcs()", + " autocmd CmdUndefined * call dpp#ext#lazy#_on_pre_cmd(''->expand())", + "augroup END", + "augroup dpp-events | augroup END", + "if !has('nvim') | return | endif", + "lua < { + override actions: Actions = { + makeState: { + description: "Make stateLines", + callback: (args: { + actionParams: unknown; + }) => { + const params = args.actionParams as MakeStateArgs; + + // TODO: Support dummy mappings/commands + + return StateLines; + }, + }, + }; + + override params(): Params { + return {}; + } +} diff --git a/denops/dpp/app.ts b/denops/dpp/app.ts index ea20868..107ac4f 100644 --- a/denops/dpp/app.ts +++ b/denops/dpp/app.ts @@ -19,14 +19,16 @@ export function main(denops: Denops) { `${toFileUrl(configPath).href}#${performance.now()}` ); const obj = new mod.Config(); - const plugins = await obj.config({ + const configReturn = await obj.config({ denops, basePath, contextBuilder, dpp, }); - await dpp.makeState(denops, basePath, plugins); + const [_, options] = await contextBuilder.get(denops); + + await dpp.makeState(denops, options, basePath, configReturn); }, }; } diff --git a/denops/dpp/base/config.ts b/denops/dpp/base/config.ts index 8524160..6142575 100644 --- a/denops/dpp/base/config.ts +++ b/denops/dpp/base/config.ts @@ -9,10 +9,15 @@ export type ConfigArguments = { dpp: Dpp; }; +export type ConfigReturn = { + plugins: Plugin[]; + stateLines: string[]; +}; + export abstract class BaseConfig { apiVersion = 1; - config(_args: ConfigArguments): Plugin[] | Promise { + config(_args: ConfigArguments): ConfigReturn[] | Promise { return []; } } diff --git a/denops/dpp/context.ts b/denops/dpp/context.ts index d88fb7f..2075054 100644 --- a/denops/dpp/context.ts +++ b/denops/dpp/context.ts @@ -46,6 +46,7 @@ export function defaultDppOptions(): DppOptions { return { extOptions: {}, extParams: {}, + inlineVimrcs: [], protocolOptions: {}, protocolParams: {}, }; diff --git a/denops/dpp/deps.ts b/denops/dpp/deps.ts index 79e1dd0..449d25a 100644 --- a/denops/dpp/deps.ts +++ b/denops/dpp/deps.ts @@ -16,7 +16,11 @@ export { assertEquals, equal, } from "https://deno.land/std@0.201.0/assert/mod.ts"; -export { parse, toFileUrl } from "https://deno.land/std@0.201.0/path/mod.ts"; +export { + extname, + parse, + toFileUrl, +} from "https://deno.land/std@0.201.0/path/mod.ts"; export { deadline, DeadlineError, diff --git a/denops/dpp/dpp.ts b/denops/dpp/dpp.ts index 3b2b03b..95b4ac0 100644 --- a/denops/dpp/dpp.ts +++ b/denops/dpp/dpp.ts @@ -1,4 +1,4 @@ -import { assertEquals, Denops, is, op, vars } from "./deps.ts"; +import { assertEquals, Denops, extname, is, op, vars } from "./deps.ts"; import { ActionName, BaseExt, @@ -19,6 +19,7 @@ import { } from "./context.ts"; import { Loader } from "./loader.ts"; import { defaultExtOptions } from "./base/ext.ts"; +import { ConfigReturn } from "./base/config.ts"; import { errorException, isDirectory } from "./utils.ts"; export class Dpp { @@ -44,7 +45,7 @@ export class Dpp { const action = ext.actions[actionName]; if (!action) { await denops.call( - "ddu#util#_error", + "dpp#util#_error", `Not found UI action: ${actionName}`, ); return; @@ -62,10 +63,15 @@ export class Dpp { return ret; } - async makeState(denops: Denops, basePath: string, plugins: Plugin[]) { + async makeState( + denops: Denops, + options: DppOptions, + basePath: string, + configReturn: ConfigReturn, + ) { // Initialize plugins const recordPlugins: Record = {}; - for (const plugin of plugins) { + for (const plugin of configReturn.plugins) { recordPlugins[plugin.name] = initPlugin(plugin, basePath); } @@ -134,7 +140,7 @@ export class Dpp { const cacheVersion = await vars.g.get(denops, "dpp#_cache_version"); const initRuntimepath = await vars.g.get(denops, "dpp#_init_runtimepath"); - const stateLines = [ + let stateLines = [ `if g:dpp#_cache_version !=# ${cacheVersion} ` + `|| g:dpp#_init_runtimepath !=# '${initRuntimepath}' | ` + "throw 'Cache loading error' | endif", @@ -146,13 +152,40 @@ export class Dpp { `let &runtimepath = '${newRuntimepath}'`, ]; + if (await vars.g.get(denops, "did_load_filetypes", false)) { + stateLines.push("filetype off"); + } + if ( + await vars.b.get(denops, "did_indent", false) || + await vars.b.get(denops, "did_ftplugin", false) + ) { + stateLines.push("filetype plugin indent off"); + } + + for await ( + const vimrc of options.inlineVimrcs.map(async (vimrc) => + await denops.call("dpp#util#_expand", vimrc) as string + ) + ) { + const vimrcLines = (await Deno.readTextFile(vimrc)).split("\n"); + if (extname(vimrc) == "lua") { + stateLines = ["lua < !line.match(/^\s*$|^\s*--/)), + ).concat(["EOF"]); + } else { + stateLines = stateLines.concat( + vimrcLines.filter((line) => !line.match(/^\s*$|^\s*"/)), + ); + } + } + const stateFile = `${basePath}/state_${progname}.vim`; console.log(stateFile); await Deno.writeTextFile(stateFile, stateLines.join("\n")); const cacheFile = `${basePath}/cache_${progname}.vim`; const cacheLines = [ - JSON.stringify([plugins, {}]), + JSON.stringify([configReturn.plugins, {}]), ]; console.log(cacheFile); await Deno.writeTextFile(cacheFile, cacheLines.join("\n")); @@ -318,6 +351,7 @@ Deno.test("initPlugin", () => { script_type: "foo", lazy: false, merged: true, + sourced: false, }, ); @@ -334,6 +368,7 @@ Deno.test("initPlugin", () => { lazy: true, merged: false, on_ft: "foo", + sourced: false, }, ); }); diff --git a/denops/dpp/types.ts b/denops/dpp/types.ts index 5bf318d..69583cd 100644 --- a/denops/dpp/types.ts +++ b/denops/dpp/types.ts @@ -26,6 +26,7 @@ export type Context = { export type DppOptions = { extOptions: Record>; extParams: Record>; + inlineVimrcs: string[]; protocolOptions: Record>; protocolParams: Record>; }; diff --git a/doc/dpp-ext-lazy.txt b/doc/dpp-ext-lazy.txt new file mode 100644 index 0000000..1b3e857 --- /dev/null +++ b/doc/dpp-ext-lazy.txt @@ -0,0 +1,55 @@ +*dpp-ext-lazy.txt* lazy ext for dpp.vim + +Author: Shougo +License: MIT license + +CONTENTS *dpp-ext-lazy-contents* + +Introduction |dpp-ext-lazy-introduction| +Install |dpp-ext-lazy-install| +Examples |dpp-ext-lazy-examples| +Actions |dpp-ext-lazy-actions| +Preview params |dpp-ext-lazy-preview-params| +Params |dpp-ext-lazy-params| +Compatibility |dpp-ext-lazy-compatibility| + + +============================================================================== +INTRODUCTION *dpp-ext-lazy-introduction* + +This ext implements lazy loading. + + +============================================================================== +INSTALL *dpp-ext-lazy-install* + +Please install both "dpp.vim" and "denops.vim". + +https://github.com/Shougo/dpp.vim +https://github.com/vim-denops/denops.vim + + +============================================================================== +EXAMPLES *dpp-ext-lazy-examples* +> +< + +============================================================================== +ACTIONS *dpp-ext-lazy-actions* + + *dpp-ext-lazy-action-makeState* +makeState + Returns state lines for |dpp#make_state()|. + + params: + {plugins}: plugins list. + (Required) + +============================================================================== +PARAMS *dpp-ext-lazy-params* + +============================================================================== +COMPATIBILITY *dpp-ext-lazy-compatibility* + +============================================================================== +vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: diff --git a/doc/dpp-ext-toml.txt b/doc/dpp-ext-toml.txt index c27b50c..664553a 100644 --- a/doc/dpp-ext-toml.txt +++ b/doc/dpp-ext-toml.txt @@ -33,7 +33,7 @@ https://github.com/vim-denops/denops.vim EXAMPLES *dpp-ext-toml-examples* > const plugins = await args.dpp.extAction(args.denops, "toml", "load", { - path: "$BASE_DIR/dein.toml", + path: "$BASE_DIR/dpp.toml", options: { lazy: true, }, diff --git a/doc/dpp.txt b/doc/dpp.txt index fe5f7bd..de30e27 100644 --- a/doc/dpp.txt +++ b/doc/dpp.txt @@ -17,6 +17,10 @@ Exts |dpp-exts| Protocols |dpp-protocols| Protocol option |dpp-protocol-options| Protocol params |dpp-protocol-params| +Create Ext |dpp-create-ext| + Ext attributes |dpp-ext-attributes| +Create Protocol |dpp-create-protocol| + Protocol attributes |dpp-protocol-attributes| FAQ |dpp-faq| Compatibility |dpp-compatibility| @@ -53,6 +57,48 @@ INTERFACE *dpp-interface* ------------------------------------------------------------------------------ OPTIONS *dpp-options* + *dpp-option-extOptions* +extOptions (dictionary) + It is a dictionary that maps ext names to its options. + The options with the name "_" is used as the options for all + names. + See also |dpp-ext-options|. + + Default: {} + + *dpp-option-extParams* +extParams (dictionary) + It is a dictionary that maps ext names to its parameters. + See also |dpp-ext-params|. + + Default: {} + + *dpp-option-inlineVimrcs* +inlineVimrcs (string[]) + The vimrcs are sourced in |dpp#min#load_state()| before hooks. + NOTE: It must be set before |dpp#make_state()|. + NOTE: The files must not be included "<<" pattern(here + document). It breaks the parser. + NOTE: It also supports ".lua" file for neovim. + + Defaults: [] + + *dpp-option-protocolOptions* +protocolOptions (dictionary) + It is a dictionary that maps protocol names to its options. + The options with the name "_" is used as the options for all + names. + See also |dpp-protocol-options|. + + Default: {} + + *dpp-option-protocolParams* +protocolParams (dictionary) + It is a dictionary that maps protocol names to its parameters. + See also |dpp-protocol-params|. + + Default: {} + ------------------------------------------------------------------------------ FUNCTIONS *dpp-functions* @@ -86,7 +132,7 @@ dpp#min#load_state({base-path}) dpp#source([{name}]) |:source| the plugins specified by {plugins}. {plugins} is the plugins name list. - If you omit it, dein will source all plugins. + If you omit it, dpp will source all plugins. It returns sourced plugins list. ============================================================================== @@ -166,6 +212,62 @@ These are the parameters that each Protocol can have. Please read the Protocol documentation. +============================================================================== +CREATE EXT *dpp-create-ext* + +To create ext, you should read other exts implementation. + +The ext must put under "denops/@dpp-exts/*.ts". + +The ext class must extend the "BaseExt" class. + +NOTE: It must be written in TypeScript language. + +NOTE: If you call Vim functions, it is not asynchronous. + + +------------------------------------------------------------------------------ +EXT ATTRIBUTES *dpp-ext-attributes* + + *dpp-ext-attribute-actions* +actions (Record) (Required) + Defines ext specific actions. + + *dpp-ext-attribute-onInit* +onInit (function) (Optional) + Called before call ext functions. + + *dpp-ext-attribute-params* +params (function) (Required) + Called to get ext params. + + +============================================================================== +CREATE PROTOCOL *dpp-create-protocol* + +To create protocol, you should read other protocols implementation. + +The protocol must put under "denops/@dpp-protocols/*.ts". + +The protocol class must extend the "BaseProtocol" class. + +NOTE: It must be written in TypeScript language. + +NOTE: If you call Vim functions, it is not asynchronous. + + +------------------------------------------------------------------------------ +PROTOCOL ATTRIBUTES *dpp-protocol-attributes* + + *dpp-protocol-attribute-onInit* +onInit (function) (Optional) + Called before call protocol functions. + + *dpp-protocol-attribute-params* +params (function) (Required) + Called to get protocol params. + + ============================================================================== FAQ *dpp-faq*