-
Notifications
You must be signed in to change notification settings - Fork 26
Kakoune: Adds and fixes ident highlighters, adds static_words and updates the keywords and builtins #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
allenyade
wants to merge
2
commits into
c3lang:main
Choose a base branch
from
allenyade:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Kakoune: Adds and fixes ident highlighters, adds static_words and updates the keywords and builtins #40
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,12 +1,13 @@ | ||||||
| hook global BufCreate .*[.]c3[it]? %{ | ||||||
| set-option buffer filetype c3 | ||||||
| set-option buffer filetype c3 | ||||||
| } | ||||||
|
|
||||||
| hook -group c3-highlight global WinSetOption filetype=c3 %{ | ||||||
| require-module c3 | ||||||
| require-module c3 | ||||||
| set-option window static_words %opt{c3_static_words} | ||||||
|
|
||||||
| add-highlighter window/c3 ref c3 | ||||||
| hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/c3 } | ||||||
| add-highlighter window/c3 ref c3 | ||||||
| hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/c3 } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -21,37 +22,38 @@ addhl shared/c3/comment-doc region <\*(?!>) \*> fill comment | |||||
| addhl shared/c3/double-string region '"' (?<!\\)(\\\\)*" fill string | ||||||
| addhl shared/c3/single-string region "'" (?<!\\)(\\\\)*' fill string | ||||||
| addhl shared/c3/literal-string region "`" (?<!\\)(\\\\)*` fill string | ||||||
| addhl shared/c3/code/shebang regex '\A#! ?/.*?\n' 0:comment | ||||||
|
|
||||||
| addhl shared/c3/code/asterisk regex '(?:\[<?)\s*(\*)\s*(?:>?\])' 1:value | ||||||
|
|
||||||
| addhl shared/c3/code/module-decl regex '(module|import)\s*[a-z0-9_]+(?:::[a-z0-9_]+)*(?:(?:,\s*[a-z0-9_]+(?:::[a-z0-9_]+)*)+|\s*(\{(?:\s*_*[A-Z][A-z0-9_]*,?\s*)+\}))?(?=;)' 0:module 1:Default 2:Default | ||||||
| addhl shared/c3/code/num regex '\b[+-]?(?:0(?:[xX][0-9a-fA-F](?:_*[0-9a-fA-F])*|[oO][0-7](?:_*[0-7])*|[bB][10](?:_*[10])*)|[0-9](?:_*[0-9])*(?:_*[eE][+-]?[0-9]+)?)(?:[iIuU](?:8|16|32|64|128)?|[fF](?:32|64)?|[uU][lL])?\b' 0:value | ||||||
| addhl shared/c3/code/ident regex '\$?\b_*[A-Z]\w*\b' 0:value | ||||||
| addhl shared/c3/code/user-attr regex '@[A-Z]\w*?[a-z]\w*\b' 0:attribute | ||||||
| addhl shared/c3/code/const regex '\$?\b_*[A-Z][A-Z_0-9]*\b' 0:value | ||||||
| addhl shared/c3/code/type regex '\$?\b_*[A-Z][A-Z_0-9]*[a-z][A-Z_0-9a-z]*\b' 0:value | ||||||
| addhl shared/c3/code/user-attr regex '@\b[A-Z][A-Z_0-9]*[a-z][A-Z_0-9a-z]*\b' 0:attribute | ||||||
| addhl shared/c3/code/func regex '(?:[@#$])?\b_*[a-z][a-zA-Z0-9_]*\s*(?=\()' 0:function | ||||||
| addhl shared/c3/code/module regex '([a-z0-9_]+)(?=::)' 1:module | ||||||
| # code/module-decl highlights '::' as modules, but they should not be highlighted | ||||||
| addhl shared/c3/code/namespace regex '::' 0:Default | ||||||
| addhl shared/c3/code/shebang regex '\A#! ?/.*?\n' 0:comment | ||||||
|
|
||||||
| evaluate-commands %sh{ | ||||||
| # generated using "c3c --list-{} | string join ' '" in fish | ||||||
| keywords='alias assert asm attrdef bitstruct break case catch const continue default defer do else enum extern false faultdef for foreach foreach_r fn tlocal if inline import macro module nextcase null interface return static struct switch true try typedef union var while' | ||||||
| attributes='@align @benchmark @bigendian @builtin @callconv @compact @const @deprecated @dynamic @export @extern @finalizer @format @if @inline @init @link @littleendian @local @maydiscard @naked @noalias @nodiscard @noinit @noinline @nopadding @norecurse @noreturn @nosanitize @nostrip @obfuscate @operator @operator_r @operator_s @optional @overlap @packed @private @public @pure @reflect @safemacro @section @tag @test @unused @used @wasm @weak @winmain' | ||||||
| builtins='$$abs $$any_make $$atomic_load $$atomic_store $$atomic_fetch_exchange $$atomic_fetch_add $$atomic_fetch_sub $$atomic_fetch_and $$atomic_fetch_nand $$atomic_fetch_or $$atomic_fetch_xor $$atomic_fetch_max $$atomic_fetch_min $$atomic_fetch_inc_wrap $$atomic_fetch_dec_wrap $$bitreverse $$breakpoint $$bswap $$ceil $$compare_exchange $$copysign $$cos $$clz $$ctz $$add $$div $$mod $$mul $$neg $$sub $$exp $$exp2 $$expect $$expect_with_probability $$floor $$fma $$fmuladd $$frameaddress $$fshl $$fshr $$gather $$get_rounding_mode $$log $$log10 $$log2 $$masked_load $$masked_store $$max $$memcpy $$memcpy_inline $$memmove $$memset $$memset_inline $$min $$nearbyint $$overflow_add $$overflow_mul $$overflow_sub $$popcount $$pow $$pow_int $$prefetch $$reduce_add $$reduce_and $$reduce_fadd $$reduce_fmul $$reduce_max $$reduce_min $$reduce_mul $$reduce_or $$reduce_xor $$reverse $$returnaddress $$rint $$round $$roundeven $$sat_add $$sat_shl $$sat_sub $$scatter $$select $$set_rounding_mode $$str_hash $$str_upper $$str_lower $$str_find $$swizzle $$swizzle2 $$sin $$sqrt $$syscall $$sysclock $$trap $$trunc $$unaligned_load $$unaligned_store $$unreachable $$veccomplt $$veccomple $$veccompgt $$veccompge $$veccompeq $$veccompne $$volatile_load $$volatile_store $$wasm_memory_size $$wasm_memory_grow $$wstr16 $$wstr32 $$DATE $$FILE $$FILEPATH $$FUNC $$FUNCTION $$LINE $$LINE_RAW $$MODULE $$BENCHMARK_NAMES $$BENCHMARK_FNS $$TEST_NAMES $$TEST_FNS $$TIME' | ||||||
| # Manually extracted from c3c --list-keywords | ||||||
| types='void bool char double float float16 bfloat int128 ichar int iptr isz long short uint128 uint ulong uptr ushort usz float128 any fault typeid' | ||||||
| # Needs to be separate from keywords due to the '$' prefix causing issues with '\b' resulting in things like '$endfor' not being highlighted at all | ||||||
| comptime_keywords='alignof assert assignable case default defined echo else embed endfor endforeach endif endswitch eval evaltype error exec extnameof feature for foreach if include is_const nameof offsetof qnameof sizeof stringify switch typefrom typeof vacount vatype vaconst vaarg vaexpr vasplat' | ||||||
|
|
||||||
| # Both joins with a separator and escapes '$' characters | ||||||
| join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*" | sed -e 's/\$/\\\$/g'; } | ||||||
|
|
||||||
| printf %s " | ||||||
| addhl shared/c3/code/keywords regex '(?<![@#$])\b(?:$(join '${keywords}' '|'))\\b' 0:keyword | ||||||
| addhl shared/c3/code/comptime-keywords regex '[$](?:$(join '${comptime_keywords}' '|'))\\b' 0:keyword | ||||||
| addhl shared/c3/code/builtins regex '(?:$(join '${builtins}' '|'))\\b' 0:keyword | ||||||
| addhl shared/c3/code/attributes regex '(?:$(join '${attributes}' '|'))\\b' 0:attribute | ||||||
| addhl shared/c3/code/types regex '(?<![@#$])\\b(?:$(join '${types}' '|'))\\b' 0:type | ||||||
| " | ||||||
| keywords='alias assert asm attrdef bitstruct break case catch const continue default defer do else enum extern false faultdef for foreach foreach_r fn tlocal if inline import lengthof macro module nextcase null interface return static struct switch true try typedef union var while' | ||||||
| attributes='align allow_deprecated benchmark bigendian builtin callconv compact const deprecated dynamic export extern finalizer format if inline init jump link littleendian local maydiscard naked noalias nodiscard noinit noinline nopadding norecurse noreturn nosanitize nostrip obfuscate operator operator_r operator_s optional overlap packed private public pure reflect safeinfer safemacro section structlike tag test unused used wasm weak winmain' | ||||||
| builtins='abs add any_make atomic_fetch_add atomic_fetch_and atomic_fetch_dec_wrap atomic_fetch_exchange atomic_fetch_inc_wrap atomic_fetch_max atomic_fetch_min atomic_fetch_nand atomic_fetch_or atomic_fetch_sub atomic_fetch_xor atomic_load atomic_store bitreverse breakpoint bswap ceil clz compare_exchange copysign cos ctz div exp exp2 expect expect_with_probability fence floor fma fmuladd frameaddress fshl fshr gather get_rounding_mode log log10 log2 masked_load masked_store matrix_mul matrix_transpose max memcpy memcpy_inline memmove memset memset_inline min mod mul nearbyint neg overflow_add overflow_mul overflow_sub popcount pow pow_int prefetch reduce_add reduce_and reduce_fadd reduce_fmul reduce_max reduce_min reduce_mul reduce_or reduce_xor returnaddress reverse rint rnd round roundeven sat_add sat_mul sat_shl sat_sub scatter select set_rounding_mode sin sprintf sqrt str_find str_hash str_lower str_pascalcase str_replace str_snakecase str_upper sub swizzle swizzle2 syscall sysclock trap trunc unaligned_load unaligned_store unreachable veccompeq veccompge veccompgt veccomple veccomplt veccompne volatile_load volatile_store wasm_memory_grow wasm_memory_size wstr16 wstr32 BENCHMARK_FNS BENCHMARK_NAMES DATE FILE FILEPATH FUNC FUNCTION LINE LINE_RAW MODULE TEST_FNS TEST_NAMES TIME ADDRESS_SANITIZER ARCH_TYPE AUTHOR_EMAILS AUTHORS BACKTRACE BENCHMARKING BUILD_DATE BUILD_HASH COMPILER_LIBC_AVAILABLE COMPILER_OPT_LEVEL COMPILER_SAFE_MODE DEBUG_SYMBOLS LANGUAGE_DEV_VERSION LLVM_VERSION MAX_VECTOR_SIZE MEMORY_ENVIRONMENT MEMORY_SANITIZER OS_TYPE PANIC_MSG PLATFORM_BIG_ENDIAN PLATFORM_F128_SUPPORTED PLATFORM_F16_SUPPORTED PLATFORM_I128_SUPPORTED PROJECT_VERSION REGISTER_SIZE TESTING THREAD_SANITIZER' | ||||||
| types='void bool char double float float16 bfloat int128 ichar int iptr isz long short uint128 uint ulong uptr ushort usz float128 any fault typeid' | ||||||
| comptime_keywords='alignof assert assignable case default defined echo else embed endfor endforeach endif endswitch eval evaltype error exec extnameof feature for foreach if include is_const kindof nameof offsetof qnameof sizeof stringify switch typefrom typeof vacount vatype vaconst vaarg vaexpr vasplat' | ||||||
|
|
||||||
| # Both joins with a separator and escapes '$' characters | ||||||
| join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*" | sed -e 's/\$/\\\$/g'; } | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
the sed isn't needed anymore since it was my hack to escape all the |
||||||
|
|
||||||
| printf %s\\n "declare-option str-list c3_static_words $(echo ${keywords} ${attributes} ${types} ${builtins} ${comptime_keywords})'" | ||||||
|
|
||||||
| printf %s " | ||||||
| addhl shared/c3/code/keywords regex '(?<![@#$])\b(?:$(join '${keywords}' '|'))\\b' 0:keyword | ||||||
| addhl shared/c3/code/comptime-keywords regex '[$](?:$(join '${comptime_keywords}' '|'))\\b' 0:keyword | ||||||
| addhl shared/c3/code/builtins regex '[$]{2}(?:$(join '${builtins}' '|'))\\b' 0:keyword | ||||||
| addhl shared/c3/code/attributes regex '[@]\b(?:$(join '${attributes}' '|'))\\b' 0:attribute | ||||||
| addhl shared/c3/code/types regex '(?<![@#$])\\b(?:$(join '${types}' '|'))\\b' 0:type | ||||||
| " | ||||||
| } | ||||||
|
|
||||||
| } | ||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right and these should probably be updated