├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── ftdetect └── carbon.vim ├── ftplugin └── carbon.vim └── syntax └── carbon.vim /.gitignore: -------------------------------------------------------------------------------- 1 | # Part of the Carbon Language project, under the Apache License v2.0 with LLVM 2 | # Exceptions. See /LICENSE for license information. 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | # Directories and symlinks generated by bazel. 6 | /bazel-* 7 | 8 | # See github_tools/MODULE.bazel. 9 | /github_tools/bazel-* 10 | /github_tools/MODULE.bazel.lock 11 | 12 | # Directories created by python. 13 | **/__pycache__/ 14 | 15 | # Ignore the user's VSCode settings and debug setup. 16 | /.vscode/settings.json 17 | /.vscode/launch.json 18 | 19 | # Ignore the user's Idea settings. 20 | /.idea/ 21 | 22 | # Directories created by clangd 23 | /.cache/clangd 24 | 25 | # User-specific Bazel configuration. 26 | /user.bazelrc 27 | 28 | # Compilation database used by clangd 29 | /compile_commands.json 30 | 31 | # Emacs temporary files 32 | *~ 33 | \#*\# 34 | 35 | # vim temporary files 36 | .*.sw[a-p] 37 | 38 | # generated by utils/tree_sitter/helix.sh 39 | /.helix/ 40 | 41 | # Ignore .DS_Store files 42 | .DS_Store 43 | 44 | # Ignore the .gdb_history that's created next to the project-specific .gdbinit 45 | .gdb_history 46 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of conduct 2 | 3 | 8 | 9 | 10 | 11 | ## Table of contents 12 | 13 | - [Guidelines](#guidelines) 14 | - [Conduct team](#conduct-team) 15 | - [Reporting conduct](#reporting-conduct) 16 | - [Filing a report](#filing-a-report) 17 | - [What happens after contacting the conduct team?](#what-happens-after-contacting-the-conduct-team) 18 | - [Appealing](#appealing) 19 | - [Special cases](#special-cases) 20 | - [Enforcement action guidelines](#enforcement-action-guidelines) 21 | - [Acknowledgements](#acknowledgements) 22 | 23 | 24 | 25 | ## Guidelines 26 | 27 | The Carbon community works to be welcoming and kind among itself and to others, 28 | with a deep commitment to psychological safety, and we want to ensure that 29 | doesn’t change as we grow and evolve. To that end, we have a few ground rules 30 | that we ask all community members to adhere to: 31 | 32 | - be welcoming, 33 | - be friendly and patient, 34 | - be considerate, 35 | - be kind, 36 | - be careful in the words that we choose, 37 | - when we disagree, try to understand why, and 38 | - recognize when progress has stopped, and take a step back. 39 | 40 | This list isn't exhaustive. Rather, take it in the spirit in which it’s intended 41 | -- a guide to make it easier to communicate and participate in the community. 42 | 43 | This code of conduct applies to all spaces managed by the Carbon project. This 44 | includes chat systems, forums, emails (on lists or between members), issue 45 | trackers, events, and any other spaces that the community uses for 46 | communication. It applies to all of your communication and conduct in these 47 | spaces, including emails, chats, things you say, slides, videos, posters, signs, 48 | or even t-shirts you display in these spaces. 49 | 50 | All community members should help support our standards of acceptable behavior. 51 | Everyone is encouraged to speak up in response to any behavior that they deem 52 | inappropriate, threatening, offensive, or harmful. If you believe someone is 53 | violating the code of conduct, please report it to the 54 | [conduct team](#conduct-team). 55 | 56 | More detailed guidance on how to participate effectively in our community 57 | spaces: 58 | 59 | - **Be welcoming.** We strive to be a community that welcomes and supports 60 | people of all backgrounds and identities. This includes, but is not limited 61 | to, members of any race, ethnicity, culture, national origin, color, 62 | immigration status, social and economic class, educational level, sex, 63 | sexual orientation, gender identity and expression, physical appearance, 64 | age, size, family status, relationship status, political belief, religion or 65 | lack thereof, and mental and physical ability. 66 | 67 | - **Be friendly and patient.** We want to encourage people to participate in 68 | our community in a constructive manner, so we can keep a friendly 69 | atmosphere. This is especially important because many of our communication 70 | tools on the Internet are low-fidelity and make it difficult to understand 71 | each other. Be patient, acknowledge that we are all on a learning journey, 72 | and stay supportive so that we can learn how to collaborate effectively as a 73 | group. 74 | 75 | - **Be considerate.** Your work will be used by other people, and you in turn 76 | will depend on the work of others. Any decision you make will affect users 77 | and colleagues, and you should take those consequences into account. 78 | Remember that we’re a world-wide community, so you might not be 79 | communicating in someone else’s primary language. 80 | 81 | - **Be kind.** Not all of us will agree all the time, but disagreement is no 82 | excuse for poor behavior and hurtful words. We might all experience some 83 | frustration now and then, but we cannot allow that frustration to turn into 84 | a personal attack. It’s important to remember that a community where people 85 | feel threatened is not a productive one. Members of our community should be 86 | kind when dealing with other members as well as with people outside the 87 | Carbon community. 88 | 89 | - **Be careful in the words that we choose and be kind to others.** Do not use 90 | insults or put downs. Harassment and other exclusionary behaviors aren’t 91 | acceptable. This includes, but is not limited to: 92 | 93 | - Violent threats or language directed against another person. 94 | - Discriminatory jokes and language. 95 | - Posting sexually explicit or violent material. 96 | - Posting, or threatening to post, other people’s personally identifying 97 | information without their explicit permission ("doxing"). 98 | - Personal insults, especially those using racist or sexist terms. 99 | - Unwelcome sexual attention. 100 | - Advocating for, or encouraging, any of the above behavior. 101 | - In general, if someone asks you to stop, then stop. Persisting after 102 | being asked to stop is considered harassment. 103 | 104 | - **When we disagree, we try to understand why.** Disagreements, both social 105 | and technical, happen all the time, and Carbon is no exception. It is 106 | important that we resolve disagreements and differing views constructively. 107 | Remember that we’re different. The strength of the project comes from its 108 | varied community: people from a wide range of backgrounds. Different people 109 | have different perspectives on issues. Being unable to understand why 110 | someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that 111 | it is human to err and blaming each other doesn’t get us anywhere. Instead, 112 | focus on helping to resolve issues and learning from mistakes. 113 | 114 | - **Recognize when progress has stopped, and take a step back.** Regardless of 115 | whether you're trying to resolve a disagreement or anything else, think 116 | about whether you're making progress. Sometimes messaging doesn't give time 117 | to think about a situation fully, and repeating positions can make people 118 | defensive. Step back for a few minutes or hours to think through the issue 119 | before responding again. Consider pulling in another community member to 120 | give a fresh perspective. Maybe meet over VC instead. Switching approaches 121 | can help resume progress. 122 | 123 | No weapons are allowed at Carbon events. Weapons include, but are not limited 124 | to, explosives (including fireworks), guns, and large knives such as those used 125 | for hunting or display, as well as any other item used for the purpose of 126 | causing injury or harm to others. 127 | 128 | In rare cases, violations of this code _outside_ of these spaces may affect, and 129 | be detrimental to, a person’s ability to participate _within_ these spaces. 130 | Important examples include, but are not limited to, 131 | [sexual and gender-based violence and/or harassment](https://hr.un.org/sites/hr.un.org/files/SEA%20Glossary%20%20%5BSecond%20Edition%20-%202017%5D%20-%20English_0.pdf), 132 | [hate crimes](https://hatecrime.osce.org/), and 133 | [hate speech](https://www.un.org/en/genocideprevention/documents/UN%20Strategy%20and%20Plan%20of%20Action%20on%20Hate%20Speech%2018%20June%20SYNOPSIS.pdf). 134 | Although we do not conduct proactive research, we have an obligation to respond 135 | to reported and, to the extent possible, corroborated concerns. Our motivations 136 | are not rooted in responding punitively, or holding people accountable. Instead, 137 | our response will be focused on how the continued participation of the person at 138 | issue could impact the community's safety, well-being, and inclusivity. It is 139 | our priority to remain a welcoming community to victims as well as groups 140 | subjected to systemic marginalization or underrepresentation. 141 | 142 | If you have questions, please feel free to ask on Discord, 143 | [GitHub](https://github.com/carbon-language/carbon-lang/discussions), or contact 144 | any member of the conduct team directly. 145 | 146 | ## Conduct team 147 | 148 | The conduct team can be emailed at conduct@carbon-lang.dev. 149 | 150 | More details about the team, its current members and its management are on the 151 | [conduct team page](/docs/project/teams/conduct_team.md). 152 | 153 | ### Reporting conduct 154 | 155 | If you believe someone is violating the code of conduct, you can report it 156 | several ways, including: 157 | 158 | - On [Discord](https://discord.gg/ZjVdShJDAs), DM ModMail. It may require 159 | confirmation that you want help on the Carbon Language server. An available 160 | moderator will respond. 161 | - Look for ModMail in the user list under "Bots", and click the name to 162 | send a direct message. 163 | - Moderators can also be found and messaged similarly, but ModMail is 164 | preferred. 165 | - Emailing the [conduct team](#conduct-team) directly at 166 | conduct@carbon-lang.dev. Bear in mind that 167 | [responses may take time](#what-happens-after-contacting-the-conduct-team). 168 | 169 | **All reports will be kept confidential**, and are only used by the conduct team 170 | to address conduct issues and keep the Carbon community safe and inclusive. 171 | 172 | Please send reports concerning a member of the conduct team directly to other 173 | members of the conduct team. This allows discussion of the complaint to more 174 | easily exclude the concerned member as a [special case](#special-cases). 175 | 176 | If you believe anyone is in **physical danger**, please notify appropriate law 177 | enforcement first. If you are unsure what law enforcement agency is appropriate, 178 | please include this in your report and we will attempt to notify them. 179 | 180 | If the violation occurs at an event and requires immediate attention, you can 181 | also reach out to any of the event organizers or staff. Event organizers and 182 | staff will be prepared to handle the incident and be able to help. If you cannot 183 | find one of the organizers, the venue staff can locate one for you. Specific 184 | event information will include detailed contact information for that event. In 185 | person reports will still be kept confidential exactly as above, but also feel 186 | free to email the conduct team, anonymously if needed. 187 | 188 | ### Filing a report 189 | 190 | Reports can be as formal or informal as needed for the situation at hand. If 191 | possible, please include as much information as you can. If you feel 192 | comfortable, please consider including: 193 | 194 | - Your contact info, so we can get in touch with you if we need to follow up. 195 | - Names -- real, nicknames, or pseudonyms -- of any individuals involved. If 196 | there were other witnesses besides you, please try to include them as well. 197 | - When and where the incident occurred. Please be as specific as possible. 198 | - Your account of what occurred, including any private chat logs or email. 199 | - Links for any public records, including community discussions. 200 | - Any extra context for the incident. 201 | - Whether you believe this incident is ongoing. 202 | - Any other information you believe we should have. 203 | 204 | ### What happens after contacting the conduct team? 205 | 206 | You will receive a reply from the conduct team acknowledging receipt within 1 207 | business day, and we will aim to respond much quicker than that. 208 | 209 | The conduct team will review the incident as soon as possible and try to 210 | determine: 211 | 212 | - What happened and who was involved. 213 | - Whether this event constitutes a code of conduct violation. 214 | - Whether this is an ongoing situation, or if there is a threat to anyone’s 215 | physical safety. 216 | 217 | If this is determined to be an ongoing incident or a threat to physical safety, 218 | the conduct team's immediate priority will be to protect everyone involved. This 219 | means we may delay an "official" response until we believe that the situation 220 | has ended and that everyone is physically safe. 221 | 222 | The conduct team will try to contact other parties involved or witnessing the 223 | event to gain clarity on what happened and understand any different 224 | perspectives. 225 | 226 | Once the conduct team has a complete account of the events they will make a 227 | decision as to how to respond. Responses may include: 228 | 229 | - Nothing, if no violation occurred or it has already been appropriately 230 | resolved. 231 | - One or more [enforcement actions](#enforcement-action-guidelines). 232 | - Involvement of relevant law enforcement if appropriate. 233 | 234 | If the situation is not resolved within one week, we’ll respond to the original 235 | reporter with an update and explanation. 236 | 237 | Once we’ve determined our response, we will separately contact the original 238 | reporter and other individuals to let them know what actions, if any, we’ll be 239 | taking. We will take into account feedback from the individuals involved on the 240 | appropriateness of our response, but we don’t guarantee we’ll act on it. 241 | 242 | After any incident, the conduct team will make a report on the situation to the 243 | Carbon leads. The Carbon leads may choose to make a public statement about the 244 | incident. If that’s the case, the identities of anyone involved will remain 245 | confidential unless instructed otherwise by those individuals. 246 | 247 | ### Appealing 248 | 249 | Only permanent resolutions, such as bans, or requests for public actions may be 250 | appealed. To appeal a decision of the conduct team, contact the 251 | [Carbon leads](docs/project/evolution.md#carbon-leads-1) with your appeal and 252 | they will review the case. 253 | 254 | In general, it is **not** appropriate to appeal a particular decision in public 255 | areas of GitHub or Discord. Doing so would involve disclosure of information 256 | which should remain confidential. Disclosing this kind of information publicly 257 | may be considered a separate and, potentially, more serious violation of the 258 | Code of Conduct. This is not meant to limit discussion of the Code of Conduct, 259 | the conduct team itself, or the appropriateness of responses in general, but 260 | **please** refrain from mentioning specific facts about cases without the 261 | explicit permission of all parties involved. 262 | 263 | ### Special cases 264 | 265 | If a complaint is raised against a member of the conduct team or Carbon leads, 266 | they will be excluded from conduct discussion and decisions, including appeals. 267 | They will only be included as needed for an involved party, such as to get their 268 | perspective or to notify them of decisions. Such complaints may lead to a 269 | member's responsibilities being revoked. 270 | 271 | ## Enforcement action guidelines 272 | 273 | The conduct team, moderators, and event organizers have the right and 274 | responsibility to remove, edit, or reject comments, commits, code, wiki edits, 275 | issues, and other contributions that are not aligned to this Code of Conduct. 276 | They will communicate reasons for moderation decisions when appropriate. 277 | 278 | The conduct team may take additional action they deem appropriate for any 279 | violation of this Code of Conduct using these guidelines based on the behavior 280 | involved: 281 | 282 | 1. **Correction** 283 | - **Behavior:** Use of inappropriate language or other minor violations of 284 | the code of conduct. 285 | - **Action:** A private, written message providing clarity around the 286 | nature of the violation and an explanation of why the behavior was 287 | inappropriate. A public apology may be requested. 288 | 1. **Warning** 289 | - **Behavior:** A code of conduct violation through a single moderate 290 | incident, or a series of minor violations. 291 | - **Action:** In addition to the correction action, a temporary 292 | restriction forbidding interaction with the people involved for a 293 | specified period of time, including unsolicited interaction with the 294 | conduct team. Violating these terms may lead to a ban. 295 | 1. **Temporary ban** 296 | - **Behavior:** A serious violation of the code of conduct, including 297 | sustained inappropriate behavior. 298 | - **Action:** In addition to the warning action, a temporary ban from use 299 | of Carbon's community spaces for a specified period of time. External 300 | channels, such as social media, should not be used to bypass these 301 | restrictions during the temporary ban. Violating these terms may lead to 302 | a permanent ban. 303 | 1. **Permanent ban** 304 | - **Behavior:** Demonstrating a pattern of violation of the code of 305 | conduct. 306 | - **Action:** A permanent ban from use of Carbon's community spaces. 307 | 308 | ## Acknowledgements 309 | 310 | This code is based on the 311 | [LLVM Code of Conduct](https://llvm.org/docs/CodeOfConduct.html), the 312 | [Django Project Code of Conduct](https://github.com/django/code-of-conduct), the 313 | [Speak Up! project](http://web.archive.org/web/20141109123859/http://speakup.io/coc.html), 314 | and the 315 | [Contributor Covenant version 2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct/). 316 | Many thanks to all of these projects for their work helping build effective 317 | tools for open source communities. 318 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ============================================================================== 2 | The Carbon language is under the Apache License v2.0 with LLVM Exceptions: 3 | ============================================================================== 4 | 5 | Apache License 6 | Version 2.0, January 2004 7 | http://www.apache.org/licenses/ 8 | 9 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 10 | 11 | 1. Definitions. 12 | 13 | "License" shall mean the terms and conditions for use, reproduction, 14 | and distribution as defined by Sections 1 through 9 of this document. 15 | 16 | "Licensor" shall mean the copyright owner or entity authorized by 17 | the copyright owner that is granting the License. 18 | 19 | "Legal Entity" shall mean the union of the acting entity and all 20 | other entities that control, are controlled by, or are under common 21 | control with that entity. For the purposes of this definition, 22 | "control" means (i) the power, direct or indirect, to cause the 23 | direction or management of such entity, whether by contract or 24 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 25 | outstanding shares, or (iii) beneficial ownership of such entity. 26 | 27 | "You" (or "Your") shall mean an individual or Legal Entity 28 | exercising permissions granted by this License. 29 | 30 | "Source" form shall mean the preferred form for making modifications, 31 | including but not limited to software source code, documentation 32 | source, and configuration files. 33 | 34 | "Object" form shall mean any form resulting from mechanical 35 | transformation or translation of a Source form, including but 36 | not limited to compiled object code, generated documentation, 37 | and conversions to other media types. 38 | 39 | "Work" shall mean the work of authorship, whether in Source or 40 | Object form, made available under the License, as indicated by a 41 | copyright notice that is included in or attached to the work 42 | (an example is provided in the Appendix below). 43 | 44 | "Derivative Works" shall mean any work, whether in Source or Object 45 | form, that is based on (or derived from) the Work and for which the 46 | editorial revisions, annotations, elaborations, or other modifications 47 | represent, as a whole, an original work of authorship. For the purposes 48 | of this License, Derivative Works shall not include works that remain 49 | separable from, or merely link (or bind by name) to the interfaces of, 50 | the Work and Derivative Works thereof. 51 | 52 | "Contribution" shall mean any work of authorship, including 53 | the original version of the Work and any modifications or additions 54 | to that Work or Derivative Works thereof, that is intentionally 55 | submitted to Licensor for inclusion in the Work by the copyright owner 56 | or by an individual or Legal Entity authorized to submit on behalf of 57 | the copyright owner. For the purposes of this definition, "submitted" 58 | means any form of electronic, verbal, or written communication sent 59 | to the Licensor or its representatives, including but not limited to 60 | communication on electronic mailing lists, source code control systems, 61 | and issue tracking systems that are managed by, or on behalf of, the 62 | Licensor for the purpose of discussing and improving the Work, but 63 | excluding communication that is conspicuously marked or otherwise 64 | designated in writing by the copyright owner as "Not a Contribution." 65 | 66 | "Contributor" shall mean Licensor and any individual or Legal Entity 67 | on behalf of whom a Contribution has been received by Licensor and 68 | subsequently incorporated within the Work. 69 | 70 | 2. Grant of Copyright License. Subject to the terms and conditions of 71 | this License, each Contributor hereby grants to You a perpetual, 72 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 73 | copyright license to reproduce, prepare Derivative Works of, 74 | publicly display, publicly perform, sublicense, and distribute the 75 | Work and such Derivative Works in Source or Object form. 76 | 77 | 3. Grant of Patent License. Subject to the terms and conditions of 78 | this License, each Contributor hereby grants to You a perpetual, 79 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 80 | (except as stated in this section) patent license to make, have made, 81 | use, offer to sell, sell, import, and otherwise transfer the Work, 82 | where such license applies only to those patent claims licensable 83 | by such Contributor that are necessarily infringed by their 84 | Contribution(s) alone or by combination of their Contribution(s) 85 | with the Work to which such Contribution(s) was submitted. If You 86 | institute patent litigation against any entity (including a 87 | cross-claim or counterclaim in a lawsuit) alleging that the Work 88 | or a Contribution incorporated within the Work constitutes direct 89 | or contributory patent infringement, then any patent licenses 90 | granted to You under this License for that Work shall terminate 91 | as of the date such litigation is filed. 92 | 93 | 4. Redistribution. You may reproduce and distribute copies of the 94 | Work or Derivative Works thereof in any medium, with or without 95 | modifications, and in Source or Object form, provided that You 96 | meet the following conditions: 97 | 98 | (a) You must give any other recipients of the Work or 99 | Derivative Works a copy of this License; and 100 | 101 | (b) You must cause any modified files to carry prominent notices 102 | stating that You changed the files; and 103 | 104 | (c) You must retain, in the Source form of any Derivative Works 105 | that You distribute, all copyright, patent, trademark, and 106 | attribution notices from the Source form of the Work, 107 | excluding those notices that do not pertain to any part of 108 | the Derivative Works; and 109 | 110 | (d) If the Work includes a "NOTICE" text file as part of its 111 | distribution, then any Derivative Works that You distribute must 112 | include a readable copy of the attribution notices contained 113 | within such NOTICE file, excluding those notices that do not 114 | pertain to any part of the Derivative Works, in at least one 115 | of the following places: within a NOTICE text file distributed 116 | as part of the Derivative Works; within the Source form or 117 | documentation, if provided along with the Derivative Works; or, 118 | within a display generated by the Derivative Works, if and 119 | wherever such third-party notices normally appear. The contents 120 | of the NOTICE file are for informational purposes only and 121 | do not modify the License. You may add Your own attribution 122 | notices within Derivative Works that You distribute, alongside 123 | or as an addendum to the NOTICE text from the Work, provided 124 | that such additional attribution notices cannot be construed 125 | as modifying the License. 126 | 127 | You may add Your own copyright statement to Your modifications and 128 | may provide additional or different license terms and conditions 129 | for use, reproduction, or distribution of Your modifications, or 130 | for any such Derivative Works as a whole, provided Your use, 131 | reproduction, and distribution of the Work otherwise complies with 132 | the conditions stated in this License. 133 | 134 | 5. Submission of Contributions. Unless You explicitly state otherwise, 135 | any Contribution intentionally submitted for inclusion in the Work 136 | by You to the Licensor shall be under the terms and conditions of 137 | this License, without any additional terms or conditions. 138 | Notwithstanding the above, nothing herein shall supersede or modify 139 | the terms of any separate license agreement you may have executed 140 | with Licensor regarding such Contributions. 141 | 142 | 6. Trademarks. This License does not grant permission to use the trade 143 | names, trademarks, service marks, or product names of the Licensor, 144 | except as required for reasonable and customary use in describing the 145 | origin of the Work and reproducing the content of the NOTICE file. 146 | 147 | 7. Disclaimer of Warranty. Unless required by applicable law or 148 | agreed to in writing, Licensor provides the Work (and each 149 | Contributor provides its Contributions) on an "AS IS" BASIS, 150 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 151 | implied, including, without limitation, any warranties or conditions 152 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 153 | PARTICULAR PURPOSE. You are solely responsible for determining the 154 | appropriateness of using or redistributing the Work and assume any 155 | risks associated with Your exercise of permissions under this License. 156 | 157 | 8. Limitation of Liability. In no event and under no legal theory, 158 | whether in tort (including negligence), contract, or otherwise, 159 | unless required by applicable law (such as deliberate and grossly 160 | negligent acts) or agreed to in writing, shall any Contributor be 161 | liable to You for damages, including any direct, indirect, special, 162 | incidental, or consequential damages of any character arising as a 163 | result of this License or out of the use or inability to use the 164 | Work (including but not limited to damages for loss of goodwill, 165 | work stoppage, computer failure or malfunction, or any and all 166 | other commercial damages or losses), even if such Contributor 167 | has been advised of the possibility of such damages. 168 | 169 | 9. Accepting Warranty or Additional Liability. While redistributing 170 | the Work or Derivative Works thereof, You may choose to offer, 171 | and charge a fee for, acceptance of support, warranty, indemnity, 172 | or other liability obligations and/or rights consistent with this 173 | License. However, in accepting such obligations, You may act only 174 | on Your own behalf and on Your sole responsibility, not on behalf 175 | of any other Contributor, and only if You agree to indemnify, 176 | defend, and hold each Contributor harmless for any liability 177 | incurred by, or claims asserted against, such Contributor by reason 178 | of your accepting any such warranty or additional liability. 179 | 180 | END OF TERMS AND CONDITIONS 181 | 182 | APPENDIX: How to apply the Apache License to your work. 183 | 184 | To apply the Apache License to your work, attach the following 185 | boilerplate notice, with the fields enclosed by brackets "[]" 186 | replaced with your own identifying information. (Don't include 187 | the brackets!) The text should be enclosed in the appropriate 188 | comment syntax for the file format. We also recommend that a 189 | file or class name and description of purpose be included on the 190 | same "printed page" as the copyright notice for easier 191 | identification within third-party archives. 192 | 193 | Copyright [yyyy] [name of copyright owner] 194 | 195 | Licensed under the Apache License, Version 2.0 (the "License"); 196 | you may not use this file except in compliance with the License. 197 | You may obtain a copy of the License at 198 | 199 | http://www.apache.org/licenses/LICENSE-2.0 200 | 201 | Unless required by applicable law or agreed to in writing, software 202 | distributed under the License is distributed on an "AS IS" BASIS, 203 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 204 | See the License for the specific language governing permissions and 205 | limitations under the License. 206 | 207 | 208 | ---- LLVM Exceptions to the Apache 2.0 License ---- 209 | 210 | As an exception, if, as a result of your compiling your source code, portions 211 | of this Software are embedded into an Object form of such source code, you 212 | may redistribute such embedded portions in such Object form without complying 213 | with the conditions of Sections 4(a), 4(b) and 4(d) of the License. 214 | 215 | In addition, if you combine or link compiled forms of this Software with 216 | software that is licensed under the GPLv2 ("Combined Software") and if a 217 | court of competent jurisdiction determines that the patent provision (Section 218 | 3), the indemnity provision (Section 9) or other Section of the License 219 | conflicts with the conditions of the GPLv2, you may retroactively and 220 | prospectively choose to deem waived or otherwise exclude such Section(s) of 221 | the License, but only in their entirety and only with respect to the Combined 222 | Software. 223 | 224 | ============================================================================== 225 | Software from third parties included in the Carbon language: 226 | ============================================================================== 227 | The Carbon language contains third party software which is under different 228 | license terms. All such code will be identified clearly using at least one of 229 | two mechanisms: 230 | 1) It will be in a separate directory tree with its own `LICENSE.txt` or 231 | `LICENSE` file at the top containing the specific license and restrictions 232 | which apply to that software, or 233 | 2) It will contain specific license and restriction terms at the top of every 234 | file. 235 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Carbon Syntax Highlighting for Vim & Neovim 2 | 3 | 8 | 9 | For Carbon developers using Vim, this plugin provides syntax highlighting for 10 | .carbon files found throughout `explorer/testdata` 11 | 12 | ## Repository and contributing 13 | 14 | This code is developed as 15 | [part](https://github.com/carbon-language/carbon-lang/tree/trunk/utils/vim) of 16 | the [Carbon Language](https://github.com/carbon-language/carbon-lang) project. 17 | Everything is then automatically mirrored into a dedicated 18 | [repository](https://github.com/carbon-language/vim-carbon-lang). 19 | 20 | If you would like to contribute, please follow the normal 21 | [Carbon contributing guide](https://github.com/carbon-language/carbon-lang/blob/trunk/CONTRIBUTING.md) 22 | and submit pull requests to the main repository. 23 | 24 | ## Manual Installation 25 | 26 | ### Vim Users 27 | 28 | From the current directory `utils/vim`, please run the following commands to 29 | install the syntax file. 30 | 31 | ``` 32 | mkdir -p ~/.vim/syntax && cp syntax/carbon.vim ~/.vim/syntax/ 33 | mkdir -p ~/.vim/ftdetect && cp ftdetect/carbon.vim ~/.vim/ftdetect/ 34 | ``` 35 | -------------------------------------------------------------------------------- /ftdetect/carbon.vim: -------------------------------------------------------------------------------- 1 | " Part of the Carbon Language project, under the Apache License v2.0 with LLVM 2 | " Exceptions. See /LICENSE for license information. 3 | " SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | autocmd BufNewFile,BufRead *.carbon setfiletype carbon 6 | -------------------------------------------------------------------------------- /ftplugin/carbon.vim: -------------------------------------------------------------------------------- 1 | " Part of the Carbon Language project, under the Apache License v2.0 with LLVM 2 | " Exceptions. See /LICENSE for license information. 3 | " SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | setlocal commentstring=//\ %s 6 | setlocal comments=:// 7 | -------------------------------------------------------------------------------- /syntax/carbon.vim: -------------------------------------------------------------------------------- 1 | " Part of the Carbon Language project, under the Apache License v2.0 with LLVM 2 | " Exceptions. See /LICENSE for license information. 3 | " SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | 5 | if exists("b:current_syntax") 6 | finish 7 | endif 8 | 9 | syn match carbonIdentifier '[a-zA-Z0-9_]\+' contained 10 | syn match carbonNominalType '[a-zA-Z0-9_]\+' contained 11 | syn match carbonComment "//.*$" contains=carbonTodo,carbonPreprocess 12 | syn keyword carbonTodo TODO contained 13 | syn keyword carbonPreprocess RUN AUTOUPDATE CHECK contained 14 | 15 | " carbon primitive types and literals 16 | syn keyword carbonBooleanType bool 17 | syn match carbonIntType 'i\d\+' 18 | syn match carbonUnsignedIntType 'u\d\+' 19 | syn match carbonFloatType 'f\d\+' 20 | syn keyword carbonStringType String 21 | syn keyword carbonBoolean true false 22 | syn match carbonNumber '\<[0-9][_0-9]*\(\.[_0-9]\+\(e[-+]\?[1-9][0-9]*\)\?\)\?\>' 23 | syn match carbonHexLiteral '\<0x[_0-9A-F]\+\(\.[_0-9A-F]\+\(p[+-]\?[1-9][0-9]*\)\?\)\?\>' 24 | syn match carbonBinLiteral '\<0b[_01]\+\>' 25 | syn region carbonStringLiteral start=+"+ end=+"+ skip=+\\"+ 26 | syn region carbonBlockStringLiteral start=+"""+ end=+"""+ skip=+\\"""+ 27 | 28 | " carbon declaration introducers 29 | syn keyword carbonNamespaceDeclaration namespace 30 | syn keyword carbonVariableDeclaration var nextgroup=carbonIdentifier skipwhite 31 | syn keyword carbonVariableDeclarationMod returned 32 | syn keyword carbonConstantDeclaration let nextgroup=carbonIdentifier skipwhite 33 | syn keyword carbonFunctionDeclaration fn 34 | syn keyword carbonClassDeclaration class nextgroup=carbonNominalType skipwhite 35 | syn keyword carbonClassDeclarationMod base abstract final 36 | syn keyword carbonClassMethodDeclaration fn destructor 37 | syn keyword carbonClassMethodDeclarationMod private virtual abstract protected impl 38 | syn keyword carbonAliasDeclaration alias nextgroup=carbonNominalType skipwhite 39 | syn keyword carbonInterfaceDeclaration interface nextgroup=carbonNominalType skipwhite 40 | syn keyword carbonChoiceDeclaration choice nextgroup=carbonNominalType skipwhite 41 | syn keyword carbonPackageDeclaration package nextgroup=carbonIdentifier skipwhite 42 | syn keyword carbonLibraryDeclaration library nextgroup=carbonStringLiteral skipwhite 43 | 44 | " carbon control flow 45 | syn keyword carbonConditional if then else 46 | syn keyword carbonLoop while for in 47 | syn keyword carbonSwitch match case default 48 | syn keyword carbonControlFlowStatement break continue return 49 | 50 | " carbon operators 51 | syn keyword carbonLogicalOperator and or not 52 | 53 | " handle any other keywords 54 | syn keyword carbonKeywordExtends extends nextgroup=carbonNominalType skipwhite 55 | syn keyword carbonKeywordSelf Self 56 | syn keyword carbonKeywordAs as 57 | syn keyword carbonKeywordTemplate template 58 | syn keyword carbonKeywordExternal external 59 | syn keyword carbonKeywordForAll forall 60 | syn keyword carbonKeywordAPI api 61 | syn keyword carbonKeywordImport import nextgroup=carbonIdentifier skipwhite 62 | 63 | hi def link carbonIdentifier Identifier 64 | hi def link carbonNominalType Type 65 | hi def link carbonComment Comment 66 | hi def link carbonTodo Todo 67 | hi def link carbonPreprocess PreProc 68 | hi def link carbonBooleanType carbonType 69 | hi def link carbonIntType carbonType 70 | hi def link carbonUnsignedIntType carbonType 71 | hi def link carbonFloatType carbonType 72 | hi def link carbonStringType carbonType 73 | hi def link carbonType Type 74 | hi def link carbonBoolean Boolean 75 | hi def link carbonHexLiteral carbonNumber 76 | hi def link carbonBinLiteral carbonNumber 77 | hi def link carbonNumber Number 78 | hi def link carbonStringLiteral carbonString 79 | hi def link carbonBlockStringLiteral carbonString 80 | hi def link carbonString String 81 | hi def link carbonNamespaceDeclaration carbonDeclaration 82 | hi def link carbonVariableDeclaration carbonDeclaration 83 | hi def link carbonVariableDeclarationMod carbonDeclaration 84 | hi def link carbonConstantDeclaration carbonDeclaration 85 | hi def link carbonFunctionDeclaration carbonDeclaration 86 | hi def link carbonClassDeclaration carbonDeclaration 87 | hi def link carbonClassDeclarationMod carbonDeclaration 88 | hi def link carbonClassMethodDeclaration carbonDeclaration 89 | hi def link carbonClassMethodDeclarationMod carbonDeclaration 90 | hi def link carbonAliasDeclaration carbonDeclaration 91 | hi def link carbonInterfaceDeclaration carbonDeclaration 92 | hi def link carbonChoiceDeclaration carbonDeclaration 93 | hi def link carbonPackageDeclaration Include 94 | hi def link carbonLibraryDeclaration Include 95 | hi def link carbonDeclaration Structure 96 | hi def link carbonKeywordExtends carbonKeyword 97 | hi def link carbonKeywordSelf carbonKeyword 98 | hi def link carbonKeywordAs carbonKeyword 99 | hi def link carbonKeywordTemplate carbonKeyword 100 | hi def link carbonKeywordExternal carbonKeyword 101 | hi def link carbonKeywordForAll carbonKeyword 102 | hi def link carbonKeywordAPI Structure 103 | hi def link carbonKeywordImport Include 104 | hi def link carbonKeyword Keyword 105 | hi def link carbonConditional Conditional 106 | hi def link carbonLoop Repeat 107 | hi def link carbonSwitch Repeat 108 | hi def link carbonControlFlowStatement Statement 109 | hi def link carbonLogicalOperator carbonOperator 110 | hi def link carbonOperator Operator 111 | 112 | let b:current_syntax = "carbon" 113 | --------------------------------------------------------------------------------