IDE tools for writing pest grammars, using the Language Server Protocol for Visual Studio Code, Vim and other editors

Overview

Pest IDE Tools

IDE support for Pest, via the LSP.

This repository contains an implementation of the Language Server Protocol in Rust, for the Pest parser generator.

A demo of the Pest VSCode extension.

Features

  • Error reporting.
  • Warnings for unused rules.
  • Syntax highlighting definitions available.
  • Rename rules.
  • Go to rule declaration, definition, or references.
  • Hover information for built-in rules and documented rules.
  • Autocompletion of defined rule names.
  • Formatting.
  • Update checking.

Please see the issues page to suggest features or view previous suggestions.

Usage

You can find documentation on how to set up the server for in the DOCS.md file.

Supported IDEs

  • Visual Studio Code
    • VSCode has a pre-built extension that can compile, update, and start up the language server. It also includes syntax highlighting definitions.

Due to the usage of the LSP by this project, adding support for new IDEs should be far more achievable than a custom implementation for each editor. Please see the tracking issue to request support for another IDE or view the current status of IDE support.

Development

This repository uses a Taskfile; install the task command for a better experience developing in this repository.

The task fmt-and-lint can be used to check the formatting and lint your code to ensure it fits with the rest of the repository.

In VSCode, press F5 to build and debug the VSCode extension. This is the only method of debugging that we have pre set-up.

Architecture

The server itself is implemented in Rust using tower-lsp. It communicates with editors via JSON-RPC through standard input/output, according to the language server protocol.

Contributing

We appreciate contributions! I recommend reaching out on Discord (the invite to which can be found at pest.rs) before contributing, to check with us.

Credits

Comments
  • The Great Rewrite of 2023

    The Great Rewrite of 2023

    This rewrites the server to use tower_lsp.

    The VSCode server will download and compile the server using cargo install.

    TODO

    • [x] Get a new version of pest_fmt released, so we can have this commit
    • [x] Test the VSCode binary installer
    • [x] VScode should use the compiled version in target/debug when launching a debug window
    • [x] GIFs
    • [x] Unused rule warnings
    enhancement 
    opened by Jamalam360 11
  • Crash when using Unicode Character

    Crash when using Unicode Character

    Using Unicode characters, such as Chinese, may crashes. But sometimes I can't reproduce it.

    Source:

    foobar = { "中文" }
    

    Log:

    thread 'main' panicked at 'byte index 13 is not a char boundary; it is inside '中' (bytes 12..15) of `foobar = { "中文" }`', C:\Users\zeng-\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\pest-language-server-0.2.1\src\helpers.rs:117:20
    
    bug 
    opened by zeng-y-l 4
  • [BUG] Goto Definition handler

    [BUG] Goto Definition handler

    It seems like there is a bug in Goto Definition response.

    Seems like it returns the result with a subtraction (with underflow) of 1 for all four fields. For the example below: | symbol | expected | lsp response | |---------|-----------|-----------------| | first | 0:0-0:5 | MAX:MAX-NAX:4 | | x | 3:0-3:1 | 2:MAX- 2:0 | | y | 5:4-5:5 | 4:3 - 4:4 |

    , where MAX stands for u32::MAX

    The example:

    first = { ANY }
    
    // some comment
    x = { first }
    
        y = { x } // there are 4 spaces before this symbol
    
    

    I noticed this commit (b503d1b) where a subtraction of one was added for both enum invariant (Pos and Span). It seems to work well when I delete this subtraction for Span (but not for Pos, as this make the wrong reponse for diagnostics).

    bug server fixed 
    opened by miroslavbel 2
  • Better `unused` warning

    Better `unused` warning

    image

    In a pest file, there will be always have a grammar_rule is not used. But that is the final rule, so the extension it will always show the unused warning.

    bug 
    opened by huacnlee 1
  • chore(deps): bump h2 from 0.3.16 to 0.3.17

    chore(deps): bump h2 from 0.3.16 to 0.3.17

    Bumps h2 from 0.3.16 to 0.3.17.

    Release notes

    Sourced from h2's releases.

    v0.3.17

    What's Changed

    • Add Error::is_library() method to check if the originated inside h2.
    • Add max_pending_accept_reset_streams(usize) option to client and server builders.
    • Fix theoretical memory growth when receiving too many HEADERS and then RST_STREAM frames faster than an application can accept them off the queue. (CVE-2023-26964)
    Changelog

    Sourced from h2's changelog.

    0.3.17 (April 13, 2023)

    • Add Error::is_library() method to check if the originated inside h2.
    • Add max_pending_accept_reset_streams(usize) option to client and server builders.
    • Fix theoretical memory growth when receiving too many HEADERS and then RST_STREAM frames faster than an application can accept them off the queue. (CVE-2023-26964)
    Commits
    • af4bcac v0.3.17
    • d3f37e9 feat: add max_pending_accept_reset_streams(n) options
    • 5bc8e72 fix: limit the amount of pending-accept reset streams
    • 8088ca6 feat: add Error::is_library method
    • 481c31d chore: Use Cargo metadata for the MSRV build job
    • d3d50ef chore: Replace unmaintained/outdated GitHub Actions
    • 45b9bcc chore: set rust-version in Cargo.toml (#664)
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies rust 
    opened by dependabot[bot] 1
  • chore(deps): bump xml2js from 0.4.23 to 0.5.0 in /vscode

    chore(deps): bump xml2js from 0.4.23 to 0.5.0 in /vscode

    Bumps xml2js from 0.4.23 to 0.5.0.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies javascript 
    opened by dependabot[bot] 0
  • chore(deps): bump openssl from 0.10.46 to 0.10.48

    chore(deps): bump openssl from 0.10.46 to 0.10.48

    Bumps openssl from 0.10.46 to 0.10.48.

    Release notes

    Sourced from openssl's releases.

    openssl v0.10.48

    What's Changed

    New Contributors

    Full Changelog: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.47...openssl-v0.10.48

    openssl v0.10.47

    No release notes provided.

    Commits
    • 4ff734f Release openssl v0.10.48 and openssl-sys v0.9.83 (#1855)
    • 5efceaa Merge pull request #1854 from alex/davids-openssl-of-horrors
    • 6ced4f3 Fix race condition with X509Name creation
    • a752805 Document the horror show
    • 78aa9aa Always provide an X509V3Context in X509Extension::new because OpenSSL require...
    • 332311b Resolve an injection vulnerability in EKU creation
    • 482575b Resolve an injection vulnerability in SAN creation
    • 690eeb2 Merge pull request #1852 from smoelius/master
    • e5b6d97 Improve reliability of some tests
    • 319200a Merge pull request #1851 from alex/libressl-versions
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies 
    opened by dependabot[bot] 0
  • Automatically fill changelog in release workflow

    Automatically fill changelog in release workflow

    It would be ideal if the release workflow could automatically grab the changelog for the tag from CHANGELOG.md and use it as the body for the GitHub release. I don't have time to work on this myself for now

    enhancement fixed 
    opened by Jamalam360 0
  • Add a code action to add an unused rule to `pestIdeTools.alwaysUsedRuleNames`

    Add a code action to add an unused rule to `pestIdeTools.alwaysUsedRuleNames`

    I haven't yet found a way in the LSP for servers to update their own config, which may be annoying. I'll look more but this might have to be vs code exclusive.

    enhancement wontfix server 
    opened by Jamalam360 4
  • IDE Support: Tracking Issue

    IDE Support: Tracking Issue

    This issue tracks progress on support for IDEs other than VSCode.

    Progress

    General Tasks

    • [x] Pull request and merge the rewrite to Tower LSP, allowing us to communicate over std i/o as defined via the LSP specification.
    • [x] Create an XML TextMate syntax - I haven't seen another editor that supports the JSON TextMate bundles that VSCode uses (maybe VSCode can use the XML ones so that there's only one source of syntax truth?).

    Editor List

    • [x] VSCode
    • [x] Sublime Text
    • [ ] Helix
    • [ ] (Neo)vim
    • [ ] Emacs
    • [ ] ~~Lapce~~; on hold, see comments

    Do you use an editor that isn't on this list? Please let us know in the comments so we are aware.

    enhancement new editor 
    opened by Jamalam360 9
Releases(v0.2.2)
  • v0.2.2(Apr 21, 2023)

  • v0.2.1(Apr 20, 2023)

    v0.2.1

    • fix(vscode): scan both stdout and stderr of Cargo commands, fixes some issues with installation flow
    • feat(*): documentation, issue templates
    • feat(sublime): begin publishing a sublime text package
    • fix(server, vscode): server now hot-reloads config updates more reliably
    • fix(server, vscode): bump problematic dependencies (love the JS ecosystem...a CVE a day keeps the doctor away)
    • feat(server): add rule inlining code action
    • feat(server): ignore unused rule name analysis if there is only one unused rule (hack fix)

    Full Changelog: https://github.com/pest-parser/pest-ide-tools/compare/v0.2.0...v0.2.1

    Source code(tar.gz)
    Source code(zip)
    pest.sublime-package(1.62 KB)
    pest.vsix(113.11 KB)
  • v0.2.0(Mar 17, 2023)

    v0.2.0

    • feat(*): port to tower lsp
      • This will allow the usage of this LS by other IDEs.
      • The vscode extension will prompt you to download the server.
      • Other IDEs will have to have the LS installed via cargo install.
    • feat(*): add configuration options
    • feat(server, #6): diagnostic for unused rules
    • feat(server, #7): show rule docs (///) on hover
    • fix(server, #8): solve issue relating to 0 vs 1 indexing causing diagnostics to occur at the wrong locations
    • feat(server): add a version checker
    • feat(readme, #2): update readme and add demo gif
    • feat(ci, #4): automatically populate changelog
    • fix(ci): lint all rust code
    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Mar 6, 2023)

  • v0.1.1(Mar 5, 2023)

Owner
pest
The Elegant Parser
pest
Rust for Visual Studio Code

Hello everyone. I'm a maintainer and I'm very busy. At some point rls-vscode will supersede the extension. Until that moment someone should maintain t

null 482 Dec 17, 2022
Visual Studio extension for Rust

Visual Studio extension for Rust Currently in development, and not feature complete. Stable versions are available on the Visual Studio extension gall

PistonDevelopers 697 Dec 18, 2022
Rust extension for Visual Studio 2017 with RLS support

Rust support for Visual Studio 2017 Preview Adds language support for Rust to Visual Studio 2017. Supports: code completion goto definition find all r

Zoey Riordan 111 Aug 4, 2022
Language Server Protocol (LSP) support for vim and neovim.

For legacy python implementation, see branch master. LanguageClient-neovim Language Server Protocol support for vim and neovim. More recordings at Upd

Junfeng Li 3.5k Dec 29, 2022
Flowistry: Powerful IDE Tools for Rust

Flowistry - a VSCode extension that helps you understand Rust programs with program analysis.

Will Crichton 1.4k Dec 29, 2022
Rust IDE support for Atom, powered by the Rust Language Server (RLS)

IDE-Rust Rust language support for Atom-IDE, powered by rust-analyzer. Features Auto-completion Diagnostics (errors and warnings from rustc) Document

The Rust Programming Language 239 Dec 14, 2022
RustDT is an Eclipse based IDE for the Rust programming language:

Project website: http://rustdt.github.io/ As of 2017, RustDT is no longer actively maintained, see this blog post for more information. If you are int

null 351 Aug 20, 2022
AIDL Language Server Protocol (LSP) server

AIDL Language Server Protocol (LSP) server Experimental AIDL LSP server based on rust-aidl-parser. Features: diagnostics workspace symbols (Ctrl+T in

Benoit Walter 0 Jan 9, 2022
A LSP (Language Server Protocol) server for OpenSCAD.

openscad-LSP A LSP (Language Server Protocol) server for OpenSCAD. inspired by dzhu/openscad-language-server Tested with VSCode on Mac and Windows. Te

Leathong 20 Dec 15, 2022
impl LSP (Language Server Protocol) Server for librime

rime-ls 为 rime 输入法核心库 librime (的部分功能) 实现 LSP 协议, 从而通过编辑器的代码补全功能输入汉字. 项目还处在早期阶段, 各方面都非常不成熟. 目标是提供 rime + LSP 的通用解决方案, 在不同编辑器内实现与其他 rime 前端类似的输入体验. Feat

zilch40 55 Jan 22, 2023
Apprentice-vscode - a port of @romainl’s excellent Apprentice Vim colour scheme to VS Code

Apprentice for VS Code apprentice-vscode is a port of @romainl’s excellent Apprentice Vim colour scheme to VS Code. The theme is available in two vari

Luna Razzaghipour 6 Dec 21, 2022
Eclipse Corrosion - Rust edition in Eclipse IDE

Eclipse Corrosion Rust edition and debug in Eclipse IDE Corrosion is a Rust development plugin for the Eclipse IDE, providing a rich edition experienc

Eclipse Foundation 194 Dec 23, 2022
Rust IDE

This branch contains the development of a "new ride" that maintain a small impact on the ui library. This is for a few reasons. Can customize the colo

Gustav Jansson 171 Dec 24, 2022
An IDE for Rust

Introduction SolidOak is a simple IDE for Rust. See the website for binary releases. It has the following features: An embedded copy of Neovim as its

Zach Oakes 907 Dec 29, 2022
Vim-fork focused on extensibility and usability

Documentation | Chat | Twitter Neovim is a project that seeks to aggressively refactor Vim in order to: Simplify maintenance and encourage contributio

Neovim 61k Jan 2, 2023
Kakoune Language Server Protocol Client

Kakoune Language Server Protocol Client kak-lsp is a Language Server Protocol client for Kakoune implemented in Rust. Installation Note kak-lsp.toml d

null 495 Dec 17, 2022
Fennel language server protocol (LSP) support.

fennel-language-server Fennel language server protocol (LSP) support. fennel-language-server is currently in a very early stage and unreliable. Use it

null 68 Dec 27, 2022
WIP: Asynchronous Language Server Protocol framework

async-lsp Asynchronous Language Server Protocol (LSP) framework based on tower. ⚠️ This project serves as a proof-of-concept for LSP with middlewares

null 9 Apr 11, 2023
Vim configuration for Rust.

rust.vim Description This is a Vim plugin that provides Rust file detection, syntax highlighting, formatting, Syntastic integration, and more. It requ

The Rust Programming Language 3.4k Jan 8, 2023