Closed bujesse closed 8 months ago
Hmm good catch 🎣!
What do you think about custom languages overwriting the defaults rather than extending them as a solution?
I think all you have to do is change the order of the table merge so that user configs for a given language would take priority over the plug-in configuration.
And then maybe add something to the readme explaining this in case another fish user comes along.
I could create a PR if you like.
That'd be great, cheers!
Wow what good timing, I just tried out the plugin and needed Fish support! For those coming later, here is an example config for making it work with Python:
telescope.setup {
extensions = {
import = {
insert_at_top = true,
custom_languages = {
{
regex = [[(?m)^(?:from[ ]+(\S+)[ ]+)?import[ ]+(\S+)[ ]*\$]], -- Note the escaped $
filetypes = { 'python' },
extensions = { 'py' },
},
},
},
},
}
Thanks for the awesome plugin @piersolenski, and thanks for the timely PR @bujesse!
Fish shell considers
$
inside double-quotes as a special character and thus needs to be escaped.It produces this error:
There are 2 ways to fix this; either detect the current shell and apply an escaped version if fish, or allow users to override the default language settings.
I tried to do the second approach, but looking at the code, I think only the first matching filetype config gets returned; and the default built-in ones come first: https://github.com/piersolenski/telescope-import.nvim/blob/0270f1438c0ac91663146a73a213bfdc536a8cb5/lua/import/utils.lua#L52 https://github.com/piersolenski/telescope-import.nvim/blob/0270f1438c0ac91663146a73a213bfdc536a8cb5/lua/import/picker.lua#L12
I have this fixed locally by just prepending a backslash directly in the plugin code, but just wanted to raise this if others encounter this issue.