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

ycm completes html error #2058

Closed
zeayes opened this issue Mar 18, 2016 · 8 comments
Closed

ycm completes html error #2058

zeayes opened this issue Mar 18, 2016 · 8 comments

Comments

@zeayes
Copy link

zeayes commented Mar 18, 2016

In html, YCM treated dot as part of identifier.

snapshot

vim -version

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 10 2016 14:43:34)
Garbage after option argument: "-version"
More info with: "vim -h"

vim html keyword config:

autocmd FileType xml,css,scss,sass,html,javascript set iskeyword& | set iskeyword+=-

YCM config:

Plugin 'Valloric/YouCompleteMe'
" set completeopt=longest,menu,preview
set completeopt=longest,menu
let g:ycm_error_symbol='>>'
let g:ycm_warning_symbol='>*'
let g:ycm_key_list_select_completion=['<c-n>']
let g:ycm_key_list_previous_completion=['<c-p>']
let g:ycm_confirm_extra_conf=0
let g:ycm_complete_in_strings=1
let g:ycm_complete_in_comments=1
let g:ycm_use_ultisnips_completer = 1
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_min_num_of_chars_for_completion=2
let g:ycm_min_num_identifier_candidate_chars=0
let g:ycm_collect_identifiers_from_tags_files=1
let g:ycm_collect_identifiers_from_comments_and_strings=1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_autoclose_preview_window_after_completion = 1
" [ 'same-buffer', 'horizontal-split', 'vertical-split', 'new-tab' ]
let g:ycm_goto_buffer_command='vertical-split'
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
let g:ycm_rust_src_path = '/usr/local/rustc-1.6.0/src'
let g:ycm_filetype_blacklist = {'tagbar' : 1, 'nerdtree' : 1}
@vheon
Copy link
Contributor

vheon commented Mar 18, 2016

ycmd uses this regex https://github.com/Valloric/ycmd/blob/master/ycmd/identifier_utils.py#L60-L63 for html and of course is not perfect; but to me the problem here is that what you're writing is not plain html but a templated html which have a different syntax compared to html. I don't know what would be the best fix for this:

  • add a regex for a templated html and handle those situations properly
  • make the html regex immune to those situation

😕 guys thoughts?

@micbou
Copy link
Collaborator

micbou commented Mar 18, 2016

The issue is not specific to a templated html. For example:

<div>test.test</div>

test.test will be extracted as an identifier.

We could exclude the dot character but according to HTML specs, dot is a valid character in tag names and attribute names/values even if I am not aware of any tag and attribute names containing a dot and dots in attribute values are rarely (never?) used.

@vheon
Copy link
Contributor

vheon commented Mar 18, 2016

The issue is not specific to a templated html. For example:

ops, sorry

@zeayes
Copy link
Author

zeayes commented Mar 18, 2016

Could YCM support vim's iskeyword as identifier?

@micbou
Copy link
Collaborator

micbou commented Mar 20, 2016

Could YCM support vim's iskeyword as identifier?

Probably but YCM currently uses regexes to extract identifiers which are much more powerful than Vim iskeyword so I think it is better to improve the regex.

@Valloric
Copy link
Member

Like @micbou said, supporting iskeyword is not the answer (and it would be too complex), improving the regex to understand common template chars ({{ and }}) is.

Valloric added a commit to ycm-core/ycmd that referenced this issue Mar 20, 2016
These are commonly used for HTML templating; see Handlebars, Angular
etc.

Fixes ycm-core/YouCompleteMe#2058
@zeayes
Copy link
Author

zeayes commented Mar 21, 2016

thanks!

@zeayes zeayes closed this as completed Mar 21, 2016
Valloric added a commit to ycm-core/ycmd that referenced this issue Mar 21, 2016
These are commonly used for HTML templating; see Handlebars, Angular
etc.

Fixes ycm-core/YouCompleteMe#2058
homu added a commit to ycm-core/ycmd that referenced this issue Mar 22, 2016
Ignoring HTML template chars `{` and `}`

These are commonly used for HTML templating; see Handlebars, Angular
etc.

Fixes ycm-core/YouCompleteMe#2058

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/436)
<!-- Reviewable:end -->
@forresthopkinsa
Copy link

Why is YCM using regex to parse HTML? I thought we were past this haha

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants