ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.45k stars 2.81k forks source link

Add dbext support #2288

Closed nilsboy closed 8 years ago

nilsboy commented 8 years ago

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:59)
Included patches: 1-52
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
+balloon_eval    +float           +mouse_urxvt     -tag_any_white
+browse          +folding         +mouse_xterm     +tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      +toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    +xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/harfbuzz     -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1     -I/usr/include/tcl8.6  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_LARGEFILE64_SOURCE=1  
Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic -Wl,-E  -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfontconfig -lgobject-2.0 -lglib-2.0 -lfreetype   -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl/5.18/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions  -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ldl -lz -lpthread -lieee -lm -lruby-1.9.1 -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib   
Printing YouCompleteMe debug information...
-- Server has Clang support compiled in: False
-- Server running at: http://127.0.0.1:57457
-- Server process ID: 25251
-- Server logfiles:
--   /tmp/ycm_temp/server_57457_stdout.log
--   /tmp/ycm_temp/server_57457_stderr.log

There is no output.

My OS is Ubuntu 14.04

Thank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.

[If filing a bug report, please include a list of steps that describe how to reproduce the bug you are experiencing. Also include test code if relevant.]

This is a vanilla vimrc that loads ycm and dbext and automatically creates an sqlite db to test the column completion.

To test the column completion put your cursor on the last line and type is.<right>.

The completion that is happening seems to originate from vim's omnifunc=sqlcomplete#Complete:

:h sql

To enable the popup, while in INSERT mode, use the following key combinations
for each group (where <C-C> means hold the CTRL key down while pressing
the space bar):
     Table List        - <C-C>t
               - <C-X><C-O> (the default map assumes tables)
     Stored Procedure List - <C-C>p
     View List         - <C-C>v
     Column List       - <C-C>c

     Drilling In / Out
               - When viewing a popup window displaying the list
                 of tables, you can press <Right>, this will
                 replace the table currently highlighted with
                 the column list for that table.
               - When viewing a popup window displaying the list
                 of columns, you can press <Left>, this will
                 replace the column list with the list of tables.
               - This allows you to quickly drill down into a
                 table to view its columns and back again.
               - <Right> and <Left> can be also be chosen via
                 your |.vimrc| >
                                let g:ftplugin_sql_omni_key_right = '<Right>'
                                let g:ftplugin_sql_omni_key_left  = '<Left>'

Is there any way you could incorporated this into ycm?

Thank you.

let g:plugin_dir = expand('~/.vim/dein')
let g:dein_dir = g:plugin_dir . '/repos/github.com/Shougo/dein.vim'
execute 'set runtimepath+=' . g:dein_dir

if !isdirectory(g:dein_dir)
  call mkdir(g:dein_dir, 'p')
  silent execute printf('!git clone --depth 1 %s %s', 'http://github.com/Shougo/dein.vim', g:dein_dir)
endif

call dein#begin(g:plugin_dir)

" Let dein manage dein
call dein#add('Shougo/dein.vim')
call dein#add('Shougo/vimproc.vim', {'build': 'make'})

call dein#add('Valloric/YouCompleteMe', {'build': './install.py'})
call dein#add('vim-scripts/dbext.vim', { 'hook_post_source': "call PluginHookPostSource_dbext()" })

call dein#end()

if dein#check_install() 
  call dein#install()
endif

autocmd VimEnter * call dein#call_hook('post_source')

filetype plugin indent on

function! PluginHookPostSource_dbext()
  " !rm /tmp/vim_simpsons.db

  let g:dbext_default_profile_testdb = 'type=SQLITE:dbname=/tmp/vim_simpsons.db'
  DBSetOption profile=testdb

  DBExecSQL create table simpsons (id int, name string, occupation string)
  DBExecSQL insert into simpsons values (1, 'Homer', 'Buttonpusher')
  DBExecSQL insert into simpsons values (2, 'Bart', 'Malcontent')
  DBExecSQL insert into simpsons values (3, 'Lisa', 'Do-Gooder')

  DBExecSQL create table simpsons2 (id int, name string)

  DBExecSQL select * from simpsons

  set filetype=sql

endfunction

let g:ftplugin_sql_omni_key_right = '<right>'
" let g:ftplugin_sql_omni_key_right = '.'

" Turn off id based completion
let g:ycm_min_num_of_chars_for_completion = 99

let g:ycm_semantic_triggers = {
   \   'sql' : ['.'],
   \ }

finish

select * from simpsons as s
" to get the column completion type: is.<right>
" to get the table completion type: <c-space>
nilsboy commented 8 years ago

see also #573

Valloric commented 8 years ago

Thanks for the detailed bug report! We really appreciate the amount of work you've put into it. :)

I can see how support for dbext might be useful to some, but the functionality is too niche to be worth the dev time plus the long-term maintenance effort.