company-web icon indicating copy to clipboard operation
company-web copied to clipboard

Can't complete on `<`

Open Compro-Prasad opened this issue 7 years ago • 11 comments

I am using spacemacs where I want to complete when I type the < character. But it doesn't complete. The company-minimum-prefix-length for me is 1. So, I have to type an extra alphabet after < to get completion. How do I resolve this? See: https://github.com/syl20bnr/spacemacs/issues/8222

Compro-Prasad avatar Jun 16 '18 17:06 Compro-Prasad

It might be unrelated to react layer which I don't use. But I tested this on an HTML file.

Compro-Prasad avatar Jun 16 '18 17:06 Compro-Prasad

I use spacemacs too But my version is outdatted: 4bb4cb46 2017-11-01 For web-mode company-minimum-prefix-length is 0 for me. Maybe for you is 1 because of some perfomance issue. Try to set to 0 and check how perfomance decrased.

Few month ago there was performance issue for company-web and that is why they might decide to increase from 0 to 1 :). I'm closing this

osv avatar Jun 21 '18 10:06 osv

Ah, you are about react + company-web... I reopen, newer tried to work with react + company-web, need to check

osv avatar Jun 21 '18 10:06 osv

No, spacemacs has the value 0 but I manually set company-minimum-prefix-length to 1.

Compro-Prasad avatar Jun 21 '18 12:06 Compro-Prasad

It happens in a normal HTML file too.

Compro-Prasad avatar Jun 21 '18 13:06 Compro-Prasad

autocomplete

What exactly happens? you want autocomplete after < ? Than set company-minimum-prefix-length to 0

osv avatar Jun 21 '18 14:06 osv

But I don't want to complete after >. Setting it to 0 means it will give me completion even after >.

Compro-Prasad avatar Jun 21 '18 14:06 Compro-Prasad

company-clang can complete on ::, -> insertions irrespective of company-minimum-prefix-length. Why can't this package do it?

Compro-Prasad avatar Jun 21 '18 14:06 Compro-Prasad

@Compro-Prasad Ah, reason why autocomplete in any place even after > is because web-mode is designed for emmet mode too!.

In case if you are ok to work without emmet support in react layer we can update next function and add some switcher for disable emmet.

(defun company-web-html-emmet-grab ()
  (let* ((limit (company-web-backward-min-tag-bound))
         (bound (save-excursion
                  (if (re-search-backward ">" limit t)
                      (point)
                    limit))))
    (and company-web-html-emmet-enable
         (bound-and-true-p emmet-mode)
         (or
          (company-grab company-web-html-emmet-tag-regexp 1 bound)
          (company-grab company-web-html-emmet-class-regexp 2 bound)
          (company-grab company-web-html-emmet-id-regexp 2 bound)
          (company-grab company-web-html-emmet-attr-regexp 2 bound)
          (company-grab company-web-html-emmet-value-regexp 3 bound)))))

osv avatar Jun 25 '18 09:06 osv

I will add switcher soon. I think it should help you

osv avatar Jun 25 '18 09:06 osv

This is a bug IMO.

Compro-Prasad avatar Aug 13 '18 06:08 Compro-Prasad