diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index dda07746d..207bdeb50 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -3,8 +3,8 @@ name: ci
on: [push, pull_request]
jobs:
- cpoptions_checker:
- name: Check cpoptions
+ vimscript:
+ name: VimScript
runs-on: ubuntu-latest
strategy:
fail-fast: false
@@ -14,16 +14,6 @@ jobs:
uses: actions/checkout@v2
- name: Ensure each vim source file declares cpoptions
run: test/autoload_should_check_cpo.sh
-
- vint:
- name: Vint
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
-
- steps:
- - name: Checkout
- uses: actions/checkout@v2
- name: Run vint with reviewdog
uses: reviewdog/action-vint@v1
with:
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
new file mode 100644
index 000000000..b729f0180
--- /dev/null
+++ b/.github/workflows/docs.yml
@@ -0,0 +1,24 @@
+name: Docs
+
+on:
+ push:
+ branches: [ master ]
+
+jobs:
+ build:
+ name: Build, Test and Deploy
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write # To push a branch
+ pull-requests: write # To create a PR from that branch
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions-rs/toolchain@v1
+ with:
+ toolchain: stable
+ - run: (test -x $HOME/.cargo/bin/mdbook || cargo install --vers "^0.4" mdbook)
+ - run: mdbook build docs && mdbook test docs
+ - uses: JamesIves/github-pages-deploy-action@4.1.7
+ with:
+ branch: gh-pages
+ folder: docs/book
diff --git a/Cargo.lock b/Cargo.lock
index 4db45ddc8..7ce945f42 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -177,7 +177,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05"
dependencies = [
"memchr",
- "regex-automata",
+ "regex-automata 0.3.8",
"serde",
]
@@ -1686,14 +1686,14 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.9.5"
+version = "1.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
+checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
dependencies = [
"aho-corasick 1.0.4",
"memchr",
- "regex-automata",
- "regex-syntax 0.7.5",
+ "regex-automata 0.4.3",
+ "regex-syntax 0.8.2",
]
[[package]]
@@ -1701,10 +1701,16 @@ name = "regex-automata"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
+
+[[package]]
+name = "regex-automata"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
dependencies = [
"aho-corasick 1.0.4",
"memchr",
- "regex-syntax 0.7.5",
+ "regex-syntax 0.8.2",
]
[[package]]
@@ -1719,6 +1725,12 @@ version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
+[[package]]
+name = "regex-syntax"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
+
[[package]]
name = "reqwest"
version = "0.11.19"
diff --git a/README.md b/README.md
index 705ad922b..0387d8f2a 100644
--- a/README.md
+++ b/README.md
@@ -4,372 +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.
-
-## Requirement
-
-- Vim: `:echo has('patch-8.1.2114')`.
-- NeoVim: `:echo has('nvim-0.4.2')`.
-
-## Installation
-
-### [vim-plug](https://github.com/junegunn/vim-plug)
-
-```vim
-" Build the Rust binary if `cargo` exists on your system.
-Plug 'liuchengxu/vim-clap', { 'do': ':Clap install-binary' }
-
-" The bang version will try to download the prebuilt binary if `cargo` does not exist.
-Plug 'liuchengxu/vim-clap', { 'do': ':Clap install-binary!' }
-
-" `:Clap install-binary[!]` will always try to compile the binary locally.
-" If you do care about the disk used for the compilation, use the way of force download,
-" which will directly download the prebuilt binary even if `cargo` is available.
-Plug 'liuchengxu/vim-clap', { 'do': { -> clap#installer#force_download() } }
-
-" `:Clap install-binary[!]` will run using the terminal feature which is inherently async.
-" If you don't want that and hope to run the hook synchorously:
-Plug 'liuchengxu/vim-clap', { 'do': has('win32') ? 'cargo build --release' : 'make' }
-```
-
-It's recommended to install the Rust binary automatically via the `do` hook. If that does not work for you, please refer to [INSTALL.md](INSTALL.md) for installing it manually.
-
-## 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/autoload/clap/floating_win.vim b/autoload/clap/floating_win.vim
index e4e89df50..598a39904 100644
--- a/autoload/clap/floating_win.vim
+++ b/autoload/clap/floating_win.vim
@@ -471,7 +471,7 @@ function! clap#floating_win#preview.show(lines) abort
let max_size = s:max_preview_size()
if max_size <= 0
- call g:clap#floating_win#preview.close()
+ call self.close()
return
endif
let lines = a:lines[:max_size]
@@ -482,8 +482,7 @@ function! clap#floating_win#preview.show(lines) abort
if clap#preview#direction() !=# 'LR'
let opts = nvim_win_get_config(s:preview_winid)
if opts.height != height
- let opts.height = height
- call nvim_win_set_config(s:preview_winid, opts)
+ call nvim_win_set_height(s:preview_winid, height)
endif
endif
endif
@@ -499,7 +498,7 @@ endfunction
function! clap#floating_win#preview.hide() abort
if !clap#preview#is_always_open()
- call g:clap#floating_win#preview.close()
+ call self.close()
endif
endfunction
diff --git a/autoload/clap/plugin/highlight_cursor_word.vim b/autoload/clap/plugin/cursorword.vim
similarity index 52%
rename from autoload/clap/plugin/highlight_cursor_word.vim
rename to autoload/clap/plugin/cursorword.vim
index c9cb61203..321e846f8 100644
--- a/autoload/clap/plugin/highlight_cursor_word.vim
+++ b/autoload/clap/plugin/cursorword.vim
@@ -1,23 +1,24 @@
" Author: liuchengxu
+" Highlight the cursor word and the occurrences
let s:save_cpo = &cpoptions
set cpoptions&vim
hi ClapUnderline gui=underline cterm=underline
-hi default link ClapCurrentWord IncSearch
-hi default link ClapCurrentWordTwins ClapUnderline
+hi default link ClapCursorWord IncSearch
+hi default link ClapCursorWordTwins ClapUnderline
-function! clap#plugin#highlight_cursor_word#add_highlights(word_highlights) abort
+function! clap#plugin#cursorword#add_highlights(word_highlights) abort
let cword_len = a:word_highlights.cword_len
let match_ids = []
let [lnum, col] = a:word_highlights.cword_highlight
- let match_id = matchaddpos('ClapCurrentWord', [[lnum, col+1, cword_len]])
+ let match_id = matchaddpos('ClapCursorWord', [[lnum, col+1, cword_len]])
if match_id > -1
call add(match_ids, match_id)
endif
- for [lnum, col] in a:word_highlights.other_words_highlight
- let match_id = matchaddpos('ClapCurrentWordTwins', [[lnum, col+1, cword_len]])
+ for [lnum, col] in a:word_highlights.twins_words_highlight
+ let match_id = matchaddpos('ClapCursorWordTwins', [[lnum, col+1, cword_len]])
if match_id > -1
call add(match_ids, match_id)
endif
diff --git a/autoload/clap/plugin/linter.vim b/autoload/clap/plugin/linter.vim
index 34c885cab..1ce0605e2 100644
--- a/autoload/clap/plugin/linter.vim
+++ b/autoload/clap/plugin/linter.vim
@@ -90,7 +90,7 @@ function! s:render_on_top_right(lines, line_highlights) abort
" Make sure the diagnostic win won't interfere with the existing code
" display.
let max_available_on_top = s:max_available_length_on_top()
- if width > max_available_on_top
+ if max_available_on_top > 0 && width > max_available_on_top
let width = max_available_on_top
let height += 1
endif
diff --git a/autoload/clap/state.vim b/autoload/clap/state.vim
index 929443ed6..7a73e8c4d 100644
--- a/autoload/clap/state.vim
+++ b/autoload/clap/state.vim
@@ -134,7 +134,6 @@ function! clap#state#render_preview(preview) abort
endif
if has_key(a:preview, 'scrollbar')
- let g:scrollbar = copy(a:preview.scrollbar)
let [top_position, length] = a:preview.scrollbar
call clap#floating_win#show_preview_scrollbar(top_position, length)
endif
diff --git a/crates/linter/src/lib.rs b/crates/linter/src/lib.rs
index 3c6f44f7b..7f9af4155 100644
--- a/crates/linter/src/lib.rs
+++ b/crates/linter/src/lib.rs
@@ -128,6 +128,7 @@ pub fn find_workspace(filetype: impl AsRef, source_file: &Path) -> Option<&
("rust", RootMarkers(&["Cargo.toml"])),
("sh", ParentOfSourceFile),
("vim", ParentOfSourceFile),
+ ("markdown", ParentOfSourceFile),
])
});
diff --git a/crates/linter/src/linters/go.rs b/crates/linter/src/linters/go.rs
index 4b71cfe0e..64a82f045 100644
--- a/crates/linter/src/linters/go.rs
+++ b/crates/linter/src/linters/go.rs
@@ -6,7 +6,7 @@ use std::path::Path;
// /home/xlc/Data0/src/github.com/ethereum-optimism/optimism/op-node/rollup/superchain.go:38:27-43: undefined: eth.XXXXSystemConfig
static RE: Lazy = Lazy::new(|| {
Regex::new(r"(?m)^([^:]+):([0-9]+):([0-9]+)-([0-9]+): (.+)$")
- .expect("Regex for parsing gopls output must be correct otherwise the format is changed")
+ .expect("Regex for parsing gopls output must be correct otherwise the upstream format must have been changed")
});
pub async fn run_gopls(source_file: &Path, workspace_root: &Path) -> std::io::Result {
diff --git a/crates/maple_core/src/config.rs b/crates/maple_core/src/config.rs
index 41259f1df..c82bfe551 100644
--- a/crates/maple_core/src/config.rs
+++ b/crates/maple_core/src/config.rs
@@ -55,7 +55,7 @@ pub fn config_file() -> &'static PathBuf {
CONFIG_FILE.get().expect("Config file uninitialized")
}
-#[derive(Serialize, Deserialize, Debug)]
+#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct MatcherConfig {
pub tiebreak: String,
@@ -78,18 +78,7 @@ 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)]
+#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct LogConfig {
pub log_file: Option,
@@ -105,9 +94,9 @@ impl Default for LogConfig {
}
}
-#[derive(Serialize, Deserialize, Debug)]
+#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
-pub struct CursorWordHighlighterConfig {
+pub struct CursorWordConfig {
/// Whether to enable this plugin.
pub enable: bool,
/// Whether to ignore the comment line
@@ -116,7 +105,7 @@ pub struct CursorWordHighlighterConfig {
pub ignore_files: String,
}
-impl Default for CursorWordHighlighterConfig {
+impl Default for CursorWordConfig {
fn default() -> Self {
Self {
enable: false,
@@ -126,21 +115,21 @@ impl Default for CursorWordHighlighterConfig {
}
}
-#[derive(Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug, Default, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct MarkdownPluginConfig {
/// Whether to enable this plugin.
pub enable: bool,
}
-#[derive(Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug, Default, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct CtagsPluginConfig {
/// Whether to enable this plugin.
pub enable: bool,
}
-#[derive(Serialize, Deserialize, Debug)]
+#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct GitPluginConfig {
/// Whether to enable this plugin.
@@ -161,24 +150,24 @@ impl Default for GitPluginConfig {
}
}
-#[derive(Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug, Default, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct LinterPluginConfig {
/// Whether to enable this plugin.
pub enable: bool,
}
-#[derive(Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug, Default, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct PluginConfig {
- pub cursor_word_highlighter: CursorWordHighlighterConfig,
- pub markdown: MarkdownPluginConfig,
+ pub cursorword: CursorWordConfig,
pub ctags: CtagsPluginConfig,
pub git: GitPluginConfig,
pub linter: LinterPluginConfig,
+ pub markdown: MarkdownPluginConfig,
}
-#[derive(Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug, Default, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct IgnoreConfig {
/// Whether to ignore the comment line when it's possible.
@@ -191,7 +180,7 @@ pub struct IgnoreConfig {
pub ignore_file_path_pattern: Vec,
}
-#[derive(Serialize, Deserialize, Debug, Default)]
+#[derive(Serialize, Deserialize, Debug, Default, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct ProviderConfig {
/// Delay in milliseconds before the user query will be handled actually.
@@ -215,16 +204,20 @@ 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)]
+#[derive(Serialize, Deserialize, Debug, Default, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct Config {
/// Log configuration.
@@ -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]
@@ -312,7 +299,44 @@ mod tests {
"#;
let user_config: Config =
toml::from_str(toml_content).expect("Failed to deserialize config");
- println!("{:#?}", user_config);
- println!("{}", toml::to_string(&user_config).unwrap());
+
+ assert_eq!(
+ user_config,
+ Config {
+ log: LogConfig {
+ log_file: Some("/tmp/clap.log".to_string()),
+ max_level: "trace".to_string()
+ },
+ matcher: MatcherConfig {
+ tiebreak: "score,-begin,-end,-length".to_string()
+ },
+ plugin: PluginConfig {
+ cursorword: CursorWordConfig {
+ enable: true,
+ ..Default::default()
+ },
+ ..Default::default()
+ },
+ provider: ProviderConfig {
+ debounce: HashMap::from_iter([
+ ("*".to_string(), 200),
+ ("files".to_string(), 100)
+ ]),
+ ignore: HashMap::from([(
+ "dumb_jump".to_string(),
+ IgnoreConfig {
+ ignore_comments: true,
+ ..Default::default()
+ }
+ )]),
+ ..Default::default()
+ },
+ global_ignore: IgnoreConfig {
+ ignore_file_path_pattern: vec!["test".to_string(), "build".to_string()],
+ ..Default::default()
+ },
+ ..Default::default()
+ }
+ );
}
}
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/mod.rs b/crates/maple_core/src/stdio_server/mod.rs
index cea4f7775..f812b1901 100644
--- a/crates/maple_core/src/stdio_server/mod.rs
+++ b/crates/maple_core/src/stdio_server/mod.rs
@@ -9,8 +9,8 @@ mod vim;
pub use self::input::InputHistory;
use self::input::{ActionEvent, Event, ProviderEvent};
use self::plugin::{
- ActionType, ClapPlugin, CtagsPlugin, CursorWordHighlighter, GitPlugin, LinterPlugin,
- MarkdownPlugin, PluginId, SyntaxHighlighterPlugin, SystemPlugin,
+ ActionType, ClapPlugin, CtagsPlugin, CursorWordPlugin, GitPlugin, LinterPlugin, MarkdownPlugin,
+ PluginId, SyntaxHighlighterPlugin, SystemPlugin,
};
use self::provider::{create_provider, Context};
use self::service::ServiceManager;
@@ -117,8 +117,8 @@ pub async fn start(config_err: Option) {
register_plugin(Box::new(MarkdownPlugin::new(vim.clone())), None);
}
- if plugin_config.cursor_word_highlighter.enable {
- register_plugin(Box::new(CursorWordHighlighter::new(vim.clone())), None);
+ if plugin_config.cursorword.enable {
+ register_plugin(Box::new(CursorWordPlugin::new(vim.clone())), None);
}
tokio::spawn({
diff --git a/crates/maple_core/src/stdio_server/plugin/ctags.rs b/crates/maple_core/src/stdio_server/plugin/ctags.rs
index 3266d0eca..d6c7ae192 100644
--- a/crates/maple_core/src/stdio_server/plugin/ctags.rs
+++ b/crates/maple_core/src/stdio_server/plugin/ctags.rs
@@ -43,6 +43,7 @@ impl CtagsPlugin {
}
}
+ /// Updates the buffer variable `clap_current_symbol`.
async fn on_cursor_moved(&mut self, bufnr: usize) -> Result<()> {
if let Some(buffer_tags) = self.buf_tags.get(&bufnr) {
let curlnum = self.vim.line(".").await?;
@@ -101,11 +102,7 @@ impl ClapPlugin for CtagsPlugin {
let (event_type, params) = autocmd;
- let params: Vec = params.parse()?;
- let bufnr = params
- .into_iter()
- .next()
- .ok_or_else(|| anyhow::anyhow!("bufnr not found in params"))?;
+ let bufnr = params.parse_bufnr()?;
match event_type {
BufEnter | BufWritePost => {
diff --git a/crates/maple_core/src/stdio_server/plugin/cursor_word_highlighter.rs b/crates/maple_core/src/stdio_server/plugin/cursorword.rs
similarity index 89%
rename from crates/maple_core/src/stdio_server/plugin/cursor_word_highlighter.rs
rename to crates/maple_core/src/stdio_server/plugin/cursorword.rs
index 1cb81acf2..81bb19cde 100644
--- a/crates/maple_core/src/stdio_server/plugin/cursor_word_highlighter.rs
+++ b/crates/maple_core/src/stdio_server/plugin/cursorword.rs
@@ -11,9 +11,9 @@ use utils::read_lines_from;
#[derive(Debug, serde::Serialize)]
struct WordHighlights {
// (line_number, highlight_col_start)
- other_words_highlight: Vec<(usize, usize)>,
+ twins_words_highlight: Vec<(usize, usize)>,
cword_highlight: (usize, usize),
- // highlight length.
+ // highlight length, in bytes.
cword_len: usize,
}
@@ -40,11 +40,13 @@ fn find_word_highlights(
) -> std::io::Result