vimspector

require:vim 8.1.1264, neovim 0.4.3

OS: Linux / MacOS

安装

使用vim-plug

1
Plug 'puremourning/vimspector'

安装对应语言调试工具

1
2
3
4
5
6
7
cd ~/.vim/plugged/vimspector
# c, c++
./install_gadget.py --enable-c
# python
./install_gadget.py --enable-python
# go
./install_gadget.py --enable-go

快捷键

预置两套快捷键Visual Studio, VSCode,也可以自行定制自己的快捷键

1
let g:vimspector_enable_mappings = 'VISUAL_STUDIO'

使用

创建配置文件 .vimspector.json,在一个配置文件中可以有多个调试配置,启动调试时进行选取。这里有一个小问题,配置是字典形式,不是数组,所以在选取时的顺序未必是你所书写的顺序。

下面是调试 C 程序的配置例子:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
  "configurations": {
    "Cpp: Launch": {
      "adapter": "vscode-cpptools",
      "configuration": {
        "name": "Cpp: Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceRoot}/a.out",
        "args": [],
        "cwd": "${workspaceRoot}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb"
      }
    },
    "Cpp: Attach": {
      "adapter": "vscode-cpptools",
      "configuration": {
        "name": "Cpp: Attach",
        "type": "cppdbg",
        "request": "attach",
        "program": "${workspaceRoot}/a.out",
        "MIMode": "gdb"
      }
    }
  }
}

退出调试:点击WinBar按钮Reset,或者使用命令:VimspectorReset

vimspector