newLISP language support for Visual Studio Code

Started by fdb, June 01, 2019, 01:53:03 PM

Previous topic - Next topic

fdb

I've made a GitHub repository with language support for newLISP in Visual Studio code: https://github.com/luxint/vscode-newlisp">//https://github.com/luxint/vscode-newlisp.



If you don't now VS Code have a look at https://code.visualstudio.com">//https://code.visualstudio.com,  a very nice free editor, built on open source,  from Microsoft, runs on Windows, Mac and Linux.



Current state of the extension is it does newLISP syntax highlighting, launching a newLISP REPL and evaluating the active file in the REPL. What I want to add is several color theme's and snippets (to show function syntax and explanations when 'hovering').



This is how it looks with theme Monokai: https://github.com/luxint/vscode-newlisp/blob/master/images/Screenshot%202019-06-01%20at%2022.18.57.png">//https://github.com/luxint/vscode-newlisp/blob/master/images/Screenshot%202019-06-01%20at%2022.18.57.png



Blue: the 'meta' functions (define, define-macro, macro, fn, lambda, lambda-macro)

Red: mutable primitive functions (set, push, ..)

Green: non-mutable primitive functions (list, array, append, ..)

Purple: numbers (integers, floats, bigints, ..)

Yellow: strings

Grey: quoted literals and comments

White: the rest



If you want to collaborate,  need different colors or have ideas how to make this better, let me know!

rickyboy

#1
Nice!



I would collab but I don't use VS Code (nor linux, nor windows, nor mac). :)



(However, I just sent a PR on your other gh project.)  Best, --Rick
(λx. x x) (λx. x x)

cameyo

#2
Thanks fdb!!!

I use notepad++, but i'd like to use VSCode on mac :-)

I'll try it as soon as possible.

It's possible to execute the current line on newLISP REPL?

It's possible to execute the active selection on newLISP REPL?

Thanks again.

cameyo

fdb

#3
Hi cameyo,



I had added the possibility to execute the active selection in the REPL but had problems getting it to work reliable so I chose to first release without it. My way of working is that I usually test my one liners in the repl first, for multi line functions I enter them in the editor, save them with cmd-S and then load them in the repl with alt-L.



Let me know if everything works ok for you.



Ferry

cameyo

#4
Hi fdb,

with notepad++ i never write text on REPL.

Left Shift + Enter -> Evaluate current line

Rigth Shift + Enter -> Evaluate current selection

Alt + F1 Open local newlisp help for selected keyword.

cameyo

fdb

#5
Hi,



I've added the ability to evaluate selected expression(s), it will either send the current selection to the REPL or, if nothing is selected, it will select the 'first' expression within the cursor position to the REPL. This 'first expression' starts 1 position left to cursor if this is a opening bracket, otherwise the next opening bracket to the right and then finds the matching closing bracket. (This seems to be the behaviour of the editor.action.selectToBracket  command of the VS Code editor and the easiest way to implement selections).



Only single new lines within the expression are supported, let me know if it works, only tried this at my MacBook

cameyo

#6
I have tried the extension on windows.

The syntax highlighting is nice.

The command 'alt+z' and 'alt+l' don't work on my system.

The errors are: "Command 'newlisp.eval' not found" and "Command 'newlisp.evalFile' not found"

(see image: https://imgur.com/a/w3QBMws">//https://imgur.com/a/w3QBMws)

To eval newlisp statements i do the following:

Add these lines to the file "keybindings.json":

(Shift+Enter to run selected text or current line)

(switch editor <--> terminal)
{ "key": "shift+enter",
  "command": "workbench.action.terminal.runSelectedText"}
{ "key": "ctrl+`",
"command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus" },
{ "key": "ctrl+`", "command": "workbench.action.terminal.focus", "when": "!terminalFocus" },

Now, open Terminal and run newlisp.exe:
(+ 1 2 3)
(define (sum a b)
    (add a b))
(sum 2 3)

cameyo

fdb

#7
Hi cameyo,



The keybindings are in the package.json file, have you tried reloading: view/command palette/developer:reload window? If you have customised keybindings (with keybindings.json) you may have keybinding conflicts.

cameyo

#8
Hi fdb,

I have installed VS Code and your extension in a new PC.

'Alt+L' and 'Alt+Z' don't work in my system.

I'll try it on Mac this weekend.

Thanks for your work

cameyo

protozen

#9
This is great to see, I'll check it out, thank you.