Hotkey propagation stopped when Xcode focused
alanhamlett opened this issue · 10 comments
Check if applicable
- I have searched the existing issues (required)
- I reproduced the issue with an empty Neovim configuration (
init.vim
orinit.lua
) - I'm willing to help fix the problem and contribute a pull request
Describe the bug
I have some Mac hotkeys defined. When Xcode is focused and ShadowVim running, the hotkeys don't work, because ShadowVim is intercepting the keypresses and sending them to Neovim, but those hotkeys don't do anything in Neovim.
How to reproduce?
- Install iTerm2
- Set a hotkey to show/hide the terminal
- Focus Xcode.app with ShadowVim running
- Press the hotkey you defined
Neovim configuration
empty `init.vim`
Environment
ShadowVim 0.1.1 (2)
$ sw_vers -productVersion
13.2.1
$ uname -m
x86_64
$ whereis nvim
nvim: /usr/local/bin/nvim /usr/local/share/man/man1/nvim.1
$ nvim --version
NVIM v0.8.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Monterey
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/0.8.1/share/nvim"
Run :checkhealth for more info
$ xcodebuild -version
Xcode 14.2
Build version 14C18
$ defaults read -app Xcode KeyBindingsMode
Default
$ defaults read -app Xcode DVTTextAutoCloseBlockComment
0
$ defaults read -app Xcode DVTTextAutoInsertCloseBrace
0
$ defaults read -app Xcode DVTTextEditorTrimTrailingWhitespace
0
$ defaults read -app Xcode DVTTextEnableTypeOverCompletions
0
$ defaults read -app Xcode DVTTextIndentCaseInC
0
$ defaults read -app Xcode DVTTextUsesSyntaxAwareIndenting
0
Which hotkey did you use to show iTerm2? I didn't notice this issue because I'm using Cmd-Esc and there's a passthrough in ShadowVim for Cmd- shortcuts.
Eventually I want to add customized passthrough in ShadowVim's preferences. But for now, I can think of a workaround by adding this kind of mapping in your init.vim
:
// Example with Alt-Esc
map <M-Esc> <Cmd>SVPressKeys <LT>M-Esc><CR>
This will send back the keyboard shortcut to Xcode, acting as a sort of passthrough.
Note that this will not work with the current version because I'm triggering SVPressKeys
in the Xcode process instead of on the system. I'll create a PR later today to change that so it works to open iTerm 2.
Which hotkey did you use to show iTerm2?
Option-Backtick (⌥-`)
@alanhamlett Try this out after compiling ShadowVim from the latest main
:
if exists('g:shadowvim')
map <A-`> <Cmd>SVPressKeys <LT>A-`><CR>
endif
It probably works, but I can't test it because the product built from master crashes immediately after running. Should I use Console.app
to get the crash message? I looked there and see menu.mickael.ShadowVim is not a MetricKit client
but not sure if that's related.
How did you build ShadowVim? Don't you see the error when running from Xcode?
You need XcodeGen to generate the Xcode project with make project
.
Also the released binary and the debug one from Xcode are considered different by macOS, so you will need to remove ShadowVim from the Accessibility permissions in the system setting and add it again after launching the new build.
You need XcodeGen to generate the Xcode project with
make project
.
Yep, I generated the project using make project
/xcodegen
.
Then I opened the project in Xcode, pressed ⌘-B
and it showed Build Succeeded
.
Then I went to Products
folder and ran ShadowVim.app
but it doesn't seem to do anything.
I didn't remove ShadowVim from the Accessibility permissions at first, but I tried that and still not working.
Want to screenshare over Zoom?
Ha, I think it might be because you need to set your development team in the code signing build settings. The app requires sandboxing off which needs a Developer ID certificate, I think.
You can should be able to see the error if you use Run ⌘R instead of Build.
Anyways, I built a notarized version myself, it will be easier: ShadowVim.zip
Ha, I think it might be because you need to set your development team in the code signing build settings. The app requires sandboxing off which needs a Developer ID certificate, I think.
That looks like it. With ⌘R
I get this error:
not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)
The passthrough works now, thanks!