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

feat: add finder option for choosing a preferred finder backend (#129) #130

Merged

Conversation

idanarye
Copy link
Contributor

@idanarye idanarye commented May 7, 2023

No description provided.

@idanarye idanarye force-pushed the allow-configuring-the-finder-in-the-plugin-setup branch 2 times, most recently from 5404f5a to 7983737 Compare May 7, 2023 14:07
Copy link
Owner

@epwalsh epwalsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @idanarye, I really like the approach you took. Only minor comments. 👍

doc/obsidian.txt Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
end
choose_template()
return true
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should explicitly return false if has_telescope is false, and same for the others below. Just for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I also verify in run_first_supported that the returned value is boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to throw a magic value from skipped implementations. That way run_first_supported can return the value of the implementation that succeeded.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to throw a magic value from skipped implementations. That way run_first_supported can return the value of the implementation that succeeded.

I like that idea 👍

@idanarye idanarye force-pushed the allow-configuring-the-finder-in-the-plugin-setup branch 3 times, most recently from 8983f44 to 71bf489 Compare May 10, 2023 17:28
Copy link
Owner

@epwalsh epwalsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @idanarye, just a minor suggestion to make util.run_first_supported more readable.

Comment on lines +459 to +465
local result = { pcall(impl_function) }
if result[1] then
return select(2, unpack(result))
elseif result[2] == IMPLEMENTATION_UNAVAILABLE then
table.insert(unavailable, impl_name)
else
error(result[2])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

Suggested change
local result = { pcall(impl_function) }
if result[1] then
return select(2, unpack(result))
elseif result[2] == IMPLEMENTATION_UNAVAILABLE then
table.insert(unavailable, impl_name)
else
error(result[2])
local supported, result = pcall(impl_function)
if supported then
return result
elseif result == IMPLEMENTATION_UNAVAILABLE then
table.insert(unavailable, impl_name)
else
error(result)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then we won't be able to use multiple returns from the implementation functions. _run_with_finder_backend doesn't use that (it doesn't even return a single value), but run_first_supported is a library function so I tried to make it as generic as possible.

Then again, maybe I'm just prematurely generalizing things...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, I see. Ok this is fine with me

@epwalsh
Copy link
Owner

epwalsh commented May 11, 2023

Looks like there's a styling and linting issue

@idanarye idanarye force-pushed the allow-configuring-the-finder-in-the-plugin-setup branch from 71bf489 to e2c04c4 Compare May 11, 2023 10:31
@idanarye idanarye force-pushed the allow-configuring-the-finder-in-the-plugin-setup branch from 3a3dd51 to 7b07a6c Compare May 11, 2023 10:58
@idanarye
Copy link
Contributor Author

@epwalsh There is one warning left, but it was not introduced by this PR (main has it: https://github.com/epwalsh/obsidian.nvim/actions/runs/4939421696/jobs/8830150709)

@epwalsh
Copy link
Owner

epwalsh commented May 11, 2023

Ah, sorry about that. Fixed.

Copy link
Owner

@epwalsh epwalsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@epwalsh epwalsh merged commit 1a9ec65 into epwalsh:main May 11, 2023
flaviosakakibara pushed a commit to flaviosakakibara/obsidian.nvim that referenced this pull request Sep 5, 2023
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

Successfully merging this pull request may close these issues.

2 participants