diff --git a/autoload/dpp/ext/installer.vim b/autoload/dpp/ext/installer.vim deleted file mode 100644 index fc7a2cd..0000000 --- a/autoload/dpp/ext/installer.vim +++ /dev/null @@ -1,58 +0,0 @@ -function dpp#ext#installer#_print_progress_message(msg) abort - if !exists('s:progress_winid') || s:progress_winid <= 0 - let s:progress_winid = s:new_progress_window() - endif - - const bufnr = s:progress_winid->winbufnr() - if bufnr->getbufline(1) ==# [''] - call setbufline(bufnr, 1, a:msg) - else - call appendbufline(bufnr, '$', a:msg) - endif - call win_execute(s:progress_winid, "call cursor('$', 0) | redraw") -endfunction - -function dpp#ext#installer#_close_progress_window() abort - if !exists('s:progress_winid') || s:progress_winid->winbufnr() < 0 - return - endif - - if has('nvim') - silent! call nvim_win_close(s:progress_winid, v:true) - else - silent! call popup_close(s:progress_winid) - endif - - let s:progress_winid = -1 -endfunction - -function s:new_progress_window() abort - const winrow = 0 - const wincol = &columns / 4 - const winwidth = 80 - const winheight = 20 - - if has('nvim') - const winid = nvim_open_win(nvim_create_buf(v:false, v:true), v:true, #{ - \ relative: 'editor', - \ row: winrow, - \ col: wincol, - \ focusable: v:false, - \ noautocmd: v:true, - \ style: 'minimal', - \ width: winwidth, - \ height: winheight, - \}) - else - const winid = popup_create([], #{ - \ pos: 'topleft', - \ line: winrow + 1, - \ col: wincol + 1, - \ minwidth: winwidth, - \ minheight: winheight, - \ wrap: 0, - \ }) - endif - - return winid -endfunction diff --git a/autoload/dpp/ext/lazy.vim b/autoload/dpp/ext/lazy.vim deleted file mode 100644 index d90bfa2..0000000 --- a/autoload/dpp/ext/lazy.vim +++ /dev/null @@ -1,509 +0,0 @@ -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') - const augroup = plugin->get('augroup', - \ dpp#util#_get_normalized_name(plugin)) - 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( - \ dpp#util#_get_normalized_name(val).'#') == 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(dpp#util#_get_normalized_name(val)->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 - -function dpp#ext#lazy#_generate_dummy_commands(plugin) abort - let dummy_commands = [] - for name in dpp#util#_convert2list(a:plugin->get('on_cmd', [])) - " Define dummy commands. - let raw_cmd = 'command ' - \ .. '-complete=custom,dpp#autoload#_dummy_complete' - \ .. ' -bang -bar -range -nargs=* '. name - \ .. printf(" call dpp#autoload#_on_cmd(%s, %s, , - \ ''->expand(), ''->expand(), ''->expand())", - \ name->string(), a:plugin.name->string()) - - call add(dummy_commands, raw_cmd) - endfor - return dummy_commands -endfunction -function dpp#ext#lazy#_generate_dummy_mappings(plugin) abort - let dummy_mappings = [] - const normalized_name = dpp#util#_get_normalized_name(a:plugin) - const on_map = a:plugin->get('on_map', []) - let items = on_map->type() == v:t_dict ? - \ on_map->items()->map({ _, val -> [val[0]->split('\zs'), - \ dpp#util#_convert2list(val[1])]}) : - \ on_map->copy()->map({ _, val -> type(val) == v:t_list ? - \ [val[0]->split('\zs'), val[1:]] : - \ [['n', 'x', 'o'], [val]] - \ }) - for [modes, mappings] in items - if mappings ==# [''] - " Use plugin name. - let mappings = ['(' .. normalized_name] - if normalized_name->stridx('-') >= 0 - " The plugin mappings may use "_" instead of "-". - call add(mappings, '(' - \ .. normalized_name->substitute('-', '_', 'g')) - endif - endif - - for mapping in mappings - " Define dummy mappings. - let prefix = printf('dpp#autoload#_on_map(%s, %s,', - \ mapping->substitute('<', '', 'g')->string(), - \ a:plugin.name->string()) - for mode in modes - let escape = has('nvim') ? "\\" : "\N" - let raw_map = mode.'noremap '.mapping - \ .. (mode ==# 'c' ? " \=" : - \ mode ==# 'i' ? " \:call " : - \ mode ==# 't' ? " " .. escape .. ":call " : - \ " :\call ") - \ .. prefix .. mode->string() .. ')' - call add(dummy_mappings, raw_map) - endfor - endfor - endfor - - return dummy_mappings -endfunction -function dpp#ext#lazy#_generate_on_lua(plugin) abort - return dpp#util#_convert2list(a:plugin.on_lua) - \ ->map({ _, val -> val->matchstr('^[^./]\+') }) - \ ->map({ _, mod -> printf("let g:dpp#_on_lua_plugins[%s] = v:true", - \ string(mod) )}) -endfunction diff --git a/autoload/dpp/ext/toml.vim b/autoload/dpp/ext/toml.vim deleted file mode 100644 index 6f4bddb..0000000 --- a/autoload/dpp/ext/toml.vim +++ /dev/null @@ -1,36 +0,0 @@ -function dpp#ext#toml#syntax() abort - if has('nvim') && ':TSBufDisable'->exists() - TSBufDisable highlight - endif - - syntax clear - - unlet! b:current_syntax - runtime! syntax/toml.vim - - unlet! b:current_syntax - silent! syntax include @tomlVim syntax/vim.vim - syntax region tomlVim matchgroup=tomlString - \ start=+\<[[:alnum:]_][[:alnum:]_-]*\s*=\s*\z('''\|"""\)+ - \ end=+\z1+ contains=@tomlVim keepend - - unlet! b:current_syntax - silent! syntax include @tomlLua syntax/lua.vim - syntax region tomlLua matchgroup=tomlString - \ start=+\; - -export class Ext extends BaseExt { - override actions: Actions = { - install: { - description: "Install plugins", - callback: async (args: { - denops: Denops; - options: DppOptions; - protocols: Record; - actionParams: unknown; - }) => { - const plugins = await detectPlugins(args); - - const bits = await Promise.all( - plugins.map(async (plugin) => - plugin.path && !await isDirectory(plugin.path) - ), - ); - - await updatePlugins(args, plugins.filter((_) => bits.shift())); - }, - }, - update: { - description: "Update plugins", - callback: async (args: { - denops: Denops; - options: DppOptions; - protocols: Record; - actionParams: unknown; - }) => { - await updatePlugins(args, await detectPlugins(args)); - }, - }, - }; - - override params(): Params { - return {}; - } -} - -async function detectPlugins(args: { - denops: Denops; - options: DppOptions; - protocols: Record; - actionParams: unknown; -}) { - const plugins = Object.values( - await vars.g.get( - args.denops, - "dpp#_plugins", - ), - ) as Plugin[]; - - // Detect protocol - for (const plugin of plugins) { - if ("protocol" in plugin) { - continue; - } - - for ( - const protocol of args.options.protocols.filter((protocolName) => - args.protocols[protocolName] - ).map((protocolName) => args.protocols[protocolName]) - ) { - const detect = await protocol.protocol.detect({ - denops: args.denops, - plugin, - protocolOptions: protocol.options, - protocolParams: protocol.params, - }); - - if (detect) { - // Overwrite by detect() - Object.assign(plugin, { - ...detect, - protocol: protocol.protocol.name, - }); - } - } - } - - return plugins; -} - -async function updatePlugins(args: { - denops: Denops; - options: DppOptions; - protocols: Record; - actionParams: unknown; -}, plugins: Plugin[]) { - // NOTE: Skip local plugins - for (const plugin of plugins.filter((plugin) => !plugin.local)) { - await args.denops.call( - "dpp#ext#installer#_print_progress_message", - plugin.name, - ); - - const protocol = args.protocols[plugin.protocol ?? ""]; - - const commands = await protocol.protocol.getSyncCommands({ - denops: args.denops, - plugin, - protocolOptions: protocol.options, - protocolParams: protocol.params, - }); - - // Execute commands - for (const command of commands) { - const proc = new Deno.Command( - command.command, - { - args: command.args, - cwd: await isDirectory(plugin.path ?? "") ? plugin.path : Deno.cwd(), - stdout: "piped", - stderr: "piped", - }, - ); - - const { stdout, stderr } = await proc.output(); - - for ( - const line of new TextDecoder().decode(stdout).split(/\r?\n/).filter(( - line, - ) => line.length > 0) - ) { - await args.denops.call( - "dpp#ext#installer#_print_progress_message", - line, - ); - } - - for ( - const line of new TextDecoder().decode(stderr).split(/\r?\n/).filter(( - line, - ) => line.length > 0) - ) { - await args.denops.call( - "dpp#ext#installer#_print_progress_message", - line, - ); - } - } - } - - await args.denops.call("dpp#ext#installer#_close_progress_window"); -} diff --git a/denops/@dpp-exts/lazy.ts b/denops/@dpp-exts/lazy.ts deleted file mode 100644 index 1a3e7df..0000000 --- a/denops/@dpp-exts/lazy.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { Actions, BaseExt, Plugin } from "../dpp/types.ts"; -import { Denops } from "../dpp/deps.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 CmdUndefined * call dpp#ext#lazy#_on_pre_cmd(''->expand())", - "augroup END", - "augroup dpp-events | augroup END", - "if has('nvim')", - "let g:dpp#_on_lua_plugins = {}", - "lua < { - override actions: Actions = { - makeState: { - description: "Make stateLines", - callback: async (args: { - denops: Denops; - actionParams: unknown; - }) => { - const params = args.actionParams as MakeStateArgs; - - let stateLines = StateLines; - - for (const plugin of params.plugins.filter((plugin) => plugin.lazy)) { - stateLines = stateLines.concat( - await args.denops.call( - "dpp#ext#lazy#_generate_dummy_commands", - plugin, - ) as string[], - ); - stateLines = stateLines.concat( - await args.denops.call( - "dpp#ext#lazy#_generate_dummy_mappings", - plugin, - ) as string[], - ); - - if ("on_lua" in plugin) { - stateLines = stateLines.concat( - await args.denops.call( - "dpp#ext#lazy#_generate_on_lua", - plugin, - ) as string[], - ); - } - } - - console.log(stateLines); - return stateLines; - }, - }, - }; - - override params(): Params { - return {}; - } -} diff --git a/denops/@dpp-exts/local.ts b/denops/@dpp-exts/local.ts deleted file mode 100644 index e1907ef..0000000 --- a/denops/@dpp-exts/local.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Actions, BaseExt, Plugin } from "../dpp/types.ts"; -import { Denops, fn } from "../dpp/deps.ts"; -import { isDirectory } from "../dpp/utils.ts"; -import { basename } from "https://deno.land/std@0.202.0/path/mod.ts"; - -type Params = Record; - -type LocalArgs = { - directory: string; - options?: Partial; - includes?: string[]; -}; - -export class Ext extends BaseExt { - override actions: Actions = { - local: { - description: "Load local plugins", - callback: async (args: { - denops: Denops; - actionParams: unknown; - }) => { - const params = args.actionParams as LocalArgs; - const base = await args.denops.call( - "dpp#util#_expand", - params.directory, - ); - - const defaultOptions = params.options ?? {}; - - let plugins: Plugin[] = []; - for (const include of params.includes ?? ["*"]) { - const files = await fn.glob( - args.denops, - base + "/" + include, - 1, - 1, - ) as string[]; - - const bits = await Promise.all( - files.map(async (file) => await isDirectory(file)), - ); - const dirs = files.filter((_) => bits.shift()); - - plugins = plugins.concat( - dirs.map((dir) => { - return { - ...defaultOptions, - repo: dir, - local: true, - path: dir, - name: basename(dir), - }; - }), - ); - } - - return plugins; - }, - }, - }; - - override params(): Params { - return {}; - } -} diff --git a/denops/@dpp-exts/toml.ts b/denops/@dpp-exts/toml.ts deleted file mode 100644 index 0872bc4..0000000 --- a/denops/@dpp-exts/toml.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Actions, BaseExt, Plugin } from "../dpp/types.ts"; -import { Denops } from "../dpp/deps.ts"; -import { parse } from "https://deno.land/std@0.202.0/toml/mod.ts"; -import { basename } from "https://deno.land/std@0.202.0/path/mod.ts"; - -type Params = Record; - -type LoadArgs = { - path: string; - options?: Partial; -}; - -type Toml = { - hooks_file?: string; - plugins: Plugin[]; -}; - -export class Ext extends BaseExt { - override actions: Actions = { - load: { - description: "Load toml config", - callback: async (args: { - denops: Denops; - actionParams: unknown; - }) => { - const params = args.actionParams as LoadArgs; - const path = await args.denops.call( - "dpp#util#_expand", - params.path, - ) as string; - - const defaultOptions = params.options ?? {}; - - const toml = parse(await Deno.readTextFile(path)) as Toml; - - const plugins = toml.plugins.map((plugin: Plugin) => { - return { - ...defaultOptions, - ...plugin, - name: plugin.name ?? basename(plugin.repo ?? ""), - }; - }); - - return plugins; - }, - }, - }; - - override params(): Params { - return {}; - } -} diff --git a/denops/@dpp-protocols/git.ts b/denops/@dpp-protocols/git.ts deleted file mode 100644 index ea51284..0000000 --- a/denops/@dpp-protocols/git.ts +++ /dev/null @@ -1,199 +0,0 @@ -import { Denops, vars } from "../dpp/deps.ts"; -import { - BaseProtocol, - Command, - Plugin, - ProtocolOptions, -} from "../dpp/types.ts"; -import { isDirectory } from "../dpp/utils.ts"; - -type Params = { - cloneDepth: number; - commandPath: string; - defaultHubSite: string; - defaultProtocol: string; - partialClone: boolean; - pullArgs: string[]; -}; - -export class Protocol extends BaseProtocol { - override async detect(args: { - denops: Denops; - plugin: Plugin; - protocolOptions: ProtocolOptions; - protocolParams: Params; - }): Promise | undefined> { - if (!args.plugin.repo) { - return; - } - - if ( - args.plugin.repo.match( - /\/\/(raw|gist)\.githubusercontent\.com\/|\/archive\/[^\/]+.zip$/, - ) - ) { - // Raw repository - return; - } - - if (await isDirectory(args.plugin.repo)) { - // Local repository - return { - local: true, - path: args.plugin.repo, - }; - } - - const url = await this.getUrl(args); - if (url.length === 0) { - return; - } - - const directory = url.replace(/\.git$/, "").replace(/^https:\/+|^git@/, "") - .replace(/:/, "/"); - - return { - path: `${await vars.g.get( - args.denops, - "dpp#_base_path", - )}/repos/${directory}`, - }; - } - - override async getUrl(args: { - denops: Denops; - plugin: Plugin; - protocolOptions: ProtocolOptions; - protocolParams: Params; - }): Promise { - if (!args.plugin.repo || !args.plugin.repo.match(/\//)) { - return ""; - } - - if (await isDirectory(args.plugin.repo)) { - // Local repository - return args.plugin.repo; - } - - let protocol = args.protocolParams.defaultProtocol; - let host = args.protocolParams.defaultHubSite; - let name = args.plugin.repo; - - const sshMatch = args.plugin.repo.match(/^git@(?[^:]+):(?.+)/); - const protocolMatch = args.plugin.repo.match( - /^(?[^:]+):(?[^\/]+)\/(?.+)/, - ); - if (sshMatch && sshMatch.groups) { - // Parse "git@host:name" pattern - protocol = "ssh"; - host = sshMatch.groups.host; - name = sshMatch.groups.name; - } else if (protocolMatch && protocolMatch.groups) { - // Parse "protocol://host/name" pattern - protocol = protocolMatch.groups.protocol; - host = protocolMatch.groups.host; - name = protocolMatch.groups.name; - } - - if (protocol !== "https" && protocol !== "ssh") { - await args.denops.call( - "dpp#util#_error", - `Invalid git protocol: "${protocol}"`, - ); - - return ""; - } - - const url = (protocol === "ssh") - ? `git@${host}:${name}` - : `${protocol}://${host}/${name}`; - - return url; - } - - override async getSyncCommands(args: { - denops: Denops; - plugin: Plugin; - protocolOptions: ProtocolOptions; - protocolParams: Params; - }): Promise { - if (!args.plugin.repo || !args.plugin.path) { - return []; - } - - if (await isDirectory(args.plugin.path)) { - const fetchArgs = [ - "-c", - "credential.helper=", - "fetch", - ]; - - const remoteArgs = [ - "remote", - "set-head", - "origin", - "-a", - ]; - - const submoduleArgs = [ - "submodule", - "update", - "--init", - "--recursive", - ]; - - // TODO: depth support - - return [ - { - command: args.protocolParams.commandPath, - args: fetchArgs, - }, - { - command: args.protocolParams.commandPath, - args: remoteArgs, - }, - { - command: args.protocolParams.commandPath, - args: args.protocolParams.pullArgs, - }, - { - command: args.protocolParams.commandPath, - args: submoduleArgs, - }, - ]; - } else { - const commandArgs = [ - "-c", - "credential.helper=", - "clone", - "--recursive", - ]; - - if (args.protocolParams.partialClone) { - commandArgs.push("--filter=blob:none"); - } - - // TODO: depth support - - commandArgs.push(await this.getUrl(args)); - commandArgs.push(args.plugin.path); - - return [{ - command: args.protocolParams.commandPath, - args: commandArgs, - }]; - } - } - - override params(): Params { - return { - cloneDepth: 0, - commandPath: "git", - defaultHubSite: "github.com", - defaultProtocol: "https", - partialClone: false, - pullArgs: ["pull", "--ff", "--ff-only"], - }; - } -} diff --git a/doc/dpp-ext-installer.txt b/doc/dpp-ext-installer.txt deleted file mode 100644 index 24cb1cb..0000000 --- a/doc/dpp-ext-installer.txt +++ /dev/null @@ -1,74 +0,0 @@ -*dpp-ext-installer.txt* installer ext for dpp.vim - -Author: Shougo -License: MIT license - -CONTENTS *dpp-ext-installer-contents* - -Introduction |dpp-ext-installer-introduction| -Install |dpp-ext-installer-install| -Examples |dpp-ext-installer-examples| -Actions |dpp-ext-installer-actions| -Params |dpp-ext-installer-params| -Compatibility |dpp-ext-installer-compatibility| - - -============================================================================== -INTRODUCTION *dpp-ext-installer-introduction* - -This ext implements installer loading. - - -============================================================================== -INSTALL *dpp-ext-installer-install* - -Please install both "dpp.vim" and "denops.vim". - -https://github.com/Shougo/dpp.vim -https://github.com/vim-denops/denops.vim - -And you need to install protocol like "dpp-protocol-git". - -https://github.com/Shougo/dpp-protocol-git - - -============================================================================== -EXAMPLES *dpp-ext-installer-examples* -> - " Install plugins - call dpp#async_ext_action('installer', 'install') - - " Update plugins - call dpp#async_ext_action('installer', 'update') -< - -============================================================================== -ACTIONS *dpp-ext-installer-actions* - - *dpp-ext-installer-action-install* -install - Install plugins. - - params: - - *dpp-ext-installer-action-recache* -recache - Re-make the dpp runtimepath cache and execute |:helptags|. - It is called automatically after - |dpp-ext-installer-action-install| or - |dpp-ext-installer-action-update|. - - *dpp-ext-installer-action-update* -update - Update plugins. - - params: - -============================================================================== -PARAMS *dpp-ext-installer-params* - -============================================================================== -COMPATIBILITY *dpp-ext-installer-compatibility* - -============================================================================== -vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: diff --git a/doc/dpp-ext-lazy.txt b/doc/dpp-ext-lazy.txt deleted file mode 100644 index dfa1df3..0000000 --- a/doc/dpp-ext-lazy.txt +++ /dev/null @@ -1,54 +0,0 @@ -*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| -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-local.txt b/doc/dpp-ext-local.txt deleted file mode 100644 index b90e1a0..0000000 --- a/doc/dpp-ext-local.txt +++ /dev/null @@ -1,78 +0,0 @@ -*dpp-ext-local.txt* Local ext for dpp.vim - -Author: Shougo -License: MIT license - -CONTENTS *dpp-ext-local-contents* - -Introduction |dpp-ext-local-introduction| -Install |dpp-ext-local-install| -Examples |dpp-ext-local-examples| -Actions |dpp-ext-local-actions| -Params |dpp-ext-local-params| -Compatibility |dpp-ext-local-compatibility| - - -============================================================================== -INTRODUCTION *dpp-ext-local-introduction* - -This ext implements local operations. - - -============================================================================== -INSTALL *dpp-ext-local-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-local-examples* -> - const plugins = await args.dpp.extAction( - args.denops, args.options, "local", "local", { - directory: "~/work", - options: { - frozen: true, - merged: false, - }, - includes: [ - "vim*", - "nvim-*", - "*.vim", - "*.nvim", - "ddc-*", - "dpp-*", - "skkeleton", - "neco-vim", - ], - } - ); -< - -============================================================================== -ACTIONS *dpp-ext-local-actions* - - *dpp-ext-local-action-local* -local - Returns local plugins. - - params: - {directory}: local directory path. - (Required) - {options}: default local plugin's |dpp-options|. - (Default: {}) - {includes}: {includes} directories are only - loaded. - (Default: []) - -============================================================================== -PARAMS *dpp-ext-local-params* - -============================================================================== -COMPATIBILITY *dpp-ext-local-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 deleted file mode 100644 index 03c476d..0000000 --- a/doc/dpp-ext-toml.txt +++ /dev/null @@ -1,75 +0,0 @@ -*dpp-ext-toml.txt* Toml ext for dpp.vim - -Author: Shougo -License: MIT license - -CONTENTS *dpp-ext-toml-contents* - -Introduction |dpp-ext-toml-introduction| -Install |dpp-ext-toml-install| -Examples |dpp-ext-toml-examples| -Functions |dpp-ext-toml-functions| -Actions |dpp-ext-toml-actions| -Params |dpp-ext-toml-params| -Compatibility |dpp-ext-toml-compatibility| - - -============================================================================== -INTRODUCTION *dpp-ext-toml-introduction* - -This ext implements toml loading. - - -============================================================================== -INSTALL *dpp-ext-toml-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-toml-examples* -> - const plugins = await args.dpp.extAction( - args.denops, args.options, "toml", "load", { - path: "$BASE_DIR/dpp.toml", - options: { - lazy: true, - }, - } - ); -< - -============================================================================== -FUNCTIONS *dpp-ext-toml-functions* - - *dpp#ext#toml#syntax()* -dpp#ext#toml#syntax() - Enable dpp specific toml syntax. - It highlights multiline string as "vim" or "lua" syntax. - If you use neovim, you should use treesitter highlight - instead. - -============================================================================== -ACTIONS *dpp-ext-toml-actions* - - *dpp-ext-toml-action-local* -toml - Returns loaded toml plugins. - - params: - {path}: toml file path. - (Required) - {options}: default toml plugin's |dpp-options|. - (Default: {}) - -============================================================================== -PARAMS *dpp-ext-toml-params* - -============================================================================== -COMPATIBILITY *dpp-ext-toml-compatibility* - -============================================================================== -vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: diff --git a/doc/dpp-protocol-git.txt b/doc/dpp-protocol-git.txt deleted file mode 100644 index 9e92b1d..0000000 --- a/doc/dpp-protocol-git.txt +++ /dev/null @@ -1,83 +0,0 @@ -*dpp-protocol-git.txt* git protocol for dpp.vim - -Author: Shougo -License: MIT license - -CONTENTS *dpp-protocol-git-contents* - -Introduction |dpp-protocol-git-introduction| -Install |dpp-protocol-git-install| -Examples |dpp-protocol-git-examples| -Params |dpp-protocol-git-params| -Compatibility |dpp-protocol-git-compatibility| - - -============================================================================== -INTRODUCTION *dpp-protocol-git-introduction* - -This protocol implements git operations. - - -============================================================================== -INSTALL *dpp-protocol-git-install* - -Please install both "dpp.vim" and "denops.vim". - -https://github.com/Shougo/dpp.vim -https://github.com/vim-denops/denops.vim - - -============================================================================== -EXAMPLES *dpp-protocol-git-examples* -> -< - -============================================================================== -PARAMS *dpp-protocol-git-params* - - *dpp-protocol-git-param-cloneDepth* -cloneDepth - The default history depth for "git clone". - If it is 1, dpp will use shallow clone feature. - NOTE: If it is set, |dpp-plugin-option-rev| does not work. - Because the history is not downloaded. - - Default: 0 - - *dpp-protocol-git-param-commandPath* -commandPath - The "git" command path used for git type. - - Default: "git" - - *dpp-protocol-git-param-defaultHubSite* -defaultHubSite - The default hub site used for git type. - - Default: "github.com" - - *dpp-protocol-git-param-defaultProtocol* -defaultProtocol - The default protocol used for git (github). - NOTE: It only accepts "https" or "ssh". - - Default: "https" - - *dpp-protocol-git-param-enablePartialClone* -enablePartialClone - Enable partial clone when plugin install. It is faster. - NOTE: git 2.19+ is required. - - Default: false - - *dpp-protocol-git-param-pullArgs* -pullArgs - The git command args used to pull updates. - - Default: ["pull", "--ff", "--ff-only"] - -============================================================================== -COMPATIBILITY *dpp-protocol-git-compatibility* - -============================================================================== -vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: