Coder Social home page Coder Social logo

raimondi / delimitmate Goto Github PK

View Code? Open in Web Editor NEW
2.0K 25.0 116.0 466 KB

Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.

Home Page: http://www.vim.org/scripts/script.php?script_id=2754

Makefile 5.86% Vim Script 94.14%

delimitmate's Introduction

This plug-in provides automatic closing of quotes, parenthesis, brackets, etc., besides some other related features that should make your time in insert mode a little bit easier, like syntax awareness (will not insert the closing delimiter in comments and other configurable regions), and expansions (off by default), and some more.

Most of the features can be modified or disabled permanently, using global variables, or on a FileType basis, using :autocmd.

delimitmate's People

Contributors

aschrab avatar atcold avatar blueyed avatar codebeige avatar ervandew avatar glench avatar gray-wind avatar grota avatar gyim avatar jamessan avatar lilyball avatar lokaltog avatar msch avatar olivia5k avatar peter50216 avatar raimondi avatar rgbd avatar tmhedberg avatar wellle avatar ypid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

delimitmate's Issues

Arrow keys turns to chars

The problem came from the commit a751498...

I blame this code (autoload/delimitMate.vim):

inoremap <buffer> <Left> <C-R>=delimitMate#FlushBuffer()<CR><Left>
inoremap <buffer> <Right> <C-R>=delimitMate#FlushBuffer()<CR><Right>
inoremap <buffer> <Up> <C-R>=delimitMate#FlushBuffer()<CR><Up>
inoremap <buffer> <Down> <C-R>=delimitMate#FlushBuffer()<CR><Down>

<S-Tab> doesn't work in vim/gVim when a filetype is set.

One of the features I like most is the S-Tab feature to exit [], "" and such.

I had an old version from 6 months ago that worked really well. But now I've done a git clone from your repository and it works only if a filetype isn't set.

To test, open vim, press (|) and , you have ()|. Run ":set ft=python", press (|) and now you get ( |).

Could this be a plugin conflict? How do I debug it?

option to only autoclose if nothing to the right of cursor

i frequently find that i need to jump to the middle of a line and add a conditional or some or structure that requires a matchpair around some of the text. so i might want to change something like:
func($var);
into
if (func($var)) {
but in the process of making the change i get to this point
if ()func($var)
and because issue #42 is outstanding, the backspace actually deletes the opening parens:
if )func($var)

i think having an option to only autoclose if there is nothing to the right of the opening matchpair would make things a lot easier.

improvements for visual wrapping

some ideas/random thoughts for improving/extending visual wrapping

1. using markers for inserting delimiters

not sure if it would make any difference, but just wondering if the visual mode wrapping would potentially not break redo (as the help doc says it does?) if it used <` and >` to navigate to the start and end of the visual selection to insert delimiters?

execute 'keepjumps normal! `>a' . rd
execute 'keepjumps normal! `<i' . ld

basing that assumption on another vim plugin (LatexBox) which I don't think breaks redo and provides some similar wrapping features.

2. normal-mode wrapping

Any chance of adding (optional?) normal-mode mappings which apply the wrapping to the current word so you don't have to enter visual mode to wrap a single word?

not a huge deal of course for me to add some mappings like this:

nnoremap <buffer> <Leader>( viw:call delimitMate#Visual("(")<cr>

would just be easier to have an option...

3. repeated/multiple wrappings

Would be good if the wrapping could be repeated (e.g. if you want to nest a selection in two delimiters, same or different). Not sure if this is widely useful, but there are definite cases for me wanting to insert 3 " characters in python documentation or two ```, ' pairs in LaTeX, and reselecting the text 2-3 times would make it not worth using the visual wrapping. Other possible cases (though I have not had the need myself) would be wrapping in different delimiters, e.g. turning `hello` into `[ 'hello' ]`

  • Maybe the suggestion from point 1 above would simplify this(?)
  • or the visual selection could be maintained or easily re-selected after the delimiters are applied?
  • or mappings could support repeating with the . command or a preceding number (so you'd type 3\" to wrap some text in three quotation marks on either end)

trouble with delimitemate and latexsuite

hello, I can't seem to get delimitmate to work in tandem with latex suite, but i've had it work elsewhere when not in tex files. I can't tell if its a bug on one side or another, or perhaps just an unforseen interaction bteween the two, how would i determine this?

'O' oddity under terminal

i type open delimiter, then delimiteMate complete it, type some stuff in between delimiters, hit escape to get me to normal mode, type 'O' (shift-o) to add new line above and then 'O' is displayed at the cursor position for several seconds before the line is added. this doesn't happen under macvim. no mapping is present for 'O' or s-o. i have the same environment and DelimitMateTest results as in #42 .

it's not exactly broken behavior, but these forced pauses do interrupt my flow.

Does not auto indent

I have "lett delimitMate_expand_cr = 1" inside my vimrc, but when I press after opening a parentheses, it doesn't automatically indent for me. Example:
After typing,

int main() {|

I hit enter expecting to see

int main() {
|
}

yet it looks like this:

int main() {
|}

Is this some sort of bad configuration on my part?

problem with <End> and <Home>

type: f(f(f(;<END><ESC>
result: f(f(f()));)))

type: f(f(f(; <HOME><ESC>
result: )))(f()))

This is happening on Cygwin Vim version 7.3.3. Doesn't happen on Windows native Gvim 7.3. Nice plug btw. I thought it might be janky but then I tried gvim. I can understand cygwin is probably the lowest on the list of priorities :) Would be nice to have it fixed anyway.

ExpandSpaces/CR not working

I can't get expand_space or rexpand_cr to work correctly. I've tried with the latest release on vim.org and from github.

  • For testing this is the only plugin I had loaded at the time *

vimrc:
set nocompatible
let b:delimitMate_expand_space = ""
let b:delimitMate_expand_cr = ""

TestMappings output:
*b:delimitMate_autoclose = 1
*b:delimitMate_expand_space =
*b:delimitMate_expand_cr =

Open & close: (|)
Delete: |
Exit: ()|
Space: ( |)
Delete space: (|)
Visual-L: (v)
Visual-R: (v)
Car return: (
|)
Delete car return: (
|)

Open & close: {|}
Delete: |
Exit: {}|
Space: { |}
Delete space: {|}
Visual-L: {v}
Visual-R: {v}
Car return: {
|}
Delete car return: {
|}

Open & close: [|]
Delete: |
Exit: []|
Space: [ |]
Delete space: [|]
Visual-L: [v]
Visual-R: [v]
Car return: [
|]
Delete car return: [
|]

Open & close: "|"
Delete: "|
Exit: ""|
Space: " |"
Delete space: "|"
Visual: "v"
Car return: "
|"
Delete car return: "
|"

Open & close: '|'
Delete: '|
Exit: ''|
Space: ' |'
Delete space: '|'
Visual: 'v'
Car return: '
|'
Delete car return: '
|'

Open & close: |
Delete: | Exit:``| Space: | Delete space:| Visual:v Car return:
| Delete car return:
|`

expand_cr does not correctly indent the brace/cursor

Given the following code: (| == cursor here)
while (1) {
for (i=0;i<10;i++){|
}

when I hit return I get the following code:
while (1) {
for (i=0;i<10;i++){
|
}
}

Since I have smarttab on I expected the following:
while (1) {
for (i=0;i<10;i++){
|
}
}

Is that an easy thing to fix or is it pretty complicated? Or am I missing a config option to fix that?

(tested on the latest devel version and a mostly virgin .vimrc (turned on a few options for testing like smarttab))

<BS> get unmapped by some other plugins (SuperTab)?

I've noticed that i loose <BS> default behavior sometimes.

Turns out that it's caused by SuperTab.vim, though not really sure.

Steps to reproduce:

Start typing in insert mode, hit "Tab" so that completion list appears
Hit "BS" few times
Hit "ESC" to get to normal mode.
Go to insert, type (, so that () appear

Typing "BS" after that - inside () doesn't remove bracket.
:verbose imap <BS> shows nothing

Is it possible to workaround it somehow? Thanks

Mappins of <Down> and <Up> break functionality with completion menu

When the completion menu is visible, and can be used to select an entry without inserting it. The current delimitMate mappings of these keys break this functionality. Imho, the mappings should be defined like
inoremap pumvisible() ? "" : "=delimitMate#Finish()"
inoremap pumvisible() ? "" : "=delimitMate#Finish()"
This way the pop-up menu works like expected.

Formating Test

Code enclosed between tags:

'^%(!)'

Code enclosed between tags, published and then changed to the four spaces format:

'^\%(\!\)'

Code preceded by four spaces:

'^\%(\!\)'

<Esc> does not works as expected

when using vim in a terminal, with timeout not set, then "imap <C-[>OC " causes strange behavior when exiting insert mode by pressing Esc : -- INSERT -- stay on screen until I press a key (which is not 'O' of course)
set timeout resolve the problem

Detect unbalanced quotes.

Sometimes, I have a single left quote and want to finish it with a right quote, but typing in the right quote adds two quotes instead of one.

Force visual mapping to be silent

When starting vim, I always get an error about the visual mapping. This patch fixes that:

diff --git a/autoload/delimitMate.vim b/autoload/delimitMate.vim
index 7671f3d..5532e89 100644
--- a/autoload/delimitMate.vim
+++ b/autoload/delimitMate.vim
@@ -653,7 +653,7 @@ function! delimitMate#VisualMaps() " {{{
        let vleader = b:_l_delimitMate_visual_leader
        " Wrap the selection with matching pairs, but do nothing if blockwise visual mode is active:
        for del in b:_l_delimitMate_right_delims + b:_l_delimitMate_left_delims + b:_l_delimitMate_quotes_list
-               exec "silent vnoremap <unique> <silent> <buffer> <expr> " . vleader . del . ' delimitMate#Visual("' . escape(del, '")') . '")'
+               exec "silent! vnoremap <unique> <silent> <buffer> <expr> " . vleader . del . ' delimitMate#Visual("' . escape(del, '")') . '")'
        endfor
 endfunction "}}}

On many files I'll get Unknown function: DelimitMate_BS

Happens every time I hit the backspace key in insert mode.
DelimitMateTest also fails. Doesn't happen in every file, but easily reproducible and every time in a given buffer.

=DelimitMate_BS()
E117: Unknown function: DelimitMate_BS
Press ENTER or type command to continue
E15: Invalid expression: DelimitMate_BS()
Press ENTER or type command to continue

Multicharacter matchpair

Using the latest version 2.4.1, I am trying to create a matchpair for erb, so in my vimrc, I have the following:

let delimitMate_matchpairs = "(:),[:],{:},<%:%>"

It works when inserting text:

<% test %>

but after I hit ESC, I get:

<% test %>>

Is there something I'm doing wrong or a setting I'm not setting (I am just using the defaults, aside from the one mentioned.)

Thanks
Dan

Make a more flexible use of expansion mappings

  • make ExpandReturn a global function
  • make WithinEmptyPair a global function so that users can write their own mappings
  • call a global function from within ExpandReturn, and if it returns anything, short circuit ExpandReturn
  • somehow call the global (non-) imap for instead of returning plain

detect unbalanced delimiters

If I have "hello)" and I type a "(" before the "h", it should not add the extra ending delimiter ")" since there's already an unbalanced ending delimiter.

strange &lt;End>&lt;Esc> behavior

In insertmode, input
["

this will output

["|"]

"|" is the cursor position

then enter <End><Esc>, It should be

[""]

but It expand as below
[""]"]

You can use this script to test it:

fun! Test() "{{{
startinsert
call feedkeys("["<End><Esc>")
endfunction "}}}
call Test()

<Left> doesn't work.

The cursor can't be moved to the left using the arrow key after a delimiter has been typed.

Allow nested quotes

Suggested by Kenneth Love, this would allow Python docstrings to be completed bydelimitMate.

"""string => """string"""

delimitMate_expand_cr breaks endwise.vim

If the option to expand on is enabled, the endwise.vim script won't work.

Steps to reproduce

  1. Install endwise.vim
  2. Open a ruby file.
  3. Type something like def foo<CR>

Normally this would be expanded to

def foo
  |
end

Where "|" indicates the cursor position.

What happens instead?

No end is inserted.

Does not auto indent

I have "lett delimitMate_expand_cr = 1" inside my vimrc, but when I press after opening a parentheses, it doesn't automatically indent for me. Example:
After typing,

int main() {|

I hit enter expecting to see

int main() {
|

}

yet it looks like this:

int main() {
|}

Is this some sort of bad configuration on my part?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.