Request for javascript? :D #11

Open
pheze opened this Issue Feb 10, 2011 · 8 comments

Comments

Projects
None yet
6 participants
@pheze

pheze commented Feb 10, 2011

$('bleh').click(function() {
|(cursor here) , possibility to add missing ; ?
})

@tpope

This comment has been minimized.

Show comment Hide comment
@tpope

tpope Feb 16, 2011

Owner

Cool though this may be, I can't imagine contorting endwise into figuring out multiple endings (')' and '}') in a single line. It would probably require an entirely new algorithm, one that I can't even conceive of (yet, anyways).

Owner

tpope commented Feb 16, 2011

Cool though this may be, I can't imagine contorting endwise into figuring out multiple endings (')' and '}') in a single line. It would probably require an entirely new algorithm, one that I can't even conceive of (yet, anyways).

@blueyed

This comment has been minimized.

Show comment Hide comment
@blueyed

blueyed Apr 5, 2011

Contributor

Something like autoclose (my fork) (or snippets, e.g. via snipMate) might work better in this case, or good enough as a workaround for now.

Contributor

blueyed commented Apr 5, 2011

Something like autoclose (my fork) (or snippets, e.g. via snipMate) might work better in this case, or good enough as a workaround for now.

@Peeja

This comment has been minimized.

Show comment Hide comment
@Peeja

Peeja May 17, 2011

What's lacking in autoclose is that it won't break open the

$('bleh').click(function() {|})

into

$('bleh').click(function() {
  |
})

I've been working on a way to do this, but then I realized that imaping <CR> breaks endwise. Is there a good way for two things to watch for <CR>?

Peeja commented May 17, 2011

What's lacking in autoclose is that it won't break open the

$('bleh').click(function() {|})

into

$('bleh').click(function() {
  |
})

I've been working on a way to do this, but then I realized that imaping <CR> breaks endwise. Is there a good way for two things to watch for <CR>?

@tpope

This comment has been minimized.

Show comment Hide comment
@tpope

tpope Jun 1, 2011

Owner

There's not a good way. If endwise finds an existing <CR> map, it'll include it, so in theory it's possible to chain.

Owner

tpope commented Jun 1, 2011

There's not a good way. If endwise finds an existing <CR> map, it'll include it, so in theory it's possible to chain.

@Kazark

This comment has been minimized.

Show comment Hide comment
@Kazark

Kazark Nov 20, 2013

Is this plugin meant to close C-style blocks? I had the impression it was for VimScript-style blocks. C-style blocks should probably be closed by other plugins. I have found several in addition to Autoclose, which was mentioned above: ClosePairs, lhBrackets, delimitMate, and auto-pairs. I have not tried any of these yet, so this is not an endorsement; just an attempt to give some leads to future viewers of this thread. There is further info at this wikia page.

Kazark commented Nov 20, 2013

Is this plugin meant to close C-style blocks? I had the impression it was for VimScript-style blocks. C-style blocks should probably be closed by other plugins. I have found several in addition to Autoclose, which was mentioned above: ClosePairs, lhBrackets, delimitMate, and auto-pairs. I have not tried any of these yet, so this is not an endorsement; just an attempt to give some leads to future viewers of this thread. There is further info at this wikia page.

@keith

This comment has been minimized.

Show comment Hide comment
@keith

keith Mar 26, 2014

Contributor

This doesn't work as expected with delimitMate. It uses a setting delimitMate_expand_cr to determine if: {|<CR>} should turn into:

{
    |
}

Obviously this setting is set in a user's vimrc. Since it's set conditionally here only if there isn't an existing mapping for <CR> what ends up happening is it's sourced and it ignores that mapping the first time through. Then endwise is sourced, adding a mapping like there is no other <CR> mapping. And then the second time delimitMate calls the maps, there is a <CR> mapping so it is not overwritten. This obviously isn't the fault of endwise, but more of an FYI. I'm not sure how to circumvent this besides attempting to not load endwise based on some filetypes where you'd prefer the delimitMate functionality.

On another note this conditional in endwise can also not be used in a user's vimrc (assuming the plugins are loaded first) since the functions would already be mapped before the variable was defined.

Contributor

keith commented Mar 26, 2014

This doesn't work as expected with delimitMate. It uses a setting delimitMate_expand_cr to determine if: {|<CR>} should turn into:

{
    |
}

Obviously this setting is set in a user's vimrc. Since it's set conditionally here only if there isn't an existing mapping for <CR> what ends up happening is it's sourced and it ignores that mapping the first time through. Then endwise is sourced, adding a mapping like there is no other <CR> mapping. And then the second time delimitMate calls the maps, there is a <CR> mapping so it is not overwritten. This obviously isn't the fault of endwise, but more of an FYI. I'm not sure how to circumvent this besides attempting to not load endwise based on some filetypes where you'd prefer the delimitMate functionality.

On another note this conditional in endwise can also not be used in a user's vimrc (assuming the plugins are loaded first) since the functions would already be mapped before the variable was defined.

@keith keith referenced this issue in Raimondi/delimitMate Mar 26, 2014

Closed

Does not auto indent #39

@keith

This comment has been minimized.

Show comment Hide comment
@keith

keith Mar 26, 2014

Contributor

I almost got around by creating the mapping myself with:

execute "imap <CR> <Plug>delimitMateCR <Plug>DiscretionaryEnd"

But that messes up endwise to where, in Ruby this happens:

if foo<CR>

Turns into:

if foo
    |
    end
Contributor

keith commented Mar 26, 2014

I almost got around by creating the mapping myself with:

execute "imap <CR> <Plug>delimitMateCR <Plug>DiscretionaryEnd"

But that messes up endwise to where, in Ruby this happens:

if foo<CR>

Turns into:

if foo
    |
    end
@keith

This comment has been minimized.

Show comment Hide comment
@keith

keith Mar 26, 2014

Contributor

The naive solution works without delimitMate's help:

execute "inoremap {<CR> {<CR>}<ESC>O"
Contributor

keith commented Mar 26, 2014

The naive solution works without delimitMate's help:

execute "inoremap {<CR> {<CR>}<ESC>O"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment