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

Support for more terminal emulators #90

Closed
jbbudzon opened this issue Jan 23, 2020 · 5 comments
Closed

Support for more terminal emulators #90

jbbudzon opened this issue Jan 23, 2020 · 5 comments

Comments

@jbbudzon
Copy link

Describe the bug
Vimspector seems to work just fine for me if I use terminal.app. When telling Vimspector to launch a debugging session, a new terminal.app window spawns, some commands execute in the newly spawned window, and Vimspector properly starts debugging.

This also appears to be true for iTerm2. When telling Vimspector to launch a debugging session, a new terminal.app window spawns (NOT an iTerm2 window). The first time I performed this test, OSX asked me if I wanted to allow iTerm2 to control terminal.app. I said yes. Once this was performed, some commands execute in the newly spawned terminal.app window, and Vimspector properly starts debugging.

If I run this test with Kitty.app, however, Vimspector times out. In this case, telling Vimspector to launch a debugging session causes a terminal.app window to spawn (similar to iTerm2). However, I was never prompted about allowing kitty to control terminal.app. Therefore, no commands ever execute in the newly spawned terminal.app window. This results in Vimspector timing out.

To Reproduce
Attempt to use Vimspector with kitty.app. The result is a time out.
Using iTerm2 with Vimspector results in a terminal.app window spawning, not an iTerm2 window.

Vimspector config file:

{
  "configurations": {
    "TestName: Launch": {
      "adapter": "lldb-vscode",
      "configuration": {
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceRoot}/a.out",
        "cwd": "${workspaceRoot}",
        "externalConsole": true,
        "stopAtEntry": true,
        "MIMode": "lldb",
        "logging": {
          "engineLogging": false
        }
      }
    },
    "TestName: Attach": {
      "adapter": "lldb-vscode",
      "configuration": {
        "name": "TestName: Attach",
        "type": "cppdbg",
        "request": "attach",
        "program": "${workspaceRoot}/a.out",
        "MIMode": "lldb"
      }
    }
  }
}

Expected behavior
There are a few things that would fulfill my expected behavior. One would be that the kitty project add support for controlling terminal.app the same way iTerm does. This should result in kitty.app working no differently than iTerm2.
However, I do find it odd that iTerm2 spawns a terminal.app window instead of a iTerm2 window. Perhaps, this is just a matter of OS configuration? If so, maybe we can document this in the readme?

Actual behaviour
kitty.app causes Vimspector to time out.
iTerm2 launches terminal.app, rather than launching an iTerm2 window.

Please include:

  • Vimspector log (~/.vimspector.log)
2020-01-23 10:30:26,440 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2020-01-23 10:30:26,441 - INFO - API is: 
2020-01-23 10:30:26,441 - INFO - VIMSPECTOR_HOME = /Users/bbudzon/.vim/pack/natpack/opt/vimspector
2020-01-23 10:30:26,447 - INFO - gadgetDir = /Users/bbudzon/.vim/pack/natpack/opt/vimspector/gadgets/macos
2020-01-23 10:30:26,448 - INFO - User requested start debug session with {}
2020-01-23 10:30:26,448 - DEBUG - Reading gadget config: /Users/bbudzon/.vim/pack/natpack/opt/vimspector/gadgets/macos/.gadgets.json
2020-01-23 10:30:26,448 - DEBUG - Reading gadget config: /Users/bbudzon/.vim/pack/natpack/opt/vimspector/gadgets/macos/.gadgets.d/lldb-vscode.json
2020-01-23 10:30:26,449 - DEBUG - Reading gadget config: None
2020-01-23 10:30:29,117 - DEBUG - Set new_variables[ LLVM ] to '/usr/local/opt/llvm' from {'shell': 'brew --prefix llvm'} from {'shell': 'brew --prefix llvm'}
2020-01-23 10:30:29,117 - INFO - Configuration: {"adapter": "lldb-vscode", "configuration": {"type": "cppdbg", "request": "launch", "program": "/Users/bbudzon/srcbuild/test/a.out", "cwd": "/Users/bbudzon/srcbuild/test", "externalConsole": true, "stopAtEntry": true, "MIMode": "lldb", "logging": {"engineLogging": false}}}
2020-01-23 10:30:29,117 - INFO - Adapter: {"variables": {"LLVM": {"shell": "brew --prefix llvm"}}, "attach": {"pidProperty": "pid", "pidSelect": "ask"}, "command": ["/usr/local/opt/llvm/bin/lldb-vscode"], "env": {"LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY": "NO"}, "name": "lldb"}
2020-01-23 10:30:29,198 - INFO - Starting debug adapter with: {"variables": {"LLVM": {"shell": "brew --prefix llvm"}}, "attach": {"pidProperty": "pid", "pidSelect": "ask"}, "command": ["/usr/local/opt/llvm/bin/lldb-vscode"], "env": {"LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY": "NO"}, "name": "lldb"}
2020-01-23 10:30:29,205 - INFO - Debug Adapter Started
2020-01-23 10:30:29,205 - DEBUG - Sending Message: {"command": "initialize", "arguments": {"adapterID": "lldb", "clientID": "vimspector", "clientName": "vimspector", "linesStartAt1": true, "columnsStartAt1": true, "locale": "en_GB", "pathFormat": "path", "supportsVariableType": true, "supportsVariablePaging": false, "supportsRunInTerminalRequest": true}, "seq": 0, "type": "request"}
2020-01-23 10:30:29,205 - DEBUG - Calling: vimspector#internal#job#Send(g:vimspector_internal_arg_0)
2020-01-23 10:30:29,227 - INFO - Server stderr: error: module importing failed: loading unimplemented

2020-01-23 10:30:29,243 - DEBUG - Message received: {'body': {'exceptionBreakpointFilters': [{'default': False, 'filter': 'cpp_catch', 'label': 'C++ Catch'}, {'default': False, 'filter': 'cpp_throw', 'label': 'C++ Throw'}, {'default': False, 'filter': 'objc_catch', 'label': 'Objective C Catch'}, {'default': False, 'filter': 'objc_throw', 'label': 'Objective C Throw'}, {'default': False, 'filter': 'swift_catch', 'label': 'Swift Catch'}, {'default': False, 'filter': 'swift_throw', 'label': 'Swift Throw'}], 'supportTerminateDebuggee': True, 'supportsCompletionsRequest': False, 'supportsConditionalBreakpoints': True, 'supportsConfigurationDoneRequest': True, 'supportsDelayedStackTraceLoading': True, 'supportsEvaluateForHovers': True, 'supportsExceptionInfoRequest': True, 'supportsExceptionOptions': True, 'supportsFunctionBreakpoints': True, 'supportsGotoTargetsRequest': False, 'supportsHitConditionalBreakpoints': True, 'supportsLoadedSourcesRequest': False, 'supportsModulesRequest': False, 'supportsRestartFrame': False, 'supportsRestartRequest': False, 'supportsSetVariable': True, 'supportsStepBack': False, 'supportsStepInTargetsRequest': False, 'supportsValueFormattingOptions': True}, 'command': 'initialize', 'request_seq': 0, 'seq': 0, 'success': True, 'type': 'response'}
2020-01-23 10:30:29,244 - DEBUG - LAUNCH!
2020-01-23 10:30:29,244 - DEBUG - Sending Message: {"command": "launch", "arguments": {"type": "cppdbg", "request": "launch", "program": "/Users/bbudzon/srcbuild/test/a.out", "cwd": "/Users/bbudzon/srcbuild/test", "externalConsole": true, "stopAtEntry": true, "MIMode": "lldb", "logging": {"engineLogging": false}, "name": "test"}, "seq": 1, "type": "request"}
2020-01-23 10:30:29,244 - DEBUG - Calling: vimspector#internal#job#Send(g:vimspector_internal_arg_0)
2020-01-23 10:30:44,248 - DEBUG - Timeout: Aborting request {'command': 'launch', 'arguments': {'type': 'cppdbg', 'request': 'launch', 'program': '/Users/bbudzon/srcbuild/test/a.out', 'cwd': '/Users/bbudzon/srcbuild/test', 'externalConsole': True, 'stopAtEntry': True, 'MIMode': 'lldb', 'logging': {'engineLogging': False}, 'name': 'test'}, 'seq': 1, 'type': 'request'}
2020-01-23 10:30:44,249 - INFO - User Msg: Request for launch aborted: Timeout
  • Output from any or all UI diagnostic tabs (Server, etc.)

Did not see any output here.

Environment

NOTE: NeoVim is not supported.
NOTE: Windows is not supported.

  • Output of vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jan  8 2020 08:55:30)
macOS version
Compiled by bbudzon@bbudzonMBP.local
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_old_static
+arabic            +file_in_path      +mouse_urxvt       -tag_any_white
+autocmd           +find_in_path      +mouse_xterm       -tcl
+autochdir         +float             +multi_byte        +termguicolors
-autoservername    +folding           +multi_lang        +terminal
-balloon_eval      -footer            -mzscheme          +terminfo
+balloon_eval_term +fork()            -netbeans_intg     +termresponse
-browse            -gettext           +num64             +textobjects
++builtin_terms    -hangul_input      +packages          +textprop
+byte_offset       +iconv             +path_extra        +timers
+channel           +insert_expand     +perl              +title
+cindent           +job               +persistent_undo   -toolbar
-clientserver      +jumplist          +popupwin          +user_commands
+clipboard         +keymap            +postscript        +vartabs
+cmdline_compl     +lambda            +printer           +vertsplit
+cmdline_hist      +langmap           +profile           +virtualedit
+cmdline_info      +libcall           -python            +visual
+comments          +linebreak         +python3           +visualextra
+conceal           +lispindent        +quickfix          +viminfo
+cryptv            +listcmds          +reltime           +vreplace
+cscope            +localmap          +rightleft         +wildignore
+cursorbind        -lua               +ruby              +wildmenu
+cursorshape       +menu              +scrollbind        +windows
+dialog_con        +mksession         +signs             +writebackup
+diff              +modify_fname      +smartindent       -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        -mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L.  -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework AppKit   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.3.0 -ldl -lobjc
  • Output of which vim:
/usr/local/bin/vim
  • Output of :py3 pass:

I did not receive any output from this command?

  • Operating system: macOS 10.14.6

Additional context
One thing I did notice is that iTerm2 has the ability to control terminal.app via OSX Security settings. Kitty does not have this and I presume is why kitty behaves differently than iTerm2 (although I'm not entirely certain that iTerm2's behavior is desirable).

@puremourning
Copy link
Owner

None of this is controlled by Vimspector, it's all the debug adapter you're using.

If you don't want a new Terminal.app window to open, remove this from the adapter config:

"env": {"LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY": "NO"}

NOTE: Setting the variable to "NO" has the same effect as it being set to "YES". The behaviour is enabled in lldb code when the variable is set

This is entirely at the behest of lldb-vscode. Unfortunately it's a restriction of lldb that we can't launch the app in Vim's embedded terminal. This is true for both lldb-vscode (which you're using) and vscode-cpptools, which currently has other issues.


That said, I can't explain the Kitty behaviour you're seeing (it must be something about your environment), because it worked for me. I don't use Kitty, but I just installed it following their website instructions and tested Vimspector 👍

Screenshot 2020-01-23 at 20 16 03

@puremourning
Copy link
Owner

Oh, you might be able to get a better experience with the built-in Vim terminal by using vscode-cpptools with gdb. That requires::

  • Install gdb (with homebrew)
  • code sign gdb - if you don't do this it won't work. google for instructions.
  • remove the workaround to use vscode-lldb in place of vscode-cpptools (remove /path/to/Vimspector/gadgets/macos/.gadgets.d/vscode-cpptools.json)
  • add "MIMode": "gdb" to the launch configuration in your .vimspector.json

I know, lots of fiddly steps. This all worked great until vscode-cpptools stopped working with the Catalina upgrade.

FWIW, all of these problems also exist for VSCode users, but I'm the one trying to fix them

@puremourning
Copy link
Owner

Closing because;

  • Kitty WFM
  • Nothing else is controlled by Vimspector.

@jbbudzon
Copy link
Author

Thanks guys! Sorry for the false report. I thought I had tried removing the LLDB_LAUNCH_FLAG_LAUNCH_IN_TTY and it didn't work, but clearly I am wrong!

I now have kitty.app working just fine and no extra terminal windows are spawning which is even nicer!

@puremourning
Copy link
Owner

great 👍

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants