Sublime Forum

Why does SublimeREPL autofill this code?

#1

I’m trying to run the main method of a Haskell file, but when I type
“main” and hit enter it autofills this dumb example code.

The first run is the problem, the second run is me hitting escape before hitting enter and getting the intended result.

How can I stop this? It’s getting annoying. Thanks so much.

0 Likes

#2

The problem is not with SublimeREPL, but with a snippet in the Haskell syntax file called
Main.sublime-snippet. You would have to modify or delete this snippet.

0 Likes

#3

Thanks for the reply.

Where can I find the Haskell syntax file? I searched in the Haskell folder in my Library (using macOS), but I couldn’t find anything quite applicable. Any ideas?

0 Likes

#4

You can use PackageResourceViewer to extract the snippet and edit it (install via Package Control). But it’s actually a lot easier to do one of the following:

  • When the snippet pops up, if you want the literal text main rather than the snippet, just ESC out of the pop-up, rather than hitting Return immediately
  • Disable auto-hinting on snippets and tokens. This is the option I use. It’s as simple as adding "auto_complete": false to your preferences file
0 Likes

#5

[quote=“connorg, post:3, topic:22930, full:true”]

Where can I find the Haskell syntax file?
[/quote]st
It’s in the Packages folder inside the Sublime Text program folder. On Windows, ST would be inside the Programs folder (64 bits). I don’t know where it would be on a Mac. Perhaps a Mac user can tell you.

If you use Package Resource Viewer, you will get a list of the Package files, and you can pick the Haskell syntax file.

0 Likes

#6

Thanks, I installed the plugin and managed to delete all of the snippets. Now the “main” suggestion has disappeared and the “Main” one is highlighted instead, which gives me:

<interactive>:5:1: error: • Data constructor not in scope: Main • Perhaps you meant variable ‘main’ (line 8)

That’s not a snippet that I can see. Do you have any idea what’s causing that? Thanks so much for your continued help.

0 Likes

#7

Please see my response to Jackeroo, I know it’s such a small thing but I don’t want to have to escape out every time I run a program. I also like the idea of having the autocomplete on, but I’ll turn it off if I can’t resolve my new issue.

0 Likes

#8

Sorry, I don’t work with Haskell. Probably just modifying the main snippet would have worked by taking out the “Hello World” part. Or there could be some other problem in your program.

0 Likes

#9

The following setting may be something you want to consider turning on:

// By default, auto complete will commit the current completion on enter.
// This setting can be used to make it complete on tab instead.
// Completing on tab is generally a superior option, as it removes
// ambiguity between committing the completion and inserting a newline.
"auto_complete_commit_on_tab": false,

As noted in the comment, this setting defauls to false. If you set this to true you will need to press Tab instead of Enter to insert a completion, which as you’ve noticed is somewhat ambiguous and a pain in the butt. With this setting on you could restore the snippet that you removed above because it won’t complete accidentally.

0 Likes