Repository: yuki-ycino/fzf-preview.vim
Branch: main
Commit: 933836744ad5
Files: 295
Total size: 466.7 KB
Directory structure:
gitextract_mlnhz3k1/
├── .eslintignore
├── .eslintrc.js
├── .github/
│ ├── ISSUE_TEMPLATE.md
│ ├── issue_example/
│ │ └── Dockerfile
│ └── workflows/
│ ├── build.yml
│ ├── can-release.yml
│ ├── release-coc.yml
│ ├── release-remote.yml
│ └── release-rpc.yml
├── .gitignore
├── .luarc.json
├── .markdownlint.json
├── .prettierrc.json
├── LICENSE
├── README.md
├── autoload/
│ ├── fzf_preview/
│ │ ├── remote/
│ │ │ ├── consumer/
│ │ │ │ ├── git.vim
│ │ │ │ └── register.vim
│ │ │ ├── exec_fzf.vim
│ │ │ ├── handler_to_process.vim
│ │ │ ├── mr.vim
│ │ │ ├── process.vim
│ │ │ ├── resource/
│ │ │ │ ├── all_buffers.vim
│ │ │ │ ├── bookmarks.vim
│ │ │ │ ├── buffers.vim
│ │ │ │ ├── changes.vim
│ │ │ │ ├── directory_files.vim
│ │ │ │ ├── git_files.vim
│ │ │ │ ├── git_status.vim
│ │ │ │ ├── grep.vim
│ │ │ │ ├── jumps.vim
│ │ │ │ ├── lines.vim
│ │ │ │ ├── marks.vim
│ │ │ │ ├── memolist.vim
│ │ │ │ ├── project_files.vim
│ │ │ │ ├── quickfix_and_locationlist.vim
│ │ │ │ ├── tags.vim
│ │ │ │ ├── todo_comments.vim
│ │ │ │ ├── util.vim
│ │ │ │ ├── vim_command.vim
│ │ │ │ ├── vim_lsp.vim
│ │ │ │ ├── vista.vim
│ │ │ │ └── yankround.vim
│ │ │ ├── runner.vim
│ │ │ ├── tagstack.vim
│ │ │ ├── util.vim
│ │ │ ├── variable.vim
│ │ │ └── window.vim
│ │ ├── rpc/
│ │ │ └── server.vim
│ │ └── rpc.vim
│ ├── fzf_preview.vim
│ └── vital/
│ ├── _fzf_preview/
│ │ ├── Async/
│ │ │ ├── Later.vim
│ │ │ └── Promise.vim
│ │ └── VS/
│ │ ├── Event/
│ │ │ └── Emitter.vim
│ │ ├── RPC/
│ │ │ └── JSON.vim
│ │ └── System/
│ │ └── Job.vim
│ ├── _fzf_preview.vim
│ ├── fzf_preview.vim
│ └── fzf_preview.vital
├── bin/
│ ├── git_actions_preview
│ ├── git_blame_pr
│ └── preview_yankround_register
├── doc/
│ └── fzf_preview_vim.txt
├── jest.config.ts
├── lua/
│ └── fzf-preview/
│ └── init.lua
├── package.json
├── plugin/
│ └── fzf_preview.vim
├── rplugin/
│ └── node/
│ └── fzf-preview.vim/
│ └── .keep
├── scripts/
│ └── preview.js
├── src/
│ ├── @types/
│ │ └── index.d.ts
│ ├── args/
│ │ ├── add-fzf-arg-parser.test.ts
│ │ ├── add-fzf-arg-parser.ts
│ │ ├── directory-files-args-parser.ts
│ │ ├── empty-source-func-args-parser.ts
│ │ ├── experimental-parser.ts
│ │ ├── files-from-resources-parser.ts
│ │ ├── grep-args-parser.ts
│ │ ├── index.ts
│ │ ├── parser.ts
│ │ ├── processes-parser.test.ts
│ │ ├── processes-parser.ts
│ │ ├── resume-parser.ts
│ │ └── session-parser.ts
│ ├── association/
│ │ ├── coc-command.ts
│ │ ├── command.ts
│ │ └── vim-variable.ts
│ ├── coc.ts
│ ├── connector/
│ │ ├── bookmarks.ts
│ │ ├── buffers.ts
│ │ ├── changes.ts
│ │ ├── coc.ts
│ │ ├── convert-for-fzf.ts
│ │ ├── directory-files.ts
│ │ ├── fzf.ts
│ │ ├── git.ts
│ │ ├── grep.ts
│ │ ├── jumps.ts
│ │ ├── lines.ts
│ │ ├── lsp.ts
│ │ ├── marks.ts
│ │ ├── memolist.ts
│ │ ├── nvim-lsp.ts
│ │ ├── old-files.ts
│ │ ├── open-bufnr.ts
│ │ ├── open-file.ts
│ │ ├── project-files.ts
│ │ ├── quickfix-and-locationlist.ts
│ │ ├── register.ts
│ │ ├── resume.ts
│ │ ├── tags.ts
│ │ ├── todo-comments.ts
│ │ ├── util.ts
│ │ ├── vim-command.ts
│ │ ├── vim-help.ts
│ │ ├── vim-lsp.ts
│ │ ├── vista.ts
│ │ └── yankround.ts
│ ├── const/
│ │ ├── fzf-handler.ts
│ │ ├── fzf-option.ts
│ │ ├── fzf-processes.ts
│ │ ├── fzf-resource.ts
│ │ ├── fzf-runner.ts
│ │ ├── git.ts
│ │ ├── module.ts
│ │ └── system.ts
│ ├── fzf/
│ │ ├── command/
│ │ │ ├── execute-fast.ts
│ │ │ ├── execute-normal.ts
│ │ │ ├── index.ts
│ │ │ └── util.ts
│ │ ├── function/
│ │ │ └── index.ts
│ │ ├── handler/
│ │ │ └── index.ts
│ │ ├── option/
│ │ │ ├── convert.test.ts
│ │ │ ├── convert.ts
│ │ │ ├── generator.test.ts
│ │ │ └── generator.ts
│ │ ├── process/
│ │ │ ├── command-palette.ts
│ │ │ ├── consumer/
│ │ │ │ ├── command-palette.ts
│ │ │ │ ├── git-action.ts
│ │ │ │ ├── git-branch-action.ts
│ │ │ │ ├── git-branch.ts
│ │ │ │ ├── git-log-action.ts
│ │ │ │ ├── git-log.ts
│ │ │ │ ├── git-reflog-action.ts
│ │ │ │ ├── git-reflog.ts
│ │ │ │ ├── git-stash-action.ts
│ │ │ │ ├── git-stash.ts
│ │ │ │ ├── git-status-action.ts
│ │ │ │ ├── git-status.ts
│ │ │ │ ├── git.ts
│ │ │ │ ├── index.ts
│ │ │ │ ├── open-buffer.ts
│ │ │ │ ├── open-bufnr.ts
│ │ │ │ ├── open-file.test.ts
│ │ │ │ ├── open-file.ts
│ │ │ │ ├── open-pr.ts
│ │ │ │ └── register.ts
│ │ │ ├── git-action.ts
│ │ │ ├── git-branch-action.ts
│ │ │ ├── git-branch.ts
│ │ │ ├── git-log-action.ts
│ │ │ ├── git-log.ts
│ │ │ ├── git-reflog-action.ts
│ │ │ ├── git-reflog.ts
│ │ │ ├── git-stash-action.ts
│ │ │ ├── git-stash.ts
│ │ │ ├── git-status-action.ts
│ │ │ ├── git-status.ts
│ │ │ ├── index.ts
│ │ │ ├── open-buffer.ts
│ │ │ ├── open-bufnr.ts
│ │ │ ├── open-file.ts
│ │ │ ├── open-pr.ts
│ │ │ ├── process.ts
│ │ │ └── register.ts
│ │ ├── resource/
│ │ │ ├── all-buffers.ts
│ │ │ ├── blame-pr.ts
│ │ │ ├── bookmarks.ts
│ │ │ ├── buffer-lines.ts
│ │ │ ├── buffer-tags.ts
│ │ │ ├── buffer-vista.ts
│ │ │ ├── buffers.ts
│ │ │ ├── changes.ts
│ │ │ ├── coc/
│ │ │ │ ├── coc-current-diagnostics.ts
│ │ │ │ ├── coc-definitions.ts
│ │ │ │ ├── coc-diagnostics.ts
│ │ │ │ ├── coc-implementations.ts
│ │ │ │ ├── coc-outline.ts
│ │ │ │ ├── coc-references.ts
│ │ │ │ ├── coc-tsserver-source-definition.ts
│ │ │ │ ├── coc-type-definitions.ts
│ │ │ │ └── index.ts
│ │ │ ├── command-palette.ts
│ │ │ ├── ctags.ts
│ │ │ ├── directory-files.ts
│ │ │ ├── files-from-resources.ts
│ │ │ ├── git-actions.ts
│ │ │ ├── git-branch-actions.ts
│ │ │ ├── git-branches.ts
│ │ │ ├── git-files.ts
│ │ │ ├── git-log-actions.ts
│ │ │ ├── git-logs.ts
│ │ │ ├── git-reflog-actions.ts
│ │ │ ├── git-reflogs.ts
│ │ │ ├── git-stash-actions.ts
│ │ │ ├── git-stashes.ts
│ │ │ ├── git-status-actions.ts
│ │ │ ├── git-status.ts
│ │ │ ├── grep.ts
│ │ │ ├── index.ts
│ │ │ ├── jumps.ts
│ │ │ ├── lines.ts
│ │ │ ├── locationlist.ts
│ │ │ ├── marks.ts
│ │ │ ├── memolist-grep.ts
│ │ │ ├── memolist.ts
│ │ │ ├── mru.ts
│ │ │ ├── mrw.ts
│ │ │ ├── nvim-lsp-current-diagnostics.ts
│ │ │ ├── nvim-lsp-definition.ts
│ │ │ ├── nvim-lsp-diagnostics.ts
│ │ │ ├── nvim-lsp-implementation.ts
│ │ │ ├── nvim-lsp-references.ts
│ │ │ ├── nvim-lsp-type-definition.ts
│ │ │ ├── oldfiles.ts
│ │ │ ├── project-files.ts
│ │ │ ├── project-mru.ts
│ │ │ ├── project-mrw.ts
│ │ │ ├── project-oldfiles.ts
│ │ │ ├── quickfix.ts
│ │ │ ├── todo-comments.ts
│ │ │ ├── vim-help.ts
│ │ │ ├── vim-lsp-current-diagnostics.ts
│ │ │ ├── vim-lsp-definition.ts
│ │ │ ├── vim-lsp-diagnostics.ts
│ │ │ ├── vim-lsp-implementation.ts
│ │ │ ├── vim-lsp-references.ts
│ │ │ ├── vim-lsp-type-definition.ts
│ │ │ ├── vista.ts
│ │ │ └── yankround.ts
│ │ ├── syntax/
│ │ │ └── colorize.ts
│ │ └── util.ts
│ ├── module/
│ │ ├── execute-command.ts
│ │ ├── file-path.ts
│ │ ├── git-config.ts
│ │ ├── recall.ts
│ │ ├── resume.ts
│ │ ├── selector/
│ │ │ ├── execute-command.ts
│ │ │ ├── file-path.ts
│ │ │ ├── git-config.ts
│ │ │ ├── recall.ts
│ │ │ ├── resume.ts
│ │ │ ├── session.ts
│ │ │ └── vim-variable.ts
│ │ ├── session.ts
│ │ └── vim-variable.ts
│ ├── plugin/
│ │ ├── fzf-runner.ts
│ │ ├── index.ts
│ │ ├── process-runner.ts
│ │ └── sync-vim-variable.ts
│ ├── register/
│ │ ├── coc/
│ │ │ └── index.ts
│ │ └── remote/
│ │ └── index.ts
│ ├── remote.ts
│ ├── rpc.ts
│ ├── store/
│ │ └── index.ts
│ ├── system/
│ │ ├── command.ts
│ │ ├── file.ts
│ │ ├── mr.ts
│ │ ├── project.ts
│ │ └── tags.ts
│ ├── type/
│ │ ├── args.ts
│ │ ├── command.ts
│ │ ├── connector.ts
│ │ ├── fzf.ts
│ │ ├── git.ts
│ │ ├── index.ts
│ │ ├── lsp.ts
│ │ ├── process.ts
│ │ ├── resource.ts
│ │ ├── rpc.ts
│ │ ├── syntax.ts
│ │ ├── system.ts
│ │ ├── vim-variable.ts
│ │ └── vim.ts
│ └── util/
│ ├── align.test.ts
│ ├── align.ts
│ ├── array.ts
│ ├── type.ts
│ └── uniq-with.ts
├── stylua.toml
├── tsconfig.json
├── tsconfig.webpack-jest.json
├── webpack.coc.ts
├── webpack.common.ts
├── webpack.preview.ts
├── webpack.remote.ts
└── webpack.rpc.ts
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintignore
================================================
.eslintrc.js
================================================
FILE: .eslintrc.js
================================================
module.exports = {
parser: "@typescript-eslint/parser",
extends: [
"airbnb-base",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:eslint-comments/recommended",
"plugin:n/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"prettier",
],
plugins: ["@typescript-eslint", "import", "simple-import-sort"],
parserOptions: {
sourceType: "module",
project: "./tsconfig.json",
ecmaVersion: 2020,
},
settings: {
"import/resolver": {
typescript: {},
},
"import/parsers": {
"@typescript-eslint/parser": [".ts"],
},
},
rules: {
complexity: ["error", 7],
"no-console": "off",
"no-else-return": "off",
"object-shorthand": "error",
"arrow-body-style": "off",
"no-restricted-syntax": "off",
"no-param-reassign": [
"error",
{
props: true,
ignorePropertyModificationsFor: ["draft", "state"],
},
],
"padding-line-between-statements": [
"error",
{
blankLine: "always",
prev: "*",
next: "return",
},
],
"no-return-await": "off",
"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",
"no-restricted-imports": ["error", { patterns: ["./", "../"] }],
"import/prefer-default-export": "off",
"import/extensions": ["error", "ignorePackages", { ts: "never" }],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"@typescript-eslint/strict-boolean-expressions": "error",
"@typescript-eslint/array-type": ["error", { default: "generic" }],
"@typescript-eslint/prefer-optional-chain": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
"eslint-comments/no-unused-disable": "error",
"n/no-unsupported-features/es-syntax": "off",
"n/no-missing-import": "off",
},
overrides: [
{
files: ["**/*.test.ts"],
extends: ["plugin:jest/recommended", "plugin:jest/style"],
plugins: ["jest"],
env: {
jest: true,
},
rules: {
"@typescript-eslint/no-empty-function": "off",
},
},
{
parserOptions: {
sourceType: "module",
project: "./tsconfig.webpack-jest.json",
},
files: ["./webpack.*.ts", "./jest.config.ts"],
rules: {
"import/no-extraneous-dependencies": ["error", { devDependencies: true }],
"no-restricted-imports": "off",
},
},
],
}
================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
## Problems summary
### Expected
### Environment Information
- fzf-preview version (package.json):
- OS:
- Vim/Neovim version:
### Provide a minimal init.vim
```vim
" call plug#begin('~/.vim/plugged')
" Plug 'junegunn/fzf'
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Plug 'ryanoasis/vim-devicons'
" call plug#end()
"
" let g:coc_global_extensions = ['coc-fzf-preview']
```
### Screenshot
### Dockerfile that reproduces the problem (if possible)
Refer to https://github.com/yuki-yano/fzf-preview.vim/blob/main/.github/issue_example/Dockerfile
```Dockerfile
```
================================================
FILE: .github/issue_example/Dockerfile
================================================
FROM ubuntu:focal
ENV DEBIAN_FRONTEND=noninteractive
# Neovim
RUN apt update && apt install -y ninja-build gettext libtool libtool-bin autoconf automake cmake g++ pkg-config unzip git
WORKDIR /usr/local/src
RUN git clone https://github.com/neovim/neovim.git
WORKDIR /usr/local/src/neovim
RUN make && make install
# zsh
RUN apt install -y zsh
# Node
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt install -y nodejs
# Python
RUN apt install -y python python3 python3-pip
# RUN pip3 install neovim
# bat & ripgrep
# RUN apt install -y bat
# RUN apt install -y ripgrep
# Workaround for https://github.com/sharkdp/bat/issues/938
RUN apt install -y -o Dpkg::Options::="--force-overwrite" bat ripgrep
# fd
RUN apt install -y fd-find
# vim plugin
RUN sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
RUN mkdir -p /root/.config/nvim
RUN echo "call plug#begin('~/.vim/plugged') \n\
Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'} \n\
Plug 'neoclide/coc.nvim', {'branch': 'release'} \n\
call plug#end() \n\
\n\
let g:coc_global_extensions = ['coc-fzf-preview'] \n" >> /root/.config/nvim/init.vim
RUN nvim -c "PlugInstall" -c "qa!"
RUN nvim -c "CocInstall -sync coc-fzf-preview" -c "qa!"
ENTRYPOINT ["nvim"]
================================================
FILE: .github/workflows/build.yml
================================================
name: Build
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
- run: yarn install --ignore-script --frozen-lockfile
- run: yarn run typecheck
- run: yarn run lint
- run: yarn run prettier
- run: yarn run test
- run: yarn run release-build:remote
- run: yarn run release-build:coc
- run: yarn run release-build:rpc
- id: check-release
run: |
if [[ $(git show --no-patch --format=%s) =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo ::set-output name=IS_RELEASE::true
fi
- if: steps.check-release.outputs.IS_RELEASE == 'true'
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
event-type: can-release
================================================
FILE: .github/workflows/can-release.yml
================================================
name: Can release
on:
repository_dispatch:
types:
- can-release
jobs:
can_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
- run: yarn install --ignore-script --frozen-lockfile
- run: yarn run can-npm-publish
================================================
FILE: .github/workflows/release-coc.yml
================================================
name: Release coc extensions
on:
workflow_run:
workflows:
- Can release
branches:
- main
types:
- completed
jobs:
release:
name: Release coc extensions
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main
- uses: actions/setup-node@v1
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: yarn install --ignore-script --frozen-lockfile
- run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- run: yarn run release-build:coc
- run: yarn run build:preview-script
- run: |
TAG="v$(yarn run --silent print-version)"
git tag $TAG
git push origin $TAG
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
================================================
FILE: .github/workflows/release-remote.yml
================================================
name: Release remote plugin
on:
workflow_run:
workflows:
- Can release
branches:
- main
types:
- completed
jobs:
release:
name: Release remote plugin
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 16
- run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- run: git checkout release/remote
- run: git merge main
- run: yarn install --ignore-script --frozen-lockfile
- run: yarn run release-build:remote
- run: yarn run build:preview-script
- run: git add --all
- run: git commit -m "Release $(yarn run --silent print-version)" --allow-empty
- run: git push origin release/remote
================================================
FILE: .github/workflows/release-rpc.yml
================================================
name: Release Vim script RPC
on:
workflow_run:
workflows:
- Can release
branches:
- main
types:
- completed
jobs:
release:
name: Release Vim script RPC
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 16
- run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- run: git checkout release/rpc
- run: git merge main
- run: yarn install --ignore-script --frozen-lockfile
- run: yarn run release-build:rpc
- run: yarn run build:preview-script
- run: git add --all
- run: git commit -m "Release $(yarn run --silent print-version)" --allow-empty
- run: git push origin release/rpc
================================================
FILE: .gitignore
================================================
/node_modules
/lib
/rplugin/node/fzf-preview.vim/index.js
/bin/preview_fzf_grep
/doc/tags
================================================
FILE: .luarc.json
================================================
{
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
"Lua.diagnostics.disable": [
"undefined-global"
],
"Lua.diagnostics.globals": [
"vim"
]
}
================================================
FILE: .markdownlint.json
================================================
{
"line-length": false,
"no-inline-html": false,
"no-duplicate-header": false,
"commands-show-output": false
}
================================================
FILE: .prettierrc.json
================================================
{
"semi": false,
"printWidth": 120
}
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2018 Yuki Yano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# 
[](https://github.com/yuki-yano/fzf-preview.vim/actions?query=workflow:Build)
[](https://github.com/yuki-yano/fzf-preview.vim/actions?query=workflow:"Release+Vim+script+RPC")
[](https://github.com/yuki-yano/fzf-preview.vim/actions?query=workflow:%22Release+remote+plugin%22)
[](https://github.com/yuki-yano/fzf-preview.vim/actions?query=workflow:%22Release+coc+extensions%22)
[](https://www.vim.org)
[](https://neovim.io)
[](https://www.typescriptlang.org)
[](https://www.vim.org)
[](https://eslint.org)
[](https://prettier.io)
[](https://jestjs.io/)
[](https://github.com/junegunn/fzf)
[](https://github.com/neoclide/coc.nvim)
[](https://github.com/hrsh7th/vim-vital-vs)
[](https://github.com/yuki-yano/fzf-preview.vim/blob/main/LICENSE)
[](https://github.com/yuki-yano/fzf-preview.vim/blob/main/doc/fzf_preview_vim.txt)
[](https://github.com/yuki-yano/fzf-preview.vim/graphs/contributors)
fzf-preview is a (Neo)vim plugin and coc extension written in TypeScript that provide powerful integration with fzf. It provides multiple presets for fzf and correspondingly powerful preview functionality. 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)
## TOC
- [1. Features](#features)
- [2. Demo](#demo)
- [3. Requirements](#requirements)
- [4. Installation](#installation)
- [5. Usage](#usage)
- [6. Customization](#customization)
- [7. Release note](#release-note)
- [8. Others](#others)
- [9. License](#license)
## Features
1. Provides an excellent UI with floating windows by default
2. Supports devicons and output highlighting by default
3. Preview the selected item (with an arbitrary command)
4. Fast file and buffer search by fuzzy matching
5. Search all project files and history
6. Search from file history files using oldfiles and mru
7. Interactive git integration (with [Fugitive](https://github.com/tpope/vim-fugitive) or [Gina](https://github.com/lambdalisue/gina.vim))
8. Jump lines from jumplist or changelist
9. Interactive grep and preview from the current project
10. Export the selected items to QuickFix.
## Demo
### Open file and :bdelete

### Interactive git integration (Integrate with [Fugitive](https://github.com/tpope/vim-fugitive) or [Gina](https://github.com/lambdalisue/gina.vim))

### Grep

### Export quickfix and refactor (with [vim-qfreplace](https://github.com/thinca/vim-qfreplace))

## Requirements
- **Node**
- git
- fzf
### Remote Plugin
- Neovim
### coc extensions
- coc.nvim
### Optional
#### Functional
- **ripgrep (Require FzfPreviewProjectGrep and FzfPreviewDirectoryFiles)** (Recommended)
- **Fugitive (Require git integration)** (Recommended)
- Gina (Require git integration)
- universal-ctags (Require FzfPreviewCtags and FzfPreviewBufferTags)
- vista.vim (Require FzfPreviewVistaCtags and FzfPreviewVistaBufferCtags)
- vim-bookmarks (Require FzfPreviewBookmarks)
- yankround.vim (Require FzfPreviewYankround)
- memolist.vim (Require FzfPreviewMemoList and FzfPreviewMemoListGrep)
- todo-comments.nvim (Require FzfPreviewTodoComments)
- GitHub cli (Require FzfPreviewBlamePR)
- Yarn (Require build latest version)
#### Appearance
When bat is installed you can highlight the preview and see it. Otherwise, head will be used
- **bat (Add color to the preview)** (Recommended)
- vim-devicons (Use devicons)
## Installation
### Vim script RPC
Use [Dein](https://github.com/Shougo/dein.vim), [vim-plug](https://github.com/junegunn/vim-plug) or any Vim plugin manager of your choice.
Install `release/rpc` branch.
```vim
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'yuki-yano/fzf-preview.vim', { 'branch': 'release/rpc' }
```
or
```vim
call dein#add('junegunn/fzf', { 'build': './install --all', 'merged': 0 })
call dein#add('yuki-yano/fzf-preview.vim', { 'rev': 'release/rpc' })
```
### Remote Plugin
Install the npm package [neovim](https://www.npmjs.com/package/neovim) to get the remote plugin working.
```shell
$ npm install -g neovim
```
Use [Dein](https://github.com/Shougo/dein.vim), [vim-plug](https://github.com/junegunn/vim-plug) or any Vim plugin manager of your choice.
Install `release/remote` branch and execute `:UpdateRemotePlugins` when after installed plugin.
```vim
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'yuki-yano/fzf-preview.vim', { 'branch': 'release/remote', 'do': ':UpdateRemotePlugins' }
```
or
```vim
call dein#add('junegunn/fzf', { 'build': './install --all', 'merged': 0 })
call dein#add('yuki-yano/fzf-preview.vim', { 'rev': 'release/remote' })
```
### coc extensions
Install the [fzf](https://github.com/junegunn/fzf), [coc.nvim](https://github.com/neoclide/coc.nvim) and install coc-fzf-preview
```vim
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
```
```vim
call dein#add('junegunn/fzf', { 'build': './install --all', 'merged': 0 })
call dein#add('neoclide/coc.nvim', { 'rev': 'release', 'merged': 0 })
```
and
```vim
:CocInstall coc-fzf-preview
```
## Usage
### Command
Vim script RPC, Remote Plugin, and coc extensions, in that order.
```vim
" Select project files
:FzfPreviewProjectFilesRpc
:FzfPreviewProjectFiles
:CocCommand fzf-preview.ProjectFiles
" Select file from git ls-files
:FzfPreviewGitFilesRpc
:FzfPreviewGitFiles
:CocCommand fzf-preview.GitFiles
" Select file from directory files (default to current working directory) (Required [ripgrep](https://github.com/BurntSushi/ripgrep))
:FzfPreviewDirectoryFilesRpc {path or none}
:FzfPreviewDirectoryFiles {path or none}
:CocCommand fzf-preview.DirectoryFiles
" Select file buffers. Used open-buffer processes.
:FzfPreviewBuffersRpc
:FzfPreviewBuffers
:CocCommand fzf-preview.Buffers
" Select all buffers. Used open-bufnr processes
:FzfPreviewAllBuffersRpc
:FzfPreviewAllBuffers
:CocCommand fzf-preview.AllBuffers
" Select project files from oldfiles
:FzfPreviewProjectOldFilesRpc
:CocCommand fzf-preview.ProjectOldFiles
" Select project mru (Most Recently Used) files
:FzfPreviewProjectMruFilesRpc
:FzfPreviewProjectMruFiles
:CocCommand fzf-preview.ProjectMruFiles
" Select project mrw (Most Recently Written) files
:FzfPreviewProjectMrwFilesRpc
:FzfPreviewProjectMrwFiles
:CocCommand fzf-preview.ProjectMrwFiles
" Grep project files from args word
:FzfPreviewProjectGrepRpc {args}
:FzfPreviewProjectGrep {args}
:CocCommand fzf-preview.ProjectGrep {args}
" Run FzfPreviewProjectGrep with the same arguments as before.
:FzfPreviewProjectGrepRecallRpc
:FzfPreviewProjectGrepRecall
:CocCommand fzf-preview.ProjectGrepRecall
" Select tags from tags file (Required [universal-ctags](https://github.com/universal-ctags/ctags))
:FzfPreviewCtagsRpc
:FzfPreviewCtags
:CocCommand fzf-preview.Ctags
" Select tags from current files (Required [universal-ctags](https://github.com/universal-ctags/ctags))
:FzfPreviewBufferTagsRpc
:FzfPreviewBufferTags
:CocCommand fzf-preview.BufferTags
" Select files from oldfiles
:FzfPreviewOldFilesRpc
:FzfPreviewOldFiles
:CocCommand fzf-preview.OldFiles
" Select mru (Most Recently Used) files
:FzfPreviewMruFilesRpc
:FzfPreviewMruFiles
:CocCommand fzf-preview.MruFiles
" Select mrw (Most Recently Written) files
:FzfPreviewMrwFilesRpc
:FzfPreviewMrwFiles
:CocCommand fzf-preview.MrwFiles
" Select line from QuickFix
:FzfPreviewQuickFixRpc
:FzfPreviewQuickFix
:CocCommand fzf-preview.QuickFix
" Select line from LocationList
:FzfPreviewLocationListRpc
:FzfPreviewLocationList
:CocCommand fzf-preview.LocationList
" Select line from current buffer (Required [bat](https://github.com/sharkdp/bat))
:FzfPreviewLinesRpc
:FzfPreviewLines
:CocCommand fzf-preview.Lines
" Select line from loaded buffer
:FzfPreviewBufferLinesRpc
:FzfPreviewBufferLines
:CocCommand fzf-preview.BufferLines
" Select jumplist item
:FzfPreviewJumpsRpc
:FzfPreviewJumps
:CocCommand fzf-preview.Jumps
" Select changelist item
:FzfPreviewChangesRpc
:FzfPreviewChanges
:CocCommand fzf-preview.Changes
" Select mark
:FzfPreviewMarksRpc
:CocCommand fzf-preview.Marks
" Select files from selected resources (project, git, directory, buffer, project_old, project_mru, project_mrw, old, mru, mrw)
:FzfPreviewFromResourcesRpc
:FzfPreviewFromResources
:CocCommand fzf-preview.FromResources
" Execute and edit command history
:FzfPreviewCommandPaletteRpc
:FzfPreviewCommandPalette
:CocCommand fzf-preview.CommandPalette
# Grep vim help
:FzfPreviewGrepHelpRpc
:FzfPreviewGrepHelp
:CocCommand fzf-preview.GrepHelp
" Interactive git integration. (Required [Fugitive](https://github.com/tpope/vim-fugitive) or [Gina](https://github.com/lambdalisue/gina.vim))
:FzfPreviewGitActionsRpc
:FzfPreviewGitActions
:CocCommand fzf-preview.GitActions
" Select git status listed file. (Required [Fugitive](https://github.com/tpope/vim-fugitive) or [Gina](https://github.com/lambdalisue/gina.vim))
:FzfPreviewGitStatusRpc
:FzfPreviewGitStatus
:CocCommand fzf-preview.GitStatus
" Select references from nvim-lsp
:FzfPreviewNvimLspReferencesRpc
:FzfPreviewNvimLspReferences
" Select diagnostics from nvim-lsp
:FzfPreviewNvimLspDiagnosticsRpc
:FzfPreviewNvimLspDiagnostics
" Select current file diagnostics from nvim-lsp
:FzfPreviewNvimLspCurrentDiagnosticsRpc
:FzfPreviewNvimLspCurrentDiagnostics
" Select definitions from nvim-lsp
:FzfPreviewNvimLspDefinitionRpc
:FzfPreviewNvimLspDefinition
" Select type definitions from nvim-lsp
:FzfPreviewNvimLspTypeDefinitionRpc
:FzfPreviewNvimLspTypeDefinition
" Select implementations from nvim-lsp
:FzfPreviewNvimLspImplementationsRpc
:FzfPreviewNvimLspImplementations
" Select references from vim-lsp
:FzfPreviewVimLspReferencesRpc
:FzfPreviewVimLspReferences
" Select diagnostics from vim-lsp
:FzfPreviewVimLspDiagnosticsRpc
:FzfPreviewVimLspDiagnostics
" Select current file diagnostics from vim-lsp
:FzfPreviewVimLspCurrentDiagnosticsRpc
:FzfPreviewVimLspCurrentDiagnostics
" Select definitions from vim-lsp
:FzfPreviewVimLspDefinitionRpc
:FzfPreviewVimLspDefinition
" Select type definitions from vim-lsp
:FzfPreviewVimLspTypeDefinitionRpc
:FzfPreviewVimLspTypeDefinition
" Select implementations from vim-lsp
:FzfPreviewVimLspImplementationsRpc
:FzfPreviewVimLspImplementations
" Select tags from vista.vim (Required [vista.vim](https://github.com/liuchengxu/vista.vim))
:FzfPreviewVistaCtagsRpc
:FzfPreviewVistaCtags
:CocCommand fzf-preview.VistaCtags
" Select current buffer tags from vista.vim (Required [vista.vim](https://github.com/liuchengxu/vista.vim))
:FzfPreviewVistaBufferCtagsRpc
:FzfPreviewVistaBufferCtags
:CocCommand fzf-preview.VistaBufferCtags
" Select bookmarks (Required [vim-bookmarks](https://github.com/MattesGroeger/vim-bookmarks))
:FzfPreviewBookmarksRpc
:FzfPreviewBookmarks
:CocCommand fzf-preview.Bookmarks
" Select register history (Required [yankround.vim](https://github.com/LeafCage/yankround.vim))
:FzfPreviewYankroundRpc
:FzfPreviewYankround
:CocCommand fzf-preview.Yankround
" Select memolist (Required [glidenote/memolist.vim](https://github.com/glidenote/memolist.vim))
:FzfPreviewMemoListRpc
:FzfPreviewMemoList
:CocCommand fzf-preview.MemoList
" Grep memolist (Required [glidenote/memolist.vim](https://github.com/glidenote/memolist.vim))
:FzfPreviewMemoListGrepRpc
:FzfPreviewMemoListGrep
:CocCommand fzf-preview.MemoListGrep
" Search TodoComments (Required [folke/todo-comments.nvim](https://github.com/folke/todo-comments.nvim))
:FzfPreviewTodoCommentsRpc
:FzfPreviewTodoComments
:CocCommand fzf-preview.TodoComments
" Open the PR corresponding to the selected line (Required [GitHub cli](https://github.com/cli/cli))
:FzfPreviewBlamePRRpc
:FzfPreviewBlamePR
:CocCommand fzf-preview.BlamePR
" Select references from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocReferences
" Select diagnostics from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocDiagnostics
" Select current file diagnostics from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocCurrentDiagnostics
" Select definitions from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocDefinition
" Select type definitions from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocTypeDefinition
" Select implementations from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocImplementations
" Select outline from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocOutline
```
### Recommended mappings
#### Vim script RPC
```vim
nmap f [fzf-p]
xmap f [fzf-p]
nnoremap [fzf-p]p :FzfPreviewFromResourcesRpc project_mru git
nnoremap [fzf-p]gs :FzfPreviewGitStatusRpc
nnoremap [fzf-p]ga :FzfPreviewGitActionsRpc
nnoremap [fzf-p]b :FzfPreviewBuffersRpc
nnoremap [fzf-p]B :FzfPreviewAllBuffersRpc
nnoremap [fzf-p]o :FzfPreviewFromResourcesRpc buffer project_mru
nnoremap [fzf-p] :FzfPreviewJumpsRpc
nnoremap [fzf-p]g; :FzfPreviewChangesRpc
nnoremap [fzf-p]/ :FzfPreviewLinesRpc --add-fzf-arg=--no-sort --add-fzf-arg=--query="'"
nnoremap [fzf-p]* :FzfPreviewLinesRpc --add-fzf-arg=--no-sort --add-fzf-arg=--query="'=expand('')"
nnoremap [fzf-p]gr :FzfPreviewProjectGrepRpc
xnoremap [fzf-p]gr "sy:FzfPreviewProjectGrepRpc-F"=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')"
nnoremap [fzf-p]t :FzfPreviewBufferTagsRpc
nnoremap [fzf-p]q :FzfPreviewQuickFixRpc
nnoremap [fzf-p]l :FzfPreviewLocationListRpc
```
#### Remote Plugin
```vim
nmap f [fzf-p]
xmap f [fzf-p]
nnoremap [fzf-p]p :FzfPreviewFromResources project_mru git
nnoremap [fzf-p]gs :FzfPreviewGitStatus
nnoremap [fzf-p]ga :FzfPreviewGitActions
nnoremap [fzf-p]b :FzfPreviewBuffers
nnoremap [fzf-p]B :FzfPreviewAllBuffers
nnoremap [fzf-p]o :FzfPreviewFromResources buffer project_mru
nnoremap [fzf-p] :FzfPreviewJumps
nnoremap [fzf-p]g; :FzfPreviewChanges
nnoremap [fzf-p]/ :FzfPreviewLines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'"
nnoremap [fzf-p]* :FzfPreviewLines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'=expand('')"
nnoremap [fzf-p]gr :FzfPreviewProjectGrep
xnoremap [fzf-p]gr "sy:FzfPreviewProjectGrep-F"=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')"
nnoremap [fzf-p]t :FzfPreviewBufferTags
nnoremap [fzf-p]q :FzfPreviewQuickFix
nnoremap [fzf-p]l :FzfPreviewLocationList
```
#### coc extensions
```vim
nmap f [fzf-p]
xmap f [fzf-p]
nnoremap [fzf-p]p :CocCommand fzf-preview.FromResources project_mru git
nnoremap [fzf-p]gs :CocCommand fzf-preview.GitStatus
nnoremap [fzf-p]ga :CocCommand fzf-preview.GitActions
nnoremap [fzf-p]b :CocCommand fzf-preview.Buffers
nnoremap [fzf-p]B :CocCommand fzf-preview.AllBuffers
nnoremap [fzf-p]o :CocCommand fzf-preview.FromResources buffer project_mru
nnoremap [fzf-p] :CocCommand fzf-preview.Jumps
nnoremap [fzf-p]g; :CocCommand fzf-preview.Changes
nnoremap [fzf-p]/ :CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'"
nnoremap [fzf-p]* :CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'=expand('')"
nnoremap [fzf-p]gr :CocCommand fzf-preview.ProjectGrep
xnoremap [fzf-p]gr "sy:CocCommand fzf-preview.ProjectGrep-F"=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')"
nnoremap [fzf-p]t :CocCommand fzf-preview.BufferTags
nnoremap [fzf-p]q :CocCommand fzf-preview.QuickFix
nnoremap [fzf-p]l :CocCommand fzf-preview.LocationList
```
### Base Fzf window Keymaps
```text
,
Cancel fzf
Open split
Open vsplit
Open tabedit
Jump to buffer if already open. See :drop.
If g:fzf_preview_buffers_jump is set to 1 then it will open the buffer in
current window instead.
Build QuickFix in open-file processes.
Execute :bdelete! command from open-buffer and open-bufnr processes.
Preview page down
Preview page up
?
Toggle display of preview screen
```
## Customization
### Optional Configuration Tips
- Increase the size of file history:
```vim
" oldfiles uses viminfo, but the default setting is 100
" Change the number by setting it in viminfo with a single quote.
" Ref: viminfo-'
set viminfo='1000
```
- Set values for each variable. The default settings are as follows.
```vim
" floating window size ratio
let g:fzf_preview_floating_window_rate = 0.9
" fzf window position settings
let g:fzf_preview_direct_window_option = ''
" fzf command default options
let g:fzf_preview_default_fzf_options = { '--reverse': v:true, '--preview-window': 'wrap' }
" Add fzf quit mapping
let g:fzf_preview_quit_map = 1
" jump to the buffers by default, when possible
let g:fzf_preview_buffers_jump = 0
" Commands used for fzf preview.
" The file name selected by fzf becomes {}
let g:fzf_preview_command = 'cat' " Not installed bat
" let g:fzf_preview_command = 'bat --color=always --plain {-1}' " Installed bat
" g:fzf_binary_preview_command is executed if this command succeeds, and g:fzf_preview_command is executed if it fails
let g:fzf_preview_if_binary_command = '[[ "$(file --mime {})" =~ binary ]]'
" Commands used for binary file
let g:fzf_binary_preview_command = 'echo "{} is a binary file"'
" Commands used to get the file list from project
let g:fzf_preview_filelist_command = 'git ls-files --exclude-standard' " Not Installed ripgrep
" let g:fzf_preview_filelist_command = 'rg --files --hidden --follow --no-messages -g \!"* *"' " Installed ripgrep
" Commands used to get the file list from git repository
let g:fzf_preview_git_files_command = 'git ls-files --exclude-standard'
" Commands used to get the file list from current directory
let g:fzf_preview_directory_files_command = 'rg --files --hidden --follow --no-messages -g \!"* *"'
" Commands used to get the git status file list
let g:fzf_preview_git_status_command = 'git -c color.status=always status --short --untracked-files=all'
" Commands used for git status preview.
let g:fzf_preview_git_status_preview_command = "[[ $(git diff --cached -- {-1}) != \"\" ]] && git diff --cached --color=always -- {-1} || " .
\ "[[ $(git diff -- {-1}) != \"\" ]] && git diff --color=always -- {-1} || " .
\ g:fzf_preview_command
" Commands used for project grep
let g:fzf_preview_grep_cmd = 'rg --line-number --no-heading --color=never --hidden'
" MRU and MRW cache directory
let g:fzf_preview_cache_directory = expand('~/.cache/vim/fzf_preview')
" If this value is not 0, disable mru and mrw
let g:fzf_preview_disable_mru = 0
" Limit of the number of files to be saved by mru
let g:fzf_preview_mru_limit = 1000
" Commands used for current file lines
let g:fzf_preview_lines_command = 'cat -n' " Not Installed bat
" let g:fzf_preview_lines_command = 'bat --color=always --plain --number' " Installed bat
" Commands used for preview of the grep result
let g:fzf_preview_grep_preview_cmd = expand(':h:h') . '/bin/preview_fzf_grep'
" Cache directory for mru and mrw
let g:fzf_preview_cache_directory = expand('~/.cache/vim/fzf_preview')
" Keyboard shortcuts while fzf preview is active
let g:fzf_preview_preview_key_bindings = ''
" let g:fzf_preview_preview_key_bindings = 'ctrl-d:preview-page-down,ctrl-u:preview-page-up,?:toggle-preview'
" Specify the color of fzf
let g:fzf_preview_fzf_color_option = ''
" Set the processes when selecting an element with fzf
let g:fzf_preview_custom_processes = {}
" For example, set split to ctrl-s
" let g:fzf_preview_custom_processes['open-file'] = fzf_preview#remote#process#get_default_processes('open-file')
" on coc extensions
" let g:fzf_preview_custom_processes['open-file'] = fzf_preview#remote#process#get_default_processes('open-file', 'coc')
" let g:fzf_preview_custom_processes['open-file']['ctrl-s'] = g:fzf_preview_custom_processes['open-file']['ctrl-x']
" call remove(g:fzf_preview_custom_processes['open-file'], 'ctrl-x')
" Use as fzf preview-window option
let g:fzf_preview_fzf_preview_window_option = ''
" let g:fzf_preview_fzf_preview_window_option = 'up:30%'
" Use vim-devicons
let g:fzf_preview_use_dev_icons = 0
" Use fzf history option
let g:fzf_preview_history_dir = false
" let g:fzf_preview_history_dir = '~/.fzf'
" devicons character width
let g:fzf_preview_dev_icon_prefix_string_length = 3
" Devicons can make fzf-preview slow when the number of results is high
" By default icons are disable when number of results is higher that 5000
let g:fzf_preview_dev_icons_limit = 5000
" The theme used in the bat preview
$FZF_PREVIEW_PREVIEW_BAT_THEME = 'OneHalfDark'
```
### Command Options
Commented-out lines are settings for the coc extension.
```vim
--processes
" Set process when selecting element with fzf started by this command.
" Value must be a global variable name.
" Variable is dictionary and format is same as g:fzf_preview_custom_processes['open-file'].
"
" Most commands are passed a file path to the process function.
" FzfPreviewAllBuffers will be passed “buffer {bufnr}”
"
" Value example: let g:foo_processes = {
" \ '': 'FzfPreviewOpenFileEnter',
" \ 'ctrl-x': get(function('s:foo_function'), 'name'),
" \ }
"
--add-fzf-arg
" Set the arguments to be passed when executing fzf.
" This value is added to the default options.
" Value must be a string without spaces.
" Example: Exclude filename with FzfPreviewProjectGrep
nnoremap g :FzfPreviewProjectGrep --add-fzf-arg=--nth=3
" nnoremap g :CocCommand fzf-preview.ProjectGrep --add-fzf-arg=--nth=3
--resume
" Reuse the input that was last used to select the element with fzf.
" Do not need to pass a value for this option.
" Example: Reuse last query for project grep.
nnoremap G :FzfPreviewProjectGrep . --resume
" nnoremap G :CocCommand fzf-preview.ProjectGrep . --resume
```
### Function
```vim
" Get the initial value of the open file processes
" processes_name is 'open-file', 'open-buffer' and 'open-bufnr'.
" plugin_type is 'remote', 'coc' or 'rpc'. Default value is 'remote'
call fzf_preview#remote#process#get_default_processes({processes_name}, {plugin_type})
```
## Release note
Changes history
- 2023/01/02 version 2.16.0
- Implement nvim-lsp resources.
- 2021/12/05 version 2.12.0
- Implement vim-lsp resources.
- 2022/08/23 version 2.13.0
- Implement coc TypeScript go to source definition resource.
- 2021/12/05 version 2.12.0
- Implement vim-lsp resources.
- 2021/10/15 version 2.9.0
- Implement coc outline resource.
- 2021/09/10 version 2.7.0
- Implement vim help resource.
- 2021/09/08 version 2.6.0
- Improve project files performance
- 2021/06/06 version 2.5.0
- Implement --experimental-fast option.
- 2021/06/04 version 2.4.0
- Implement [todo-comments.nvim](https://github.com/folke/todo-comments.nvim) resource.
- 2021/05/19 version 2.3.0
- Implement fzf history option.
- 2021/05/18 version 2.2.0
- Implement grep recall.
- 2021/01/16 version 2.0.7
- Implement coc implementations resource.
- 2021/01/16 version 2.0.6
- Implement [memolist.vim](https://github.com/glidenote/memolist.vim) resource.
- 2021/01/10 version 2.0.0
- Release of stable version.
- Change release from github actions.
- Update latest npm packages.
- 2021/01/06 version 0.6.0
- Update coc.nvim package version to 0.0.80.
- 2020/12/31 version 0.5.0
- Implement Vim script RPC
- Only need Vim and Node
- **Breaking change**: The release branch of the Remote Plugin has been changed to release/remote.
- 2020/11/08 version 0.4.27
- Add g:fzf_preview_direct_window_option option.
- 2020/11/07 version 0.4.26
- Change buffer sort with mru order.
- Add mru and mrw limit settings.
- Improve grep preview highlight.
- 2020/10/30 version 0.4.24
- Improved grep etc previews to scroll to the top of the file.
- 2020/10/4 version 0.4.20
- Implement CommandPalette resource.
- 2020/10/4 version 0.4.17
- Implement CocTypeDefinitions resource.
- 2020/07/30 version 0.4.7
- Implement git reflog integration.
- 2020/07/30 version 0.4.6
- Implement git stash integration.
- Implement rename git branch.
- 2020/07/27 version 0.4.1
- Implement create git branch.
- 2020/07/27 version 0.4.0
- Implement interactive git integration. (`:FzfPreviewGitActions` and `:CocCommand fzf-preview.GitActions`)
- 2020/07/24 version 0.3.2
- Remove g:fzf_preview_filelist_postprocess_command and to colorize the fzf window by default
- 2020/07/24 version 0.2.1
- Change g:fzf_preview_default_fzf_options and g:fzf_preview_fzf_preview_window_option default value.
- Fix export quickfix bug in grep.
- 2020/07/23 version 0.2.0
- Improving the internal data structure.
- Remove `FzfPreviewProjectCommandGrep` command. (Changes to the data structure have made implementation difficult)
- Some bug fixes.
## Others
- How to use fish user?
- Set the `set shell` and `$SHELL`.
```vim
set shell=/bin/zsh
let $SHELL = "/bin/zsh"
```
- Use true color preview in Neovim
- Set the preview command to `COLORTERM=truecolor`
```vim
augroup fzf_preview
autocmd!
autocmd User fzf_preview#rpc#initialized call s:fzf_preview_settings() " fzf_preview#remote#initialized or fzf_preview#coc#initialized
augroup END
function! s:fzf_preview_settings() abort
let g:fzf_preview_command = 'COLORTERM=truecolor ' . g:fzf_preview_command
let g:fzf_preview_grep_preview_cmd = 'COLORTERM=truecolor ' . g:fzf_preview_grep_preview_cmd
endfunction
```
- `FzfPreviewVistaBufferCtags` does not work
- Vista must be initialized. Run the Vista command once or write the following settings.
```vim
autocmd VimEnter * call vista#RunForNearestMethodOrFunction()
```
## License
The MIT License (MIT)
================================================
FILE: autoload/fzf_preview/remote/consumer/git.vim
================================================
" using pseudo synchronous call in Vim8 because Vim8 asynchronous call is unstable
function! s:execute(command) abort
if !has('nvim')
call feedkeys(':' . a:command . "\n", 'n')
else
execute a:command
endif
endfunction
function! fzf_preview#remote#consumer#git#add(file) abort
call system('git add ' . shellescape(a:file))
if v:shell_error
echomsg 'Failed: git add ' . a:file
endif
endfunction
function! fzf_preview#remote#consumer#git#add_intent_to_add(file) abort
call system('git add --intent-to-add ' . shellescape(a:file))
if v:shell_error
echomsg 'Failed: git add --intent-to-add ' . a:file
endif
endfunction
function! fzf_preview#remote#consumer#git#reset(file, option) abort
if a:option !=# ''
let command = 'git reset ' . a:option . ' ' . shellescape(a:file)
else
let command = 'git reset ' . shellescape(a:file)
endif
call system(command)
if v:shell_error
echomsg 'Failed: ' . command
endif
endfunction
function! fzf_preview#remote#consumer#git#reset_intent_to_add(file) abort
call system('git reset --intent-to-add ' . shellescape(a:file))
if v:shell_error
echomsg 'Failed: git reset --intent-to-add ' . a:file
endif
endfunction
function! fzf_preview#remote#consumer#git#patch(file) abort
if exists(':Gin') == 2
tabedit
call s:execute('GinPatch ' . fnamemodify(a:file, ':p'))
return
elseif exists(':Gina') == 2
call s:execute('Gina patch ' . fnamemodify(a:file, ':p'))
return
elseif exists(':Git') != 0
execute 'tabedit ' . a:file . ' | Git diff'
return
endif
echoerr 'Gin, Gina and Fugitive not installed'
endfunction
function! fzf_preview#remote#consumer#git#chaperon(file) abort
if exists(':Gin') == 2
tabedit
call s:execute('GinChaperon ' . fnamemodify(a:file, ':p'))
return
elseif exists(':Gina') == 2
call s:execute('Gina chaperon ' . fnamemodify(a:file, ':p'))
return
endif
echoerr 'Gin and Gina not installed'
endfunction
function! fzf_preview#remote#consumer#git#commit(option) abort
if match(a:option, '--fixup') != -1
echomsg system('git commit ' . a:option)
return
elseif exists(':Gin') == 2
call s:execute('Gin commit --verbose ' . a:option)
return
elseif exists(':Gina') == 2
call s:execute('Gina commit --verbose ' . a:option)
return
elseif exists(':Git') == 2
execute 'Git commit --verbose ' . a:option
return
endif
echoerr 'Gin, Gina and Fugitive not installed'
endfunction
function! fzf_preview#remote#consumer#git#restore(file) abort
if exists(':Gin') == 2
call s:execute('Gin checkout -- ' . fnamemodify(a:file, ':p'))
return
elseif exists(':Gina') == 2
call s:execute('Gina checkout -- ' . fnamemodify(a:file, ':p'))
return
elseif exists(':Git') == 2
execute 'Git checkout -- ' . a:file
return
else
call system('git checkout -- ' . shellescape(a:file))
if v:shell_error
echomsg 'Failed: git checkout -- ' . a:file
endif
endif
endfunction
function! fzf_preview#remote#consumer#git#switch(branch) abort
if exists(':Gin') == 2
call s:execute('Gin checkout ' . a:branch)
return
elseif exists(':Gina') == 2
call s:execute('Gina checkout ' . a:branch)
return
elseif exists(':Git') == 2
execute 'Git checkout ' . a:branch
return
else
call system('git checkout ' . shellescape(a:branch))
if v:shell_error
echomsg 'Failed: git checkout ' . a:branch
endif
endif
endfunction
function! fzf_preview#remote#consumer#git#create_branch() abort
let branch_name = input('Branch name: ')
if branch_name !=# ''
echomsg system('git checkout -b ' . shellescape(branch_name))
endif
endfunction
function! fzf_preview#remote#consumer#git#diff(branch, ...) abort
let branch2 = get(a:, 1, '')
if exists(':Gin') == 2
execute 'silent GinDiff ' . a:branch . '..' . branch2
echomsg 'git diff ' . a:branch . '..' . branch2
return
elseif exists(':Gina') == 2
execute 'silent Gina diff ' . a:branch . '..' . branch2
echomsg 'git diff ' . a:branch . '..' . branch2
return
elseif exists(':Git') == 2
execute 'silent Git diff ' . a:branch . '..' . branch2
echomsg 'git diff ' . a:branch . '..' . branch2
return
endif
echoerr 'Gin, Gina and Fugitive not installed'
endfunction
function! fzf_preview#remote#consumer#git#show(name_or_hash) abort
" TODO: Until GinShow is implemented in gin, gina is the priority
if exists(':Gina') == 2
call s:execute('Gina show ' . a:name_or_hash)
return
elseif exists(':Gin') == 2
call s:execute('GinBuffer show ' . a:name_or_hash)
return
elseif exists(':Git') == 2
execute 'Git show ' . a:name_or_hash
return
endif
echoerr 'Gin, Gina and Fugitive not installed'
endfunction
function! fzf_preview#remote#consumer#git#merge(branch, option) abort
if exists(':Gin') == 2
call s:execute('Gin merge ' . a:option . ' ' . a:branch)
return
elseif exists(':Gina') == 2
call s:execute('Gina merge ' . a:option . ' ' . a:branch)
return
elseif exists(':Git') == 2
execute 'Git merge ' . a:option . ' ' . a:branch
return
endif
echoerr 'Gin, Gina and Fugitive not installed'
endfunction
function! fzf_preview#remote#consumer#git#rebase(branch) abort
if exists(':Gin') == 2
call s:execute('Gin rebase ' . a:branch)
return
elseif exists(':Gina') == 2
call s:execute('Gina rebase ' . a:branch)
return
elseif exists(':Git') == 2
execute 'Git rebase ' . a:branch
return
endif
echoerr 'Fugitive and Gina not installed'
endfunction
function! fzf_preview#remote#consumer#git#rebase_interactive(branch_or_hash) abort
if exists(':Gin') == 2
execute 'Gin rebase --interactive ' . a:branch_or_hash
return
elseif exists(':Git') == 2
execute 'Git rebase --interactive ' . a:branch_or_hash
return
endif
echoerr 'Gin and Fugitive not installed'
endfunction
function! fzf_preview#remote#consumer#git#push(option) abort
echomsg system('git push ' . a:option)
if v:shell_error
echomsg 'Failed: git push ' . a:option
endif
endfunction
function! fzf_preview#remote#consumer#git#fetch() abort
echomsg system('git fetch')
if v:shell_error
echomsg 'Failed: git fetch'
endif
endfunction
function! fzf_preview#remote#consumer#git#delete_branch(branch, option) abort
echomsg system('git branch --delete ' . a:option . ' ' . shellescape(a:branch))
if v:shell_error
echomsg 'Failed: git branch --delete ' . a:option . ' ' . a:branch
endif
endfunction
function! fzf_preview#remote#consumer#git#rename_branch(src) abort
let dest = input('Branch name: ')
if dest !=# ''
let command = 'git branch -m ' . shellescape(a:src) . ' ' . dest
echo system(command)
if v:shell_error
echomsg 'Failed: ' . command
endif
endif
endfunction
function! fzf_preview#remote#consumer#git#stash_apply(stash) abort
let command = 'git stash apply ' . shellescape(a:stash)
echo system(command)
if v:shell_error
echomsg 'Failed: ' . command
endif
endfunction
function! fzf_preview#remote#consumer#git#stash_pop(stash) abort
let command = 'git stash pop ' . shellescape(a:stash)
echo system(command)
if v:shell_error
echomsg 'Failed: ' . command
endif
endfunction
function! fzf_preview#remote#consumer#git#stash_drop(stash) abort
let command = 'git stash drop ' . shellescape(a:stash)
echo system(command)
if v:shell_error
echomsg 'Failed: ' . command
endif
endfunction
function! fzf_preview#remote#consumer#git#stash_create() abort
let message = input('Message: ')
if message !=# ''
let command = 'git stash save "' . message . '"'
else
let command = 'git stash save'
endif
echo system(command)
if v:shell_error
echomsg 'Failed: ' . command
endif
endfunction
function! fzf_preview#remote#consumer#git#pull() abort
echomsg system('git pull')
if v:shell_error
echomsg 'Failed: git pull'
endif
endfunction
function! fzf_preview#remote#consumer#git#yank(branch) abort
let hash = system('git rev-parse ' . shellescape(a:branch))
call fzf_preview#remote#consumer#register#set(hash, 'v')
echomsg 'yanked ' a:branch . ' branch hash: ' . hash
endfunction
================================================
FILE: autoload/fzf_preview/remote/consumer/register.vim
================================================
function! fzf_preview#remote#consumer#register#set(str, options) abort
call setreg('"', a:str, a:options)
endfunction
function! fzf_preview#remote#consumer#register#paste(str, options) abort
call setreg('"', a:str, a:options)
normal! ""p
endfunction
================================================
FILE: autoload/fzf_preview/remote/exec_fzf.vim
================================================
function! fzf_preview#remote#exec_fzf#exec(command, env, ...) abort
let session_token = get(a:, 1, '')
if a:env ==# 'remote'
if session_token !=# ''
execute a:command . ' --session=' . session_token
else
execute a:command
endif
elseif a:env ==# 'coc'
let command_name = substitute(a:command, '^FzfPreview', 'fzf-preview.', '')
if session_token !=# ''
execute 'CocCommand ' . command_name . ' --session=' . session_token
else
execute 'CocCommand ' . command_name
endif
elseif a:env ==# 'rpc'
if session_token !=# ''
execute a:command . 'Rpc --session=' . session_token
else
execute a:command . 'Rpc'
endif
endif
endfunction
================================================
FILE: autoload/fzf_preview/remote/handler_to_process.vim
================================================
function! fzf_preview#remote#handler_to_process#call_funcref_or_fallback_default_process(env, default_process_function_name, expect_key, lines, process_name) abort
if a:env ==# 'remote'
call s:call_remote_plugin(a:default_process_function_name, a:expect_key, a:lines, a:process_name)
elseif a:env ==# 'coc'
call s:call_coc(a:default_process_function_name, a:expect_key, a:lines, a:process_name)
elseif a:env ==# 'rpc'
call s:call_rpc(a:default_process_function_name, a:expect_key, a:lines, a:process_name)
endif
endfunction
function! s:call_remote_plugin(default_process_function_name, expect_key, lines, process_name) abort
if (a:process_name == v:null)
call call(a:default_process_function_name, [a:lines])
else
let processes = eval('g:' . a:process_name)
let Process = processes[a:expect_key]
if type(Process) == v:t_string
if exists('*' . Process)
call call(Process, [a:lines])
else
call fzf_preview#rpc#exec_process_callback(Process, a:lines)
endif
elseif type(Process) == v:t_func
call Process(a:lines)
endif
endif
endfunction
function! s:call_coc(default_process_function_name, expect_key, lines, process_name) abort
if (a:process_name == v:null)
let process_name = substitute(a:default_process_function_name, '^FzfPreview', '', '')
call CocAction('runCommand', 'fzf-preview-callback.' . process_name, [a:lines])
else
let processes = eval('g:' . a:process_name)
let Process = processes[a:expect_key]
if type(Process) == v:t_string
let Process = substitute(Process, '^FzfPreview', '', '')
if exists('*' . Process)
call call(Process, [a:lines])
else
call CocAction('runCommand', 'fzf-preview-callback.' . Process, [a:lines])
endif
elseif type(Process) == v:t_func
call Process(a:lines)
endif
endif
endfunction
function! s:call_rpc(default_process_function_name, expect_key, lines, process_name) abort
if (a:process_name == v:null)
call fzf_preview#rpc#exec_process_callback(a:default_process_function_name, a:lines)
else
let processes = eval('g:' . a:process_name)
let Process = processes[a:expect_key]
if type(Process) == v:t_string
if exists('*' . Process)
call call(Process, [a:lines])
else
call fzf_preview#rpc#exec_process_callback(Process, a:lines)
endif
elseif type(Process) == v:t_func
call Process(a:lines)
endif
endif
endfunction
================================================
FILE: autoload/fzf_preview/remote/mr.vim
================================================
function! fzf_preview#remote#mr#append(path, cache_path) abort
let files = s:get_files_with_create_directory(a:cache_path)
call insert(files, a:path)
call writefile(fzf_preview#remote#util#uniq(files)[:g:fzf_preview_mru_limit - 1], a:cache_path)
endfunction
function! fzf_preview#remote#mr#mru_file_path() abort
return g:fzf_preview_cache_directory . '/mru'
endfunction
function! fzf_preview#remote#mr#mrw_file_path() abort
return g:fzf_preview_cache_directory . '/mrw'
endfunction
function! s:get_files_with_create_directory(cache_path) abort
if !isdirectory(g:fzf_preview_cache_directory)
call mkdir(g:fzf_preview_cache_directory, 'p')
endif
try
let files = readfile(a:cache_path)
catch
let files = []
endtry
return files
endfunction
================================================
FILE: autoload/fzf_preview/remote/process.vim
================================================
function! fzf_preview#remote#process#get_default_processes(name, ...) abort
let env = get(a:, 1, 'remote')
if env ==# 'remote'
return FzfPreviewGetDefaultProcesses(a:name)
elseif env ==# 'coc'
return CocAction('runCommand', 'fzf-preview.GetDefaultProcesses', [a:name])
elseif env ==# 'rpc'
return fzf_preview#rpc#get_default_processes(a:name)
endif
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/all_buffers.vim
================================================
function! fzf_preview#remote#resource#all_buffers#get() abort
let buffers = []
for bufinfo in copy(getbufinfo())
let buffer = {
\ 'name': fnamemodify(bufinfo['name'], ':.'),
\ 'bufnr': bufinfo['bufnr'],
\ }
call add(buffers, buffer)
endfor
let buffers = map(copy(getbufinfo({ 'buflisted': 1 })),
\ { _, buffer -> {
\ 'fileName': fnamemodify(buffer['name'], ':.'),
\ 'bufnr': buffer['bufnr'],
\ 'isCurrent': v:false,
\ 'isAlternate': v:false,
\ 'isModified': v:false,
\ }
\ }
\ )
return buffers
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/bookmarks.vim
================================================
function! fzf_preview#remote#resource#bookmarks#get() abort
return filter(map(bm#location_list(), {
\ _, b -> s:bookmarks_format_line(b)
\ }), {
\ _, b -> b.file !=# ''
\ })
endfunction
function! s:bookmarks_format_line(line) abort
let line = split(a:line, ':')
let filename = fnamemodify(line[0], ':.')
if !filereadable(filename)
return { 'file': '' }
endif
let line_number = line[1]
let text = line[2]
if text ==# 'Annotation'
let comment = line[3]
else
let text = join(line[2:], ':')
endif
if text !=# 'Annotation'
return { 'file': filename, 'line': line_number, 'text': text, 'comment': '' }
else
return { 'file': filename, 'line': line_number, 'text': text, 'comment': comment }
endif
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/buffers.vim
================================================
function! fzf_preview#remote#resource#buffers#get_other_buffers() abort
let list = filter(range(1, bufnr('$')),
\ { _, bufnr -> bufexists(bufnr) && buflisted(bufnr) && filereadable(expand('#' . bufnr . ':p')) && bufnr != bufnr('%') && bufnr != bufnr('#')}
\ )
return map(list, { _, bufnr -> s:bufnr_to_bufinfo(bufnr) })
endfunction
function! fzf_preview#remote#resource#buffers#get_current_buffer() abort
return s:bufnr_to_bufinfo(bufnr('%'))
endfunction
function! fzf_preview#remote#resource#buffers#get_alternate_buffer() abort
return s:bufnr_to_bufinfo(bufnr('#'))
endfunction
function! fzf_preview#remote#resource#buffers#get() abort
let list = filter(range(1, bufnr('$')),
\ { _, bufnr -> bufexists(bufnr) && buflisted(bufnr) && filereadable(expand('#' . bufnr . ':p'))}
\ )
return map(list, { _, bufnr -> s:bufnr_to_bufinfo(bufnr) })
endfunction
function! s:bufnr_to_bufinfo(bufnr) abort
let name = bufname(a:bufnr)
let is_current = a:bufnr == bufnr('%')
let is_alternate = a:bufnr == bufnr('#')
let is_modified = getbufvar(a:bufnr, '&modified')
return {
\ 'fileName': name,
\ 'bufnr': a:bufnr,
\ 'isCurrent': is_current == 1 ? v:true : v:false,
\ 'isAlternate': is_alternate == 1 ? v:true : v:false,
\ 'isModified': is_modified == 1 ? v:true : v:false,
\ }
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/changes.vim
================================================
function! fzf_preview#remote#resource#changes#get() abort
if !filereadable(expand('%'))
return []
endif
let list = []
let lnums = map(copy(getchangelist('%')[0]), { _, change -> change['lnum'] })
for lnum in lnums
let lines = getbufline(bufnr('%'), lnum)
if len(lines) > 0
call add(list, lnum . ' ' . lines[0])
endif
endfor
call reverse(list)
let list = fzf_preview#remote#util#uniq(list)
return list
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/directory_files.vim
================================================
function! fzf_preview#remote#resource#directory_files#get(command) abort
return systemlist(a:command)
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/git_files.vim
================================================
function! fzf_preview#remote#resource#git_files#get(command) abort
return systemlist(a:command)
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/git_status.vim
================================================
function! fzf_preview#remote#resource#git_status#get(command) abort
return systemlist(a:command)
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/grep.vim
================================================
function! fzf_preview#remote#resource#grep#get(command) abort
return systemlist(a:command)
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/jumps.vim
================================================
function! fzf_preview#remote#resource#jumps#get() abort
let splitted_project_path = split(fzf_preview#remote#util#project_root(), '/')
let bufnr_and_lnum_list = map(copy(getjumplist()[0]), {
\ _, jump -> { 'bufnr': jump['bufnr'], 'lnum': jump['lnum'] }
\ })
let result = fzf_preview#remote#util#bufnr_and_lnum_to_resource(bufnr_and_lnum_list, splitted_project_path)
call reverse(result)
return result
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/lines.vim
================================================
function! fzf_preview#remote#resource#lines#get(command) abort
return systemlist(a:command)
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/marks.vim
================================================
function! fzf_preview#remote#resource#marks#get() abort
let splitted_project_path = split(fzf_preview#remote#util#project_root(), '/')
let chars = [
\ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
\ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
\ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
\ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
\ ]
let bufnr_and_lnum_list = map(map(copy(chars), {
\ _, char -> getpos("'" . char)
\ }), {
\ _, pos -> { 'bufnr': pos[0] == 0 ? bufnr('%') : pos[0], 'lnum': pos[1] }
\ })
call filter(bufnr_and_lnum_list, { _, bufnr_and_lnum -> bufnr_and_lnum['lnum'] != 0 })
let result = fzf_preview#remote#util#bufnr_and_lnum_to_resource(bufnr_and_lnum_list, splitted_project_path)
return result
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/memolist.vim
================================================
function! fzf_preview#remote#resource#memolist#files() abort
return memolist#files()
endfunction
function! fzf_preview#remote#resource#memolist#grep(command) abort
return systemlist(a:command. ' ' . g:memolist_path)
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/project_files.vim
================================================
function! fzf_preview#remote#resource#project_files#get(command) abort
return systemlist(a:command)
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/quickfix_and_locationlist.vim
================================================
function! fzf_preview#remote#resource#quickfix_and_locationlist#get(type) abort
let lines = s:get_quickfix_or_locationlist_lines(a:type)
if !empty(filter(lines, { _, line -> line !=# '' }))
return lines
else
return []
endif
endfunction
function! s:get_quickfix_or_locationlist_lines(type) abort
let qf_or_loc_lists = s:get_quickfix_or_loclist(a:type)
if len(qf_or_loc_lists) != 0
return len(qf_or_loc_lists) > 0 ? getbufline(qf_or_loc_lists[0]['bufnr'], 1, '$') : []
endif
return s:open_process_with_qf_and_close(a:type, { type -> s:get_quickfix_or_locationlist_lines(type) })
endfunction
function! s:get_quickfix_or_loclist(type) abort
return filter(getwininfo(), { _, w -> w['tabnr'] == tabpagenr() && getwinvar(w['winnr'], '&filetype') ==# 'qf' && w[a:type]})
endfunction
function! s:open_process_with_qf_and_close(type, F) abort
let winid = win_getid()
if a:type ==# 'quickfix'
copen
elseif a:type ==# 'loclist'
try
lopen
catch
return []
endtry
else
return []
endif
call win_gotoid(winid)
let result = a:F(a:type)
if a:type ==# 'quickfix'
cclose
elseif a:type ==# 'loclist'
lclose
endif
return result
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/tags.vim
================================================
function! fzf_preview#remote#resource#tags#ctags() abort
return s:read_tag_file()
endfunction
function! s:read_tag_file() abort
let lines = []
let files = filter(s:get_tag_files(), { _, file -> filereadable(file) })
for file in files
let lines = lines + filter(readfile(file), { _, line -> match(line, '^!') == -1 })
endfor
call map(lines, { _, line -> s:parse_tagline(line) })
return lines
endfunction
function! s:get_tag_files() abort
return split(&tags, ',')
endfunction
function! s:parse_tagline(line) abort
let elem = split(a:line, '\t')
let file_path = fnamemodify(elem[1], ':.')
let match = matchlist(elem[2], '^\(\d\+\);"')
try
let info = {
\ 'name': elem[0],
\ 'file': file_path,
\ 'line': match[1],
\ 'type': elem[3],
\ }
catch
throw 'Set excmd=number or excmd=combine in universal-ctags options'
endtry
return info
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/todo_comments.vim
================================================
function! fzf_preview#remote#resource#todo_comments#get() abort
lua vim.g.fzf_preview_todo_keywords = vim.fn.keys((require('todo-comments.config').keywords))
return g:fzf_preview_todo_keywords
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/util.vim
================================================
function! fzf_preview#remote#resource#util#exec_command(command) abort
return systemlist(a:command)
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/vim_command.vim
================================================
function! fzf_preview#remote#resource#vim_command#commands() abort
return map(getcompletion('', 'command'), {_, command -> {
\ 'name': command,
\ 'number': v:null,
\ }})
endfunction
function! fzf_preview#remote#resource#vim_command#history() abort
let commands = filter(map(range(1, max([0, histnr(':')])), {_, index -> histget(':', index)}), {_, command -> command !=# ''})
return map(reverse(commands), {index, command -> {
\ 'name': command,
\ 'number': index + 1,
\ }})
endfunction
function! fzf_preview#remote#resource#vim_command#exec(command) abort
echo a:command
execute a:command
endfunction
function! fzf_preview#remote#resource#vim_command#edit(command) abort
call histadd(':', a:command)
redraw
call feedkeys(":\", 'n')
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/vim_lsp.vim
================================================
let s:references = {}
let s:definition = {}
let s:type_definition = {}
let s:implementation = {}
function! fzf_preview#remote#resource#vim_lsp#servers(method) abort
return filter(lsp#get_allowed_servers(), 'lsp#capabilities#has_' . a:method . '_provider(v:val)')
endfunction
function! fzf_preview#remote#resource#vim_lsp#request_references(servers) abort
let s:references = {}
let command_id = lsp#_new_command()
let ctx = {
\ 'counter': len(a:servers),
\ 'list':[],
\ 'last_command_id': command_id,
\ 'mods': '',
\ 'in_preview': 0,
\ 'jump_if_one': 0,
\ }
let params = {
\ 'textDocument': lsp#get_text_document_identifier(),
\ 'position': lsp#get_position(),
\ 'context': {'includeDeclaration': v:false},
\ }
for server in a:servers
call lsp#send_request(server, {
\ 'method': 'textDocument/references',
\ 'params': params,
\ 'on_notification': function('s:handle_references', [ctx, server, 'references']),
\ })
endfor
endfunction
function! fzf_preview#remote#resource#vim_lsp#request_definition(servers) abort
let s:definition = {}
let command_id = lsp#_new_command()
let ctx = {
\ 'counter': len(a:servers),
\ 'list':[],
\ 'last_command_id': command_id,
\ 'mods': '',
\ 'in_preview': 0,
\ 'jump_if_one': 0,
\ }
let params = {
\ 'textDocument': lsp#get_text_document_identifier(),
\ 'position': lsp#get_position(),
\ }
for server in a:servers
call lsp#send_request(server, {
\ 'method': 'textDocument/definition',
\ 'params': params,
\ 'on_notification': function('s:handle_definition', [ctx, server, 'definition']),
\ })
endfor
endfunction
function! fzf_preview#remote#resource#vim_lsp#request_type_definition(servers) abort
let s:type_definition = {}
let command_id = lsp#_new_command()
let ctx = {
\ 'counter': len(a:servers),
\ 'list':[],
\ 'last_command_id': command_id,
\ 'mods': '',
\ 'in_preview': 0,
\ 'jump_if_one': 0,
\ }
let params = {
\ 'textDocument': lsp#get_text_document_identifier(),
\ 'position': lsp#get_position(),
\ }
for server in a:servers
call lsp#send_request(server, {
\ 'method': 'textDocument/typeDefinition',
\ 'params': params,
\ 'on_notification': function('s:handle_type_definition', [ctx, server, 'typeDefinition']),
\ })
endfor
endfunction
function! fzf_preview#remote#resource#vim_lsp#request_implementation(servers) abort
let s:implementation = {}
let command_id = lsp#_new_command()
let ctx = {
\ 'counter': len(a:servers),
\ 'list':[],
\ 'last_command_id': command_id,
\ 'mods': '',
\ 'in_preview': 0,
\ 'jump_if_one': 0,
\ }
let params = {
\ 'textDocument': lsp#get_text_document_identifier(),
\ 'position': lsp#get_position(),
\ }
for server in a:servers
call lsp#send_request(server, {
\ 'method': 'textDocument/implementation',
\ 'params': params,
\ 'on_notification': function('s:handle_implementation', [ctx, server, 'implementation']),
\ })
endfor
endfunction
function! fzf_preview#remote#resource#vim_lsp#fetch_references() abort
return s:references
endfunction
function! fzf_preview#remote#resource#vim_lsp#fetch_definition() abort
return s:definition
endfunction
function! fzf_preview#remote#resource#vim_lsp#fetch_type_definition() abort
return s:type_definition
endfunction
function! fzf_preview#remote#resource#vim_lsp#fetch_implementation() abort
return s:implementation
endfunction
function! s:handle_references(ctx, server, type, data) abort
let s:references[a:data['server_name']] = a:data['response']['result']
endfunction
function! s:handle_definition(ctx, server, type, data) abort
let s:definition[a:data['server_name']] = a:data['response']['result']
endfunction
function! s:handle_type_definition(ctx, server, type, data) abort
let s:type_definition[a:data['server_name']] = a:data['response']['result']
endfunction
function! s:handle_implementation(ctx, server, type, data) abort
let s:implementation[a:data['server_name']] = a:data['response']['result']
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/vista.vim
================================================
function! fzf_preview#remote#resource#vista#ctags() abort
let result = vista#executive#ctags#ProjectRun()
let keys = keys(result)
let source = []
let index = 0
while index < len(keys)
let kind = keys[index]
let values = result[kind]
for value in values
call add(source, { 'lineNumber': value['lnum'], 'kind': kind, 'text': value['text'], 'tagFile': value['tagfile'] })
endfor
let index = index + 1
endwhile
return source
endfunction
function! fzf_preview#remote#resource#vista#buffer_ctags() abort
let result = vista#executive#ctags#Run(expand('%:p'))
let keys = keys(result)
let source = []
let index = 0
while index < len(keys)
let kind = keys[index]
let values = result[kind]
for value in values
call add(source, { 'lineNumber': value['lnum'], 'kind': kind, 'text': value['text'], 'line': getline(value['lnum']) })
endfor
let index = index + 1
endwhile
return source
endfunction
================================================
FILE: autoload/fzf_preview/remote/resource/yankround.vim
================================================
function! fzf_preview#remote#resource#yankround#get() abort
let histories = map(copy(g:_yankround_cache), 'split(v:val, "\t", 1)')
return map(histories, { key, val -> { 'line': key + 1, 'option': val[0], 'text': get(val, 1) } })
endfunction
================================================
FILE: autoload/fzf_preview/remote/runner.vim
================================================
function! fzf_preview#remote#runner#fzf_run(params) abort
let source = a:params['source']
let options = a:params['options']
let handler = a:params['handler']
let env = a:params['environment']
if env ==# 'remote'
let Sink = function('s:handler_wrapper', [handler])
elseif env ==# 'coc'
let Sink = function('s:coc_handler')
elseif env ==# 'rpc'
let Sink = function('fzf_preview#rpc#rpc_handler')
endif
let window = !empty(g:fzf_preview_direct_window_option) ?
\ g:fzf_preview_direct_window_option :
\ { 'width': g:fzf_preview_floating_window_rate, 'height': g:fzf_preview_floating_window_rate }
call feedkeys("\nohlsearch\", 'nit')
call fzf#run({
\ 'source': source,
\ 'sink*': Sink,
\ 'options': options,
\ 'window': window,
\ })
endfunction
function! s:handler_wrapper(handler, lines) abort
call feedkeys('', 'x')
call call(a:handler, [a:lines])
endfunction
function! s:coc_handler(lines) abort
call feedkeys('', 'x')
call CocAction('runCommand', 'fzf-preview.HandleResource', [a:lines])
endfunction
================================================
FILE: autoload/fzf_preview/remote/tagstack.vim
================================================
function! fzf_preview#remote#tagstack#push_tag_stack() abort
let from = [bufnr('%'), line('.'), col('.'), 0]
let tagname = expand('')
let winid = win_getid()
call settagstack(winid, {'items': [{'from': from, 'tagname': tagname}]}, 'a')
call settagstack(winid, {'curidx': len(gettagstack(winid)['items']) + 1})
endfunction
================================================
FILE: autoload/fzf_preview/remote/util.vim
================================================
function! fzf_preview#remote#util#is_git_directory() abort
let git_root = system('git rev-parse --show-toplevel 2>/dev/null')
if git_root ==# ''
return v:false
else
return v:true
endif
endfunction
function! fzf_preview#remote#util#project_root() abort
let git_root = system('git rev-parse --show-toplevel 2>/dev/null')
if git_root ==# ''
echomsg 'The current directory is not a git project'
return ''
endif
return strpart(git_root, 0, strlen(git_root) - 1)
endfunction
function! fzf_preview#remote#util#is_project_file(file, splitted_project_path) abort
let splitted_file_path = split(a:file, '/')
if len(splitted_file_path) == 0
return 0
endif
let is_project_file = 1
let index = 0
for dir_name in a:splitted_project_path[:len(splitted_file_path) - 1]
if dir_name !=# splitted_file_path[index]
let is_project_file = 0
endif
let index = index + 1
endfor
return is_project_file
endfunction
function! fzf_preview#remote#util#bufnr_and_lnum_to_resource(bufnr_and_lnum_list, splitted_project_path) abort
let result = []
for bufnr_and_lnum in a:bufnr_and_lnum_list
let bufnr = bufnr_and_lnum['bufnr']
let lnum = bufnr_and_lnum['lnum']
let bufinfos = getbufinfo(bufnr)
if len(bufinfos) > 0
let bufinfo = bufinfos[0]
let file = bufinfo['name']
if fzf_preview#remote#util#is_project_file(file, a:splitted_project_path) && filereadable(file)
let file = fnamemodify(file, ':.')
let line_number = lnum
let lines = getbufline(bufname(bufnr), lnum)
if len(lines) > 0
let text = lines[0]
else
let text = ''
endif
call add(result, { 'file': file, 'line': line_number, 'text': text })
endif
endif
endfor
return result
endfunction
function! fzf_preview#remote#util#get_columns() abort
return &columns
endfunction
function! fzf_preview#remote#util#uniq(list) abort
let result = []
for item in a:list
if index(result, item) == -1
call add(result, item)
endif
endfor
return result
endfunction
================================================
FILE: autoload/fzf_preview/remote/variable.vim
================================================
function! fzf_preview#remote#variable#get_global_variables() abort
return {
\ 'fzfPreviewDefaultFzfOptions': g:fzf_preview_default_fzf_options,
\ 'fzfPreviewUseDevIcons': g:fzf_preview_use_dev_icons,
\ 'fzfPreviewDevIconPrefixStringLength': g:fzf_preview_dev_icon_prefix_string_length,
\ 'fzfPreviewDevIconsLimit': g:fzf_preview_dev_icons_limit,
\ 'webDevIconsUnicodeDecorateFileNodesDefaultSymbol': get(g:, 'WebDevIconsUnicodeDecorateFileNodesDefaultSymbol', ''),
\ 'webDevIconsUnicodeDecorateFileNodesExtensionSymbols': get(g:, 'WebDevIconsUnicodeDecorateFileNodesExtensionSymbols', {}),
\ 'webDevIconsUnicodeDecorateFileNodesExactSymbols': get(g:, 'WebDevIconsUnicodeDecorateFileNodesExactSymbols', {}),
\ 'webDevIconsUnicodeDecorateFileNodesPatternSymbols': get(g:, 'WebDevIconsUnicodeDecorateFileNodesPatternSymbols', {}),
\ 'fzfPreviewCommand': g:fzf_preview_command,
\ 'fzfBinaryPreviewCommand': g:fzf_binary_preview_command,
\ 'fzfPreviewIfBinaryCommand': g:fzf_preview_if_binary_command,
\ 'fzfPreviewFilelistCommand': g:fzf_preview_filelist_command,
\ 'fzfPreviewGitFilesCommand': g:fzf_preview_git_files_command,
\ 'fzfPreviewDirectoryFilesCommand': g:fzf_preview_directory_files_command,
\ 'fzfPreviewGitStatusCommand': g:fzf_preview_git_status_command,
\ 'fzfPreviewGitStatusPreviewCommand': g:fzf_preview_git_status_preview_command,
\ 'fzfPreviewGrepCmd': g:fzf_preview_grep_cmd,
\ 'fzfPreviewScriptDir': g:fzf_preview_script_dir,
\ 'fzfPreviewCacheDirectory': g:fzf_preview_cache_directory,
\ 'fzfPreviewLinesCommand': g:fzf_preview_lines_command,
\ 'fzfPreviewGrepPreviewCmd': g:fzf_preview_grep_preview_cmd,
\ 'fzfPreviewCustomProcesses': g:fzf_preview_custom_processes,
\ 'fzfPreviewFzfPreviewWindowOption': g:fzf_preview_fzf_preview_window_option,
\ 'fzfPreviewPreviewKeyBindings': g:fzf_preview_preview_key_bindings,
\ 'fzfPreviewHistoryDir': g:fzf_preview_history_dir,
\ 'fzfPreviewFzfColorOption': g:fzf_preview_fzf_color_option,
\ 'fzfPreviewBuffersJump': g:fzf_preview_buffers_jump,
\ 'yankroundDir': get(g:, 'yankround_dir', ''),
\ 'fzfPreviewYankroundPreviewCommand': g:fzf_preview_yankround_preview_command,
\ 'fzfPreviewBlamePrCommand': g:fzf_preview_blame_pr_command,
\ }
endfunction
================================================
FILE: autoload/fzf_preview/remote/window.vim
================================================
" TODO: Command other than fzf-preview saves wrong resumes
let s:resource_command_name = ''
function! fzf_preview#remote#window#set_resource_command_name(command_name) abort
if s:resource_command_name !=# a:command_name
let s:resource_command_name = a:command_name
endif
call timer_start(10, { -> fzf_preview#remote#window#set_status_line(v:true) })
endfunction
function! fzf_preview#remote#window#get_resource_command_name() abort
return substitute(s:resource_command_name, '^FzfPreview', '', '')
endfunction
function! fzf_preview#remote#window#set_status_line(updated_command_name) abort
if !g:fzf_preview_update_statusline
return
endif
if &laststatus != 3
return
endif
if a:updated_command_name
setlocal statusline=%#Identifier#\ >\ fzf-preview\ %{fzf_preview#remote#window#get_resource_command_name()}
else
setlocal statusline=\
endif
endfunction
function! fzf_preview#remote#window#set_fzf_last_query(...) abort
if &filetype ==# 'fzf' && s:resource_command_name !=# ''
let matches = matchlist(getline('.'), '\w\+\>.\(\(\w\|\s\|''\)\+\)')
if len(matches) > 0
let query = substitute(substitute(matches[1], '\s\+$', '', ''), '^\s\+', '', '')
if get(g:, 'fzf_preview_has_remote', v:false)
call FzfPreviewDispatchResumeQuery(s:resource_command_name, query)
endif
if get(g:, 'fzf_preview_has_coc', v:false)
call CocAction('runCommand', 'fzf-preview-function.DispatchResumeQuery', [s:resource_command_name, query])
endif
if get(g:, 'fzf_preview_has_rpc', v:false)
call fzf_preview#rpc#dispatch_resume_query(s:resource_command_name, query)
endif
endif
call timer_start(50, function('fzf_preview#remote#window#set_fzf_last_query'))
endif
endfunction
================================================
FILE: autoload/fzf_preview/rpc/server.vim
================================================
let s:JSON = vital#fzf_preview#import('VS.RPC.JSON')
let s:Server = {}
function! fzf_preview#rpc#server#import() abort
return s:Server
endfunction
function! s:Server.new(args) abort
let l:server = extend(deepcopy(s:Server), { 'cmd': a:args.command, 'rpc': s:JSON.new(), 'request_id': 0 })
let l:server.events = l:server.rpc.events
return l:server
endfunction
function! s:Server.start() abort
return self.rpc.start({ 'cmd': self.cmd })
endfunction
function! s:Server.request(method, params) abort
return self.rpc.request(self.id(), a:method, a:params)
endfunction
function! s:Server.response(id, params) abort
return self.rpc.response(a:id, a:params)
endfunction
function! s:Server.id() abort
let self.request_id += 1
return self.request_id
endfunction
================================================
FILE: autoload/fzf_preview/rpc.vim
================================================
let s:Promise = vital#fzf_preview#import('Async.Promise')
let s:Server = fzf_preview#rpc#server#import()
let s:root_dir = expand(':h:h:h')
let s:state = {
\ 'id': -1,
\ 'sources': {},
\ 'server': v:null
\ }
let default_processes = {}
call s:Promise.on_unhandled_rejection({ err -> fzf_preview#rpc#log('[ERROR]', err) })
function! fzf_preview#rpc#initialize() abort
if !filereadable(printf('%s/lib/rpc.js', s:root_dir))
return
endif
call s:start()
function! s:initialize_default_processes(response) abort
let s:default_processes = a:response
let g:fzf_preview_has_rpc = v:true
silent doautocmd User fzf_preview#initialized
silent doautocmd User fzf_preview#rpc#initialized
endfunction
call s:state.server.request('getDefaultProcesses', {}).then({ response -> s:initialize_default_processes(response) })
endfunction
function! fzf_preview#rpc#restart() abort
if !empty(s:state.server)
call s:state.server.stop()
endif
let s:state.server = v:null
call s:start()
endfunction
function! fzf_preview#rpc#get_default_processes(name) abort
return s:default_processes[a:name]
endfunction
function! fzf_preview#rpc#command(command, ...) abort
call s:start()
if a:0 == 0
call s:state.server.request('execCommand', { 'commandName': a:command })
else
call s:state.server.request('execCommand', { 'commandName': a:command, 'args': a:1 })
endif
endfunction
function! fzf_preview#rpc#rpc_handler(lines) abort
call feedkeys('', 'x')
call s:state.server.request('callProcess', { 'lines': a:lines })
endfunction
function! fzf_preview#rpc#exec_process_callback(process_name, lines) abort
call s:state.server.request('execProcessCallback', { 'processName': a:process_name, 'lines': a:lines })
endfunction
function! fzf_preview#rpc#dispatch_resume_query(command_name, query) abort
call s:state.server.request('dispatchResumeQuery', { 'commandName': a:command_name, 'query': a:query })
endfunction
function! fzf_preview#rpc#log(...) abort
if exists('g:fzf_preview_debug')
call writefile([join([strftime('%H:%M:%S')] + a:000, "\t")], '/tmp/fzf_preview_rpc.log', 'a')
endif
endfunction
function! s:start() abort
try
if !empty(s:state.server)
return s:state.server
endif
let s:state.server = s:Server.new({ 'command': s:command() })
" call s:state.server.rpc.job.events.on('stdout', { out -> fzf_preview#rpc#log('[STDOUT]', out) })
call s:state.server.events.on('stderr', { err -> fzf_preview#rpc#log('[ERROR]', err) })
call s:state.server.events.on('request', { request -> s:on_request(request) })
call s:state.server.start()
return s:state.server
catch /.*/
echomsg string({ 'exception': v:exception, 'throwpoint': v:throwpoint })
endtry
endfunction
function! s:on_request(request) abort
if a:request['method'] ==# 'execCommand'
execute a:request['params']['command']
call s:state.server.response(a:request['id'], { 'result': v:null })
elseif a:request['method'] ==# 'execCall'
let result = call(a:request['params']['fname'], a:request['params']['args'])
call s:state.server.response(a:request['id'], { 'result': result })
elseif a:request['method'] ==# 'getVar'
let result = get(g:, a:request['params']['name'])
call s:state.server.response(a:request['id'], { 'result': result })
elseif a:request['method'] ==# 'getVvar'
let result = get(v:, a:request['params']['name'])
call s:state.server.response(a:request['id'], { 'result': result })
endif
endfunction
function! s:command() abort
return ['node', printf('%s/lib/rpc.js', s:root_dir)]
endfunction
================================================
FILE: autoload/fzf_preview.vim
================================================
function! fzf_preview#install() abort
!yarn install
UpdateRemotePlugins
endfunction
================================================
FILE: autoload/vital/_fzf_preview/Async/Later.vim
================================================
" ___vital___
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
" Do not modify the code nor insert new lines before '" ___vital___'
function! s:_SID() abort
return matchstr(expand(''), '\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_fzf_preview#Async#Later#import() abort', printf("return map({'set_max_workers': '', 'call': '', 'get_max_workers': '', 'set_error_handler': '', 'get_error_handler': ''}, \"vital#_fzf_preview#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
let s:tasks = []
let s:workers = []
let s:max_workers = 50
let s:error_handler = v:null
function! s:call(fn, ...) abort
call add(s:tasks, [a:fn, a:000])
if empty(s:workers)
call add(s:workers, timer_start(0, s:Worker, { 'repeat': -1 }))
endif
endfunction
function! s:get_max_workers() abort
return s:max_workers
endfunction
function! s:set_max_workers(n) abort
if a:n <= 0
throw 'vital: Async.Later: the n must be a positive integer'
endif
let s:max_workers = a:n
endfunction
function! s:get_error_handler() abort
return s:error_handler
endfunction
function! s:set_error_handler(handler) abort
let s:error_handler = a:handler
endfunction
function! s:_default_error_handler() abort
let ms = split(v:exception . "\n" . v:throwpoint, '\n')
echohl ErrorMsg
for m in ms
echomsg m
endfor
echohl None
endfunction
function! s:_worker(...) abort
if v:dying
return
endif
let n_workers = len(s:workers)
if empty(s:tasks)
if n_workers
call timer_stop(remove(s:workers, 0))
endif
return
endif
try
call call('call', remove(s:tasks, 0))
catch
if s:error_handler is# v:null
call s:_default_error_handler()
else
call s:error_handler()
endif
endtry
if n_workers < s:max_workers
call add(s:workers, timer_start(0, s:Worker, { 'repeat': -1 }))
endif
endfunction
let s:Worker = funcref('s:_worker')
================================================
FILE: autoload/vital/_fzf_preview/Async/Promise.vim
================================================
" ___vital___
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
" Do not modify the code nor insert new lines before '" ___vital___'
function! s:_SID() abort
return matchstr(expand(''), '\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_fzf_preview#Async#Promise#import() abort', printf("return map({'resolve': '', '_vital_depends': '', 'race': '', 'wait': '', '_vital_created': '', 'all': '', 'noop': '', 'on_unhandled_rejection': '', 'is_promise': '', 'chain': '', 'is_available': '', 'reject': '', 'new': '', '_vital_loaded': ''}, \"vital#_fzf_preview#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
" ECMAScript like Promise library for asynchronous operations.
" Spec: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
" This implementation is based upon es6-promise npm package.
" Repo: https://github.com/stefanpenner/es6-promise
" States of promise
let s:PENDING = 0
let s:FULFILLED = 1
let s:REJECTED = 2
let s:DICT_T = type({})
let s:TIMEOUT_ERROR = 'vital: Async.Promise: Timeout'
let s:DEFAULT_WAIT_INTERVAL = 30
function! s:_vital_created(module) abort
let a:module.TimeoutError = s:TIMEOUT_ERROR
lockvar a:module.TimeoutError
endfunction
function! s:_vital_loaded(V) abort
let s:Later = a:V.import('Async.Later')
endfunction
function! s:_vital_depends() abort
return ['Async.Later']
endfunction
function! s:noop(...) abort
endfunction
let s:NOOP = funcref('s:noop')
" Internal APIs
let s:PROMISE = {
\ '_state': s:PENDING,
\ '_has_floating_child': v:false,
\ '_children': [],
\ '_fulfillments': [],
\ '_rejections': [],
\ '_result': v:null,
\ }
let s:id = -1
function! s:_next_id() abort
let s:id += 1
return s:id
endfunction
" ... is added to use this function as a callback of s:Later.call()
function! s:_invoke_callback(settled, promise, callback, result, ...) abort
let has_callback = a:callback isnot v:null
let success = 1
let err = v:null
if has_callback
try
let l:Result = a:callback(a:result)
catch
let err = {
\ 'exception' : v:exception,
\ 'throwpoint' : v:throwpoint,
\ }
let success = 0
endtry
else
let l:Result = a:result
endif
if a:promise._state != s:PENDING
" Do nothing
elseif has_callback && success
call s:_resolve(a:promise, Result)
elseif !success
call s:_reject(a:promise, err)
elseif a:settled == s:FULFILLED
call s:_fulfill(a:promise, Result)
elseif a:settled == s:REJECTED
call s:_reject(a:promise, Result)
endif
endfunction
" ... is added to use this function as a callback of s:Later.call()
function! s:_publish(promise, ...) abort
let settled = a:promise._state
if settled == s:PENDING
throw 'vital: Async.Promise: Cannot publish a pending promise'
endif
if empty(a:promise._children)
if settled == s:REJECTED && !a:promise._has_floating_child
call s:_on_unhandled_rejection(a:promise._result)
endif
return
endif
for i in range(len(a:promise._children))
if settled == s:FULFILLED
let l:CB = a:promise._fulfillments[i]
else
" When rejected
let l:CB = a:promise._rejections[i]
endif
let child = a:promise._children[i]
if child isnot v:null
call s:_invoke_callback(settled, child, l:CB, a:promise._result)
else
call l:CB(a:promise._result)
endif
endfor
let a:promise._children = []
let a:promise._fulfillments = []
let a:promise._rejections = []
endfunction
function! s:_subscribe(parent, child, on_fulfilled, on_rejected) abort
let a:parent._children += [ a:child ]
let a:parent._fulfillments += [ a:on_fulfilled ]
let a:parent._rejections += [ a:on_rejected ]
endfunction
function! s:_handle_thenable(promise, thenable) abort
if a:thenable._state == s:FULFILLED
call s:_fulfill(a:promise, a:thenable._result)
elseif a:thenable._state == s:REJECTED
call s:_reject(a:promise, a:thenable._result)
else
call s:_subscribe(
\ a:thenable,
\ v:null,
\ funcref('s:_resolve', [a:promise]),
\ funcref('s:_reject', [a:promise]),
\ )
endif
endfunction
function! s:_resolve(promise, ...) abort
let l:Result = a:0 > 0 ? a:1 : v:null
if s:is_promise(Result)
call s:_handle_thenable(a:promise, Result)
else
call s:_fulfill(a:promise, Result)
endif
endfunction
function! s:_fulfill(promise, value) abort
if a:promise._state != s:PENDING
return
endif
let a:promise._result = a:value
let a:promise._state = s:FULFILLED
if !empty(a:promise._children)
call s:Later.call(funcref('s:_publish', [a:promise]))
endif
endfunction
function! s:_reject(promise, ...) abort
if a:promise._state != s:PENDING
return
endif
let a:promise._result = a:0 > 0 ? a:1 : v:null
let a:promise._state = s:REJECTED
call s:Later.call(funcref('s:_publish', [a:promise]))
endfunction
function! s:_notify_done(wg, index, value) abort
let a:wg.results[a:index] = a:value
let a:wg.remaining -= 1
if a:wg.remaining == 0
call a:wg.resolve(a:wg.results)
endif
endfunction
function! s:_all(promises, resolve, reject) abort
let total = len(a:promises)
if total == 0
call a:resolve([])
return
endif
let wait_group = {
\ 'results': repeat([v:null], total),
\ 'resolve': a:resolve,
\ 'remaining': total,
\ }
" 'for' statement is not available here because iteration variable is captured into lambda
" expression by **reference**.
call map(
\ copy(a:promises),
\ {i, p -> p.then({v -> s:_notify_done(wait_group, i, v)}, a:reject)},
\ )
endfunction
function! s:_race(promises, resolve, reject) abort
for p in a:promises
call p.then(a:resolve, a:reject)
endfor
endfunction
" Public APIs
function! s:new(resolver) abort
let promise = deepcopy(s:PROMISE)
let promise._vital_promise = s:_next_id()
try
if a:resolver != s:NOOP
call a:resolver(
\ funcref('s:_resolve', [promise]),
\ funcref('s:_reject', [promise]),
\ )
endif
catch
call s:_reject(promise, {
\ 'exception' : v:exception,
\ 'throwpoint' : v:throwpoint,
\ })
endtry
return promise
endfunction
function! s:all(promises) abort
return s:new(funcref('s:_all', [a:promises]))
endfunction
function! s:race(promises) abort
return s:new(funcref('s:_race', [a:promises]))
endfunction
function! s:resolve(...) abort
let promise = s:new(s:NOOP)
call s:_resolve(promise, a:0 > 0 ? a:1 : v:null)
return promise
endfunction
function! s:reject(...) abort
let promise = s:new(s:NOOP)
call s:_reject(promise, a:0 > 0 ? a:1 : v:null)
return promise
endfunction
function! s:is_available() abort
return has('lambda') && has('timers')
endfunction
function! s:is_promise(maybe_promise) abort
return type(a:maybe_promise) == s:DICT_T && has_key(a:maybe_promise, '_vital_promise')
endfunction
function! s:wait(promise, ...) abort
if a:0 && type(a:1) is# v:t_number
let t = a:1
let i = s:DEFAULT_WAIT_INTERVAL . 'm'
else
let o = a:0 ? a:1 : {}
let t = get(o, 'timeout', v:null)
let i = get(o, 'interval', s:DEFAULT_WAIT_INTERVAL) . 'm'
endif
let s = reltime()
while a:promise._state is# s:PENDING
if (t isnot# v:null && reltimefloat(reltime(s)) * 1000 > t)
return [v:null, s:TIMEOUT_ERROR]
endif
execute 'sleep' i
endwhile
if a:promise._state is# s:FULFILLED
return [a:promise._result, v:null]
else
return [v:null, a:promise._result]
endif
endfunction
function! s:chain(promise_factories) abort
return s:_chain(copy(a:promise_factories), [])
endfunction
function! s:_chain(promise_factories, results) abort
if len(a:promise_factories) is# 0
return s:resolve(a:results)
endif
let l:Factory = remove(a:promise_factories, 0)
try
return Factory()
\.then({ v -> add(a:results, v) })
\.then({ -> s:_chain(a:promise_factories, a:results) })
catch
return s:reject({
\ 'exception': v:exception,
\ 'throwpoint': v:throwpoint,
\})
endtry
endfunction
let s:_on_unhandled_rejection = s:NOOP
function! s:on_unhandled_rejection(on_unhandled_rejection) abort
let s:_on_unhandled_rejection = a:on_unhandled_rejection
endfunction
function! s:_promise_then(...) dict abort
let parent = self
let state = parent._state
let child = s:new(s:NOOP)
let l:Res = a:0 > 0 ? a:1 : v:null
let l:Rej = a:0 > 1 ? a:2 : v:null
if state == s:FULFILLED
let parent._has_floating_child = v:true
call s:Later.call(funcref('s:_invoke_callback', [state, child, Res, parent._result]))
elseif state == s:REJECTED
let parent._has_floating_child = v:true
call s:Later.call(funcref('s:_invoke_callback', [state, child, Rej, parent._result]))
else
call s:_subscribe(parent, child, Res, Rej)
endif
return child
endfunction
let s:PROMISE.then = funcref('s:_promise_then')
" .catch() is just a syntax sugar of .then()
function! s:_promise_catch(...) dict abort
return self.then(v:null, a:0 > 0 ? a:1 : v:null)
endfunction
let s:PROMISE.catch = funcref('s:_promise_catch')
function! s:_on_finally(CB, parent, Result) abort
call a:CB()
if a:parent._state == s:FULFILLED
return a:Result
else " REJECTED
return s:reject(a:Result)
endif
endfunction
function! s:_promise_finally(...) dict abort
let parent = self
let state = parent._state
let child = s:new(s:NOOP)
if a:0 == 0
let l:CB = v:null
else
let l:CB = funcref('s:_on_finally', [a:1, parent])
endif
if state != s:PENDING
call s:Later.call(funcref('s:_invoke_callback', [state, child, CB, parent._result]))
else
call s:_subscribe(parent, child, CB, CB)
endif
return child
endfunction
let s:PROMISE.finally = funcref('s:_promise_finally')
" vim:set et ts=2 sts=2 sw=2 tw=0:
================================================
FILE: autoload/vital/_fzf_preview/VS/Event/Emitter.vim
================================================
" ___vital___
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
" Do not modify the code nor insert new lines before '" ___vital___'
function! s:_SID() abort
return matchstr(expand(''), '\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_fzf_preview#VS#Event#Emitter#import() abort', printf("return map({'new': ''}, \"vital#_fzf_preview#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
"
" new
"
function! s:new() abort
return s:Emitter.new()
endfunction
"
" Emitter
"
let s:Emitter = {}
"
" new
"
function! s:Emitter.new() abort
return extend(deepcopy(s:Emitter), {
\ 'events': {}
\ })
endfunction
"
" emit
"
function! s:Emitter.emit(event_name, ...) abort
for l:Listener in get(self.events, a:event_name, [])
call call(l:Listener, a:000)
endfor
endfunction
"
" on
"
function! s:Emitter.on(event_name, Listener) abort
let self.events[a:event_name] = get(self.events, a:event_name, [])
call add(self.events[a:event_name], a:Listener)
endfunction
"
" listener_count
"
function! s:Emitter.listener_count(event_name) abort
return len(get(self.events, a:event_name, []))
endfunction
"
" off
"
function! s:Emitter.off(event_name, ...) abort
let self.events[a:event_name] = get(self.events, a:event_name, [])
let l:Listener = get(a:000, 0, v:null)
let l:i = len(self.events[a:event_name]) - 1
while l:i >= 0
if self.events[a:event_name][l:i] ==# l:Listener || l:Listener is# v:null
call remove(self.events[a:event_name], l:i)
endif
let l:i -= 1
endwhile
endfunction
================================================
FILE: autoload/vital/_fzf_preview/VS/RPC/JSON.vim
================================================
" ___vital___
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
" Do not modify the code nor insert new lines before '" ___vital___'
function! s:_SID() abort
return matchstr(expand(''), '\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_fzf_preview#VS#RPC#JSON#import() abort', printf("return map({'_vital_depends': '', 'new': '', '_vital_loaded': ''}, \"vital#_fzf_preview#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
"
" _vital_loaded
"
function! s:_vital_loaded(V) abort
let s:Promise = a:V.import('Async.Promise')
let s:Job = a:V.import('VS.System.Job')
let s:Emitter = a:V.import('VS.Event.Emitter')
endfunction
"
" _vital_depends
"
function! s:_vital_depends() abort
return ['Async.Promise', 'VS.Event.Emitter', 'VS.System.Job']
endfunction
"
" new
"
function! s:new() abort
return s:Connection.new()
endfunction
"
" s:Connection
"
let s:Connection = {}
"
" new
"
function! s:Connection.new() abort
return extend(deepcopy(s:Connection), {
\ 'job': s:Job.new(),
\ 'events': s:Emitter.new(),
\ 'buffer': '',
\ 'header_length': -1,
\ 'message_length': -1,
\ 'request_map': {},
\ })
endfunction
"
" start
"
function! s:Connection.start(args) abort
if !self.job.is_running()
call self.job.events.on('stdout', self.on_stdout)
call self.job.events.on('stderr', self.on_stderr)
call self.job.events.on('exit', self.on_exit)
call self.job.start(a:args)
endif
endfunction
"
" stop
"
function! s:Connection.stop() abort
if self.job.is_running()
call self.job.events.off('stdout', self.on_stdout)
call self.job.events.off('stderr', self.on_stderr)
call self.job.events.off('exit', self.on_exit)
call self.job.stop()
endif
endfunction
"
" is_running
"
function! s:Connection.is_running() abort
return self.job.is_running()
endfunction
"
" request
"
function! s:Connection.request(id, method, params) abort
let l:ctx = {}
function! l:ctx.callback(id, method, params, resolve, reject) abort
let self.request_map[a:id] = { 'resolve': a:resolve, 'reject': a:reject }
let l:message = { 'id': a:id, 'method': a:method }
if a:params isnot# v:null
let l:message.params = a:params
endif
call self.job.send(self.to_message(l:message))
endfunction
return s:Promise.new(function(l:ctx.callback, [a:id, a:method, a:params], self))
endfunction
"
" response
"
function! s:Connection.response(id, ...) abort
let l:message = { 'id': a:id }
let l:message = extend(l:message, len(a:000) > 0 ? a:000[0] : {})
call self.job.send(self.to_message(l:message))
endfunction
"
" notify
"
function! s:Connection.notify(method, params) abort
let l:message = { 'method': a:method }
if a:params isnot# v:null
let l:message.params = a:params
endif
call self.job.send(self.to_message(l:message))
endfunction
"
" cancel
"
function! s:Connection.cancel(id) abort
if has_key(self.request_map, a:id)
call remove(self.request_map, a:id)
endif
endfunction
"
" to_message
"
function! s:Connection.to_message(message) abort
let a:message.jsonrpc = '2.0'
let l:message = json_encode(a:message)
return 'Content-Length: ' . strlen(l:message) . "\r\n\r\n" . l:message
endfunction
"
" on_message
"
function! s:Connection.on_message(message) abort
if has_key(a:message, 'id')
" Request from server.
if has_key(a:message, 'method')
call self.events.emit('request', a:message)
" Response from server.
else
if has_key(self.request_map, a:message.id)
let l:request = remove(self.request_map, a:message.id)
if has_key(a:message, 'error')
call l:request.reject(a:message.error)
else
call l:request.resolve(get(a:message, 'result', v:null))
endif
endif
endif
" Notify from server.
elseif has_key(a:message, 'method')
call self.events.emit('notify', a:message)
endif
endfunction
"
" flush
"
function! s:Connection.flush(data) abort
let self.buffer .= a:data
while self.buffer !=# ''
" header check.
if self.header_length == -1
let l:header_length = stridx(self.buffer, "\r\n\r\n") + 4
if l:header_length < 4
return
endif
let self.header_length = l:header_length
let self.message_length = self.header_length + str2nr(get(matchlist(self.buffer, '\ccontent-length:\s*\(\d\+\)'), 1, '-1'))
endif
" content check.
let l:buffer_len = strlen(self.buffer)
if l:buffer_len < self.message_length
return
endif
let l:content = strpart(self.buffer, self.header_length, self.message_length - self.header_length)
try
call self.on_message(json_decode(l:content))
catch /.*/
endtry
let self.buffer = strpart(self.buffer, self.message_length)
let self.header_length = -1
endwhile
endfunction
"
" on_stdout
"
function! s:Connection.on_stdout(data) abort
call self.flush(a:data)
endfunction
"
" on_stderr
"
function! s:Connection.on_stderr(data) abort
call self.events.emit('stderr', a:data)
endfunction
"
" on_exit
"
function! s:Connection.on_exit(code) abort
call self.events.emit('exit', a:code)
endfunction
================================================
FILE: autoload/vital/_fzf_preview/VS/System/Job.vim
================================================
" ___vital___
" NOTE: lines between '" ___vital___' is generated by :Vitalize.
" Do not modify the code nor insert new lines before '" ___vital___'
function! s:_SID() abort
return matchstr(expand(''), '\zs\d\+\ze__SID$')
endfunction
execute join(['function! vital#_fzf_preview#VS#System#Job#import() abort', printf("return map({'_vital_depends': '', 'new': '', '_vital_loaded': ''}, \"vital#_fzf_preview#function('%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
delfunction s:_SID
" ___vital___
"
" _vital_loaded
"
function! s:_vital_loaded(V) abort
let s:Emitter = a:V.import('VS.Event.Emitter')
endfunction
"
" _vital_depends
"
function! s:_vital_depends() abort
return ['VS.Event.Emitter']
endfunction
"
" new
"
function! s:new() abort
return s:Job.new()
endfunction
let s:chunk_size = 2048
let s:Job = {}
"
" new
"
function! s:Job.new() abort
let l:job = extend(deepcopy(s:Job), {
\ 'events': s:Emitter.new(),
\ 'write_buffer': '',
\ 'write_timer': -1,
\ 'job': v:null,
\ })
let l:job.write = function(l:job.write, [], l:job)
return l:job
endfunction
"
" start
"
function! s:Job.start(args) abort
if self.is_running()
return
endif
let l:option = {}
for l:key in ['cwd', 'env']
if has_key(a:args, l:key)
let l:option[l:key] = a:args[l:key]
endif
endfor
let self.job = s:_create(
\ a:args.cmd,
\ l:option,
\ function(self.on_stdout, [], self),
\ function(self.on_stderr, [], self),
\ function(self.on_exit, [], self)
\ )
endfunction
"
" stop
"
function! s:Job.stop() abort
if !self.is_running()
return
endif
call self.job.stop()
let self.job = v:null
endfunction
"
" is_running
"
function! s:Job.is_running() abort
return !empty(self.job)
endfunction
"
" send
"
function! s:Job.send(data) abort
if !self.is_running()
return
endif
let self.write_buffer .= a:data
if self.write_timer != -1
return
endif
call self.write()
endfunction
"
" write
"
function! s:Job.write(...) abort
let self.write_timer = -1
if self.write_buffer ==# ''
return
endif
call self.job.send(strpart(self.write_buffer, 0, s:chunk_size))
let self.write_buffer = strpart(self.write_buffer, s:chunk_size)
if self.write_buffer !=# ''
let self.write_timer = timer_start(0, self.write)
endif
endfunction
"
" on_stdout
"
function! s:Job.on_stdout(data) abort
call self.events.emit('stdout', a:data)
endfunction
"
" on_stderr
"
function! s:Job.on_stderr(data) abort
call self.events.emit('stderr', a:data)
endfunction
"
" on_exit
"
function! s:Job.on_exit(code) abort
call self.events.emit('exit', a:code)
endfunction
"
" create job instance
"
if has('nvim')
function! s:_create(cmd, option, out, err, exit) abort
let a:option.on_stdout = { id, data, event -> a:out(join(data, "\n")) }
let a:option.on_stderr = { id, data, event -> a:err(join(data, "\n")) }
let a:option.on_exit = { id, data, code -> a:exit(code) }
let l:job = jobstart(a:cmd, a:option)
return {
\ 'stop': { -> jobstop(l:job) },
\ 'send': { data -> jobsend(l:job, data) }
\ }
endfunction
else
function! s:_create(cmd, option, out, err, exit) abort
let a:option.noblock = v:true
let a:option.in_io = 'pipe'
let a:option.in_mode = 'raw'
let a:option.out_io = 'pipe'
let a:option.out_mode = 'raw'
let a:option.err_io = 'pipe'
let a:option.err_mode = 'raw'
let a:option.out_cb = { job, data -> a:out(data) }
let a:option.err_cb = { job, data -> a:err(data) }
let a:option.exit_cb = { job, code -> a:exit(code) }
let l:job = job_start(a:cmd, a:option)
return {
\ 'stop': { -> ch_close(l:job) },
\ 'send': { data -> ch_sendraw(l:job, data) }
\ }
endfunction
endif
================================================
FILE: autoload/vital/_fzf_preview.vim
================================================
let s:_plugin_name = expand(':t:r')
function! vital#{s:_plugin_name}#new() abort
return vital#{s:_plugin_name[1:]}#new()
endfunction
function! vital#{s:_plugin_name}#function(funcname) abort
silent! return function(a:funcname)
endfunction
================================================
FILE: autoload/vital/fzf_preview.vim
================================================
let s:plugin_name = expand(':t:r')
let s:vital_base_dir = expand(':h')
let s:project_root = expand(':h:h:h')
let s:is_vital_vim = s:plugin_name is# 'vital'
let s:loaded = {}
let s:cache_sid = {}
function! vital#{s:plugin_name}#new() abort
return s:new(s:plugin_name)
endfunction
function! vital#{s:plugin_name}#import(...) abort
if !exists('s:V')
let s:V = s:new(s:plugin_name)
endif
return call(s:V.import, a:000, s:V)
endfunction
let s:Vital = {}
function! s:new(plugin_name) abort
let base = deepcopy(s:Vital)
let base._plugin_name = a:plugin_name
return base
endfunction
function! s:vital_files() abort
if !exists('s:vital_files')
let s:vital_files = map(
\ s:is_vital_vim ? s:_global_vital_files() : s:_self_vital_files(),
\ 'fnamemodify(v:val, ":p:gs?[\\\\/]?/?")')
endif
return copy(s:vital_files)
endfunction
let s:Vital.vital_files = function('s:vital_files')
function! s:import(name, ...) abort dict
let target = {}
let functions = []
for a in a:000
if type(a) == type({})
let target = a
elseif type(a) == type([])
let functions = a
endif
unlet a
endfor
let module = self._import(a:name)
if empty(functions)
call extend(target, module, 'keep')
else
for f in functions
if has_key(module, f) && !has_key(target, f)
let target[f] = module[f]
endif
endfor
endif
return target
endfunction
let s:Vital.import = function('s:import')
function! s:load(...) abort dict
for arg in a:000
let [name; as] = type(arg) == type([]) ? arg[: 1] : [arg, arg]
let target = split(join(as, ''), '\W\+')
let dict = self
let dict_type = type({})
while !empty(target)
let ns = remove(target, 0)
if !has_key(dict, ns)
let dict[ns] = {}
endif
if type(dict[ns]) == dict_type
let dict = dict[ns]
else
unlet dict
break
endif
endwhile
if exists('dict')
call extend(dict, self._import(name))
endif
unlet arg
endfor
return self
endfunction
let s:Vital.load = function('s:load')
function! s:unload() abort dict
let s:loaded = {}
let s:cache_sid = {}
unlet! s:vital_files
endfunction
let s:Vital.unload = function('s:unload')
function! s:exists(name) abort dict
if a:name !~# '\v^\u\w*%(\.\u\w*)*$'
throw 'vital: Invalid module name: ' . a:name
endif
return s:_module_path(a:name) isnot# ''
endfunction
let s:Vital.exists = function('s:exists')
function! s:search(pattern) abort dict
let paths = s:_extract_files(a:pattern, self.vital_files())
let modules = sort(map(paths, 's:_file2module(v:val)'))
return uniq(modules)
endfunction
let s:Vital.search = function('s:search')
function! s:plugin_name() abort dict
return self._plugin_name
endfunction
let s:Vital.plugin_name = function('s:plugin_name')
function! s:_self_vital_files() abort
let builtin = printf('%s/__%s__/', s:vital_base_dir, s:plugin_name)
let installed = printf('%s/_%s/', s:vital_base_dir, s:plugin_name)
let base = builtin . ',' . installed
return split(globpath(base, '**/*.vim', 1), "\n")
endfunction
function! s:_global_vital_files() abort
let pattern = 'autoload/vital/__*__/**/*.vim'
return split(globpath(&runtimepath, pattern, 1), "\n")
endfunction
function! s:_extract_files(pattern, files) abort
let tr = {'.': '/', '*': '[^/]*', '**': '.*'}
let target = substitute(a:pattern, '\.\|\*\*\?', '\=tr[submatch(0)]', 'g')
let regexp = printf('autoload/vital/[^/]\+/%s.vim$', target)
return filter(a:files, 'v:val =~# regexp')
endfunction
function! s:_file2module(file) abort
let filename = fnamemodify(a:file, ':p:gs?[\\/]?/?')
let tail = matchstr(filename, 'autoload/vital/_\w\+/\zs.*\ze\.vim$')
return join(split(tail, '[\\/]\+'), '.')
endfunction
" @param {string} name e.g. Data.List
function! s:_import(name) abort dict
if has_key(s:loaded, a:name)
return copy(s:loaded[a:name])
endif
let module = self._get_module(a:name)
if has_key(module, '_vital_created')
call module._vital_created(module)
endif
let export_module = filter(copy(module), 'v:key =~# "^\\a"')
" Cache module before calling module._vital_loaded() to avoid cyclic
" dependences but remove the cache if module._vital_loaded() fails.
" let s:loaded[a:name] = export_module
let s:loaded[a:name] = export_module
if has_key(module, '_vital_loaded')
try
call module._vital_loaded(vital#{s:plugin_name}#new())
catch
unlet s:loaded[a:name]
throw 'vital: fail to call ._vital_loaded(): ' . v:exception . " from:\n" . s:_format_throwpoint(v:throwpoint)
endtry
endif
return copy(s:loaded[a:name])
endfunction
let s:Vital._import = function('s:_import')
function! s:_format_throwpoint(throwpoint) abort
let funcs = []
let stack = matchstr(a:throwpoint, '^function \zs.*, .\{-} \d\+$')
for line in split(stack, '\.\.')
let m = matchlist(line, '^\(.\+\)\%(\[\(\d\+\)\]\|, .\{-} \(\d\+\)\)$')
if !empty(m)
let [name, lnum, lnum2] = m[1:3]
if empty(lnum)
let lnum = lnum2
endif
let info = s:_get_func_info(name)
if !empty(info)
let attrs = empty(info.attrs) ? '' : join([''] + info.attrs)
let flnum = info.lnum == 0 ? '' : printf(' Line:%d', info.lnum + lnum)
call add(funcs, printf('function %s(...)%s Line:%d (%s%s)',
\ info.funcname, attrs, lnum, info.filename, flnum))
continue
endif
endif
" fallback when function information cannot be detected
call add(funcs, line)
endfor
return join(funcs, "\n")
endfunction
function! s:_get_func_info(name) abort
let name = a:name
if a:name =~# '^\d\+$' " is anonymous-function
let name = printf('{%s}', a:name)
elseif a:name =~# '^\d\+$' " is lambda-function
let name = printf("{'%s'}", a:name)
endif
if !exists('*' . name)
return {}
endif
let body = execute(printf('verbose function %s', name))
let lines = split(body, "\n")
let signature = matchstr(lines[0], '^\s*\zs.*')
let [_, file, lnum; __] = matchlist(lines[1],
\ '^\t\%(Last set from\|.\{-}:\)\s*\zs\(.\{-}\)\%( \S\+ \(\d\+\)\)\?$')
return {
\ 'filename': substitute(file, '[/\\]\+', '/', 'g'),
\ 'lnum': 0 + lnum,
\ 'funcname': a:name,
\ 'arguments': split(matchstr(signature, '(\zs.*\ze)'), '\s*,\s*'),
\ 'attrs': filter(['dict', 'abort', 'range', 'closure'], 'signature =~# (").*" . v:val)'),
\ }
endfunction
" s:_get_module() returns module object wihch has all script local functions.
function! s:_get_module(name) abort dict
let funcname = s:_import_func_name(self.plugin_name(), a:name)
try
return call(funcname, [])
catch /^Vim\%((\a\+)\)\?:E117:/
return s:_get_builtin_module(a:name)
endtry
endfunction
function! s:_get_builtin_module(name) abort
return s:sid2sfuncs(s:_module_sid(a:name))
endfunction
if s:is_vital_vim
" For vital.vim, we can use s:_get_builtin_module directly
let s:Vital._get_module = function('s:_get_builtin_module')
else
let s:Vital._get_module = function('s:_get_module')
endif
function! s:_import_func_name(plugin_name, module_name) abort
return printf('vital#_%s#%s#import', a:plugin_name, s:_dot_to_sharp(a:module_name))
endfunction
function! s:_module_sid(name) abort
let path = s:_module_path(a:name)
if !filereadable(path)
throw 'vital: module not found: ' . a:name
endif
let vital_dir = s:is_vital_vim ? '__\w\+__' : printf('_\{1,2}%s\%%(__\)\?', s:plugin_name)
let base = join([vital_dir, ''], '[/\\]\+')
let p = base . substitute('' . a:name, '\.', '[/\\\\]\\+', 'g')
let sid = s:_sid(path, p)
if !sid
call s:_source(path)
let sid = s:_sid(path, p)
if !sid
throw printf('vital: cannot get from path: %s', path)
endif
endif
return sid
endfunction
function! s:_module_path(name) abort
return get(s:_extract_files(a:name, s:vital_files()), 0, '')
endfunction
function! s:_module_sid_base_dir() abort
return s:is_vital_vim ? &rtp : s:project_root
endfunction
function! s:_dot_to_sharp(name) abort
return substitute(a:name, '\.', '#', 'g')
endfunction
function! s:_source(path) abort
execute 'source' fnameescape(a:path)
endfunction
" @vimlint(EVL102, 1, l:_)
" @vimlint(EVL102, 1, l:__)
function! s:_sid(path, filter_pattern) abort
let unified_path = s:_unify_path(a:path)
if has_key(s:cache_sid, unified_path)
return s:cache_sid[unified_path]
endif
for line in filter(split(execute(':scriptnames'), "\n"), 'v:val =~# a:filter_pattern')
let [_, sid, path; __] = matchlist(line, '^\s*\(\d\+\):\s\+\(.\+\)\s*$')
if s:_unify_path(path) is# unified_path
let s:cache_sid[unified_path] = sid
return s:cache_sid[unified_path]
endif
endfor
return 0
endfunction
if filereadable(expand(':r') . '.VIM') " is case-insensitive or not
let s:_unify_path_cache = {}
" resolve() is slow, so we cache results.
" Note: On windows, vim can't expand path names from 8.3 formats.
" So if getting full path via and $HOME was set as 8.3 format,
" vital load duplicated scripts. Below's :~ avoid this issue.
function! s:_unify_path(path) abort
if has_key(s:_unify_path_cache, a:path)
return s:_unify_path_cache[a:path]
endif
let value = tolower(fnamemodify(resolve(fnamemodify(
\ a:path, ':p')), ':~:gs?[\\/]?/?'))
let s:_unify_path_cache[a:path] = value
return value
endfunction
else
function! s:_unify_path(path) abort
return resolve(fnamemodify(a:path, ':p:gs?[\\/]?/?'))
endfunction
endif
" copied and modified from Vim.ScriptLocal
let s:SNR = join(map(range(len("\")), '"[\\x" . printf("%0x", char2nr("\"[v:val])) . "]"'), '')
function! s:sid2sfuncs(sid) abort
let fs = split(execute(printf(':function /^%s%s_', s:SNR, a:sid)), "\n")
let r = {}
let pattern = printf('\m^function\s%d_\zs\w\{-}\ze(', a:sid)
for fname in map(fs, 'matchstr(v:val, pattern)')
let r[fname] = function(s:_sfuncname(a:sid, fname))
endfor
return r
endfunction
"" Return funcname of script local functions with SID
function! s:_sfuncname(sid, funcname) abort
return printf('%s_%s', a:sid, a:funcname)
endfunction
================================================
FILE: autoload/vital/fzf_preview.vital
================================================
fzf_preview
8e269699b0b993fc68599ed94571db5d3e933bcf
VS.RPC.JSON
Async.Promise
VS.System.Job
VS.Event.Emitter
================================================
FILE: bin/git_actions_preview
================================================
#!/usr/bin/env bash
if [[ $1 == 'status' ]]; then
git -c color.status=always status
elif [[ $1 == 'branch' ]]; then
git for-each-ref --sort=-committerdate --count=10 --color=always --format="Date: %(color:red)%(authordate:iso)%(color:reset) %(color:green)[%(authorname)]%(color:reset) Ref: %(color:yellow)%(refname:short)%(color:reset)
Subject: %(subject)
"
elif [[ $1 =~ ^(log|push|fetch|pull) ]]; then
git log --decorate --pretty='format:%C(yellow)%h %C(green)%cd %C(reset)%s %C(red)%d %C(cyan)[%an]' --date=iso --graph --color=always
elif [[ $1 =~ ^current-log ]]; then
file=$(echo "$1" | awk -F':' '{print $2}')
if [[ $file != '' ]]; then
git log --decorate --pretty='format:%C(yellow)%h %C(green)%cd %C(reset)%s %C(red)%d %C(cyan)[%an]' --date=iso --graph --color=always -- "$file"
fi
elif [[ $1 =~ ^commit ]]; then
git diff --cached --color=always
fi
================================================
FILE: bin/git_blame_pr
================================================
#! /usr/bin/perl
#
# Written in 2017 by Kazuho Oku
#
# To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see .
use strict;
use warnings;
my $git_blame_pid = open(my $fh, "-|", "git", "blame", "--first-parent", @ARGV)
or die "failed to invoke git-blame:$!";
my %cached; # commit-id -> substitution string
while (my $line = <$fh>) {
my ($commit, $src) = split / .*?\) /, $line, 2;
$cached{$commit} = lookup($commit)
unless $cached{$commit};
print $cached{$commit}, ' ', $src;
}
while (waitpid($git_blame_pid, 0) != $git_blame_pid) {}
exit $?;
sub lookup {
my $commit = shift;
my $message = `git show --oneline $commit`;
if ($message =~ /Merge\s+(?:pull\s+request|pr)\s+\#?(\d+)\s/i) {
return sprintf '%-9s', "PR #$1";
}
return $commit;
}
================================================
FILE: bin/preview_yankround_register
================================================
#!/usr/bin/env bash
if which gsed > /dev/null && which gcut > /dev/null; then
gsed -n "$2,$2p" "$1" | gcut -f 2 | gsed -e "s/\x0/\n/g"
else
sed -n "$2,$2p" "$1" | cut -f 2 | sed -e "s/\x0/\n/g"
fi
================================================
FILE: doc/fzf_preview_vim.txt
================================================
*fzf-preview-vim.txt*
Author: yuki-yano
License: MIT
Version: 0.1
==============================================================================
CONTENTS *fzf-preview-contents*
Introduction |fzf-preview-introduction|
Installation |fzf-preview-installation|
Mappings |fzf-preview-mappings|
Commands |fzf-preview-commands|
Keymap |fzf-preview-keymap|
==============================================================================
INTRODUCTION *fzf-preview-introduction*
*fzf-preview* is Vim script RPC, coc extensions or Neovim remote plugin to
provide some fzf sources with preview.
Requirements:
- Neovim (Remote Plugin)
https://neovim.io/
- coc.nvim (coc extensions)
https://github.com/neoclide/coc.nvim
- Node
https://nodejs.org/
- git
https://git-scm.com/
- fzf
https://github.com/junegunn/fzf
- ripgrep (Require some preview)
https://github.com/BurntSushi/ripgrep
Optional:
- bat (Add color to the preview)
https://github.com/sharkdp/bat
- vim-devicons (Use devicons)
https://github.com/ryanoasis/vim-devicons
- Fugitive (Require git integration)
https://github.com/tpope/vim-fugitive
- Gina (Require git integration)
https://github.com/lambdalisue/gina.vim
- universal-ctags (Requre FzfPreviewCtags and FzfPreviewBufferTags)
https://github.com/universal-ctags/ctags
- vista.vim (Require FzfPreviewVistaCtags and FzfPreviewVistaBufferCtags)
https://github.com/liuchengxu/vista.vim
- vim-bookmarks (Require FzfPreviewBookmarks)
https://github.com/MattesGroeger/vim-bookmarks
- yankround.vim (Require FzfPreviewYankround)
https://github.com/LeafCage/yankround.vim
- memolist.vim (Require FzfPreviewMemoList and FzfPreviewMemoListGrep)
https://github.com/glidenote/memolist.vim
- todo-comments.nvim (Require FzfPreviewTodoComments)
https://github.com/folke/todo-comments.nvim
- GitHub cli (Require integrate with GitHub)
https://github.com/cli/cli
- Yarn (Build latest remote plugin)
https://classic.yarnpkg.com/
Latest version:
https://github.com/yuki-yano/fzf-preview.vim
==============================================================================
VIM SCRIPT RPC PLUGIN INSTALLATION *fzf-preview-vim-rpc-installation*
Use Dein, vim-plug or any Vim plugin manager of your choice.
Install release/rpc branch.
>
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'yuki-yano/fzf-preview.vim', { 'branch': 'release/rpc' }
<
or
>
call dein#add('junegunn/fzf', { 'build': './install --all', 'merged': 0 })
call dein#add('yuki-yano/fzf-preview.vim', { 'rev': 'release/rpc' })
<
==============================================================================
REMOTE PLUGIN INSTALLATION *fzf-preview-remote-installation*
Install the npm package [neovim](https://www.npmjs.com/package/neovim)
to get the remote plugin working.
>
$ npm install -g neovim
<
Use Dein, vim-plug or any Vim plugin manager of your choice.
Install release/remote branch and `:UpdateRemotePlugins`
when after installed plugin.
>
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'yuki-yano/fzf-preview.vim', { 'branch': 'release/remote', 'do': ':UpdateRemotePlugins' }
<
or
>
call dein#add('junegunn/fzf', { 'build': './install --all', 'merged': 0 })
call dein#add('yuki-yano/fzf-preview.vim', { 'rev': 'release/remote' })
<
==============================================================================
COC EXTENSION INSTALLATION *fzf-preview-coc-installation*
Install the [coc.nvim](https://github.com/neoclide/coc.nvim)
Install coc extensions fzf-preview.
use vim-plug:
>
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
<
use dein:
>
call dein#add('junegunn/fzf', { 'build': './install --all', 'merged': 0 })
call dein#add('neoclide/coc.nvim', { 'rev': 'release', 'merged': 0 })
<
execute after
:CocInstall coc-fzf-preview
==============================================================================
COMMANDS *fzf-preview-commands*
Vim script RPC, Remote Plugin, and coc extensions, in that order.
*:FzfPreviewProjectFiles*
:FzfPreviewProjectFilesRpc
:FzfPreviewProjectFiles
:CocCommand fzf-preview.ProjectFiles
Select and open git repository files from project.
*:FzfPreviewGitFiles*
:FzfPreviewGitFilesRpc
:FzfPreviewGitFiles
:CocCommand fzf-preview.GitFiles
Select and open git repository files from git ls-files.
*:FzfPreviewDirectoryFiles*
:FzfPreviewDirectoryFilesRpc {path or none}
:FzfPreviewDirectoryFiles {path or none}
:CocCommand fzf-preview.DirectoryFiles {path or none}
Select and open directory files from ripgrep with fzf interface.
Default to current working directory.
*:FzfPreviewBuffers*
:FzfPreviewBuffersRpc
:FzfPreviewBuffers
:CocCommand fzf-preview.Buffers
Select and open file buffers.
Use open-buffer processes.
*:FzfPreviewAllBuffers*
:FzfPreviewAllBuffersRpc
:FzfPreviewAllBuffers
:CocCommand fzf-preview.AllBuffers
Select and open all buffers(include not file).
Use open-bufnr processes.
*:FzfPreviewProjectOldFiles*
:FzfPreviewProjectOldFilesRpc
:FzfPreviewProjectOldFiles
:CocCommand fzf-preview.ProjectOldFiles
Select and open the past open files in the project using fzf.
The target file is selected from |v:oldfiles|.
*:FzfPreviewProjectMruFiles*
:FzfPreviewProjectMruFilesRpc
:FzfPreviewProjectMruFiles
:CocCommand fzf-preview.ProjectMruFiles
Select and open the past open files in the project using fzf.
The target file is selected from most recently used.
*:FzfPreviewProjectMrwFiles*
:FzfPreviewMrwFilesRpc
:FzfPreviewMrwFiles
:CocCommand fzf-preview.MrwFiles
Select and open the past open files in the project using fzf.
The target file is selected from most recently written.
*:FzfPreviewProjectGrep*
:FzfPreviewProjectGrepRpc
:FzfPreviewProjectGrep
:CocCommand fzf-preview.ProjectGrep
Search text from the project.
The retrieved result is displayed in file name, number of lines, preview
and can be opened with fzf interface.
*:FzfPreviewProjectGrepRecall*
:FzfPreviewProjectGrepRecallRpc
:FzfPreviewProjectGrepRecall
:CocCommand fzf-preview.ProjectGrepRecall
Run FzfPreviewProjectGrep with the same arguments as before.
*:FzfPreviewCTags*
:FzfPreviewCtagsRpc
:FzfPreviewCtags
:CocCommand fzf-preview.Ctags
Select tags from tags file
The same script as FzfPreviewProjectGrep is used for preview.
Required: |universal-ctags|
Cautions:
Set --excmd=number or --excmd=combine to universal-ctags option
*:FzfPreviewBufferTags*
:FzfPreviewBufferTagsRpc
:FzfPreviewBufferTags
:CocCommand fzf-preview.BufferTags
Select from tags of currently open buffer
The same script as FzfPreviewProjectGrep is used for preview.
Required: |universal-ctags|
*:FzfPreviewOldFiles*
:FzfPreviewOldFilesRpc
:FzfPreviewOldFiles
:CocCommand fzf-preview.OldFiles
Select and open the opened file.
For the target file, see |v:oldfiles|.
*:FzfPreviewMruFiles*
:FzfPreviewMruFilesRpc
:FzfPreviewMruFiles
:CocCommand fzf-preview.MruFiles
Select and open the opened file.
For the target file, most recently used.
*:FzfPreviewMrwFiles*
:FzfPreviewMrwFilesRpc
:FzfPreviewMrwFiles
:CocCommand fzf-preview.MrwFiles
Select and open the opened file.
For the target file, most recently written.
*:FzfPreviewQuickFix*
:FzfPreviewQuickFixRpc
:FzfPreviewQuickFix
:CocCommand fzf-preview.QuickFix
Select and open the QuickFix item.
*:FzfPreviewLocationList*
:FzfPreviewLocationListRpc
:FzfPreviewLocationList
:CocCommand fzf-preview.LocationList
Select and open the LocationList item.
*:FzfPreviewLines*
:FzfPreviewLinesRpc
:FzfPreviewLines
:CocCommand fzf-preview.Lines
Select line from current buffer.
*:FzfPreviewBufferLines*
:FzfPreviewBufferLinesRpc
:FzfPreviewBufferLines
:CocCommand fzf-preview.BufferLines
Select line from all buffer
*:FzfPreviewJumps*
:FzfPreviewJumpsRpc
:FzfPreviewJumps
:CocCommand fzf-preview.Jumps
Select and open the jumplist
*:FzfPreviewChanges*
:FzfPreviewChangesRpc
:FzfPreviewChanges
:CocCommand fzf-preview.Changes
Select and open the changelist
*:FzfPreviewMarks*
:FzfPreviewMarksRpc
:FzfPreviewMarks
:CocCommand fzf-preview.Marks
List marks from the project.
The retrieved result is displayed in file name, number of lines.
The same script as FzfPreviewProjectGrep is used for preview.
*:FzfPreviewFromResources*
:FzfPreviewFromResourcesRpc
:FzfPreviewFromResources
:CocCommand fzf-preview.FromResources
Select a resource and generate a file list.
From there, select the file using the fzf interface.
Resources: [project, git, directory, buffer, project_old,
project_mru, project_mrw, old, mru, mrw]
*:FzfPreviewCommandPalette*
:FzfPreviewCommandPaletteRpc
:FzfPreviewCommandPalette
:CocCommand fzf-preview.CommandPalette
Execute and edit command history
*:FzfPreviewGrepHelp*
:FzfPreviewGrepHelpRpc
:FzfPreviewGrepHelp
:CocCommand fzf-preview.GrepHelp
Grep vim help.
*:FzfPreviewGitStatus*
:FzfPreviewGitStatusRpc
:FzfPreviewGitStatus
:CocCommand fzf-preview.GitStatus
Git status integration.
*:FzfPreviewGitActions*
:FzfPreviewGitActionsRpc
:FzfPreviewGitActions
:CocCommand fzf-preview.GitActions
Interactive git integration.
Select resource and action.
*:FzfPreviewVistaCtags*
:FzfPreviewVistaCtagsRpc
:FzfPreviewVistaCtags
:CocCommand fzf-preview.VistaCtags
Select tags from vista.vim.
Required: vista.vim
*:FzfPreviewVistaBufferCtags*
:FzfPreviewVistaBufferCtagsRpc
:FzfPreviewVistaBufferCtags
:CocCommand fzf-preview.VistaBufferCtags
Select current buffer tags from vista.vim.
Required: vista.vim
*:FzfPreviewNvimLspReferences*
:FzfPreviewNvimLspReferencesRpc
:FzfPreviewNvimLspReferences
Select and open the references from nvim-lsp.
*:FzfPreviewNvimLspDiagnostics*
:FzfPreviewNvimLspDiagnosticsRpc
:FzfPreviewNvimLspDiagnostics
Select and open the diagnostics from nvim-lsp.
*:FzfPreviewNvimLspCurrentDiagnostics*
:FzfPreviewNvimLspCurrentDiagnosticsRpc
:FzfPreviewNvimLspCurrentDiagnostics
Select and open the current file diagnostics from nvim-lsp.
*:FzfPreviewNvimLspDefinitions*
:FzfPreviewNvimLspDefinitionRpc
:FzfPreviewNvimLspDefinition
Select and open the definitions from nvim-lsp.
*:FzfPreviewNvimLspTypeDefinitions*
:FzfPreviewNvimLspTypeDefinitionsRpc
:FzfPreviewNvimLspTypeDefinition
Select and open the type definitions from nvim-lsp.
*:FzfPreviewNvimLspImplementations*
:FzfPreviewNvimLspImplementationsRpc
:FzfPreviewNvimLspImplementations
Select and open the implementations from nvim-lsp.
*:FzfPreviewVimLspReferences*
:FzfPreviewVimLspReferencesRpc
:FzfPreviewVimLspReferences
Select and open the references from vim-lsp.
*:FzfPreviewVimLspDiagnostics*
:FzfPreviewVimLspDiagnosticsRpc
:FzfPreviewVimLspDiagnostics
Select and open the diagnostics from vim-lsp.
*:FzfPreviewVimLspCurrentDiagnostics*
:FzfPreviewVimLspCurrentDiagnosticsRpc
:FzfPreviewVimLspCurrentDiagnostics
Select and open the current file diagnostics from vim-lsp.
*:FzfPreviewVimLspDefinitions*
:FzfPreviewVimLspDefinitionRpc
:FzfPreviewVimLspDefinition
Select and open the definitions from vim-lsp.
*:FzfPreviewVimLspTypeDefinitions*
:FzfPreviewVimLspTypeDefinitionsRpc
:FzfPreviewVimLspTypeDefinition
Select and open the type definitions from vim-lsp.
*:FzfPreviewVimLspImplementations*
:FzfPreviewVimLspImplementationsRpc
:FzfPreviewVimLspImplementations
Select and open the implementations from vim-lsp.
*:FzfPreviewBookmarks*
:FzfPreviewBookmarksRpc
:FzfPreviewBookmarks
:CocCommand fzf-preview.Bookmarks
Select and open the bookmarks from vim-bookmarks
*:FzfPreviewYankround*
:FzfPreviewYankroundRpc
:FzfPreviewYankround
:CocCommand fzf-preview.Yankround
Select register history and insert " register from yankround.vim
Use register processes.
*:FzfPreviewMemoList*
:FzfPreviewMemoListRpc
:FzfPreviewMemoList
:CocCommand fzf-preview.MemoList
Select memolist and open from memolist.vim.
*:FzfPreviewMemoListGrep*
:FzfPreviewMemoListGrepRpc
:FzfPreviewMemoListGrep
:CocCommand fzf-preview.MemoListGrep
Grep memolist and open from memolist.vim.
*:FzfPreviewTodoComments*
:FzfPreviewTodoCommentsRpc
:FzfPreviewTodoComments
:CocCommand fzf-preview.TodoComments
Search TodoComments from todo-comments.nvim
*:FzfPreviewBlamePR*
:FzfPreviewBlamePRRpc
:FzfPreviewBlamePR
:CocCommand fzf-preview.BlamePR
The PR corresponding to each line is displayed and
the selected PR is opened in the browser.
Use open-pr processes.
*:FzfPreviewCocReferences*
:CocCommand fzf-preview.CocReferences
Select and open the references from coc.nvim.
Only coc extensions.
*:FzfPreviewCocDiagnostics*
:CocCommand fzf-preview.CocDiagnostics
Select and open the diagnostics from coc.nvim.
Only coc extensions.
*:FzfPreviewCocCurrentDiagnostics*
:CocCommand fzf-preview.CocCurrentDiagnostics
Select and open the current file diagnostics from coc.nvim.
Only coc extensions.
*:FzfPreviewCocDefinition*
:CocCommand fzf-preview.CocDefinition
Select and open the definitions from coc.nvim.
Only coc extensions.
*:FzfPreviewCocTypeDefinition*
:CocCommand fzf-preview.CocTypeDefinition
Select and open the type definitions from coc.nvim.
Only coc extensions.
*:FzfPreviewCocImplementations*
:CocCommand fzf-preview.CocImplementations
Select and open the implementations from coc.nvim.
Only coc extensions.
*:FzfPreviewCocOutline*
:CocCommand fzf-preview.CocOutline
Select and open the outline from coc.nvim.
Only coc extensions.
==============================================================================
COMMAND OPTIONS *fzf-preview-command-options*
--processes
Set process when selecting element with fzf started by this command.
Value must be a global variable name.
Variable is dictionary and format is
same as get from |fzf_preview#remote#process#get_default_processes|.
Most command pass a file paths to the process.
FzfPreviewAllBuffers will be passed “buffer {bufnr}”
Value example: let g:foo_processes = {
\ 'enter': 'FzfPreviewOpenFileEnter',
\ 'ctrl-x': get(function('s:foo_function'), 'name'),
\ }
--add-fzf-arg
Set the arguments to be passed when executing fzf.
This value is added to the default options.
Value must be a string without spaces.
Usage example: Exclude filename with FzfPreviewProjectGrep
>
nnoremap g :FzfPreviewProjectGrep --add-fzf-arg=--nth=3
" nnoremap g :CocCommand fzf-preview.ProjectGrep --add-fzf-arg=--nth=3
<
--resume
Reuse the input that was last used to select the element with fzf.
Do not need to pass a value for this option.
Usage example: Reuse last query for project grep.
>
nnoremap G :FzfPreviewProjectGrep . --resume
" nnoremap G :CocCommand fzf-preview.ProjectGrep . --resume
<
==============================================================================
OPTIONS *fzf-preview-options*
*g:fzf_preview_floating_window_rate*
This value is used for the size of the floating window.
The size of the floating window is the size of the vim multiplied
by this value.
Set between 0 and 1.
Default value is 0.9
*g:fzf_preview_direct_window_option*
This value is used to position the window.
It is passed to the window option of |fzf#run|, and
|g:fzf_preview_floating_window_rate| is disabled.
Default value is ''
*g:fzf_preview_default_fzf_options*
It is used as the default option when starting fzf.
Set a dictionary variable whose option name is key.
The string you pass to value is automatically enclosed in double quotes.
If the value to be passed to the option is empty, set v:true.
Default value is { '--reverse': v:true, '--preview-window': 'wrap' }
*g:fzf_preview_quit_map*
If this value is 1, mapping that will safely quit
in fzf's normal mode and visual mode is added
Default value is 1
*g:fzf_preview_command*
Shell command used for fzf preview. The head command is used by default.
If the bat command is installed, the bat is used by default and
the preview is syntax highlighted.
Not installed bat:
Default value is 'cat'
Installed bat:
Default value is 'bat --color=always --plain {-1}'
*g:fzf_preview_if_binary_command*
g:fzf_binary_preview_command is executed if this command succeeds,
and g:fzf_preview_command is executed if it fails
Default value is '[[ "$(file --mime {})" =~ binary ]]'
*g:fzf_binary_preview_command*
Shell command used for binary file preview.
Since it is heavy to display in text, if there is no particular reason,
echo etc. substitute.
Default value is 'echo "{} is a binary file"'
*g:fzf_preview_filelist_command*
This is the command used to search for files in the project.
If ripgrep is not included, git ls-files will be used.
Installed ripgrep:
Default value is 'rg --files --hidden --follow --no-messages --glob "!.git/*" --glob \!"* *"'
Not installed ripgrep:
Default value is 'git ls-files --exclude-standard'
*g:fzf_preview_git_files_command*
This is the command used to search for files in the git repository.
Default value is 'git ls-files --exclude-standard'
*g:fzf_preview_directory_files_command*
This is the command used to search for files in the current directory.
Default value is 'rg --files --hidden --follow --no-messages -g \!"* *"'
Keep in mind a path can be append at the end of the command.
*g:fzf_preview_git_status_command*
This is the command used to git status files
Default value is 'git -c color.status=always status --short --untracked-files=all'
*g:fzf_preview_git_status_preview_command*
This is the command used to git status preview
Default value is "[[ $(git diff --cached -- {-1}) != \"\" ]] && git diff --cached --color=always -- {-1} || " .
\ "[[ $(git diff -- {-1}) != \"\" ]] && git diff --color=always -- {-1} || " .
\ g:fzf_preview_command
*g:fzf_preview_grep_cmd*
This command is used for project grep.
Recommend using a fast grep command such as ripgrep or ag.
Interactively grep the specified directory.
Installed ripgrep:
Default value is 'rg --line-number --no-heading --color=never --hidden'
Not installed ripgrep:
:ProjectGrepPreview is disabled.
*g:fzf_preview_cache_directory*
Specify the directory to store the MRU and MRW cache files.
Default value is 'expand('~/.cache/vim/fzf_preview')'
*g:fzf_preview_disable_mru*
If this value is not 0, disable mru and mrw.
Default value is 0
*g:fzf_preview_mru_limit*
Limit of the number of files to be saved by mru.
Default value is 1000
*g:fzf_preview_lines_command*
This command is used for get current file lines.
Installed bat:
Default value is 'bat --color=always --plain --number'
Not installed bat:
Default value is 'cat -n'
*g:fzf_preview_grep_preview_cmd*
This command is used for :ProjectGrepPreview. bin/preview.rb is used by default.
Default value is 'expand(":h:h") . "/bin/preview.rb"'
*g:fzf_preview_preview_key_bindings*
This command determines keyboard shortcuts during an interactive FZF
session. Options are a string passed directly to fzf's "--bind" option.
Default value is ''
*g:fzf_preview_fzf_color_option*
Specify the color option to be passed to the fzf command.
Options are a string passed directly to fzf's "--color" option.
Default value is ''
*g:fzf_preview_custom_processes*
Set the custom processes.
Dictionary format is { '{processes_name}': { '{input_key}': |String|(Global function name) } }
Default child value can be get with |fzf_preview#remote#process#get_default_processes|
Default value is {}
Example: {
'open-file': {
'ctrl-o': 'FzfPreviewOpenFileCtrlO',
'ctrl-q': 'FzfPreviewOpenFileCtrlQ',
'ctrl-t': 'FzfPreviewOpenFileCtrlT',
'ctrl-v': 'FzfPreviewOpenFileCtrlV',
'ctrl-x': 'FzfPreviewOpenFileCtrlX',
'enter': 'FzfPreviewOpenFileEnter'
},
'register': {
'enter': 'FzfPreviewRegisterEnter'
}
}
*g:fzf_preview_fzf_preview_window_option*
Used as fzf preview-window option
For example, 'up:30%'
Default value is ''
*g:fzf_preview_use_dev_icons*
If this value is 1, devicons is used as fzf candidate.
Default value is 0
*g:fzf_preview_history_dir*
If this value is directory path, use the files in the target directory
and the fzf history option will be enabled.
For example, '~/.fzf'
Default value is false
*g:fzf_preview_dev_icon_prefix_string_length*
Set how many string length devicon is represented.
Default value is 3
*g:fzf_preview_dev_icons_limit*
Devicons can make fzf-preview slow when the number of results is high.
By default icons are disable when number of results is higher this value.
Default value is 5000
*g:fzf_preview_yankround_preview_command*
Command to preview yankround history.
Defaul value is expand(':h:h') . '/bin/preview_yankround_register'
*g:fzf_preview_blame_pr_command*
Command to FzfPreviewBlamePR source.
Defaul value is expand(':h:h') . '/bin/git_blame_pr'
*g:fzf_preview_update_statusline*
If true, statusline is updated during fzf-preview startup.
Defaul value is true
*$FZF_PREVIEW_PREVIEW_BAT_THEME*
The theme used in the bat preview.
Default value is 'OneHalfDark'
*$FZF_PREVIEW_PLUGIN_HELP_ROOT_DIR*
The root directory to be searched by GrepHelp.
Default value is ''
==============================================================================
FUNCTIONS *fzf-preview-functions*
*fzf_preview#remote#process#get_default_processes*
Get the initial value of the processes.
Args is {process_name} and {plugin_type (optional)}.
processes_name is 'open-file', 'open-buffer' and 'open-bufnr'.
plugin_type is 'remote', 'coc' or 'rpc'. Default value is 'remote'.
value from 'open-file' (and 'remote') is
{
'ctrl-o': 'FzfPreviewOpenFileCtrlO',
'ctrl-q': 'FzfPreviewOpenFileCtrlQ',
'ctrl-t': 'FzfPreviewOpenFileCtrlT',
'ctrl-v': 'FzfPreviewOpenFileCtrlV',
'ctrl-x': 'FzfPreviewOpenFileCtrlX',
'enter': 'FzfPreviewOpenFileEnter'
}
value from 'open-file' and 'coc' is
{
'ctrl-o': 'OpenFileCtrlO',
'ctrl-q': 'OpenFileCtrlQ',
'ctrl-t': 'OpenFileCtrlT',
'ctrl-v': 'OpenFileCtrlV',
'ctrl-x': 'OpenFileCtrlX',
'enter': 'OpenFileEnter'
}
value from 'open-file' and 'rpc' is
{
'ctrl-o': 'FzfPreviewOpenFileCtrlO',
'ctrl-q': 'FzfPreviewOpenFileCtrlQ',
'ctrl-t': 'FzfPreviewOpenFileCtrlT',
'ctrl-v': 'FzfPreviewOpenFileCtrlV',
'ctrl-x': 'FzfPreviewOpenFileCtrlX',
'enter': 'FzfPreviewOpenFileEnter'
}
==============================================================================
USER AUTOCMD EVENTS *fzf-preview-user-autocmd-events*
*fzf_preview#remote#initialized*
Runs when initialization of the Remote Plugin is complete.
*fzf_preview#rpc#initialized*
Runs when initialization of the Vim script RPC is complete.
*fzf_preview#coc#initialized*
Runs when initialization of the coc extensions is complete.
Deprecated
*fzf_preview#initialized*
Runs when initialization of the Remote Plugin, coc extensions and
Vim script RPC is complete.
==============================================================================
BASE DEFAULT KEYMAP *fzf-preview-keymap*
,
- Cancel fzf
- Open split
- Open vsplit
- Open tabedit
- Open drop
- Build QuickFix from open-file processes.
- Execute :bdelete! command from open-buffer and open-bufnr processes.
- Preview page down
- Preview page up
?
- Toggle Preview
==============================================================================
EXAMPLE *fzf-preview-mappings*
Here is mapping example.
>
nnoremap p :FzfPreviewProjectFiles
nnoremap b :FzfPreviewBuffers
nnoremap