kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
3.18k stars 62 forks source link

Custom separator doesn't work #61

Closed mawkler closed 2 years ago

mawkler commented 2 years ago

Checklist

Describe the bug

I'm trying to create my own custom separator *, for instance to remove italics in markdown files, but it doesn't work. Here's my config:

require('nvim-surround').setup({
  delimiters = {
    separators = {
      ['*'] = { '*', '*' },
    },
  },
})

To Reproduce

  1. Surround a word with * using ysiw*
  2. Delete surrounding *s using ds*
  3. *s are not deleted

Full config to reproduce:

Click to expand ```lua -- Ignore default config and plugins vim.opt.runtimepath:remove(vim.fn.expand('~/.config/nvim')) vim.opt.packpath:remove(vim.fn.expand('~/.local/share/nvim/site')) -- Append test directory local test_dir = vim.fn.expand('~/code-other/nvim-test-config') vim.opt.runtimepath:append(vim.fn.expand(test_dir)) vim.opt.packpath:append(vim.fn.expand(test_dir)) -- Install packer local install_path = test_dir .. '/pack/packer/start/packer.nvim' local install_plugins = false if vim.fn.empty(vim.fn.glob(install_path)) > 0 then vim.cmd('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path) vim.cmd('packadd packer.nvim') install_plugins = true end local packer = require('packer') vim.g.mapleader = ' ' packer.init({ package_root = test_dir .. '/pack', compile_path = test_dir .. '/plugin/packer_compiled.lua' }) packer.startup(function() function Use(module) use(require(string.format('configs.%s', module))) end -- Packer can manage itself packer.use 'wbthomason/packer.nvim' -- Plugins: use { 'kylechui/nvim-surround', config = function() require('nvim-surround').setup({ delimiters = { separators = { ['*'] = { '*', '*' }, }, }, }) end } if install_plugins then packer.sync() else -- load plugins at your earliest convenience vim.defer_fn(function() vim.cmd('doautocmd User LoadPlugins') end, 1) end end) vim.o.termguicolors = true vim.keymap.set('n', '', 'qa') ```

Expected behavior

*s get deleted.

mawkler commented 2 years ago

Also, perhaps there should be a fallback for ydsx/ycsx, to handle any non-configured character x by interpreting it as a separator?

kylechui commented 2 years ago

Also, perhaps there should be a fallback for ydsx/ycsx, to handle any non-configured character x by interpreting it as a separator?

The current default actually is to treat the character as a separator, see #59 for details. As for deletion, it doesn't yet work with non-buitlin textobjects, e.g. va* is not a thing either. However, this might become a thing in the near-future, if #60 pans out properly.

kylechui commented 2 years ago

Merging this issue into #60.