@@ -30,6 +30,7 @@ let g:ycm_neovim_ns_id = s:is_neovim ? nvim_create_namespace( 'ycm_id' ) : -1
30
30
" This needs to be called outside of a function
31
31
let s: script_folder_path = escape ( expand ( ' <sfile>:p:h' ), ' \' )
32
32
let s: force_semantic = 0
33
+ let s: force_manual = 0
33
34
let s: completion_stopped = 0
34
35
" These two variables are initialized in youcompleteme#Enable.
35
36
let s: default_completion = {}
@@ -224,9 +225,9 @@ function! youcompleteme#Enable()
224
225
\ } )
225
226
endif
226
227
227
- nnoremap <silent> <Plug > (YCMFindSymbolInWorkspace)
228
+ nnoremap <silent> <plug > (YCMFindSymbolInWorkspace)
228
229
\ :call youcompleteme#finder#FindSymbol( 'workspace' )<CR>
229
- nnoremap <silent> <Plug > (YCMFindSymbolInDocument)
230
+ nnoremap <silent> <plug > (YCMFindSymbolInDocument)
230
231
\ :call youcompleteme#finder#FindSymbol( 'document' )<CR>
231
232
endfunction
232
233
@@ -639,6 +640,9 @@ endfunction
639
640
640
641
641
642
function ! s: EnableCompletingInCurrentBuffer ()
643
+ if ! g: ycm_auto_trigger
644
+ call s: SetCompleteFunc ()
645
+ endif
642
646
let b: ycm_completing = 1
643
647
endfunction
644
648
@@ -1010,10 +1014,11 @@ function! s:OnTextChangedInsertMode( popup_is_visible )
1010
1014
" CurrentIdentifierFinished check.
1011
1015
if s: force_semantic && ! py3eval ( ' base.LastEnteredCharIsIdentifierChar()' )
1012
1016
let s: force_semantic = 0
1017
+ let s: force_manual = 0
1013
1018
endif
1014
1019
1015
1020
if get ( b: , ' ycm_completing' ) &&
1016
- \ ( g: ycm_auto_trigger || s: force_semantic ) &&
1021
+ \ ( g: ycm_auto_trigger || s: force_semantic || s: force_manual ) &&
1017
1022
\ ! s: InsideCommentOrStringAndShouldStop () &&
1018
1023
\ ! s: OnBlankLine ()
1019
1024
call s: RequestCompletion ()
@@ -1045,6 +1050,7 @@ function! s:OnInsertLeave()
1045
1050
1046
1051
call s: StopPoller ( s: pollers .completion )
1047
1052
let s: force_semantic = 0
1053
+ let s: force_manual = 0
1048
1054
let s: completion = s: default_completion
1049
1055
1050
1056
call s: OnFileReadyToParse ()
@@ -1085,6 +1091,7 @@ function! s:IdentifierFinishedOperations()
1085
1091
endif
1086
1092
py3 ycm_state.OnCurrentIdentifierFinished ()
1087
1093
let s: force_semantic = 0
1094
+ let s: force_manual = 0
1088
1095
let s: completion = s: default_completion
1089
1096
endfunction
1090
1097
@@ -1149,8 +1156,37 @@ function! s:RequestCompletion()
1149
1156
endif
1150
1157
endfunction
1151
1158
1159
+ function ! s: ManuallyRequestCompletion () abort
1160
+ " Since this function is called in a mapping through the expression register
1161
+ " <C-R>=, its return value is inserted (see :h c_CTRL-R_=). We don't want to
1162
+ " insert anything so we return an empty string.
1163
+
1164
+ if ! s: AllowedToCompleteInCurrentBuffer ()
1165
+ return ' '
1166
+ endif
1167
+
1168
+ if get ( b: , ' ycm_completing' )
1169
+ let s: force_manual = 0
1170
+ call s: RequestCompletion ()
1171
+ call s: RequestSignatureHelp ()
1172
+ endif
1173
+
1174
+ return ' '
1175
+ endfunction
1176
+
1177
+ function ! s: SetCompleteFunc ()
1178
+ let &completefunc = ' youcompleteme#CompleteFunc'
1179
+ endfunction
1180
+
1181
+ function ! youcompleteme#CompleteFunc ( findstart, base ) abort
1182
+ call s: ManuallyRequestCompletion ()
1183
+ " Cancel, but silently stay in completion mode.
1184
+ return -2
1185
+ endfunction
1186
+
1187
+ inoremap <silent> <plug> (YCMComplete) <C-r> =<SID> ManuallyRequestCompletion()<CR>
1152
1188
1153
- function ! s: RequestSemanticCompletion ()
1189
+ function ! s: RequestSemanticCompletion () abort
1154
1190
if ! s: AllowedToCompleteInCurrentBuffer ()
1155
1191
return ' '
1156
1192
endif
@@ -1682,7 +1718,7 @@ function! s:ToggleInlayHints()
1682
1718
endif
1683
1719
endfunction
1684
1720
1685
- silent ! nnoremap <silent> <Plug > (YCMToggleInlayHints)
1721
+ silent ! nnoremap <silent> <plug > (YCMToggleInlayHints)
1686
1722
\ <cmd> call <SID> ToggleInlayHints()<CR>
1687
1723
1688
1724
" This is basic vim plugin boilerplate
0 commit comments