andymass / vim-matchup

vim match-up: even better % :facepunch: navigate and highlight matching words :facepunch: modern matchit and matchparen. Supports both vim and neovim + tree-sitter.
https://www.vim.org/scripts/script.php?script_id=5624
MIT License
1.7k stars 72 forks source link

Not working if set timeoutlen #196

Closed tynguyen2k1 closed 1 year ago

tynguyen2k1 commented 2 years ago

Explain the issue

vim-matchup(a.1 a.2 a.3 b.1) won't work if I set timeoutlen

  1. What vim version are you using? If using neovim, Are you using tree-sitter or classic matching? NVIM v0.5.1 and tree-sitter

Minimal vimrc file

Please provide a minimal vimrc file that reproduces the issue. The following should often suffice:

O = vim.o
BO = vim.bo
WO = vim.wo
G = vim.g
CMD = vim.cmd

O.backup = false -- creates a backup file
O.clipboard = "unnamedplus" -- allows neovim to access the system clipboard
O.cmdheight = 1 -- more space in the neovim command line for displaying messages
O.colorcolumn = "99999" -- fixes indentline for now
-- O.completeopt = { "menuone", "noselect" }
O.conceallevel = 0 -- so that `` is visible in markdown files
O.fileencoding = "utf-8" -- the encoding written to a file
O.foldmethod = "manual" -- folding, set to "expr" for treesitter based folding
O.foldexpr = "" -- set to "nvim_treesitter#foldexpr()" for treesitter based folding
O.guifont = "monospace:h17" -- the font used in graphical neovim applications
O.hidden = true -- required to keep multiple buffers and open multiple buffers
O.hlsearch = false -- nohighlight all matches on previous search pattern
O.ignorecase = true -- ignore case in search patterns
-- O.mouse = "a" -- allow the mouse to be used in neovim
--
O.pumheight = 10 -- pop up menu height
O.showmode = true -- false if you don't like -- INSERT -- anymore
O.showtabline = 4 -- always show tabs
O.smartcase = true -- smart case
O.smartindent = true -- make indenting smarter again
O.splitbelow = true -- force all horizontal splits to go below current window
O.splitright = true -- force all vertical splits to go to the right of current window
O.swapfile = false -- creates a swapfile
O.termguicolors = true -- set term gui colors (most terminals support this)

-- O.timeoutlen = 300 -- time to wait for a mapped sequence to complete (in milliseconds)

O.title = true -- set the title of window to the value of the titlestring
--
-- O.undodir = utils.join_paths(get_cache_dir(), "undo") -- set an undo directory
O.undofile = true -- enable persistent undo
O.updatetime = 300 -- faster completion
O.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
O.expandtab = true -- convert tabs to spaces
O.shiftwidth = 4 -- the number of spaces inserted for each indentation
O.tabstop = 4 -- insert 4 spaces for a tab
O.cursorline = true -- highlight the current line
O.number = true -- set numbered lines
O.relativenumber = false -- set relative numbered lines
O.numberwidth = 4 -- set number column width to 2 {default 4}
O.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time
O.wrap = false -- display lines as one long line
O.spell = false
O.spelllang = "en"
O.scrolloff = 4 -- is one of my fav
O.sidescrolloff = 4

vim.api.nvim_command('set nofoldenable')
vim.api.nvim_command('set nocompatible')

all my plugins

return require('packer').startup(function(use)
  -- Packer can manage itself
  use 'wbthomason/packer.nvim'
  -- Theme
  use 'folke/tokyonight.nvim'
  -- Status line
  use {
    'glepnir/galaxyline.nvim',
      branch = 'main',
      -- some optional icons
      requires = {'kyazdani42/nvim-web-devicons', opt = true}
  }
  -- Buffer
  use "romgrk/barbar.nvim"
  -- For hex color
  use 'norcalli/nvim-colorizer.lua'
  -- File explorer
  use {
    'kyazdani42/nvim-tree.lua',
    config = function ()
      require('plugins.nvimtree').setup()
    end,
    requires = 'kyazdani42/nvim-web-devicons'
  }
  -- find file
  use {
    'nvim-telescope/telescope.nvim',
    requires = { {'nvim-lua/plenary.nvim'} }
  }
  use 'nvim-lua/popup.nvim'
  use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }
  -- Comment
  use 'numToStr/Comment.nvim'
  use 'JoosepAlviste/nvim-ts-context-commentstring' -- comment chuan hon

  -- Neovim LSP
  use 'neovim/nvim-lspconfig'
  -- use {
  --   'jose-elias-alvarez/null-ls.nvim',
  --   config = function ()
  --     require('plugins.null-ls').setup()
  --   end,
  --   requires = 'nvim-lua/plenary.nvim'
  -- }
  -- Tab/Auto completion
  use 'hrsh7th/nvim-cmp'
  use 'hrsh7th/cmp-nvim-lsp'
  use 'hrsh7th/cmp-buffer'
  use 'hrsh7th/cmp-path'
  -- use 'hrsh7th/cmp-cmdline'
  use 'antoinemadec/FixCursorHold.nvim'

  -- snippets
  -- use 'hrsh7th/cmp-vsnip'
  -- use 'hrsh7th/vim-vsnip'
  use 'L3MON4D3/LuaSnip'
  use 'saadparwaiz1/cmp_luasnip'
  use "rafamadriz/friendly-snippets" -- snippets co san
  -- lsp installer
  use 'williamboman/nvim-lsp-installer' -- trinh quan ly lsp
  -- Auto pairs '', "", [], {}, (), ``
  use 'windwp/nvim-autopairs'
  -- For indent line
  use 'lukas-reineke/indent-blankline.nvim'
  -- For nice highlighting
  use {
    'nvim-treesitter/nvim-treesitter',
    -- run = ':TSUpdate'
  }
  -- matchup
  use {
    'andymass/vim-matchup',
    config = function ()
      CMD[[let g:matchup_surround_enabled = 1]]
    end
  }
  -- Smooth scrolling
  use {
    'karb94/neoscroll.nvim',
    config = function ()
      require('neoscroll').setup()
    end
  }
  -- Tmux navigator
  use 'christoomey/vim-tmux-navigator'
  -- Git
  use "lewis6991/gitsigns.nvim"
  -- float terminal
  use 'akinsho/toggleterm.nvim'
  -- Hop, use for easy motion
  use {
    'phaazon/hop.nvim',
    setup = function ()
      require("keybinds").hop()
    end,
    config = function ()
      require('hop').setup()
    end
  }
  -- Auto tag
  use 'windwp/nvim-ts-autotag'
  --change (){}[], tag
  use 'tpope/vim-surround'
  -- using . repeat surround.vim
  use 'tpope/vim-repeat'
  -- highlight current word
  use {
    'RRethy/vim-illuminate',
    config = function ()
      vim.g.Illuminate_delay = 300
      vim.api.nvim_set_keymap('n', '<a-n>', '<cmd>lua require"illuminate".next_reference{wrap=true}<cr>', {noremap=true})
      vim.api.nvim_set_keymap('n', '<a-p>', '<cmd>lua require"illuminate".next_reference{reverse=true,wrap=true}<cr>', {noremap=true})
    end,
    requires = 'neovim/nvim-lspconfig'
  }

  -- Live server
  use 'turbio/bracey.vim'

end)
andymass commented 2 years ago

What exactly is not working?

Do I understand that if you do not set timeoutlen then it works fine?

tynguyen2k1 commented 2 years ago

When i set timeoutlen except for highlighting, all doesn't seem to work

andymass commented 2 years ago

I tried out the full config in a clean environment and everything seems to work both with and without timeoutlen, however it is very difficult to use text objects like a% and i%, they must be typed very fast.

I recommend not setting timeoutlen this low since it is difficult to press the consecutive keys this quickly.

Does this resolve the issue? Why do you need to set timeoutlen this small?