lh-dev is a VimL for plugins oriented toward coding. It provides language independent functions that can be used by these plugins. The functions themselves can be specialized on a filetype basis.
I'll first present options that end-user of plugins based on lh-dev may tune, then the API itself for coding plugin authors.
Note: Starting with v2.0.0, naming policies and coding style policies have been extracted to lh-style project.
This part is just a draft for the moment.
Function boundaries can be obtained with lh#dev#find_function_boundaries()
The analysis currently relies on ctags and on |matchit|. The code can be
specialized though (see Inherited filetypes).
Two mappings are also provided to select function boundaries, or to apply operators on function boundaries.
v_if
in strict visual mode (not in select mode)o_if
on operators.
For instance:
vif
selects the current functionyif
|yank|s the current functiondif
|delete|s the current function
This can also be used to define a way to jump to the start/end of the current function in languages such as C++:
" excerpt from [lh-cpp](https://github.com/LucHermitte/lh-cpp).
nnoremap <silent> <buffer> [[ :call lh#dev#_goto_function_begin()<cr>
onoremap <silent> <buffer> [[ :<c-u>call lh#dev#_goto_function_begin()<cr>
nnoremap <silent> <buffer> ][ :call lh#dev#_goto_function_end()<cr>
onoremap <silent> <buffer> ][ :<c-u>call lh#dev#_goto_function_end()<cr>
`lh#dev#import#add()`. See the following templates that exploit it:
VimL:" C++ std::vector<> snippet
VimL: let s:value_start = '¡'
VimL: let s:value_end = s:value_start
VimL: let s:marker_open = '<+'
VimL: let s:marker_close = '+>'
VimL: call s:AddPostExpandCallback('lh#dev#import#add("<vector>")')
std::vector<¡s:Surround(1, '<+type+>')¡> <++>
VimL:" Python os.path.exists() snippet
VimL:" hint: os.path.exists()
VimL: let s:value_start = '¡'
VimL: let s:value_end = s:value_start
VimL: let s:marker_open = '<+'
VimL: let s:marker_close = '+>'
VimL: call s:AddPostExpandCallback('lh#dev#import#add("os", {"symbol": "path"})')
os.path.exists(¡s:Surround(1, '<+type+>')¡)<++>
Most features provided by lh-dev can be specialized according to the filetype, usually of the current file.
Options can be obtained with:
-
lh#ft#option#get(name, filetype [, default [, scopes]])
This returns which ever exists first among:
b:{filetype}_{name}
, org:{filetype}_{name}
, orb:{name}
, org:{name}
.{default}
is returned if none exists. Default value for{default}
isg:lh#option#unset
. -
lh#ft#option#get_postfixed(name, filetype [, default [, scopes]])
This returns which ever exists first among:
b:{name}_{filetype}
, org:{name}_{filetype}
, orb:{name}
, org:{name}
.{default}
is returned if none exists. Default value for{default}
isg:lh#option#unset
.This flavour is more suited to variables like
g:airline#extensions#btw#section
andg:airline#extensions#btw#section_qf
.
- Filetype inheritance is supported.
- The order of the scopes for the variables checked can be specified through the optional argument
{scope}
.
g:{name}
is a global default option for all filetypes best set from a.vimrc
or a pluging:{filetype}_{name}
is a global default option for a specific filetype (and its sub-filetypes) best set from a.vimrc
or a pluginb:{name}
is a local option for all filetypes, best set for a vimrc_local, or possibly a ftplugin.b:{filetype}_{name}
is a local option for a specific filetype (and its sub-filetypes), best set for a vimrc_local, or possibly a ftplugin.
Entry point: lh#dev#{theme}#function()
Default function: lh#dev#{theme}#_function()
Specialized function: lh#dev#{filetype}#{theme}#_function()
lh#dev#option#call(name, filetype [, parameters])
lh#dev#option#pre_load_overrides(name, filetype [, parameters])
lh#dev#option#fast_call(name, filetype [, parameters])
lh#ft#option#inherited_filetypes(filetypes)
- Requirements: Vim 7.+, lh-vim-lib (v4.6.0), lh-tags (v3.0.0)
- Install with vim-addon-manager any plugin that requires lh-dev should be enough.
- With vim-addon-manager, install lh-dev (this is the preferred method because of the dependencies).
ActivateAddons lh-dev
- vim-flavor (which also supports dependencies)
flavor 'LucHermitte/lh-dev'
- Vundle/NeoBundle:
Bundle 'LucHermitte/lh-vim-lib'
Bundle 'LucHermitte/lh-tags'
Bundle 'LucHermitte/lh-dev'
- Clone from the git repositories
git clone git@github.com:LucHermitte/lh-vim-lib.git
git clone git@github.com:LucHermitte/lh-tags.git
git clone git@github.com:LucHermitte/lh-dev.git