Shougo / ddu.vim

Dark deno-powered UI framework for Vim/NeoVim
MIT License
295 stars 24 forks source link

`toggle` and `resume` dose not work well. #20

Closed ryota2357 closed 2 years ago

ryota2357 commented 2 years ago

Tanks you for Shougo/ddu-ui-filer#3 and Shougo/ddu-ui-filer#5. But I found new bugs related to them.

Problems summary

There are 2 bugs about toggle of uiParams and resume of ddu-options.

  1. When setting resume in ddu#custom#path_global(), there is bug: Shougo/ddu-ui-filer#5. But setting in ddu#start(), there is no bug (ddu restores the previous state as I expected).
  2. When setting both resume and toggle, resume works well but toggle does not work.

Expected

  1. If setting resume in ddu#custom#path_global()`, ddu restores the previous state.
  2. toggle works with or without resume setting

Environment Information

neovim ``` NVIM v0.7.2 Build type: Release LuaJIT 2.1.0-beta3 Compiled by brew@HMBRW-A-001-M1-004.local Features: +acl +iconv +tui See ":help feature-compile" システム vimrc: "$VIM/sysinit.vim" 省略時の $VIM: "/opt/homebrew/Cellar/neovim/0.7.2/share/nvim" Run :checkhealth for more info ```
defx: health#defx#check
========================================================================
## defx.nvim
  - OK: has("python3") was successful
  - OK: Python 3.6.1+ was successful

denops: health#denops#check
========================================================================
  - INFO: Supported Deno version: `1.17.1`
  - INFO: Detected Deno version: `1.23.3`
  - OK: Deno version check: passed
  - INFO: Supported Neovim version: `0.6.0`
  - INFO: Detected Neovim version: `0.7.2`
  - OK: Neovim version check: passed
  - INFO: Denops status: `running`
  - OK: Denops status check: passed

nvim: health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $TERM_PROGRAM='tmux'
  - INFO: $COLORTERM='truecolor'

## tmux
  - OK: escape-time: 0
  - INFO: Checking stuff
  - OK: focus-events: on
  - INFO: $TERM: screen-256color

nvim-lsp-installer: require("nvim-lsp-installer.health").check()
========================================================================
## nvim-lsp-installer report
  - OK: neovim version >= 0.7.0
  - WARNING: **Go**: not available
  - OK: **cargo**: `cargo 1.62.0 (a748cf5a3 2022-06-08)`
  - WARNING: **luarocks**: not available
  - OK: **Ruby**: `ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]`
  - OK: **RubyGem**: `3.3.7`
  - WARNING: **Composer**: not available
  - OK: **PHP**: `PHP 8.1.8 (cli) (built: Jul  8 2022 10:46:35) (NTS)`
  - OK: **npm**: `8.13.2`
  - OK: **node**: `v18.4.0`
  - OK: **python3**: `Python 3.10.4`
  - OK: **pip3**: `pip 22.1.1 from /Users/otsukiryota/.pyenv/versions/3.10.4/lib/python3.10/site-packages/pip (python 3.10)`
  - WARNING: **javac**: not available
  - WARNING: **java**: not available
  - WARNING: **julia**: not available
  - OK: **wget**: `GNU Wget 1.21.3 built on darwin21.3.0.`
  - OK: **curl**: `curl 7.79.1 (x86_64-apple-darwin21.0) libcurl/7.79.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.45.1`
  - OK: **gzip**: `Apple gzip 353.100.22`
  - OK: **tar**: `bsdtar 3.5.1 - libarchive 3.5.1 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8 `
  - OK: **bash**: `GNU bash, version 3.2.57(1)-release (arm64-apple-darwin21)`
  - OK: **sh**: `Ok`
  - OK: GitHub API rate limit. Used: 0. Remaining: 5000. Limit: 5000. Reset: 木  7/14 00:24:38 2022.

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - OK: `tree-sitter` found 0.20.6 (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v18.4.0 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: Apple clang version 13.1.6 (clang-1316.0.21.2.5)
  - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I J
  - ql             ✓ ✓ . ✓ ✓ 
  - java           ✓ ✓ . ✓ ✓ 
  - kotlin         ✓ ✓ ✓ . ✓ 
  - pascal         ✓ ✓ ✓ ✓ ✓ 
  - cpp            ✓ ✓ ✓ ✓ ✓ 
  - julia          ✓ ✓ ✓ ✓ ✓ 
  - javascript     ✓ ✓ ✓ ✓ ✓ 
  - bash           ✓ ✓ ✓ . ✓ 
  - comment        ✓ . . . . 
  - css            ✓ . ✓ ✓ ✓ 
  - jsdoc          ✓ . . . . 
  - scss           ✓ . . ✓ . 
  - hcl            ✓ . ✓ ✓ ✓ 
  - erlang         ✓ . ✓ . . 
  - glimmer        ✓ . . . . 
  - elixir         ✓ ✓ ✓ ✓ ✓ 
  - gdscript       ✓ ✓ . ✓ ✓ 
  - gleam          ✓ ✓ ✓ ✓ ✓ 
  - markdown       ✓ . ✓ . ✓ 
  - godot_resource ✓ ✓ ✓ . . 
  - tiger          ✓ ✓ ✓ ✓ ✓ 
  - eex            ✓ . . . ✓ 
  - v              ✓ ✓ ✓ ✓ ✓ 
  - heex           ✓ ✓ ✓ ✓ ✓ 
  - turtle         ✓ ✓ ✓ ✓ ✓ 
  - ocaml          ✓ ✓ ✓ . ✓ 
  - devicetree     ✓ ✓ ✓ ✓ ✓ 
  - qmljs          ✓ . ✓ . . 
  - proto          ✓ . ✓ . . 
  - ocaml_interface✓ ✓ ✓ . ✓ 
  - svelte         ✓ . ✓ ✓ ✓ 
  - tsx            ✓ ✓ ✓ ✓ ✓ 
  - ocamllex       ✓ . . . ✓ 
  - wgsl           ✓ . ✓ . . 
  - org            . . . . . 
  - sql            ✓ . . . ✓ 
  - swift          ✓ ✓ . . . 
  - scheme         ✓ . ✓ . ✓ 
  - elvish         ✓ . . . ✓ 
  - fortran        ✓ . ✓ ✓ . 
  - rust           ✓ ✓ ✓ ✓ ✓ 
  - todotxt        ✓ . . . . 
  - bibtex         ✓ . ✓ ✓ . 
  - rego           ✓ . . . ✓ 
  - typescript     ✓ ✓ ✓ ✓ ✓ 
  - zig            ✓ . ✓ ✓ ✓ 
  - c_sharp        ✓ ✓ ✓ . ✓ 
  - scala          ✓ . ✓ . ✓ 
  - embedded_template✓ . . . ✓ 
  - vala           ✓ . . . . 
  - supercollider  ✓ ✓ ✓ ✓ ✓ 
  - clojure        ✓ ✓ ✓ . ✓ 
  - regex          ✓ . . . . 
  - slint          ✓ . . ✓ . 
  - commonlisp     ✓ ✓ ✓ . . 
  - json5          ✓ . . . ✓ 
  - haskell        ✓ . ✓ . ✓ 
  - query          ✓ ✓ ✓ ✓ ✓ 
  - pioasm         ✓ . . . ✓ 
  - foam           ✓ ✓ ✓ ✓ ✓ 
  - cuda           ✓ ✓ ✓ ✓ ✓ 
  - beancount      ✓ . ✓ . . 
  - hocon          ✓ . . . ✓ 
  - make           ✓ . . . ✓ 
  - help           ✓ . . . . 
  - latex          ✓ . ✓ . ✓ 
  - cmake          ✓ . ✓ . . 
  - llvm           ✓ . . . . 
  - http           ✓ . . . ✓ 
  - hjson          ✓ ✓ ✓ ✓ ✓ 
  - dockerfile     ✓ . . . ✓ 
  - prisma         ✓ . . . . 
  - cooklang       ✓ . . . . 
  - markdown_inline✓ . . . ✓ 
  - rnoweb         ✓ . ✓ . ✓ 
  - rasi           ✓ ✓ ✓ ✓ . 
  - tlaplus        ✓ ✓ ✓ . ✓ 
  - r              ✓ ✓ . ✓ ✓ 
  - astro          ✓ ✓ ✓ ✓ ✓ 
  - sparql         ✓ ✓ ✓ ✓ ✓ 
  - hack           ✓ . . . . 
  - toml           ✓ ✓ ✓ ✓ ✓ 
  - norg           . . . . . 
  - verilog        ✓ ✓ ✓ . ✓ 
  - m68k           ✓ ✓ ✓ . ✓ 
  - fennel         ✓ ✓ . . ✓ 
  - rst            ✓ ✓ . . ✓ 
  - pug            ✓ . . . ✓ 
  - dart           ✓ ✓ . ✓ ✓ 
  - gomod          ✓ . . . ✓ 
  - vue            ✓ . ✓ ✓ ✓ 
  - go             ✓ ✓ ✓ ✓ ✓ 
  - c              ✓ ✓ ✓ ✓ ✓ 
  - jsonc          ✓ ✓ ✓ ✓ ✓ 
  - lalrpop        ✓ ✓ . . . 
  - php            ✓ ✓ ✓ ✓ ✓ 
  - elm            ✓ . . . ✓ 
  - solidity       ✓ . . . . 
  - yaml           ✓ ✓ ✓ ✓ ✓ 
  - glsl           ✓ ✓ ✓ ✓ ✓ 
  - yang           ✓ . ✓ ✓ . 
  - gowork         ✓ . . . ✓ 
  - vim            ✓ ✓ ✓ . ✓ 
  - ninja          ✓ . ✓ ✓ . 
  - graphql        ✓ . . ✓ ✓ 
  - d              ✓ . ✓ ✓ ✓ 
  - nix            ✓ ✓ ✓ . ✓ 
  - ruby           ✓ ✓ ✓ ✓ ✓ 
  - dot            ✓ . . . ✓ 
  - fusion         ✓ ✓ ✓ ✓ . 
  - perl           ✓ . ✓ . . 
  - python         ✓ ✓ ✓ ✓ ✓ 
  - ledger         ✓ . ✓ ✓ ✓ 
  - json           ✓ ✓ ✓ ✓ . 
  - fish           ✓ ✓ ✓ ✓ ✓ 
  - surface        ✓ . ✓ ✓ ✓ 
  - teal           ✓ ✓ ✓ ✓ ✓ 
  - lua            ✓ ✓ ✓ ✓ ✓ 
  - html           ✓ ✓ ✓ ✓ ✓ 

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

provider: health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: pbcopy

## Python 3 provider (optional)
  - INFO: pyenv: Path: /opt/homebrew/Cellar/pyenv/2.3.2/libexec/pyenv
  - INFO: pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
  - INFO: pyenv: Root: /Users/otsukiryota/.pyenv
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Executable: /Users/otsukiryota/.pyenv/versions/3.10.4/bin/python3
  - INFO: Python version: 3.10.4
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
  - INFO: Host: /Users/otsukiryota/.rbenv/shims/neovim-ruby-host
  - OK: Latest "neovim" gem is installed: 0.9.0

## Node.js provider (optional)
  - INFO: Node.js: v18.4.0
  - INFO: Nvim node.js host: /Users/otsukiryota/.nodebrew/node/v18.4.0/lib/node_modules/neovim/bin/cli.js
  - OK: Latest "neovim" npm/yarn package is installed: 4.10.1

## Perl provider (optional)
  - WARNING: "Neovim::Ext" cpan module is not installed
    - ADVICE:
      - See :help |provider-perl| for more information.
      - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim

vim.lsp: require("vim.lsp.health").check()
========================================================================
  - INFO: LSP log level : WARN
  - INFO: Log path: /Users/otsukiryota/.cache/nvim/lsp.log
  - INFO: Log size: 71667 KB

vim.treesitter: require("vim.treesitter.health").check()
========================================================================
  - INFO: Runtime ABI version : 14
  - OK: Loaded parser for astro: ABI version 13
  - OK: Loaded parser for bash: ABI version 13
  - OK: Loaded parser for beancount: ABI version 13
  - OK: Loaded parser for bibtex: ABI version 13
  - OK: Loaded parser for c: ABI version 13
  - OK: Loaded parser for clojure: ABI version 13
  - OK: Loaded parser for cmake: ABI version 13
  - OK: Loaded parser for comment: ABI version 13
  - OK: Loaded parser for commonlisp: ABI version 13
  - OK: Loaded parser for cooklang: ABI version 13
  - OK: Loaded parser for cpp: ABI version 13
  - OK: Loaded parser for css: ABI version 13
  - OK: Loaded parser for cuda: ABI version 13
  - OK: Loaded parser for c_sharp: ABI version 13
  - OK: Loaded parser for d: ABI version 14
  - OK: Loaded parser for dart: ABI version 13
  - OK: Loaded parser for devicetree: ABI version 14
  - OK: Loaded parser for dockerfile: ABI version 13
  - OK: Loaded parser for dot: ABI version 13
  - OK: Loaded parser for eex: ABI version 13
  - OK: Loaded parser for elixir: ABI version 13
  - OK: Loaded parser for elm: ABI version 13
  - OK: Loaded parser for elvish: ABI version 13
  - OK: Loaded parser for embedded_template: ABI version 13
  - OK: Loaded parser for erlang: ABI version 13
  - OK: Loaded parser for fennel: ABI version 13
  - OK: Loaded parser for fish: ABI version 13
  - OK: Loaded parser for foam: ABI version 13
  - OK: Loaded parser for fortran: ABI version 13
  - OK: Loaded parser for fusion: ABI version 13
  - OK: Loaded parser for gdscript: ABI version 13
  - OK: Loaded parser for gleam: ABI version 13
  - OK: Loaded parser for glimmer: ABI version 13
  - OK: Loaded parser for glsl: ABI version 13
  - OK: Loaded parser for go: ABI version 13
  - OK: Loaded parser for godot_resource: ABI version 14
  - OK: Loaded parser for gomod: ABI version 13
  - OK: Loaded parser for gowork: ABI version 13
  - OK: Loaded parser for graphql: ABI version 13
  - OK: Loaded parser for hack: ABI version 13
  - OK: Loaded parser for haskell: ABI version 13
  - OK: Loaded parser for hcl: ABI version 13
  - OK: Loaded parser for heex: ABI version 13
  - OK: Loaded parser for help: ABI version 13
  - OK: Loaded parser for hjson: ABI version 13
  - OK: Loaded parser for hocon: ABI version 13
  - OK: Loaded parser for html: ABI version 13
  - OK: Loaded parser for http: ABI version 13
  - OK: Loaded parser for java: ABI version 13
  - OK: Loaded parser for javascript: ABI version 13
  - OK: Loaded parser for jsdoc: ABI version 13
  - OK: Loaded parser for json: ABI version 13
  - OK: Loaded parser for json5: ABI version 13
  - OK: Loaded parser for jsonc: ABI version 13
  - OK: Loaded parser for julia: ABI version 13
  - OK: Loaded parser for kotlin: ABI version 13
  - OK: Loaded parser for lalrpop: ABI version 13
  - OK: Loaded parser for latex: ABI version 13
  - OK: Loaded parser for ledger: ABI version 13
  - OK: Loaded parser for llvm: ABI version 13
  - OK: Loaded parser for lua: ABI version 13
  - OK: Loaded parser for m68k: ABI version 13
  - OK: Loaded parser for make: ABI version 13
  - OK: Loaded parser for markdown: ABI version 13
  - OK: Loaded parser for markdown_inline: ABI version 13
  - OK: Loaded parser for ninja: ABI version 13
  - OK: Loaded parser for nix: ABI version 13
  - OK: Loaded parser for norg: ABI version 13
  - OK: Loaded parser for ocaml: ABI version 13
  - OK: Loaded parser for ocamllex: ABI version 14
  - OK: Loaded parser for ocaml_interface: ABI version 13
  - OK: Loaded parser for org: ABI version 13
  - OK: Loaded parser for pascal: ABI version 13
  - OK: Loaded parser for perl: ABI version 13
  - OK: Loaded parser for php: ABI version 13
  - OK: Loaded parser for pioasm: ABI version 13
  - OK: Loaded parser for prisma: ABI version 13
  - OK: Loaded parser for proto: ABI version 13
  - OK: Loaded parser for pug: ABI version 13
  - OK: Loaded parser for python: ABI version 13
  - OK: Loaded parser for ql: ABI version 13
  - OK: Loaded parser for qmljs: ABI version 13
  - OK: Loaded parser for query: ABI version 13
  - OK: Loaded parser for r: ABI version 13
  - OK: Loaded parser for rasi: ABI version 13
  - OK: Loaded parser for regex: ABI version 13
  - OK: Loaded parser for rego: ABI version 13
  - OK: Loaded parser for rnoweb: ABI version 13
  - OK: Loaded parser for rst: ABI version 13
  - OK: Loaded parser for ruby: ABI version 13
  - OK: Loaded parser for rust: ABI version 13
  - OK: Loaded parser for scala: ABI version 13
  - OK: Loaded parser for scheme: ABI version 13
  - OK: Loaded parser for scss: ABI version 13
  - OK: Loaded parser for slint: ABI version 13
  - OK: Loaded parser for solidity: ABI version 13
  - OK: Loaded parser for sparql: ABI version 13
  - OK: Loaded parser for sql: ABI version 13
  - OK: Loaded parser for supercollider: ABI version 13
  - OK: Loaded parser for surface: ABI version 13
  - OK: Loaded parser for svelte: ABI version 13
  - OK: Loaded parser for swift: ABI version 14
  - OK: Loaded parser for teal: ABI version 14
  - OK: Loaded parser for tiger: ABI version 13
  - OK: Loaded parser for tlaplus: ABI version 13
  - OK: Loaded parser for todotxt: ABI version 13
  - OK: Loaded parser for toml: ABI version 13
  - OK: Loaded parser for tsx: ABI version 13
  - OK: Loaded parser for turtle: ABI version 13
  - OK: Loaded parser for typescript: ABI version 13
  - OK: Loaded parser for v: ABI version 13
  - OK: Loaded parser for vala: ABI version 13
  - OK: Loaded parser for verilog: ABI version 13
  - OK: Loaded parser for vim: ABI version 13
  - OK: Loaded parser for vue: ABI version 13
  - OK: Loaded parser for wgsl: ABI version 13
  - OK: Loaded parser for yaml: ABI version 13
  - OK: Loaded parser for yang: ABI version 13
  - OK: Loaded parser for zig: ABI version 13

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

Both bugs use follow vimrc.

if !has("nvim")
  set nocompatible
  filetype plugin indent on
  syntax enable
endif

let s:plugins = [
      \ 'vim-denops/denops.vim',
      \ 'Shougo/ddu.vim',
      \ 'Shougo/ddu-ui-filer',
      \ '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

autocmd FileType ddu-filer call s:ddu_my_settings()
function! s:ddu_my_settings() abort
  nnoremap <buffer><expr> <CR> ddu#ui#filer#is_directory()
    \ ? "<Cmd>call ddu#ui#filer#do_action('expandItem', {'mode': 'toggle'})<CR>"
    \ : "<Cmd>call ddu#ui#filer#do_action('itemAction')<CR>"
  nnoremap <buffer> q <Cmd>call ddu#ui#filer#do_action('quit')<CR>
endfunction

For the 1st bug, add follow vimrc.

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

For the 2nd bug, add follow vimrc.

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

How to reproduce the problem from neovim/Vim startup (Required!)

For the 1st bug.

  1. Call ddu#start({})
  2. On a directory, push <CR> to expand the directory.
  3. Push q to quit ddu.
  4. Call ddu#start({})

then you will see that ddu does not restore the previous state. But,

  1. Set resume in ddu#custom#pach_global() v:false.
  2. Call ddu#start({ 'resume': v:true })
  3. On a directory, push <CR> to expand the directory.
  4. Push q to quit ddu.
  5. Call ddu#start({ 'resume': v:true })

then you will see that ddu restores the previous state.

For the 2nd bug.

  1. Call ddu#start({ 'resume': v:true })
  2. Call ddu#start({ 'resume': v:true })

then, you will see that ddu-ui-filer still open. But,

  1. Call ddu#start({})
  2. Call ddu#start({})

then ddu close.