Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Replace UI #624

Merged
merged 144 commits into from
Jun 1, 2019
Merged

[RFC] Replace UI #624

merged 144 commits into from
Jun 1, 2019

Conversation

Shougo
Copy link
Owner

@Shougo Shougo commented Apr 23, 2019

Fix #509 #625

@Shougo
Copy link
Owner Author

Shougo commented May 6, 2019

Please test the branch.

@Luxed
Copy link

Luxed commented May 6, 2019

After testing the branch with the colorscheme source, I get this error on Windows 10 with neovim 0.3.4:

[denite] Traceback (most recent call last):
[denite]   File "C:/Users/cbrunel/AppData/Local/nvim/dein/.cache/init.vim/.dein/rplugin/python3\denite\rplugin.py", line 25, in start
[denite]     return ui.start(args[0], context)
[denite]   File "C:/Users/cbrunel/AppData/Local/nvim/dein/.cache/init.vim/.dein/rplugin/python3\denite\ui\default.py", line 67, in start
[denite]     self._start(context['sources_queue'][0], context)
[denite]   File "C:/Users/cbrunel/AppData/Local/nvim/dein/.cache/init.vim/.dein/rplugin/python3\denite\ui\default.py", line 126, in _start
[denite]     self.update_buffer()
[denite]   File "C:/Users/cbrunel/AppData/Local/nvim/dein/.cache/init.vim/.dein/rplugin/python3\denite\ui\default.py", line 332, in update_buffer
[denite]     self.update_status()
[denite]   File "C:/Users/cbrunel/AppData/Local/nvim/dein/.cache/init.vim/.dein/rplugin/python3\denite\ui\default.py", line 384, in update_status
[denite]     self._vim.command('redrawstatus')
[denite]   File "C:\Program Files\Python37\lib\site-packages\pynvim\api\nvim.py", line 287, in command
[denite]     return self.request('nvim_command', string, **kwargs)
[denite]   File "C:\Program Files\Python37\lib\site-packages\pynvim\api\nvim.py", line 182, in request
[denite]     res = self._session.request(name, *args, **kwargs)
[denite]   File "C:\Program Files\Python37\lib\site-packages\pynvim\msgpack_rpc\session.py", line 102, in request
[denite]     raise self.error_wrapper(err)
[denite] pynvim.api.nvim.NvimError: b'Vim(function):E127: Cannot redefine function denite#start: It is in use'
[denite] Please execute :messages command.
E474: Invalid argument

It could be my fault because I recently switched to Dein as a plugin manager.
I added {'rev': 'ui'} as an argument to my dein#add() call. I then sourced my init.vim, did :call dein#update(), then just to be sure I also did call dein#recache_runtimepath(). I also restarted my neovim and did :UpdateRemotePlugins

@tex
Copy link
Contributor

tex commented May 6, 2019

I tried this branch. Just switched the branch. No changes to my config. No errors, but I do not understand what to do with it. Not able to get to insert mode to filter. Esc does not work to hide denite buffer. Enter does move cursor one line down. No nice input line. What to do?

@Shougo
Copy link
Owner Author

Shougo commented May 6, 2019

I tried this branch. Just switched the branch. No changes to my config. No errors, but I do not understand what to do with it. Not able to get to insert mode to filter. Esc does not work to hide denite buffer. Enter does move cursor one line down. No nice input line. What to do?

Please read the documentation. You need to define mappings like defx.

" Define mappings
autocmd FileType denite call s:denite_my_settings()
function! s:denite_my_settings() abort
  nnoremap <silent><buffer><expr> <CR>
  \ denite#do_map('do_action')
  nnoremap <silent><buffer><expr> d
  \ denite#do_map('do_action', 'delete')
  nnoremap <silent><buffer><expr> p
  \ denite#do_map('do_action', 'preview')
  nnoremap <silent><buffer><expr> q
  \ denite#do_map('quit')
  nnoremap <silent><buffer><expr> i
  \ denite#do_map('open_filter_buffer')
  nnoremap <silent><buffer><expr> <Space>
  \ denite#do_map('toggle_select').'j'
endfunction

@Shougo
Copy link
Owner Author

Shougo commented May 6, 2019

After testing the branch with the colorscheme source, I get this error on Windows 10 with neovim 0.3.4:

I have tested but I don't reproduce the problem.
You should create the minimal vimrc. If not, I will ignore your report.

@Luxed
Copy link

Luxed commented May 7, 2019

After testing the branch with the colorscheme source, I get this error on Windows 10 with neovim 0.3.4:

I have tested but I don't reproduce the problem.
You should create the minimal vimrc. If not, I will ignore your report.

After getting home and doing a little bit more testing, vim-airline is the culprit. Right now it gives me a huge log of errors. I will make an issue if necessary but I don't have time right now.

@Shougo
Copy link
Owner Author

Shougo commented May 7, 2019

After getting home and doing a little bit more testing, vim-airline is the culprit. Right now it gives me a huge log of errors. I will make an issue if necessary but I don't have time right now.

It is vim-airline's issue.

I have checked vim-airline's code.
https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/denite.vim

It uses old statusline APIs.
It is removed in ui branch.

@hrsh7th
Copy link
Contributor

hrsh7th commented May 7, 2019

I met 2 problems on this.

  1. open_filter_buffer causes error Vim(call):E21.
  2. denite menu is not start when select next menu.

But sorry, I didn't use .vimrc.mini yet. I will test those problems with .vimrc.mini.

@Shougo
Copy link
Owner Author

Shougo commented May 7, 2019

open_filter_buffer causes error Vim(call):E21.

I don't reproduce the error. So I will ignore your report.

denite menu is not start when select next menu.

Please upload the minimal vimrc.

@hrsh7th
Copy link
Contributor

hrsh7th commented May 7, 2019

open_filter_buffer causes error Vim(call):E21.

I did'nt reproduce with init.mini.vim too ...
I try to detect this reason.

denite menu is not start when select next menu.

This problems reproduce on my init.mini.vim.

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

let dein = {}
let dein.dir = {}
let dein.dir.install = $XDG_CONFIG_HOME . '/dein.mini/repos/github.com/Shougo/dein.vim'
let dein.dir.plugins = $XDG_CONFIG_HOME . '/dein.mini'

if !isdirectory(dein.dir.install)
  call mkdir(dein.dir.install, 'p')
  call system(printf('git clone https://github.com/Shougo/dein.vim %s', shellescape(dein.dir.install)))
endif

let &runtimepath = &runtimepath . ',' . dein.dir.install
if dein#load_state(dein.dir.install)
  call dein#begin(dein.dir.plugins)
  call dein#add('Shougo/dein.vim')
  call dein#add('Shougo/denite.nvim', { 'rev': 'ui' })
  call dein#end()
endif

if dein#check_install()
  call dein#install()
endif

filetype plugin indent on
syntax enable

augroup vimrc
  autocmd!
augroup END

autocmd vimrc FileType denite call s:denite_setting()
function! s:denite_setting() abort
  nnoremap <silent><buffer><expr>i       denite#do_map('open_filter_buffer')
  nnoremap <silent><buffer><expr>a       denite#do_map('open_filter_buffer')
  nnoremap <silent><buffer><expr>q       denite#do_map('quit')
  nnoremap <silent><buffer><expr><Esc>   denite#do_map('quit')
  nnoremap <silent><buffer><expr><Tab>   denite#do_map('choose_action')
  nnoremap <silent><buffer><expr><C-l>   denite#do_map('redraw')
  nnoremap <silent><buffer><expr><C-h>   denite#do_map('restore_sources')
  nnoremap <silent><buffer><expr><CR>    denite#do_map('do_action')
  nnoremap <silent><buffer><expr>v       denite#do_map('do_action', 'vsplitswitch')
  nnoremap <silent><buffer><expr>s       denite#do_map('do_action', 'splitswitch')
  nnoremap <silent><buffer><expr>@       denite#do_map('toggle_select')
endfunction

let s:menus = {}
let s:menus.vim = {'description': 'vim runtime.'}
let s:menus.vim.command_candidates = [
      \ ['upgrade: dein:deps', 'call dein#update()']
      \ ]
call denite#custom#var('menu', 'menus', s:menus)

@Shougo
Copy link
Owner Author

Shougo commented May 7, 2019

I have fixed menu error.

@hrsh7th
Copy link
Contributor

hrsh7th commented May 7, 2019

open_filter_buffer causes error Vim(call):E21.

I detect this problem's reason. It's my mistake.
My vimrc has window layout fixer. It execute at filetype autocmd.

FYI: this problems will cause by this.

  " fix layout(sloppy code).
  let s:current_winnr = tabpagewinnr(tabpagenr())
  try
    for s:ft in ['defx', 'deol', 'denite']
      let s:winnrs = range(1, tabpagewinnr(tabpagenr(), '$'))
      if len(s:winnrs) > 1
        for s:winnr in s:winnrs
          if s:ft ==# 'defx' && s:ft == getbufvar(winbufnr(s:winnr), '&filetype')
            execute printf('silent noautocmd %swincmd w', s:winnr)
            execute printf('silent noautocmd vertical resize %s', 35)
            break
          endif
          if s:ft ==# 'deol' && s:ft == getbufvar(winbufnr(s:winnr), '&filetype')
            execute printf('silent noautocmd %swincmd w', s:winnr)
            execute printf('silent noautocmd wincmd K | silent noautocmd resize %s', 12)
            break
          endif
          if s:ft ==# 'denite' && s:ft == getbufvar(winbufnr(s:winnr), '&filetype')
            execute printf('silent noautocmd %swincmd w', s:winnr)
            execute printf('silent noautocmd wincmd J | silent noautocmd resize %s', 12)
            break
          endif
        endfor
      endif
    endfor
    silent noautocmd execute printf('%swincmd w', s:current_winnr)
  catch
  endtry

@mhartington
Copy link
Contributor

Previously, I had used the updatetime setting to redraw the UI a lot faster. Is the correct way to do this with:

  let g:denite#_update_timer = timer_start(5, {-> denite#call_map('update')}, {'repeat': -1})

Also, is it possible to replicate denite:move_to_next_line and denite:move_to_previous_line?
Overall, the older UI seemed to be a bit more user friendly at first glance. Though I understand the motivation to remove it.

@orokasan
Copy link
Contributor

orokasan commented May 8, 2019

In Vim8.0, after quiting filter buffer error messages are always shown.
Denite still works propery but a bit annoying.
It doesn't occur in neovim.
8eb8a4358ff8c9fdba13c388a8dd8759

gVim 8.1.1048 + kaoriya
minimal .vimrc :

set rtp+=~/.cache/dein/repos/github.com/Shougo/denite.nvim
set rtp+=~/.cache/dein/repos/github.com/roxma/nvim-yarp
set rtp+=~/.cache/dein/repos/github.com/roxma/vim-hug-neovim-rpc
let g:python3_host_prog ='python.exe'
set encoding=utf-8
autocmd FileType denite call s:denite_my_settings()
function! s:denite_my_settings() abort
  nnoremap <silent><buffer><expr> <CR>
  \ denite#do_map('do_action')
  nnoremap <silent><buffer><expr> i
  \ denite#do_map('open_filter_buffer')
endfunction

In addition, I think dynamic filtering isn't working in the help source.(this occurs in both nvim and vim8.0 on my environment)

@Shougo
Copy link
Owner Author

Shougo commented May 8, 2019

@orokasan I have fixed the error. Please use the latest version.

@Shougo
Copy link
Owner Author

Shougo commented May 8, 2019

In addition, I think dynamic filtering isn't working in the help source.(this occurs in both nvim and vim8.0 on my environment)

You should check your candidates number.
The dynamic filter is skipped if the candidates are too huge.

@Shougo
Copy link
Owner Author

Shougo commented May 8, 2019

I have improved filter behavior.

@Shougo
Copy link
Owner Author

Shougo commented May 8, 2019

Previously, I had used the updatetime setting to redraw the UI a lot faster. Is the correct way to do this with:

I have improved the timer. Please use the latest version. I don't want to use updatetime for it.

Also, is it possible to replicate denite:move_to_next_line and denite:move_to_previous_line?
Overall, the older UI seemed to be a bit more user friendly at first glance. Though I understand the motivation to remove it.

I don't want to add the feature.

@orokasan
Copy link
Contributor

orokasan commented May 8, 2019

@orokasan I have fixed the error. Please use the latest version.

I conformed all problems are fixed. Thanks !

@Luxed
Copy link

Luxed commented May 8, 2019

Also, is it possible to replicate denite:move_to_next_line and denite:move_to_previous_line?
Overall, the older UI seemed to be a bit more user friendly at first glance. Though I understand the motivation to remove it.

I second that. I really like how you can stay in the same mode right with Denite right now.

I don't want to add the feature.

If you don't want to add that feature it's ok, but would it even be possible?
If yes, could someone simply make a PR to add the feature?
If no, would it be possible to make our own UI since it should now be a different process?

@tex
Copy link
Contributor

tex commented May 8, 2019

@Shougo thanks for help with configuration. I now see how it works.

@Shougo
Copy link
Owner Author

Shougo commented May 8, 2019

If you don't want to add that feature it's ok, but would it even be possible?

You can add it, but I don't accept the PR.
The filtering UI must be simple.
It is like you should not move the cursor in insert mode.

If no, would it be possible to make our own UI since it should now be a different process?

You can add another filter UI instead.

@notomo
Copy link
Contributor

notomo commented May 9, 2019

I tried ui branch.

  • -cursor-pos option seems not to work.

I tested this.

	:Denite -resume -cursor-pos=+1 -immediately
	:Denite -resume -cursor-pos=-1 -immediately
  • :Denite line on denite buffer increases the line numbers.

minimal init.vim

set runtimepath+=~/path/to/denite.nvim
augroup vimrc
    autocmd!
augroup END
autocmd vimrc FileType denite call s:denite_my_settings()
function! s:denite_my_settings() abort
    nnoremap <silent> <buffer> <expr> <CR> denite#do_map('do_action')
    nnoremap <silent> <buffer> <expr> q denite#do_map('quit')
    nnoremap <silent> <buffer> <expr> i denite#do_map('open_filter_buffer')
endfunction

@Shougo
Copy link
Owner Author

Shougo commented May 9, 2019

-cursor-pos option seems not to work.

Reproduced. Please wait until fix.

:Denite line on denite buffer increases the line numbers.

I don't reproduce it. Please upload the reproduce instructions.
If not, I will ignore your issue.

@Shougo Shougo mentioned this pull request May 9, 2019
@Shougo
Copy link
Owner Author

Shougo commented May 10, 2019

I will remove old screenshots in README.
Because UI will be changed.

@Shougo
Copy link
Owner Author

Shougo commented May 28, 2019

Can we somehow restore the behaviour in 1.? Or should this PR wait for neovim/pynvim#393 ?

Fixed. Please use the latest version.

@Shougo
Copy link
Owner Author

Shougo commented May 31, 2019

I will merge the feature later.
Please wait.

@petobens
Copy link
Contributor

Sorry for the rather long vimrc that follows but it's the shortest way I can reproduce this:

set nocompatible

let $DOTVIM = expand('$HOME/.config/nvim')

if has('vim_starting')
    execute 'set runtimepath+=' . expand(
                \ '$DOTVIM/bundle/repos/github.com/Shougo/dein.vim')
endif

call dein#begin(expand('$DOTVIM/bundle/'))
call dein#add('vim-airline/vim-airline')
call dein#add('gioele/vim-autoswap')
call dein#add('junegunn/vim-easy-align')
call dein#add('jamessan/vim-gnupg')
call dein#add('machakann/vim-highlightedyank')
call dein#add('Yggdroot/indentLine')
call dein#add('simnalamburt/vim-mundo', {'on_cmd' : 'MundoToggle'})
call dein#add('neomake/neomake')
if exists(':tnoremap')
    call dein#add('kassio/neoterm')
endif
call dein#add('scrooloose/nerdcommenter')
call dein#add('justinmk/vim-sneak')
call dein#add('majutsushi/tagbar', {'on_cmd' : 'TagbarOpen'})
call dein#add('SirVer/ultisnips')
call dein#add('dhruvasagar/vim-zoom')
call dein#add('petobens/colorish', {'frozen': 1})
call dein#add('tpope/vim-abolish')
call dein#add('tpope/vim-dispatch')
call dein#add('tpope/vim-repeat')
call dein#add('tpope/vim-rhubarb')
call dein#add('tpope/vim-surround')
call dein#add('airblade/vim-gitgutter')
call dein#add('junegunn/gv.vim')
call dein#add('tpope/vim-fugitive')
call dein#add('tommcdo/vim-fubitive')
call dein#add('shumphrey/fugitive-gitlab.vim')
call dein#add('rhysd/git-messenger.vim', {'on_cmd' : 'GitMessenger',
    \ 'on_map' : '<Plug>(git-messenger)'})
call dein#add('lervag/vimtex', {'on_ft' : ['tex', 'bib']})
call dein#add('plasticboy/vim-markdown', {'on_ft' : 'markdown'})
call dein#add('davidhalter/jedi-vim', {'on_ft' : 'python'})
call dein#add('jeetsukumaran/vim-pythonsense', {'on_ft' : 'python'})
if has('nvim')
    call dein#add('numirias/semshi', {'on_ft': 'python'})
endif
call dein#add('tmhedberg/SimpylFold', {'on_ft' : 'python'})
call dein#add('vim-python/python-syntax', {'on_ft' : 'python'})
call dein#add('petobens/vim-virtualenv')  " won't work if loaded on_ft
call dein#add('jalvesaq/Nvim-R')
call dein#add('chrisbra/csv.vim', {'on_ft': 'csv'})
call dein#add('tpope/vim-dadbod')
call dein#add('cespare/vim-toml', {'on_ft': 'toml'})
call dein#add('Shougo/dein.vim')
call dein#add('Shougo/denite.nvim', {'rev': 'ui'})
call dein#add('neoclide/denite-extra')
call dein#add('raghur/fruzzy')
call dein#add('neoclide/denite-git')
call dein#add('Shougo/neomru.vim')
call dein#add('Shougo/neoyank.vim')
call dein#add('rafi/vim-denite-z')
call dein#add('kmnk/denite-dirmark')
call dein#add('Shougo/deoplete.nvim')
call dein#add('Shougo/context_filetype.vim')
call dein#add('Shougo/echodoc.vim')
call dein#add('deoplete-plugins/deoplete-docker')
if has('nvim')
    call dein#add('deoplete-plugins/deoplete-jedi')
endif
call dein#add('Shougo/neco-vim', {'name' : 'neco-vim'})
call dein#add('Shougo/neco-syntax')
call dein#add('Shougo/neoinclude.vim')
call dein#add('tbodt/deoplete-tabnine', {'build': './install.sh'})
call dein#add('Shougo/defx.nvim')
call dein#add('kristijanhusak/defx-icons')
call dein#add('kristijanhusak/defx-git')

call dein#end()

filetype plugin indent on

let g:dein#install_log_filename = expand('$HOME/.cache/dein/dein.log')
let g:dein#install_max_processes = 16

function! s:dein_update()
  call dein#update()
  Denite -no-start-filter -post-action=open dein/log:!
endfunction
nnoremap ,bu :call <SID>dein_update()<CR>

call denite#custom#option('default', {
            \ 'auto_resize': 1,
            \ })

If I now press ,bu then the plugins start updating but eventually the following error shows up:

Error detected while processing function <lambda>3[1]..denite#call_map[1]..denite#_call_map[13]..denite#util#rpcrequest:
line   18:
Error invoking '_denite_do_map' on channel 4 (python3-rplugin-host):
ch 4 returned a response with an unknown request id. Ensure the client is properly synchronized
Error invoking '_denite_do_map' on channel 4:
Invalid channel: 4
Press ENTER or type command to continue
Error detected while processing function <lambda>2[1]..denite#call_async_map[1]..denite#_call_map[13]..denite#util#rpcrequest:
line   16:
E475: Invalid argument: Channel doesn't exist

@Shougo
Copy link
Owner Author

Shougo commented Jun 1, 2019

If I now press ,bu then the plugins start updating but eventually the following error shows up:

I cannot fix the error.
You should not do it.

@Shougo Shougo merged commit f1d40d0 into master Jun 1, 2019
@Shougo Shougo deleted the ui branch June 1, 2019 09:33
@Shougo
Copy link
Owner Author

Shougo commented Jun 1, 2019

Merged.

@petobens
Copy link
Contributor

petobens commented Jun 1, 2019

I cannot fix the error.
You should not do it.

So I cannot use denite with dein source now?

@carlitux carlitux mentioned this pull request Jun 2, 2019
@Shougo
Copy link
Owner Author

Shougo commented Jun 3, 2019

So I cannot use denite with dein source now?

Yes.

ta1kt0me added a commit to ta1kt0me/vimrc that referenced this pull request Jun 3, 2019
ta1kt0me added a commit to ta1kt0me/vimrc that referenced this pull request Jun 3, 2019
@petobens
Copy link
Contributor

petobens commented Jun 7, 2019

Yes.

Apparently the problem is with -post-action=open. If I replace:

  Denite -no-start-filter -post-action=open dein/log:!

with

Denite -no-start-filter dein/log:!

it seems to work. No idea if this is a bug or not

@Shougo
Copy link
Owner Author

Shougo commented Jun 8, 2019

It works for me.
But the update is asynchronous no grantee.

@petobens
Copy link
Contributor

petobens commented Jun 8, 2019

My change actually doesn't fix it. Is there a way to silence the error?

Error detected while processing function <lambda>4[1]..denite#call_map[1]..denite#_call_map[13]..denite#util#rpcrequest:
line   18:
Error invoking '_denite_do_map' on channel 3 (python3-rplugin-host):^@ch 3 returned a response with an unknown request id. Ensure the client is properly synchronized

i.e catch the exception and avoid displaying the message. Or at least can you explain why this happens? It didn't use to...

@Shougo
Copy link
Owner Author

Shougo commented Jun 9, 2019

My change actually doesn't fix it. Is there a way to silence the error?

No. Because, Python seems crashed.

Please read this:

Error detected while processing function <lambda>2[1]..denite#call_async_map[1]..denite#_call_map[13]..denite#util#rpcrequest:
line   16:
E475: Invalid argument: Channel doesn't exist

@Shougo
Copy link
Owner Author

Shougo commented Jun 9, 2019

You can trace the log.

       $ export NVIM_PYTHON_LOG_FILE=/tmp/log
       $ export NVIM_PYTHON_LOG_LEVEL=DEBUG
       $ neovim
       ...
       $ cat /tmp/log_{PID}

@Shougo
Copy link
Owner Author

Shougo commented Jun 9, 2019

At least, this is not denite.nvim's bug.

@Shougo
Copy link
Owner Author

Shougo commented Jun 9, 2019

OK. I get the reason.

call denite#custom#option('default', {
            \ 'auto_resize': 1,
            \ })

If you enable auto_resize, Python seems crashed.

@Shougo
Copy link
Owner Author

Shougo commented Jun 9, 2019

I have disabled auto resize when asynchronous.

@petobens
Copy link
Contributor

Thank you!

@petobens
Copy link
Contributor

Mmm unfortunately I'm still seeing:

Error detected while processing function <lambda>5[1]..denite#call_map[1]..denite#_call_map[13]..denite#util#rpcrequest:
line   18:
Error invoking '_denite_do_map' on channel 3 (python3-rplugin-host):^@ch 3 returned a response with an unknown request id. Ensure the client is properly synchronized

even with your auto resize asynchronous fix so the problem apparently was not related with the auto_resize feature...

@Shougo
Copy link
Owner Author

Shougo commented Jun 13, 2019

I don't reproduce the problem.
But it seems neovim problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split UI process