Git Product home page Git Product logo

rakunavigator's Introduction

For those interested in a Perl 5 Language Server, check out https://marketplace.visualstudio.com/items?itemName=bscan.perlnavigator

Raku Navigator

This is a Raku Extension for Visual Studio Code including a Language Server. Currently it provides

  • Definition of Raku language and file associations
  • Icon for Raku files
  • Syntax Highlighting (thanks to https://github.com/Raku/atom-language-perl6)
  • Snippets for simple loops and grammars
  • Language Server providing:
    • Syntax checking and warnings
    • Outline view and breadcrumbs
    • Autocompletion and go-to definition on local variables, grammars, and classes

Install the vscode extension from: https://marketplace.visualstudio.com/items?itemName=bscan.raku-navigator

Gif of Extension in Action

Gif of Raku LSP

Other recommended settings

I also recommend the following vscode settings when using Raku. The word separators are important for highlighting function names that have a hyphen in them, and for variables that include sigils.

"[raku]": {
	"editor.wordSeparators": "`~!#^&*()=+[{]}\\|;:'\",.<>/?",
},

Configuration Settings

  • raku.rakuPath specifies the location of your raku install. Defaults to "raku"
  • raku.includePaths adds locations to the path via a -I command line switch

rakunavigator's People

Contributors

bscan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rakunavigator's Issues

The order of multiple Heredocs might be wrong in syntax

According to the raku docs, this code should work

my ($first, $second) = qq:to/END1/, qq:to/END2/; 
  FIRST
  MULTILINE
  STRING
  END1
   SECOND
   MULTILINE
   STRING
   END2 
say $first;  # OUTPUT: «FIRST␤MULTILINE␤STRING␤»
say $second; # OUTPUT: «SECOND␤MULTILINE␤STRING␤»

while the syntax could only recognize (which could not compile)

my ($first, $second) = qq:to/END1/, qq:to/END2/; 
   SECOND
   MULTILINE
   STRING
   END2 
  FIRST
  MULTILINE
  STRING
  END1
say $first;  # OUTPUT: «FIRST␤MULTILINE␤STRING␤»
say $second; # OUTPUT: «SECOND␤MULTILINE␤STRING␤»

Only Parse Raku Code Once Instead of Twice

To syntax check a file, navigator.raku parses the code with nqp and also compiles it. I need the parsed output because of the is helpful for identifying the end of subs and class declaration. However, compilation is also important because of additional checks that happen in the optimize phase (e.g. subroutine signature mismatches). Currently, I am parsing the code twice which is slow and results in use statements being evaluated twice. I would like to update this code to compile only once, while still returning the $parsed code. https://github.com/bscan/RakuNavigator/blob/master/server/src/raku/navigator.raku

Standalone installation instructions

Currently, there is no information on separating the language server from the VSCode extension. For users of other editors, it might be good to provide instructions for installing the server outside of VSCode to be used in something like Neovim.

How to configure the Raku paths (for execution)

First -- thank you for working on this project!


After installing the extension I cannot run Raku scripts with it.

I made a few changes in the corresponding "settings.json" as suggested in the README. I still cannot run scripts.

I assume I am configuring the paths in the wrong way.

From README is not clear (exactly) where and how to place these configurations:

raku.rakuPath specifies the location of your raku install. Defaults to "raku"
raku.includePaths adds locations to the path via a -I command line switch

Syntax highlighting in Helix

I've gotten errors to appear but I can't get syntax highlighting to work in Helix. Is there something I'm missing in my languages.toml?

[language-server.rakunavigator]
command = "node"
args = ["/home/dan/Programs/RakuNavigator/server/out/server.js", "--stdio"]

[[language]]
name = "raku"
scope = "source.raku"
file-types = ["raku", "rakudoc"]
comment-tokens = "#"
language-servers = ["rakunavigator"]

Add Compilation Modes Setting

Currently, the raku source is compiled using nqp::getcomp. This could run BEGIN and CHECK blocks, but a regex strips these phasers out. This should ideally be controlled by a setting. Some people may want to run these blocks (e.g. BEGIN block being required to set a path). This would also be the first of multiple compilation "modes" if we identify other methods of parsing.

"Could not find" module error in test file

I'm getting an error that the editor cannot find the lib when in the test file, but prove6 runs correctly.

Here is the folder structure:

├── HELP.md
├── README.md
├── lib
│   └── Pangram.rakumod
└── t
    └── pangram.rakutest

And here's the top of the test file:

use Test;
use lib $?FILE.IO.parent(2).add('lib');
use Pangram;

This is the full error:

    /Users/italo/.vscode/extensions/bscan.raku-navigator-0.3.2/server/src/lib
    /Users/italo/.raku
    /opt/homebrew/Cellar/rakudo-star/2024.02/share/perl6/site
    /opt/homebrew/Cellar/rakudo-star/2024.02/share/perl6/vendor
    /opt/homebrew/Cellar/rakudo-star/2024.02/share/perl6/core
    CompUnit::Repository::AbsolutePath<6136726709184>
    CompUnit::Repository::NQP<6136721594120>
    CompUnit::Repository::Perl5<6136721594160>
raku navigator

This is from Exercism's Pangram exercise: https://exercism.org/tracks/raku/exercises/pangram

I'm running the Raku VS Code extension v0.3.2, Rakudo v2024.02 on macOS 14.2.1 (M1 Pro).

Parse Symbol Table for Imported Functions

The Perl Navigator parses the symbol table to find imported functions, and then gets the file and line number from them. I would like to do something similar for Raku, but parsing the symbol table is not finding the results I need. I use nqp to parse and compile code in https://github.com/bscan/RakuNavigator/blob/master/server/src/raku/navigator.raku and then I would like to dump the symbol table. The following snippet works from within a script, but I would like to parse the symbol table from the $compiled code instead. Pull requests are more than welcome.

for ::.kv -> $k, $v {
    if ($k.starts-with('&')) {
         print $k, $v.signature.gist(), $v.file, $v.line;
    }
}

False positive errors?

I have a raku module installed:

zef list --installed | grep ^BDD                                                                                                                                                       ─╯
===> Found via /Users/gd/rakudo/share/perl6/site
===> Found via /Users/gd/rakudo/share/perl6/core
BDD::Behave:ver<0.0.4>:auth<github:gdonald>

And I'm getting this error:

Screen Shot 2022-06-05 at 4 14 04 PM

My code works, but vscode thinks it's broken.

Further down when I use the module like this:

Screen Shot 2022-06-05 at 4 25 56 PM

It gives me this weird error I do not get when I run my code. This code is supported by a Raku Grammer, so that may be related:

Screen Shot 2022-06-05 at 4 23 37 PM

Again, works fine when I run it, just that vscode thinks it's broken and underlines it with red.

Import Regex and String Highlighting from Atom

The Raku syntax highlighting is currently taken from the Atom extension here: https://github.com/Raku/atom-language-perl6/. This is also the syntax that powers Github, so is an important repo. Currently, I've only ported the core syntax and not the regex syntax or quoting files. For example, see the following highlighting in github. Vscode does not highlight \d. I assume this would be straightforward to incorporate.

$foo ~~ /Foo\d+bar/;

Add a few example Raku files for testing

This doesn't necessarily mean a formal automated test suite (although that would be great too). Primarily we need a few Raku files to exercise the full set of features, especially around the different types of errors and warnings that the Raku compiler can generate, and the types of constructs that the Raku tagger is looking for.

Syntax: Redeclaration of symbol '…'.

I get these messages from the syntax check while there is no duplication of the particular symbol. In this case, it trips over the line

unit class QA::Gui::InputWidget:auth<github:MARTIMM>;

It has the same problems with other modules in the same project when using unit. I've tried to rephrase this declaration

class QA::Gui::InputWidget:auth<github:MARTIMM> does QA::Gui::Frame {

having a different error

Syntax: QA::Gui::Frame is not composable, so QA::Gui::InputWidget cannot compose it

This class was declared like a class instead of a role. However, the error was still there after the change.

Note also that raku didn't have any trouble compiling the code.

Syntax: Unrecognized character name [ENTER MARK]

Thanks for building this!

The following code:

say "\c[CHECK MARK]";

results in an error:

Syntax: Unrecognized character name [ENTER MARK]
raku navigator

CHECK and ENTER are both phasers, so maybe that's where it gets confused?

`raku.includePaths` doesn't seem to work

In my settings.json I have added the full path to my lib directory in my Raku module:

"raku.includePaths": [
    "/Users/gd/workspace/raku/Console-Blackjack/lib"
]

But my code does not then find anything in my lib directory:

Screen Shot 2022-06-02 at 7 03 43 PM

The path I defined in settings.json doesn't appear in the list of paths it's searching. Any idea? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.