Skip to content

How to prevent inserting a space after the type? #2786

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

Closed
Eason0210 opened this issue Mar 16, 2022 Discussed in #2785 · 6 comments · Fixed by #2788
Closed

How to prevent inserting a space after the type? #2786

Eason0210 opened this issue Mar 16, 2022 Discussed in #2785 · 6 comments · Fixed by #2788
Labels
status: in discussion Not actionable, because discussion is still ongoing or there's no decision yet type: support User support tickets, questions, help with setup etc.

Comments

@Eason0210
Copy link

Eason0210 commented Mar 16, 2022

Discussed in #2785

Originally posted by Eason0210 March 16, 2022
I use Emacs + eglot + company + yasnippet, when I insert the name of a type( Int Double or Float), HLS will insert a space after it.
Any one known how to disable this feature?

For example: I input length' :: [Int] , and I will get length' :: [Int ]

image image

The same issue also happened on vscode

From the EGLOT event log, you can see HLS return is "Int "

 [stderr] 2022-03-16 17:40:00.516289 [ThreadId 171] INFO hls:	finish: Completion (took 0.00s)
[server-reply] (id:2) Wed Mar 16 17:40:01 2022:
(:id 2 :jsonrpc "2.0" :result
     (:isIncomplete t :items
                    [(:detail ":: Type" :documentation
                              (:kind "markdown" :value "*Imported from 'Prelude'*\n* * *\n\n")
                              :insertText "Int " :insertTextFormat 2 :kind 22 :label "Int" :sortText "00")
                     (:detail ":: Type" :documentation
                              (:kind "markdown" :value "*Imported from 'Prelude'*\n* * *\n\n")
                              :insertText "Integer " :insertTextFormat 2 :kind 22 :label "Integer" :sortText "01")
                     (:detail ":: Type -> Constraint" :documentation
                              (:kind "markdown" :value "*Imported from 'Prelude'*\n* * *\n\n")
                              :insertText "Integral ${1:Type}" :insertTextFormat 2 :kind 8 :label "Integral" :sortText "02")

# .... more ....

Emacs 29.0.50
Mac OS 12.3
HLS: 1.6.1.0

@July541
Copy link
Collaborator

July541 commented Mar 16, 2022

I think you've enabled "haskell.plugin.ghcide-completions.config.snippetsOn": true by default, it will insert some snippets to be convenient for your next step, consider setting this field to false to disable it(This field may be a little different depending on your editor). Here docs may useful: https://haskell-language-server.readthedocs.io/en/latest/configuration.html#generic-server-options

@Eason0210
Copy link
Author

Hi @July541 , Thanks for your information.

If I understand correctly, with "haskell.plugin.ghcide-completions.config.snippetsOn": false, I won't be able to use the snippet feature.

I was wondering, is it possible for the server to return a string without spaces (Just "Int" for example) while enabling the snippet feature.

I'm curious, why HLS need to return an extra space?

@ksqsf
Copy link

ksqsf commented Mar 16, 2022

+1 for not inserting spaces by default.

@drsooch drsooch added type: support User support tickets, questions, help with setup etc. status: in discussion Not actionable, because discussion is still ongoing or there's no decision yet labels Mar 16, 2022
@July541
Copy link
Collaborator

July541 commented Mar 16, 2022

I'm curious, why HLS need to return an extra space?

An extra space left because there is no argument for Int.

The only thing I can think of is entering multiple parameters in succession, but it also annoying for the last param, I'll delete the space before going to the next line.

Agree to remove the space while no arguments.

@Eason0210
Copy link
Author

@July541 Thanks for your explanation.

The only thing I can think of is entering multiple parameters in succession, but it also annoying for the last param, I'll delete the space before going to the next line.

Recently, I will use formatting tools to handle the unused spaces.

Agree to remove the space while no arguments.

Indeed, this would be a small enhancement when input these type keywords without arguments.

@michaelpj
Copy link
Collaborator

This just seems like a bug, tbh? Maybe something around here https://github.com/haskell/haskell-language-server/blob/master/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs#L262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in discussion Not actionable, because discussion is still ongoing or there's no decision yet type: support User support tickets, questions, help with setup etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants