Skip to content

Commit

Permalink
Add real Nushell syntax highlighting support (#1078)
Browse files Browse the repository at this point in the history
* Add real Nushell syntax highlighting support

* Try to use @vuepress/plugin-shiki

* chore: Add shiki patch file

* chore: Update docs

* Add patch-package

* chore: Update docs

* chore: Update docs

* chore: Update docs

* chore: Update docs
  • Loading branch information
hustcer authored Oct 2, 2023
1 parent 5708b37 commit 63ee848
Show file tree
Hide file tree
Showing 77 changed files with 2,159 additions and 788 deletions.
20 changes: 18 additions & 2 deletions .vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';
import { defineUserConfig } from '@vuepress/cli';
import { gitPlugin } from '@vuepress/plugin-git';
import { feedPlugin } from 'vuepress-plugin-feed2';
import { shikiPlugin } from '@vuepress/plugin-shiki';
import { defaultTheme } from '@vuepress/theme-default';
import { sitemapPlugin } from 'vuepress-plugin-sitemap2';
import { docsearchPlugin } from '@vuepress/plugin-docsearch';
Expand Down Expand Up @@ -139,6 +140,21 @@ export default defineUserConfig({
gitPlugin(),
backToTopPlugin(),
mediumZoomPlugin(),
shikiPlugin({
theme: 'dark-plus',
langs: [
'nushell',
'rust',
'bash',
'shell',
'sh',
'toml',
'json',
'python',
'cpp',
'powershell',
],
}),
docsearchPlugin({
appId: 'GHCTOYCW6T',
indexName: 'nushell',
Expand All @@ -162,7 +178,7 @@ export default defineUserConfig({
: a.frontmatter.date,
b.data.git?.createdTime
? new Date(b.data.git?.createdTime)
: b.frontmatter.date
: b.frontmatter.date,
);
},
}),
Expand All @@ -173,7 +189,7 @@ export default defineUserConfig({
onPrepared: async (app) => {
await app.writeTemp(
'pages.js',
`export default ${JSON.stringify(app.pages.map(({ data }) => data))}`
`export default ${JSON.stringify(app.pages.map(({ data }) => data))}`,
);
},
});
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ Nushell is available as [downloadable binaries](https://github.com/nushell/nushe

#### macOS / Linux:

```console
```shell
$ brew install nushell
```

#### Windows:

```console
```shell
$ winget install nushell
```

Expand Down
8 changes: 4 additions & 4 deletions book/3rdpartyprompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ If you like [oh-my-posh](https://ohmyposh.dev/), you can use oh-my-posh with Nus
3. Generate the .oh-my-posh.nu file. By default it will be generated to your home directory. You can use `--config` to specify a theme, other wise, oh-my-posh comes with a default theme.
4. Initialize oh-my-posh prompt by adding in ~/.config/nushell/config.nu(or the path output by `$nu.config-path`) to source ~/.oh-my-posh.nu.

```shell
```nu
# Generate the .oh-my-posh.nu file
> oh-my-posh init nu --config ~/.poshthemes/M365Princess.omp.json
> oh-my-posh init nu --config ~/.poshthemes/M365Princess.omp.json
# Initialize oh-my-posh.nu at shell startup by adding this line in your config.nu file
> source ~/.oh-my-posh.nu
Expand All @@ -35,7 +35,7 @@ For MacOS users:
2. Download and install a [nerd font](https://github.com/ryanoasis/nerd-fonts).
3. Set the PROMPT_COMMAND in the file output by `$nu.config-path`, here is a code snippet:

```shell
```nu
let posh_dir = (brew --prefix oh-my-posh | str trim)
let posh_theme = $'($posh_dir)/share/oh-my-posh/themes/'
# Change the theme names to: zash/space/robbyrussel/powerline/powerlevel10k_lean/
Expand All @@ -58,7 +58,7 @@ $env.PROMPT_INDICATOR = $"(ansi y)$> (ansi reset)"

Here's an example config section for Starship:

```
```nu
$env.STARSHIP_SHELL = "nu"
def create_left_prompt [] {
Expand Down
12 changes: 6 additions & 6 deletions book/aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ Aliases in Nushell offer a way of doing a simple replacement of command calls (b

For example, let's create an alias called `ll` which will expand to `ls -l`.

```
```nu
> alias ll = ls -l
```

We can now call this alias:

```
```nu
> ll
```

Once we do, it's as if we typed `ls -l`. This also allows us to pass in flags or positional parameters. For example, we can now also write:

```
```nu
> ll -a
```

Expand All @@ -31,7 +31,7 @@ Your useable aliases can be seen in `scope aliases` and `help aliases`.
To make your aliases persistent they must be added to your _config.nu_ file by running `config nu` to open an editor and inserting them, and then restarting nushell.
e.g. with the above `ll` alias, you can add `alias ll = ls -l` anywhere in _config.nu_

```nushell
```nu
$env.config = {
# main configuration
}
Expand All @@ -46,15 +46,15 @@ alias ll = ls -l
Note that `alias uuidgen = uuidgen | tr A-F a-f` (to make uuidgen on mac behave like linux) won't work.
The solution is to define a command without parameters that calls the system program `uuidgen` via `^`.

```
```nu
def uuidgen [] { ^uuidgen | tr A-F a-f }
```

See more in the [custom commands](custom_commands.md) section of this book.

Or a more idiomatic example with nushell internal commands

```
```nu
def lsg [] { ls | sort-by type name -i | grid -c | str trim }
```

Expand Down
Loading

0 comments on commit 63ee848

Please sign in to comment.