Coder Social home page Coder Social logo

ddu-kind-file's Introduction

ddu-kind-file's People

Contributors

erw7 avatar jrudess avatar matsui54 avatar milly avatar ogaken-1 avatar ryota2357 avatar shougo avatar uga-rosa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ddu-kind-file's Issues

Odd behavior with filer

Problems summary

newFile, rename, trash are breaks tree-view.

Please see the below movie.

2022-11-20.23.58.50.mov
  1. Start ddu.
  2. Create new file hoge/fuga/bar.txt with newFile
  3. Delete hoge/fuga/bar.txt with trash
  4. Rename hoge/fuga/foo.txt to hoge/fuga/foo1.txt with rename

Expected

Does not breaks the tree-view.

Environment Information

:version
NVIM v0.8.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

      システム vimrc: "$VIM/sysinit.vim"
       省略時の $VIM: "/opt/homebrew/Cellar/neovim/0.8.1/share/nvim"

Run :checkhealth for more info
  • macOS 13.0.1
  • All plugins are up-to-date.

Provide a minimal init.vim/vimrc with less than 50 lines (Required!)

let s:plugins = [
      \ 'vim-denops/denops.vim',
      \ 'Shougo/ddu.vim',
      \ 'Shougo/ddu-ui-filer',
      \ 'ryota2357/ddu-column-icon_filename',
      \ 'Shougo/ddu-column-filename',
      \ 'Shougo/ddu-source-file',
      \ 'Shougo/ddu-kind-file',
      \ ]

for item in s:plugins
  execute 'set runtimepath+=~/.cache/dein/repos/github.com/' . item
endfor

call ddu#custom#patch_global({
    \   'ui': 'filer',
    \   'sources': [{'name': 'file', 'params': {}}],
    \   'resume': v:true,
    \   'sourceOptions': {
    \     '_': {
    \       'columns': ['icon_filename'],
    \     },
    \   },
    \   'kindOptions': {
    \     'file': {
    \       'defaultAction': 'open',
    \     },
    \   }
    \ })

autocmd FileType ddu-filer call s:ddu_my_settings()
function! s:ddu_my_settings() abort
  nnoremap <buffer><expr><silent><CR> ddu#ui#filer#is_tree()
    \ ? "<Cmd>call ddu#ui#filer#do_action('expandItem', {'mode': 'toggle'})<CR>"
    \ : "<Cmd>call ddu#ui#filer#do_action('itemAction')<CR>"
  nnoremap <buffer><silent> q <Cmd>call ddu#ui#filer#do_action('quit')<CR>
  nnoremap <buffer> n <Cmd>call ddu#ui#filer#do_action('itemAction', { 'name': 'newFile' })<CR>
  nnoremap <buffer> r <Cmd>call ddu#ui#filer#do_action('itemAction', { 'name': 'rename' })<CR>
  nnoremap <buffer> d <Cmd>call ddu#ui#filer#do_action('itemAction', { 'name': 'trash' })<CR>
endfunction

In the movie, I use icon_filename for ddu-column, but the same problem occurs with filename

fold is not enabled when opening file in insert mode

I have noticed that the settings for each file type configured in dein's ftplugin are not being loaded when I open by ddu.vim.

The minimum configuration is the following two files, but essentially init.vim alone should probably suffice. The last line hooks :echom to the FileType event

  • init.vim
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim

call dein#begin('/tmp/dein')
  call dein#add('vim-denops/denops.vim')
  call dein#add('Shougo/ddu.vim')
  call dein#add('Shougo/ddu-ui-ff')
  call dein#add('Shougo/ddu-source-file_rec')
  call dein#add('Shougo/ddu-kind-file')
  call dein#load_toml('~/.config/minimal/ftplugin.toml')
call dein#end()

call ddu#custom#patch_global({
      \ 'sources': [{'name': 'file_rec'}],
      \ 'ui': 'ff',
      \ 'uiParams': {
      \   'ff': {
      \     'startFilter': v:true,
      \   },
      \ },
      \ 'kindOptions': {
      \   '_': {
      \     'defaultAction': 'open',
      \   },
      \ },
      \})

augroup my-ddu-ff
  autocmd!
  autocmd FileType ddu-ff        call <SID>ddu_ff_mapping()
  autocmd FileType ddu-ff-filter call <SID>ddu_ff_filter_mapping()
augroup END

function! s:ddu_ff_mapping() abort
  nnoremap <buffer><silent> <CR> <Cmd>call ddu#ui#do_action('itemAction')<CR>
endfunction

function! s:ddu_ff_filter_mapping() abort
  inoremap <buffer><silent> <CR> <Cmd>call ddu#ui#do_action('itemAction')<CR>
  inoremap <buffer><silent> <C-n> <Cmd>call ddu#ui#ff#execute('normal! j')<CR>
  inoremap <buffer><silent> <C-p> <Cmd>call ddu#ui#ff#execute('normal! k')<CR>
endfunction

" Indent by 4 spaces
set tabstop=4
set shiftwidth=4
set expandtab

" Show cursorline
set cursorline

autocmd FileType * echom &ft
  • ftplugin.toml
[ftplugin]

toml = '''
    set foldmethod=expr
    set foldexpr=<SID>fold_expr(v:lnum)

    function! s:fold_expr(lnum) abort
      let line = getline(a:lnum)
      return line ==# '' || line[0:3] ==# '    '
    endfunction
'''

Reproduce steps:

  • Place these two files in XDG_CONFIG_HOME/minimal/.
  • Open neovim ($ NVIM_APPNAME=minimal nvim).
  • Start ddu (:call ddu#start({}))
  • You are already in the filter because startFilter is set to v:true.
  • Select ftplugin.toml with <C-n>/<C-p> and open it with <CR> (these three are mapped in insert mode).
  • You can see that the contents of toml are not folded.
  • If you close the filter and open it from ddu-ff (I do nmap to <CR>), you will see that it is properly folded.

Feature request: Able to specify the method of the executeSystem.

Sometimes I want to call wslview as a priority over vim.ui.open.
Currently, ddu#kind#file#open does a good job of selecting the system calls that are available in the environment,
but in some cases, I would like to control the priority from the config.
Is it possible to achieve this with an actionParams or something like that?
I would like to be able to specify a parameter like "method" in the actionParams of executeSystem.

e.g.:

call ddu#custom#patch_global({
    \ "actionParams": {
        \ "executeSystem": {
            \ "method": "wslview" # calls wslview.exe
        \ }
    \ }
})
call ddu#custom#patch_global({
    \ "actionParams": {
        \ "executeSystem": {
            \ "method": "neovim" # uses vim.ui.open
        \ }
    \ }
})
call ddu#custom#patch_global({
    \ "actionParams": {
        \ "executeSystem": {
            \ "method": "gnome" # calls gnome-open
        \ }
    \ }
})
call ddu#custom#patch_global({
    \ "actionParams": {
        \ "executeSystem": {
            \ "method": "wincmd-rundll32" # calls rundll32 over cmd.exe
        \ }
    \ }
})

cannot delete/trash file

minimal setting

set runtimepath^=path/to/ddu.vim
set runtimepath^=path/to/ddu-ui-ff
set runtimepath^=path/to/ddu-source-file_rec
set runtimepath^=path/to/ddu-kind-file

augroup Ddu
  autocmd!
  autocmd FileType ddu-ff nnoremap <buffer> d <Cmd>call ddu#ui#ff#do_action('itemAction', {'name': 'delete'})<CR>
augroup END

call ddu#custom#patch_global({
      \ 'sources': [{'name': 'file_rec'}],
      \ 'ui': 'ff',
      \ })

instruction

  1. start vim
  2. :call ddu#start()
  3. move cursor file that I will delete
  4. press d
  5. show error message
Screen.Recording.2022-11-27.at.2.07.03.mov

error message

Error detected while processing function ddu#ui#ff#do_action[13]..ddu#ui_action[1]..ddu#_request[22]..denops#request[1]..denops#server#request[6]..<SNR>27_request:                                                                   
line    1:
Error invoking 'invoke' on channel 4:
Error: Failed to call 'uiAction' with ["default","itemAction",{"name":"delete"}]: Error: Failed to call 'call' with ["ddu#item_action","default","delete",[{"word":"tmp","action":{"path":"/Users/solenoid/LocalProject/neovim_minimal/tmp","isD
irectory":false},"kind":"file","matcherKey":"tmp","__sourceIndex":0,"__sourceName":"file_rec","__level":0,"__expanded":false}],{}]: Error: Failed to call 'nvim_call_function' with ["ddu#item_action",["default","delete",[{"word":"tmp","actio
n":{"path":"/Users/solenoid/LocalProject/neovim_minimal/tmp","isDirectory":false},"kind":"file","matcherKey":"tmp","__sourceIndex":0,"__sourceName":"file_rec","__level":0,"__expanded":false}],{}]]: [0,"Vim(return):Error invoking 'invoke' on
 channel 4:\nError: Failed to call 'itemAction' with [\"default\",\"delete\",[{\"word\":\"tmp\",\"__sourceName\":\"file_rec\",\"action\":{\"path\":\"/Users/solenoid/LocalProject/neovim_minimal/tmp\",\"isDirectory\":false},\"__level\":0,\"ki
nd\":\"file\",\"__expanded\":false,\"matcherKey\":\"tmp\",\"__sourceIndex\":0}],{}]: Error: Failed to call 'call' with [\"ddu#kind#file#confirm\",\"Are you sure you want to delete /Users/solenoid/LocalProject/neovim_minimal/tmp?\",\"&Yes\\n
&No\\n&Cancel\",2]: Error: Failed to call 'nvim_call_function' with [\"ddu#kind#file#confirm\",[\"Are you sure you want to delete /Users/solenoid/LocalProject/neovim_minimal/tmp?\",\"&Yes\\n&No\\n&Cancel\",2]]: [0,\"Vim:E117: Unknown functi
on: ddu#kind#file#confirm\"]\n    at Session.call (https://deno.land/x/[email protected]/session.ts:207:13)\n    at async Session.call (file:///Users/solenoid/.cache/dein/repos/github.com/vim-denops/denops.vim/denops/@denops-private/servic
e.ts:170:14)\n    at async Session.dispatch (https://deno.land/x/[email protected]/session.ts:99:12)\n    at async https://deno.land/x/[email protected]/session.ts:108:18\n    at async Session.handleRequest (https://deno.land/x/msgpack_rp
[email protected]/session.ts:104:29)\n    at Session.call (https://deno.land/x/[email protected]/session.ts:207:13)\n    at async DenopsImpl.call (file:///Users/solenoid/.cache/dein/repos/github.com/vim-denops/denops.vim/denops/@denops/impl.ts:34:1
2)\n    at async delete (file:///Users/solenoid/.cache/dein/repos/github.com/Shougo/ddu-kind-file/denops/@ddu-kinds/file.ts:111:23)\n    at async Ddu.itemAction (file:///Users/solenoid/.cache/dein/repos/github.com/Shougo/ddu.vim/denops/ddu/
ddu.ts:735:19)\n    at async Session.itemAction (file:///Users/solenoid/.cache/dein/repos/github.com/Shougo/ddu.vim/denops/ddu/app.ts:247:7)\n    at async Session.dispatch (https://deno.land/x/[email protected]/session.ts:99:12)\n    at as
ync https://deno.land/x/[email protected]/session.ts:108:18\n    at async Session.handleRequest (https://deno.land/x/[email protected]/session.ts:104:29)\n    at Session.call (https://deno.land/x/[email protected]/session.ts:207:13)\n   
 at async Service.dispatch (file:///Users/solenoid/.cache/dein/repos/github.com/vim-denops/denops.vim/denops/@denops-private/service.ts:124:14)\n    at async Session.invoke (file:///Users/solenoid/.cache/dein/repos/github.com/vim-denops/den
ops.vim/denops/@denops-private/host/nvim.ts:53:16)\n    at async Session.dispatch (https://deno.land/x/[email protected]/session.ts:99:12)\n    at async https://deno.land/x/[email protected]/session.ts:108:18\n    at async Session.handleR
equest (https://deno.land/x/[email protected]/session.ts:104:29)"]
    at Session.call (https://deno.land/x/[email protected]/session.ts:207:13)
    at async Session.call (file:///Users/solenoid/.cache/dein/repos/github.com/vim-denops/denops.vim/denops/@denops-private/service.ts:170:14)
    at async Session.dispatch (https://deno.land/x/[email protected]/session.ts:99:12)
    at async https://deno.land/x/[email protected]/session.ts:108:18
    at async Session.handleRequest (https://deno.land/x/[email protected]/session.ts:104:29)
    at Session.call (https://deno.land/x/[email protected]/session.ts:207:13)
    at async DenopsImpl.call (file:///Users/solenoid/.cache/dein/repos/github.com/vim-denops/denops.vim/denops/@denops/impl.ts:34:12)
    at async itemAction (file:///Users/solenoid/.cache/dein/repos/github.com/Shougo/ddu-ui-ff/denops/@ddu-uis/ff.ts:592:7)
    at async Ddu.uiAction (file:///Users/solenoid/.cache/dein/repos/github.com/Shougo/ddu.vim/denops/ddu/ddu.ts:550:19)
    at async Session.uiAction (file:///Users/solenoid/.cache/dein/repos/github.com/Shougo/ddu.vim/denops/ddu/app.ts:233:7)
    at async Session.dispatch (https://deno.land/x/[email protected]/session.ts:99:12)
    at async https://deno.land/x/[email protected]/session.ts:108:18
    at async Session.handleRequest (https://deno.land/x/[email protected]/session.ts:104:29)
    at Session.call (https://deno.land/x/[email protected]/session.ts:207:13)
    at async Service.dispatch (file:///Users/solenoid/.cache/dein/repos/github.com/vim-denops/denops.vim/denops/@denops-private/service.ts:124:14)
    at async Session.invoke (file:///Users/solenoid/.cache/dein/repos/github.com/vim-denops/denops.vim/denops/@denops-private/host/nvim.ts:53:16)
    at async Session.dispatch (https://deno.land/x/[email protected]/session.ts:99:12)
    at async https://deno.land/x/[email protected]/session.ts:108:18
    at async Session.handleRequest (https://deno.land/x/[email protected]/session.ts:104:29)

Location list support

Sometime back I submitted a pull-request which added location-list support for denite. I've started making the same update for ddu in a commit located at https://github.com/jrudess/ddu-kind-file/commit/613bd03f9d3f459dbfe1ae09680bf2c4da4fc555

With Denite, I retrieved the window number using the following API:

  wininfo = self._vim.call('denite#helper#_get_wininfo')
  self.vim.call('setloclist', wininfo['winnr'], qfloclist)

Do you have a similar API for ddu? For now I've just got a hard-coded constant buffer number.

  // TODO: Need correct buffer number
  const winnr = await fn.bufwinnr(args.denops, 1);
  await fn.setloclist(args.denops, winnr, qfloclist, " ");

`buflisted` is not set after the second time

problem

If I open a file with itemAction open and delete its buffer with :bdelete, when I try to open the same file again, buflisted is not set.

1. call ddu#start()
2. call ddu#ui#do_action('itemAction') " name: 'open'
3. set buflisted? " -> buflisted
4. bdelete

5. call ddu#start()
6. call ddu#ui#do_action('itemAction') " name: 'open'
7. set buflisted? " -> nobuflisted
_AppData_Local_nvim-ddu.2023-08-04.16-01-42.mp4

environment

NVIM v0.10.0-dev-753+g4a06de40e
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
  • Windows 11

init.vim

let s:plugins = [
    \ 'vim-denops/denops.vim',
    \ 'Shougo/ddu.vim',
    \ 'Shougo/ddu-ui-ff',
    \ 'Shougo/ddu-kind-file',
    \ 'Shougo/ddu-source-file_rec',
    \ ]

let s:plugin_dir = stdpath('data') .. '/plugins/'
for plugin in s:plugins
    let s:path = s:plugin_dir .. plugin
    if !isdirectory(s:path)
        let s:repo_url = 'https://github.com/' .. plugin
        execute '!git clone' s:repo_url s:path
    endif
    execute 'set rtp^=' .. s:path
endfor

call ddu#custom#patch_global({
    \   'ui': 'ff',
    \   'sources': [{'name': 'file_rec', 'params': {}}],
    \   'kindOptions': {
    \     'file': {
    \       'defaultAction': 'open',
    \     },
    \   }
    \ })

autocmd FileType ddu-ff call s:ddu_my_settings()
function! s:ddu_my_settings() abort
    nnoremap <buffer> <CR> <Cmd>call ddu#ui#do_action('itemAction')<CR>
endfunction

nnoremap <Space>f <Cmd>call ddu#start()<CR>
nnoremap <Space>b <Cmd>set buflisted?<CR>
nnoremap <Space>c <Cmd>bdelete<CR>

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.