Skip to content

Commit

Permalink
fix: semantic tokens, python, operator fixes (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks authored Jan 16, 2024
1 parent 524d439 commit 6a553b2
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 18 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.11.1

- Disable default semantic highlighting for Moonlight II
- More closely match semantic tokens with original TM scopes (Python test)
- Fix semantic function coloring consistency for all langs
- Fix non-semantic python function call coloring in some situations
- Fix operators being italicised incorrectly in italics variants
- Markdown improvements for original Moonlight

## 0.11.0

- Refreshed colors
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

## Semantic highlighting

Semantic highlighting is enabled by default. To disable it, add the following to your settings.json:
Semantic highlighting is enabled by default for `Moonlight`, but not `Moonlight II`.
To change the setting, add the following to your settings.json:

```json
"editor.semanticHighlighting.enabled": false
"editor.semanticHighlighting.enabled": true
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "moonlight",
"displayName": "Moonlight",
"description": "A VS Code theme with bubblegum colors on a moonlit background.",
"version": "0.11.0",
"version": "0.11.1",
"publisher": "atomiks",
"type": "module",
"license": "MIT",
Expand Down
Binary file modified preview.webp
Binary file not shown.
22 changes: 15 additions & 7 deletions src/moonlight-ii.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
"$schema": "vscode://schemas/color-theme",
"name": "moonlight-ii",
"type": "dark",
"semanticHighlighting": true,
"semanticHighlighting": false,
"semanticTokenColors": {
"function": "{sky}",
"function.declaration": "{blue}",
"method.defaultLibrary": "{sky}",
"function": "{blue}",
"method.declaration": "{blue}",
"function.defaultLibrary": "{sky}",
"method": "{sky}",
"variable.defaultLibrary": "{yellow}",
"property.declaration": "{teal}"
"property": "{gray8}",
"property.declaration": "{teal}",
"property.readonly": "{lightOrange}",
"class.builtin": "{orange}",
"selfParameter": "{red}",
"module": "{gray10}"
},
"tokenColors": [
{
Expand Down Expand Up @@ -150,7 +156,8 @@
"string.other.end.code"
],
"settings": {
"foreground": "{cyan}"
"foreground": "{cyan}",
"fontStyle": "normal"
}
},
{
Expand Down Expand Up @@ -180,7 +187,8 @@
"scope": [
"entity.name.function",
"variable.function",
"keyword.other.special-method"
"keyword.other.special-method",
"meta.function-call.generic"
],
"settings": {
"foreground": "{blue}"
Expand Down
24 changes: 16 additions & 8 deletions src/moonlight.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
"type": "dark",
"semanticHighlighting": true,
"semanticTokenColors": {
"function": "{sky}",
"function.declaration": "{blue}",
"method.defaultLibrary": "{sky}",
"function": "{blue}",
"method.declaration": "{blue}",
"function.defaultLibrary": "{sky}",
"method": "{sky}",
"property": "{gray8}",
"property.declaration": "{green}",
"variable.defaultLibrary": "{yellow}"
"property.readonly": "{lightCyan}",
"variable.defaultLibrary": "{yellow}",
"class.builtin": "{orange}",
"selfParameter": "{red}",
"module": "{gray10}"
},
"tokenColors": [
{
Expand Down Expand Up @@ -106,7 +112,8 @@
"string.other.end.code"
],
"settings": {
"foreground": "{cyan}"
"foreground": "{cyan}",
"fontStyle": "normal"
}
},
{
Expand Down Expand Up @@ -147,7 +154,8 @@
"scope": [
"entity.name.function",
"variable.function",
"keyword.other.special-method"
"keyword.other.special-method",
"meta.function-call.generic"
],
"settings": {
"foreground": "{blue}"
Expand Down Expand Up @@ -645,7 +653,7 @@
"text.html.markdown markup.inline.raw.markdown punctuation.definition.raw.markdown"
],
"settings": {
"foreground": "{gray8}"
"foreground": "{cyan}"
}
},
{
Expand Down Expand Up @@ -754,7 +762,7 @@
"markup.inline.raw.string.markdown"
],
"settings": {
"foreground": "{gray9}"
"foreground": "{cyan}"
}
},
{
Expand Down
63 changes: 63 additions & 0 deletions tests/python.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import random
import functools

# Decorator for logging
def debug(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
result = func(*args, **kwargs)
print(f"Function {func.__name__!r} returned {result!r}")
return result
return wrapper

# A simple class with different methods and properties
class Animal:
def __init__(self, name):
self._name = name

@property
def name(self):
return self._name

@name.setter
def name(self, value):
self._name = value

def speak(self):
raise NotImplementedError("Subclasses must implement this method")

class Dog(Animal):
def speak(self):
return f"{self._name} says woof!"

class Cat(Animal):
def speak(self):
return f"{self._name} says meow!"

# A function that handles exceptions
@debug
def random_animal_speak(animals):
try:
choice = random.choice(animals)
speak = choice.speak()
except IndexError as e:
print("No animals in the list!")
except Exception as e:
print(f"An error occurred: {e}")
else:
return speak
finally:
print("Function random_animal_speak() is done")

# Using list comprehension, map and lambda
animals = [Dog("Buddy"), Cat("Whiskers"), Dog("Rex")]
animal_sounds = map(lambda animal: animal.speak(), animals)
loud_sounds = [sound.upper() for sound in animal_sounds]

# Main block
if __name__ == "__main__":
for sound in loud_sounds:
print(sound)

# Print a random animal's sound
print(random_animal_speak(animals))

0 comments on commit 6a553b2

Please sign in to comment.