Giter Club home page Giter Club logo

auto-pairs.kak's People

Contributors

alexherbo2 avatar johnisom avatar maximbaz avatar mogenson avatar taupiqueur avatar tomkpz avatar vbauerster 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

Watchers

 avatar  avatar  avatar  avatar

auto-pairs.kak's Issues

Hitting <Backspace> in Insert mode deletes character after cursor

I'm getting the following issue, as described in the title. Demonstrated in the video below.

I've tried playing with different options and disabling other plugins, but I still get this behavior. The only thing that helps is auto-pairs-disable.

Appreciate any tips on what could be wrong in my case.

P.S. I'm a new kak convert and just wanted to say thanks for all your plugins! My vimrc was 80% filled with plugins by tpope, and my kakrc is 80% filled with plugins by you :D

recording.mp4

Using ksh, auto-pairs acts very wonky

When using oksh as /bin/sh (which is just a portable version of OpenBSD's ksh- in fact, this happens with loksh, another port, and mksh, so it's affecting all ksh derivatives), auto-pairs.kak acts very strangely.

When hitting enter to create a new line, it will create a new line, then indent it, create a new line after the indented line, and then leave your cursor at the indentation point. It also seems to be duplicating spaces once you have leading spaces and hit space multiple times.

Here's a recording demonstrating the problem:

asciicast

I have a hunch it's the printf statements printing spaces somewhere in there, resulting in auto-pairs thinking that it needs to "complete" a bracket represented by a . Looking it though, I'm not quite sure what exactly the problem would be. It could also be related to bash's printf built-in not being used (and ksh and friends having no printf built-in), but I've tested this possibility by replacing printf usage with /bin/printf without any differences from this cropping up. I also thought it could be related to busybox's printf implementation (which is being used, as the system I'm running kak under uses busybox for coreutils, including printf), but again, changing out printf to explicitly use busybox printf changed nothing, and it worked fine under bash.

With all plugins except auto-pairs.kak disabled, this still occurs, so I feel pretty confident the problems lies here.

lots of space in matching pairs

When I type [ , I expect to see

[ | ]

but lately I've been getting

[ |        ]

(where | is the cursor. Apologies for the block formatting, backtick formatting erases the precise amount of spaces!)

This seems like something that could be auto-pairs, but I'm not 100% sure. Does this seem likely to you? What other info could I provide you to check? I'm running auto-pairs.kak at 3e529e8

:auto-pairs-surround should respect spaces

:auto-pairs-enable

In normal mode press this: oa=( b c

Result:

a=( b c )

Suppose you have text:

a=b c

Select b c.
Enable :auto-pairs-surround.
Press (<space>

Expected:

a=( b c )

Actual:

a=( b c)

auto-pairs-enable fails

When I run :auto-pairs-enable, it throws this error:

error running hook ModuleLoaded(auto-pairs)/: 2:2: 'auto-pairs-enable' 2:5: 'auto-pairs-save-settings' no such command: '$'
Config-change detected:
Error: 1:1: 'auto-pairs-enable' 2:5: 'auto-pairs-save-settings' no such command: '$'

Using words as autopairs

Hey,
is it possible to use full strings as autopairs? For example if and fi in shellscripts.
Thanks for providing this useful plug in!

pasting with no-hooks creates unnecessary closing characters

If I insert something from the system clipboard which has parantheses (or other pairs), I will get redundant closing characters at the end of my paste.

  • copy some code with parantheses
  • go to insert mode with no-hooks: \i
  • CTRL-V or CMD-V or whatever your system / terminal supports
  • => extra parentheses

Bad indent after inserting new line between brackets

Thank for this nice plugin.

Recently, I have observed an annoying behavior when inserting a new line between some separators on my cpp file.
The cursor is | in the following.

  {|}

press Enter:

  {
     |
     }

I would expect the lower bracket to be aligned with the upper one.
This bug seems to depends on the current filetype. It does not occurs on the kakrc but does occur on cpp files.

Setup:

  • Kakoune on current master
  • A kakrc with only prelude and auto-pairs plugins loaded and nothing else.

auto-pairs and VHDL file type insert-on-new-line commands.

I have problem with defining proper behavior of some file type command when auto-pairs is enabled.
I have following command defined

define-command -hidden vhdl-insert-on-new-line %[
  evaluate-commands -save-regs x %[
    # Save previous line indent in register x.
    try %[ execute-keys -draft k<a-x>s^\h+<ret>"xy ] catch %[ reg x '' ]

    # Wisely add ");" for "generic (".
    evaluate-commands %[
      try %[
        execute-keys -draft k<a-x> <a-k>^\h*(?i)generic\h*\($<ret> }i<a-x> <a-K>^<c-r>x(\)\;)<ret>
        execute-keys -draft o<c-r>x)<semicolon><esc>
      ]
  ]
]

When auto-pairs is not enabled, after inserting following sequence

   generic (

and hitting enter I end up with:

   generic (
      <- cursor here
   );

When auto-pairs is enabled I always end up with:

   generic (
      <- cursor here
   )

The ; is missing in the last line. The cursor in both cases is indented one more level, but this is expected and is the result of another command.

I have tried multiple methods to get this command work properly both with and without auto-pairs, but I failed.
Can you help?

Error: cannot unmap key that is currently executing

On the latest kakoune master this key sequence from the new line (<enter>s throws these errors

error running hook WinSetOption(inserted_pairs=0)/auto-pairs: 3:7: 'unmap': cannot unmap key that is currently executing
error running hook InsertChar(s)/auto-pairs: 2:7: 'unmap': cannot unmap key that is currently executing

I checked it with clear kak -n only sourcing this plugin.

Any workaround that comes to mind?

Ability to limit the "skipping closing pair"?

I generally enoy using auto-pairs, but sometimes it is getting in the way. Most of the time it's when I'm editing text, and it starts detecting completely unrelated characters.

I was wondering if it would be possible to somehow configure the following rules:

  • after opening character, insert closing character, only if trailing text are whitespaces, to the end of the line.
  • after inserting closing character, actually skip inserting it, only if the immediate character under the cursor is exactly the same

Right now it seems to me that heuristic would differentiate substantial majority of cases, where I actually don't want auto-pairs to change what I'm inserting.

auto-pairs-surround documentation

Hi,

This is in the README:

map global user S -docstring 'Surround++' ': auto-pairs-surround _ _ * *<ret>'

What is the meaning of auto-pairs-surround parameters? There is no documentation for it.
An explanation for this should at least be added in the README.

Exception per file type?

Is it possible to introduce some exception rule per file type?
For example in rust it's pretty common to type <'a>, so when I type <' I get <'' instead.
So I'd like to have exception like do not auto-pair a single quote if previous char is <.

Plug support?

Are you planning to add support for installing this plugin with Plug?

The current way of putting things into autoload and installing dependencies by hand is cumbersome, and impossible to put in dotfiles. It would have been so great if users could just say plug alexherbo2/auto-pairs.kak and try out this project immediately.

This seems like a very useful project. I didn't try it yet (it's too late today already), but will soon!

Typing a closing quote should not insert more quotes

This already works for brackets:

brackets

But it doesn't work for quotes, and it is super annoying:

quotes

delimitMate is very good at handling a special case of three quotes (used for docstrings in python), ideally this should behave identically in auto-pairs:

nvim-quotes

Auto-pairs adding extra pair when pasting text

I noticed that when pasting text in insert mode, the plugin adds an extra "pair" at the end.
For example, if in insert mode I paste the following:

{

}

I get:

{

}

}

Is there anyway to disable this while pasting text?
Thank you for your help!

Not matching pairs but only whitespaces

I'm using your new implementation of autopairs but so far I can't seem to make it work, whenever i type any "pairable" character, it doesn't pair it but when i hit space it kinda matches the indentation downwards, I'm not sure if the last thing is intended, is there a way to disable it?, and why could it be that the plugin is not pairing my input?

Thanks.

Critical bug with python: autopair remove stuff out of its scope ( ! )

how to repoduce:

Open a new python file:
kak /tmp/foo.py
paste the following:

def f():
    bar
    foo

But the cursor on the line of hello and A<ret> to insert on a new line between bar and foo. Type hello world . You should be in insert mode like so :

def f():
    bar
    hello world_
    foo

Now start deleting with backspace. Continue pressing backspace until the begining of the line.

expected behaviour

The line is deleted, the foo and bar line are unchanged

actual behaviour

Backspace act like backspace+delete, swallowing character on the right side of the cursor. It start by deleting the \n char. of the hello world line and then the content of the foo line.

Type "through" closing pair

Hey, thanks for the great plugin!

I'm new to using auto-pairs, so I find myself often typing [] because I forget that auto-pairs will add the closing pair for me. However, when I do this, I end up with []], one closing pair for the one inserted by auto-pairs and another for the one that I type. It would be great if it was possible to type "through" the closing pair if it's already there.

I think in addition to me forgetting to use auto-pairs and typing the extra ], there are other cases this behavior is helpful. For example, take the following Elm code:

html [] [ span [] [ text "hello" ] ]

Each time I type [] and want to continue typing past the closing pair with auto-pairs enabled, I need to do the following keystrokes:

[ -- Create the bracket (and auto-pairs inserts the closing one)
<esc> -- exit insert mode
l -- move to the right
i -- go back to insert mode
... -- continue typing

However, if I could type "through" the closing bracket I could do:

[ -- Create the bracket (and auto-pairs inserts the closing one)
] -- Don't actually insert the "]", but just move past that character
... -- continue typing, but now I don't need to leave insert mode at all!

I think that this is something VSCode does too.

I have no idea the technical hurdles to achieve this, but it would be cool if it was possible!

Installation quesiton

In the installation section you mention about 2 options:

  1. Add auto-pairs.kak to your autoload

or

  1. source it manually.

Which one is done by require-module auto-pairs?

What does the opposite option look like?

Strange behavior with whitespace

When autopairs is enabled, 'o' no longer moves the insert cursor to the beginning of the next line, instead it selects the current line and adds a new line below the insert point.

For example:

If I type:

ifoobar<Esc>obazfoo

foobabazfoor

appears instead of

foobar
bazfoo

Also, if inserting text when inside a pair, typing whitespace adds additional whitespace after the insert point.

So if I type:

I(foo bar baz bat<Esc>

(foo bar baz bat )

(only one space is showing up in the preformatted text, but there should be three spaces after bat)

appears instead of

(foo bar baz bat)

I kinda get what's happening with that, (the whitespace is one of the pair characters), but I think that should only happen if there aren't any non-whitespace characters between the already paired characters. That is, if I type a left paren, then a whitespace, the balance should be a whitespace, then a right paren. But if I type a left paren and then any non-whitespace character, the balance should only ever be a right paren.

Right way to override auto_pairs option?

What is the right way to override global auto_pairs option for specific file type?
For example, I've tried following in order to remove <> pair:

hook global WinSetOption "filetype=go" %{
    set window auto_pairs '(' ')' '{' '}' '[' ']' '"' '"' '''' '''' '`' '`'
}

Echoing, shows that there is no <> pair, but < keeps auto paired with >.

Readline keybindings don't work when auto-pairs is enabled

To repro, use the following configuration

plug "alexherbo2/auto-pairs.kak" %{
    enable-auto-pairs
}
plug "chambln/kakoune-readline" config %{
    hook global WinCreate .* readline-enable
}

Readline keybindings (eg. <a-f> and <a-b>) do not work when auto-pairs is enabled.

Support single quote

Since it is impossible to add single quote to the auto_pairs list, how about coming up with a workaround?

We can agree to represent a single quote as "<q>" and treat this specially, convert "<q>" to a single quote directly in shell scripts where auto_pairs variable is being consumed.

What do you think?

Pressing `o` behaves incorrectly

Pressing o does create a new line below the current line, however the cursor does not go to that line. Instead, the current line is selected and the cursor is left at the end.

Unfortunately, the test added in this commit doesn't detect this behavior because it's only checking the contents of the buffer, not the state of the cursor or selection.

Delete surrounding brackets doesn't work when spaces are involved

[ cmd ] && echo yes

Select cmd, type :auto-pairs-surround, press Backspace twice.

Expected:

cmd && echo yes

Actual:

error running hook InsertDelete([)/auto-pairs-surround-delete: 1:1: 'auto-pairs-surround-delete-opener' 2:4: 'execute-keys' no selections remaining

Doesn't work in mac

After entering :auto-pairs-enable command, I expect auto pair completion, but nothing happens.
For example I enter { and result is the same.
I'm using mac os kakoune version.

Inserting closing character does not skip over whitespace

It would be nice if inserting the closing character of a pair would skip over whitespace (including new lines) if the character is already in place. Example:

Buffer:
void main() {
    return 0;|
}

Input: }

Result:
void main() {
    return 0;
}|

I tried to implement this like so:

define-command -hidden -params 2 auto-pairs-insert-closer %{ try %{
  execute-keys -draft "hf%arg(2)<a-k>\Q%arg(2)\E\s*\Q%arg(2)<ret>"
  execute-keys -with-hooks "<backspace><esc>hf%arg(2)a"
}}

but it results in a bunch of extra selection and doesn't work twice in a row (without leaving insert mode) because hooks aren't executed recursively.

Is there a better way to accomplish this with Kakoune's awkward scripting?

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.