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

The best way to select and highlight based on character coordinates #2839

Closed
ul opened this issue Apr 6, 2019 · 2 comments
Closed

The best way to select and highlight based on character coordinates #2839

ul opened this issue Apr 6, 2019 · 2 comments

Comments

@ul
Copy link
Contributor

ul commented Apr 6, 2019

For showing diagnostics and applying formatting kak-lsp needs to convert column coordinate in ranges sent by language servers from character offset to a byte offset. I see a few options to do that, please help me to figure out the best one.

  1. Keep buffer copy in kak-lsp and analyze it to convert character offset to a byte offset.

Pros:

Cons:

  • Higher memory consumption.
  • Duplicating editor's functionality.
  1. Translate all coordinates on lsp.kak side by doing the following in the loop: position cursor using a character-based column with <line>g<column>l and extract byte offset with %val{cursor_column}

Pros:

  • "Glue"-level change, keeps kak-lsp server and Kakoune from bloat, no duplication of functionality.

Cons:

  • Extra shell<->Kakoune ping-pong for each coordinate, might introduce noticeable lag and need to be careful not to bump buffer timestamp while doing this.
  • Probably not very maintainable shell code.
  1. Add support for character-based range-specs to Kakoune

Pros:

Cons:

  • Could be another "pet feature" which kakoune doesn't need as it's possible to accomplish the task with existing functionality.
  • Performance hit?
@mawww
Copy link
Owner

mawww commented Apr 8, 2019

Option 2. and 3. both have an additional con, which is that they only really work on current timestamp (Option 3 could handle other timestamps at the price of some implementation complexity), Option 1. does not have this problem as the lsp server and kak-lsp are already in sync regarding buffer state.

Option 2 might be implementable more efficiently now that we have echo -to-file ... to return the data back without forking a shell. (As an aside, a good part of kak-lsp scripting might be able to take advantage of that to reduce the amount of forking).

@ul
Copy link
Contributor Author

ul commented Apr 22, 2019

Thanks for the suggestion! I decided to give the first option a go for now as it doesn't seem so bad in terms of resource consumption increase, but gives me opportunity to solve the problem (and its performance aspects) in the comfort of Rust, because I don't feel my skill of Kakoune+shell scripting being good enough to accomplish non-trivial task with confidence.

@ul ul closed this as completed Apr 22, 2019
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

2 participants