Git Product home page Git Product logo

idris-vscode's Introduction

idris-vscode

Which Extension Should I Use?

This extension wraps the Idris IDE Protocol, which is built in to the Idris compiler. There is also https://github.com/bamboo/idris2-lsp-vscode, which uses the Idris language server.

Use this extension if you are using Idris 1, as the language server only supports Idris 2, or if the language server doesn’t fit your use case for some other reason.

For Idris 2, the language-server based extension provides additional features, such as semantic highlighting. If you are using the latest version of Idris 2, it may provide a better experience.

Installation

Support for Idris, the dependently-typed, functional language.

Installation

The plugin itself can be installed from within VSCode or VSCodium through the Extensions Panel. It should come up if you search for ‘Idris’. The extension id is meraymond.idris-vscode.

You can also download the vsix file from the Releases page on Github, or from the VSCode Marketplace, or from the Open VSX Registry.

You will need Idris or Idris 2 installed separately. If it’s not on your $PATH, you can specify the absolute path to the executable in the config. The extension will not download or install anything on the user’s behalf.

If you want to test local changes to the extension, build it with npm install && npm run watch, then you can launch the local version with Run > Start Debugging inside VS.

Idris 2

Currently the extension will default to v1. If you want it to use Idris 2, change the path in the configuration to your Idris 2 binary, and tick the Idris 2 Mode checkbox.

Only the current version of Idris 2 is supported, which at the moment is 0.6.0. If you experience problems, please make sure you are using the most recent version.

At the moment, some of the IDE commands haven’t been implemented in Idris 2.

Commands

Add Clause

Generate the initial clause for the function definition under the cursor.

Add Missing

Generate pattern matches for any missing clauses for the function definition or case statement under the cursor.

Apropos

Search the documentation for references to a string.

Apropos At Cursor

Search the documentation for references to the word under the cursor.

Browse Namespace

Show all declarations and sub-modules for a given namespace.

Case Split

Split the variable under the cursor into all possible pattern matches.

Documentation For

Show the documentation for a given function.

Documentation At Cursor

Show the documentation for the function under the cursor.

Generate Definition

Generate complete definition for the function definition under the cursor.

Interpret Selection

Interpret the highlighted code and show the result in the editor.

List Metavariables

Show a list of all the holes (metavariables) in the current namespace.

Print Definition

Show the definition for a given function.

Print Definition At Cursor

Show the definition for the function under the cursor.

Make Case

Turn the variable under the cursor into a case statement.

Make Lemma

Create a new function declaration, and use it to solve the hole under the cursor.

Make With

Turn the variable under the cursor into a with statement.

Proof Search

Solve the hole under the cursor.

Version

Show the current version of Idris.

Keybindings

The extension doesn’t set any key-bindings out of the box, but here are some suggested bindings based on the Atom plugin. Just copy them to your User/keybindings.json.

[
  {
    "key": "ctrl+alt+a",
    "command": "idris.addClause",
    "when": "editorLangId == idris && editorTextFocus"
  },
  {
    "key": "ctrl+alt+b",
    "command": "idris.browseNamespace",
    "when": "editorLangId == idris && editorTextFocus"
  },
  {
    "key": "ctrl+alt+c",
    "command": "idris.caseSplit",
    "when": "editorLangId == idris && editorTextFocus"
  },
  {
    "key": "ctrl+alt+d",
    "command": "idris.docsForSelection",
    "when": "editorLangId == idris && editorTextFocus"
  },
  {
    "key": "ctrl+alt+g",
    "command": "idris.generateDef",
    "when": "editorLangId == idris && editorTextFocus"
  },
  {
    "key": "ctrl+alt+i",
    "command": "idris.interpretSelection",
    "when": "editorLangId == idris && editorTextFocus"
  },
  {
    "key": "ctrl+alt+m",
    "command": "idris.makeCase",
    "when": "editorLangId == idris && editorTextFocus"
  },
  {
    "key": "ctrl+alt+l",
    "command": "idris.makeLemma",
    "when": "editorLangId == idris && editorTextFocus"
  },
  {
    "key": "ctrl+alt+w",
    "command": "idris.makeWith",
    "when": "editorLangId == idris && editorTextFocus"
  },
  {
    "key": "ctrl+alt+p",
    "command": "idris.proofSearch",
    "when": "editorLangId == idris && editorTextFocus"
  },
  {
    "key": "ctrl+alt+t",
    "command": "idris.typeAt",
    "when": "editorLangId == idris && editorTextFocus"
  }
]

Literate Idris

The extension should work equally well for literate Idris files. For Idris 1, this only applies to .lidr files. Idris 2 extends this this to embedded code blocks in Markdown, LaTeX and Org-Mode files. However, the extension will only activate automatically for .idr and .lidr files. In order to use it for other file types, it may need be activated manually, with the Idris: Activate Extension command, if you have not previously opened any Idris files.

LaTeX and Org-Mode are not yet implemented, but Markdown support is.

Semantic Highlighting

The apropos, browse namespace, documentation and definition commands use VS’s semantic highlighting API to colourise their output. If you don’t see any highlighting, it’s likely that your theme doesn’t support it yet.

Currently, Idris source files don’t use semantic highlighting. There are a few issues to work out to get it to sync with Idris in a non-terrible way. Also Idris 2 does not yet return the metadata required for semantic highlighting.

About

If you run into any problems, please raise an issue, or raise a PR if you want to.

There is not, nor will there ever be, telemetry in this extension (though that may not apply to VS itself).

Acknowledgments

The syntax files are adapted from vscode-idris’s port of the Atom plugin’s grammars.

License

MIT

idris-vscode's People

Contributors

lsby avatar meraymond2 avatar oshmkufa2010 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

idris-vscode's Issues

Having issue with extension

Hello,
having this erorr on macOS:

[error] Error: Illegal argument: line must be non-negative
at v (/Applications/Visual Studio

Activate extension on language 'idris2' too

Hi,
would it be a problem if you automatically activate the extension on Idris 2 files too?
That means adding

"activationEvents": [
    "onLanguage:idris2",
    "onLanguage:idris",

to package.json.

If you want to, I could generate a pull request for that.

Failing to package vsix file using vsce

Hey, first of all, thank you for this great extension.
It works perfectly for me when running in extension debug mode via VSCode.
However, when trying to create a .vsix file for local installation using vsce, the resulting file is incomplete:

vsce package

Contents of the resulting idris-vscode-0.0.4.vsix:

  • extension.vsixmanifest
  • [Content_Types].xml

If I manually bundle the required files (also tested with webpack) and install the resulting zip/vsix file, it works.

It's perfectly possible that I'm missing something or that the project is not setup yet for bundling or that my local setup is broken. Any pointers would be highly appreciated.

Notification for Idris2 load file behaviour

In Idris2, the file will not load at all while it contains errors. This means that none of the commands will work.

I haven't gotten an answer yet as to whether it's a bug or intended behaviour, but in the meantime, this extension should notify the user that their command won't work until the errors are fixed (at least the error highlighting is working now).

Currently, the load file function doesn't look at errors, because the only way for it to fail in Idris 1 was if the file didn't exist.

How to configure packages?

I am able to compile module with

> idris2 -p contrib Main.idr

but inside of the editor itself, I have an error

image

I attempted to include contrib into the path but it does not help

image

"Idris 2 mode" checkbox is missing

README says,

Currently the extension will default to v1. If you want it to use Idris 2, change the path in the configuration to your Idris 2 binary, and tick the Idris 2 Mode checkbox.

But I see no such checkbox in VSCode. This is what I see:

image

Incidentally, the extension throws an error:

image

with the Idris2 program in question being a simple:

module Main

main : IO ()
main = putStrLn "Hello world!"

RFC: borrow TM grammars to layer under semantic highlighting

Thanks so much for working on this extension.

I am currently using your extension with the syntaxes from vscode-idris, which is working well. I know you have plans for semantic highlighting, but my experience with semantic highlighting has been that it often still needs a regex-based grammar to rely on for operators, punctuation, etc.

Perhaps you are planning to re-implement the regex-based grammars from scratch, but if you're interested in borrowing, the diff can be seen in this commit: dustypomerleau@02ff35d

Failed to load file.

sorry not Idris2.

Hi.
I was following the TDD idris book (10.3.3 TestStore.idr) in AMD fx8300 windows 10 visual studio code. However, I saw 'Failed to load file'. Is there any way? (In Atom and other extensions it works.)

`idris.caseSplit` and `idris.proofSearch` don't work after an `idris.addClause`

I don't know the exact steps that cause this, but I can reproduce this consistently by:

  1. Creating and saving a new test.idr file with the following content:
import Data.Vect

vectZip : Vect n a -> Vect n b -> Vect n (a, b)
  1. Using idris.addClause on vectZip, generating a clause vectZip xs ys = ?vectZip_rhs;
  2. Trying to run idris.caseSplit on xs or ys or trying to run idris.proofSearch on ?vectZip_rhs.

When I try to case-split, I get the message "xs cannot be case-split.", even though it obviously can. Saving, closing and reopening the file makes case splitting work as expected.

From step 3, when I try a proof-search I see a message "Solving for ?vectZip_rhs..." followed by a notification "Cannot call write after a stream was destroyed". After this no other command works and reopening the file doesn't help - a VS Code restart is needed.

Idris 2 0.3.0 support

0.3.0 has just been released, so this issue is a reminder to check what's changed and make sure nothing is broken.

Add support for addClause and other commands on unsaved files

If I create a new file, set the language to Idris, add the following content:

import Data.Vect

vectZip : Vect n a -> Vect n b -> Vect n (a, b)

And try to run idris.addClause on vectZip, it gets filled with:

import Data.Vect

vectZip : Vect n a -> Vect n b -> Vect n (a, b)
: openFile: does not exist (No such file or directory)

The same thing happens with idris.proofSearch and probably other commands.

Could not start Idris process

I'm setting up on a new machine.

I am running VS Code in Windows 10, and Idris2 via MSYS2. I am using the latest 0.3.0 master for Idris2 as of filing this bug.

I do have Idris2 Mode checked.

From cmd running C:\msys64\home\HillerupJ.idris2\bin\idris2 starts up the Idris2 repl just fine. I've also tried C:\msys64\home\HillerupJ.idris2\bin\idris2.cmd, same thing.

Error message is Could not start Idris process with: C:\msys64\home\HillerupJ.idris2\bin\idris2

Syntax highlighting sometimes fails

In some files syntax highlighting fails, even in a well defined file

For example

sendRequest : LinearIO io =>
       (1 _ : Socket Open) ->
       (msg : Request) ->
       L io {use=1} (Res Bool (\res => Socket (case res of
                                                    False => Closed
                                                    True => Open)))
sendRequest soc req = send soc (buildRequest req)

fails to highlight properly after the case expression.

Edit:
I believe this may be a problem with brackets in types where the start and end are on different lines, as when I replace the brackets with $s it highlights correctly.

ERR_STREAM_DESTROYED when trying to run command `idris.addClause`

System

(Click to expand)
$ uname -a
Linux a 5.10.25_1 #1 SMP 1616262869 x86_64 GNU/Linux
$ code-oss --version
Warning: 'app' is not in the list of known options, but still passed to Electron/Chromium.
1.54.3
Unknown commit
x64
$ code-oss --list-extensions --show-versions | rg idris
Warning: 'app' is not in the list of known options, but still passed to Electron/Chromium.
[email protected]
$ idris2 --version
Idris 2, version 0.3.0
$ which idris2
/home/a/.idris2/bin/idris2
$ cat "/home/a/.config/Code - OSS/User/settings.json" | rg idris
	"idris.idrisPath": "/home/a/.idris2/bin/idris2",
	"idris.idris2Mode": true,

Reproduction

(Click to expand)
  • In a terminal, run:
mkdir -p ~/tmp
printf 'foo : Bool -> Bool' > ~/tmp/Main.idr
code-oss ~/tmp/Main.idr
  • In the editor, navigate cursor to foo.
  • Input Ctrl-e.
  • Input >idris.addClause.

Expected behaviour

(Click to expand)
  • Buffer now contains something similar to:
foo : Bool -> Bool
foo x = ?foo_rhs
  • Log (Extension Host) has no errors related to this extension.

Actual behaviour

(Click to expand)
  • Buffer still only contains:
foo : Bool -> Bool
  • Log (Extension Host) contains:
[2021-03-21 20:54:03.174] [exthost] [error] Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
	at doWrite (_stream_writable.js:431:19)
	at writeOrBuffer (_stream_writable.js:419:5)
	at Socket.Writable.write (_stream_writable.js:309:11)
	at /home/a/.vscode-oss/extensions/meraymond.idris-vscode-0.0.8/node_modules/idris-ide-client/build/client.js:71:24
	at new Promise (<anonymous>)
	at IdrisClient.makeReq (/home/a/.vscode-oss/extensions/meraymond.idris-vscode-0.0.8/node_modules/idris-ide-client/build/client.js:69:16)
	at IdrisClient.loadFile (/home/a/.vscode-oss/extensions/meraymond.idris-vscode-0.0.8/node_modules/idris-ide-client/build/client.js:229:21)
	at /home/a/.vscode-oss/extensions/meraymond.idris-vscode-0.0.8/out/commands.js:279:36
	at Generator.next (<anonymous>)
	at /home/a/.vscode-oss/extensions/meraymond.idris-vscode-0.0.8/out/commands.js:8:71
	at new Promise (<anonymous>)
	at __awaiter (/home/a/.vscode-oss/extensions/meraymond.idris-vscode-0.0.8/out/commands.js:4:12)
	at Object.exports.loadFile (/home/a/.vscode-oss/extensions/meraymond.idris-vscode-0.0.8/out/commands.js:275:42)
	at /home/a/.vscode-oss/extensions/meraymond.idris-vscode-0.0.8/out/commands.js:55:25
	at Generator.next (<anonymous>)
	at fulfilled (/home/a/.vscode-oss/extensions/meraymond.idris-vscode-0.0.8/out/commands.js:5:58)
	at processTicksAndRejections (internal/process/task_queues.js:94:5) idris.addClause

Miscellaneous

(Click to expand)
  • The :ac Idris 2 command seems to work fine:
$ idris2 --client ':ac 1 foo' ~/tmp/Main.idr
foo x = ?foo_rhs

Publish 0.0.14 to Open VSX

osvx is broken and won't let me publish to Open VSX. For now, anyone using VSCodium can download the vsix from here, until I figure out how to work around it.

Hovering over contents of a new takes about one minute

After opening a file in editor, hovering over a function name only sees the message "loading...", it takes about a minute to finally see the type information, and during this time, the chezscheme processing running idris2.so is spinning CPU at 100%.

The same behavior happens regardless of whether the Hover Action is set to "Type Of" or "Type At". However, when the hover action is set to "Type At", hovering over certain locally defined function would trigger the loading issue every time. I have not been able to reproduce the issue on all locally defined functions though.

Environment:
Idris 2, version 0.4.0-f77670814
idris-vscode v.0.0.9

Maybe it's a version mismatch between idris2 and idris-vscode?

show type not working in .lidr file

I'm not seeing any "show type" information in a Foo.lidr with contents

> foo : Integer
> foo = ?fooRhs

when I hover over ?fooRhs. I do see it for the corresponding .idr code.

Feature request: Jump to definition, Ctrl-Click.

It would be super handy to be able to ctrl-click go-to-definition on any identifier, if possible also on operators (since notation in idris2 is very frightening for beginners like me). The hover already works and is useful, but often I am interested in what else is contained in a given module. At least for me, go-to-definition is my Nr 1 feature in any language IDE extension. I'm using idris2.

Thanks for making this extension :)

file path is wrong within workspace with multiple folders

I have the following workspace with two folders:
image

You can add a new folder to the current workspace like this
image

The errors are shown in the "Problems" tab but not in the file editor (no squiggle underlines).
image

Note that the file path is /null/..., which is wrong.

Completions don't work with Idris2

The completions reply from the client isn't correct with Idris 2. I don't have any specific notes in the client repo about that command, but presumably the output has changed, so it no longer works.

Improve formatting on error message display

Error messages have too many new lines. Also VSCode already shows the location so it is not necessary to include the location in the message.

Current:

While
processing
right
hand
side
of imap. Can't
find
an
implementation
for FromString (IFunc (IVect n a) (IVect n b)).

/Users/michaelmesser/Code/Idris2FRP/src/Incremental.idr:76:14--76:17
    |
 76 |     imap f = "q"
    |              ^^^

Ideal:

While processing right hand side of imap.
Can't find an implementation for FromString (IFunc (IVect n a) (IVect n b)).

or

Can't find an implementation for FromString (IFunc (IVect n a) (IVect n b)).

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.