Neovim Client Library for Clojure

Jeb Beich has created a Neovim client library for Clojure: jebberjeb/neovim-client. That means you can use Neovim's inter-process messaging library for scripting Neovim from a Clojure process.

There's a sample plugin that creates a horizontal split and then sets some text in a buffer:

(ns sample-plugin.core
  (:require [neovim-client.nvim :as nvim])
  (:gen-class))

(defn -main
  [& args]
  (nvim/connect!)
  (nvim/hsplit!)
  (let [cur-buf (nvim/get-current-buffer)]
    (nvim/buffer-set-text! cur-buf "Sample plugin was here!")))

You can also open a Clojure REPL and send commands to an instance of Neovim -- see the readme for instructions on how to do this. It might be fun to combine this with Neovim's built-in terminal emulator.

Read More →

Vison: JSON Schema Completion

Vison (GitHub: Quramy/vison) by Yosuke Kurami is a plugin for writing JSON schema files. It handles completion for keys and values, and works with downloadable JSON schemas that are intended to be used for auto-completion.

Vison

The completion menu includes type hints and shows what values are optional, so it will make writing JSON files much easier. This is ideal if you frequently write things like package.json files.

Read More →

Omni Completion and JavaScript

This week I tried out Visual Studio Code (VSCode), a new editor from Microsoft that has features focused on web development. One of the cool things about it is it brings IntelliSense to JavaScript developers, and it's cross platform as well -- it supports Mac OS X, Linux, and Windows.

IntelliSense is one of those things that works well if you're learning a codebase or API, and work with a strongly typed language. Because languages like C# have detailed type hints, IntelliSense is able to provide a rich completion interface that helps you find the right objects and methods. Visual Studio also encourages code comments, and makes typing Microsoft's XML-style comments quite easy.

JavaScript isn't C#, however, so VSCode has to do some extra magic to dredge up the right type hints. It works by using Microsoft's TypeScript definition files. It's a little bit like ctags -- you effectively have a tags file that maps between names and values to aid completion. Type definition fines are written partly by hand, though, so it's not quite as easy as ctags.

Read More →

PyVim

PyVim (GitHub: jonathanslenders/pyvim) by Jonathan Slenders is a pure Python Vim clone. You can try it out with pip:

pip install pyvim

I installed it on a Mac and it ran fine. Python has some libraries that make a Python Vim clone a worthwhile effort -- PyVim uses Pygments for syntax highlighting, and the author's Prompt Toolkit which is a readline replacement that also supports multi-line editing, completion, Emacs and vi key bindings, and Unicode support. The readme shows PyVim rendering Chinese and Japanese double width characters.

PyVim

Read More →

Yet Another JavaScript Syntax

JavaScript is moving pretty fast, so you might find Vim's built-in syntax lags behind the latest standards and APIs. YAJS: Yet Another JavaScript Syntax by othree is an extended version of jelera/vim-javascript-syntax. It includes support for ES6, web APIs, and DOM keywords.

The ES6 support is extremely good -- it supports features like fat arrow, array comprehensions, and the template strings.

I took a screenshot of YAJS vs. the built in highlighting, and you can see how it handles arrow functions, template strings, and some of the newer keywords:

Read More →

Google Colour Scheme

Primary (GitHub: google/vim-colorscheme-primary) by Lisie Michel at Google is a colour scheme based on Google's branding. The GUI version uses Google's exact colours, while the 256 and 8 colour versions are approximations.

Primary

I usually have a dark terminal, but I noticed Primary looks really nice in the light colour scheme mode. I don't usually write about colour schemes, but this one interested me because it's actually on Google's GitHub repository and looks good in light mode.

Read More →

Column Editing with Tabs

Sometimes you just can't get Excel to do what you want. Given a CSV file and some careful Visual mode blockwise editing, Vim is actually pretty good for editing columns of values.

I had columns of URLs that were separated by tabs that I wanted to edit with Visual-block mode, but I also wanted to wrap each line in quotes and brackets to make a JSON document. This is what the file looked like:

Columns

Read More →

TypeScript with Tsuquyomi

If you're searching for the perfect Vim TypeScript plugin, then there's a new one called Tsuquyomi (GitHub: Quramy/tsuquyomi, License: MIT) by Yosuke Kurami. It uses TSServer, which comes with TypeScript, and provides omni completion, symbol navigation, compiler errors, and identifier renaming. It requires vimproc, which is used for asynchronously executing commands.

Tsuquyomi works with tsconfig.json, so when it runs the TypeScript compiler it'll take your global options into account. It also supports showing outlines of the file using Unite and unite-outline.

For most TypeScript programmers, Tsuquyomi feels like a complete solution. The documentation is pretty good, so as long as you can install TypeScript and vimproc you should be able to get it working.

Read More →

Putting Text in Insert and Replace Mode

One of my colleagues asked me how to paste over text in Vim. There are three steps to this:

  1. Enter the right mode (Replace): R
  2. Invoke the Insert/Replace mode's "insert register contents" command: CTRL-R
  3. Press the key for a register: " for the last delete or yank, or * for the system clipboard

I'd wager that Replace mode is quite underused, and CTRL-R is even less common. If CTRL-R is new to you, the help page is available at :help i_CTRL-R -- notice the preceding i_ for "Insert mode". This is a good command to learn because it means you can paste registers during editing, but you should generally prefer using Normal mode for yank/put because you'll get a more fine grained undo history.

Also, if you're not used to "registers" and are a little scared off by the terminology, just remember that they're only like extra copy and paste buffers and get filled when you perform certain operations. You can worry about what registers really are once you've got used to the basics.

Read More →