npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-vim

v0.4.2

Published

A JavaScript implementation of the vim text editor

Downloads

28

Readme

#Vim(for Chrome)

Vim for Chrome is a project to bring the vim editor to Google Chrome as an app.

##Commands

The crucial bit, at least with respect to central functionality, is how commands are executed and defined.

To move to insert mode:

vim.exec('i');

To type hello:

vim.exec(['h', 'e', 'l', 'l', 'o']);

Obviously, this provides a simple way to route keystrokes into the application.But it also facilitates creating new commands:

Capital "O" might be defined like:

vim.exec(['k', 'o']);

##Extensibility

The actual extension API is like:

vim.extend({
	'insert': { //name of mode you are extending
		'O': function() {
			vim.exec(['k', 'o']);
		}
	},
	on: { //event-based actions
		'insert': function() { //event fired by vim on switch to insert
			vim.notify('-- INSERT --');
		}
	}
});

A little more dry:

###Extension object:

extensionObject = {
	{
		mode: {
		 	{
			'command': function(value) {
				//run when that command is called in that mode
			},
		...
	},
	on: {
		'eventName': function(subject) { ... };
		...
	}
};
  • mode is a string, but can be any mode.
  • command is a string, BUT will be executed as a regular expression if a literal match is not found. The command function is given the command value in any case.

###What about syntax + highlighting ?

Maybe the question is: how does this structure allow for syntax formatting and highlighting ?

I think that the answer is pretty straightforward : create a listener for the "stroke" event(doesn 't exist), which will get passed the actual line that changed. Check the line for your keywords, then when you find them draw out the element associated with each character and add a class ('function ') if the keyword is 'function ' for later handling by a stylesheet. That seems about as easy/efficient as it could be, though obviously that would then be exposed in a more friendly way.

##Status

Just revisiting this (spring 2013) since starting it last winter. Need to evaluate whether (1) the architecture will actually scale to the needs of vim (hunch: yes) and (2) need to find a better solution for rendering. The backbone paradigm, I think, breaks down with this. We end up with a trillion 'models' for characters when fundamentally we're just trying to map a string of text to the screen with some extra meta information. So that needs some thought, and a rewrite based on those conclusions.