11 ms·
Improved C syntax highlighting for Vim
- CalChris 5y agoThis looks very good. Does it work with neovim? Maybe in ~/.config/nvim/after/syntax/
- _bohm 5y agoAFAIK vimscript after/syntax/ files still work fine with neovim. But if you're on neovim 0.5+ I would recommend using the tree-sitter highlighting integration instead :)
- Shadonototro 5y agothe blue parenthesis are very hard to read in his screenshot other than that, looks very nice, good job!
- pulkomandy 5y agoThe parentheses color are not caused by this script, but by my usage of rainbow parentheses (some variant of https://github.com/luochen1990/rainbow https://github.com/luochen1990/rainbow) which I have configured for my usual light background vim theme. I did not spend time to set up a more empty vim configuration to take the screenshots. The script does not introduce any new colors, it just changes what is highlighted as cType. It does change the color of parentheses for "if" statements to be the same color as the keyword. I am undecided if I should keep that or not. Opinions from people not using rainbow or similar plugins are welcome.
- sramsay 5y agoReally, really cool!
- bArray 5y agoUnfortunately doesn't work for me, it complains about not having definitions for cppType and cppStatement. Looking in the file it undefined them [1] [2], putting them back just messes with the formatting (as the code comments suggest). It looks like this was something that was changed from the original code [3]. [1] https://github.com/pulkomandy/c.vim/blob/main/cpp.vim#L2 https://github.com/pulkomandy/c.vim/blob/main/cpp.vim#L2 [2] https://github.com/pulkomandy/c.vim/blob/main/cpp.vim#L6 https://github.com/pulkomandy/c.vim/blob/main/cpp.vim#L6 [3] https://github.com/pulkomandy/c.vim/commit/4159fe507815f897f088253645fa3501876519b0 https://github.com/pulkomandy/c.vim/commit/4159fe507815f897f...
- app4soft 5y agoPlease, report issue.[0,1] [0] https://twitter.com/pulkomandy/status/1426547182228971521 https://twitter.com/pulkomandy/status/1426547182228971521 [1] https://github.com/pulkomandy/c.vim/issues https://github.com/pulkomandy/c.vim/issues
- shakna 5y agohttps://github.com/pulkomandy/c.vim/issues/1 https://github.com/pulkomandy/c.vim/issues/1
- bern4444 5y agoI highly recommend looking into Treesitter for anyone who wants to improve syntax highlighting. I know its supported today natively in neovim. Not sure about regular vim or other editors/ides. But its a massive improvement on the otherwise regex approach to syntax highlighting every editor takes.
- divbzero 5y agoThis might be the push I need to finally make the switch to Neovim.
- nathias 5y agomake sure you use versions above 0.5
- OJFord 5y ago'All' of the (three or so?) neovim plugins I've come across wanting to use, and found Ah damn, 'neovim' in the name, work just fine in vanilla vim, FYI. I don't know how much (or if anything) a plugin has to do to support it, but there's some kind of python RPC thing that allows it. IME it's been install that once, and neovim plugins 'just work'. (But I have only found/tried ones that explicitly mention it.) (Edit, this: https://github.com/roxma/vim-hug-neovim-rpc https://github.com/roxma/vim-hug-neovim-rpc)
- jpe90 5y agoI'm on neovim nightly and recently turned off treesitter. The highlighting is nice but it consistently was giving me segfaults while autocompleting, adds substantially to my startup time, and renders the editor completely unresponsive when opening large files. I think it's worth mentioning it's still early in development before highly recommending it, but it's cool to tinker with if you're in the mood for it.
- phreeza 5y ago> renders the editor completely unresponsive I thought one of the points of neovim was to support true async stuff. So in theory, it should be possible to just open the file without syntax highlights but still be able to edit?
- david2ndaccount 5y agoIt’s kind of janky, but my current strategy is to parse my code base with libclang and dump a vim script file that adds all of the types, enums, function declarations etc. as literal syntax keywords. I also generate a tag file at the same time.
- antoinealb 5y agoDo you have the code for this or a writeup somewhere? I'd be interested in trying out this approach.
- david2ndaccount 5y agoI extracted it out of one of my projects and put it into its own git repo here: https://github.com/DaveP1776/clangtags https://github.com/DaveP1776/clangtags There’s still some project-specific stuff baked in, but that’ll show the idea.
- LAC-Tech 5y agoThe default syntax highlighting for most of the languages I've used in vim is pretty bad. Usually people will download plugins to resolve it. The syntax highlighter for HTML also loads in the syntax highlighter for visual basic for reasons I don't really understand.
- tfigment 5y agoProbably legacy that 20 years ago VBscript could be used instead of JavaScript in IE.
- dspillett 5y agoMore likely due to ASP, VBScript mixed into HTML server-side much like PHP. VBScript could, and occasionally was, used client-side, but it was very rare in my experience. Outside of articles pushed by MS the “same language on server and client” angle didn't hold enough water to override the “only supported by IE” issue even when IE had ~90% market share in the early 2000s.
- nathias 5y agouse neovim above 0.5 that has native LSP support and use treesitter
- throwaway47292 5y agoI havent used syntax highlighting in 8 years or so (global-font-lock-mode 0) highly recommend it, if you could try. for example this code[1]: // the code will run twice bool panic = true while (true) { panic = !panic; if (panic) break; } I can argue is easier to read without highlighting. I think colors break the flow of code in unintended ways, and mistreat comments (either overvalue with some pink color or undervalue with some toned down gray), and almost all themes make keywords extremely important. [1] https://github.com/jackdoe/programming-for-kids/issues/3#issuecomment-886025230 https://github.com/jackdoe/programming-for-kids/issues/3#iss...
- maccard 5y agoThat code is even easier to read with semantic highlighting than "basic" syntax highlighting. That said, syntax highlighting definitely helps when handling embedded strings, differentiating between value types, figuring out if something is a macro, function or global variable (which is important, as in a language like C++, the behaviour of `foo(x++)` depends on which of the above it is) Highlighting doesn't tell you what's important, it tells you what's different. You should find a scheme that roughly weighs what's important to you;
- packetlost 5y agoI've tried the no highlighting approach. It doesn't work for me. Glad it works for you, but I'll take my candy colors over nothing any day.
- anthk 5y agoOk, but GL acceleration for HaikuOS when? JK, good luck for the author.
- aaccount 5y agoCool, thanks