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

Improve error handling #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions plugin/lldb.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ function! s:InitLldbPlugin()
return
endif

"
" Setup the python3 interpreter path
"
let vim_lldb_pydir = s:FindPythonScriptDir()
try
execute 'python3 import sys; sys.path.append("' . vim_lldb_pydir . '")'
execute 'py3file ' . vim_lldb_pydir . '/plugin.py'
catch
echom 'Error loading lldb module; vim-lldb will be disabled. Check LLDB installation or set LLDB environment variable.'
return
endtry

if exists("s:lldb_disabled")
echom 'Error loading lldb module; vim-lldb will be disabled. Check LLDB installation or set LLDB environment variable.'
return
endif

" Key-Bindings
" FIXME: choose sensible keybindings for:
" - process: start, interrupt, continue, continue-to-cursor
Expand All @@ -28,12 +45,6 @@ function! s:InitLldbPlugin()
map <D-B> :Lbreakpoint<CR>
endif

"
" Setup the python3 interpreter path
"
let vim_lldb_pydir = s:FindPythonScriptDir()
execute 'python3 import sys; sys.path.append("' . vim_lldb_pydir . '")'

"
" Register :L<Command>
" The LLDB CommandInterpreter provides tab-completion in Vim's command mode.
Expand Down Expand Up @@ -115,8 +126,6 @@ function! s:InitLldbPlugin()
autocmd CursorMoved * :Lrefresh
autocmd CursorHold * :Lrefresh
autocmd VimLeavePre * python3 ctrl.doExit()

execute 'py3file ' . vim_lldb_pydir . '/plugin.py'
endfunction()

function! s:CompleteCommand(A, L, P)
Expand All @@ -138,14 +147,14 @@ EOF
endfunction()

" Returns cword if search term is empty
function! s:CursorWord(term)
return empty(a:term) ? expand('<cword>') : a:term
function! s:CursorWord(term)
return empty(a:term) ? expand('<cword>') : a:term
endfunction()

" Returns cleaned cWORD if search term is empty
function! s:CursorWORD(term)
function! s:CursorWORD(term)
" Will strip all non-alphabetic characters from both sides
return empty(a:term) ? substitute(expand('<cWORD>'), '^\A*\(.\{-}\)\A*$', '\1', '') : a:term
return empty(a:term) ? substitute(expand('<cWORD>'), '^\A*\(.\{-}\)\A*$', '\1', '') : a:term
endfunction()

call s:InitLldbPlugin()
4 changes: 1 addition & 3 deletions python-vim-lldb/import_lldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,4 @@ def import_lldb():

if not import_lldb():
import vim
vim.command(
'redraw | echo "%s"' %
" Error loading lldb module; vim-lldb will be disabled. Check LLDB installation or set LLDB environment variable.")
vim.command("let s:lldb_disabled=1")