Closed C-Loftus closed 5 months ago
Fyi this is the ctx matching code I was working with in light of what we have been discussing on slack
from talon import Context, Module, actions, app, settings, ui
mod = Module()
ctx = Context()
# Neovim (commandline version) and nvim-qt.exe (GUI version)
mod.apps.neovim = """
win.title: /nvim/
win.title: /VIM MODE/
win.title: /Neovim/
"""
ctx.matches = r"""
app: neovim
"""
ctx.tags = ["user.command_client"]
@ctx.action_class("user")
class VimActions:
def command_server_directory() -> str:
return "neovim-command-server"
def trigger_command_server_command_execution():
actions.key("ctrl-q")
# Based on you using a custom titlestring see doc/vim.md
@ctx.action_class("user")
class win_actions:
def filename():
title = actions.win.title()
result = title.split(")")
if len(result) > 1:
# Assumes the last word after the last ) entry has the filename
result = result[-1]
# print(f"vim.filename(): {result.strip()}")
return result.strip()
else:
return ""
ctx.tags = ["user.cursorless"]
Thank you for the feedbacks.
For the command-client, I have added it to the code as you pointed out https://github.com/hands-free-vim/neovim-talon/commit/e01b628dd0afa8a6ca1aa2a5512cc423f4facf33.
For the cursorless tag, it is now part of the cursorless.nvim installation documentation https://github.com/hands-free-vim/cursorless.nvim?tab=readme-ov-file#talon-configuration
For the neovim app detection, I am wondering if win.title: /VIM MODE/
is a good one. Iirc some people use https://github.com/hands-free-vim/talon-vim which relies on VIM MODE
being in the window title, but they might not use neovim and instead use gvim or other vim-based editors. If that is the case, and they add neovim-talon, their other vim-based editor would be detected as neovim app but that would be incorrect.
FWIW the current code is Windows-based only due to me testing on Windows only (see https://github.com/hands-free-vim/neovim-talon/blob/9d01b7023085cbf3b1f5aa665674d0236b967cc2/apps/neovim.py#L6). I guess we could still have a false positive with the current code when conhost.exe
is the one detected by Talon as being gvim or other vim-based editor. So in that sense, we are not gaining anything specifying the app.exe and your method is simpler.
Any thoughts @fidgetingbits?
I guess that could be closed now that the last point has been solved with your PR https://github.com/hands-free-vim/neovim-talon/pull/4?
Correct should be all set!
Talon doesn't recognize neovim as neovim but rather just recognizes it as vim. Not sure if that is an issue for this repo or upstream somehow. I am on ubuntu 22.04 with kitty as my terminal
I am also finding that the
tag(): user.cursorless
is not being set anywhere. Where does the user enable this to allow cursorless commands to work in neovim?Finally, when I change the context match to just
app: vim
and manually enabletag(): user.cursorless
on theapp: vim
match, cursorless commands fail because the context match for the command server doesn't seem to work with neovim. Are there any settings that need to be changed for that?Thanks for all your work on this :pray: