kakoune-lsp / kakoune-lsp

Kakoune Language Server Protocol Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ANSI-like escaped chars are shown if Korean variable names are hovered

xnuk opened this issue · comments

  • rust-analyzer 1.79.0-nightly (c9f8f34 2024-03-27)
  • kak-lsp 16.0.0-snapshot (377a1a0)
    • kak-lsp 16.0.0 also reproducible
  • Kakoune v2023.08.05
  • on Arch Linux x64
// main.rs

fn main() {
    let 된장 = 1;
}
zz.mp4

I named it as 된장 because I ate 된장찌개 today

proposed upstream fix is at rust-lang/rust-analyzer#17003

if you need a workaround, you can use our offset_encoding config value (needs below fix unfortunately):

From a54e5f9c3297e2882e8dced8e78a49a85e026f29 Mon Sep 17 00:00:00 2001
From: Johannes Altmanninger <aclopte@gmail.com>
Date: Wed, 3 Apr 2024 14:57:20 +0200
Subject: [PATCH 1/2] If offset_encoding is explicitly specified, always use
 that

It looks like when we ask rust-analyzer that we prefer utf-16 but
tell it that we also support utf-8, it will ignore our preference and
always use utf-8. I think this violates LSP; I'm not sure if we want to
work around it like below (because that might make user errors worse)
---
 src/capabilities.rs | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/capabilities.rs b/src/capabilities.rs
index b19cb77..9e72f24 100644
--- a/src/capabilities.rs
+++ b/src/capabilities.rs
@@ -362,17 +362,17 @@ pub fn initialize(meta: EditorMeta, ctx: &mut Context) {
                                 }),
                                 stale_request_support: None,
                                 position_encodings: Some(match preferred_offset_encoding {
-                                    None | Some(OffsetEncoding::Utf8) => {
+                                    None => {
                                         vec![
                                             PositionEncodingKind::UTF8,
                                             PositionEncodingKind::UTF16,
                                         ]
                                     }
+                                    Some(OffsetEncoding::Utf8) => {
+                                        vec![PositionEncodingKind::UTF8]
+                                    }
                                     Some(OffsetEncoding::Utf16) => {
-                                        vec![
-                                            PositionEncodingKind::UTF16,
-                                            PositionEncodingKind::UTF8,
-                                        ]
+                                        vec![PositionEncodingKind::UTF16]
                                     }
                                 }),
                             }),
-- 
2.44.0.413.gd6fd04375f


From 9e3600961c690f52e5a5219c8b93472ec4c093a1 Mon Sep 17 00:00:00 2001
From: Johannes Altmanninger <aclopte@gmail.com>
Date: Wed, 3 Apr 2024 14:59:41 +0200
Subject: [PATCH 2/2] Use utf-16 position encoding for rust-analyzer

---
 kak-lsp.toml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kak-lsp.toml b/kak-lsp.toml
index f194628..e2fabd3 100644
--- a/kak-lsp.toml
+++ b/kak-lsp.toml
@@ -369,6 +369,7 @@ command = "ocamllsp"
 filetypes = ["rust"]
 roots = ["Cargo.toml"]
 command = "rust-analyzer"
+offset_encoding = "utf-16"
 # command = "sh"
 # args = [
 #     "-c",
-- 
2.44.0.413.gd6fd04375f

Thanks! Should I close this issue then?

yeah I think so