瀏覽代碼

New options for controlling the diag ui

Strahinja Val Markovic 11 年之前
父節點
當前提交
cb359c0b6a
共有 3 個文件被更改,包括 25 次插入6 次删除
  1. 12 0
      plugin/youcompleteme.vim
  2. 12 5
      python/ycm/diagnostic_interface.py
  3. 1 1
      python/ycm/youcompleteme.py

+ 12 - 0
plugin/youcompleteme.vim

@@ -117,6 +117,18 @@ let g:ycm_show_diagnostics_ui =
       \ get( g:, 'ycm_show_diagnostics_ui',
       \ get( g:, 'ycm_register_as_syntastic_checker', 1 ) )
 
+let g:ycm_enable_signs =
+      \ get( g:, 'ycm_enable_signs',
+      \ get( g:, 'syntastic_enable_signs', 1 ) )
+
+let g:ycm_enable_highlighting =
+      \ get( g:, 'ycm_enable_highlighting',
+      \ get( g:, 'syntastic_enable_highlighting', 1 ) )
+
+let g:ycm_echo_current_diagnostic =
+      \ get( g:, 'ycm_echo_current_diagnostic',
+      \ get( g:, 'syntastic_echo_current_error', 1 ) )
+
 let g:ycm_error_symbol =
       \ get( g:, 'ycm_error_symbol',
       \ get( g:, 'syntastic_error_symbol', '>>' ) )

+ 12 - 5
python/ycm/diagnostic_interface.py

@@ -23,7 +23,8 @@ import vim
 
 
 class DiagnosticInterface( object ):
-  def __init__( self ):
+  def __init__( self, user_options ):
+    self._user_options = user_options
     # Line and column numbers are 1-based
     self._buffer_number_to_line_to_diags = defaultdict(
       lambda: defaultdict( list ) )
@@ -36,14 +37,20 @@ class DiagnosticInterface( object ):
     line += 1  # Convert to 1-based
     if line != self._previous_line_number:
       self._previous_line_number = line
-      self._EchoDiagnosticForLine( line )
+
+      if self._user_options[ 'echo_current_diagnostic' ]:
+        self._EchoDiagnosticForLine( line )
 
 
   def UpdateWithNewDiagnostics( self, diags ):
     self._buffer_number_to_line_to_diags = _ConvertDiagListToDict( diags )
-    self._next_sign_id = _UpdateSigns( self._buffer_number_to_line_to_diags,
-                                       self._next_sign_id )
-    _UpdateSquiggles( self._buffer_number_to_line_to_diags )
+
+    if self._user_options[ 'enable_signs' ]:
+      self._next_sign_id = _UpdateSigns( self._buffer_number_to_line_to_diags,
+                                        self._next_sign_id )
+
+    if self._user_options[ 'enable_highlighting' ]:
+      _UpdateSquiggles( self._buffer_number_to_line_to_diags )
 
 
   def _EchoDiagnosticForLine( self, line_num ):

+ 1 - 1
python/ycm/youcompleteme.py

@@ -65,7 +65,7 @@ class YouCompleteMe( object ):
   def __init__( self, user_options ):
     self._user_options = user_options
     self._user_notified_about_crash = False
-    self._diag_interface = DiagnosticInterface()
+    self._diag_interface = DiagnosticInterface( user_options )
     self._omnicomp = OmniCompleter( user_options )
     self._latest_completion_request = None
     self._latest_file_parse_request = None