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

Dynamically set the prompt regex #79

Open
rdnetto opened this issue Aug 6, 2017 · 3 comments
Open

Dynamically set the prompt regex #79

rdnetto opened this issue Aug 6, 2017 · 3 comments
Labels
help wanted needs-design This issue needs some amount of design consideration before it's ready to work on

Comments

@rdnetto
Copy link
Collaborator

rdnetto commented Aug 6, 2017

Many people users have a custom prompt set, but it's not obvious that the regex needs to be configured, or that that's the source of the problem (see #74).

Rather than relying on the assumption that the prompt contains a >, we should just parse ~/.ghci and set it to something sane. Note that we'll need to handle the various escape sequences GHCi allows.

@parsonsmatt
Copy link
Owner

I'm not sure I'm a big fan of this. Users can set a prompt in ~/.ghci or ./.ghci, and they can also call :set prompt "lmao" at any point in the REPL. I'd rather set the REPL prompt on initialization to something we can control and discourage users from changing it.

Intero> your code here

seems like a reasonable thing IMO.

@rdnetto
Copy link
Collaborator Author

rdnetto commented Dec 3, 2017

I'm not sure I'm a big fan of this. Users can set a prompt in ~/.ghci or ./.ghci, and they can also call :set prompt "lmao" at any point in the REPL.

Iterating over the possible files should be fairly trivial. I agree that users manually setting the prompt will break this, but it seems like quite a corner case. (We could fix this easily by adding a handler for :set prompt similar to the existing one for :reload which populates quickfix, but I'm not sure if it's worth the effort).

I'd rather set the REPL prompt on initialization to something we can control and discourage users from changing it.

It looks like the best way to do this would be to use --ghci-script, which allows us to run a script after .ghci, etc.

The second approach is considerably simpler, but means users lose the ability to have a coloured prompt which matches their colour scheme. e.g. I use :set prompt "\ESC[38;2;255;100;0mλ> \ESC[m" to render λ> in orange. A better long-term solution for this use case would be to add a file type with syntax highlighting for the Intero session, which would also enable better highlighting of error messages. (Though maybe GHCi will colour these automatically in the future, making the point moot.)

tldr; forcing the prompt sounds good to me (though maybe to λ> for the screen space impaired), existing functionality/hacks broken by it have better solutions.

EDIT: Actually, looks like GHC 8.2 colorizes the error messages in GHCi too, so the prompt is all we care about for now.

@parsonsmatt parsonsmatt added help wanted needs-design This issue needs some amount of design consideration before it's ready to work on labels Apr 21, 2018
@lucc
Copy link

lucc commented Nov 11, 2018

For all those who struggle with their custom prompt and find this issue here is one way to put to use what @rdnetto said above:

In your neovim config do

Plug 'parsonsmatt/intero-neovim' " or whatever plugin manager you use
let g:intero_ghci_options = '-ghci-script ' . expand('~/.ghc/intero.conf')
let g:intero_prompt_regex = "Intero> "

And create the file ~/.ghc/intero.conf with these contents:

-- A special config file for use with interor in neovim
:set prompt "Intero> "

Obviously the file can also be somewhere else apart from ~/.ghc/intero.conf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted needs-design This issue needs some amount of design consideration before it's ready to work on
Projects
None yet
Development

No branches or pull requests

3 participants