carbon-lang icon indicating copy to clipboard operation
carbon-lang copied to clipboard

Add syntax highlighting for vim and neovim

Open x2w-sloth opened this issue 2 years ago • 2 comments

PR to add a vim syntax file to support syntax highlighting for .carbon files. Since the Carbon language specification is still in progress, a single syntax file is easier to maintain and adapt to design changes in Carbon. After the language syntax has matured and stabilized, advanced tooling such as Treesitter and Language Servers can take over the syntax highlighting in neovim.

Highlighting Support

  • comments and preprocessors (RUN, CHECK, etc)
  • string and numeric literals
  • primitive type names, classes, aliases
  • control flow constructs
  • identifier names
  • package and library declarations
  • most keywords mentioned in docs/design/README.md

With a Dark Colorscheme:

carbon01

This image is longer than I thought, so I'm not posting what it looks like in a light colorscheme, but it should look fine as long as vim highlight-groups are properly defined.

x2w-sloth avatar Jul 26 '22 13:07 x2w-sloth

I'm not good enough with things like regex to do any useful review, but stuff like this is great for helping future adoption. Good job.

MichaelBonnet avatar Jul 26 '22 17:07 MichaelBonnet

Added copyright check support for .vim files in pre-commit workflow. Formatted README as requested, thank you for your patience @jonmeow .

x2w-sloth avatar Jul 31 '22 04:07 x2w-sloth

Thanks for the Vim plugin But could you please separate files from carbon-language?

mattn avatar Aug 01 '22 07:08 mattn

Hi, can you elaborate on what you mean by "separating files from carbon-language"? I'm not quite sure what you mean.

x2w-sloth avatar Aug 01 '22 09:08 x2w-sloth

I just hope that this vim syntax files will be moved to

https://github.com/carbon-language/vim-carbon-lang

mattn avatar Aug 01 '22 12:08 mattn

Oh, I only placed the syntax files in utils/vim because other syntax highlighting utilities are also there. You could open an issue to migrate the syntax files to that new repository if you like.

x2w-sloth avatar Aug 01 '22 15:08 x2w-sloth

Now I confirmed vim-carbon-lang is ready to use. Thank you.

mattn avatar Aug 06 '22 14:08 mattn