Skip to content

Commit cd9ff88

Browse files
committed
Making it possible to disable/change the mappings.
1 parent 99f1686 commit cd9ff88

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

doc/clang_complete.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ The snippets engine (clang_complete, ultisnips... see the snippets
137137
subdirectory).
138138
Default: "clang_complete"
139139

140+
*clang_complete-snippet_jump_map*
141+
*g:clang_complete_snippet_jump_map*
142+
Key clang_complete snippet engine uses to jump between replaceables.
143+
If it is empty string, then nothing is mapped.
144+
Default: '<tab>'
145+
140146
*clang_complete-conceal_snippets*
141147
*g:clang_conceal_snippets*
142148
Note: This option is specific to clang_complete snippets engine.
@@ -272,18 +278,21 @@ Default: 0
272278
*g:clang_print_type_key*
273279
Set the key used to print the type of the identifier under cursor.
274280
If cursor is on an enum, then the value of that enum is also printed.
281+
If it is empty then no shortcut will be created to gather this info.
275282
Defaut: "zp"
276283
Note: You can call ClangPrintType() vim function to print this information.
277284

278285
*clang_complete-jumpto_declaration_key*
279286
*g:clang_jumpto_declaration_key*
280287
Set the key used to jump to declaration.
288+
If it is empty then no shortcut will be created for this jump.
281289
Default: "<C-]>"
282290
Note: You could use the g:ClangGotoDeclaration() to do the same with a mapping.
283291

284292
*clang_complete-jumpto_declaration_in_preview_key*
285293
*g:clang_jumpto_declaration_in_preview_key*
286294
Set the key used to jump to declaration in a preview window.
295+
If it is empty then no shortcut will be created for this jump.
287296
Default: "<C-W>]"
288297
Note: You could use the g:ClangGotoDeclarationPreview() to do the same with a mapping.
289298

@@ -292,6 +301,7 @@ Note: You could use the g:ClangGotoDeclarationPreview() to do the same with a ma
292301
Set the key used to jump back.
293302
Note: Effectively this will be remapped to <C-O>. The default value is chosen
294303
to be coherent with ctags implementation.
304+
If it is empty then nothing will be remapped to <C-O>, you can use <C-O> as it is.
295305
Default: "<C-T>"
296306

297307
*clang_complete-make_default_keymappings*

plugin/clang_complete.vim

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ function! s:ClangCompleteInit()
7878
let g:clang_snippets_engine = 'clang_complete'
7979
endif
8080

81+
if !exists('g:clang_complete_snippet_jump_map')
82+
let g:clang_complete_snippet_jump_map = '<tab>'
83+
endif
84+
8185
if !exists('g:clang_user_options')
8286
let g:clang_user_options = ''
8387
endif
@@ -195,10 +199,18 @@ function! s:ClangCompleteInit()
195199
inoremap <expr> <buffer> . <SID>CompleteDot()
196200
inoremap <expr> <buffer> > <SID>CompleteArrow()
197201
inoremap <expr> <buffer> : <SID>CompleteColon()
198-
execute "nnoremap <buffer> <silent> " . g:clang_print_type_key . " :call ClangPrintType()<CR><Esc>"
199-
execute "nnoremap <buffer> <silent> " . g:clang_jumpto_declaration_key . " :call <SID>GotoDeclaration(0)<CR><Esc>"
200-
execute "nnoremap <buffer> <silent> " . g:clang_jumpto_declaration_in_preview_key . " :call <SID>GotoDeclaration(1)<CR><Esc>"
201-
execute "nnoremap <buffer> <silent> " . g:clang_jumpto_back_key . " <C-O>"
202+
if g:clang_print_type_key != ""
203+
execute "nnoremap <buffer> <silent> " . g:clang_print_type_key . " :call ClangPrintType()<CR><Esc>"
204+
endif
205+
if g:clang_jumpto_declaration_key != ""
206+
execute "nnoremap <buffer> <silent> " . g:clang_jumpto_declaration_key . " :call <SID>GotoDeclaration(0)<CR><Esc>"
207+
endif
208+
if g:clang_jumpto_declaration_in_preview_key != ""
209+
execute "nnoremap <buffer> <silent> " . g:clang_jumpto_declaration_in_preview_key . " :call <SID>GotoDeclaration(1)<CR><Esc>"
210+
endif
211+
if g:clang_jumpto_back_key != ""
212+
execute "nnoremap <buffer> <silent> " . g:clang_jumpto_back_key . " <C-O>"
213+
endif
202214
endif
203215

204216
if g:clang_omnicppcomplete_compliance == 1

plugin/snippets/clang_complete.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
import vim
33

44
def snippetsInit():
5-
python_cmd = vim.eval('s:py_cmd')
6-
vim.command("noremap <silent> <buffer> <tab> :{} updateSnips()<CR>".format(python_cmd))
7-
vim.command("snoremap <silent> <buffer> <tab> <ESC>:{} updateSnips()<CR>".format(python_cmd))
5+
snippet_jump_map = vim.eval("g:clang_complete_snippet_jump_map")
6+
if "" != snippet_jump_map:
7+
python_cmd = vim.eval('s:py_cmd')
8+
vim.command("noremap <silent> <buffer> {} :{} updateSnips()<CR>".format(snippet_jump_map, python_cmd))
9+
vim.command("snoremap <silent> <buffer> {} <ESC>:{} updateSnips()<CR>".format(snippet_jump_map, python_cmd))
810
if int(vim.eval("g:clang_conceal_snippets")) == 1:
911
vim.command("syntax match placeHolder /\$`[^`]*`/ contains=placeHolderMark")
1012
vim.command("syntax match placeHolderMark contained /\$`/ conceal")

0 commit comments

Comments
 (0)