Closed oblitum closed 8 years ago
Thanks for the issue report! Always excited to add support for a new language.
Would you mind telling me how to install the dependencies required to run pulp psci
, preferably on OS X? I'm a bit unfamiliar with PureScript's tooling.
There're precompiled binaries here: http://www.purescript.org/download/. Sorry but I'm on ArchLinux and here it's as easy as pacman -S purescript pulp
.
It's also available from NPM.
Ah, the download page says it's on homebrew as well!
http://www.purescript.org/learn/getting-started/ tells the initial steps to get to the pulp psci
command.
Seems to be working on my end, with your exact config:
The error message could use some touching up, but that's what preprocess is for.
Note I had to pulp init
, and it only worked in that directory (which is the desired behavior, since it's supposed to mimc the underlying interpreter). It also is not instantaneous because pulp psci
takes a little while to start up, and the interpreter is started from scratch every time. Are you able to reproduce this?
The error message could use some touching up, but that's what preprocess is for.
Yes, I thought about that too, I'm interested in that.
Are you able to reproduce this?
Sadly no, I get almost no feedback, I just get the "No matching autocommands" message from vim.
Interesting... could you post your Vim and script
versions? And perhaps record a screencast with asciinema if possible? Please show a successful run of pulp psci
before you run vim -c 'Codi purescript'
.
Regarding preprocess, you can basically clean up the output of the interpreter before it's handed off to the formatter, to git rid of messages that aren't useful. I currently have a line-wise preprocessor API, but I will probably have to change it to a buffer-wise API to accommodate multi-line error messages.
This is my asciinema, it contains the vim version too: https://asciinema.org/a/bmmdzcgmiaheo3adwigsjq4bp
It appears that Python isn't working quite correctly either (4 doesn't show up). Can you paste the output of man script
? I'm interested in the date, since old versions of script
have been an issue.
script --version
script from util-linux 2.28
Python is working AFAIK, 4 is shown in the asciinema, maybe you have to replay it because this tool seems to cut some frames at random.
By the way. The date at the bottom of man script
is June 2014.
It comes from this package on ArchLinux: https://www.archlinux.org/packages/core/i686/util-linux/
Ah, I see that the text is a little cut off on the side on Asciinema - I believe you that it works correctly though. In any case, I'm able to reproduce the issue on my Ubuntu VM, and it has to do with script
and/or Vim's job system not liking the space in pulp psci
. The intermediate output is something like:
script -qfec 'pulp psci' /dev/null
bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 1: syntax error: unexpected end of file
...which is odd, since there is clearly a matching end quote. I haven't found a solution yet, but just wanted to give an update.
Thanks for the report.
You're on the track but weirdly for me here on ArchLinux your command script -qfec 'pulp psci' /dev/null
enters the REPL without problems. Anyway, I then created a script pulp_psci
that's just pulp psci
to try the plugin using a single command and it now started to work!
Some things I've noticed:
pulp psci
) flickers the buffer a lot.pulp_psci
, it seems a bit slow to get the result in the Vim buffer, not sure whether it's really slower than the REPL, which is not instant itself, but it seems so.As you said before:
It also is not instantaneous because pulp psci takes a little while to start up, and the interpreter is started from scratch every time.
That should be the reason why I'm seeing this slowness.
I've found a fix, it looks like an issue with the new job API from Vim, I think this should be fixed upstream.
Your script does:
let job = job_start(cmd, { 'callback': 'codi#__callback' })
where cmd
is 'script -qfec '.shellescape('pulp psci', 1).' /dev/null'
, which end up as "script -qfec 'pulp psci' /dev/null"
, since shellescape
will use single quotes, per docs, for strings containing whitespace. If you check :h job_start
:
[snip]
{command} can be a String. This works best on MS-Windows. On
Unix it is split up in white-separated parts to be passed to
execvp(). Arguments in double quotes can contain white space.
{command} can be a List, where the first item is the executable
and further items are the arguments. All items are converted
to String. *This works best on Unix*.
[snip]
Notice how the first paragraph seems incompatible with shellescape
given the arguments containing whitespace are expected with double-quotes.
Learning that I've then patched the script with the following:
let job = job_start('script -qfec "pulp psci" /dev/null', { 'callback': 'codi#__callback' })
Which, strangely, didn't work either! Since it's following the docs, looks like some bug, or just not to be used on Linux.
I've then followed the second paragraph and did:
let job = job_start(['script', '-qfec', 'pulp psci', '/dev/null'], { 'callback': 'codi#__callback' })
This worked! So, you should use job_start
that way for best compatibility with *nix.
cc @Shougo
cc @Shougo
Hi, what's?
@Shougo I've just cc you because I recall you implemented the job api on Vim right? It's just to inform you of these issues regarding commands containing whitespace/quotation.
Hm. OK. It should be reported to upstream. But to escape arguments is very difficult. I recommend for you to use the arguments list.
@oblitum Wow, I had no idea how I missed the list command form of job_start! That actually makes things a lot easier. Expect a commit addressing this soon.
@Shougo Thanks for chiming in and reporting :)
@oblitum Can you check out the user/metakirby5_2
branch (I sure am bad at naming) and see if it works for you?
@metakirby5 yes, it fixes.
Just a reminder that the spurious "No matching autocommands" message is still present.
The only thing I can think of that would be causing that is the user autocommands. I've added a wrapper around the triggers which checks if they exist - can you pull again and see if it resolves the issue?
Sadly it didn't work, the message still shows up.
One thing though. I've noticed the message shows up for :Codi purescript
and not for :Codi python
, despite the last commit being applied or not.
That's certainly interesting... would you happen to have any other plugins installed for the purescript
filetype? Could you try running :Codi purescript
using a .vimrc
that contains nothing but the Codi-related plugin calls and settings?
Spot on, I've tried here and found out that the message shows up only when FrigoEU/psc-ide-vim is on my plugin list. I've then removed code.vim from the plugin list while leaving just psc-ide-vim and tried set ft=purescript
just after opening vim and the message appeared. So, this is a psc-ide-vim issue.
Great that we've isolated the problem! I'll go ahead and merge this in and close the issue.
OK. Thanks for the help! Feel free to embed PureScript support.
I think I'll actually leave PureScript out due to the caveat of requiring a pulp init
. Since Codi is meant to be a scratchpad, it should ideally work anywhere as long as you have the interpreter. If there is enough demand for languages that require similar prerequisites, I'll give it some more thought :)
OK. Just like to comment that in PureScript development, AFAIK, it's always expected to run REPL inside a project, so it's not a problem to expect that from the user. In PureScript one starts the REPL in context with a project to try out importing its own code/library and playing with it.
Hmm... seems reasonable. However, running :Codi purescript
outside of a project provides no indication of what's not working, which is problematic for built-in behavior. I think I might need to add an optional 'precondition' which allows user-defined checking of dependencies such as having run pulp init
. Since PureScript is the only language which requires this particular attribute, I don't want to introduce this quite yet. I'll open up an enhancement issue for this, though!
OK. Thanks anyway, being configurable as it is is a pretty good option.
For information. The vim message issue has been fixed in the affected plugin https://github.com/FrigoEU/psc-ide-vim/issues/17
I'm not having success trying a setup for PureScript (the plugin is working for Python as expected). I've put this snippet in my
.vimrc
:When I open vim and execute
:Code purescript
I get a message "No matching autocommands" and nothing happens when I write code. An example session of PureScript REPL is like the following:Any help appreciated!