sponsor Vim development Vim logo Vim Book Ad

frawor : Vim framework

 script karma  Rating 0/5, Downloaded by 9281  Comments, bugs, improvements  Vim wiki

created by
ZyX
 
script type
utility
 
description
Frawor is a modular vim framework designed to collect some commonly needed
functions.

To start using the only thing you should do is to add

    execute frawor#Setup('0.0', {})

where '0.0' is your plugin version and {} is a dictionary containing plugin
dependencies (the core frawor module is added to dependencies automatically).
There are additional rules you should follow:

1. All script-local functions should be anonymous functions:

        function s:F.somefunc(args)

    In some plugins you may even end with having no non-anonymous function
    definitions.

2. If function cannot be anonymous (because it is is to be used by `sort()`, for
    example), then its name should be added to `s:_functions` list.

3. If you define a command, its name should go to `s:_commands` list, same for
    autocommand groups (`s:_augroups`).

4. All script-local variables whose name starts with `s:_` are reserved and
    should be used only in a way described in documentation.

Advantages
==========

1. Plugin reloading for easier development and updates without vim restart:

        call frawor#Reload('plugin/frawor')

    to reload all plugins (as they all depend on core frawor module).

2. Frawor provides an easier way to mappings customization:

        execute frawor#Setup('0.0', {'@/mappings': '0.0'})
        <...>
        call s:_f.mapgroup.add('Foo',
                \{'bar': {'lhs': 't', 'rhs': ':Bar<CR>'},
                \ 'baz': {'lhs': 'T', 'rhs': s:F.baz}},
            \{'leader': '<leader>', 'silent': 1})
    will define two mappings: `<leader>t` which will call command `:Bar` and
    `<leader>T` which will run `s:F.baz` function. Both mappings are silent. Now
    pretend that you are the user who does not need to run `s:F.baz` and wants to
    launch `:Bar` using `,t`. In this case all he needs is to add the following
    lines to the vimrc:

        let g:frawormap_Foo=','

        let g:frawormap_Foo_bar='t'
        let g:frawormap_Foo_baz=0

    Replacing `','` with `0` here will lead to disabling the whole mapping
    group.

3. Options:

        "plugin/foo.vim:
        execute frawor#Setup('0.0', {'@/options': '0.0'})
        let s:_options={'columns': {'default': 80, 'checker': 'range 0 inf'}}
        <...>
                    let columns=s:_f.getoption('columns')
        <...>

        "vimrc:
        let g:foo_columns=78
        autocmd FileType vim  let b:foo_columns=78
    If you don't want to prefix your options with `foo` (second component after
    runtimepath of a path to your plugin), define `s:_oprefix`. Note the
    `checker` key: it saves you from writing code for checking user input (but
    will instead generate an exception for invalid value).

4. Function argument checks:

        execute frawor#Setup('0.0', {'@/functions': '0.0'})
        let s:formats={'html': ...,
                      'markdown': ...}
        function s:F.checkedfunc(format, columns)
            <...>
        endfunction
        let s:F.checkedfunc=s:_f.wrapfunc({'function': s:F.checkedfunc,
                                          '@FWC': ['key formats  '.
                                          \         'range 0 inf', 'check'],})

    Here you can see FWC decorator which uses FWC-to-vimscript compiler where FWC
    is a name of the domain-specific language written exclusively for frawor.

5. Complicated command-line arguments handling:

        execute frawor#Setup('0.0', {'@/commands': '0.0'})
        let s:formats={'html': ...,
                      'markdown': ...,}
        function s:F.run_foo(options)
            " Here a:options is dictionary containing all prefixed options user
            " have given on the command-line
            let format=a:options.format
            let columns=a:options.columns
            if a:options.beatify
                <...>
            endif
        endfunction
        "                Prefix  default  Description of
        "                         value   the prefix argument
        let s:foo_args='{columns :=(80)   |earg range 0 inf '.
                      '  format          key formats '.
                      '!beatify :=(0)'}'
        " Define a :Foo command
        call s:_f.command.add('Foo', {'function': s:F.run_foo,
                                     \    '@FWC': [s:foo_args, 'filter'],}
                             \{'complete': [s:foo_args], 'nargs': '+'})
        " " Example usage:
        " Foo col 78 f markdown
        " Foo nobeatify f html
        " Foo format html beatify c 78

    Note that while command accepts short versions of prefixes, `s:F.run_foo`
    function will get dictionary with only full names.

6. Portable versions of OS-specific functions: vimscript implementation of some
    functions from python os module.

7. Vimscript base64 encoder/decoder, fancy table echoing, maparg that returns
    dictionary for old vim's and more.

Project page: https://bitbucket.org/ZyX_I/frawor
Documentation: http://vimpluginloader.sourceforge.net/doc/frawor.txt.html
 
install details
Plugin can be installed using vim-addon-manager (script #2905).
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
frawor-0.2.4.tar.xz 0.2.4 2023-01-11 7.3 ZyX Make frawor work with newer Vim versions
frawor-0.2.3.tar.gz 0.2.3 2013-09-29 7.3 ZyX Add a workaround for the vim bug described in https://groups.google.com/forum/#!topic/vim_dev/1M7UMk-E1to
frawor-0.2.2.tar.gz 0.2.2 2013-09-21 7.3 ZyX Added frawor-od-override [1]

[1] http://vimpluginloader.sourceforge.net/doc/frawor.txt.html#frawor-od-override>
frawor-0.2.1.tar.gz 0.2.1 2013-02-09 7.3 ZyX Made loading of command dictionary functions (it and completion) more lazy
Added “usedictcompsplitfunc” command option
frawor-0.2.tar.gz 0.2 2013-02-08 7.3 ZyX Removed double loading functionality. It is assumed now that you split files into plugin/ with interface and autoload/ with everything else
Moved almost everything from plugin/ to autoload/
Improved @/python: it now supports case “both pythons are present”. Python3 modules are loaded from python3/, python2 from python/; removed s:_r.py resource
Made @/signs and @/commands features not be ignoredeps ones
Added function autoloading support: "function" key value may be 3-tuple [{plid}, {plver}, {funcname}], {funcname} is pulled from s:_aufunctions dictionary
frawor-0.1.24.tar.gz 0.1.24 2012-09-23 7.3 ZyX Added some code minimization possibilities to @/fwc/constructor
frawor-0.1.23.tar.gz 0.1.23 2012-09-15 7.3 ZyX @/fwc/constructor refactoring and documenting: it can now be used outside of FWC
@/fwc/*: Added support for numbers in place of variables: now “1” no longer refers to “s:1”
frawor-0.1.22.tar.gz 0.1.22 2012-02-22 7.3 ZyX Optimization and minor bug fixes
frawor-0.1.21.tar.gz 0.1.21 2012-02-21 7.3 ZyX Added require core feature
Added s:_loading variable
frawor-0.1.20.tar.gz 0.1.20 2012-02-19 7.3 ZyX Added os.readsystem() function
Made os.run also accept plain strings as the first
frawor-0.1.19.tar.gz 0.1.19 2012-02-18 7.3 ZyX Made plugin/frawor/base64 use built-in and() and or() functions if they are available
Refactored plugin/frawor/fwc/constructor
frawor-0.1.18.tar.gz 0.1.18 2011-11-15 7.3 ZyX Fixed FraworLoad({expandable_plid})
frawor-0.1.16.tar.gz 0.1.16 2011-11-08 7.3 ZyX Fixed os.path.abspath and os.path.exists under windows
frawor-0.1.15.tar.gz 0.1.15 2011-11-08 7.3 ZyX Made `isfunc' be also a filter
Large perfomance improvements, fixed plugin reloading
Various completion fixes
frawor-0.1.14.tar.gz 0.1.14 2011-08-23 7.3 ZyX Fixed behavior of the plugin when &wildignore is "*"
frawor-0.1.13.tar.gz 0.1.13 2011-08-20 7.2.242 ZyX Various compatibility improvements (now works on vim-7.2.242)
@/decorators/altervars: Added `folds' special setter
@/fwc: Made `range' check be aware of -onlystrings option, various fixes
frawor-0.1.11.tar.gz 0.1.11 2011-07-20 7.3 ZyX @/os: Made relpath be aware of paths with trailing path separators
frawor-0.1.10.tar.gz 0.1.10 2011-07-20 7.3 ZyX @/os: Added os.path.relpath function
      Made abspath also work for paths like a/b/c where a/ does not exist
      Made os.path.normpath also simplify its argument
frawor-0.1.9.tar.gz 0.1.9 2011-07-20 7.3 ZyX @/os: Added os.path.relpath function
      Made abspath also work for paths like a/b/c where a/ does not exist
      Made os.path.normpath also simplify its argument
frawor-0.1.8.tar.gz 0.1.8 2011-07-17 7.3 ZyX Improved `path pipe and completion\nMade unmap handle «... does not exist» error
frawor-0.1.7.tar.gz 0.1.7 2011-06-26 7.3 ZyX @/table: Improved stdisplaywidth emulation
@/fwc/compiler: Fixed `cur arguments inside {optional} section
frawor-0.1.6.tar.gz 0.1.6 2011-06-25 7.3 ZyX Fixed completion and checker for +history altervars special
frawor-0.1.5.tar.gz 0.1.5 2011-06-24 7.3 ZyX @/fwc changes:
- Added `idof check\n- Fixed `either' key: checks in alternatives were effectively ignored
frawor-0.1.4.tar.gz 0.1.4 2011-06-22 7.3 ZyX Added @/history module
frawor-0.1.3.tar.gz 0.1.3 2011-06-22 7.3 ZyX @/mappings: Added possibility to specify functions in `strfunc and `func' keys (required for plugin autoloading)\n@/table: Posted strdisplaywidth function (relevant for old vims, for newer ones it is just a reference to built-in strdisplaywidth)
frawor-0.1.tar.gz 0.1 2011-06-19 7.3 ZyX Initial upload
ip used for rating: 216.73.216.130

Questions about Vim should go to the maillist. Help Uganda.     Vim at Github