" vimspector - A multi-language debugging system for Vim " Copyright 2018 Ben Jackson " " Licensed under the Apache License, Version 2.0 (the "License"); " you may not use this file except in compliance with the License. " You may obtain a copy of the License at " " http://www.apache.org/licenses/LICENSE-2.0 " " Unless required by applicable law or agreed to in writing, software " distributed under the License is distributed on an "AS IS" BASIS, " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. " See the License for the specific language governing permissions and " limitations under the License. if !has( 'python3' ) finish endif " Boilerplate {{{ let s:save_cpo = &cpoptions set cpoptions&vim " }}} function! s:Debug( ... ) abort py3 < s:latest_completion_request.start_pos " fix up the text (insert anything that is already present in the line " that would be erased by the fixed-up earlier start position) " " both start_pos and item.start are 1-based let item.text = s:latest_completion_request.line[ \ s:latest_completion_request.start_pos + pfxlen - 1 : \ item.start + pfxlen - 1 ] . item.text endif if item.length > len( a:query ) " call s:Debug( 'Rejecting %s, length is greater than %s', " \ item, " \ len( a:query ) ) continue endif call add( items, { 'word': item.text, \ 'abbr': item.label, \ 'menu': get( item, 'type', '' ), \ 'icase': 1, \ } ) endfor let s:latest_completion_request = {} " call s:Debug( 'Items: %s', items ) return { 'words': items, 'refresh': 'always' } endif endfunction function! vimspector#OmniFuncWatch( find_start, query ) abort return vimspector#CompleteFuncSync( 'Expression: ', a:find_start, a:query ) endfunction function! vimspector#OmniFuncConsole( find_start, query ) abort return vimspector#CompleteFuncSync( '> ', a:find_start, a:query ) endfunction function! vimspector#Install( bang, ... ) abort if !s:Enabled() return endif let prefix = vimspector#internal#state#GetAPIPrefix() py3 __import__( 'vimspector', \ fromlist = [ 'installer' ] ).installer.RunInstaller( \ vim.eval( 'prefix' ), \ vim.eval( 'a:bang' ) == '!', \ *vim.eval( 'a:000' ) ) endfunction function! vimspector#CompleteInstall( ArgLead, CmdLine, CursorPos ) abort if !s:Enabled() return endif return py3eval( '"\n".join(' \ . '__import__( "vimspector", fromlist = [ "gadgets" ] )' \ . '.gadgets.GADGETS.keys() ' \ . ')' ) endfunction function! vimspector#Update( bang, ... ) abort if !s:Enabled() return endif let prefix = vimspector#internal#state#GetAPIPrefix() py3 __import__( 'vimspector', \ fromlist = [ 'installer' ] ).installer.RunUpdate( \ vim.eval( 'prefix' ), \ vim.eval( 'a:bang' ) == '!', \ *vim.eval( 'a:000' ) ) endfunction function! vimspector#AbortInstall() abort if !s:Enabled() return endif let prefix = vimspector#internal#state#GetAPIPrefix() py3 __import__( 'vimspector', fromlist = [ 'installer' ] ).installer.Abort() endfunction function! vimspector#OnBufferCreated( file_name ) abort if len( a:file_name ) == 0 return endif " Don't actually load up vimsepctor python in autocommands that trigger " regularly. We'll only create the session obkect in s:Enabled() if !s:Initialised() return endif if !s:Enabled() return endif py3 _vimspector_session.RefreshSigns( vim.eval( 'a:file_name' ) ) endfunction function! vimspector#ShowEvalBalloon( is_visual ) abort if a:is_visual let expr = py3eval( '__import__( "vimspector", fromlist = [ "utils" ] )' \ . '.utils.GetVisualSelection(' \ . ' int( vim.eval( "winbufnr( winnr() )" ) ) )' ) let expr = join( expr, '\n' ) else let expr = expand( '' ) endif return py3eval( '_vimspector_session.ShowEvalBalloon(' \ . ' int( vim.eval( "winnr()" ) ), "' \ . expr \ . '", 0 )' ) endfunction function! vimspector#PrintDebugInfo() abort if !s:Enabled() return endif py3 _vimspector_session.PrintDebugInfo() endfunction " Boilerplate {{{ let &cpoptions=s:save_cpo unlet s:save_cpo " }}}