Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Vim's regex-based syntax highlighting cannot detect variables in C code. If you don't mind switching to Neovim, you can use nvim-treesitter to use tree-sitter queries to highlight C files (a default set of queries is available out of the box, which do highlight variables) instead.
By looking around the Web, I think you can maybe do what you want in Vim with this plugin, which requires you to setup an LSP server for C (note: I haven't tried it). Otherwise, the way Vim makes its syntax highlighting (natively) simply cannot compete with tree-sitter or LSP-based highlighting which construct the entire AST of your code, because C's syntax is too complex. There is a proposal to include an alternative syntax highlighting system, but work on it hasn't even started as far as I know, so vim-lsp-cxx-highlight and tree-sitter are really the only way to highlight identifiers in C/C++.
By looking around the Web, I think you can maybe do what you want in Vim with this plugin, which requires you to setup an LSP server for C (note: I haven't tried it). Otherwise, the way Vim makes its syntax highlighting (natively) simply cannot compete with tree-sitter or LSP-based highlighting which construct the entire AST of your code, because C's syntax is too complex. There is a proposal to include an alternative syntax highlighting system, but work on it hasn't even started as far as I know, so vim-lsp-cxx-highlight and tree-sitter are really the only way to highlight identifiers in C/C++.
Related posts
- Bram Moolenaar Passed Away
- Inconsistent instructions on NeoVim's user manual
- How can I create a new mode in vim? My goal is to create a way for vscode users or other text editor users to code in vim with their common keyboard shortcuts (e.g. <C-z> undo, <C-c> copy, <c-v> paste, etc. )
- Looking for a C IDE better than VSCode
- Shit's straight outta 2004