mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 00:50:05 +08:00
Improve foldsearch layer (#3492)
This commit is contained in:
parent
d0fe6fcda1
commit
b181a3542f
@ -31,6 +31,28 @@ function! SpaceVim#layers#foldsearch#config()
|
||||
\ ]
|
||||
\ ],
|
||||
\ 1)
|
||||
let lnum = expand('<slnum>') + s:lnum - 1
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['F', 'W'], 'call call('
|
||||
\ . string(s:_function('s:foldsearch_cursor')) . ', [])',
|
||||
\ ['foldsearch-cword',
|
||||
\ [
|
||||
\ 'SPC F W is to foldsearch cursor word',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||
\ ]
|
||||
\ ],
|
||||
\ 1)
|
||||
let lnum = expand('<slnum>') + s:lnum - 1
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['F', 'e'], 'call call('
|
||||
\ . string(s:_function('s:foldsearch_expr')) . ', [])',
|
||||
\ ['foldsearch-regexp',
|
||||
\ [
|
||||
\ 'SPC F e is to foldsearch regular expression',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||
\ ]
|
||||
\ ],
|
||||
\ 1)
|
||||
endfunction
|
||||
|
||||
function! s:foldsearch_word() abort
|
||||
@ -40,6 +62,20 @@ function! s:foldsearch_word() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:foldsearch_cursor() abort
|
||||
let word = expand('<cword>')
|
||||
if !empty(word)
|
||||
call SpaceVim#plugins#foldsearch#word(word)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:foldsearch_expr() abort
|
||||
let word = input('foldsearch expr >')
|
||||
if !empty(word)
|
||||
call SpaceVim#plugins#foldsearch#expr(word)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" function() wrapper
|
||||
if v:version > 703 || v:version == 703 && has('patch1170')
|
||||
function! s:_function(fstr) abort
|
||||
|
@ -10,7 +10,7 @@ let s:JOB = SpaceVim#api#import('job')
|
||||
let s:matched_lines = []
|
||||
|
||||
function! SpaceVim#plugins#foldsearch#word(word)
|
||||
let argv = ['rg', '--line-number', a:word]
|
||||
let argv = ['rg', '--line-number', '--fixed-strings', a:word]
|
||||
call s:foldsearch(argv)
|
||||
endfunction
|
||||
|
||||
|
@ -27,8 +27,12 @@ lang: zh
|
||||
name = "foldsearch"
|
||||
```
|
||||
|
||||
该模块依赖于命令:[ripgrep](https://github.com/BurntSushi/ripgrep)。
|
||||
|
||||
## 快捷键
|
||||
|
||||
| 快捷键 | 功能描述 |
|
||||
| --------- | --------------- |
|
||||
| `SPC F w` | Foldsearch word |
|
||||
| 快捷键 | 功能描述 |
|
||||
| --------- | ----------------------------- |
|
||||
| `SPC F w` | foldsearch input word |
|
||||
| `SPC F W` | foldsearch cursor word |
|
||||
| `SPC F e` | foldsearch regular expression |
|
||||
|
@ -7,23 +7,32 @@ description: "This layer provides functions that fold away lines that don't matc
|
||||
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
|
||||
- [Description](#description)
|
||||
- [Intro](#intro)
|
||||
- [Install](#install)
|
||||
- [Key bindings](#key-bindings)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
## Description
|
||||
## Intro
|
||||
|
||||
This layer provides functions that fold away lines that don't match a specific search pattern.
|
||||
The search pattern can be a word or a regular expression. To enable this layer:
|
||||
The search pattern can be a word or a regular expression.
|
||||
|
||||
## Install
|
||||
|
||||
To use this layer, add it to your configuration file.
|
||||
|
||||
```toml
|
||||
[layers]
|
||||
name = "foldsearch"
|
||||
```
|
||||
|
||||
This layer requires [ripgrep](https://github.com/BurntSushi/ripgrep).
|
||||
|
||||
## Key bindings
|
||||
|
||||
| Key bindings | Description |
|
||||
| ------------ | --------------------- |
|
||||
| `SPC F w` | foldsearch input word |
|
||||
| Key bindings | Description |
|
||||
| ------------ | ----------------------------- |
|
||||
| `SPC F w` | foldsearch input word |
|
||||
| `SPC F W` | foldsearch cursor word |
|
||||
| `SPC F e` | foldsearch regular expression |
|
||||
|
Loading…
Reference in New Issue
Block a user