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

"Project-local" REPLs / dynamically detecting REPL settings? #195

Open
gwerbin opened this issue Sep 18, 2021 · 3 comments
Open

"Project-local" REPLs / dynamically detecting REPL settings? #195

gwerbin opened this issue Sep 18, 2021 · 3 comments

Comments

@gwerbin
Copy link

gwerbin commented Sep 18, 2021

Hi, thanks for the very useful plugin! I've found Iron to be a nice alternative to the (also excellent) Neoterm.

However, I don't see an obvious way to configure the REPL invocation dynamically.For example, I'd ideally like to have logic along these lines for a Python project (hypothetical code):

iron.core.add_repl_definitions({
  python = {
    dynamic = function(bufno)
      local venv_root = _py_find_venv_root()
      local pipenv_root = _py_find_pipenv_root()
      local pyproject_root = _py_find_pyproject_root()
      local poetry_root = _py_is_poetry(pyproject_root)

      local command
      if poetry_root then
        command = {"poetry", "run", "ipython", "--no-autoindent"}
      elseif pipenv_root then
        command = {"pipenv", "run", "ipython", "--no-autoindent"}
      elseif venv_root then
        command = {venv_root .. "/bin/ipython", "--no-autoindent"}
      end

      return {
        command = command
      }
    end
  }
})

I'd also want to do other things, like try to detect if ipython is available in the current env and use it only if present.

Is this kind of thing possible currently? It would be a really useful feature for working with GUI frontends to Neovim, which you don't necessarily want to have to start from within a shell session.

@hkupty
Copy link
Collaborator

hkupty commented Sep 20, 2021

I'm really glad iron is being useful for you!

I definitely think we wan get something dynamic working, but I don't think it was prioritized so far... Shouldn't be too hard to add there though..

I surely want to improve and make it easier for users to tailor the best possible individual experience, so dynamic configuration would definitely make sense, as well as providing functions for dynamically detecting binaries.

The issue is that, due to work and personal life, I couldn't focus on iron as much as it deserves. In fact, I'm super glad it is at a somewhat stable state now, because it is being useful for many people without needing patching or intense overlook from me. Hopefully I can change that situation in the future, but for now I can try to squeeze in a few improvements here and there.

I'll check if/how I can add dynamic config support. Thanks for the issue!

@gwerbin
Copy link
Author

gwerbin commented Sep 20, 2021

I totally understand your situation!

I started looking into the Iron source code and found it fairly readable. But I'm myself trying to spend more time with family and less time coding.

I think one thing that might help other people contribute would be some informal documentation of how Iron fits together internally, and what changes you already have planned. That way people don't have to spend as long familiarizing themselves with the codebase, and can do things like internal refactoring that won't be "offensive" or obstructive towards your other planned improvements.

@hkupty
Copy link
Collaborator

hkupty commented May 18, 2022

I've recently merged v3.0 which greatly simplifies how the repl is picked up. I can definitely foresee now adding repl providers instead of picking them up straight away. I'll bump this issue and try to fix this in the next iteration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants