vifm / neovim-vifm

A neovim plugin to use vifm like netrw and NERDTree.
Other
47 stars 1 forks source link

unable to rename multiple files #2

Closed vlcinsky closed 7 years ago

vlcinsky commented 7 years ago

I have problems to use :rename on multiple files.

neovim version:

NVIM v0.2.1-dev
Build type: RelWithDebInfo
Compilation: /usr/bin/x86_64-linux-gnu-gcc -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-10058w/neovim-0.2.0ubuntu1+git201708261906+3618+26~ubuntu16.04.1/build/config -I/build/neovim-10058w/neovim-0.2.0ubuntu1+git201708261906+3618+26~ubuntu16.04.1/src -I/build/neovim-10058w/neovim-0.2.0ubuntu1+git201708261906+3618+26~ubuntu16.04.1/.deps/usr/include -I/build/neovim-10058w/neovim-0.2.0ubuntu1+git201708261906+3618+26~ubuntu16.04.1/.deps/usr/include -I/build/neovim-10058w/neovim-0.2.0ubuntu1+git201708261906+3618+26~ubuntu16.04.1/.deps/usr/include -I/build/neovim-10058w/neovim-0.2.0ubuntu1+git201708261906+3618+26~ubuntu16.04.1/.deps/usr/include -I/build/neovim-10058w/neovim-0.2.0ubuntu1+git201708261906+3618+26~ubuntu16.04.1/.deps/usr/include -I/build/neovim-10058w/neovim-0.2.0ubuntu1+git201708261906+3618+26~ubuntu16.04.1/.deps/usr/include -I/usr/include -I/build/neovim-10058w/neovim-0.2.0ubuntu1+git201708261906+3618+26~ubuntu16.04.1/build/src/nvim/auto -I/build/neovim-10058w/neovim-0.2.0ubuntu1+git201708261906+3618+26~ubuntu16.04.1/build/include
přeložil  root@lcy01-11

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

   systémový vimrc soubor: "$VIM/sysinit.vim"
  implicitní hodnota $VIM:"/usr/share/nvim"

vifm version:

$ vifm --version
Version: 0.9
Git info: built out of repository
Compiled at: Aug 27 2017 09:57:22

Support of extended keys is on
Parsing of .desktop files is enabled
With GTK+ library
Without magic library
With X11 library
With dynamic loading of X11 library
With file program
With -n option for cp and mv
With remote command execution

When I open neovim, start vifm from here (by :e .), select visually few files and call :rename, it prints:

Chyba při zpracování /usr/share/nvim/runtime/plugin/health.vim:
řádek    8:
E10: po \ by měl následovat /. ? nebo &
--- Automatické příkazy ---
Chyba při zpracování /usr/share/nvim/runtime/plugin/shada.vim:
řádek    9:
E10: po \ by měl následovat /. ? nebo &
řádek   10:
E10: po \ by měl následovat /. ? nebo &
řádek   11:
E10: po \ by m�ěl následovat /. ? nebo &[J
--- Automatické příkazy ---
řádek   13:
E10: po \ by měl následovat /. ? nebo &
řádek   14:
E10: po \ by měl následovat /. ? nebo &
--- Automatické příkazy ---
řádek   16:
E10: po \ by měl následovat /. ? nebo &
řádek   17:
E10: po \ by měl následovat /. ? nebo &
řádek   18:
E10: po \ by měl následovat /. ? nebo &
řádek   19:
E10: po \ by měl následovat /. ? nebo &
řádek   20:
E35: žádný předchozí regulární výraz
řádek   21:
E10: po \ by měl následovat /. ? nebo &
řádek   22:
E10: po \ by měl následovat /. ? nebo &
--- Automatické příkazy ---
řádek   24:
E10: po \ by měl následovat /. ? nebo &
řádek   25:
E10: po \ by měl následovat /. ? nebo &
řádek   26:
E10: po \ by měl následovat /. ? nebo &
řádek   27:
E10: po \ by měl následovat /. ? nebo &
řádek   28:
E10: po \ by měl následovat /. ? nebo &
řádek   29:
E10: po \ by měl následovat /. ? nebo &
--- Automatické příkazy ---
řádek   31:
E10: po \ by měl následovat /. ? nebo &
řádek   32:
E10: po \ by měl následovat /. ? nebo &
řádek   33:
E10: po \ by měl následovat /. ? nebo &
řádek   34:
E10: po \ by měl následovat /. ? nebo &
řádek   35:
E10: po \ by měl následovat /. ? nebo &
řádek   36:
E10: po \ by měl následovat /. ? nebo &
--- Automatické příkazy ---
řádek   38:
E10: po \ by měl následovat /. ? nebo &
Press ENTER or type command to continue

What translates (translation might not be precise) to:

Error processing /usr/share/nvim/runtime/plugin/health.vim:
line    8:
E10: after \ should follow /. ? or &
--- Automated commands ---
Error processing /usr/share/nvim/runtime/plugin/shada.vim:
line    9:
E10: after \ should follow /. ? or &
line   10:
E10: after \ should follow /. ? or &
line   11:
E10: after \ should folloe /. ? or &[J
--- Automated commands ---
line   13:
E10: after \ should follow /. ? or &
line   14:
E10: after \ should follow /. ? or &
--- Automated commands ---
line   16:
E10: after \ should follow /. ? or &
line   17:
E10: after \ should follow /. ? or &
line   18:
E10: after \ should follow /. ? or &
line   19:
E10: after \ should follow /. ? or &
line   20:
E35: no previous regular expression
line   21:
E10: after \ should follow /. ? or &
line   22:
E10: after \ should follow /. ? or &
--- Automated commands ---
line   24:
E10: after \ should follow /. ? or &
line   25:
E10: after \ should follow /. ? or &
line   26:
E10: after \ should follow /. ? or &
line   27:
E10: after \ should follow /. ? or &
line   28:
E10: after \ should follow /. ? or &
line   29:
E10: after \ should follow /. ? or &
--- Automated commands ---
line   31:
E10: after \ should follow /. ? or &
line   32:
E10: after \ should follow /. ? or &
line   33:
E10: after \ should follow /. ? or &
line   34:
E10: after \ should follow /. ? or &
line   35:
E10: after \ should follow /. ? or &
line   36:
E10: after \ should follow /. ? or &
--- Automated commands ---
line   38:
E10: after \ should follow /. ? or &
Press ENTER or type command to continue

and vifm opens editor window with the selected files. Neovim shows terminal mode.

After that, I am unable to complete the rename as neovim seems to be completely confused (neovim with terminal window running vifm and vim or neovim editor open from here).

The only sane method to procede is :cq.

vlcinsky commented 7 years ago

The problem seems to be generally bound to opening editor window from within vifm.

Apart from rename on multiple windows, also command :clone?has the same type of problem. Note the ? which shall allow editing target file names before completing the clone action.

xaizek commented 7 years ago

It seems like you didn't configure vifm to run nvim instead of Vim (see 'vicmd' option). The issue arises from the fact that nvim defines $VIM and $VIMRUNTIME forcing Vim to process nvim files and something goes wrong (if you don't have Vim configured you it might work in vi compatible mode). Setting 'vicmd' to nvim should fix it.

vlcinsky commented 7 years ago

@xaizek I set vicmd in my ~/.vifm/vifmrc to nvim and the first part of the problem seems resolved - the long (translated) list of compains is gone now.

Now when I select multiple files (nvim -> :e . -> select few files -> :rename) it opens (without complains) file containing names of selected files.

Anyway, trying to edit the file does not work. I see two status lines at the bottom what means, I have nvim with one terminal window open and in that is another nvim running.

The outer window shows "Normal" mode, the inner one is in "insert" mode.

I am unable to finish editing file names, it does not react to normal nvim commands as it seems the outer windows is catching most of my key strokes. For this reason, when I enter :q, the outer nvim windows closes (what was not my intention).

xaizek commented 7 years ago

For me nested nvim works fine, but maybe that's because I don't have anything configured for nvim except this plugin. Outer nvim remains in --TERMINAL-- mode as it should, maybe something in your configuration of nvim triggers switching back to normal mode?

vlcinsky commented 7 years ago

Yes, I shall try the neovim only with neovim-vifm extension.

vlcinsky commented 7 years ago

I got it.

It was not about any plugin, but keyboard mapping for my terminal mode:

tnoremap <esc> <c-\><c-n>

I use this mapping to make switching between "command-like" terminal mode and normal mode. It allows me to jump around terminal output just by <esc> and then using vim normal mode navigation commands.

The reasons for mappint it to <esc> is very simple. I work exclusively on Czech keyboard layout (following advice of my touch typing teacher who explained me, that programming is still possible but my mind will not have to swap two different keyboard layouts). And on Czech keyboard I have to use <altgr>-q to produce \ what makes <c-\> a bit difficult (involves three fingers).

Two productivity tools are competing here: terminal mode (I am havy user of it) and vifm within neovim (being heavy user outside of neovim).

Do you have any idea, if I could remap my <esc> mapping for the time I use the vifm window?

PS: If there is no simple solution, I agree on closing this issue anyway as the main problem "it does not work" is resolved now.

xaizek commented 7 years ago

I'd expect something like this to do the job:

augroup InVifm
    autocmd!
    autocmd TermOpen term://*:vifm tnoremap <esc> <esc>
augroup END

It works with :VifmToggle, but not with :e .. Looks like TermOpen autocommand isn't fired on termopen(), while I think it should (per documentation), so it might be a bug in nvim or I'm missing something.

vlcinsky commented 7 years ago

Yes, I can confirm your description:

anyway, my mapping for normal terminal use got lost this way.

My current solution is using alternative mapping to escape terminal mode to normal one using Alt-n:

tnoremap <a-n> <c-\><c-n>

Later on I can dive a bit deeper into understanding autocommands and possibly filing issue with neovim. Thanks so far. Using vifm inside of nvim is great.

xaizek commented 7 years ago

I'm closing this then, since the plugin itself appears to be working fine.

I just had another idea to implement the mapping, which seems to work:

tnoremap <expr> <esc> bufname('%') !~ '^term://.*:vifm$' ? "\<c-\>\<c-n>" : ''