Comments (11)
In the example we created a new command, but you can also add a new mapping for FzfPreviewBuffers.
By default, the following settings are made for the processor.
let default = {
\ '': function('fzf_preview#resource_processor#edit'),
\ 'ctrl-x': function('fzf_preview#resource_processor#split'),
\ 'ctrl-v': function('fzf_preview#resource_processor#vsplit'),
\ 'ctrl-t': function('fzf_preview#resource_processor#vsplit'),
\ 'ctrl-q': function('fzf_preview#resource_processor#export_quickfix'),
\ }
Therefore, after passing the created processor to set_processor_once,
Start FzfPreviewBuffers and change the mapping.
Example
function! s:buffers_delete_from_paths(paths) abort
for path in a:paths
execute 'bdelete! ' . path
endfor
endfunction
let g:buffer_delete_processor = {
\ '': function('fzf_preview#resource_processor#edit'),
\ 'ctrl-s': function('fzf_preview#resource_processor#split'),
\ 'ctrl-v': function('fzf_preview#resource_processor#vsplit'),
\ 'ctrl-t': function('fzf_preview#resource_processor#vsplit'),
\ 'ctrl-q': function('fzf_preview#resource_processor#export_quickfix'),
\ 'ctrl-x': function('s:buffers_delete_from_paths'),
\ }
nnoremap <silent> <Leader>b :<C-u>call fzf_preview#resource_processor#set_processor_once(g:buffer_delete_processor)<CR>:FzfPreviewBuffers<CR>
from fzf-preview.vim.
I checked the :CocCommand fzf-preview.Buffers
with the following settings, and I'm able to remove the buffer without any problems.
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']
from fzf-preview.vim.
Thank you.
I would consider adding features.
from fzf-preview.vim.
I am considering adding an opener(processor?) to determine how to handle the selected resource.
Since it will be possible to pass the process to be performed to the resource selected from the outside, I think that it can be realized by deleting the buffer there.
from fzf-preview.vim.
Processing can be passed by merging #52.
For example, if you want to do bdelete, you can write like this.
function! s:buffers_delete_from_paths(paths) abort
for path in a:paths
execute 'bdelete! ' . path
endfor
endfunction
function! s:fzf_preview_buffer_delete() abort
call fzf_preview#resource_processor#set_processor_once({'': function('<SID>buffers_delete_from_paths')})
FzfPreviewBuffers
endfunction
command! FzfPreviewBufferDelete call s:fzf_preview_buffer_delete()
How about that? @rlisowski
from fzf-preview.vim.
I'm new to fzf-preview but interested in closing buffers as well. One question about the solution: with the current implementation one has to call a different function FzfPreviewBufferDelete
do be able to delete the buffer? I think it would be way more convenient if one could delete buffers out of the "normal" FzfPreviewBuffer
list by using a shortcut (like C-x
opens the selected file in a new split)
from fzf-preview.vim.
I changed the concept, you can pass processor as an argument when running the command.
An example looks like this.
function! s:buffers_delete_from_paths(paths) abort
for path in a:paths
execute 'bdelete! ' . path
endfor
endfunction
let g:fzf_preview_buffer_delete_processors = fzf_preview#resource_processor#get_default_processors()
let g:fzf_preview_buffer_delete_processors['ctrl-x'] = function('s:buffers_delete_from_paths')
nnoremap <silent> <Leader>b :<C-u>FzfPreviewBuffers -processors=g:fzf_preview_buffer_delete_processors<CR>
Fixed
from fzf-preview.vim.
Tested it and it works pretty well, thanks a lot for the super fast response and the fix.
Just in case anyone else is interested in this: be sure to use a different "buffer closing" command (like :Bdelete
from https://github.com/moll/vim-bbye) then the default :bdelete
. Otherwise your entire session will be closed if the buffer is currently open when you try to close it.
from fzf-preview.vim.
Works perfect. Thanks.
from fzf-preview.vim.
Sorry for re commenting here but does this still work with the new coc version of fzf preview? I tried <C-q>
as suggested in the Readme but this puts the buffer to the quickfix window. I'd like to call FzfPreviewBuffers
and then close some of the listed buffers there with a shortcut.
from fzf-preview.vim.
Thanks for the quick response!
let g:coc_global_extensions = ['coc-fzf-preview']
This line was missing in my config and now it works as expected!
from fzf-preview.vim.
Related Issues (20)
- Document opening multiple files with TAB in preview window HOT 1
- [Feature Request] Open all files in fzf-preview HOT 2
- FZF search history feature request HOT 3
- [Question] $FZF_PREVIEW_PREVIEW_BAT_THEME has no effect? HOT 6
- Live grep HOT 3
- Ctags error
- Bunch of unknown characters showing on the first line HOT 2
- Support fzf_preview_command when doing ProjectGrep HOT 1
- Preview's highligt-line may not work in Vim HOT 4
- If the path of a file in the buffer list contains space, Bat preview fails
- FromResources aborts when any of the resources fail to load
- Issue when installing in Win 10
- bufferlines not working properly when working directory changed
- Feature request: add ability to use nerdfont.vim plugin to display filetype icons
- fish: Command substitutions not allowed HOT 1
- Use of ctags is hard coded as a constant HOT 1
- Older versions of Node throwing SyntaxError: Unexpected token '?' HOT 2
- Feature idea: include additional file search paths that are normally ignored by git / ripgrep
- Use project commands like `:FzfPreviewProjectFiles` and `:FzfPreviewProjectMruFiles` on non-git repos HOT 2
- :CocCommand fzf-preview.ProjectGrep . doesn't respect .gitignore
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fzf-preview.vim.