Adding the g:ycm_auto_trigger option
Toggling this option off turns off the identifier completer and the semantic triggers. Fixes #597
This commit is contained in:
parent
1ccf57614f
commit
aeb2c5c227
15
README.md
15
README.md
@ -678,6 +678,21 @@ Default: `0`
|
||||
|
||||
let g:ycm_min_num_identifier_candidate_chars = 0
|
||||
|
||||
### The `g:ycm_auto_trigger` option
|
||||
|
||||
When set to `0`, this option turns off YCM's identifier completer (the
|
||||
as-you-type popup) _and_ the semantic triggers (the popup you'd get after typing
|
||||
`.` or `->` in say C++). The Syntastic integration remains working and you can
|
||||
still force semantic completion with the `<C-Space>` shortcut.
|
||||
|
||||
If you want to just turn off the identifier completer but keep the semantic
|
||||
triggers, you should set `g:ycm_min_num_of_chars_for_completion` to a high
|
||||
number like `99`.
|
||||
|
||||
Default: `1`
|
||||
|
||||
let g:ycm_auto_trigger = 1
|
||||
|
||||
### The `g:ycm_filetype_whitelist` option
|
||||
|
||||
This option controls for which Vim filetypes (see `:h filetype`) should YCM be
|
||||
|
@ -366,7 +366,10 @@ function! s:OnCursorMovedInsertMode()
|
||||
if g:ycm_autoclose_preview_window_after_completion
|
||||
call s:ClosePreviewWindowIfNeeded()
|
||||
endif
|
||||
call s:InvokeCompletion()
|
||||
|
||||
if g:ycm_auto_trigger
|
||||
call s:InvokeCompletion()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import abc
|
||||
from collections import defaultdict
|
||||
from ycm.utils import ToUtf8IfNeeded, ForceSemanticCompletion, RunningInsideVim
|
||||
|
||||
if RunningInsideVim():
|
||||
@ -100,8 +101,9 @@ class Completer( object ):
|
||||
def __init__( self, user_options ):
|
||||
self.user_options = user_options
|
||||
self.min_num_chars = user_options[ 'min_num_of_chars_for_completion' ]
|
||||
self.triggers_for_filetype = TriggersForFiletype(
|
||||
user_options[ 'semantic_triggers' ] )
|
||||
self.triggers_for_filetype = (
|
||||
TriggersForFiletype( user_options[ 'semantic_triggers' ] )
|
||||
if user_options[ 'auto_trigger' ] else defaultdict( set ) )
|
||||
self.completions_future = None
|
||||
self._completions_cache = None
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"filepath_completion_use_working_dir": 0,
|
||||
"auto_trigger": 1,
|
||||
"min_num_of_chars_for_completion": 2,
|
||||
"min_num_identifier_candidate_chars": 0,
|
||||
"semantic_triggers": {},
|
||||
|
@ -26,7 +26,7 @@ from .test_utils import ( Setup, BuildRequest, PathToTestFile,
|
||||
from webtest import TestApp
|
||||
from nose.tools import eq_, with_setup
|
||||
from hamcrest import ( assert_that, has_item, has_items, has_entry,
|
||||
contains_inanyorder )
|
||||
contains_inanyorder, empty )
|
||||
from ..responses import BuildCompletionData, UnknownExtraConf
|
||||
from .. import handlers
|
||||
import bottle
|
||||
@ -127,6 +127,36 @@ int main()
|
||||
CompletionEntryMatcher( 'x' ),
|
||||
CompletionEntryMatcher( 'y' ) ) )
|
||||
|
||||
@with_setup( Setup )
|
||||
def GetCompletions_ClangCompleter_NoCompletionsWhenAutoTriggerOff_test():
|
||||
ChangeSpecificOptions( { 'auto_trigger': False } )
|
||||
app = TestApp( handlers.app )
|
||||
contents = """
|
||||
struct Foo {
|
||||
int x;
|
||||
int y;
|
||||
char c;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Foo foo;
|
||||
foo.
|
||||
}
|
||||
"""
|
||||
|
||||
# 0-based line and column!
|
||||
completion_data = BuildRequest( filepath = '/foo.cpp',
|
||||
filetype = 'cpp',
|
||||
contents = contents,
|
||||
line_num = 10,
|
||||
column_num = 6,
|
||||
start_column = 6,
|
||||
compilation_flags = ['-x', 'c++'] )
|
||||
|
||||
results = app.post_json( '/completions', completion_data ).json
|
||||
assert_that( results, empty() )
|
||||
|
||||
|
||||
@with_setup( Setup )
|
||||
def GetCompletions_ClangCompleter_UnknownExtraConfException_test():
|
||||
|
Loading…
Reference in New Issue
Block a user