GithubHelp home page GithubHelp logo

Comments (11)

yuki-yano avatar yuki-yano commented on June 5, 2024 2

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.

yuki-yano avatar yuki-yano commented on June 5, 2024 1

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.

yuki-yano avatar yuki-yano commented on June 5, 2024

Thank you.
I would consider adding features.

from fzf-preview.vim.

yuki-yano avatar yuki-yano commented on June 5, 2024

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.

yuki-yano avatar yuki-yano commented on June 5, 2024

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.

tuxflo avatar tuxflo commented on June 5, 2024

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.

yuki-yano avatar yuki-yano commented on June 5, 2024

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.

tuxflo avatar tuxflo commented on June 5, 2024

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.

rlisowski avatar rlisowski commented on June 5, 2024

Works perfect. Thanks.

from fzf-preview.vim.

tuxflo avatar tuxflo commented on June 5, 2024

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.

tuxflo avatar tuxflo commented on June 5, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.