[libvirt] [PATCH 0/2] Add support for some useful vim plugins

libclang can be integrated into vim in pretty useful ways, notably to provide semantic syntax highlighting and code completion. This series enables basic support for both (through the color_coded and YouCompleteMe plugin respectively) by creating the required per-project configuration files automatically at configure time. Note that external libraries (eg. libxml2) are not being processed at the moment, but even with this basic configuration the plugins can be very useful. More sophisticated support can be worked in later on. Visual comparison: http://imgur.com/a/TBJsz Andrea Bolognani (2): Add color_coded support Add YouCompleteMe support .color_coded.in | 40 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ .ycm_extra_conf.py.in | 45 +++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 2 ++ 4 files changed, 89 insertions(+) create mode 100644 .color_coded.in create mode 100644 .ycm_extra_conf.py.in -- 2.7.4

color_coded[1] is a vim plugin that implements semantic syntax highlighting using libclang. For non-trivial projects such as libvirt, the plugin needs some help figuring out where to find the various header files: generate its configuration file at configure time so that the plugin works out of the box. [1] https://github.com/jeaye/color_coded --- .color_coded.in | 40 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + configure.ac | 1 + 3 files changed, 42 insertions(+) create mode 100644 .color_coded.in diff --git a/.color_coded.in b/.color_coded.in new file mode 100644 index 0000000..15e1c7c --- /dev/null +++ b/.color_coded.in @@ -0,0 +1,40 @@ +-I@abs_top_builddir@ +-I@abs_top_srcdir@ +-I@abs_top_builddir@/gnulib/lib +-I@abs_top_srcdir@/gnulib/lib +-I@abs_top_builddir@/include +-I@abs_top_srcdir@/include +-I@abs_top_builddir@/src +-I@abs_top_srcdir@/src +-I@abs_top_builddir@/src/access +-I@abs_top_srcdir@/src/access +-I@abs_top_builddir@/src/admin +-I@abs_top_srcdir@/src/admin +-I@abs_top_builddir@/src/bhyve +-I@abs_top_srcdir@/src/bhyve +-I@abs_top_builddir@/src/conf +-I@abs_top_srcdir@/src/conf +-I@abs_top_builddir@/src/libxl +-I@abs_top_srcdir@/src/libxl +-I@abs_top_builddir@/src/locking +-I@abs_top_srcdir@/src/locking +-I@abs_top_builddir@/src/logging +-I@abs_top_srcdir@/src/logging +-I@abs_top_builddir@/src/lxc +-I@abs_top_srcdir@/src/lxc +-I@abs_top_builddir@/src/qemu +-I@abs_top_srcdir@/src/qemu +-I@abs_top_builddir@/src/remote +-I@abs_top_srcdir@/src/remote +-I@abs_top_builddir@/src/rpc +-I@abs_top_srcdir@/src/rpc +-I@abs_top_builddir@/src/secret +-I@abs_top_srcdir@/src/secret +-I@abs_top_builddir@/src/security +-I@abs_top_srcdir@/src/security +-I@abs_top_builddir@/src/util +-I@abs_top_srcdir@/src/util +-I@abs_top_builddir@/src/vmx +-I@abs_top_srcdir@/src/vmx +-I@abs_top_builddir@/src/xenconfig +-I@abs_top_srcdir@/src/xenconfig diff --git a/.gitignore b/.gitignore index 9c475da..e690c99 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ *.swp *~ .#* +.color_coded .deps .dirstamp .gdb_history diff --git a/configure.ac b/configure.ac index 5f7a07a..752d787 100644 --- a/configure.ac +++ b/configure.ac @@ -879,6 +879,7 @@ AC_CONFIG_FILES([\ Makefile src/Makefile include/libvirt/Makefile docs/Makefile \ gnulib/lib/Makefile \ gnulib/tests/Makefile \ + .color_coded \ libvirt.pc \ libvirt-qemu.pc \ libvirt-lxc.pc \ -- 2.7.4

YouCompleteMe[1] is a vim plugin that implements semantic code completion using libclang. For non-trivial projects such as libvirt, the plugin needs some help figuring out where to find the various header files: generate its configuration file at configure time so that the plugin works out of the box. [1] http://valloric.github.io/YouCompleteMe/ --- .gitignore | 1 + .ycm_extra_conf.py.in | 45 +++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 1 + 3 files changed, 47 insertions(+) create mode 100644 .ycm_extra_conf.py.in diff --git a/.gitignore b/.gitignore index e690c99..e2eaff1 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ .lvimrc .memdump .sc-start-sc_* +.ycm_extra_conf.py /ABOUT-NLS /AUTHORS /ChangeLog diff --git a/.ycm_extra_conf.py.in b/.ycm_extra_conf.py.in new file mode 100644 index 0000000..96c8a47 --- /dev/null +++ b/.ycm_extra_conf.py.in @@ -0,0 +1,45 @@ +flags = [ + '-I@abs_top_builddir@', + '-I@abs_top_srcdir@', + '-I@abs_top_builddir@/gnulib/lib', + '-I@abs_top_srcdir@/gnulib/lib', + '-I@abs_top_builddir@/include', + '-I@abs_top_srcdir@/include', + '-I@abs_top_builddir@/src', + '-I@abs_top_srcdir@/src', + '-I@abs_top_builddir@/src/access', + '-I@abs_top_srcdir@/src/access', + '-I@abs_top_builddir@/src/admin', + '-I@abs_top_srcdir@/src/admin', + '-I@abs_top_builddir@/src/bhyve', + '-I@abs_top_srcdir@/src/bhyve', + '-I@abs_top_builddir@/src/conf', + '-I@abs_top_srcdir@/src/conf', + '-I@abs_top_builddir@/src/libxl', + '-I@abs_top_srcdir@/src/libxl', + '-I@abs_top_builddir@/src/locking', + '-I@abs_top_srcdir@/src/locking', + '-I@abs_top_builddir@/src/logging', + '-I@abs_top_srcdir@/src/logging', + '-I@abs_top_builddir@/src/lxc', + '-I@abs_top_srcdir@/src/lxc', + '-I@abs_top_builddir@/src/qemu', + '-I@abs_top_srcdir@/src/qemu', + '-I@abs_top_builddir@/src/remote', + '-I@abs_top_srcdir@/src/remote', + '-I@abs_top_builddir@/src/rpc', + '-I@abs_top_srcdir@/src/rpc', + '-I@abs_top_builddir@/src/secret', + '-I@abs_top_srcdir@/src/secret', + '-I@abs_top_builddir@/src/security', + '-I@abs_top_srcdir@/src/security', + '-I@abs_top_builddir@/src/util', + '-I@abs_top_srcdir@/src/util', + '-I@abs_top_builddir@/src/vmx', + '-I@abs_top_srcdir@/src/vmx', + '-I@abs_top_builddir@/src/xenconfig', + '-I@abs_top_srcdir@/src/xenconfig', +] + +def FlagsForFile(filename, **kwargs): + return { 'flags': flags, 'do_cache': True } diff --git a/configure.ac b/configure.ac index 752d787..fa63406 100644 --- a/configure.ac +++ b/configure.ac @@ -880,6 +880,7 @@ AC_CONFIG_FILES([\ gnulib/lib/Makefile \ gnulib/tests/Makefile \ .color_coded \ + .ycm_extra_conf.py \ libvirt.pc \ libvirt-qemu.pc \ libvirt-lxc.pc \ -- 2.7.4

On Fri, Apr 28, 2017 at 04:20:48PM +0200, Andrea Bolognani wrote:
libclang can be integrated into vim in pretty useful ways, notably to provide semantic syntax highlighting and code completion.
So presumably this requires users to have libclang installed on their system. Perhaps worth a note in the HACKING file about prerequisites and any VIM setup (if not 100% automatic) Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Fri, 2017-04-28 at 15:24 +0100, Daniel P. Berrange wrote:
So presumably this requires users to have libclang installed on their system. Perhaps worth a note in the HACKING file about prerequisites and any VIM setup (if not 100% automatic)
Setting up the plugins themselves is non-trivial, as unfortunately neither is packaged (at least not for Fedora or Debian). So the user is going to have to follow the instructions provided by the plugin's authors, which include building them from source. I think that's entirely out of scope for our own documentation. The upside is that users who have already set up the plugins won't need to do anything specific for them to work with libvirt, they will just pick up the respective configuration files automatically. -- Andrea Bolognani / Red Hat / Virtualization

On Fri, 2017-04-28 at 16:38 +0200, Andrea Bolognani wrote:
The upside is that users who have already set up the plugins won't need to do anything specific for them to work with libvirt, they will just pick up the respective configuration files automatically.
And, it goes without saying, people who have not setup the plugins in question will not be affected at all by the presence of their configuration files :) -- Andrea Bolognani / Red Hat / Virtualization

On Fri, Apr 28, 2017 at 04:38:18PM +0200, Andrea Bolognani wrote:
On Fri, 2017-04-28 at 15:24 +0100, Daniel P. Berrange wrote:
So presumably this requires users to have libclang installed on their system. Perhaps worth a note in the HACKING file about prerequisites and any VIM setup (if not 100% automatic)
Setting up the plugins themselves is non-trivial, as unfortunately neither is packaged (at least not for Fedora or Debian).
So the user is going to have to follow the instructions provided by the plugin's authors, which include building them from source. I think that's entirely out of scope for our own documentation.
The upside is that users who have already set up the plugins won't need to do anything specific for them to work with libvirt, they will just pick up the respective configuration files automatically.
Ok, well perhaps just put a quick note in HACKING that we ship these config files, and provide a link to the upstream plugin which describes it further. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Fri, 2017-04-28 at 15:52 +0100, Daniel P. Berrange wrote:
Ok, well perhaps just put a quick note in HACKING that we ship these config files, and provide a link to the upstream plugin which describes it further.
I couldn't find an existing section where this would fit, so I created a new one called "Tooling" (see patch 3/2). I've only documented the vim plugins so far, but we should also document 'make tags' later on, plus any other similar tool that I'm forgetting at the moment. -- Andrea Bolognani / Red Hat / Virtualization

Advertise some of the useful developer tooling libvirt integrates with out of the box. --- HACKING | 13 +++++++++++++ docs/hacking.html.in | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/HACKING b/HACKING index 74d1068..b78a9ae 100644 --- a/HACKING +++ b/HACKING @@ -239,6 +239,19 @@ on the subject, on Richard Jones' guide to working with open source projects <http://people.redhat.com/rjones/how-to-supply-code-to-open-source-projects/>. +Tooling +======= +libvirt includes support for some useful development tools right in its source +repository, meaning users will be able to take advantage of them without +little or no configuration. Examples include: + +- color_coded <https://github.com/jeaye/color_coded>, a vim plugin for +libclang-powered semantic syntax highlighting; + +- YouCompleteMe <http://valloric.github.io/YouCompleteMe/>, a vim plugin for +libclang-powered semantic code completion. + + Naming conventions ================== When reading libvirt code, a number of different naming conventions will be diff --git a/docs/hacking.html.in b/docs/hacking.html.in index 2bc12ea..d6a574c 100644 --- a/docs/hacking.html.in +++ b/docs/hacking.html.in @@ -314,6 +314,26 @@ Richard Jones' guide to working with open source projects</a>. </p> + <h2><a name="tooling">Tooling</a></h2> + + <p> + libvirt includes support for some useful development tools right in its + source repository, meaning users will be able to take advantage of them + without little or no configuration. Examples include: + </p> + + <ul> + <li> + <a href="https://github.com/jeaye/color_coded">color_coded</a>, + a vim plugin for libclang-powered semantic syntax highlighting; + </li> + + <li> + <a href="http://valloric.github.io/YouCompleteMe/">YouCompleteMe</a>, + a vim plugin for libclang-powered semantic code completion. + </li> + </ul> + <h2><a name="naming">Naming conventions</a></h2> <p> -- 2.7.4

On Fri, Apr 28, 2017 at 06:33:49PM +0200, Andrea Bolognani wrote:
Advertise some of the useful developer tooling libvirt integrates with out of the box. --- HACKING | 13 +++++++++++++ docs/hacking.html.in | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+)
ACK Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Tue, 2017-05-02 at 09:06 +0100, Daniel P. Berrange wrote:
Advertise some of the useful developer tooling libvirt integrates with out of the box. --- HACKING | 13 +++++++++++++ docs/hacking.html.in | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+) ACK
Can I consider this an ACK for the entire series, since it wouldn't make sense to advertise support for those plugins without actually implementing it? :) -- Andrea Bolognani / Red Hat / Virtualization

On Tue, May 02, 2017 at 11:57:02AM +0200, Andrea Bolognani wrote:
On Tue, 2017-05-02 at 09:06 +0100, Daniel P. Berrange wrote:
Advertise some of the useful developer tooling libvirt integrates with out of the box. --- HACKING | 13 +++++++++++++ docs/hacking.html.in | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+) ACK
Can I consider this an ACK for the entire series, since it wouldn't make sense to advertise support for those plugins without actually implementing it? :)
Opps, yes, I forgot I didn't actually ack the previous patches last week :) Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Andrea Bolognani
-
Daniel P. Berrange