Page 1 of 1

newLISP language support for Visual Studio Code

PostPosted: Sat Jun 01, 2019 8:53 pm
by fdb
I've made a GitHub repository with language support for newLISP in Visual Studio code: https://github.com/luxint/vscode-newlisp.

If you don't now VS Code have a look at 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

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!

Re: newLISP language support for Visual Studio Code

PostPosted: Sat Jun 01, 2019 11:37 pm
by rickyboy
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

Re: newLISP language support for Visual Studio Code

PostPosted: Sun Jun 02, 2019 11:12 am
by cameyo
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

Re: newLISP language support for Visual Studio Code

PostPosted: Sun Jun 02, 2019 12:12 pm
by fdb
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

Re: newLISP language support for Visual Studio Code

PostPosted: Sun Jun 02, 2019 2:02 pm
by cameyo
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

Re: newLISP language support for Visual Studio Code

PostPosted: Mon Jun 03, 2019 10:46 pm
by fdb
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

Re: newLISP language support for Visual Studio Code

PostPosted: Thu Jun 06, 2019 7:04 pm
by cameyo
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)
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)
Code: Select all
{ "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:
Code: Select all
(+ 1 2 3)
(define (sum a b)
    (add a b))
(sum 2 3)

cameyo

Re: newLISP language support for Visual Studio Code

PostPosted: Thu Jun 06, 2019 7:51 pm
by fdb
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.

Re: newLISP language support for Visual Studio Code

PostPosted: Fri Jun 07, 2019 9:05 am
by cameyo
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

Re: newLISP language support for Visual Studio Code

PostPosted: Tue Jul 02, 2019 10:25 pm
by protozen
This is great to see, I'll check it out, thank you.