Giter Site home page Giter Site logo

miv's Introduction

miv

CI Status Hackage Release MIT License

Vim plugin manager written in Haskell

The miv is a command line tool for managing Vim plugins with a single YAML configuration file. The motivation of this tool is

  • to generate a Vim plugin loader files in Vim script
    • A plugin manager written in Vim script build script code and evaluates it on editor startup. But the executed commands do not change unless the user's configurations do not change. Instead of building the commands on editor startup, miv generates static plugin loader scripts after plugin installation.
  • to provide a declarative way to manage Vim plugins
    • Various loading triggers, script configurations and loading dependency can be defined.
  • to provide a command line tool which is friendly to interact with other tools
    • You can easily update the Vim plugins in cron schedule or from shell script.

Installation

Homebrew

brew install itchyny/tap/miv

Build with stack

git clone https://github.com/itchyny/miv.git && cd miv && stack install

User guide

  1. Add the miv plugin path to runtimepath in your .vimrc.
  2. Create miv configuration file at ~/.vimrc.yaml. (or ~/.vim/.vimrc.yaml, $XDG_CONFIG_HOME/miv/config.yaml)
  3. Execute miv install.

Example vimrc:

filetype off
if has('vim_starting')
  set rtp^=~/.vim/miv/miv
  " or when you set $XDG_DATA_HOME,
  " set rtp^=$XDG_DATA_HOME/miv/miv
endif
filetype plugin indent on

Example miv configuration file (refer to .vimrc.yaml for how the author configures):

plugin:

  Align:
    command: Align

  itchyny/lightline.vim:
    before: |
      let g:lightline = {
            \   'colorscheme': 'wombat',
            \ }

  itchyny/calendar.vim:
    mapleader: ","
    command: Calendar
    mapping: <Plug>(calendar)
    script: |
      nmap <Leader>z <Plug>(calendar)
    before: |
      let g:calendar_views = [ 'year', 'month', 'day_3', 'clock' ]

  prabirshrestha/vim-lsp:
    before: |
      let g:lsp_async_completion = 1
      let g:lsp_text_edit_enabled = 0
      let g:lsp_signs_enabled = 0
      augroup lsp_install
        autocmd!
        autocmd User lsp_buffer_enabled setlocal omnifunc=lsp#complete
      augroup END

  prabirshrestha/asyncomplete.vim: {}

  prabirshrestha/asyncomplete-lsp.vim:
    dependon: asyncomplete

  prabirshrestha/asyncomplete-buffer.vim:
    dependon: asyncomplete
    after: |
      call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({
          \ 'name': 'buffer',
          \ 'whitelist': ['*'],
          \ 'completor': function('asyncomplete#sources#buffer#completor'),
          \ 'config': {
          \    'max_buffer_size': 100000,
          \  },
          \ }))

  prabirshrestha/asyncomplete-file.vim:
    dependon: asyncomplete
    after: |
      call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
          \ 'name': 'file',
          \ 'whitelist': ['*'],
          \ 'completor': function('asyncomplete#sources#file#completor'),
          \ }))

  mattn/vim-lsp-settings:
    dependon: lsp

  mattn/emmet-vim:
    filetype:
      - html
      - css
    before: |
      let g:user_emmet_settings = { 'indentation' : '  ' }
    after: |
      autocmd FileType html,css imap <buffer> <tab> <plug>(emmet-expand-abbr)

  elzr/vim-json:
    filetype: json

  cespare/vim-toml:
    filetype: toml

  groenewege/vim-less:
    filetype: less

  tpope/vim-haml:
    filetype: haml

  jade.vim:
    filetype: jade

  kana/vim-textobj-user: {}

  kana/vim-textobj-entire:
    dependon: textobj-user
    mapmode:
      - o
      - v
    mapping:
      - <Plug>(textobj-entire-a)
      - <Plug>(textobj-entire-i)
      - ie
      - ae

  kana/vim-textobj-line:
    dependon: textobj-user
    mapmode:
      - o
      - v
    mapping:
      - <Plug>(textobj-line-a)
      - <Plug>(textobj-line-i)
      - il
      - al

before: |
  let g:is_bash = 1
  let g:loaded_2html_plugin = 1
  let g:loaded_rrhelper = 1

after: |
  let g:mapleader = ','

filetype:
  vim: |
    setlocal foldmethod=marker
  css: |
    setlocal iskeyword=37,45,48-57,95,a-z,A-Z,192-255
  make: |
    setlocal noexpandtab
  sh: |
    setlocal iskeyword=36,45,48-57,64,95,a-z,A-Z,192-255

miv subcommands

The miv command has the following subcommands.

command description
install Installs all the plugins.
update Updates the plugins (outdated plugins are skipped).
update! Updates all the plugins.
update [plugins] Updates the specified plugins.
clean Removes unused directories and files.
generate Generates the miv plugin files. (miv install and miv update automatically do this task)
ftdetect Gather ftdetect scripts. (miv install and miv update automatically do this task)
helptags Generates the helptags file. (miv install and miv update automatically do this task)
list Lists all the plugins.
edit Edits the miv config file.
command Lists the subcommands of miv.
path [plugins] Prints the paths of the plugins.
each [commands] Executes the commands each directory of the plugins. For example, you can execute miv each pwd or miv each git gc.
help Shows the help of miv.
version Shows the version of miv.

Commands to execute when you want to

do what command
install a new plugin miv edit, update the configuration file, save, exit the editor and miv install
update the installed plugins but skip outdated plugins miv update
update all the installed plugins miv update!
update specific plugins miv update [plugin1] [plugin2]..
uninstall a plugin miv edit, remove the related configurations, miv generate (and miv clean if you want)
list all the plugins miv list
count the number of plugins miv list | wc -l
change the current working directory to a plugin directory cd "$(miv path [plugin])"
want a help miv help

Plugin configuration

Loading triggers for the plugin

key type description
filetype string | string[] load the plugin on setting the filetype
command string | string[] load the plugin on invoking the command
function string | string[] load the plugin on calling a function matching the value in regex
mapping string | string[] load the plugin on the mapping
mapmode 'n' | 'v' | 'x' | 's' | 'i' | 'c' | 'l' | 'o' | 't' specify the map-modes for the mapping configuration
cmdline ':' | '/' | '?' | '@' the command-line character to load the plugin
insert boolean load the plugin on entering the insert mode for the first time

Configurations for the plugin

key type description
script string script run on startup, specify some configurations or mappings to load the plugin
after string script run after the plugin is loaded
before string script run just before the plugin is loaded
mapleader string the mapleader (<Leader>) for the script

Dependency configurations

key type description
dependon string | string[] plugins on which the plugin depends; they are loaded just before the plugin is loaded
dependedby string | string[] (deprecated in favor of loadafter) plugins loaded just after the plugin is loaded
loadbefore string | string[] indicates lazy loading, the plugin is loaded just before any of the configured plugins
loadafter string | string[] indicates lazy loading, the plugin is loaded just after any of the configured plugins

Other miscellaneous configurations

key type description
enable string enable the plugin when the expression (in Vim script) is truthy
submodule boolean pull the submodules of the repository
build string build shell script to execute after installing and updating
sync boolean skip pulling the repository if the value is false

Author

itchyny (https://github.com/itchyny)

License

This software is released under the MIT License, see LICENSE.

miv's People

Contributors

arubertoson avatar eliza0x avatar itchyny avatar kozo2 avatar lorenzleutgeb 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

miv's Issues

Document target users aka why this instead of X, Y, Z?

There are a few alternatives to this, some old and some new, and in various languages. How does this compare to the rest, i.e. from a users' perspective, which users would want to choose this over the alternatives?

Better explanation of yaml configuration

I just came across miv, I read a reddit post from 2 years ago that you're not interested in making it popular, so I guess it's mostly written by you, for you. I still believe that it would be nice to have some explanation how to write the yaml. Some options I can easily pick up on as they remind me of other managers with lazy evaluation but others are harder, mostly thinking about mapleader, mapping, insert and script.

It might be an effort, but making it a bit more accessible wouldn't hurt!

windows support

C:\Users\kozo2\Documents\GitHub> miv install
Installing: thinca/vim-quickrun
fatal: could not create leading directories of ''C:\Users\kozo2/.vim/miv/quickrun'': Invalid argument
Error:
  thinca/vim-quickrun
C:\Users\kozo2\Documents\GitHub> ls ~/vimfiles


    ディレクトリ: C:\Users\kozo2\vimfiles


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        2014/07/16     16:44        523 .gvimrc.un~
-a---        2014/07/16     16:43       3730 .vimrc.un~
-a---        2014/07/16     16:44         24 gvimrc
-a---        2014/07/16     16:43        115 vimrc


C:\Users\kozo2\Documents\GitHub> ls ~/.vim


    ディレクトリ: C:\Users\kozo2\.vim


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        2014/07/16     22:18            miv


Feature Request: Support non-GitHub repos

Consider the following configuration:

plugin:
  'https://framagit.org/tyreunom/coquille.git': {}

Running miv install will fail as follows:

https://framagit.org/tyreunom/coquille.git: fatal: repository 'https://github.com/https://framagit.org/tyreunom/coquille.git/' not found
Error occured in installing.
Failed plugin:
  https://framagit.org/tyreunom/coquille.git
...

For example, vim-plug supports this.

Error detected while processing ~/.vim/miv/miv/plugin/miv.vim

Hello here. Was using miv for some time with great success, but today I get an error:

~ vim
Error detected while processing /Users/dmtry/.vim/miv/miv/plugin/miv.vim:
line  563:
E492: Not an editor command: filetypeScript:
line  564:
E488: Trailing characters: c:
line  566:
E492: Not an editor command: html: |
line  568:
E492: Not an editor command: css: |
line  571:
E492: Not an editor command: javascript: |
line  573:
E492: Not an editor command: coffee: |
line  575:
E492: Not an editor command: php: |
line  577:
E492: Not an editor command: xml: |
line  579:
  File "<string>", line 1
    : |
    ^
SyntaxError: invalid syntax
:!make :  | tee /var/folders/xd/04rn46yj1nq8wm0vnfwgg6yw0000gp/T/vLkPsNp/0
make: *** No rule to make target `:'.  Stop.

Press ENTER or type command to continue

What it can be?
Thanks for advance.

Quirky use of XDG Base Directories

The XDG Base Directory Specification says:

$XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.

The way that miv handles this is a bit quirky, and IMO in violation of that spec. In case $XDG_CONFIG_HOME is empty, miv should use the default value $HOME/.config and add $HOME/config/miv/config.yaml to the list of files that will be searched. At the moment the IO Nothing returned from lookupEnv is just dropped.

miv/src/Main.hs

Lines 50 to 52 in 603912d

maybeXdgConfig <- lookupEnv "XDG_CONFIG_HOME" <&> fmap ((</>"miv") >>> (</>"config.yaml"))
fmap listToMaybe $ filterM doesFileExist =<< mapM expandHomeDirectory
(maybeToList maybeXdgConfig ++

Similar reasoning applies to the usage of XDG_DATA_HOME.

Workaround

XDG_CONFIG_HOME=$HOME/.config miv ...

miv: Parse error

error message

~/.cabal/bin% ./miv update
miv: Parse error

how to reproduce error

  • vim-jp配付 macvim latest
  • mac os x 10.9.4
  • brewでinstallしたhaskell-platform latest
  • miv commit eeb6dca

.vimrc.yaml

config: {}
plugin:
  Valloric/YouCompleteMe:
    submodule: true
    command:
      - YcmCompleter 

.vim/vimrc

filetype off
if has('vim_starting')
  set rtp^=~/.vim/miv/miv/
endif
filetype plugin indent on

nnoremap ; :
nnoremap : ;

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.