Repository: xonsh/xonsh

Issue:
Can't use neovim (previously: Alias resolution in threadable prediction is broken again?)
I use neovim (aliased to vim as aliases['vi'] = 'nvim'). Finding a commit where it works without touching `__xonsh_commands_cache__.threadable_predictors` is not an easy task:

* at debian's 0.5.2 it was working OK.
* at 7a44848d4cfbb542deb87fd282f1dbc945959e11 (recent and seemingly relevant commit by @scopatz) it works OK.
* at intermediate commits from [builtins.py history](https://github.com/xonsh/xonsh/commits/master/xonsh/built_ins.py) (e.g. 80d4afdd91797ecff3ffb9f4b63afd30c57ad907) neovim doesn't even start (`termios.error: (5, 'Input/output error')`)
* at 77d30597a6c5f21545f051a0f121de967d2666f0 and later commits it misbehaves badly, all keypresses are output in bold instead of commands being executed. unusable.

Seems like you've introduced those "threadable predictors" kludge, whatever magic it is, then recently they started to support aliases, but got broken nearly immediately after that.

This threadable prediction thing has to be some really worthy and unavoidable dark magic if you want to maintain it... How do other shells live without it?

If my findings are not well described enough, or my bug hunting was too sloppy, please tell me the direction in which to improve it.


Discussion:
Hi @t184256 Thanks for reporting. Have you tried it on v0.5.6? There was a bug in v0.5.5 related to threadable predictors and aliases but it should be fixed now.
Yes, and it's broken on 0.5.6 in this specific way:

> at 77d3059 and later commits it misbehaves badly, all keypresses are output in bold instead of commands being executed. unusable.
Ok, and what is the output of the `xonfig` command?
```
$ xonfig
+------------------+-----------------+
| xonsh            | 0.5.6           |
| Python           | 3.5.3           |
| PLY              | 3.9             |
| have readline    | True            |
| prompt toolkit   | 1.0.9           |
| shell type       | prompt_toolkit  |
| pygments         | 2.1.3           |
| on posix         | True            |
| on linux         | True            |
| distro           | debian          |
| on darwin        | False           |
| on windows       | False           |
| on cygwin        | False           |
| is superuser     | False           |
| default encoding | utf-8           |
| xonsh encoding   | utf-8           |
| encoding errors  | surrogateescape |
+------------------+-----------------+
```
Thanks for the detailed analysis here @t184256. I don't think that this is an alias resolution issue. Rather, it seems like it comes from the changes to some of out job control. @mitnk most recently touched that, so maybe he can chime in here.  As a quick test, though, can you try running `nvim` directly (without aliases) and test to see if it is still broken? I strongly suspect that it is.
I hope I've understood your directions right. I installed xonsh from master, deleted aliases from my .xonshrc and executed `/usr/bin/nvim`; got the same bug. Reverted to 7a44848d4cfbb542deb87fd282f1dbc945959e11; the bug disappeared.

Additionally, on both 7a44848d4cfbb542deb87fd282f1dbc945959e11 and master:
1. If I use `vim`, `vim` just works OK
2. If I use `__xonsh_commands_cache__.threadable_predictors['nvim'] = lambda args: False` `nvim` works OK.

Maybe aliases are totally unrelated and I was misleading. In that case my point is simpler: on 7a44848d4cfbb542deb87fd282f1dbc945959e11 `nvim` worked OK. Now it doesn't.
Hi @t184256 

1. is your `/usr/bin/nvim` a binary or a soft link to another binary?

2. when you reproduce this issue, what's the command you typed? just a bare `nvim` (without file names?) ?

EDIT: deleted a unrelated patch.

------------

I tried mimic the issue by a `cp /usr/local/bin/vim /usr/local/bin/nvim`. But cannot reproduce the issue.
Ok, on your last comment, I guess `/usr/bin/nvim` is a script and not a regular binary? If so, what's the header of this script?

Resolving patch:
diff --git a/xonsh/commands_cache.py b/xonsh/commands_cache.py
--- a/xonsh/commands_cache.py
+++ b/xonsh/commands_cache.py
@@ -353,6 +353,7 @@ def default_threadable_predictors():
         'mvim': predict_help_ver,
         'mutt': predict_help_ver,
         'nano': predict_help_ver,
+        'nvim': predict_false,
         'psql': predict_false,
         'python': predict_shell,
         'python2': predict_shell,


Test patch: