Improving code completion

#1

I’m using VSCode with the PureScript IDE plugin. It autocompletes some things like reference to top-level declarations, but it would be nice if it also supported things like autocompleting function params within a function definition, local variables, and dotting record variables. Is this something that would need to be implemented in psc-ide? Is that what’s responsible for the :complete command in the REPL?

1 Like
#2

I think some sort of implementation just requires doing the work, yes. We don’t have a lenient parser though, so it would only work if your file fully parses. Completion for records would require a full typecheck, and in general the compiler doesn’t preserve all the information the ide would need within the externs to do local type resolution.

#3

What are the “externs”?

Since the file needs to fully parse maybe there could be some way of disregarding parts that are incomplete.

A somewhat related feature is having some way to get type information for local variables/params on hover in an editor.

#4

During compilation, the compiler writes an externs file out alongside the output javascript for each module. It contains information about the external API of the module (hence the name “externs”): what values, types, classes etc. it defines, and what their types are. This allows the compiler to avoid re-type-checking that module in subsequent compiles if it hasn’t changed.

2 Likes
#5

Here’s some additional discussion on autocomplete, specifically for records.

This is a reasonable desire but I think really depends on enhanced compiler support with AST based type information for starters. If and when such compiler work is done I’m sure that will make it into editor extensions.