Title: Highlight C++11+ attribute specifications · Issue #57 · vim-jp/vim-cpp · GitHub
Open Graph Title: Highlight C++11+ attribute specifications · Issue #57 · vim-jp/vim-cpp
X Title: Highlight C++11+ attribute specifications · Issue #57 · vim-jp/vim-cpp
Description: I have for the time being implemented this in my own local copy (in ~/.vim/syntax). I am not an expert at vim syntax files, so I have one minor problem which is that if you have [noreturn], the noreturn will be highlighted (and some othe...
Open Graph Description: I have for the time being implemented this in my own local copy (in ~/.vim/syntax). I am not an expert at vim syntax files, so I have one minor problem which is that if you have [noreturn], the nor...
X Description: I have for the time being implemented this in my own local copy (in ~/.vim/syntax). I am not an expert at vim syntax files, so I have one minor problem which is that if you have [noreturn], the nor...
Opengraph URL: https://github.com/vim-jp/vim-cpp/issues/57
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Highlight C++11+ attribute specifications","articleBody":"I have for the time being implemented this in my own local copy (in ~/.vim/syntax). I am not an expert at vim syntax files, so I have one minor problem which is that if you have `[noreturn]`, the `noreturn` will be highlighted (and some other weird edge cases), but I'm not able to fix this myself, so I've simply attached attached my diff so far:\r\n\r\n```diff\r\ndiff --git a/usr/local/share/nvim/runtime/syntax/cpp.vim b/home/cactus/.vim/syntax/cpp.vim\r\nindex ed38913..92fd735 100644\r\n--- a/usr/local/share/nvim/runtime/syntax/cpp.vim\r\n+++ b/home/cactus/.vim/syntax/cpp.vim\r\n@@ -47,6 +47,8 @@ if !exists(\"cpp_no_cpp11\")\r\n syn region cppRawString\tmatchgroup=cppRawStringDelimiter start=+\\%(u8\\|[uLU]\\)\\=R\"\\z([[:alnum:]_{}[\\]#\u003c\u003e%:;.?*\\+\\-/\\^\u0026|~!=,\"']\\{,16}\\)(+ end=+)\\z1\"+ contains=@Spell\r\n syn match cppCast\t\t\"\\\u003c\\(const\\|static\\|dynamic\\)_pointer_cast\\s*\u003c\"me=e-1\r\n syn match cppCast\t\t\"\\\u003c\\(const\\|static\\|dynamic\\)_pointer_cast\\s*$\"\r\n+ syn region cppAttrSpec\tmatchgroup=cppAttributeDelimiter start=+\\[\\[+ end=+\\]\\]+ contains=TOP\r\n+ syn keyword cppAttribute\tnoreturn carries_dependency contained containedin=cppAttrSpec\r\n endif\r\n \r\n \" C++ 14 extensions\r\n@@ -56,6 +58,7 @@ if !exists(\"cpp_no_cpp14\")\r\n syn match cppNumber\t\tdisplay \"\\\u003c[1-9]\\('\\=\\d\\+\\)*\\(u\\=l\\{0,2}\\|ll\\=u\\)\\\u003e\" contains=cFloat\r\n syn match cppNumber\t\tdisplay \"\\\u003c0x\\x\\('\\=\\x\\+\\)*\\(u\\=l\\{0,2}\\|ll\\=u\\)\\\u003e\"\r\n syn case match\r\n+ syn keyword cppAttribute\tdeprecated contained containedin=cppAttrSpec\r\n endif\r\n \r\n \" C++ 20 extensions\r\n@@ -65,12 +68,14 @@ if !exists(\"cpp_no_cpp20\")\r\n syn keyword cppStructure\tconcept\r\n syn keyword cppType\t\tchar8_t\r\n syn keyword cppModule\t\timport module export\r\n+ syn keyword cppAttribute\tlikely unlikely no_unique_address contained containedin=cppAttrSpec\r\n endif\r\n \r\n \" C++ 17 extensions\r\n if !exists(\"cpp_no_cpp17\")\r\n syn match cppCast\t\t\"\\\u003creinterpret_pointer_cast\\s*\u003c\"me=e-1\r\n syn match cppCast\t\t\"\\\u003creinterpret_pointer_cast\\s*$\"\r\n+ syn keyword cppAttribute\tfallthrough nodiscard maybe_unused contained containedin=cppAttrSpec\r\n endif\r\n \r\n \" The minimum and maximum operators in GNU C++\r\n@@ -90,6 +95,8 @@ hi def link cppBoolean\t\tBoolean\r\n hi def link cppConstant\t\tConstant\r\n hi def link cppRawStringDelimiter\tDelimiter\r\n hi def link cppRawString\t\tString\r\n+hi def link cppAttributeDelimiter\tStorageClass\r\n+hi def link cppAttribute\tStorageClass\r\n hi def link cppNumber\t\tNumber\r\n hi def link cppModule\t\tInclude\r\n```\r\n\r\nI have made an effort to not highlight attributes outside of valid contexts (e.g. `likely` is not highlighted unless it's inside an attribute specifier), but it seems to have some unfortunate side effects. At the moment, this is the resulting highlighting in a few cases:\r\n\r\n","author":{"url":"https://github.com/sophec","@type":"Person","name":"sophec"},"datePublished":"2021-07-19T14:25:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/57/vim-cpp/issues/57"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bd0e05d3-ed9b-e467-6a61-5ac43b194b35 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6A4:79F9B:1E248AB:2B5A9FF:6A4CEB29 |
| html-safe-nonce | 74b51ea60c731d83b72762e23ca8427731643562e8589266b5483aee93506f4d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkE0Ojc5RjlCOjFFMjQ4QUI6MkI1QTlGRjo2QTRDRUIyOSIsInZpc2l0b3JfaWQiOiI5OTQyNzQ3NjAzMjQ4Njg5MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d53ca566c486d4f43214b357cce07664c0b677d78608ad405aa95d03c787b777 |
| hovercard-subject-tag | issue:947710537 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/vim-jp/vim-cpp/57/issue_layout |
| twitter:image | https://opengraph.githubassets.com/23b40196599d789bace7ed3e17d15639c3f079cf4c579abb9a26ad220f308a26/vim-jp/vim-cpp/issues/57 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/23b40196599d789bace7ed3e17d15639c3f079cf4c579abb9a26ad220f308a26/vim-jp/vim-cpp/issues/57 |
| og:image:alt | I have for the time being implemented this in my own local copy (in ~/.vim/syntax). I am not an expert at vim syntax files, so I have one minor problem which is that if you have [noreturn], the nor... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sophec |
| hostname | github.com |
| expected-hostname | github.com |
| None | 299b43bca6e02ad35197ffeba30d2466846d5fb02ab96fbced5b5e6cec589fb8 |
| turbo-cache-control | no-preview |
| go-import | github.com/vim-jp/vim-cpp git https://github.com/vim-jp/vim-cpp.git |
| octolytics-dimension-user_id | 1051958 |
| octolytics-dimension-user_login | vim-jp |
| octolytics-dimension-repository_id | 4631849 |
| octolytics-dimension-repository_nwo | vim-jp/vim-cpp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 4631849 |
| octolytics-dimension-repository_network_root_nwo | vim-jp/vim-cpp |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c5a57f04eeb310f57c73fd6d751d957e2ca27ed2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width