-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvim-mysql-suggestions.vim
61 lines (50 loc) · 1.96 KB
/
vim-mysql-suggestions.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let g:path_myslq_plugin = expand('<sfile>:p:h')
function! MySQLCompleteFunction( findstart, base )
if a:findstart
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] =~ '[A-Za-z_.]'
let start -= 1
endwhile
return start
else
let command = "php ".g:path_myslq_plugin."/db.php '".g:database_host."' '".g:database_user."' '".g:database_password."' '".g:database_database."' '".a:base."'"
let output = system( command )
let matches = split(output, ';')
let result = []
for i in matches
let exploded = split(i, '/')
call add(result, {'word' : exploded[0], 'kind' : exploded[2], 'menu' : exploded[1]}) ", 'info': 'int'
endfor
return result
endif
endfunction
function! DatabasePrefixesInit(word)
let command = "php ".g:path_myslq_plugin."/db.php '".g:database_host."' '".g:database_user."' '".g:database_password."' '".g:database_database."' 'prefixes' '".a:word."'"
return system( command )
endfunction
function! MySQLCompleteSuperTabContext()
let column = col('.')
if column > 1
let synname = synIDattr(synID(line('.'), column-1, 1), 'name')
if synname == 'phpStringSingle' || synname == 'javaScriptString' || synname == 'javaScriptFuncArg'
return "\<c-x>\<c-u>"
elseif synname == 'phpMethodsVar'
let curline = getline('.')
let beforecursor = curline[ 0 : (column-2) ]
let splitWord = split(beforecursor, '->')
let currentWord = splitWord[-1]
let currentWord = substitute( currentWord , "_" , '' , 'g')
if strlen(currentWord) > 2
if DatabasePrefixesInit( currentWord ) == '1'
return "\<c-x>\<c-u>"
endif
endif
return "\<c-x>\<c-o>"
endif
if &omnifunc != ''
return "\<c-x>\<c-o>"
endif
endif
return "\<c-x>\<c-p>"
endfunction