YouCompleteMe is a semantic code-completion engine. YouCompleteMe works natively with Vim but it can also be integrated with other editors through ycmd.
{% dynamic if user.is_googler %}
(This applies to anyone compiling on gLinux, even if editing over SSHFS on MacOS) See the Google intranet specific instructions go/ycm.
You'll also need to setup ${FUCHSIA_DIR}/scripts/youcompleteme/default_settings.json
as the default settings path in your editor, in order to disable the internal use_clangd
flag. If you want to use clangd, you can additionally edit that file to set use_clangd
to 1, and clang_binary_path
to ${FUCHSIA_DIR}/prebuilt/third_party/clang/${HOST_PLATFORM}/bin/clangd
.
{% dynamic else %}
See the installation guide.
Note: Installing YCM on MacOS with Homebrew is not recommended because of library compatibility errors. Use the official installation guide instead.
{% dynamic endif %}
YouCompleteMe (and other tools like clang-tidy) require a JSON compilation database that specifies how each file is compiled. fx
will automatically symlink the database, compile_commands.json
, from your current build directory to your source root.
If this database is not present, then Vim can be configured to fall back to the configuration in /scripts/youcompleteme/ycm_extra_conf.py. See Vim configuration for how to set this up.
YouCompleteMe will use compile_commands.json
to do code completion and find symbol definitions/declarations. See your editor's YouCompleteMe docs for details. The editor should pick up compile_commands.json
file automatically.
See Vim setup for instructions on configuring Vim for Fuchsia development.
You'll need to set the ycmd config option global_ycm_extra_conf
to point to ${FUCHSIA_DIR}/scripts/youcompleteme/ycm_extra_conf.py
. Note you may need to manually replace ${FUCHSIA_DIR}
with the correct path.
Alternatively, you can create a .ycm_extra_conf.py
symbolic link to let YCM automatically find the config for any fuchsia repository:
ln -s $FUCHSIA_DIR/scripts/youcompleteme/ycm_extra_conf.py $FUCHSIA_DIR/.ycm_extra_conf.py