Skip to content
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

feat: add shellsession grammar #483

Merged
merged 2 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ export type Lang =
| 'scheme'
| 'scss'
| 'shaderlab' | 'shader'
| 'shellscript' | 'bash' | 'console' | 'sh' | 'shell' | 'zsh'
| 'shellscript' | 'bash' | 'sh' | 'shell' | 'zsh'
| 'shellsession' | 'console'
| 'smalltalk'
| 'solidity'
| 'sparql'
Expand Down
30 changes: 30 additions & 0 deletions packages/shiki/languages/shellsession.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "shellsession",
"scopeName": "text.shell-session",
"patterns": [
{
"match": "(?x) ^ (?: ( (?:\\(\\S+\\)\\s*)? (?: sh\\S*? | \\w+\\S+[@:]\\S+(?:\\s+\\S+)? | \\[\\S+?[@:][^\\n]+?\\].*? ) ) \\s* )? ( [>$#%❯➜] | \\p{Greek} ) \\s+ (.*) $",
"captures": {
"1": {
"name": "entity.other.prompt-prefix.shell-session"
},
"2": {
"name": "punctuation.separator.prompt.shell-session"
},
"3": {
"name": "source.shell",
"patterns": [
{
"include": "source.shell"
}
]
}
}
},
{
"name": "meta.output.shell-session",
"match": "^.+$"
}
],
"fileTypes": ["sh-session"]
}
13 changes: 13 additions & 0 deletions packages/shiki/samples/shellsession.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$ echo $EDITOR
vim
$ git checkout main
Switched to branch 'main'
Your branch is up-to-date with 'origin/main'.
$ git push
Everything up-to-date
$ echo 'All
> done!'
All
done!

# From https://github.com/highlightjs/highlight.js/blob/fcefad4a6bf99b88c54b2b724ca77466e94c374d/test/detect/shell/default.txt#L4
16 changes: 13 additions & 3 deletions packages/shiki/src/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ export type Lang =
| 'scheme'
| 'scss'
| 'shaderlab' | 'shader'
| 'shellscript' | 'bash' | 'console' | 'sh' | 'shell' | 'zsh'
| 'shellscript' | 'bash' | 'sh' | 'shell' | 'zsh'
| 'shellsession' | 'console'
| 'smalltalk'
| 'solidity'
| 'sparql'
Expand Down Expand Up @@ -808,6 +809,7 @@ export const languages: ILanguageRegistration[] = [
scopeName: 'text.marko',
path: 'marko.tmLanguage.json',
displayName: 'Marko',
samplePath: 'marko.sample',
embeddedLangs: ['css', 'less', 'scss', 'javascript']
},
{
Expand All @@ -821,7 +823,7 @@ export const languages: ILanguageRegistration[] = [
scopeName: 'source.mdx',
path: 'mdx.tmLanguage.json',
displayName: 'MDX',
embeddedLangs: ['tsx', 'toml', 'yaml', 'c', 'clojure', 'coffee', 'cpp', 'csharp', 'css', 'diff', 'docker', 'elixir', 'elm', 'erlang', 'go', 'graphql', 'haskell', 'html', 'ini', 'java', 'javascript', 'json', 'julia', 'kotlin', 'less', 'lua', 'make', 'markdown', 'objective-c', 'perl', 'python', 'r', 'ruby', 'rust', 'scala', 'scss', 'shellscript', 'sql', 'xml', 'swift', 'typescript']
embeddedLangs: ['tsx', 'toml', 'yaml', 'c', 'clojure', 'coffee', 'cpp', 'csharp', 'css', 'diff', 'docker', 'elixir', 'elm', 'erlang', 'go', 'graphql', 'haskell', 'html', 'ini', 'java', 'javascript', 'json', 'julia', 'kotlin', 'less', 'lua', 'make', 'markdown', 'objective-c', 'perl', 'python', 'r', 'ruby', 'rust', 'scala', 'scss', 'shellscript', 'shellsession', 'sql', 'xml', 'swift', 'typescript']
},
{
id: 'mermaid',
Expand Down Expand Up @@ -1078,7 +1080,15 @@ export const languages: ILanguageRegistration[] = [
scopeName: 'source.shell',
path: 'shellscript.tmLanguage.json',
displayName: 'Shell',
aliases: ['bash', 'console', 'sh', 'shell', 'zsh']
aliases: ['bash', 'sh', 'shell', 'zsh']
},
{
id: 'shellsession',
scopeName: 'text.shell-session',
path: 'shellsession.tmLanguage.json',
displayName: 'Shell Session',
aliases: ['console'],
embeddedLangs: ['shellscript']
},
{
id: 'smalltalk',
Expand Down
4 changes: 3 additions & 1 deletion scripts/grammarSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ export const githubGrammarSources: [string, string][] = [
'https://github.com/scala/vscode-scala-syntax/blob/master/syntaxes/Scala.tmLanguage.json'
],
['scheme', 'https://github.com/sjhuangx/vscode-scheme/blob/master/syntaxes/scheme.tmLanguage'],
['shellsession', 'https://github.com/hronro/sublime-linguist-syntax/blob/master/syntaxes/ShellSession.tmLanguage'],
[
'smalltalk',
'https://github.com/leocamello/vscode-smalltalk/blob/master/syntaxes/smalltalk.tmLanguage.json'
Expand Down Expand Up @@ -358,7 +359,8 @@ export const languageAliases = {
rust: ['rs'],
'html-ruby-erb': ['erb'],
shaderlab: ['shader'],
shellscript: ['bash', 'console', 'sh', 'shell', 'zsh'],
shellscript: ['bash', 'sh', 'shell', 'zsh'],
shellsession: ['console'],
stylus: ['styl'],
typescript: ['ts'],
vb: ['cmd'],
Expand Down