-
Notifications
You must be signed in to change notification settings - Fork 32
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
Doesn't work under virtual environment #48
Comments
|
It's the title of each kitty window, yes. I'm using SwayFX window manager, I guess it could be set there, both Sway in Wayland and i3 in X11 use this property to display window titles in the UI, but I always assumed that applications set these properties through Wayland / X. Not sure if this works the same in GNOME, KDE, etc. This is how the example window looks when I run [
{
"at_prompt": false,
"cmdline": [
"/usr/bin/zsh"
],
"columns": 126,
"cwd": "/home/simon/test",
"env": {
"KITTY_WINDOW_ID": "1",
"PWD": "/home/simon"
},
"foreground_processes": [
{
"cmdline": [
"/usr/bin/python",
"/home/simon/.local/bin/pipenv",
"shell"
],
"cwd": "/home/simon",
"pid": 408767
}
],
"id": 1,
"is_active": false,
"is_focused": false,
"is_self": false,
"lines": 30,
"pid": 407939,
"title": "nvim",
"user_vars": {}
},
{
"at_prompt": false,
"cmdline": [
"/usr/bin/zsh"
],
"columns": 126,
"cwd": "/home/simon/test",
"env": {
"KITTY_WINDOW_ID": "2",
"PWD": "/home/simon/test"
},
"foreground_processes": [
{
"cmdline": [
"kitten",
"@",
"ls"
],
"cwd": "/home/simon/test",
"pid": 447456
},
{
"cmdline": [
"jq",
".[].tabs.[].windows"
],
"cwd": "/home/simon/test",
"pid": 447457
}
],
"id": 2,
"is_active": true,
"is_focused": true,
"is_self": true,
"lines": 30,
"pid": 408568,
"title": "kitty @ ls | jq '.[].tabs.[].windows'",
"user_vars": {}
}
] |
I found one issue with this, though. When I send nvim to the background via |
if window is None:
return
cmd = window.child.foreground_cmdline[0]
print(cmd)
# if is_window_vim(window, vim_id):
if cmd[-4:] == "nvim":
for keymap in key_mapping.split(">"):
encoded = encode_key_mapping(window, keymap)
window.write_to_child(encoded) when the focus terminal , the result of the terminal is "-zsh", and when the focus nvim , the result is nvim. perfectly solved the problem of nvim being in a python virtual environment |
Interesting, so it seems like |
It doesn't actually work for me. Interestingly, the values depend on wether I run nvim using
In the first case, both Funnily enough, in the second case ( However, a combination of the original check + def is_window_vim(window, vim_id):
fp = window.child.foreground_processes
return window.title == 'nvim' or any(re.search(vim_id, p['cmdline'][0] if len(p['cmdline']) else '', re.I) for p in fp) I switched to the literal check |
@SLeitgeb That's odd, I'm using a virtual environment provided by pyenv, It may be that the tools have different implementation mechanisms |
@nanmoumou That's interesting, I thought pyenv doesn't actually deal with virtual environments, but let's you switch python versions by setting the PATH environment variable. I guess all the tools behave differently based on what processes they call, etc. |
I noticed that navigation doesn't work in nvim instances launched from an activated virtual environments (I use
pipenv shell
for this).Debugging with the recommended
print(fp)
, I noticed thatnvim
is not reported in thecmdline
key:After a bit of exploration, I managed to get navigation working by extending the matching logic to also look at the current window title like this:
Not sure if this is a good idea, thoughts? Would this fail in some scenario or could it have some unintended consequences? Anyway, it works at least as a temporary workaround.
The text was updated successfully, but these errors were encountered: