Just add plugin:
Plug 'seletskiy/vim-pythonx'
- Import required py-modules in snippets files (e.g. in
go.snippets):global !p import go endglobal
setters/getters: https://cloud.githubusercontent.com/assets/8445924/6055706/a64d8f42-acfc-11e4-8c44-1296ddad121f.gif
cycle by var name: https://cloud.githubusercontent.com/assets/8445924/6055740/97ca2092-acfd-11e4-92d4-bd117fcbc5aa.gif
Will get identifier under cursor and either complete it to the full variable name from previous code in file, or substitute identifier with previous variable declaration
In go.snippets:
snippet i "if "
if ${1:`!p snip.rv=go.get_last_var_for_snippet()`} {
${2:${VISUAL}}
}
endsnippet
In .vimrc:
au FileType go inoremap <C-L> <C-\><C-O>:py go.cycle_by_var_name()<CR>
au FileType go smap <C-L> <BS><C-L>i will expand into if with last used variable as condition. Use <C-L> to
select previous variables.
Returns binded variable name and type name for inserting into method declarations:
func (someVar TypeForSomeVar) MethodName() {
// come code
}Method will deduce tuple (someVar TypeForSomeVar) from either previous method
declaration or type declaration.
In go.snippets:
snippet d "define method"
func (`!p snip.rv=' '.join(go.extract_prev_method_binding_for_cursor())`) $1($2) $3${3/.+/ /}{
$4
}
endsnippet
snippet dp "define method on pointer"
func (`!p snip.rv=' *'.join(go.extract_prev_method_binding_for_cursor())`) $1($2) $3${3/.+/ /}{
$4
}
endsnippet
Return basename part of the path for using as new package name.
Returns previous used slice name.
Split line in parenthesis into multiple lines.
TBD: gif
Same, asd cycle_by_var_name, but for using in snippet.
Filter identifiers list and return first variable. If prev_var is
specified, then identifier list will be scanned either for exact match for
prev_var, and then return variable that came just before; if prev_var is
matching prefix for some var, then return value will be completed value.
Return list of identifiers that are looks like variables.
Return list of identifiers that are looks like just declared using
:=, = or passed via arguments.
Return identifier under cursor.
Return imports list with package names from current file.
Return package name from import name.
Return package name from specified file.

