当前位置:网站首页>Vim: extend the semantic analysis function of YCM for the third-party library of C language
Vim: extend the semantic analysis function of YCM for the third-party library of C language
2022-07-24 09:08:00 【This person's surname is Yu and his name is Meng bailing】
Preface
In many Vim Editor's auto completion plug-in ,YouCompleteMe(YCM) It is definitely one of the best plug-ins , But the configuration process is often prohibitive for beginners . After years of tossing by the author , So far, it has basically reached the level of daily use .
If the reader is right YouCompleteMe This plug-in is unfamiliar , It is suggested to first refer to the author's blog Vim: To configure Python and C++ Common plug-ins .
In the use of Vim edit C Family language code , If some third-party libraries are used additionally ( Such as OpenCV), Will find YCM Resolution failure , Library file not found , Post order automatic association cannot be used . So , This paper combines YCM file , First analyze why YCM In this case, it will fail , Then give the corresponding solution .
YCM Principles of semantic analysis
adopt YCM file [1], To study the YCM The basic principle of semantic analysis of code , as follows :
YCM Use
clangdTools ( rely on clang compiler ) Semantic analysis of code , Such as code completion ,GoTo, Code diagnosis, etc . IfclangdUnable to parse code , be YCM It cannot provide semantic analysis .and clang The compiler needs some columns compile flags To parse the code , The reason why we encounter problems is that the compiler does not find the corresponding compile flags, And then the resolution fails , The phenomenon that the library file cannot be found .
Method
Here, I'll just extract YCM file , as follows :
Method 1
Option 1: Use a compilation database
If using CMake, add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON when configuring (or add set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) to CMakeLists.txt) and copy or symlink the generated database to the root of your project.
If using Ninja, check out the compdb tool (-t compdb) in its docs.
If using GNU make, check out compiledb or Bear.
For other build systems, check out .ycm_extra_conf.py below.
According to the above , I often use CMake The way , The operation is as follows :
In the configured CMakeLists.txt To add the following :
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )cmake once , Edit again
Method 2
Option 2: Provide the flags manually
I don't need this method , Readers may refer to YCM file , See information [1].
summary
This paper analyzes YCM Yes C The principle of semantic analysis of Family Languages , It's solved Vim Editor use C++ Third party Library ( With OpenCV For example )YCM Resolution failure , The library file cannot be found .
Reference material
边栏推荐
- Guys, what parameters can be set when printing flinksql so that the values can be printed? This later section is omitted. It's inconvenient. I read the configuration on the official website
- 【FFH】实时聊天室之WebSocket实战
- Code random notes_ Linked list_ Turn over the linked list in groups of 25K
- One year after I came to Ali, I ushered in my first job change
- Android系统安全 — 5.2-APK V1签名介绍
- SQL 优化原则
- UE5影视动画渲染MRQ分层学习笔记
- Rocky基础-Shell脚本基础知识
- Houdini notes
- What is the "age limit" on tiktok and how to solve it?
猜你喜欢

First acquaintance with JVM

Open source summer interview | learn with problems, Apache dolphin scheduler, Wang Fuzheng

The detailed process of building discuz forum is easy to understand

Tiflash source code reading (V) deltatree storage engine design and implementation analysis - Part 2

Matlab各函数说明

Unity解决Package Manager“You seem to be offline”

【FFH】实时聊天室之WebSocket实战

Aruba learning notes 06 wireless control AC basic configuration (CLI)

The difference between & &, | and |

How to judge and analyze NFT market briefly through NFT go?
随机推荐
How can tiktok transport videos not be streaming limited?
Re6:读论文 LeSICiN: A Heterogeneous Graph-based Approach for Automatic Legal Statute Identification fro
2021 robocom world robot developer competition - undergraduate group (Preliminary) problem solution
基于FPGA的VGA字符显示
Account 1-3
[example of URDF exercise based on ROS] use of four wheeled robot and camera
Little dolphin "transformed" into a new intelligent scheduling engine, which can be explained in simple terms in the practical development and application of DDS
[assembly language practice] solve the unary quadratic equation ax2+bx+c=0 (including source code and process screenshots, parameters can be modified)
数据中台:始于阿里,兴于DaaS
SQL optimization principles
Replace the function of pow with two-dimensional array (solve the time overrun caused by POW)
gnuplot软件学习笔记
Getting started with sorting - insert sorting and Hill sorting
Tiktok 16 popular categories, tiktok popular products to see which one you are suitable for?
PIP3 installation complete with source
The next stop of data visualization platform | gifts from domestic open source data visualization datart "super iron powder"
SDUT compilation principle experimental code
mysql URL
Discuz论坛搭建详细过程,一看就懂
Virtual machine terminator terminal terminator installation tutorial