Announce: ECMAScript interface for Vim

classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Announce: ECMAScript interface for Vim

Bob Pepin
Hi,
This is to announce the release of an ECMAScript scripting interface for Vim.

Why? Because it seemed like the right thing to do.

The longer backstory is that I recently returned to using Vim as a programming editor, when I was left without a computer and it was by far the best editor on the iPad. The last time I used Vim for programming, “fe” still stood for “fileencoding”. I am aware that I missed around 20 years of Vim history and that Vim script is the way it is for good (historical) reasons. I soon discovered that Vim it had added control structures to ex scripts, then lists and dictionaries, then lambdas. It seemed on track to reinvent ECMAScript. Since at the time of writing, ECMAScript is by some measures the most popular programming language in the world, with an excellent free, embeddable and portable implementation (Duktape), it seems by far the best option to use the real thing for future Vim scripting.

Therefore, a Vim fork with a Duktape interface integrated can be found at:

https://github.com/bobpepin/vim/tree/duktape

Note that it is in the duktape branch of the repository.

Steps to compile:
1. Download a source release of Duktape from http://duktape.org and unpack
2. Clone the repository above, checkout the duktape branch
    $ git clone -b duktape https://github.com/bobpepin/vim.git
3. Edit vim/src/Makefile, point CONF_OPT_DUKTAPE_PREFIX to the right directory in the duktape    
    sources
4. Compile Vim as usual

The API is probably best explained by example:
https://github.com/bobpepin/vim/blob/duktape/runtime/indent/python.js.

The python.js file was generated from indent/python.vim using a cross-compiler which can be found at https://github.com/bobpepin/vim2js.

To try it out, in a new buffer do :duk source(‘indent/python.js’) and write some python code. It is also instructive to do vim -O python.vim python.js to get a side-by-side view of the two APIs.

There is also extensive documentation and further examples under :help duktape, or in runtime/doc/if_duk.txt (https://github.com/bobpepin/vim/blob/duktape/runtime/doc/if_duk.txt).

In the hope that somebody finds this useful,

Best,

Bob

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bram Moolenaar

Bob Pepin wrote:

> This is to announce the release of an ECMAScript scripting interface for Vim.
>
> Why? Because it seemed like the right thing to do.

[...]

Interesting.  Javascript is a popular language these days, thus I assume
several users will be interested in this.

I wonder, is this also possible for Typescript?  It's like a better
version of Javascript, and its popularity is growing.

Anyway, I would like to hear whether users would use this.

--
Micro$oft: where do you want to go today?
    Linux: where do you want to go tomorrow?
  FreeBSD: are you guys coming, or what?

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bob Pepin
On 5 Mar 2019, at 12.53, Bram Moolenaar <[hidden email]> wrote:

I wonder, is this also possible for Typescript?  It's like a better
version of Javascript, and its popularity is growing.

Looks nice, especially since it seems to include all the latest versions of ES. It should be possible in principle, since the Typescript compiler is itself compiled to ES5 and has an API for transpiling. It should also be possible to plug in Vim functions for interfacing with the filesystem, something along the lines of https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#customizing-module-resolution.

How well this works in practice remains to be seen, I will try to play around with it a bit.

Best,
Bob

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Salman Halim
In reply to this post by Bram Moolenaar
On Tue, Mar 5, 2019, 06:53 Bram Moolenaar <[hidden email]> wrote:

Bob Pepin wrote:

> This is to announce the release of an ECMAScript scripting interface for Vim.
>
> Why? Because it seemed like the right thing to do.

[...]

Interesting.  Javascript is a popular language these days, thus I assume
several users will be interested in this.

I wonder, is this also possible for Typescript?  It's like a better
version of Javascript, and its popularity is growing.

Anyway, I would like to hear whether users would use this.

I definitely plan to check it out. I use JavaScript professionally and used ActionScript a number of years ago, also, so am definitely interested. 

Salman

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bob Pepin
In reply to this post by Bob Pepin
> On 5 Mar 2019, at 20.15, Bob Pepin <[hidden email]> wrote:
>
> On 5 Mar 2019, at 12.53, Bram Moolenaar <[hidden email]> wrote:
>>
>> I wonder, is this also possible for Typescript?  It's like a better
>> version of Javascript, and its popularity is growing.
>
> How well this works in practice remains to be seen, I will try to play around with it a bit.
>

First results look promising, with the latest vim-duktape git and after downloading typescript.js from https://raw.githubusercontent.com/Microsoft/TypeScript/master/lib/typescript.js and putting it into a runtimepath directory:

Entering Ex mode.  Type "visual" to go to Normal mode.
:duk var ts = require('typescript.js')

:duk var source = 'for(const x of [1, 2, 3]) msg(x)'

:duk var result = ts.transpileModule(source, {})

:duk JSON.stringify(result.outputText)
Duktape result: "for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) {\r\n  
 var x = _a[_i];\r\n    msg(x);\r\n}\r\n"
:duk var fun = compile(result.outputText, "<inline>", {})

:duk fun()
1
2
3

Performance-wise, we are at 500 ms for require(’typescript.js’) and 9 ms for everything else.

I will see if I can integrate the TypeScript module system with Vim sometime this week.

Bob

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bailey Stoner
In reply to this post by Salman Halim
Is this going to be built in a way that lets us adapt it to other VMs? The reliability of software in the JavaScript ecosystem has me a bit worried here, but I guess we could compile plugins written in other languages like Go to asmjs or similar.

As for typescript, it just compiles to us so should just work.

Mar 5, 2019, 1:11 PM by [hidden email]:
On Tue, Mar 5, 2019, 06:53 Bram Moolenaar <[hidden email]> wrote:

Bob Pepin wrote:

> This is to announce the release of an ECMAScript scripting interface for Vim.
>
> Why? Because it seemed like the right thing to do.

[...]

Interesting.  Javascript is a popular language these days, thus I assume
several users will be interested in this.

I wonder, is this also possible for Typescript?  It's like a better
version of Javascript, and its popularity is growing.

Anyway, I would like to hear whether users would use this.

I definitely plan to check it out. I use JavaScript professionally and used ActionScript a number of years ago, also, so am definitely interested. 

Salman


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bailey Stoner
In reply to this post by Bob Pepin
Correction, us=js- sorry!


Mar 5, 2019, 7:47 PM by [hidden email]:
Is this going to be built in a way that lets us adapt it to other VMs? The reliability of software in the JavaScript ecosystem has me a bit worried here, but I guess we could compile plugins written in other languages like Go to asmjs or similar.

As for typescript, it just compiles to us so should just work.

Mar 5, 2019, 1:11 PM by [hidden email]:
On Tue, Mar 5, 2019, 06:53 Bram Moolenaar <[hidden email]> wrote:

Bob Pepin wrote:

> This is to announce the release of an ECMAScript scripting interface for Vim.
>
> Why? Because it seemed like the right thing to do.

[...]

Interesting.  Javascript is a popular language these days, thus I assume
several users will be interested in this.

I wonder, is this also possible for Typescript?  It's like a better
version of Javascript, and its popularity is growing.

Anyway, I would like to hear whether users would use this.

I definitely plan to check it out. I use JavaScript professionally and used ActionScript a number of years ago, also, so am definitely interested. 

Salman


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bob Pepin
In reply to this post by Bob Pepin


> On 6 Mar 2019, at 13.36, Andy Massimino <[hidden email]> wrote:

> What is the performance of duktape like?
>

Parsing typescript.js (~ 7 MB, 121 K lines) into an AST with Esprima takes 14 s on Duktape, versus 0.5 s on Node.js. Impressive performance by Node.js / V8 indeed. Note however that this still corresponds to around 10 000 lines per second for Duktape.

Also, binary sizes:
-r-xr-xr-x  1 bob  staff    28M Mar  6 20:43 /usr/local/bin/node
-rwxr-xr-x  1 bob  staff   330K Feb 11 21:56 ../../duktape-2.3.0/duk

Both with no external dependencies to speak of (Duktape is dynamically linked against system libc, node against libc, libc++ and libicu).

Bob

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bailey Stoner
This should all be negligible, since people will most likely (or at least should) compile the typescript into their plugins. It wouldn't make sense to run the typescript compiler in Vim itself.


Mar 6, 2019, 12:09 PM by [hidden email]:

On 6 Mar 2019, at 13.36, Andy Massimino <[hidden email]> wrote:
What is the performance of duktape like?

Parsing typescript.js (~ 7 MB, 121 K lines) into an AST with Esprima takes 14 s on Duktape, versus 0.5 s on Node.js. Impressive performance by Node.js / V8 indeed. Note however that this still corresponds to around 10 000 lines per second for Duktape.

Also, binary sizes:
-r-xr-xr-x 1 bob staff 28M Mar 6 20:43 /usr/local/bin/node
-rwxr-xr-x 1 bob staff 330K Feb 11 21:56 ../../duktape-2.3.0/duk

Both with no external dependencies to speak of (Duktape is dynamically linked against system libc, node against libc, libc++ and libicu).

Bob

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bailey Stoner
In reply to this post by Bob Pepin
Oh, duktape is a node alternative... My apologies for the confusion.


Mar 6, 2019, 12:14 PM by [hidden email]:
This should all be negligible, since people will most likely (or at least should) compile the typescript into their plugins. It wouldn't make sense to run the typescript compiler in Vim itself.


Mar 6, 2019, 12:09 PM by [hidden email]:

On 6 Mar 2019, at 13.36, Andy Massimino <[hidden email]> wrote:
What is the performance of duktape like?

Parsing typescript.js (~ 7 MB, 121 K lines) into an AST with Esprima takes 14 s on Duktape, versus 0.5 s on Node.js. Impressive performance by Node.js / V8 indeed. Note however that this still corresponds to around 10 000 lines per second for Duktape.

Also, binary sizes:
-r-xr-xr-x 1 bob staff 28M Mar 6 20:43 /usr/local/bin/node
-rwxr-xr-x 1 bob staff 330K Feb 11 21:56 ../../duktape-2.3.0/duk

Both with no external dependencies to speak of (Duktape is dynamically linked against system libc, node against libc, libc++ and libicu).

Bob

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Andrey Butirsky
In reply to this post by Bob Pepin
On Monday, 4 March 2019 15:09:36 UTC+3, Bob Pepin  wrote:
> Hi,
> This is to announce the release of an ECMAScript scripting interface for Vim.
>
> Why? Because it seemed like the right thing to do.
>

Thumbs up for any common language support!
I would love if those languages could be used as much effectively as Vimscript itself for Vim programming.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bob Pepin
> On 28 Mar 2019, at 15.01, Andrey <[hidden email]> wrote:
>
> On Monday, 4 March 2019 15:09:36 UTC+3, Bob Pepin  wrote:
>> Hi,
>> This is to announce the release of an ECMAScript scripting interface for Vim.
>>
>> Why? Because it seemed like the right thing to do.
>>
>
> Thumbs up for any common language support!
> I would love if those languages could be used as much effectively as Vimscript itself for Vim programming.
>

I tried to make all Vim builtins also ES builtins so that simple scripts look almost the same in ES as in Vimscript. Have a look at https://github.com/bobpepin/vim/blob/duktape/runtime/indent/python.js, autogenerated from the corresponding .vim file, https://github.com/bobpepin/vim/blob/duktape/runtime/indent/python.vim.

(Caveat: no datatypes requiring automatic memory management can be passed between Vimscript builtins and ES)

I am playing around with the asyn/await features from recent ES versions together with Vim channels and events (keyboard input/autocmds) right now, imho it’s significantly more effective than Vimscript as soon as callbacks get involved. For a sample JSP implementation, see https://github.com/bobpepin/vim/blob/duktape/src/jsp-jsonrpc.ts.

Best,
Bob

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

John Elliott
Nice work Bob. :) If you are ever in the NYC area we'd love to have you share about integrating Duktape at our little vim meetup.

As a developer using javascript and vim every day, the idea of being able to experiment with JS in vim is quite exciting.

John

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Andrey Butirsky
In reply to this post by Bob Pepin
On 3/30/19 9:54 PM, Bob Pepin wrote:
On 28 Mar 2019, at 15.01, Andrey [hidden email] wrote:

Thumbs up for any common language support!
I would love if those languages could be used as much effectively as Vimscript itself for Vim programming.

I tried to make all Vim builtins also ES builtins so that simple scripts look almost the same in ES as in Vimscript. Have a look at https://github.com/bobpepin/vim/blob/duktape/runtime/indent/python.js, autogenerated from the corresponding .vim file, https://github.com/bobpepin/vim/blob/duktape/runtime/indent/python.vim.

(Caveat: no datatypes requiring automatic memory management can be passed between Vimscript builtins and ES)

I am playing around with the asyn/await features from recent ES versions together with Vim channels and events (keyboard input/autocmds) right now, imho it’s significantly more effective than Vimscript as soon as callbacks get involved. For a sample JSP implementation, see https://github.com/bobpepin/vim/blob/duktape/src/jsp-jsonrpc.ts.

Best,
Bob

Thanks Bob, sounds interesting.

Actually, I'm new to Vimscript and just had to lean it while working on my re-make of StlShowFunc plugin.

Just curious if the plugin could be easily re-writed on ECMAScript also, could you have a look maybe? :)

(e.g., people complained that Python integration is not very elegant, dunno anything about that)

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Tony Mechelynck
On Sat, Mar 30, 2019 at 10:55 PM Andrey Butirsky <[hidden email]> wrote:

>
> On 3/30/19 9:54 PM, Bob Pepin wrote:
>
> On 28 Mar 2019, at 15.01, Andrey <[hidden email]> wrote:
>
> Thumbs up for any common language support!
> I would love if those languages could be used as much effectively as Vimscript itself for Vim programming.
>
> I tried to make all Vim builtins also ES builtins so that simple scripts look almost the same in ES as in Vimscript. Have a look at https://github.com/bobpepin/vim/blob/duktape/runtime/indent/python.js, autogenerated from the corresponding .vim file, https://github.com/bobpepin/vim/blob/duktape/runtime/indent/python.vim.
>
> (Caveat: no datatypes requiring automatic memory management can be passed between Vimscript builtins and ES)
>
> I am playing around with the asyn/await features from recent ES versions together with Vim channels and events (keyboard input/autocmds) right now, imho it’s significantly more effective than Vimscript as soon as callbacks get involved. For a sample JSP implementation, see https://github.com/bobpepin/vim/blob/duktape/src/jsp-jsonrpc.ts.
>
> Best,
> Bob
>
> Thanks Bob, sounds interesting.
>
> Actually, I'm new to Vimscript and just had to lean it while working on my re-make of StlShowFunc plugin.
>
> Just curious if the plugin could be easily re-writed on ECMAScript also, could you have a look maybe? :)
>
> (e.g., people complained that Python integration is not very elegant, dunno anything about that)

Isn't there a chicken-and-egg problem there somewhere? I mean, Vim
cannot understand ECMAScript except by means of the plugin, so if the
plugin itself were written in ECMAScript, Vim couldn't decipher it,
could it?

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

David Demelier
In reply to this post by Bob Pepin
Le 02/03/2019 à 16:42, Bob Pepin a écrit :

> Hi,
> This is to announce the release of an ECMAScript scripting interface for Vim.
>
> Why? Because it seemed like the right thing to do.
>
> The longer backstory is that I recently returned to using Vim as a programming editor, when I was left without a computer and it was by far the best editor on the iPad. The last time I used Vim for programming, “fe” still stood for “fileencoding”. I am aware that I missed around 20 years of Vim history and that Vim script is the way it is for good (historical) reasons. I soon discovered that Vim it had added control structures to ex scripts, then lists and dictionaries, then lambdas. It seemed on track to reinvent ECMAScript. Since at the time of writing, ECMAScript is by some measures the most popular programming language in the world, with an excellent free, embeddable and portable implementation (Duktape), it seems by far the best option to use the real thing for future Vim scripting.
>
> Therefore, a Vim fork with a Duktape interface integrated can be found at:
>
> https://github.com/bobpepin/vim/tree/duktape
>

Thanks, I love and use Duktape myself! Very good choice.

> There is also extensive documentation and further examples under :help duktape, or in runtime/doc/if_duk.txt (https://github.com/bobpepin/vim/blob/duktape/runtime/doc/if_duk.txt).

Given that ECMAScript use camelCase I'd suggest to rename the low level
API. E.g. read_blob -> readBlob.

Regards,

--
David

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bob Pepin
On 1 Apr 2019, at 11.04, David Demelier <[hidden email]> wrote:

Given that ECMAScript use camelCase I'd suggest to rename the low level API. E.g. read_blob -> readBlob.

In this case read_blob is a low-level API that directly mirrors the corresponding C function in Vim. In general, I think the benefits of being consistent with Vim or VimScript notation trump ES community conventions. Also, we have for example win_screenpos and winbufnr, that would either become winScreenpos and winbufnr or winScreenPos and winBufNr. In the latter case you wouldn’t be able to uniquely map back to vim functions, e.g. for looking things up with :help (although there are only 1 or 2 examples like that, _ is mostly used for namespacing of builtins).

Best,
Bob

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Announce: ECMAScript interface for Vim

Bailey Stoner
Vimscript isn't even consistent in this, as many functions are UpperCamelCase (EG, commands).

I'm concerned that people are going to start pulling in NPM libraries much more often. if Vim's ES6 implementation attempts to stay consistent with Vimscript, then JS libraries and VimScript are going to have feel super cumbersome to jump between.

Code will read messier, as there will be a jumble of different code styles, and it'll ultimately lead to difficulty with linting files. I can not stress too much how important linting and prettifying is for languages like JavaScript.

As for lookups, they can easily check for the camelCase version and look up snake_case if it fails. I'm not sure if it's worth harming the developer experience to avoid a single lookup for an action that is driven by a user-interaction anyway? This would also provide the ability for developers to document their usage and APIs separately, which may improve manual readability for users who don't want all the extra bits.

Instead of maintaining a legacy pattern simply because there's a legacy pattern, sticking with ES6 syntax seems to be more reasonable for the future consistency, readability, reliability, and maintainability of Vim. if Vim is adopting ES6 as a means to embrace a highly familiar language, why would we not also want to embrace the already familiar syntax?


Apr 1, 2019, 12:46 PM by [hidden email]:
On 1 Apr 2019, at 11.04, David Demelier <[hidden email]> wrote:

Given that ECMAScript use camelCase I'd suggest to rename the low level API. E.g. read_blob -> readBlob.

In this case read_blob is a low-level API that directly mirrors the corresponding C function in Vim. In general, I think the benefits of being consistent with Vim or VimScript notation trump ES community conventions. Also, we have for example win_screenpos and winbufnr, that would either become winScreenpos and winbufnr or winScreenPos and winBufNr. In the latter case you wouldn’t be able to uniquely map back to vim functions, e.g. for looking things up with :help (although there are only 1 or 2 examples like that, _ is mostly used for namespacing of builtins).

Best,
Bob


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.