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

Refactor fs.fnl to use nvim 0.8 builtins #630

Merged
merged 1 commit into from
Dec 22, 2024

Conversation

saccarosium
Copy link
Contributor

@saccarosium saccarosium commented Dec 15, 2024

Hi,
I've seen that in the README was stated that Conjure works with neovim 0.7 or above. I've found in fs.fnl that vim.fse.normalize is been used, witch is a nvim 0.8+ feature so I've updated the minimum version required in the README and plugin/conjure.vim. With this version bump we unlock a lot of functionality that can replace some of the old batteries that were created.

I've also took the liberty to convert the plugin/conjure.vim to lua so we can use vim.notify instead of echoerr. vim.notify can integrate with other plugins and change the displaying of notifications (see example noice.nvim)

@saccarosium saccarosium force-pushed the cleanup-old-batteries branch from 9a173e0 to d6dcdbc Compare December 15, 2024 22:27
@saccarosium saccarosium force-pushed the cleanup-old-batteries branch from d6dcdbc to b785a53 Compare December 15, 2024 22:33
(local config (autoload :conjure.config))

(local path-sep (if (= jit.os :Windows) "\\" "/"))
Copy link
Owner

Choose a reason for hiding this comment

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

This is implemented in nfnl.fs/path-sep as a function. I'll replace this though, no biggie!

(fn env [k]
(let [v (nvim.fn.getenv k)]
(let [v (vim.fn.getenv k)]
Copy link
Owner

Choose a reason for hiding this comment

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

Good call, I like these getting replaced with the built in API now.

(text.ends-with file-path (.. mod-path ".fnl"))
(text.ends-with file-path (.. mod-path "/init.fnl")))
(vim.endswith file-path (.. mod-path ".fnl"))
(vim.endswith file-path (.. mod-path "/init.fnl")))
Copy link
Owner

Choose a reason for hiding this comment

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

Oh this is a new one to me.

require("conjure.main").main()
else
vim.notify_once("Conjure requires Neovim > v0.8", vim.log.levels.ERROR)
end
Copy link
Owner

Choose a reason for hiding this comment

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

Sweet, didn't realise we could use a Lua file here!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can use a lua in every directory in the runtimepath. I think this was added in 0.5.0 (don't quote me on that ;) )

@Olical Olical merged commit b785a53 into Olical:main Dec 22, 2024
2 checks passed
@Olical
Copy link
Owner

Olical commented Dec 22, 2024

Lovely, thanks!

@saccarosium
Copy link
Contributor Author

I you are ok with it I can make other PRs to move the code to built in APIs.

I'm quite familiar with neovim std library so I can help.

My question would be do we have a clear minimum nvim version that we are targeting? For reference usually plugin authors supports the current stable release (now 0.10.*) and maybe the previous (now 0.9).

@Olical
Copy link
Owner

Olical commented Dec 23, 2024

So I've been trying to support as far back as I can without it causing headaches with lots of polyfilling and if statements in the code. There are some branches where I have to support two different APIs but not many. In hindsight I should've collected all version support branches in a specific module that makes it VERY obvious for when those things get removed.

I worry about targeting stable because I'll be fine on Arch but our Ubuntu brothers and sisters might be a little upset about that if we don't have a good reason for it. Version churn for the sake of churn smells a little too npm for my liking so I try to avoid it.

So, that is to say, lets try to support at LEAST the previous version, hopefully further back if possible. But this is all extremely subjective, we have to go with our gut. If we drop support for 0.8 in favour of 0.9 but the code looks identical if you squint and there's no benefit to the user, we shouldn't do it.

If however we get things like first class Lua callbacks and can eliminate all the Vim Script bridge code with string interpolation all over the place, then we should DEFINITELY do that. Which is a thing I did a while back, dropping support for old versions in order to remove the hacky Vim -> Lua callbacks through strings was DEFINITELY worth it. This is just an example to highlight the sort of big improvements I think are definitely worth it, but we can judge it on a case by case basis.

So, please feel free to drop usage of my custom Fennel in favour of built in APIs! If it will break support for older versions though let's weigh that up carefully against the need to move the version support line only when we need to, not because we want to.

@saccarosium
Copy link
Contributor Author

Ok, gotcha! I do believe that sticking with 0.8 is really a good sweet spot.

In hindsight I should've collected all version support branches in a specific module that makes it VERY obvious for when those things get removed.

I do believe that centralize the polyfills can be a good thing to make the transition easier in the future.

Also do we bother with native Windows support? Looking at the code we are very UNIX biased. I don't care about it but if you care I can also backport some of the latest fs.* stuff from neovim 0.10 that helps a lot with Windows support.

@Olical
Copy link
Owner

Olical commented Dec 24, 2024 via email

@saccarosium
Copy link
Contributor Author

I'm useless with dev tooling on windows.

We are in the same boat I'm afraid

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