Skip to content

How to disable lsp-completion on code comment ? #2215

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
zhangjie2012 opened this issue Sep 29, 2020 · 6 comments
Closed

How to disable lsp-completion on code comment ? #2215

zhangjie2012 opened this issue Sep 29, 2020 · 6 comments

Comments

@zhangjie2012
Copy link

My setting about completion:

lsp-completion-enable t
lsp-completion-enable-additional-text-edit nil

When input any char, alway complete, is that a bug ?

image

@kiennq
Copy link
Member

kiennq commented Sep 29, 2020

No, it's not a bug. It seems you're using lsp-go client, which enable completion-in-comment.

@zhangjie2012
Copy link
Author

Your are right, I found code in lsp-go.el

(lsp-register-client
 (make-lsp-client :new-connection (lsp-stdio-connection
                                   (lambda () (cons lsp-go-gopls-server-path lsp-go-gopls-server-args)))
                  :major-modes '(go-mode)
                  :language-id "go"
                  :priority 0
                  :server-id 'gopls
                  :completion-in-comments? t
                  :library-folders-fn #'lsp-go--library-default-directories
                  :after-open-fn (lambda ()
                                   ;; https://github.com/golang/tools/commit/b2d8b0336
                                   (setq-local lsp-completion-filter-on-incomplete nil))))

Do you know how to set completion-in-comments to nil, I can not find it in document.

@kiennq
Copy link
Member

kiennq commented Sep 29, 2020

You can probably try (setf (lsp--client-completion-in-comments? (gethash 'gopls lsp-clients)) nil)

@zhangjie2012
Copy link
Author

You can probably try (setf (lsp--client-completion-in-comments? (gethash 'gopls lsp-clients)) nil)

not work.

I changed lsp-go.el source code, and removed lsp-go.elc file.

@nbfalcon
Copy link
Member

nbfalcon commented Jan 25, 2021

@zhangjie2012 you need to M-x eval-expression that snippet and to add it to your init file if you want comment completion to be disabled after you restart Emacs. You also need to call lsp-workspace-root to restart your gopls workspace.

@yyoncho
Copy link
Member

yyoncho commented Oct 16, 2021

marking as closed. Please reoplen if @nbfalcon solution does not work.

@yyoncho yyoncho closed this as completed Oct 16, 2021
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