通过你显示GTK +标识符完成我的建议

时间:2014-07-02 21:45:59

标签: vim gtk gtk3

我为STL和boost安装了ycm和完成工作,但每当我构建gtk应用程序时,我都没有gtk标识符的完成建议。

我的ycm_extra_conf.py文件包含gtk标题以及其他标题的所有内容。

我想要的是当我输入例如:

#include<gtk/gtk.h>
int main()
{
GtkWi // here no suggestions that begin with GtkWi (it should suggest 'GtkWindow') 
/* rest */
}

正如我所说的建议为STL工作和提升。

这是我对ycm的vimrc配置:

"
" YouCompleteMe options
"

"let g:ycm_register_as_syntastic_checker = 1 "default 1
let g:Show_diagnostics_ui = 1 "default 1

let g:ycm_enable_diagnostic_signs = 0
let g:ycm_enable_diagnostic_highlighting = 1
let g:ycm_always_populate_location_list = 1 "default 0
let g:ycm_open_loclist_on_ycm_diags = 1 "default 1


let g:ycm_complete_in_strings = 1 "default 1
let g:ycm_complete_in_comments = 0 "default 0
let g:ycm_collect_identifiers_from_tags_files = 1 "default 0
let g:ycm_collect_identifiers_from_comments_and_strings = 0 "default 0
let g:ycm_cache_omnifunc = 1 "default 1
let g:ycm_use_ultisnips_completer = 1 "default 1
let g:ycm_seed_identifiers_with_syntax = 1

let g:ycm_path_to_python_interpreter = '' "default ''

let g:ycm_server_use_vim_stdout = 0 "default 0 (logging to console)
let g:ycm_server_log_level = 'info' "default info
let g:ycm_server_keep_logfiles = 0 "default 0

let g:ycm_autoclose_preview_window_after_completion = 0 "default 0
let g:ycm_autoclose_preview_window_after_insertion = 0 "default 0

"let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'  "where to search for .ycm_extra_conf.py if not found
let g:ycm_confirm_extra_conf = 1

let g:ycm_goto_buffer_command = 'same-buffer' "[ 'same-buffer', 'horizontal-split', 'vertical-split', 'new-tab' ]
let g:ycm_filetype_whitelist = { '*': 1 }

let g:ycm_key_detailed_diagnostics = '<leader>d' "default <leader>d
let g:ycm_key_invoke_completion = '<C-Space>'
let g:ycm_key_list_previous_completion = ['<S-TAB>', '<Up>']
let g:ycm_key_list_select_completion = ['<TAB>', '<Down>']


nnoremap <F11> :YcmForceCompileAndDiagnostics <CR>

2 个答案:

答案 0 :(得分:2)

这些最后的日子我比以往任何时候都更回答自己的问题。 这是因为当没有人回答你的问题时,别无他法,只能自己找到解决方案。

这里我所做的是使标识符不仅适用于gtk和C ++,而且适用于任何语言和任何类型的库:

下载exuberant-ctags 然后这是创建标签的shema:

Find all files:
find /root_dir -type f

Find with exclusions:
find /root_dir -type d \( -path /exclude_dir1 -path exclude_dir2 \) -prune -o -print


ctags invocation:
ctags --totals --c++-kinds=+p --fields=+ialS --languages=c++ \
--sort=foldcase --langmap=C++:.h.hpp -f file_name.tags

final invocation schema
find find-options | xargs ctags ctags-options

add to vimrc
set tags+=file_name.tags;

example:
find /usr/include/gtk-3.0 -type f | xargs ctags --totals --c++-kinds=+p \
--fields=+ialS --languages=c++ --langmap=C++:.h.hpp --sort=foldcase -f gtk-3.0.tags

example:
find /opt/boost_1_55_0/boost/asio -type f | xargs ctags --totals --c++-kinds=+p \
--fields=+ialS --languages=c++ --langmap=C++:.h.hpp --sort=foldcase -f asio.tags

example: (non-recursive)
find /opt/boost_1_55_0/boost -maxdepth 1 -type f | xargs ctags --totals --c++-kinds=+p \
--fields=+ialS --languages=c++ --langmap=C++:.h.hpp --sort=foldcase -f boost.tags

example: (depth 2 with exclusion)
find /opt/boost_1_55_0/boost -maxdepth 2 -type d \( -path /opt/boost_1_55_0/boost/typeof \) \
-prune -o -print | xargs ctags --totals --c++-kinds=+p \
--fields=+ialS --languages=c++ --langmap=C++:.h.hpp --sort=foldcase -f boost2.tags

以下是我的vimrc在创建标记并将它们放入标记目录后的外观:

212 "boost tags
213 set tags+=/home/user/dev/tags/boost/asio.tags;
214 set tags+=/home/user/dev/tags/boost/boost1.tags;
215 "set tags+=/home/user/dev/tags/boost/boost2.tags;
216 
217 "tags location
218 set tags+=/home/user/dev/tags/gtk/gtk-3.0.tags;
219 set tags+=/home/user/dev/tags/gtk/glib-2.0.tags;
220 set tags+=/home/user/dev/tags/gtk/atk-1.0.tags;
221 set tags+=/home/user/dev/tags/gtk/cairo.tags;
222 set tags+=/home/user/dev/tags/gtk/pixman-1.tags;
223 set tags+=/home/user/dev/tags/gtk/pango-1.0.tags;
224 set tags+=/home/user/dev/tags/gtk/gio-unix-2.0.tags;
225 set tags+=/home/user/dev/tags/gtk/pixbuf-2.0.tags;
226 set tags+=/home/user/dev/tags/gtk/libpng12.tags;
227 
228 "crypto tags
229 set tags+=/home/user/dev/tags/crypto/cryptopp-5.6.2.tags;
230 
231 "llvm tags
232 "set tags+=/home/user/dev/tags/llvm/llvm-3.4.2.tags;

完成此操作后,vim将导入标签,youcompleteme引擎将使用该标签并在您键入时建议您。

这些步骤将我的vim变成了超级强大的IDE:D

答案 1 :(得分:0)

您没有获得语义完成的原因是因为YCM只在您键入触发器(如。)时触发语义完成。如果要仅基于标识符使用语义完成,请手动按CTRL-SPACE