Configuring VIM ROS1 & ROS2 Semantic C++ autocompletion with YouCompleteMe

Hi fellow ROS enthusiasts who also like to use VIM.

First time posting here!

I have compiled a tutorial on how to set up YCM with VIM and make use of its C++ semantic auto-completion to speed up your development. This works with both ROS1 & ROS2 on Ubuntu.

(GitHub - Briancbn/ros_vim_autocomplete: VIM with YCM Clang Completer setup for ROS1 and ROS2)

For Windows, I only included in the tutorial to set up YCM with VIM,

However, as I am not familiar with generating the compile_commands.json file using colcon and ninja build, currently the Windows setup doesn’t work with ROS. I do intend to support in the future. Help is definitely appreciated. (Generating compile_commands.json for Windows · Issue #4 · Briancbn/ros_vim_autocomplete · GitHub)

I have also included the tutorial for some additional tools I create along the way to speedup the development.

Table of Contents

Why VIM?

Vim is definitely not the easiest editor to use, but with vim commands, you can save the time of moving your hand between the keyboard and the mouse, since most of the GUI related tasks have keys assigned to it.

Vim also can be easily installed in a headless OS (without GUI) and provide access to much more functionality than vi and nano, while VSCode and QtCreator needs to be have a GUI installed afaik.

Why YCM & C++ Semantic Auto-completion?

YouCompleteMe (YCM) is a fully configurable auto-completion module for VIM. It is also an open source project than allows you the full control over the customization.

C++ Semantic auto-completion can greatly speed up your development. With it you can save time over the following tasks

  1. Look up function and namespaces in the documentation
  2. Find bugs through repeated and time consuming compilation
  3. Spend hours to hunt down bugs turned out to be caused by a typo or wrong spelling. (auto-completion in general)

I also included a tutorial to use the tabnine fork of YCM to leverage their AI auto-completion capability.(similar to Copilot)

What else is there?

  1. Customization of the YCM module and some explanation
  2. Tools to speed up navigation in the ROS1 / ROS2 workspace:
    • colcon edit that is similar to rosed with tab completion.
    • I have also included my own fork and custom debian installation for colcon_cd to include tab completion as well!!! (PR pending)
  3. My own sourcing tool with tab completion capability.

Thanks to

I have referenced the work done by galou (Gaël Écorchard) · GitHub in ROS1. There is also a wonderful ros-vim project here, hopefully it can support ROS2 too soon!

Would the official ROS2 tutorial be interested in an additional VIM IDE setup section (like the old one in ROS1)? We really need a good tutorial for VSCode for ROS2 too - I can contribute too.

Everybody has their own setup for their development environment. I am very excited to see the sharing of your setup in the comments tooo!

10 Likes

This looks really good! Many thanks for sharing!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.