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

[potential bug] When running <leader>te (task edit) I seem to open a vim instance within an vim instance #193

Closed
arooni opened this issue Oct 21, 2018 · 22 comments

Comments

@arooni
Copy link

arooni commented Oct 21, 2018

env: ubuntu 18.04 with latest task warrior and taskwii
screenshot from 2018-10-21 18-07-26

Use case:
I have taskwiki open as a buffer along with other buffers for my personal journal/notes file.

  • i select a task i want to edit
  • te
  • i see the edit screen; but its kinda like a vim within a vim window (attached screenshot so you could see what i see).
  • as i try to scroll i can only scroll in the outward vim instance not in the vim instance that contains fields to edit in
  • unable to edit file and in addition task warrior locks it creating a file in ~/.task so it can't be edited till i delete that file.

ideas? what am i doing wrong? thanks!

@tbabej
Copy link
Collaborator

tbabej commented Oct 22, 2018

Are you using vim or neovim?

@arooni
Copy link
Author

arooni commented Oct 26, 2018

neovim

@tbabej
Copy link
Collaborator

tbabej commented Jan 25, 2019

Does this issue still persist? I am able to perform :TaskWikiEdit in neovim just fine. Can you post your nvim --version?

@mgoral
Copy link

mgoral commented Mar 25, 2019

@arooni Taskwiki opens new neovim inside terminal buffer (:h terminal), but this buffer starts in original neovim's normal mode (try e.g. :term - you can freely navigate that buffer like all other buffers in neovim). To enter terminal mode, you have to access to the "inner" neovim, e.g. by pressing a. Then you'll be inside the inner neovim, which starts in its own normal mode, so to edit its buffer (the one with loaded task), you have enter insert mode (e.g. once again a). Now when you exit the inner neovim, Taskwarrior will detect your changes, automatically remove all temporary files and everything works like expected. Also the outer's terminal buffer is automatically deleted and the original wiki file is displayed.

I think that neovim 0.1.x automatically started terminal buffers in terminal mode and that it changed for 0.2+, so maybe that's where confusion comes from?

@arooni
Copy link
Author

arooni commented Mar 28, 2019

@tbabej

[I]  ~  nvim --version
NVIM v0.3.4
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20190113-94620-d8vv4n/neovim-0.3.4/build/config -I/tmp/neovim-20190113-94620-d8vv4n/neovim-0.3.4/src -I/usr/local/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/tmp/neovim-20190113-94620-d8vv4n/neovim-0.3.4/build/src/nvim/auto -I/tmp/neovim-20190113-94620-d8vv4n/neovim-0.3.4/build/include
Compiled by brew@Mojave.local

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.3.4/share/nvim"

Run :checkhealth for more info

@mgoral
So you're saying I need to run :term before running taskwiki?

@mgoral
Copy link

mgoral commented Mar 28, 2019 via email

@arooni
Copy link
Author

arooni commented Mar 28, 2019

If I have a task selected, and then run :TaskWikiEdit

It errors out:

Error detected while processing function <SNR>131_LoadRemotePlugins[1]..<SNR>131_GetManifest[1]..<SNR>131_GetManifestPath:
line    7:
E117: Unknown function: stdpath
Press ENTER or type command to continue
 NORMAL  SPELL [EN]  term://.//38645:task  b30d07a6 edit[-]                                                                                                                    [unix]    2%    1/45  :  1 
:TaskWikiEdit

Not sure if that's a different plugin that's getting in the way

@jean
Copy link

jean commented Feb 17, 2020

I'm seeing the same thing:

Launching 'vim "task.1f82c8a5.task"' now...
Error detected while processing function <SNR>13_LoadRemotePlugins[1]..<SNR>13_GetManifest[1]..<SNR>13_GetManifestPath:
line    7:
E117: Unknown function: stdpath
E15: Invalid expression: stdpath('data')                                                                                                                                                                                                                                                                                      
Press ENTER or type command to continue

It looks like it's trying to launch vim instead of nvim?

@tbabej
Copy link
Collaborator

tbabej commented Feb 17, 2020

This is happening in the taskwarrior itself, we are only launching the task edit command through taskwiki. The task edit uses the editor that is defined via your $EDITOR env variable.

@arooni
Copy link
Author

arooni commented Feb 18, 2020

i set and verified that the editor variable was set to nvim; but after running task edit i still get an error:

[I]  ~  echo $EDITOR
nvim
[I]  ~ 

Error detected while processing function <SNR>134_LoadRemotePlugins[1]..<SNR>134_GetManifest[1]..<SNR>134_GetManifestPath:
line    7:
E117: Unknown function: stdpath
Press ENTER or type command to continue
 NORMAL  term://.//54443:task  d649e19c edit[-]                                                                                                                                 [unix]    2%    1/46  :  1 

@tbabej
Copy link
Collaborator

tbabej commented Feb 18, 2020

I'm not sure this is related to taskwiki though, a quick google search showcases this error discussed in various scenarios,i.e.:

neovim/neovim#9960

@arooni
Copy link
Author

arooni commented Feb 18, 2020

fair point.

@arooni
Copy link
Author

arooni commented Feb 18, 2020

setting editor to nvim seeed to help quite a bit. but on some tasks i see:

Filter: ( ( ( uuid = 9a498c82 ) ) )
Task is already being edited.

[Process exited 2]

even though there are no other nvim or taskwarrior processes. any insight to this?

@tbabej
Copy link
Collaborator

tbabej commented Feb 19, 2020

If you poke in the sources of Taskwarrior, in CmdEdit.cpp you can see that this is being raised if the filename for editing the task already exists:

  // Check if the file already exists, if so, bail out
  Path filepath = Path (file.str ());
  if (filepath.exists ())
    throw std::string ("Task is already being edited.");

So the fix here is to simply clean your ~/.task directory and make sure there are no *.task files there.

@tbabej tbabej closed this as completed Feb 19, 2020
@arooni
Copy link
Author

arooni commented Feb 19, 2020

@tbabej makes sense; it seems right now the only way to not get these extra *.task files is to use :q! which seems to terminate the whole nvim enterprise, not just the inner invocation used for taskwarrior.

so is there a best practice other than quitting out of nvim after each task edit?

definitely not trying to be a help vampire and i appreciate your help.

@arooni
Copy link
Author

arooni commented Feb 19, 2020

i.e. how to quit out of the inner layer of task warrior (the edit screen) without quitting out of nvim completely

@aaronfc
Copy link

aaronfc commented Mar 5, 2020

Setting the EDITOR environment variable didn't work for me. I ended up adding:

editor=nvim

to the ~/.taskrc file.

@arooni
Copy link
Author

arooni commented Mar 5, 2020

@aaronfc any way to quit out of the embedded editor window if you decide you don't want to make changes? i run :q and it seems to run the containing taskwarrior window. running :bd simply kills the buffer and taskwarrior keeps *.task files in my ~/.taskwarrior directory that prevent me from editing the same task again until I clear them out.

finally running :wq or :wq! from inside the editor (with no changes) shows "E382: Cannot write, 'buftype' option is set"

@aaronfc
Copy link

aaronfc commented Mar 29, 2020

@arooni You have first to go into insert mode (press i) and then you can quit by :q.

@arooni
Copy link
Author

arooni commented Mar 29, 2020

@aaronfc thanks so much for breaking that down!

@tmerse
Copy link

tmerse commented Jan 3, 2021

@arooni autocmd TermOpen * startinsert may safe you some typing aswell.

@maxksec
Copy link

maxksec commented Jun 9, 2022

Not sure if it is relevant yet, but I could not make it work with the previous suggestions. Ended up doing the following:

install neovim remote

pip3 install neovim-remote

sudo touch /usr/local/bin/nested-nvim
sudo chmod +x /usr/local/bin/nested-nvim

the contents of the file:

#!/bin/bash
if [ -n "$NVIM_LISTEN_ADDRESS" ]; then
  nvr -cc tabedit --remote-wait +'set bufhidden=wipe' "$@"
else
  "nvim" "$@"
fi

in .bashrc or .zshrc add

export VISUAL=nested-nvim
alias v="$VISUAL"
alias vim="$VISUAL"

reload shell

and after that the edit worked in place for me :)

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

No branches or pull requests

7 participants