Git Product home page Git Product logo

vim-glaive's Introduction

Glaive is a utility for configuring maktaba plugins. It turns this:

let g:myplugin_enablefeature = 1
let g:myplugin_defaultdir = $HOME
let g:myplugin_weirdmode = 'm'

into this:

Glaive myplugin enablefeature defaultdir=`$HOME` weirdmode='m'

In order for this to work, the plugin must use the maktaba flag API. Any plugin using the flag API can be configured by glaive.

Maktaba is a vimscript library for plugin authors. It handles parsing the setting syntax, looking up the plugins, and applying the settings. Glaive itself is merely a thin wrapper around the hooks that maktaba provides: any plugin can support a similar interface with minimal effort. Plugin manager plugins in particular are encouraged to do so.

For details, see the executable documentation in the vroom/ directory or the helpfiles in the doc/ directory. The helpfiles are also available via :help glaive if Glaive is installed (and helptags have been generated).

Usage example

This example uses Vundle.vim, whose plugin-adding command is Plugin. Note that Vundle does not add plugins to the runtime path until vundle#end(), so Glaive commands must come after this function call.

We will use two plugins for demonstration:

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

...

" Add maktaba, glaive, and codefmt to the runtimepath.
" (Glaive must also be installed before it can be used.)
Plugin 'google/vim-maktaba'
Plugin 'google/vim-glaive'
Plugin 'google/vim-codefmt'

...

vundle#end()
filetype plugin indent on

" Add helloworld to the runtime path. (Normally this would be done with another
" Plugin command, but helloworld doesn't have a repository of its own.)
call maktaba#plugin#Install(maktaba#path#Join([maktaba#Maktaba().location,
    \ 'examples', 'helloworld']))

call glaive#Install()

" Configure helloworld using glaive.
Glaive helloworld plugin[mappings] name='Bram'

" Real world example: configure vim-codefmt
Glaive codefmt google_java_executable='java -jar /path/to/google-java-format.jar'

Now, <Leader>Hh should say Hello, Bram!, and <Leader>Hg should say Goodbye, Bram!. (Recall that <Leader> defaults to \.)

vim-glaive's People

Contributors

artasparks avatar chiphogg avatar dbarnett avatar fowles avatar glts avatar malcolmr avatar omrisarig13 avatar rocketdonkey avatar xanderman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-glaive's Issues

Add custom completion for :Glaive

I suspect you will want to add this sooner or later, might as well have an issue on the issue tracker!

Basic custom completion for a :command is easy to add but tremendously helpful for the user.

:Gl<Tab>
:Glaive 
:Glaive myp<Tab>
:Glaive myplugin 

and perhaps even

:Glaive myplugin som<Tab>
:Glaive myplugin somesetting

More info at :h :command-completion.

Glaive appears not to work in .vimrc

I'm rewriting my plugin to use maktaba, and I want to use Glaive to configure it.

The relevant (I think) parts of my .vimrc:

" Google's vim enhancements
Bundle 'google/glaive'
Bundle 'google/maktaba'

" My productivity system
Bundle 'chiphogg/vim-vtd'

Glaive vim-vtd plugin[mappings]

This fails like so:

Error detected while processing /home/chogg/.vimrc: 
line  331: 
E492: Not an editor command: Glaive vim-vtd plugin[mappings]

Yet, when I run :Glaive vim-vtd plugin[mappings] by hand inside vim, it works just fine. I even verified that it changes the value of the plugin flag from an empty dict to mappings: 1.

Is Glaive not ready by .vimrc-time?

More broadly: how would one enable mappings in a maktaba plugin without Glaive?

Mechanism to query current config

The :Glaive command makes it handy to update flag values, but we currently don't have a user-level interface for checking current flag values (calling functions like :echo maktaba#plugin#Get('someplugin').Flag('someflag') doesn't count as a user-level interface).

Many vim commands like :set, :let, :command, :map, etc. have a no-arg version that spits out the current config. Glaive should adopt a convention like this to let people query/explore their plugin config.

This could entail a :Glaive command to list all flags and their values by plugin, a :Glaive SOMEPLUGIN command to list flags for an individual plugin, and :Glaive SOMEPLUGIN SOMEFLAG to show the current value of an individual flag.

:Glaive doesn't detect newly-added runtimepath entries

If you install and immediately try to configure a plugin with Glaive, it sometimes complains that the plugin doesn't exist. For example:

VAMActivate someplugin
Glaive someplugin plugin[mappings]

shows the error ERROR(NotFound): Plugin someplugin.

Tab completion should only list plugins with flags

Currently, tab completion lists all registered plugin names, even if they don't use maktaba and don't respect maktaba flags. Since pull req google/vim-maktaba#39, this can include plugins that were detected on rtp but weren't explicitly registered, which can bloat Glaive's plugin list with plugins that can't actually be meaningfully configured by Glaive.

We should try to pare down the list of plugins to only include ones that make sense for Glaive. This is a little more complicated than it looks since we can't just check whether a plugin defines flags: most plugins have at least one flag, the plugin[] flag maktaba automatically defines. One approach would be to check PLUGIN.AddonInfo() to see whether the plugin defines a dependency on maktaba, since right now it's not really possible for plugins to query flags without calling maktaba functions.

Glaive feature to trigger plugin activation

It's a common pattern to install a plugin, configure it, install another plugin, configure it, etc. It would be nice to be able to consolidate this down to a single line by configuring :Glaive to hook into your plugin manager somehow so it knows how to trigger plugin activation.

The vim-pi project (vim plugin index, a spinoff of the vim-addon-manager project) maps canonical plugin names to an installation source. This means we can both install and configure the plugin using the same short canonical name. For VAM, it's as simple as telling :Glaive NAME to execute :ActivateAddons NAME if the plugin isn't yet activated. For other plugin managers, it might be more complicated, but should still be possible.

Document tab completion in help file

Glaive has pretty nice tab completion support, but not all users will think to try hitting tab. Also, the trick of FLAGNAME=<Tab> is pretty neat but even less likely for users to find by accident.

We should mention this magic in the vim help file and possibly the README so more users will be able to discover it.

Update guidelines to mention vroom

Now that vroom is released, we should mention in CONTRIBUTING.md that people should run it before submitting and possibly document how in README.md or a vroom/README or something.

Could Glaive syntax be changed to match vim's :set?

@glts asked:

I wonder why you chose to make the notation different from Vim's notation.

:set list             :Glaive plug list
:set nolist     vs    :Glaive plug !list
:set list!      vs    :Glaive plug ~list
:set invlist    vs    :Glaive plug ~list
:set list?      vs    TBD
:set list&      vs    N/A

Is there a technical reason for this? I think acceptance would be better if users could apply the same pattern as in standard :set.

It's kind of painful to change the syntax if it breaks compatibility, but I think it's a fair question and we should investigate the possibility.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.