Skip to content

Commit fef40a9

Browse files
authored
Merge pull request #4 from keith/ks/convert-to-use-python3
Convert to use python3
2 parents 1fafe87 + 63d3ff3 commit fef40a9

File tree

4 files changed

+66
-67
lines changed

4 files changed

+66
-67
lines changed

README

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ This plugin is known to work with the following flavours of Vim:
1111
* Linux (tested on Ubuntu 12.04/12.10):
1212
* vim/gvim (from vim-gnome package version 7.3)
1313

14-
* Mac OS X (tested on Mountain Lion)
15-
* Vim command-line (7.3 from Xcode)
14+
* macOS (tested on Monterey)
15+
* Vim command-line (8.2 from homebrew)
1616
* MacVim 7.3
1717

1818
To install the plugin, ensure you have
1919
* a working version of lldb on your path, or the environment variable LLDB
2020
pointing to the lldb binary you would like to use.
21-
* a python-enabled vim (check with ":python print 2")
21+
* a python3-enabled vim (check with "vim --version | grep python3")
2222

2323

2424
Installation

plugin/lldb.vim

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ function! s:FindPythonScriptDir()
1313
endfunction()
1414

1515
function! s:InitLldbPlugin()
16-
if has('python') == 0
17-
call confirm('ERROR: This Vim installation does not have python support. lldb.vim will not work.')
16+
if !has('python3')
17+
call confirm('ERROR: This Vim installation does not have python3 support. lldb.vim will not work.')
1818
return
1919
endif
20-
20+
2121
" Key-Bindings
2222
" FIXME: choose sensible keybindings for:
2323
" - process: start, interrupt, continue, continue-to-cursor
@@ -29,10 +29,10 @@ function! s:InitLldbPlugin()
2929
endif
3030

3131
"
32-
" Setup the python interpreter path
32+
" Setup the python3 interpreter path
3333
"
3434
let vim_lldb_pydir = s:FindPythonScriptDir()
35-
execute 'python import sys; sys.path.append("' . vim_lldb_pydir . '")'
35+
execute 'python3 import sys; sys.path.append("' . vim_lldb_pydir . '")'
3636

3737
"
3838
" Register :L<Command>
@@ -41,86 +41,86 @@ function! s:InitLldbPlugin()
4141
"
4242

4343
" Window show/hide commands
44-
command -complete=custom,s:CompleteWindow -nargs=1 Lhide python ctrl.doHide('<args>')
45-
command -complete=custom,s:CompleteWindow -nargs=0 Lshow python ctrl.doShow('<args>')
46-
44+
command -complete=custom,s:CompleteWindow -nargs=1 Lhide python3 ctrl.doHide('<args>')
45+
command -nargs=0 Lshow python3 ctrl.doShow('<args>')
46+
4747
" Launching convenience commands (no autocompletion)
48-
command -nargs=* Lstart python ctrl.doLaunch(True, '<args>')
49-
command -nargs=* Lrun python ctrl.doLaunch(False, '<args>')
50-
command -nargs=1 Lattach python ctrl.doAttach('<args>')
51-
command -nargs=0 Ldetach python ctrl.doDetach()
48+
command -nargs=* Lstart python3 ctrl.doLaunch(True, '<args>')
49+
command -nargs=* Lrun python3 ctrl.doLaunch(False, '<args>')
50+
command -nargs=1 Lattach python3 ctrl.doAttach('<args>')
51+
command -nargs=0 Ldetach python3 ctrl.doDetach()
5252

5353
" Regexp-commands: because vim's command mode does not support '_' or '-'
5454
" characters in command names, we omit them when creating the :L<cmd>
5555
" equivalents.
56-
command -complete=custom,s:CompleteCommand -nargs=* Lregexpattach python ctrl.doCommand('_regexp-attach', '<args>')
57-
command -complete=custom,s:CompleteCommand -nargs=* Lregexpbreak python ctrl.doCommand('_regexp-break', '<args>')
58-
command -complete=custom,s:CompleteCommand -nargs=* Lregexpbt python ctrl.doCommand('_regexp-bt', '<args>')
59-
command -complete=custom,s:CompleteCommand -nargs=* Lregexpdown python ctrl.doCommand('_regexp-down', '<args>')
60-
command -complete=custom,s:CompleteCommand -nargs=* Lregexptbreak python ctrl.doCommand('_regexp-tbreak', '<args>')
61-
command -complete=custom,s:CompleteCommand -nargs=* Lregexpdisplay python ctrl.doCommand('_regexp-display', '<args>')
62-
command -complete=custom,s:CompleteCommand -nargs=* Lregexpundisplay python ctrl.doCommand('_regexp-undisplay', '<args>')
63-
command -complete=custom,s:CompleteCommand -nargs=* Lregexpup python ctrl.doCommand('_regexp-up', '<args>')
64-
65-
command -complete=custom,s:CompleteCommand -nargs=* Lapropos python ctrl.doCommand('apropos', '<args>')
66-
command -complete=custom,s:CompleteCommand -nargs=* Lbacktrace python ctrl.doCommand('bt', '<args>')
67-
command -complete=custom,s:CompleteCommand -nargs=* Lbreakpoint python ctrl.doBreakpoint('<args>')
68-
command -complete=custom,s:CompleteCommand -nargs=* Lcommand python ctrl.doCommand('command', '<args>')
69-
command -complete=custom,s:CompleteCommand -nargs=* Ldisassemble python ctrl.doCommand('disassemble', '<args>')
70-
command -complete=custom,s:CompleteCommand -nargs=* Lexpression python ctrl.doCommand('expression', '<args>')
71-
command -complete=custom,s:CompleteCommand -nargs=* Lhelp python ctrl.doCommand('help', '<args>')
72-
command -complete=custom,s:CompleteCommand -nargs=* Llog python ctrl.doCommand('log', '<args>')
73-
command -complete=custom,s:CompleteCommand -nargs=* Lplatform python ctrl.doCommand('platform','<args>')
74-
command -complete=custom,s:CompleteCommand -nargs=* Lplugin python ctrl.doCommand('plugin', '<args>')
75-
command -complete=custom,s:CompleteCommand -nargs=* Lprocess python ctrl.doProcess('<args>')
76-
command -complete=custom,s:CompleteCommand -nargs=* Lregister python ctrl.doCommand('register', '<args>')
77-
command -complete=custom,s:CompleteCommand -nargs=* Lscript python ctrl.doCommand('script', '<args>')
78-
command -complete=custom,s:CompleteCommand -nargs=* Lsettings python ctrl.doCommand('settings','<args>')
79-
command -complete=custom,s:CompleteCommand -nargs=* Lsource python ctrl.doCommand('source', '<args>')
80-
command -complete=custom,s:CompleteCommand -nargs=* Ltype python ctrl.doCommand('type', '<args>')
81-
command -complete=custom,s:CompleteCommand -nargs=* Lversion python ctrl.doCommand('version', '<args>')
82-
command -complete=custom,s:CompleteCommand -nargs=* Lwatchpoint python ctrl.doCommand('watchpoint', '<args>')
83-
56+
command -complete=custom,s:CompleteCommand -nargs=* Lregexpattach python3 ctrl.doCommand('_regexp-attach', '<args>')
57+
command -complete=custom,s:CompleteCommand -nargs=* Lregexpbreak python3 ctrl.doCommand('_regexp-break', '<args>')
58+
command -complete=custom,s:CompleteCommand -nargs=* Lregexpbt python3 ctrl.doCommand('_regexp-bt', '<args>')
59+
command -complete=custom,s:CompleteCommand -nargs=* Lregexpdown python3 ctrl.doCommand('_regexp-down', '<args>')
60+
command -complete=custom,s:CompleteCommand -nargs=* Lregexptbreak python3 ctrl.doCommand('_regexp-tbreak', '<args>')
61+
command -complete=custom,s:CompleteCommand -nargs=* Lregexpdisplay python3 ctrl.doCommand('_regexp-display', '<args>')
62+
command -complete=custom,s:CompleteCommand -nargs=* Lregexpundisplay python3 ctrl.doCommand('_regexp-undisplay', '<args>')
63+
command -complete=custom,s:CompleteCommand -nargs=* Lregexpup python3 ctrl.doCommand('_regexp-up', '<args>')
64+
65+
command -complete=custom,s:CompleteCommand -nargs=* Lapropos python3 ctrl.doCommand('apropos', '<args>')
66+
command -complete=custom,s:CompleteCommand -nargs=* Lbacktrace python3 ctrl.doCommand('bt', '<args>')
67+
command -complete=custom,s:CompleteCommand -nargs=* Lbreakpoint python3 ctrl.doBreakpoint('<args>')
68+
command -complete=custom,s:CompleteCommand -nargs=* Lcommand python3 ctrl.doCommand('command', '<args>')
69+
command -complete=custom,s:CompleteCommand -nargs=* Ldisassemble python3 ctrl.doCommand('disassemble', '<args>')
70+
command -complete=custom,s:CompleteCommand -nargs=* Lexpression python3 ctrl.doCommand('expression', '<args>')
71+
command -complete=custom,s:CompleteCommand -nargs=* Lhelp python3 ctrl.doCommand('help', '<args>')
72+
command -complete=custom,s:CompleteCommand -nargs=* Llog python3 ctrl.doCommand('log', '<args>')
73+
command -complete=custom,s:CompleteCommand -nargs=* Lplatform python3 ctrl.doCommand('platform','<args>')
74+
command -complete=custom,s:CompleteCommand -nargs=* Lplugin python3 ctrl.doCommand('plugin', '<args>')
75+
command -complete=custom,s:CompleteCommand -nargs=* Lprocess python3 ctrl.doProcess('<args>')
76+
command -complete=custom,s:CompleteCommand -nargs=* Lregister python3 ctrl.doCommand('register', '<args>')
77+
command -complete=custom,s:CompleteCommand -nargs=* Lscript python3 ctrl.doCommand('script', '<args>')
78+
command -complete=custom,s:CompleteCommand -nargs=* Lsettings python3 ctrl.doCommand('settings','<args>')
79+
command -complete=custom,s:CompleteCommand -nargs=* Lsource python3 ctrl.doCommand('source', '<args>')
80+
command -complete=custom,s:CompleteCommand -nargs=* Ltype python3 ctrl.doCommand('type', '<args>')
81+
command -complete=custom,s:CompleteCommand -nargs=* Lversion python3 ctrl.doCommand('version', '<args>')
82+
command -complete=custom,s:CompleteCommand -nargs=* Lwatchpoint python3 ctrl.doCommand('watchpoint', '<args>')
83+
8484
" Convenience (shortcut) LLDB commands
85-
command -complete=custom,s:CompleteCommand -nargs=* Lprint python ctrl.doCommand('print', vim.eval("s:CursorWord('<args>')"))
86-
command -complete=custom,s:CompleteCommand -nargs=* Lpo python ctrl.doCommand('po', vim.eval("s:CursorWord('<args>')"))
87-
command -complete=custom,s:CompleteCommand -nargs=* LpO python ctrl.doCommand('po', vim.eval("s:CursorWORD('<args>')"))
88-
command -complete=custom,s:CompleteCommand -nargs=* Lbt python ctrl.doCommand('bt', '<args>')
85+
command -complete=custom,s:CompleteCommand -nargs=* Lprint python3 ctrl.doCommand('print', vim.eval("s:CursorWord('<args>')"))
86+
command -complete=custom,s:CompleteCommand -nargs=* Lpo python3 ctrl.doCommand('po', vim.eval("s:CursorWord('<args>')"))
87+
command -complete=custom,s:CompleteCommand -nargs=* LpO python3 ctrl.doCommand('po', vim.eval("s:CursorWORD('<args>')"))
88+
command -complete=custom,s:CompleteCommand -nargs=* Lbt python3 ctrl.doCommand('bt', '<args>')
8989

9090
" Frame/Thread-Selection (commands that also do an Uupdate but do not
9191
" generate events in LLDB)
92-
command -complete=custom,s:CompleteCommand -nargs=* Lframe python ctrl.doSelect('frame', '<args>')
93-
command -complete=custom,s:CompleteCommand -nargs=? Lup python ctrl.doCommand('up', '<args>', print_on_success=False, goto_file=True)
94-
command -complete=custom,s:CompleteCommand -nargs=? Ldown python ctrl.doCommand('down', '<args>', print_on_success=False, goto_file=True)
95-
command -complete=custom,s:CompleteCommand -nargs=* Lthread python ctrl.doSelect('thread', '<args>')
92+
command -complete=custom,s:CompleteCommand -nargs=* Lframe python3 ctrl.doSelect('frame', '<args>')
93+
command -complete=custom,s:CompleteCommand -nargs=? Lup python3 ctrl.doCommand('up', '<args>', print_on_success=False, goto_file=True)
94+
command -complete=custom,s:CompleteCommand -nargs=? Ldown python3 ctrl.doCommand('down', '<args>', print_on_success=False, goto_file=True)
95+
command -complete=custom,s:CompleteCommand -nargs=* Lthread python3 ctrl.doSelect('thread', '<args>')
9696

97-
command -complete=custom,s:CompleteCommand -nargs=* Ltarget python ctrl.doTarget('<args>')
97+
command -complete=custom,s:CompleteCommand -nargs=* Ltarget python3 ctrl.doTarget('<args>')
9898

9999
" Continue
100-
command -complete=custom,s:CompleteCommand -nargs=* Lcontinue python ctrl.doContinue()
100+
command -complete=custom,s:CompleteCommand -nargs=* Lcontinue python3 ctrl.doContinue()
101101

102102
" Thread-Stepping (no autocompletion)
103-
command -nargs=0 Lstepinst python ctrl.doStep(StepType.INSTRUCTION)
104-
command -nargs=0 Lstepinstover python ctrl.doStep(StepType.INSTRUCTION_OVER)
105-
command -nargs=0 Lstepin python ctrl.doStep(StepType.INTO)
106-
command -nargs=0 Lstep python ctrl.doStep(StepType.INTO)
107-
command -nargs=0 Lnext python ctrl.doStep(StepType.OVER)
108-
command -nargs=0 Lfinish python ctrl.doStep(StepType.OUT)
103+
command -nargs=0 Lstepinst python3 ctrl.doStep(StepType.INSTRUCTION)
104+
command -nargs=0 Lstepinstover python3 ctrl.doStep(StepType.INSTRUCTION_OVER)
105+
command -nargs=0 Lstepin python3 ctrl.doStep(StepType.INTO)
106+
command -nargs=0 Lstep python3 ctrl.doStep(StepType.INTO)
107+
command -nargs=0 Lnext python3 ctrl.doStep(StepType.OVER)
108+
command -nargs=0 Lfinish python3 ctrl.doStep(StepType.OUT)
109109

110110
" hack: service the LLDB event-queue when the cursor moves
111111
" FIXME: some threaded solution would be better...but it
112112
" would have to be designed carefully because Vim's APIs are non threadsafe;
113113
" use of the vim module **MUST** be restricted to the main thread.
114-
command -nargs=0 Lrefresh python ctrl.doRefresh()
114+
command -nargs=0 Lrefresh python3 ctrl.doRefresh()
115115
autocmd CursorMoved * :Lrefresh
116116
autocmd CursorHold * :Lrefresh
117-
autocmd VimLeavePre * python ctrl.doExit()
117+
autocmd VimLeavePre * python3 ctrl.doExit()
118118

119-
execute 'pyfile ' . vim_lldb_pydir . '/plugin.py'
119+
execute 'py3file ' . vim_lldb_pydir . '/plugin.py'
120120
endfunction()
121121

122122
function! s:CompleteCommand(A, L, P)
123-
python << EOF
123+
python3 << EOF
124124
a = vim.eval("a:A")
125125
l = vim.eval("a:L")
126126
p = vim.eval("a:P")
@@ -129,7 +129,7 @@ EOF
129129
endfunction()
130130

131131
function! s:CompleteWindow(A, L, P)
132-
python << EOF
132+
python3 << EOF
133133
a = vim.eval("a:A")
134134
l = vim.eval("a:L")
135135
p = vim.eval("a:P")

python-vim-lldb/import_lldb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def import_lldb():
3636
"%s -P" %
3737
lldb_executable,
3838
shell=True,
39-
stderr=fnull).strip()
39+
stderr=fnull).strip().decode()
4040
if not os.path.exists(lldb_minus_p_path):
4141
# lldb -P returned invalid path, probably too old
4242
pass

python-vim-lldb/vim_panes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,8 @@ def write(self, msg):
368368
""" replace buffer with msg"""
369369
self.prepare()
370370

371-
msg = str(msg.encode("utf-8", "replace")).split('\n')
372371
try:
373-
self.buffer.append(msg)
372+
self.buffer.append(msg.splitlines())
374373
vim.command("execute \"normal ggdd\"")
375374
except vim.error:
376375
# cannot update window; happens when vim is exiting.

0 commit comments

Comments
 (0)