예제 #1
0
파일: output.py 프로젝트: CHANTXU64/.vim
    def _RenderWinBar(self, category):
        if not utils.UseWinBar():
            return

        if not self._window.valid:
            return

        with utils.LetCurrentWindow(self._window):
            tab_buffer = self._buffers[category]

            try:
                if tab_buffer.flag:
                    vim.command('nunmenu WinBar.{}'.format(
                        utils.Escape(category)))
                else:
                    vim.command('nunmenu WinBar.{}*'.format(
                        utils.Escape(category)))
            except vim.error as e:
                # E329 means the menu doesn't exist; ignore that.
                if 'E329' not in str(e):
                    raise

            vim.command(
                "nnoremenu <silent> 1.{0} WinBar.{1}{2} "
                ":call vimspector#ShowOutputInWindow( {3}, '{1}' )<CR>".format(
                    tab_buffer.index,
                    utils.Escape(category), '*' if tab_buffer.flag else '',
                    utils.WindowID(self._window)))
예제 #2
0
    def __init__(self, window, api_prefix, render_event_emitter,
                 IsBreakpointPresentAt):

        self._window = window
        self._api_prefix = api_prefix
        self._render_subject = render_event_emitter.subscribe(self._DisplayPC)
        self._IsBreakpointPresentAt = IsBreakpointPresentAt

        self._terminal = None
        self.current_syntax = None

        self._logger = logging.getLogger(__name__)
        utils.SetUpLogging(self._logger)

        # FIXME: This ID is by group, so should be module scope
        self._next_sign_id = 1
        self._signs = {
            'vimspectorPC': None,
        }
        self._current_frame = None
        self._scratch_buffers = []

        with utils.LetCurrentWindow(self._window):
            if utils.UseWinBar():
                # Buggy neovim doesn't render correctly when the WinBar is defined:
                # https://github.com/neovim/neovim/issues/12689
                vim.command('nnoremenu WinBar.■\\ Stop '
                            ':call vimspector#Stop()<CR>')
                vim.command('nnoremenu WinBar.▶\\ Cont '
                            ':call vimspector#Continue()<CR>')
                vim.command('nnoremenu WinBar.▷\\ Pause '
                            ':call vimspector#Pause()<CR>')
                vim.command('nnoremenu WinBar.↷\\ Next '
                            ':call vimspector#StepOver()<CR>')
                vim.command('nnoremenu WinBar.→\\ Step '
                            ':call vimspector#StepInto()<CR>')
                vim.command('nnoremenu WinBar.←\\ Out '
                            ':call vimspector#StepOut()<CR>')
                vim.command('nnoremenu WinBar.⟲: '
                            ':call vimspector#Restart()<CR>')
                vim.command('nnoremenu WinBar.✕ '
                            ':call vimspector#Reset()<CR>')

            if not signs.SignDefined('vimspectorPC'):
                signs.DefineSign('vimspectorPC',
                                 text='▶',
                                 double_text='▶',
                                 texthl='MatchParen',
                                 linehl='CursorLine')
            if not signs.SignDefined('vimspectorPCBP'):
                signs.DefineSign('vimspectorPCBP',
                                 text='●▶',
                                 double_text='▷',
                                 texthl='MatchParen',
                                 linehl='CursorLine')
예제 #3
0
    def __init__(self, session, win):
        self._logger = logging.getLogger(__name__)
        utils.SetUpLogging(self._logger)

        self._buf = win.buffer
        self._session = session
        self._connection = None

        self._current_thread = None
        self._current_frame = None
        self._current_syntax = ""

        self._threads = []
        self._sources = {}
        self._scratch_buffers = []

        # FIXME: This ID is by group, so should be module scope
        self._next_sign_id = 1

        utils.SetUpHiddenBuffer(self._buf, 'vimspector.StackTrace')
        utils.SetUpUIWindow(win)

        mappings = settings.Dict('mappings')['stack_trace']

        with utils.LetCurrentWindow(win):
            for mapping in utils.GetVimList(mappings, 'expand_or_jump'):
                vim.command(f'nnoremap <silent> <buffer> { mapping } '
                            ':<C-U>call vimspector#GoToFrame()<CR>')

            for mapping in utils.GetVimList(mappings, 'focus_thread'):
                vim.command(f'nnoremap <silent> <buffer> { mapping } '
                            ':<C-U>call vimspector#SetCurrentThread()<CR>')

            if utils.UseWinBar():
                vim.command('nnoremenu <silent> 1.1 WinBar.Pause/Continue '
                            ':call vimspector#PauseContinueThread()<CR>')
                vim.command('nnoremenu <silent> 1.2 WinBar.Expand/Collapse '
                            ':call vimspector#GoToFrame()<CR>')
                vim.command('nnoremenu <silent> 1.3 WinBar.Focus '
                            ':call vimspector#SetCurrentThread()<CR>')

        win.options['cursorline'] = False

        if not signs.SignDefined('vimspectorCurrentThread'):
            signs.DefineSign('vimspectorCurrentThread',
                             text='▶ ',
                             double_text='▶',
                             texthl='MatchParen',
                             linehl='CursorLine')

        self._line_to_frame = {}
        self._line_to_thread = {}

        self._requesting_threads = StackTraceView.ThreadRequestState.NO
        self._pending_thread_request = None
예제 #4
0
  def _UpdateView( self, breakpoint_list, show=True ):
    if show and not self._HasWindow():
      vim.command( f'botright { settings.Int( "bottombar_height" ) }new' )
      self._win = vim.current.window
      if self._HasBuffer():
        with utils.NoAutocommands():
          vim.current.buffer = self._buffer
      else:
        self._buffer = vim.current.buffer
        mappings = settings.Dict( 'mappings' )[ 'breakpoints' ]
        groups = {
          'toggle': 'ToggleBreakpointViewBreakpoint',
          'toggle_all': 'ToggleAllBreakpointsViewBreakpoint',
          'delete': 'DeleteBreakpointViewBreakpoint',
          'jump_to': 'JumpToBreakpointViewBreakpoint',
          'add_line': 'SetAdvancedLineBreakpoint',
          'add_func': 'AddAdvancedFunctionBreakpoint'
        }
        for key, func in groups.items():
          for mapping in utils.GetVimList( mappings, key ):
            vim.command( f'nnoremap <silent> <buffer> { mapping } '
                         ':<C-u>call '
                         f'vimspector#{ func }()<CR>' )
        utils.SetUpHiddenBuffer( self._buffer,
                                 "vimspector.Breakpoints" )

      utils.UpdateSessionWindows( {
        'breakpoints': utils.WindowID( self._win )
      } )

      # set highlighting
      vim.eval( "matchadd( 'WarningMsg', 'ENABLED', 100 )" )
      vim.eval( "matchadd( 'WarningMsg', 'VERIFIED', 100 )" )
      vim.eval( "matchadd( 'LineNr', 'DISABLED', 100 )" )
      vim.eval( "matchadd( 'LineNr', 'PENDING', 100 )" )
      vim.eval( "matchadd( 'Title', '\\v^\\S+:{0,}', 100 )" )

      if utils.UseWinBar():
        vim.command( 'nnoremenu <silent> 1.1 WinBar.Delete '
                     ':call vimspector#DeleteBreakpointViewBreakpoint()<CR>' )
        vim.command( 'nnoremenu <silent> 1.2 WinBar.Toggle '
                     ':call vimspector#ToggleBreakpointViewBreakpoint()<CR>' )
        vim.command( 'nnoremenu <silent> 1.2 WinBar.*Toggle '
                     ':call'
                       ' vimspector#ToggleAllBreakpointsViewBreakpoint()<CR>' )
        vim.command( 'nnoremenu <silent> 1.3 WinBar.Jump\\ To '
                     ':call vimspector#JumpToBreakpointViewBreakpoint()<CR>' )
        # TODO: Add tests for this function
        vim.command( 'nnoremenu <silent> 1.4 WinBar.+Line '
                     ':call vimspector#SetAdvancedLineBreakpoint()<CR>' )
        vim.command( 'nnoremenu <silent> 1.4 WinBar.+Function '
                     ':call vimspector#AddAdvancedFunctionBreakpoint()<CR>' )
        vim.command( 'nnoremenu <silent> 1.4 WinBar.Clear '
                     ':call vimspector#ClearBreakpoints()<CR>' )
        vim.command( 'nnoremenu <silent> 1.4 WinBar.Save '
                     ':call vimspector#WriteSessionFile()<CR>' )
        vim.command( 'nnoremenu <silent> 1.4 WinBar.Load '
                     ':call vimspector#ReadSessionFile()<CR>' )

      # we want to maintain the height of the window
      self._win.options[ "winfixheight" ] = True

    self._breakpoint_list = breakpoint_list

    def FormatEntry( el ):
      prefix = ''
      if el.get( 'type' ) == 'L':
        prefix = '{}:{} '.format( os.path.basename( el.get( 'filename' ) ),
                                  el.get( 'lnum' ) )

      return '{}{}'.format( prefix, el.get( 'text' ) )

    if self._HasBuffer():
      with utils.ModifiableScratchBuffer( self._buffer ):
        with utils.RestoreCursorPosition():
          utils.SetBufferContents( self._buffer,
                                   list( map( FormatEntry, breakpoint_list ) ) )
예제 #5
0
    def __init__(self, variables_win, watches_win):
        self._logger = logging.getLogger(__name__)
        utils.SetUpLogging(self._logger)

        self._connection = None
        self._current_syntax = ''

        def AddExpandMappings():
            vim.command('nnoremap <silent> <buffer> <CR> '
                        ':<C-u>call vimspector#ExpandVariable()<CR>')
            vim.command('nnoremap <silent> <buffer> <2-LeftMouse> '
                        ':<C-u>call vimspector#ExpandVariable()<CR>')

        # Set up the "Variables" buffer in the variables_win
        self._scopes: typing.List[Scope] = []
        self._vars = View(variables_win, {}, self._DrawScopes)
        utils.SetUpHiddenBuffer(self._vars.buf, 'vimspector.Variables')
        with utils.LetCurrentWindow(variables_win):
            AddExpandMappings()

        # Set up the "Watches" buffer in the watches_win (and create a WinBar in
        # there)
        self._watches: typing.List[Watch] = []
        self._watch = View(watches_win, {}, self._DrawWatches)
        utils.SetUpPromptBuffer(self._watch.buf, 'vimspector.Watches',
                                'Expression: ', 'vimspector#AddWatchPrompt',
                                'vimspector#OmniFuncWatch')
        with utils.LetCurrentWindow(watches_win):
            AddExpandMappings()
            vim.command(
                'nnoremap <buffer> <DEL> :call vimspector#DeleteWatch()<CR>')

            if utils.UseWinBar():
                vim.command('nnoremenu 1.1 WinBar.New '
                            ':call vimspector#AddWatch()<CR>')
                vim.command('nnoremenu 1.2 WinBar.Expand/Collapse '
                            ':call vimspector#ExpandVariable()<CR>')
                vim.command('nnoremenu 1.3 WinBar.Delete '
                            ':call vimspector#DeleteWatch()<CR>')

        # Set the (global!) balloon expr if supported
        has_balloon = int(vim.eval("has( 'balloon_eval' )"))
        has_balloon_term = int(vim.eval("has( 'balloon_eval_term' )"))

        self._oldoptions = {}
        if has_balloon or has_balloon_term:
            self._oldoptions = {
                'balloonexpr': vim.options['balloonexpr'],
                'balloondelay': vim.options['balloondelay'],
            }
            vim.options[
                'balloonexpr'] = 'vimspector#internal#balloon#BalloonExpr()'
            vim.options['balloondelay'] = 250

        if has_balloon:
            self._oldoptions['ballooneval'] = vim.options['ballooneval']
            vim.options['ballooneval'] = True

        if has_balloon_term:
            self._oldoptions['balloonevalterm'] = vim.options[
                'balloonevalterm']
            vim.options['balloonevalterm'] = True

        self._is_term = not bool(int(vim.eval("has( 'gui_running' )")))
예제 #6
0
    def __init__(self, variables_win, watches_win):
        self._logger = logging.getLogger(__name__)
        utils.SetUpLogging(self._logger)

        self._connection = None
        self._current_syntax = ''
        self._server_capabilities = None

        self._variable_eval: Scope = None
        self._variable_eval_view: View = None

        mappings = settings.Dict('mappings')['variables']

        # Set up the "Variables" buffer in the variables_win
        self._scopes: typing.List[Scope] = []
        self._vars = View(variables_win, {}, self._DrawScopes)
        utils.SetUpHiddenBuffer(self._vars.buf, 'vimspector.Variables')
        with utils.LetCurrentWindow(variables_win):
            if utils.UseWinBar():
                vim.command('nnoremenu <silent> 1.1 WinBar.Set '
                            ':call vimspector#SetVariableValue()<CR>')
            AddExpandMappings(mappings)

        # Set up the "Watches" buffer in the watches_win (and create a WinBar in
        # there)
        self._watches: typing.List[Watch] = []
        self._watch = View(watches_win, {}, self._DrawWatches)
        utils.SetUpPromptBuffer(self._watch.buf, 'vimspector.Watches',
                                'Expression: ', 'vimspector#AddWatchPrompt',
                                'vimspector#OmniFuncWatch')
        with utils.LetCurrentWindow(watches_win):
            AddExpandMappings(mappings)
            for mapping in utils.GetVimList(mappings, 'delete'):
                vim.command(
                    f'nnoremap <buffer> { mapping } :call vimspector#DeleteWatch()<CR>'
                )

            if utils.UseWinBar():
                vim.command('nnoremenu <silent> 1.1 WinBar.New '
                            ':call vimspector#AddWatch()<CR>')
                vim.command('nnoremenu <silent> 1.2 WinBar.Expand/Collapse '
                            ':call vimspector#ExpandVariable()<CR>')
                vim.command('nnoremenu <silent> 1.3 WinBar.Delete '
                            ':call vimspector#DeleteWatch()<CR>')
                vim.command('nnoremenu <silent> 1.1 WinBar.Set '
                            ':call vimspector#SetVariableValue()<CR>')

        # Set the (global!) balloon expr if supported
        has_balloon = int(vim.eval("has( 'balloon_eval' )"))
        has_balloon_term = int(vim.eval("has( 'balloon_eval_term' )"))

        self._oldoptions = {}
        if has_balloon or has_balloon_term:
            self._oldoptions = {
                'balloonexpr': vim.options['balloonexpr'],
                'balloondelay': vim.options['balloondelay'],
            }
            vim.options['balloonexpr'] = ("vimspector#internal#"
                                          "balloon#HoverTooltip()")

            vim.options['balloondelay'] = 250

        if has_balloon:
            self._oldoptions['ballooneval'] = vim.options['ballooneval']
            vim.options['ballooneval'] = True

        if has_balloon_term:
            self._oldoptions['balloonevalterm'] = vim.options[
                'balloonevalterm']
            vim.options['balloonevalterm'] = True

        self._is_term = not bool(int(vim.eval("has( 'gui_running' )")))