Git Product home page Git Product logo

Comments (3)

krobelus avatar krobelus commented on June 21, 2024 2

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 <[email protected]>
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 <[email protected]>
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

from kakoune-lsp.

xnuk avatar xnuk commented on June 21, 2024

Thanks! Should I close this issue then?

from kakoune-lsp.

krobelus avatar krobelus commented on June 21, 2024

yeah I think so

from kakoune-lsp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.