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

Add plugin command support for nix repl #3934

Closed
wants to merge 2 commits into from
Closed

Conversation

lf-
Copy link
Member

@lf- lf- commented Aug 15, 2020

Motivation: I want to make https://github.com/lf-/nix-doc a repl command, but it is useful to be able to extend the REPL otherwise.

Side note: In case my documentation changes look weird, there was an error in the documentation, which previously claimed that RegisterCommand was possible from a plugin, which it is not, because it is in src/nix and thus cannot be linked to by a library since that directory only links into an executable. I encountered this myself when initially implementing this feature and that is why I had to refactor the REPL logic out into libexpr.

  • Refactor the repl core into libexpr
  • Use dependency injection via std::function to provide the completion
    functions from editline so we don't introduce extra dependencies for
    libexpr
  • Add a RegisterReplCmd analogous to RegisterPrimOp for repl commands
  • Refactor: get rid of the "ugly" global curRepl and replace it with a
    trick with closures on the nix side (that are effectively globals
    [static vars in a templated function per-closure], but
    unique per repl user and thus not as ugly ;p)
  • Rip out readline support since there appears to be no build system
    support for it according to rg READLINE and it is thus dead code
  • Integration test this new plugin functionality
  • Document it (see above)

- Refactor the repl core into libexpr
- Use dependency injection via std::function to provide the completion
  functions from editline so we don't introduce extra dependencies for
  libexpr
- Add a RegisterReplCmd analogous to RegisterPrimOp for repl commands
- Refactor: get rid of the "ugly" global curRepl and replace it with a
  trick with closures on the nix side (that are effectively globals, but
  unique per repl user and thus not as ugly ;p)
- Rip out readline support since there appears to be no build system
  support for it and it is thus dead code
- Integration test this new plugin functionality
- Document it
@@ -558,6 +558,18 @@ Path getDataDir()
return dataDir ? *dataDir : getHome() + "/.local/share";
}

Strings editorFor(const Path & file, unsigned int line)
Copy link
Member Author

Choose a reason for hiding this comment

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

extracted because it needed to be available from libexpr and didn't inherently depend on any nix expression stuff

lf- added a commit to lf-/nix-doc that referenced this pull request Aug 22, 2020
NixOS/nix#3934 allows for custom REPL commands
to be added. This had my name on it in several regards ;-)
@stale
Copy link

stale bot commented Feb 13, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 13, 2021
@lf-
Copy link
Member Author

lf- commented Feb 13, 2021

I am not interested in pursuing these changes any further due to lack of feedback and potential future integration of a documentation system.

@lf- lf- closed this Feb 13, 2021
@lf- lf- deleted the repl-plugins branch May 22, 2024 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant