Code Monkey home page Code Monkey logo

vim-scavenger's Introduction

scavenger.vim

This plugin will eat your dead configurations and convert them into digestible resources...

The biology of the process is really quite simple: instead of having all of your options set in the same tumid and mutated, poor .vimrc file, you would create a resource file in: your project folder, in a folder that holds all of your code, in a folder that holds other stuff that you edit with vim, or in subfolders of that, if you'd like.

It traverses up the tree, starting from the current file's directory and sources each file that matches a pattern. It does so in the order of outer to inner, so as to shadow more general files with the more immediate ones.

Questions

Wouldn't you get confused as to where you keep all your options?

-- Unlikely. There is a handy window that will popup on command to let you quickly view and edit any resource files that apply to the currently edited one.

Isn't there another project that does the same thing?

-- I don't know, which is why I made this one, but please send me its name so I can post it here.

Can you add a feature I would like to see?

-- It's possible. Please create an issue, and we can discuss it.

Installation

Pathogen and most vim package managers should work.

Usage

Just place files that match your defined pattern somewhere within or up the path from any file you wish them to apply to.

Will do the thing. It is by default set up to run on BufEnter autocmd. Of course, it will not apply a resource file to itself:

:Scavenge 

Will show a quick popup window with all the matched resource files currently in and up the path:

:ScaFiles 

Options

Below are the options that you can put in your .vimrc to overwrite the defaults shown here, after the equals sign.

A list of glob file patterns which will be searched for:

let g:scavenger_patterns = ['project.vim', 'rc.vim']

The list above will then be filtered through the below list of regular expressions:

let g:scavenger_exclude = []

The g:scavenger_map is a hash of which the key is a comma-separated list of patterns to match the file to be edited, and the value an array of glob patterns to be used in addition to the g:scavenger_patterns. The latter having been described above, here is the syntax for the keys:

  • Files can be included by either an extension or the filetype
  • Files can be excluded the same way by prefixing a bang (!) to one of the above
  • If there is no extension, as in a shell script, the parser will understand an empty pattern
  • \* Matches all types, and is compatible with !.
  • Items to the right shadow those stated previously.

Example:

let g:scavenger_map = {
    \'sh,pl,!' : '*shell.vim' " example: would include files "test.sh", "test.pl", but not "test"
    \'vim,!vim,vim' : 'vim.vim' " example: would apply any vim.vim found in tree to test.vim
    \'*' : 'myrc.vim' " would apply any myrc.vim to any file edited
    \}

If set to 1 the autocmd for :Scavenge will not be defined, leaving you to customize this behavior at your own discretion:

g:scavenger_manual_only = 0

Scavenger will by default pick up filetype files in your $HOME/.vim/ftplugin folder, but you can disable this behaviour by specifying

let g:scavenger_ft = 0

Key Mappings

There are none. Feel free to assign what works best for you--that's the scavenger way.

To Do

  • Create a help file

License

The MIT License (MIT)

Copyright (c) 2013 github.com/bijoutrouvaille

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

vim-scavenger's People

Contributors

bijoutrouvaille avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

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.