Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hrsh7th/vim-candle
Candidates listing engine for vim/nvim built on yaegi on golang.
https://github.com/hrsh7th/vim-candle
vim vim-plugin
Last synced: 10 days ago
JSON representation
Candidates listing engine for vim/nvim built on yaegi on golang.
- Host: GitHub
- URL: https://github.com/hrsh7th/vim-candle
- Owner: hrsh7th
- Created: 2020-01-12T07:50:58.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-15T01:20:37.000Z (over 1 year ago)
- Last Synced: 2024-08-07T18:46:43.228Z (3 months ago)
- Topics: vim, vim-plugin
- Language: Vim Script
- Homepage:
- Size: 369 KB
- Stars: 12
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
vim-candle
===Any candidates listing engine for vim/nvim built on [yaegi](https://github.com/containous/yaegi).
Status
===- Works
- Not documented
- APIs aren't stable
- Tested only in macRequirements
===- vim
- exists('*win_exeute')- nvim
- exists('deletebufline')Concept
===### Performance
- filtering written in golang.
- virtual scroll.### Works on vim/neovim
- use `job` API only.### Use function
- because the commands can't pass complex object.Setting
===```viml
augroup vimrc
autocmd!
augroup END"
" global mapping
"
nnoremap k :call candle#mapping#toggle()
nnoremap n :call candle#mapping#action_next('default')
nnoremap p :call candle#mapping#action_prev('default')"
" mapping for candle buffer
"
autocmd vimrc User candle#start call s:on_candle_start()
function! s:on_candle_start()
nnoremap k :call candle#mapping#cursor_move(-1)
nnoremap j :call candle#mapping#cursor_move(1)
nnoremap K :call candle#mapping#cursor_move(-10)
nnoremap J :call candle#mapping#cursor_move(10)
nnoremap gg :call candle#mapping#cursor_top()
nnoremap G :call candle#mapping#cursor_bottom()
nnoremap - :call candle#mapping#toggle_select()
nnoremap * :call candle#mapping#toggle_select_all()
nnoremap i :call candle#mapping#input_open()
nnoremap a :call candle#mapping#input_open()
nnoremap :call candle#mapping#choose_action()
nnoremap :call candle#mapping#restart()nnoremap :call candle#mapping#action('default')
nnoremap s :call candle#mapping#action('split')
nnoremap v :call candle#mapping#action('vsplit')
nnoremap d :call candle#mapping#action('delete')
endfunction"
" mapping for candle.input buffer
"
autocmd vimrc User candle#input#start call s:on_candle_input_start()
function! s:on_candle_input_start()
cnoremap :call candle#mapping#choose_action()
cnoremap :call candle#mapping#action('default')
cnoremap :call candle#mapping#cursor_move(-1) \| call candle#mapping#input_open()
cnoremap :call candle#mapping#cursor_move(+1) \| call candle#mapping#input_open()
endfunction```
# Recipes
### mru files
Recently opened files (and exclude displayed files).
```viml
nnoremap mru_file :call candle#start({
\ 'mru_file': {
\ 'ignore_patterns': map(range(1, tabpagewinnr(tabpagenr(), '$')), { i, winnr ->
\ fnamemodify(bufname(winbufnr(winnr)), ':p')
\ })
\ }
\ })
```### mru projects
Recently projects (When choose one project, listing all files).
```viml
nnoremap mru_project :call candle#start({
\ 'mru_dir': {},
\ }, {
\ 'action': {
\ 'default': { candle -> [
\ execute('quit'),
\ win_gotoid(candle.prev_winid),
\ candle#start({
\ 'source': 'file',
\ 'params': {
\ 'root_path': candle.get_action_items()[0].path,
\ 'ignore_patterns': ['.git/', 'node_modules'],
\ }
\ })
\ ] }
\ }
\ })
```### files
All files under specified root.
```viml
nnoremap file :call candle#start({
\ 'file': {
\ 'root_path': 'path to root dir',
\ 'ignore_patterns': ['.git/', 'node_modules'],
\ }
\ })
```### grep
Invoke ripgrep/ag/pt/jvgrep/grep.
You can specify your custom grep command.
```viml
nnoremap grep :call candle#start({
\ 'grep': {
\ 'root_path': 'path to root dir',
\ 'pattern': input('PATTERN: '),
\ 'command': [
\ 'rg',
\ '-i',
\ '--vimgrep',
\ '--no-heading',
\ '--no-column',
\ ] + map([
\ '.git',
\ '.svn',
\ 'image/',
\ 'vendor/',
\ 'node_modules/',
\ ], { _, v -> printf('--glob=!%s', v) }) + [
\ '-e',
\ '%PATTERN%',
\ '%ROOT_PATH%',
\ ]
\ }
\ })
```### grep + [vim-qfreplace](https://github.com/thinca/vim-qfreplace)
Modify grep results with qfreplace.
```viml
function! s:qfreplace_accept(candle) abort
return len(filter(a:candle.get_action_items()), { _, item ->
\ !has_key(item, 'path') || !has_key(item, 'lnum') || !has_key(item, 'text')
\ }) == 0
endfunctionfunction! s:qfreplace_invoke(candle) abort
call setqflist(map(a:candle.get_action_items(), { _, item -> {
\ 'filename': item.path,
\ 'lnum': item.lnum,
\ 'text': item.text
\ } }))
call qfreplace#start('')
endfunctioncall candle#action#register({
\ 'name': 'qfreplace',
\ 'accept': function('s:qfreplace_accept'),
\ 'invoke': function('s:qfreplace_invoke'),
\ })
```### menus
Your custom menu.
```viml
nnoremap menu :call candle#start({
\ 'item': [{
\ 'id': 1,
\ 'title': 'PlugUpdate',
\ 'execute': 'PlugUpdate'
\ }, {
\ 'id': 2,
\ 'title': 'Open .vimrc',
\ 'execute': 'vsplit $MYVIMRC'
\ }]
\ }, {
\ 'action': {
\ 'default': { candle -> execute(candle.get_cursor_item().execute) }
\ }
\ })
```