Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move with other pairs #331

Closed
jakubkaczor opened this issue Feb 27, 2023 · 6 comments · Fixed by #357
Closed

Move with other pairs #331

jakubkaczor opened this issue Feb 27, 2023 · 6 comments · Fixed by #357
Labels
bug Something isn't working

Comments

@jakubkaczor
Copy link
Contributor

Description

Using Rule the cursor moves independent of the type of ending pair. That is having

Rule("$", "$", "markdown"):with_move(conds.done())

in the configuration, the cursor is moved with ", ), etc., even with (, which is an opening bracket, while this behavior is expected only with $.

Mapping bug

nil

Steps to reproduce

  1. Run nvim -u minimal.lua test.md to open a new markdown file with a minimal config.
  2. Enter insert mode.
  3. Type $a. The state of the buffer is $a|$, where | is the cursor. After pressing other ending pair, such as " it moves to the state $a$|.

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      {
        'windwp/nvim-autopairs',
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  local autopairs = require('nvim-autopairs')
  autopairs.setup()
  local Rule = require "nvim-autopairs.rule"
  local conds = require "nvim-autopairs.conds"

  autopairs.add_rule(
    Rule("$", "$", "markdown"):with_move(conds.done())
  )
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing nvim-autopairs and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]
@jakubkaczor jakubkaczor added the bug Something isn't working label Feb 27, 2023
@TheOmegaCarrot
Copy link

TheOmegaCarrot commented Mar 1, 2023

I am also experiencing this issue. I am also seeing pressing space (!) triggering the move.

@haoming-li-ling
Copy link

I suggest before the issue is fixed, use auto-expanding snippets to do the trick. Then you can use the tab key to get out of the math environment.

@lutalli
Copy link

lutalli commented Mar 18, 2023

I also experienced this issue when trying to type $\mathbf{$. Instead of typing { the cursor just moved right.

The expected behavior is that the cursor only moves when entering a repeated $, but currently typing all kind of brackets will cause the cursor to move.


I also tested some other symbols than $ and I got kinda random results:

  • Firstly with Rule("$", "$"):with_move(conds.done()), all () [] {} " will cause the cursor to move.
  • With rule ? ?, * * or ? #, () " will cause the cursor to move, but [] {} don't.
  • With rule # #, # ? or $ :, only " will cause the cursor to move, but () [] {} don't.

I'm not sure if that says something.

bew added a commit to bew/nvim-autopairs that referenced this issue May 16, 2023
bew added a commit to bew/nvim-autopairs that referenced this issue May 16, 2023
@stale
Copy link

stale bot commented May 17, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label May 17, 2023
@TheOmegaCarrot
Copy link

Any new information or workarounds regarding this bug?

@stale stale bot removed the wontfix This will not be worked on label May 17, 2023
@bew
Copy link
Contributor

bew commented May 18, 2023

Well I opened a PR yesterday at #357, I think it would help if you can test it 😃

And if someone can understand why one of the test doesn't work as I expected (fixed)

bew added a commit to bew/nvim-autopairs that referenced this issue May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants