-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Note: we mostly implement features in the clangd language server, and rely on Microsoft's LSP client framework to expose these in VSCode. Features requiring a lot of VSCode-specific work are unlikely to be implemented.
Feature Request: Preprocessor Directive Matching Highlighting
Description
I would like to request a feature to add preprocessor directive matching highlighting to the vscode-clangd extension.
Currently, when clicking on preprocessor directives like #if, #ifdef, #ifndef, etc., there is no visual indication of their corresponding #else, #elif, or #endif directives. This feature is already supported in Microsoft's C/C++ extension and significantly improves code navigation in files with complex conditional compilation.
Proposed Solution
Implement syntax-aware matching pairs for preprocessor directives that:
- Highlight all related directives (
#if/#elif/#else/#endif) when one of them is selected - Provide visual feedback similar to bracket matching
- Work with all preprocessor conditional directives (
#if,#ifdef,#ifndef,#elif,#else,#endif)
Use Case Example
#if defined(PLATFORM_WINDOWS)
// Windows-specific code
#elif defined(PLATFORM_LINUX)
// Linux-specific code
#else
// Default code
#endifWhen clicking on any of these directives, all four lines should be visually highlighted to show the conditional block structure.
Benefits
- Improved code readability and navigation
- Better understanding of complex conditional compilation blocks
- Consistency with existing IDE features for bracket/parenthesis matching
- Parity with Microsoft's C/C++ extension behavior
Additional Context
This feature would be particularly valuable for large codebases that make extensive use of preprocessor conditionals, such as cross-platform projects or code with multiple configuration options.