Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Support User defined literals #17

@osyo-manga

Description

@osyo-manga

Twitter でそういう話がでていたので立てておきます。

[目的]

以下のように C++11 で追加されたユーザ定義リテラルもリテラルとして一緒に
ハイライトを行いたい。

// _user_defined_literal をリテラルとしてハイライトしたい
1234_user_defined_literal
"homu"_user_defined_literal

Vim のシンタックスはあまり詳しくないのですが、とりあえず、既存のシンタックスの末尾に `\w*` を追加してみました。
syn match   cNumber     display contained "\d\+\(\w*\)\>"
syn match   cNumber     display contained "0x\x\+\(\w*\)\>"
syn match   cOctal      display contained "0\o\+\(\w*\)\>" contains=cOctalZero
syn match   cFloat      display contained "\d\+\.\d*\(\w*\)"
syn region cCppString   start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\w*+ end='$' contains=cSpecial,cFormat,@Spell

いまは『数値+リテラル』を1つのシンタックスとして定義する事を考えています。
上記のコードを https://github.com/vim-jp/cpp-vim/blob/master/syntax/cpp.vim#L38 あたりに追加すればよさそう?
Vim のシンタックスに詳しい人誰か。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions