Skip to content

nikhgupta/vimrcg

Repository files navigation

VimRCG [VimRC Generator]

VimRCG is an attempt to provide a ready-to-go VIM configuration that can be downloaded via curl, wget, etc.

$ curl http://vimrc.org/api/generate > ~/.vimrc; vim +PlugInstall +q

or, more simply:

$ curl http://vimrc.download > ~/.vimrc; vim +PlugInstall +q

Screenshot

At the moment, the generated Vim configuration is a port of my existing Vim configuration, and may have several quirks and random mappings (maybe?).

The code was written over a weekend - for my brother who was having difficulties with Vim configuration. And, therefore, should be considered to be an alpha/unstable release at the moment. Several things may not work out on the vimrc.org website, or generated config may not work as expected. Although, I have tried to ensure such issues are minimal, expect inconsistencies till the time code for the website, and vim cofig is revisited.

This project hopes that the community will contribute in adapting the generated Vim configuration for general use, so that new users as well as experienced users can get started with VIM in a moment.

API Documentation

GET /generate

Generate VIM configuration with all bells and whistles. Response is plain-text and can be downloaded via curl, wget, etc. to replace ~/.vimrc file.

GET /generate?only=sane_defaults,startup_screen

Generate a VIM configuration comprising of only the topics listed above. Required topics like variables, plugin_manager, etc. are always returned, so as to ensure that the generated VIM config is usable.

GET /generate?exclude=macosx

This endpoint can be used when you want to exclude topics from the generated VIM configuration, e.g. you may not want to include macosx topic in a vim config solely being used on Linux systems. Or, in cases, when you may not want to include a particular feature, like startup_screen.

GET /topics.json

VIM configuration generated by /generate endpoint is broken into several topics. You can grab a list of all such topics via this endpoint. Each topic is accompanied with metadata, and sections.

A topic is identified via its name, or via an id. /generate endpoint uses id to place them sequentially in the generated configuration.

A topic is, further, divided into sections. Section, here, is a granular unit of vim config that provides a particular feature to the editor. Sections have a list of features it provides, and the accompanying code.

GET /topics.json?list=1

Return a JSON array of all topic names available.

GET /topics.json?only=sane_defaults,macosx

Return a JSON comprising of only the topics listed above. Required topics likes variables, etc. are not returned unless mentioned explicitely.

GET /topics.json?exclude=sane_defaults,macosx

Return a JSON with all topics excluding the ones listed above. Required topics likes variables, etc. can also be filtered out.

GET /sections.json?only=<key>

INTERNAL API

Return a JSON comprising of specific sections only. The key parameter is calculated in a specific way:

  • Calculate section_id for each section:

      # assuming we want to target 7th section in a topic
      section_id = "%05d" % (topic.index * 100 + 6)
    
  • Join all such section_ids as a CSV string. This is the key parameter.

I am open to any suggestions that eases out requesting particular sections.