Skip to content

What unicode unit does vim-lsc use in lsp ranges? #170

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
Avi-D-coder opened this issue Mar 27, 2019 · 3 comments
Closed

What unicode unit does vim-lsc use in lsp ranges? #170

Avi-D-coder opened this issue Mar 27, 2019 · 3 comments

Comments

@Avi-D-coder
Copy link

Does this project use UTF-8, UTF-16, codepoint, or grapheme cluster indexes for lsp ranges?

If this project uses a unit other than UTF-16 could/would you ever conform to the protocol 3.0 and use UTF-16?

I am conducting a survey to inform the debate over what unit ranges should use in the Language Server Protocol.
The debate is occuring in issue #376.

@natebosch
Copy link
Owner

This project currently uses whatever strchars() uses (though there are probably also bugs). I'm pretty sure that is codepoints.

I do plan on conforming to spec to use UTF-16.

@Avi-D-coder
Copy link
Author

@natebosch thanks

@andymass
Copy link
Contributor

I think if vim-lsc were to become utf-16 conforming, where col('.') (byte position) is used would be replaced with something like;

" get column number measured in utf16 code units (a𐐀b -> [0, 1, 3])
function! Utf16col()
  if col('.') == 1
    return 0
  endif
  let str = getline('.')[:col('.')-2]   " chars prior to cursor
  return strlen(substitute(str, '.',
        \ '\=char2nr(submatch(0)) >= 0x10000 ? "XX" : "X"', 'g'))
endfunction

Not clear what to do at the moment since servers are inconsistent.

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

3 participants