kana / vim-smartinput Goto Github PK
View Code? Open in Web Editor NEWVim plugin: Provide smart input assistant
Vim plugin: Provide smart input assistant
If I have my cursor like so:
test(┃one')
and try to set the left single-quote, I get two:
test('┃'one')
and whether I move the cursor right and delete:
test(''┃one')
or merely delete in place, the result has me back to where I started:
test(┃one')
IEnumerable#
-- <
-> IEnumerable<#>
to complete type parameters.foo #
-- <
-> foo <#
to write comparison expressions as usual.For example, a"foo"<Esc>.
inserts "foofoo"
while the expected result is "foo""foo"
.
In vim
filetype, "
has two roles. One is a string literal, and the other is a comment sign. So that the ideal behavior is to:
""
if a string can be inserted into the cursor position, or"
as a comment otherwise.The current default rules doesn't care about inserting comments.
at least in javascript:
if you type 'hello
then type \'
including backslash, it incorrectly removes the ending single quote and leaves you in hell
If I yank some text, create a pair of brackets and hit enter to expand then C-style, and then try to paste, the text I yanked is lost.
Maybe I'm doing something wrong, but here's how it works out when trying to do nested braces in SASS:
body {
div {
}
}
Instead of indenting the inner closing brace, it shifts it all the way over to left. Thoughts?
For some reason I chose not to use :map-<expr>
to do s:do_smart_input_assistant
.
However, as I reviewed the code to fix #7, it seems to be possible to use :map-<expr>
.
Let's reconsider using :map-<expr>
to s:do_smart_input_assistant
.
If it's possible, the complex cursor adjustment can be removed.
For example, if the cursor line is foo |bar)
(note that |
means the cursor position),
()
be completed if (
is typed at the point?()
etc?
\%#$
(at the end of a line) or \%#\K\(.\&\k\@!\)
(followed by non-keyword character)?Minimal installation for reproduction:
https://github.com/kusnier/supertab_smartinput_problem
How to reproduce:
$ vim
Enter: test<TAB><BS>
Vim is now in a recursion. Abort with <C-c>
Result:
test<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("\<SNR>12__trigger_or_fallback("")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")")
I'm using an up to date MacVim 7.3 both in GUI and CLI mode on Mac OS X 10.6.8 and a slightly older Vim 7.3 also in GUI and CLI mode on Ubuntu 10.10.
When I type (
, smartinput correctly inserts the matching )
but I'm not able to "undo" the ()
pair by hitting <BS>
. Only the first (
is deleted instead of both parenthesis. Of course, it's the same for all the other pairs ''""{}[]
.
Please let me know if you need more informations.
Thank you.
For example, the default syntax file for lisp
:
lispString
for string constants, thenlispString
to String
, andString
is liked to Constant
by default.Therefore:
synIDattr(id, 'name')
returns 'lispString'
.synIDattr(synIDtrans(id), 'name')
returns 'Constant'
.String
or not.Currently synIDtrans()
ed values are used to match "syntax"
of rules. This
means that only Constant
is a valid value for "syntax"
.
But Constant
implies String
, Number
and other constants. If user wants to define rules only for String
, such rules will never be used with the current behavior.
There are 4 options for the problem:
Constant
.
lispString
.lispString
.
synIDtrans()
.lispString
.lispString
.:highlight
.Let's reconsider which is the best way to deal with "syntax" matching.
Consider also actual usage and other possibility.
To reproduce: Type {<CR><ESC>
. Should now be in normal mode but have to press ESC again to leave insert mode.
Given the following line:
"some text|
pressing "
ends up with
"some text""|
It might be useful to leave from the current block by 'at': '\%#)'
intead of 'at': '(\%#)'
.
For example,
IEnumerable#
-- <
-> IEnumerable<#>
(with vim-smartpunc) is useful to write type pameters in C#._<_
<--> <
(read _
as a whitespace / with vim-smartchr) is useful to write comparison expressions.Both configurations are conflicted. What is the best way to coexist such configurations?
Some thoughts:
"at"
in Command-line mode.:wqall
:s/.../.../g
."at"
, "filetype"
and "syntax"
."at"
is not configurable ('foo\%#'
-style only),"filetype"
depends on how rules are defined (e.g. via filetype plugins or :autocmd FileType
)"syntax"
is not supported completely."input"
for any rule."input"
is limited to a normal string,Steps to reproduce:
{ foo }
When the closing curly brace is entered the following happens:
:call search('}', 'cW')
{ foo }
{ foo }
{ foo }
{ foo }
If you don't enter the closing brace "manually" everything works as expected when leaving insert mode (ESC). The same problem occurs when entering square brackets and parenthesis but not when entering single or double quotes for instance.
Using v0.0.3.
For example,
foo+bar
inserts foo + bar
,foo +bar
inserts foo + bar
,foo+ bar
inserts foo + bar
, andfoo + bar
inserts foo + bar
.r"..."
and others.r'...'
and others. Because a rule to input English words such as Let's
conflicts with r'...'
.For example: {'at': '()\%#', 'char': '<BS>', 'input: '<BS><BS>'}
So many men, so many minds. The "expected" behavior of operator rules depends on users' tastes and 'filetype'
. So that it's hard to define the default rules on operators.
Therefore:
=
.Hi,
Could you add a parameter to the rule definition that can modify the rule weight, such as
{at: '...', 'char': '...', input: '...', 'weight': 5} -> rule weight = 5 + original weight
. This is required because sometimes the number of character in the regexp does not correlate to the specificity of the regexp
For example
\%#} is more specific than \%#\s*}
// ...
/// ...
/* ... */
mode()
and getcmdtype()
be written in rules?Maybe I just haven't found this, but sometimes I don't want to have the completion and only want to enter one " without the automatic completion to "" . How can I do this?
Currently both alternative input and fallback input are not remapped.
But there should be an option to specify a remappability of both types of input.
Reproduced on Windows 7 Professional SP1 32-bit with the following version of gvim:
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Nov 4 2011 08:50:34)
MS-Windows 32-bit GUI version with OLE support
Included patches: 1-353
Compiled by [email protected]
Huge version with GUI. Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +conceal +cryptv +cscope +cursorbind +cursorshape
+dialog_con_gui +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +gettext/dyn -hangul_input +iconv/dyn +insert_expand +jumplist
+keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap +lua/dyn +menu +mksession +modify_fname +mouse +mouseshape +multi_byte_ime/dyn +multi_lang -mzscheme +netbeans_intg +ole +path_extra
+perl/dyn +persistent_undo -postscript +printer +profile +python/dyn -python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white -tcl -tgetent -termresponse +textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu
+windows +writebackup -xfontset -xim -xterm_save -xpm_w32
system vimrc file: "$VIM\vimrc"
user vimrc file: "$HOME\_vimrc"
2nd user vimrc file: "$VIM\_vimrc"
user exrc file: "$HOME\_exrc"
2nd user exrc file: "$VIM\_exrc"
system gvimrc file: "$VIM\gvimrc"
user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$VIM\_gvimrc"
system menu file: "$VIMRUNTIME\menu.vim"
Compilation: gcc -O3 -fomit-frame-pointer -freg-struct-return -fno-strength-reduce -DWIN32 -DHAVE_PATHDEF -DFEAT_HUGE -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -DFEAT_PERL -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL="perl58.dll" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL="python27.dll" -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL="lua51.dll" -DDYNAMIC_GETTEXT -DDYNAMIC_ICONV -DFEAT_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG -DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_OLE -march=i386 -Iproto -I/cygdrive/c/strawberry/perl/lib/CORE -I/cygdrive/c/PROGRA~2/Lua/5.1/include -s -mno-cygwin
Linking: gcc -s -o gvim.exe -luuid -lole32 -lwsock32 -mwindows -lcomctl32 -lversion -loleaut32 -lstdc++
As many default rules are defined, now it takes about 4000 milliseconds to :source
the autoload file, but the smart input assistant is not so slow.
Possible bottleneck:
smartpunc#define_rule()
sorts available nrules for each time.Hi,
I jsut try to add some custom mapping for ruby here what I want to do
# => #{} only inside a string
| => || always
but it didn't work and I can't find a clear exemple of adding customme mapping. Could yuo please help and maybe we can add some sample to the documentation
here waht i add to my vimrc file
smartinput#map_to_trigger('i', '|', "|")
smartinput#define_rule({'at': '\%#', 'char': '#', 'input': "#{}\<Left>" ,'filetype': ['ruby'], 'syntax':['Constant']})
smartinput#define_rule({'at': '\%#', 'char': '|', 'input': "||<Left>" ,'filetype': ['ruby']})
The current name, vim-smartpunc, is just a temporary name to start development.
There must be a better name.
With this "before":
{
asdf#
}
When I type <enter>}
, I would expect to get:
{
asdf
}#
But instead, I get:
{
asdf
}#
}
Could this be fixed to allow leaving the block easily just as you can do on single lines?
... to write code like the following:
foo = bar +
baz +
qux
I have my shiftwidth set to 2 (as well as my tabstop), so when I input {<enter>, I expect the following:
{
#
}
With two spaces. Instead, I get 4 spaces:
{
#
}
Looks like the plugin isn't respecting shiftwidth and always shifting 4 spaces.
For example:
=
:
foo#
foo = #
foo == #
<BS>
:
foo == #
foo = #
foo#
In Replace mode, smart input assistant is usually useless. Especially, ()
completion causes unnatural result. Disable smart input assistant in Replace mode to avoid such problems.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.