Just add plugin using Plug:
Plug 'seletskiy/vim-pythonx'
Import required py-modules in snippets files (e.g. in go.snippets
):
global !p
import go
endglobal
Thx @kovetskiy.
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.
Returns key-value data from phpdoc before current cursor position. Sometimes value may be array.
Getter/setter snippets, based on this and following functions:
Snippets from the above gif: php_vim_pythonx.snippets
Returns a class name with expanded namespaces from path variable.
Returns camelCase identifier from string, for example:
protected $_storage;
returns just Storage
.
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
Try to import corresponding package with looking for name under cursor.
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.