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

Fly mode from inside a string #17

Closed
marlun opened this issue Mar 15, 2023 · 7 comments
Closed

Fly mode from inside a string #17

marlun opened this issue Mar 15, 2023 · 7 comments

Comments

@marlun
Copy link

marlun commented Mar 15, 2023

I often use the fly mode and it works great. It doesn't work inside strings and I understand why but wonder if it would be possible to configure so that it does? In other plugins it worked and I had to do ctrl-v) to add a ')' inside a string because otherwise I would jump to the wrapping ).

If possible I would appreciate a config example. I'm guessing you could use "list_of_characters" but I'm not sure how.

@altermo
Copy link
Owner

altermo commented Mar 15, 2023

Added a new configuration option for the extension fly called nofilter which disables filtering.

With this you can do something like:

extensions={
    --The other extensions
    {'fly',{')','}',']',' ',"'",'"',nofilter=true}},
}

@altermo altermo closed this as completed Mar 15, 2023
@marlun
Copy link
Author

marlun commented Mar 18, 2023

Might be that these two are working against each other and I'm just not understanding but now when I'm writing normal text in markdown and I hit ' I get '' which I didn't get before. Can I get both?

@altermo
Copy link
Owner

altermo commented Mar 19, 2023

Can you elaborate more specifically: can't reproduce glitch.

@marlun
Copy link
Author

marlun commented Mar 21, 2023

Before I only ran the setup function without any options:

use {
	'altermo/ultimate-autopair.nvim',
	event = { 'InsertEnter', 'CmdlineEnter' },
	config = function()
		require('ultimate-autopair').setup({
			-- extensions = {
			-- 	{ 'fly', { ')', '}', ']', ' ', "'", '"', nofilter = true } },
			-- }
		})
	end,
}

Now when writing in markdown files, I can write something like: That's nice without getting an extra ' in the end. However when I'm in code and I have something like require('ultimate-autopair|') (caret at "|"), if I hit ) I would get require('ultimate-autopair)') instead of jumping out: require('ultimate-autopair')|.

If I uncomment the option you gave me above I can jump out of require('ultimate-autopair') but when I write markdown I get That'' or rather That's nice' because I would continue writing after the first ' but the second one would be at the end when I'm done writing.

@altermo
Copy link
Owner

altermo commented Mar 21, 2023

Well... The current way to configure built-in extensions is stupid: When setting extension you overwrite the builtin extensions and thus need to include all the builtin extensions in the config (probably should fix this).
So width that in mind:

use{
    'altermo/ultimate-autopair.nvim',
    event={'InsertEnter','CmdlineEnter'},
    config=function ()
        require('ultimate-autopair').setup({
            extensions={
                {'cmdtype',{'/','?','@'}},
                'multichar',
                'string',
                {'treenode',{inside={'comment'}}},
                {'escape',{filter=true}},
                'rules',
                'filetype',
                {'alpha',{before={"'"}}},
                {'suround',{'"',"'"}},
                {'fly',{')','}',']',' ',"'",'"',nofilter=true}},
            },
        })
    end,
}

@marlun
Copy link
Author

marlun commented Mar 21, 2023

Ah, yes, that makes it a little harder BUT your above config seems to work. Thanks!

@marlun
Copy link
Author

marlun commented May 17, 2023

I'm writing in this closed issue because I'm getting the following when I'm opening neovim:

|| ultimate-autopair:
|| Old configuration detected
|| The problem:
|| extensions option needs updating (aborting)
|| packer.nvim: Error running config for ultimate-autopair.nvim: ...vim/lua/ultimate-autopair/configs/default/utils/init.lua:44: attempt to compare two nil values

Here's my current config again which you helped me with above:

require('ultimate-autopair').setup({
	extensions = {
		{ 'cmdtype',  { '/', '?', '@' } },
		'multichar',
		'string',
		{ 'treenode', { inside = { 'comment' } } },
		{ 'escape',   { filter = true } },
		'rules',
		'filetype',
		{ 'alpha',   { before = { "'" } } },
		{ 'suround', { '"', "'" } },
		{ 'fly',     { ')', '}', ']', ' ', "'", '"', nofilter = true } },
	},
})

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