From 90789c13bded47eebb8e6493403953c2c432063f Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Tue, 31 Oct 2023 10:41:17 +0800 Subject: [PATCH] New docs --- .github/workflows/docs.yml | 10 +- README.md | 326 +----------------- crates/maple_core/src/config.rs | 35 +- .../src/stdio_server/handler/on_move.rs | 2 +- .../src/stdio_server/plugin/markdown.rs | 35 +- .../src/stdio_server/provider/mod.rs | 2 +- docs/src/README.md | 6 + docs/src/plugins/plugins.md | 44 ++- docs/src/providers/intro.md | 45 ++- 9 files changed, 126 insertions(+), 379 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index fab42df69..9df22fec5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,4 +1,4 @@ -name: CI +name: Docs on: push: @@ -8,7 +8,7 @@ on: jobs: build: - name: Build, Test and Deploy + name: Build, Test and Deploy Docs runs-on: ubuntu-latest permissions: contents: write # To push a branch @@ -19,8 +19,8 @@ jobs: with: toolchain: stable - run: (test -x $HOME/.cargo/bin/mdbook || cargo install --vers "^0.4" mdbook) - - run: mdbook build docs && mdbook test docs # In case of custom book path: mdbook build path/to/mybook && mdbook test path/to/mybook + - run: mdbook build docs && mdbook test docs - uses: JamesIves/github-pages-deploy-action@4.1.7 with: - branch: gh-pages # The branch the action should deploy to. - folder: docs/book # The folder the action should deploy. + branch: gh-pages + folder: docs/book diff --git a/README.md b/README.md index ccaa407ec..0387d8f2a 100644 --- a/README.md +++ b/README.md @@ -4,344 +4,22 @@ [![CI](https://github.com/liuchengxu/vim-clap/workflows/ci/badge.svg)](https://github.com/liuchengxu/vim-clap/actions?workflow=ci) [![Gitter][g1]][g2] -[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/liuchengxu) [g1]: https://badges.gitter.im/liuchengxu/vim-clap.svg [g2]: https://gitter.im/liuchengxu/vim-clap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge -Vim-clap is a modern generic performant finder using the `floating_win` of neovim or `popup` of vim, powered by an external backend written in Rust. +Vim-clap stands as a comprehensive and efficient solution, providing powerful fuzzy pickers and replacements for various established Vim plugins, designed to support both Vim and NeoVim.

-[>>>> More screenshots](https://github.com/liuchengxu/vim-clap/issues/1) - -## Table of Contents - - - -* [Features](#features) -* [Caveats](#caveats) -* [Requirement](#requirement) -* [Installation](#installation) - * [vim-plug](#vim-plug) -* [Usage](#usage) - * [Commands](#commands) - * [Providers](#providers) - * [Global variables](#global-variables) - * [Keybindings](#keybindings) - * [Insert mode](#insert-mode) - * [NeoVim only](#neovim-only) - * [Normal mode](#normal-mode) - * [Cmdline mode](#cmdline-mode) - * [Execute some code during the process](#execute-some-code-during-the-process) - * [Change highlights](#change-highlights) - * [Search syntax](#search-syntax) - * [Fzf search syntax](#fzf-search-syntax) - * [Extended search syntax](#extended-search-syntax) - * [Config file](#config-file) -* [How to define your own provider](#how-to-define-your-own-provider) -* [Disable auto-completion plugin in clap input window](#disable-auto-completion-plugin-in-clap-input-window) -* [Contribution](#contribution) -* [Credit](#credit) -* [License](#license) - - - -## Features - -- [x] ~~Pure vimscript~~. - - Pin to some early version of vim-clap if you prefer the pure vimscript plugin. -- [x] ~~Work out of the box, without any extra dependency~~. - - The Rust binary is now a must-have to make everything work smoothly. -- [x] Blazingly fast thanks to the powerful Rust backend. -- [x] Consistent command interface with [clap-rs/clap](https://github.com/clap-rs/clap) -- [x] Support writing new providers in both Vimscript and Rust. -- [x] Support [the search syntax borrowed from fzf](https://github.com/junegunn/fzf#search-syntax) and more. -- [x] Flexible UI layout. -- [ ] Support searching by multiple providers simultaneously. - -## Caveats - -- Vim-clap is in a very early stage, breaking changes and bugs are expected. - -- The Windows support is not fully tested. The providers without using any system related command should work smoothly, that is to say, most sync providers are just able to work. Please [create an issue](https://github.com/liuchengxu/vim-clap/issues/new?assignees=&labels=&template=bug_report.md&title=) if you run into any error in Windows. And any help would be appreciated. - -- Although a lot of effort has been made to unify the behavior of vim-clap between vim and neovim, and most part works in the same way, it just can't be exactly the same, for `floating_win` and `popup` are actually two different things anyway. - -## Usage - -Vim-clap is utterly easy to use, just type, press Ctrl-J/K to locate the wanted entry, and press Enter to apply and exit. The default settings should work well for most people in most cases, but it's absolutely hackable too. - -### Commands - -The paradigm is `Clap [provider_id_or_alias] {provider_args}`, where the `provider_id_or_alias` is obviously either the name or alias of provider. Technically the `provider_id` can be anything that can be used a key of a Dict, but I recommend you using an _identifier_ like name as the provider id, and use the alias rule if you prefer a special name. - -#### Providers - -| Command | List | Requirement | -| :------------------------------------- | :----------------------------------------------------- | :---------------------------------------------------------------------- | -| `Clap blines` | Lines in the current buffer | _none_ | -| `Clap buffers` | Open buffers | _none_ | -| `Clap colors` | Colorschemes | _none_ | -| `Clap command` | Command | _none_ | -| `Clap hist:` or `Clap command_history` | Command history | _none_ | -| `Clap hist/` or `Clap search_history` | Search history | _none_ | -| `Clap filetypes` | File types | _none_ | -| `Clap help_tags` | Help tags | _none_ | -| `Clap jumps` | Jumps | _none_ | -| `Clap lines` | Lines in the loaded buffers | _none_ | -| `Clap marks` | Marks | _none_ | -| `Clap maps` | Maps | _none_ | -| `Clap quickfix` | Entries of the quickfix list | _none_ | -| `Clap loclist` | Entries of the location list | _none_ | -| `Clap registers` | Registers | _none_ | -| `Clap yanks` | Yank stack of the current vim session | _none_ | -| `Clap history` | Open buffers and `v:oldfiles` | _none_ | -| `Clap windows` | Windows | _none_ | -| `Clap providers` | List the vim-clap providers | _none_ | -| `Clap bcommits` | Git commits for the current buffer | **[git][git]** | -| `Clap commits` | Git commits | **[git][git]** | -| `Clap gfiles` or `Clap git_files` | Files managed by git | **[git][git]** | -| `Clap git_diff_files` | Files managed by git and having uncommitted changes | **[git][git]** | -| `Clap live_grep`**+** | Grep using word-regexp matcher | **[rg][rg]** | -| `Clap dumb_jump` | Definitions/References using regexp with grep fallback | **[rg][rg]** with `--pcre2` | -| `Clap files` | Files | **[maple][maple]** | -| `Clap filer` | Ivy-like file explorer | **[maple][maple]** | -| `Clap grep`**+** | Grep using fuzzy matcher | **[maple][maple]** | -| `Clap igrep` | A combo of `filer` and `grep` | **[maple][maple]** | -| `Clap tags` | Tags in the current buffer | **[maple][maple]** | -| `Clap tagfiles` | Search existing `tagfiles` | **[maple][maple]** | -| `Clap proj_tags` | Tags in the current project | **[maple][maple]** and **[universal-ctags][universal-ctags]** (`+json`) | -| `Clap recent_files` | Persistent ordered history of recent files | **[maple][maple]** | - -[rg]: https://github.com/BurntSushi/ripgrep -[git]: https://github.com/git/git -[maple]: https://github.com/liuchengxu/vim-clap/blob/master/INSTALL.md#maple-binary -[universal-ctags]: https://github.com/universal-ctags/ctags - -- The command with a superscript `!` means that it is not yet implemented or not tested. -- The command with a superscript `+` means that it supports multi-selection via Tab. -- `:Clap grep` - - Use `:Clap grep --query=` to grep the word under cursor. - - Use `:Clap grep --query=@visual` to grep the visual selection. - - `cwd` will be searched by default, specify the extra paths in the end to search multiple directories. - - `:Clap grep --path ~/.vim/plugged/ale` with `cwd` is `~/.vim/plugged/vim-clap` will both search vim-clap and ale. - -[Send a pull request](https://github.com/liuchengxu/vim-clap/pulls) if you want to get your provider listed here. - -### Global variables - -- `g:clap_layout`: Dict, `{ 'width': '67%', 'height': '33%', 'row': '33%', 'col': '17%' }` by default. This variable controls the size and position of vim-clap window. By default, the vim-clap window is placed relative to the currently active window. To make it relative to the whole editor modify this variable as shown below: - - ```vim - let g:clap_layout = { 'relative': 'editor' } - ``` - -- `g:clap_open_action`: Dict, `{ 'ctrl-t': 'tab split', 'ctrl-x': 'split', 'ctrl-v': 'vsplit' }`, extra key bindings for opening the selected file in a different way. NOTE: do not define a key binding which is conflicted with the other default bindings of vim-clap, and only `ctrl-*` is supported for now. - -- `g:clap_provider_alias`: Dict, if you don't want to invoke some clap provider by its id(name), as it's too long or somehow, you can add an alias for that provider. - - ```vim - " The provider name is `command_history`, with the following alias config, - " now you can call it via both `:Clap command_history` and `:Clap hist:`. - let g:clap_provider_alias = {'hist:': 'command_history'} - ``` - -- `g:clap_selected_sign`: Dict, `{ 'text': ' >', 'texthl': "ClapSelectedSign", "linehl": "ClapSelected"}`. - -- `g:clap_current_selection_sign`: Dict, `{ 'text': '>>', 'texthl': "ClapCurrentSelectionSign", "linehl": "ClapCurrentSelection"}`. - -- `g:clap_no_matches_msg`: String, `'NO MATCHES FOUND'`, message to show when there is no matches found. - -- `g:clap_popup_input_delay`: Number, `200ms` by default, delay for actually responsing to the input, vim only. - -- `g:clap_disable_run_rooter`: Bool, `v:false`, vim-clap by default will try to run from the project root by changing `cwd` temporarily. Set it to `v:true` to run from the origin `cwd`. The project root here means the git base directory. Create an issue if you want to see more support about the project root. - -The option naming convention for provider is `g:clap_provider_{provider_id}_{opt}`. - -- `g:clap_provider_grep_blink`: [2, 100] by default, blink 2 times with 100ms timeout when jumping the result. Set it to [0, 0] to disable the blink. - -- `g:clap_provider_grep_opts`: An empty string by default, allows you to enable flags such as `'--hidden -g "!.git/"'`. - -See `:help clap-options` for more information. - -### Keybindings - -#### Insert mode - -- [x] Use Ctrl-j/Down or Ctrl-k/Up to navigate the result list up and down linewise. -- [x] Use PageDown/PageUp to scroll the result list down and up. -- [x] Use Ctrl-a/Home to go to the start of the input. -- [x] Use Ctrl-e/End to go to the end of the input. -- [x] Use Ctrl-c, Ctrl-g, Ctrl-[ or Esc(vim) to exit. -- [x] Use Ctrl-h/BS to delete previous character. -- [x] Use Ctrl-d to delete next character. -- [x] Use Ctrl-b to move cursor left one character. -- [x] Use Ctrl-f to move cursor right one character. -- [x] Use Ctrl-n for next input in the history. -- [x] Use Ctrl-p for previous input in the history. -- [x] Use Enter to select the entry and exit. - - Use Enter to expand the directory or edit the file for `:Clap filer`. -- [x] By default Alt-u does nothing. - - Use Alt-u to go up one directory in `:Clap filer`. -- [x] Use Tab to select multiple entries and open them using the quickfix window.(Need the provider has `sink*` support) - - Use Tab to expand the directory for `:Clap filer`. -- [x] Use Ctrl-t or Ctrl-x, Ctrl-v to open the selected entry in a new tab or a new split. -- [x] Use Ctrl-u to clear inputs. -- [x] Use Ctrl-l to launch the whole provider list panel for invoking another provider at any time. -- [x] Use Shift-Tab to invoke the action dialog(vim only). -- [x] Use Shift-up and Shift-down to scroll the preview. - -#### NeoVim only - -##### Normal mode - -- [x] Use j/Down or k/Up to navigate the result list up and down linewise. -- [x] By default Alt-u does nothing. - - Use Alt-u to go up one directory in `:Clap filer`. -- [x] Use Ctrl-c, Ctrl-g or Esc to exit. -- [x] Use Ctrl-d/Ctrl-u/PageDown/PageUp to scroll the result list down and up. -- [x] Use Ctrl-l to launch the whole provider list panel for invoking another provider at any time. -- [x] Use Ctrl-n for next input in the history. -- [x] Use Ctrl-p for previous input in the history. -- [x] Use Shift-up and Shift-down to scroll the preview. -- [x] Use gg and G to scroll to the first and last item. -- [x] Use Enter to select the entry and exit. -- [x] Use Shift-Tab to invoke the action dialog. -- [x] Actions defined by `g:clap_open_action`. - -##### Cmdline mode - -- [x] Use `:q` to exit. - -See `:help clap-keybindings` for more information. Note that the [keybindings are not consistent](https://github.com/liuchengxu/vim-clap/issues/864) due to discrepancies between Vim/Neovim and different providers. - -### Execute some code during the process - -```vim -augroup YourGroup - autocmd! - autocmd User ClapOnEnter call YourFunction() - autocmd User ClapOnExit call YourFunction() -augroup END -``` - -### Change highlights - -By default vim-clap will use the colors extracted from your colorscheme, which is not guaranteed to suitable for all the colorschemes. Then you can try the built-in `material_design_dark` theme then: - -```vim -let g:clap_theme = 'material_design_dark' -``` - -![clap-highlights](https://user-images.githubusercontent.com/8850248/74818883-6cfdc380-533a-11ea-81fb-d09d90498c96.png) - -You could also set `g:clap_theme` to be a `Dict` to specify the palette: - -```vim -" Change the CamelCase of related highlight group name to under_score_case. -let g:clap_theme = { 'search_text': {'guifg': 'red', 'ctermfg': 'red'} } -``` - -`ClapDisplay` and `ClapPreview` are the most basic highlight groups for the display and preview window, which can be overrided if the provider has its own syntax highlight, then checkout the related [syntax](syntax) file for more granular highlights directly. - -If you want to write your own clap theme, take [autoload/clap/themes/material_design_dark.vim](autoload/clap/themes/material_design_dark.vim) as a reference. - -See `:help clap-highlights` for more information. - -### Search syntax - -#### Fzf search syntax - -vim-clap adopts the almost all fzf search syntax, please refer to [the search syntax section of fzf's README](https://github.com/junegunn/fzf#search-syntax) for more details. Note that the OR operator defined by a single bar character is not yet implemented, but you can achieve that by using multiple exact matches. - -#### Extended search syntax - -Apart from the basic fzf search syntax, more search syntax are supported: - -| Token | Match type | Description | -| ------ | ---------- | ------------------------------------------------------------ | -| `"cli` | word-match | Items that match word `cli` (`clippy` does not match `"cli`) | - -### Config file - -User config file is loaded from: - -- Linux: `~/.config/vimclap/config.toml` -- macOS: `~/Library/Application\ Support/org.vim.Vim-Clap/config.toml` -- Windows: `C:\Users\Alice\AppData\Roaming\Vim\Vim Clap\config\config.toml` - -```toml -[log] -# Note that the log file path must be an absolute path. -log-file = "/tmp/clap.log" -max-level = "debug" - -[matcher] -# There are four sort keys for results: score, begin, end, length, -# you can specify how the records are sorted using `tiebreak`. -tiebreak = "score,-begin,-end,-length" -``` - - - - - - - - - - - -## How to define your own provider - -```vim -" `:Clap quick_open` to open some dotfiles quickly. -" `description` is actually optional, but if you want to show this provider -" when you call `:Clap`, the `description` is neccessary. -let g:clap_provider_quick_open = { - \ 'source': ['~/.vimrc', '~/.spacevim', '~/.bashrc', '~/.tmux.conf'], - \ 'sink': 'e', - \ 'description': 'Quick open some dotfiles', - \ } -``` - -Find more examples at [wiki/Examples](https://github.com/liuchengxu/vim-clap/wiki/Examples). - -For complete guide about writing a clap provider please see [PROVIDER.md](PROVIDER.md). - -## Disable auto-completion plugin in clap input window - -Some of the auto-completion engines need to turn off to prevent bizarre behaviors(#580) - -For nvim-completion, add autocmd to your init.vim: - -```vim -autocmd FileType clap_input let g:completion_enable_auto_pop = 0 -``` - -For nvim-compe: - -```vim -autocmd FileType clap_input call compe#setup({ 'enabled': v:false }, 0) -``` +[User facing documentation and guide](https://liuchengxu.github.io/vim-clap) ## Contribution Vim-clap is still in beta. Any kinds of contributions are highly welcome. -If you would like to see support for more providers or share your own provider, please [create an issue](https://github.com/liuchengxu/vim-clap/issues) or [create a pull request](https://github.com/liuchengxu/vim-clap/pulls). - -If you'd liked to discuss the project more directly, check out [![][g1]][g2]. - -## Credit - -- Vim-clap is initially enlightened by [snails](https://github.com/manateelazycat/snails). -- Some providers' idea and code are borrowed from [fzf.vim](https://github.com/junegunn/fzf.vim). -- The built-in fzy python implementation is based on [sweep.py](https://github.com/aslpavel/sweep.py). - ## [License](LICENSE) MIT diff --git a/crates/maple_core/src/config.rs b/crates/maple_core/src/config.rs index 26a26b1ce..d472fc227 100644 --- a/crates/maple_core/src/config.rs +++ b/crates/maple_core/src/config.rs @@ -78,17 +78,6 @@ impl MatcherConfig { } } -#[derive(Serialize, Deserialize, Debug, Default)] -#[serde(rename_all = "kebab-case", default, deny_unknown_fields)] -pub struct PickerConfig { - /// Specifies how many items will be displayed in the results window. - pub max_display_size: Option, - /// Render the preview highlight with specified theme using syntect backend. - /// - /// If the theme is not found, the default theme (`Visual Studio Dark+`) will be used. - pub syntect_highlight_theme: Option, -} - #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "kebab-case", default, deny_unknown_fields)] pub struct LogConfig { @@ -172,10 +161,10 @@ pub struct LinterPluginConfig { #[serde(rename_all = "kebab-case", default, deny_unknown_fields)] pub struct PluginConfig { pub cursorword: CursorWordConfig, - pub markdown: MarkdownPluginConfig, pub ctags: CtagsPluginConfig, pub git: GitPluginConfig, pub linter: LinterPluginConfig, + pub markdown: MarkdownPluginConfig, } #[derive(Serialize, Deserialize, Debug, Default)] @@ -215,13 +204,17 @@ pub struct ProviderConfig { /// Priorities of the ignore config: /// provider_ignores > provider_ignores > global_ignore pub ignore: HashMap, -} -#[derive(Serialize, Deserialize, Debug, Default)] -#[serde(rename_all = "kebab-case", default, deny_unknown_fields)] -pub struct InputHistoryConfig { + /// Specifies how many items will be displayed in the results window. + pub max_display_size: Option, + + /// Render the preview highlight with specified theme using syntect backend. + /// + /// If the theme is not found, the default theme (`Visual Studio Dark+`) will be used. + pub syntect_highlight_theme: Option, + /// Whether to share the input history of each provider. - pub share_all_inputs: bool, + pub share_input_history: bool, } #[derive(Serialize, Deserialize, Debug, Default)] @@ -233,9 +226,6 @@ pub struct Config { /// Matcher configuration. pub matcher: MatcherConfig, - /// Picker configuration. - pub picker: PickerConfig, - /// Plugin configuration. pub plugin: PluginConfig, @@ -249,9 +239,6 @@ pub struct Config { /// /// The project path must be specified as absolute path or a path relative to the home directory. pub project_ignore: HashMap, - - /// Input history configuration - pub input_history: InputHistoryConfig, } impl Config { @@ -294,7 +281,7 @@ mod tests { [matcher] tiebreak = "score,-begin,-end,-length" - [plugin.cursor-word-highlighter] + [plugin.cursorword] enable = true [provider.debounce] diff --git a/crates/maple_core/src/stdio_server/handler/on_move.rs b/crates/maple_core/src/stdio_server/handler/on_move.rs index 1c4006bdb..c17c51a8c 100644 --- a/crates/maple_core/src/stdio_server/handler/on_move.rs +++ b/crates/maple_core/src/stdio_server/handler/on_move.rs @@ -480,7 +480,7 @@ impl<'a> CachedPreviewImpl<'a> { // 1 (header line) + 1 (1-based line number) let line_number_offset = context_lines.len() + 1 + 1; let maybe_line_highlights = if let Some(theme) = - &crate::config::config().picker.syntect_highlight_theme + &crate::config::config().provider.syntect_highlight_theme { const THEME: &str = "Visual Studio Dark+"; let theme = if HIGHLIGHTER.theme_exists(theme) { diff --git a/crates/maple_core/src/stdio_server/plugin/markdown.rs b/crates/maple_core/src/stdio_server/plugin/markdown.rs index 9b13ffb4e..fcf9fae5b 100644 --- a/crates/maple_core/src/stdio_server/plugin/markdown.rs +++ b/crates/maple_core/src/stdio_server/plugin/markdown.rs @@ -1,5 +1,5 @@ use crate::stdio_server::input::{AutocmdEvent, PluginAction}; -use crate::stdio_server::plugin::ClapPlugin; +use crate::stdio_server::plugin::{ClapPlugin, Toggle}; use crate::stdio_server::vim::Vim; use anyhow::{anyhow, Result}; use once_cell::sync::Lazy; @@ -201,17 +201,37 @@ fn find_toc_range(input_file: impl AsRef) -> std::io::Result Self { - Self { vim } + Self { + vim, + toggle: Toggle::Off, + } + } + + async fn update_toc(&self, bufnr: usize) -> Result<()> { + let file = self.vim.bufabspath(bufnr).await?; + if let Some((start, end)) = find_toc_range(&file)? { + let shiftwidth = self.vim.getbufvar("", "&shiftwidth").await?; + // TODO: skip update if the new doc is the same as the old one. + let new_toc = generate_toc(file, start + 1, shiftwidth)?; + self.vim.deletebufline(bufnr, start + 1, end + 1).await?; + self.vim.exec("append_and_write", json!([start, new_toc]))?; + } + Ok(()) } } #[async_trait::async_trait] impl ClapPlugin for MarkdownPlugin { async fn handle_autocmd(&mut self, _autocmd: AutocmdEvent) -> Result<()> { + if self.toggle.is_off() { + return Ok(()); + } + Ok(()) } @@ -219,8 +239,8 @@ impl ClapPlugin for MarkdownPlugin { let PluginAction { method, params: _ } = action; match method.as_str() { Self::GENERATE_TOC => { - let curlnum = self.vim.line(".").await?; let file = self.vim.current_buffer_path().await?; + let curlnum = self.vim.line(".").await?; let shiftwidth = self.vim.getbufvar("", "&shiftwidth").await?; let mut toc = generate_toc(file, curlnum, shiftwidth)?; let prev_line = self.vim.curbufline(curlnum - 1).await?; @@ -231,15 +251,8 @@ impl ClapPlugin for MarkdownPlugin { .exec("append_and_write", json!([curlnum - 1, toc]))?; } Self::UPDATE_TOC => { - let file = self.vim.current_buffer_path().await?; let bufnr = self.vim.bufnr("").await?; - if let Some((start, end)) = find_toc_range(&file)? { - let shiftwidth = self.vim.getbufvar("", "&shiftwidth").await?; - // TODO: skip update if the new doc is the same as the old one. - let new_toc = generate_toc(file, start + 1, shiftwidth)?; - self.vim.deletebufline(bufnr, start + 1, end + 1).await?; - self.vim.exec("append_and_write", json!([start, new_toc]))?; - } + self.update_toc(bufnr).await?; } Self::DELETE_TOC => { let file = self.vim.current_buffer_path().await?; diff --git a/crates/maple_core/src/stdio_server/provider/mod.rs b/crates/maple_core/src/stdio_server/provider/mod.rs index 33bfb39dc..9ba9bfdd5 100644 --- a/crates/maple_core/src/stdio_server/provider/mod.rs +++ b/crates/maple_core/src/stdio_server/provider/mod.rs @@ -325,7 +325,7 @@ impl Context { }; let input_history = crate::datastore::INPUT_HISTORY_IN_MEMORY.lock(); - let inputs = if crate::config::config().input_history.share_all_inputs { + let inputs = if crate::config::config().provider.share_input_history { input_history.all_inputs() } else { input_history.inputs(&env.provider_id) diff --git a/docs/src/README.md b/docs/src/README.md index 0884f2407..0d5e9636d 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -30,3 +30,9 @@ Vim-clap was initially written in pure VimScript, but later incorporated a Rust - While Vim-clap is intended to be compatible with Windows, comprehensive testing on this platform has not been conducted to the same extent as macOS and Linux (specifically Ubuntu), as the plugin author primarily utilizes these operating systems. Consequently, there may be Windows-specific issues yet to be identified. If you encounter any problems on Windows, please [create an issue](https://github.com/liuchengxu/vim-clap/issues/new?assignees=&labels=&template=bug_report.md&title=), and any assistance in addressing these issues would be highly appreciated. - While Vim-Clap strives to offer equal support for both Vim and NeoVim, certain nuances arise from the differing implementation details between the two. For example, the focusability of Vim's `popup` differs from NeoVim's `floating_win`. + +## Credit + +- Vim-clap is initially enlightened by [snails](https://github.com/manateelazycat/snails). +- Some providers' idea and code are borrowed from [fzf.vim](https://github.com/junegunn/fzf.vim). +- The built-in fzy python implementation is based on [sweep.py](https://github.com/aslpavel/sweep.py). diff --git a/docs/src/plugins/plugins.md b/docs/src/plugins/plugins.md index f525ea41f..3430f569c 100644 --- a/docs/src/plugins/plugins.md +++ b/docs/src/plugins/plugins.md @@ -1,5 +1,15 @@ # Available Plugins + + +* [ctags](#ctags) +* [cursorword](#cursorword) +* [git](#git) +* [linter](#linter) +* [markdown](#markdown) + + + ## ctags - Alternatives @@ -12,14 +22,9 @@ enable = true ``` -- Features - - highlight the word under the cursor. - -- Alternatives - - [vim_current_word](https://github.com/dominikduda/vim_current_word) - - [vim-illuminate](https://github.com/RRethy/vim-illuminate) - - [vim-cursorword](https://github.com/itchyny/vim-cursorword) - - [vim-brightest](https://github.com/osyo-manga/vim-brightest) +| Features | Alternatives | +| :------------------------------------- | :----------------------------------------------------- | +| Highlight the word under the cursor | [nvim-blame-line](https://github.com/tveskag/nvim-blame-line)
[vim-illuminate](https://github.com/RRethy/vim-illuminate)
[vim-cursorword](https://github.com/itchyny/vim-cursorword)
[vim-brightest](https://github.com/osyo-manga/vim-brightest) | ## git @@ -28,12 +33,27 @@ enable = true enable = true ``` +| Features | Alternatives | +| :------------------------------------- | :----------------------------------------------------- | +| Show blame info at the end of line | [nvim-blame-line](https://github.com/tveskag/nvim-blame-line) | +| Open the permalink of current line in browser | _none_ | + +## linter + +```toml +[plugin.linter] +enable = true +``` + - Features - - Show blame info at the end of line + - Lint files asynchronously - Alternatives - - [nvim-blame-line](https://github.com/tveskag/nvim-blame-line) - -## linter + - [ale](https://github.com/dense-analysis/ale) ## markdown + +```toml +[plugin.markdown] +enable = true +``` diff --git a/docs/src/providers/intro.md b/docs/src/providers/intro.md index 1e65d6407..129255039 100644 --- a/docs/src/providers/intro.md +++ b/docs/src/providers/intro.md @@ -1,5 +1,15 @@ # Clap Providers + + +* [Builtin Providers](#builtin-providers) + * [Global Variables](#global-variables) +* [How to Create Your Own Provider](#how-to-create-your-own-provider) +* [Disable Auto-Completion Plugin in Clap Input Window](#disable-auto-completion-plugin-in-clap-input-window) + + + + ## Builtin Providers Additional requirement means the potential extra tool needed for the particular provider besides the Rust binary [`maple`](../guide/install_rust.md). @@ -54,7 +64,7 @@ Additional requirement means the potential extra tool needed for the particular [Send a pull request](https://github.com/liuchengxu/vim-clap/pulls) if certain provider is not listed here. -### Global variables +### Global Variables - `g:clap_layout`: Dict, `{ 'width': '67%', 'height': '33%', 'row': '33%', 'col': '17%' }` by default. This variable controls the size and position of vim-clap window. By default, the vim-clap window is placed relative to the currently active window. To make it relative to the whole editor modify this variable as shown below: @@ -89,3 +99,36 @@ The option naming convention for provider is `g:clap_provider_{provider_id}_{opt - `g:clap_provider_grep_opts`: An empty string by default, allows you to enable flags such as `'--hidden -g "!.git/"'`. See `:help clap-options` for more information. + +## How to Create Your Own Provider + +```vim +" `:Clap quick_open` to open some dotfiles quickly. +" `description` is actually optional, but if you want to show this provider +" when you call `:Clap`, the `description` is neccessary. +let g:clap_provider_quick_open = { + \ 'source': ['~/.vimrc', '~/.spacevim', '~/.bashrc', '~/.tmux.conf'], + \ 'sink': 'e', + \ 'description': 'Quick open some dotfiles', + \ } +``` + +Find more examples at [wiki/Examples](https://github.com/liuchengxu/vim-clap/wiki/Examples). + +For complete guide about writing a clap provider please see [PROVIDER.md](PROVIDER.md). + +## Disable Auto-Completion Plugin in Clap Input Window + +Some of the auto-completion engines need to turn off to prevent bizarre behaviors(#580) + +For nvim-completion, add autocmd to your init.vim: + +```vim +autocmd FileType clap_input let g:completion_enable_auto_pop = 0 +``` + +For nvim-compe: + +```vim +autocmd FileType clap_input call compe#setup({ 'enabled': v:false }, 0) +```