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

Auto pairing for Python triple quotes randomly fails with Treesitter #104

Open
AllanChain opened this issue Dec 30, 2024 · 1 comment
Open
Milestone

Comments

@AllanChain
Copy link

When trying to type triple quotes in Python, the auto pairing fails randomly if Treesitter parser for Python is installed.

Expected:

"""|"""

Randomly (~60%) get:

"""|"

Steps to reproduce:

  1. Install lazy.nvim, ultimate-autopair.nvim, and nvim-treesitter:
Minimal init.lua
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  local lazyrepo = "https://github.com/folke/lazy.nvim.git"
  local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
  if vim.v.shell_error ~= 0 then
    vim.api.nvim_echo({
      { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
      { out, "WarningMsg" },
      { "\nPress any key to exit..." },
    }, true, {})
    vim.fn.getchar()
    os.exit(1)
  end
end
vim.opt.rtp:prepend(lazypath)

-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"

-- Setup lazy.nvim
require("lazy").setup({
  spec = {
    -- import your plugins
    {
      'altermo/ultimate-autopair.nvim',
    event={'InsertEnter','CmdlineEnter'},
    branch='v0.6', --recommended as each new version will have breaking changes
    opts={
        --Config goes here
    },
    },
    {"nvim-treesitter/nvim-treesitter", lazy=false, build = ":TSUpdate"}
  },
  -- Configure any other settings here. See the documentation for more details.
  -- colorscheme that will be used when installing plugins.
  install = { colorscheme = { "habamax" } },
  -- automatically check for plugin updates
  checker = { enabled = true },
})
  1. Install Python parser with :TSInstall python
  2. Open an empty Python file and type """
Version info
NVIM v0.10.3
Build type: RelWithDebInfo
LuaJIT 2.1.1731601260
Health check
ultimate-autopair
- ERROR test(rfaswarp) { '"foo|"', "\1", '"|"foo', {ts = true} } failed, actuall result: '|""foo'
- ERROR test(rfaswarp) { '"|foo"', "\1", '"|"foo', {ts = true} } failed, actuall result: '"|foo"'
- ERROR test(rfaswarp) { '"|"', "\1", '"|"', {ts = true} } failed, actuall result: '|""'
- OK all test in category fastwarp have passed
- OK all test in category options have passed
- OK all test in category ext_cond have passed
- OK all test in category filter have passed
- OK all test in category simple have passed
- OK all test in category close have passed
- OK all test in category newline have passed
- OK all test in category backspace have passed
- OK all test in category tabout have passed
- OK all test in category ext_cmdtype have passed
- OK all test in category ext_alpha have passed
- OK all test in category multiline have passed
- OK all test in category ext_filetype have passed
- OK all test in category string have passed
- OK all test in category ext_suround have passed
- OK all test in category ext_escape have passed
- OK all test in category utf8 have passed
- OK all test in category ext_tsnode have passed
- OK all test in category ext_fly have passed
- OK all test in category space have passed
- OK all test in category space2 have passed

Additional information: Things work fine without Python parser installed.

@AllanChain
Copy link
Author

I should also mention that if the auto-pairing feature fails initially, it will continue to fail unless I quit and reopen Neovim. However, if it works from the start, it will function throughout the entire Neovim process.

@altermo altermo added this to the v0.7 milestone Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants