Skip to content

Commit

Permalink
update nim grammar to support the new number literals (#5306)
Browse files Browse the repository at this point in the history
* add synthetic sample file intended to show all allowed nim syntax

* nim: update NimLime url to get the new nim literals correctly highlighted

* fixup

* update vendor/README.md

* update vendor/README.md

* vendor/grammars/NimLime
  • Loading branch information
timotheecour committed Apr 6, 2021
1 parent 8b1f601 commit 9f717cc
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
url = https://github.com/github-linguist/NSIS
[submodule "vendor/grammars/NimLime"]
path = vendor/grammars/NimLime
url = https://github.com/Varriount/NimLime
url = https://github.com/timotheecour/NimLime
branch = master2
[submodule "vendor/grammars/Nixinova-tmLanguage"]
path = vendor/grammars/Nixinova-tmLanguage
url = https://github.com/Nixinova/tmLanguage
Expand Down
84 changes: 84 additions & 0 deletions samples/Nim/main.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
iterator fn1: int = yield 12
template fn2 = discard
macro fn3 = discard
proc fn4 = discard
proc fn5(a, b: int, c: float, d, e: string; f: char) = discard

template fn6 =
block: ## number literals
echo (1'u8, 0b1010, 0xdeadBEEF'big, -123'32, 12_345.002e-12'f128)
let a = 0xdeadBEEF'wrap
let b = -123'wrap

block: ## char literals
let c = '\1'
let c = '\e'
let c = '\n'
let c = '\x12'

block: ## string literals
let a = ""
let b = "ab\ndef"
let c = r"a\ndef"
let g = """
a\ndef"""
let h = """a\ndef"""
let i = """a\ndef""".dedent # BUG: syntax highlight wrong
let j = """a\ndef"""&"asdf" # BUG: syntax highlight wrong
let k = """a\ndef""" & "asdf" # ok

block:
## tuples
let a = (-123'wrap, 12'f33, )
let b = ()
let c = (1,)
let d = (1)

block:
let a = @[1]
let b = [1,2]

proc `'fn6b`(a: string): int = discard
proc `cast`(a: string): int = discard
proc fn6c[T; T2](a: T): T = discard
proc fn6d[T, T2](a: T): T = discard
proc fn6e[T](a: T): T = discard

runnableExamples: discard

runnableExamples("-r:off"): discard

proc fn7 =
runnableExamples("-r:off -d:danger"):
assert 1 + 1 == 2

proc fn8 =
runnableExamples("-r:off -d:danger"):
assert 1 + 1 == 2

proc fn9 =
##[
hello world `foo.bar`
* b1
* b2
* b3
]##
runnableExamples("-r:off -d:danger"):
assert 1 + 1 == 2

type F10 = enum a1, a2
type F11 = ref object of RootRef
x1, x2: int
x3: tuple[a: int]
x4: (int, float, float32, float64)

type
F12 = int
F13 = ref F12

const a = 1
const
b = 2
c = b
let d = "ad"
var e = "ad"
2 changes: 1 addition & 1 deletion vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **NewLisp:** [textmate/lisp.tmbundle](https://github.com/textmate/lisp.tmbundle)
- **Nextflow:** [nextflow-io/atom-language-nextflow](https://github.com/nextflow-io/atom-language-nextflow)
- **Nginx:** [brandonwamboldt/sublime-nginx](https://github.com/brandonwamboldt/sublime-nginx)
- **Nim:** [Varriount/NimLime](https://github.com/Varriount/NimLime)
- **Nim:** [timotheecour/NimLime](https://github.com/timotheecour/NimLime)
- **Ninja:** [khyo/language-ninja](https://github.com/khyo/language-ninja)
- **Nit:** [R4PaSs/Sublime-Nit](https://github.com/R4PaSs/Sublime-Nit)
- **Nix:** [wmertens/sublime-nix](https://github.com/wmertens/sublime-nix)
Expand Down
2 changes: 1 addition & 1 deletion vendor/grammars/NimLime
2 changes: 1 addition & 1 deletion vendor/licenses/git_submodule/NimLime.dep.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
type: git_submodule
name: NimLime
version: f75325a01dd4428e12fbc38289ed6e0d12e82a9c
version: b16e7469dd8a6a9e3e77382dfce642d424a472af
license: mit
licenses:
- text: |-
Expand Down

0 comments on commit 9f717cc

Please sign in to comment.