diff --git a/README.md b/README.md index aacf4e42..ce4d9c17 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # fzf-preview.vim -fzf-preview is a coc extensions and Neovim plugin that provides collection of features to assist file management using fzf. It provides multiple presets of fzf and correspondingly powerful preview. It also provides advanced interactive git integration. +fzf-preview is a (Neo)vim plugin and coc extensions written by TypeScript that provides powerfully integrates fzf. It provides multiple presets of fzf and correspondingly powerful preview. It also provides advanced interactive git integration. Since fzf-preview.vim implements RPC in the Vim script, it will work in both Vim and Neovim if you use the RPC release. It can also be installed as Remote Plugin and coc extensions. If you want to use the integration with coc, install coc extensions. +[Introductory Article](https://zenn.dev/yano/articles/vim_with_fzf_preview_is_best_experience) (Japanese) + This plugin can be easily extended in comparison to [fzf.vim](https://github.com/junegunn/fzf.vim). e.g. [Fugitive](https://github.com/tpope/vim-fugitive)(launch git commands), bdelete(delete a selected buffer from the buffer list) diff --git a/autoload/fzf_preview/rpc.vim b/autoload/fzf_preview/rpc.vim index 589b0913..4d6e56e3 100644 --- a/autoload/fzf_preview/rpc.vim +++ b/autoload/fzf_preview/rpc.vim @@ -14,7 +14,7 @@ let default_processes = {} call s:Promise.on_unhandled_rejection({ err -> fzf_preview#rpc#log('[ERROR]', err) }) function! fzf_preview#rpc#initialize() abort - call s:server() + call s:start() function! s:initialize_default_processes(response) abort let s:default_processes = a:response @@ -30,7 +30,7 @@ function! fzf_preview#rpc#get_default_processes(name) abort endfunction function! fzf_preview#rpc#command(command, ...) abort - call s:server() + call s:start() if a:0 == 0 call s:state.server.request('execCommand', { 'commandName': a:command }) else @@ -52,7 +52,7 @@ function! fzf_preview#rpc#log(...) abort endif endfunction -function! s:server() abort +function! s:start() abort try if !empty(s:state.server) return s:state.server diff --git a/src/rpc.ts b/src/rpc.ts index faee9b5b..f6bd5e07 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -33,12 +33,15 @@ connection.onRequest(getDefaultProcessesRequest, () => { }) const execCommandRequest = new rpc.RequestType("execCommand") -connection.onRequest(execCommandRequest, ({ commandName, args }) => { - commandDefinition.forEach(async (fzfCommand) => { +connection.onRequest(execCommandRequest, async ({ commandName, args }) => { + for (const fzfCommand of commandDefinition) { if (commandName === fzfCommand.commandName) { + // eslint-disable-next-line no-await-in-loop await executeCommand(args != null ? args : "", fzfCommand) + + return } - }) + } }) const callProcessRequest = new rpc.RequestType("callProcess") @@ -47,14 +50,17 @@ connection.onRequest(callProcessRequest, async ({ lines }) => { }) const execProcessCallbackRequest = new rpc.RequestType("execProcessCallback") -connection.onRequest(execProcessCallbackRequest, ({ processName, lines }) => { - processesDefinition.forEach(({ processes }) => { - processes.forEach(async (process) => { +connection.onRequest(execProcessCallbackRequest, async ({ processName, lines }) => { + for (const { processes } of processesDefinition) { + for (const process of processes) { if (processName === process.name) { + // eslint-disable-next-line no-await-in-loop await executeProcess(lines, process) + + return } - }) - }) + } + } }) setRpcClient(connection)