Make clang-tidy work with helix editor #11495
-
Just like there is clippy for rust, I think clang-tidy is for C and C++. But unfortunately, I am not able to get clang-tidy to work in helix: for a simple cpluplus file, there should be tons of linter warnings in this particular code snippet: // main.cpp
#include <iostream>
#include <memory>
#include <string>
#include <vector>
int main() {
int a;
std::string hello{"hello"};
std::string world{"world"};
if (hello + world == "")
std::cout << "empty!\n";
std::unique_ptr<std::string> ptr{new std::string{"abc"}};
ptr.reset(new std::string{"xyz"});
ptr.reset(NULL);
std::vector<int> vec{1, 2, 3, 4};
for (std::vector<int>::iterator it = vec.begin(); it != vec.end(); ++it)
std::cout << *it << '\n';
} One of these linter(clang-tidy) errors for example is: /home/vishal/main.cc:15:7: warning: use std::make_unique instead [modernize-make-unique]
15 | ptr.reset(new std::string{"xyz"});
| ~^~~~~ ~~~~~~~~~~~~~~~~ ~
| = std::make_unique<std::string To run clang-tidy, I normally do: Normally, Clion and other IDEs if setup properly can show these linter errors right in the editor, for helix however I am not able to reproduce this. Kindly help. My config to try and get this fixed was as follows, what am I missing?: [language-server.rust-analyzer.config.check]
command = "clippy"
[language-server.clangd.config.check]
command = "clang-tidy" |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I'm not sure if |
Beta Was this translation helpful? Give feedback.
-
Thanks @kirawi, this makes sense. So finally, the following got the clang-tidy diagnostics working for me on helix:
[language-server]
clangd = { command = "clangd", args = [ "--clang-tidy" ] }
Diagnostics:
ClangTidy:
Add: [modernize*, readability*]
CompileFlags:
Add: [-std=c++14, -Wall, -Wextra, -Wshadow] References: |
Beta Was this translation helpful? Give feedback.
Thanks @kirawi, this makes sense.
So finally, the following got the clang-tidy diagnostics working for me on helix:
References: