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

How to disable autoimport #1505

Open
GNSubrahmanyam opened this issue Jul 11, 2020 · 13 comments
Open

How to disable autoimport #1505

GNSubrahmanyam opened this issue Jul 11, 2020 · 13 comments

Comments

@GNSubrahmanyam
Copy link

@fbricon @snjeza
Editor: Monaco editor
language client: Monaco language client
In our use case we want to disable autoimport. How to stop sending completionItem/resolve
image

@snjeza
Copy link
Contributor

snjeza commented Jul 11, 2020

@GNSubrahmanyam you can try the following settings:

"java.completion.enabled": false,

@GNSubrahmanyam
Copy link
Author

GNSubrahmanyam commented Jul 11, 2020

@snjeza In that case no auto complete is coming. We need autocomplete. We want to disable auto import statements

image

@fbricon
Copy link
Contributor

fbricon commented Jul 11, 2020

It's not possible to disable automatic type import at that point. Can you explain how auto import is a problem in monaco?

@GNSubrahmanyam
Copy link
Author

image
In our use case we locked few lines in code editor. Where candidates or learners will write code in editable part. While typing candidates or learners selects method from the codeCompleteItem (Example: StreamDecoder from com.oracle.webservices.internal.impl.internalspi.encoding.* it automatically imports com.oracle.webservices.internal.impl.internalspi.encoding.)
image

It mess up the whole codelock feature.

@GNSubrahmanyam
Copy link
Author

@fbricon Is there any way to suggest method autocomplete for imported packages only?

@GNSubrahmanyam
Copy link
Author

@fbricon Any updates how we can achieve this?

@GNSubrahmanyam
Copy link
Author

@fbricon Found a solution

import { has, get, map, omit, set} from "lodash";
import * as rpc from "vscode-ws-jsonrpc";
export const launch = (request: http.IncomingMessage, socket: rpc.IWebSocket) => {
if (rpc.isResponseMessage(message)) {
          if (typeof message.result === 'object' && has(message.result, 'isIncomplete')) {
            let items = map(get(message.result, 'items'), (item) => {
              if (has(item, 'additionalTextEdits')) {
                item = omit(item, 'additionalTextEdits')
                return item;
              }
              return item;
            })

            set(message.result, 'items', items)

          }
        }

@fbricon
Copy link
Contributor

fbricon commented Jul 13, 2020

interesting, where do you put that code?

@GNSubrahmanyam
Copy link
Author

@GNSubrahmanyam
Copy link
Author

Am i doing right ? By omitting additionalTextEdits

@fbricon
Copy link
Contributor

fbricon commented Jul 13, 2020

that's very, very hacky. I'm not sure but other things than import statements might be sent as additional textedits.

@GNSubrahmanyam
Copy link
Author

True, In our case we don't want auto import. What are other alternative to achieve this ?

@pawansingh00
Copy link

@GNSubrahmanyam Hi can you please help me with the configs used to make it work with monaco-languageclient?
To ve more specific - How to modify this line --https://github.com/TypeFox/monaco-languageclient/blob/69f41d2c2d9b37bcbb9a080d86ec2eed838d6885/example/src/json-server-launcher.ts#L19

to make it work with -- this java lsp.

And do we need any other chnages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants