Permalink
Browse files

If g:clang_snippet is not set, use the dummy snippet engine.

  • Loading branch information...
Rip-Rip committed Mar 10, 2013
1 parent 361aa8a commit 9ae860962132416258b4ff0f07f17a6ce09c6294
View
@@ -121,8 +121,8 @@ Default: "clang_complete"
*clang_complete-conceal_snippets*
*g:clang_conceal_snippets*
Note: This option is specific to clang_complete snippets engine.
If equal to 1, clang_complete will use vim 7.3 conceal feature to hide <#
and #> which delimit snippet placeholders.
If equal to 1, clang_complete will use vim 7.3 conceal feature to hide the
snippet placeholders.
Example of conceal configuration (see |'concealcursor'| and |'conceallevel'|
for details): >
View
@@ -53,8 +53,8 @@ function! s:ClangCompleteInit()
let g:clang_periodic_quickfix = 0
endif
if !exists('g:clang_snippets')
let g:clang_snippets = 0
if !exists('g:clang_snippets') || g:clang_snippets == 0
let g:clang_snippets_engine = 'dummy'
endif
if !exists('g:clang_snippets_engine')
@@ -134,9 +134,7 @@ function! s:ClangCompleteInit()
return
endif
if g:clang_snippets == 1
python snippetsInit()
endif
python snippetsInit()
inoremap <expr> <buffer> <C-X><C-U> <SID>LaunchCompletion()
inoremap <expr> <buffer> . <SID>CompleteDot()
@@ -257,20 +255,18 @@ function! s:initClangCompletePython()
exe 'python sys.path = ["' . s:plugin_path . '"] + sys.path'
exe 'pyfile ' . fnameescape(s:plugin_path) . '/libclang.py'
if g:clang_snippets == 1
"try
exe 'python from snippets.' . g:clang_snippets_engine . ' import *'
let l:snips_loaded = 1
"catch
" let l:snips_loaded = 0
"endtry
if l:snips_loaded == 0
" Oh yeah, vimscript rocks!
" Putting that echoe inside the catch, will throw an error, and
" display spurious unwanted errors…
echoe 'Snippets engine ' . g:clang_snippets_engine . ' not found'
return 0
endif
try
exe 'python from snippets.' . g:clang_snippets_engine . ' import *'
let l:snips_loaded = 1
catch
let l:snips_loaded = 0
endtry
if l:snips_loaded == 0
" Oh yeah, vimscript rocks!
" Putting that echoe inside the catch, will throw an error, and
" display spurious unwanted errors…
echoe 'Snippets engine ' . g:clang_snippets_engine . ' not found'
return 0
endif
py vim.command('let l:res = ' + str(initClangComplete(vim.eval('g:clang_complete_lib_flags'), vim.eval('g:clang_compilation_database'), vim.eval('g:clang_library_path'))))
@@ -352,9 +348,7 @@ function! ClangComplete(findstart, base)
let l:time_start = reltime()
endif
if g:clang_snippets == 1
python snippetsReset()
endif
python snippetsReset()
python completions, timer = getCurrentCompletions(vim.eval('a:base'))
python vim.command('let l:res = ' + completions)
@@ -396,16 +390,14 @@ function! s:TriggerSnippet()
return
endif
if g:clang_snippets == 1
" Stop monitoring as we'll trigger a snippet
silent! iunmap <buffer> <C-Y>
augroup ClangComplete
au! CursorMovedI <buffer>
augroup end
" Stop monitoring as we'll trigger a snippet
silent! iunmap <buffer> <C-Y>
augroup ClangComplete
au! CursorMovedI <buffer>
augroup end
" Trigger the snippet
python snippetsTrigger()
endif
" Trigger the snippet
python snippetsTrigger()
if g:clang_close_preview
pclose
View
@@ -381,7 +381,7 @@ def formatResult(result):
abbr = chunk_spelling
if chunk.isKindPlaceHolder():
word += snippetsFormatPlaceHolder(chunk.spelling)
word += snippetsFormatPlaceHolder(chunk_spelling)
else:
word += chunk_spelling
@@ -392,7 +392,7 @@ def formatResult(result):
if returnValue:
menu = returnValue.spelling + " " + menu
completion['word'] = snippetsAddSnippet(info, word)
completion['word'] = snippetsAddSnippet(info, word, abbr)
completion['abbr'] = abbr
completion['menu'] = menu
completion['info'] = info
@@ -15,7 +15,7 @@ def snippetsInit():
def snippetsFormatPlaceHolder(word):
return "$`%s`" % word
def snippetsAddSnippet(fullname, word):
def snippetsAddSnippet(fullname, word, abbr):
return word
r = re.compile('\$`[^`]*`')
View
@@ -1,18 +1,16 @@
def snippetsInit():
print "Initializing stuffs"
pass
def snippetsFormatPlaceHolder(word):
print "Creating snippet for placeholder " + word
return word
return ''
def snippetsAddSnippet(fullname, word):
print "Adding snippet for " + fullname
return fullname
def snippetsAddSnippet(fullname, word, abbr):
return abbr
def snippetsTrigger():
print "Triggering snippets"
pass
def snippetsReset():
print "Resetting all snippets"
pass
# vim: set ts=2 sts=2 sw=2 expandtab :
@@ -2,9 +2,9 @@
import re
from UltiSnips import UltiSnips_Manager
ultisnips_idx = 0
def snippetsInit():
global ultisnips_idx
ultisnips_idx = 0
UltiSnips_Manager.add_buffer_filetypes('%s.clang_complete' % vim.eval('&filetype'))
def snippetsFormatPlaceHolder(word):
@@ -13,12 +13,14 @@ def snippetsFormatPlaceHolder(word):
ultisnips_idx += 1
return '${%d:%s}' % (ultisnips_idx, word)
def snippetsAddSnippet(fullname, word):
def snippetsAddSnippet(fullname, word, abbr):
global ultisnips_idx
ultisnips_idx = 0
UltiSnips_Manager.add_snippet(fullname, word, fullname, "i", "clang_complete")
return fullname
def snippetsTrigger():
print vim.current.line
UltiSnips_Manager.expand()
def snippetsReset():

0 comments on commit 9ae8609

Please sign in to comment.