-
Notifications
You must be signed in to change notification settings - Fork 458
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
✨ add a Contributing guide to parser and editor tools related stuff #1311
Open
AucaCoyan
wants to merge
6
commits into
nushell:main
Choose a base branch
from
AucaCoyan:add-editor-tools-contrib-page
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
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ddfb23b
:sparkles: add the page and test if it works
AucaCoyan 2e78699
:sparkles: add contributing guide to parser and editor related topics
AucaCoyan bc66a93
:memo: update section on tree-sitter
AucaCoyan 535f9cc
:pencil2: typo
AucaCoyan 8f8ad98
Merge branch 'main' into add-editor-tools-contrib-page
AucaCoyan 12f1c21
:pencil2: fix typo and red ci
AucaCoyan 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 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
title: Parser and other editor tools | ||
--- | ||
|
||
# Parser and other editor tools | ||
|
||
Hi! There is a lot of space to grow in this area, and the development is | ||
somewhat spaced in time, so I (@AucaCoyan) decided to make a document explaning | ||
the framework, conventions and other required knowledge to help others and | ||
myself with this section. | ||
|
||
## Parser | ||
|
||
The most important piece of this chapter is the parser. The parser is the bridge | ||
between the `*.nu` text files and the internal representation of object in | ||
nushell. Almost everything in this chapter interacts or is affected by the | ||
parser. | ||
|
||
### Current status | ||
|
||
The current production parser is not bad at all, but it has certain areas that | ||
some improvement that could be greately appreciated. Sophia [started a new parser](https://github.com/sophiajt/new-nu-parser/) | ||
and it's still on the works. The central idea of this new parser is that it | ||
will have multiple passes over the text, improving the typing structures by | ||
a lot. | ||
|
||
## Formatter | ||
|
||
We have [`nufmt`](https://github.com/nushell/nufmt), but is a little stagnated | ||
because it will probably need some rework after the new parser is landed. The | ||
current issue is a bug reading stdin from the cmdline. Ask @AucaCoyan anything! | ||
|
||
## LSPs | ||
|
||
LSP stands for Language Server Protocol, a [Microsoft document](https://microsoft.github.io/language-server-protocol/) | ||
to establish communication between text editors and parsers and other tools. | ||
|
||
We currently have 2 of them, one for VS Code and one for other terminal editors | ||
|
||
### VSCode | ||
|
||
This has [it's own extension](https://github.com/nushell/vscode-nushell-lang/) | ||
and it's the most advanced LSP. It was the first to appear it is bootstraped | ||
from a prototype of Microsoft. It's written in Typescript and interacts with | ||
`nu` in the command line to have: | ||
|
||
- hover | ||
- go to definition | ||
- auto-completions | ||
|
||
### nu-lsp | ||
|
||
This is a newer LSP that we would like to have as the long term for every editor | ||
. It's written in rust and it's on the `nushell/nushell` repo, in the | ||
[`crates/nu-lsp`](https://github.com/nushell/nushell/tree/main/crates/nu-lsp) | ||
folder. Interacts via stdin and stdout and it is useful for vim, | ||
neovim, helix and other text editors. Sadly, it doesn't have the same level of | ||
features of VSCode-nushell-lang, that's why we still can't replace it. | ||
|
||
## Tree-sitter | ||
|
||
For syntax highligting we can use [nushell tre-sitter grammar](https://github.com/nushell/tree-sitter-nu) | ||
AucaCoyan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this is useful for terminal text editors (nvim, helix, etc), VS Code [has | ||
its own grammar](https://github.com/nushell/vscode-nushell-lang/blob/main/syntaxes/nushell.tmLanguage.json) | ||
|
||
## I dont know a thing about all this, can you give me a hint where to learn? | ||
|
||
Sure! | ||
|
||
- Adrian Hesketh gives an excellent talk about [how LSP works](https://youtu.be/EkK8Jxjj95s?si=KT3YdfV5LebbTzXp) | ||
- TeeJ explains [tree-sitter in a 15 min video](https://www.youtube.com/watch?v=09-9LltqWLY) | ||
- about the formatter: | ||
- Bob Nystrom worked with the dart formatter and [wrote a precious blog post](https://journal.stuffwithstuff.com/2015/09/08/the-hardest-program-ive-ever-written/) about his journey. The hackernews | ||
[post is also useful](https://news.ycombinator.com/item?id=22706242) for the | ||
comments! | ||
- and a [short overall view](https://blog.vjeux.com/2017/javascript/anatomy-of-a-javascript-pretty-printer.html) | ||
of how `prettier` works |
This file contains 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
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.
There are a few things missing from this list.
It also helps locate nu and if it finds it allow nu to be used as a terminal shell.
It displays Inlays
It allows you to have separate IncludeDirs
It has diagnostics to show errors
Most of this is laid out in the extension readme