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

Help needed: When using space indentation, completion triggers on first entered char #486

Open
Walheimat opened this issue Sep 14, 2024 · 1 comment

Comments

@Walheimat
Copy link

Walheimat commented Sep 14, 2024

Describe the bug

When completing in a Java buffer and not using tab-indent-mode, auto completion always triggers immediately.

Maybe there is some workaround for this. For now I'll disable auto-completion for java-mode.

To Reproduce

Use this slightly altered version of lsp-start-plain to also set up company and disable tabs:

(require 'package)

(make-directory "/tmp/lsp-test" t)

(setq debug-on-error t
      no-byte-compile t
      byte-compile-warnings nil
      inhibit-startup-screen t
      package-archives '(("melpa" . "https://melpa.org/packages/")
                         ("gnu" . "https://elpa.gnu.org/packages/"))
      package-user-dir "/tmp/lsp-test"
      custom-file (expand-file-name "custom.el" package-user-dir))

;; (delete-file package-user-dir)

(let* ((pkg-list '(lsp-mode
		   lsp-ui
		   yasnippet
		   lsp-java
		   lsp-treemacs
		   flycheck
		   ;; For this problem.
		   company)))

  (package-initialize)
  (package-refresh-contents)

  (mapc (lambda (pkg)
          (unless (package-installed-p pkg)
            (package-install pkg))
          (require pkg))
        pkg-list)

  (yas-global-mode)

  ;; Don't use tabs
  (setq-default indent-tabs-mode nil)

  (add-hook 'prog-mode-hook 'lsp)
  ;; (add-hook 'kill-emacs-hook `(lambda ()
  ;; (delete-directory ,package-user-dir t)))
  )

Save the file in a directory (I use ~/.emacs.d/lsp/init.el) and then start emacs with emacs --init-directory ~/.emacs.d/lsp.

Find a Java file, go to some line that has some level of indentation, hit return to open a new line, type a single char: it will immediately trigger completion.

Now re-enable indent-tabs-mode, and do the same: it will only trigger completion after three chars (the default for company-minimum-prefix-width).

@Walheimat
Copy link
Author

So the same happens for company-mode and without using orderless. Completion happens on the first char. I will update the OP.

@Walheimat Walheimat changed the title Help needed: Unable to use orderless and corfu when using lsp-java without tab indentation Help needed: When using space indentation, completion triggers on first entered char Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant