Open printesoi opened 12 years ago
bar
must have a return type. Clang may not work well completing broken code. You may use the code checking functionality in these cases.
@oblitum this was just an typo in my comment, the problem is that it does not completes when editing at the end of the file(explicitly on editing on the last line of the file), elsewhere works!
Now ok. I think I've glanced over some similar issue, in libclang or clang_complete, in the past, but don't remember where now... regards.
@printesoi a semicolon is missing at the end of the last line of test.h
. When I add it, completion starts to work. Do you have the typo in your local file too or only here?
@xaizek with or whithout the semicolon a the end of the line of test.h the completion does not work.
$ gvim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Mar 20 2012 01:47:35)
Included patches: 1-475
Compiled by ArchLinux
Big version with GTK2 GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi
+file_in_path +find_in_path +float +folding -footer +fork() +gettext
-hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall
+linebreak +lispindent +listcmds +localmap +lua +menu +mksession +modify_fname
+mouse +mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm
-mouse_sysmouse +mouse_xterm +mouse_urxvt +multi_byte +multi_lang -mzscheme
+netbeans_intg +path_extra +perl +persistent_undo +postscript +printer -profile
+python -python3 +quickfix +reltime +rightleft +ruby +scrollbind +signs
+smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
+toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim
+xsmp_interact +xterm_clipboard -xterm_save
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "/etc/gvimrc"
user gvimrc file: "$HOME/.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/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/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/local/include -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -L/usr/local/lib -Wl,--as-needed -o vim -pthread -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 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -lncurses -lnsl -lacl -lattr -lgpm -ldl -L/usr/lib -llua -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -fstack-protector -L/usr/local/lib -L/usr/lib/perl5/core_perl/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -lruby -lpthread -lrt -ldl -lcrypt -lm -L/usr/lib
vim-clang_complete from master branch,
$ clang --version
clang version 3.1 (branches/release_31)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Just to be sure, if you change the header and save it, but don't reparse de cpp file (let's say you kept it open and changed the header and saved), you won't get completion as if the header was corrected, because headers are precompiled for completion. You must issue a precompilation by hand, or close/open your cpp.
Just guessing.
Correction: Close/Open VIM. Your cpp translation unit still keeps resident even after you close the buffer. I've hinted about a reparsing shortcut at another issue. If this is the problem, you may employ it.
@oblitum I have this header:
#ifndef CLICKABLEBIT_H
#define CLICKABLEBIT_H
#include <QLabel>
class QMouseEvent;
class ClickableBit : public QLabel
{
Q_OBJECT
public:
explicit ClickableBit(QWidget *parent = 0);
protected:
void mousePressEvent(QMouseEvent *ev);
void toggleValue();
signals:
void valueChanged(int value);
void clicked(int value);
public slots:
void slotSetValue(int value);
};
#endif // CLICKABLEBIT_H
and this source:
#include <QMouseEvent>
#include "clickablebit.h"
ClickableBit::ClickableBit(QWidget *parent) :
QLabel(parent)
{
QWidget* widget = parent ? parent : this;
int width = widget->fontMetrics().width('0');
setFixedWidth(width);
setTextInteractionFlags(Qt::NoTextInteraction);
setNum(0);
}
void ClickableBit::mousePressEvent(QMouseEvent *ev)
{
if (ev->button() == Qt::LeftButton)
{
toggleValue();
emit clicked(text().toInt());
}
}
void ClickableBit::slotSetValue(int value)
{
setNum(value ? 1 : 0);
emit valueChanged(text().toInt());
}
void ClickableBit::toggleValue()
{
setNum(text() == QString("0") ? 1 : 0);
}
Notice that there is a semicolon at the end of the class in the header, but the completion does not work when editing the very last line of the file(without empty lines aflter).
What about your original sample now? Does it still behaves the same as this last one?
@oblitum yes, event if I add the semicolon and I restart ViM the completion still does not work.
Well, for me it's working in the last line as in any other, without problems...
@printesoi the reason might be in some other plugin. Did you try to run Vim with clang_complete only and almost empty ~/.vimrc
?
I've rebuilt my VIM environment from ground up now and I don't know why, I've got this issue.
I'm suspecting whether it has something todo with the latest VIM releases. Since it seems to be the single significant change I got. Not only this, there's some weirdness I'm experiencing with the background messages I get from python scripts like libclang.py
, they are not being given in parallel like before, they show up after some key events instead.
@printesoi Well it seems I got a similar issue of yours and found its cause by luck since it's not happening anymore. First of, I don't use .clang_complete
files and autoload options, I disable it because it causes me more headaches than expected.
What has solved this for me is that I was setting g:clang_user_options
in wrong manner. I was setting it like
let g:clang_user_options = "-std=c++11 -stdlib=libc++"
and after, through a .vimprj
file, I was appending to it like this:
let g:clang_user_options .="-I."
I discovered through g:ClangUpdateQuickFix()
(clang_complete's code checking functionality) that I was forgetting a space when appending "-I.", so I was getting g:clang_user_options = "-std=c++11 -stdlib=libc++-I."
. The correct should have been g:clang_user_options = "-std=c++11 -stdlib=libc++ -I."
Changing to:
let g:clang_user_options .=" -I."
solved the problem I was having with completion at the last line.
This warns this problem may be related with wrong compiler options being passed, while still allowing completion somewhat working.
@oblitum Thank you, but it's not working for me. It's working on the whole file, except for the last position on the last line.
@printesoi That's what was happening to me too, and was solved by checking what clang was getting for its compiler options.
@oblitum for example the header t.h
class T
{
public:
T();
~T();
int foo();
void bar(int x);
private:
int m_x;
};
and the source code:
#include "t.h"
if I write T:: the completion fails and g:ClangUpdateQuickFix() displays
t.cpp|3 col 8175 error| expected unqualified-id
if I write then
T::T() {}
and call g:ClangUpdateQuickFix() it displays nothing (so there are no more errors) and the completion works normally, even on the last line.
I have the folowing header ("test.h") :
and in the source file ("test.cpp"):
and when trying to complete where *\ is I get "User defined completion (^U^N^P) Pattern not found", but when I try to complete above the definition of the constructor(i.e. anywhere but the end of the file) the completion works fine.
P.S. Thank you very much for you work!