newLISP language support for Visual Studio Code

Notices and updates
Post Reply
fdb
Posts: 52
Joined: Sat Nov 09, 2013 8:49 pm

newLISP language support for Visual Studio Code

Post 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-newlis ... .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
Posts: 595
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: newLISP language support for Visual Studio Code

Post 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
(λx. x x) (λx. x x)

cameyo
Posts: 107
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy

Re: newLISP language support for Visual Studio Code

Post 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

fdb
Posts: 52
Joined: Sat Nov 09, 2013 8:49 pm

Re: newLISP language support for Visual Studio Code

Post 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

cameyo
Posts: 107
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy

Re: newLISP language support for Visual Studio Code

Post 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

fdb
Posts: 52
Joined: Sat Nov 09, 2013 8:49 pm

Re: newLISP language support for Visual Studio Code

Post 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

cameyo
Posts: 107
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy

Re: newLISP language support for Visual Studio Code

Post 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

fdb
Posts: 52
Joined: Sat Nov 09, 2013 8:49 pm

Re: newLISP language support for Visual Studio Code

Post 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.

cameyo
Posts: 107
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy

Re: newLISP language support for Visual Studio Code

Post 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

protozen
Posts: 36
Joined: Thu Aug 22, 2013 4:02 am

Re: newLISP language support for Visual Studio Code

Post by protozen »

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

Post Reply