wlh320 / rime-ls Goto Github PK
View Code? Open in Web Editor NEWA language server for Rime input method engine 通过 LSP 代码补全使用 Rime 输入法
License: BSD 3-Clause "New" or "Revised" License
A language server for Rime input method engine 通过 LSP 代码补全使用 Rime 输入法
License: BSD 3-Clause "New" or "Revised" License
我遇到一个很奇怪的无法工作的场景,能够稳定复现。
arch下之前一直正常, 最近发现无法自动完成rime的build了。使用的rime配置为rime-ice
难道随着nvim或者lsp插件更新 无法用了 ?
Uploading RPReplay_Final1708562563.mp4…
感谢大佬的项目,但是我在Win10上一直没有配置成功。
我用的是neovim+nvim-cmp,配置文件用的是配置示例里第一个,每个路径都改好了。
但是打开nvim后提示
Client 2 quit with exit code 3221225781 and signal 0
敲几个字母也没有rime的补全。
LspLog看不到相关报错,配置的日志文件目录下也看不到输出。
将下载好的librime放到相应位置后
export LIBRIME_LIB_DIR= /usr/local/lib
export LIBRIME_INCLUDE_DIR= /usr/local/include
cargo build --release
之后运行会遇到
dyld[46557]: Library not loaded: @rpath/librime.1.dylib
Referenced from: <1378A569-3C10-3E64-9374-B718D98D94AB> /Users/evpeople/code/rust/rime-ls/target/release/rime_ls
Reason: no LC_RPATH's found
此时要做的是
export DYLD_LIBRARY_PATH=/usr/local/lib # 最好放在.zshrc中
此时可以运行了,但是会因权限报错,这时就是去系统设置解决权限问题了
平台archlinux
neovim lspconfig+cmp
大佬,我第一次用rime,用的是添加了custom server
的那个方法,但是没有cmp的补全,是我配置的问题还是rime需要额外的配置呢
发行版: Debian testing
clang
: 14.0.6
cargo
: 1.65.0
librime-dev
: 1.7.3
rime-ls
: 0.1.0
编译命令: cargo build --release
编译报错 输出:
Updating crates.io index
Updating git repository `https://github.com/lotem/librime-sys`
Compiling proc-macro2 v1.0.50
Compiling quote v1.0.23
Compiling unicode-ident v1.0.6
Compiling syn v1.0.107
Compiling libc v0.2.139
Compiling version_check v0.9.4
Compiling autocfg v1.1.0
Compiling memchr v2.5.0
Compiling futures-core v0.3.25
Compiling glob v0.3.1
Compiling cfg-if v1.0.0
Compiling pin-project-lite v0.2.9
Compiling serde_derive v1.0.152
Compiling log v0.4.17
Compiling futures-task v0.3.25
Compiling tinyvec_macros v0.1.0
Compiling serde v1.0.152
Compiling futures-channel v0.3.25
Compiling unicode-width v0.1.10
Compiling futures-sink v0.3.25
Compiling regex-syntax v0.6.28
Compiling textwrap v0.11.0
Compiling tinyvec v1.6.0
Compiling libloading v0.7.4
Compiling nom v5.1.2
Compiling proc-macro-error-attr v1.0.4
Compiling termcolor v1.2.0
Compiling slab v0.4.7
Compiling futures-util v0.3.25
Compiling clang-sys v1.4.0
Compiling bitflags v1.3.2
Compiling bindgen v0.57.0
Compiling strsim v0.8.0
Compiling once_cell v1.17.0
Compiling vec_map v0.8.2
Compiling humantime v2.1.0
Compiling ansi_term v0.12.1
Compiling aho-corasick v0.7.20
Compiling tokio v1.24.2
Compiling lock_api v0.4.9
Compiling proc-macro-error v1.0.4
Compiling rustc-hash v1.1.0
Compiling lazycell v1.3.0
Compiling smallvec v1.10.0
Compiling atty v0.2.14
Compiling unicode-normalization v0.1.22
Compiling which v3.1.1
Compiling clap v2.34.0
Compiling futures-io v0.3.25
Compiling parking_lot_core v0.9.6
Compiling unicode-bidi v0.3.9
Compiling lazy_static v1.4.0
Compiling shlex v0.1.1
Compiling peeking_take_while v0.1.2
Compiling pin-utils v0.1.0
Compiling serde_json v1.0.91
Compiling percent-encoding v2.2.0
Compiling form_urlencoded v1.1.0
Compiling num_cpus v1.15.0
Compiling tracing-core v0.1.30
Compiling scopeguard v1.1.0
Compiling ryu v1.0.12
Compiling bytes v1.3.0
Compiling idna v0.3.0
Compiling async-trait v0.1.61
Compiling itoa v1.0.5
Compiling httparse v1.8.0
Compiling tracing v0.1.37
Compiling tower-layer v0.3.2
Compiling tower-service v0.3.2
Compiling hashbrown v0.12.3
Compiling dirs-sys v0.3.7
Compiling regex v1.7.1
Compiling cexpr v0.4.0
Compiling str_indices v0.4.1
Compiling dashmap v5.4.0
Compiling directories v4.0.1
Compiling ropey v1.5.1
Compiling env_logger v0.8.4
Compiling futures-macro v0.3.25
Compiling pin-project-internal v1.0.12
Compiling tokio-macros v1.8.2
Compiling serde_repr v0.1.10
Compiling auto_impl v0.5.0
Compiling tower-lsp-macros v0.6.0
Compiling pin-project v1.0.12
Compiling librime-sys v0.1.0 (https://github.com/lotem/librime-sys#094db695)
Compiling tokio-util v0.7.4
Compiling futures v0.3.25
Compiling tower v0.4.13
Compiling url v2.3.1
Compiling lsp-types v0.93.2
Compiling tower-lsp v0.17.0
Compiling rime_ls v0.1.0 (/home/yaowj/.local/share/nvim/lazy/rime-ls)
error[E0658]: `let...else` statements are unstable
--> src/lsp.rs:68:9
|
68 | / let Ok(settings) = serde_json::from_value::<Settings>(params) else {
69 | | return ;
70 | | };
| |__________^
|
= note: see issue #87335 <https://github.com/rust-lang/rust/issues/87335> for more information
For more information about this error, try `rustc --explain E0658`.
error: could not compile `rime_ls` due to previous error
warning: build failed, waiting for other jobs to finish...
执行全部文本变动的通知,插入新值这里似乎发生了死锁,服务器后续不工作也没有报错,客户端也无法正常连接了。
Lines 60 to 63 in 0b8ad0c
通过把这里的 获取文本rope的操作,放到下面进行文本局部插入的if分支里,就可以进行全部文本替换和局部插入。
Lines 333 to 336 in 0b8ad0c
不懂Rust,不知道上面修改后的原理,我去看dashMap的文档和issue里提到过insert会有死锁的问题。
const net = require('net');
const {
createMessageConnection,
SocketMessageReader,
SocketMessageWriter
} = require("vscode-jsonrpc");
const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
function main() {
const argv = process.argv;
const client = new net.Socket();
client.connect(9257, '127.0.0.1', () => {
console.log('Connected to LSP server');
});
const reader = new SocketMessageReader(client);
const writer = new SocketMessageWriter(client);
const connection = createMessageConnection(reader, writer);
connection.onNotification('window/logMessage', (params) => {
console.log('Received message:', params);
});
connection.onNotification('window/workDoneProgress/create', (params) => {
console.log('Received :', params);
});
connection.onRequest('workspace/executeCommand', (params) => {
console.log('Received command:', params);
});
connection.listen();
client.on('close', () => {
console.log('Connection closed');
});
connection.onNotification((method, params) => {
console.log(`Notification: ${method} ${JSON.stringify(params, null, 2)}`);
});
connection.sendRequest("initialize", {
"initializationOptions": {
"shared_data_dir": "D:\\App\\Rime\\weasel-0.15.0\\data",
"user_data_dir": "D:\\Temp\\Rime\\lsp",
"log_dir": "D:\\Temp\\Rime\\lsp\\log",
"max_candidates": 10,
"trigger_characters": [],
"schema_trigger_character": "&"
},
"capabilities": {
"textDocument": {
"synchronization": {
"dynamicRegistration": true
}
},
"window": {
"showMessage": {
"messageActionItem": {
"additionalPropertiesSupport": false
}
}
}
}
})
.then(async (e) => {
console.log("Resp: ", JSON.stringify(e, null, 2))
await connection.sendNotification("initialized", {})
await connection.sendNotification("textDocument/didOpen", {
"textDocument": {
"languageId": "text",
"text": "zh",
"uri": "file:///res://Temp/Rime/test.txt",
"version": 1,
}
});
await sleep(300);
connection.sendNotification("textDocument/didChange", {
"textDocument": {
"uri": "file:///res://Temp/Rime/test.txt",
"version": 100
},
"contentChanges": [{
"text": "qi",
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 0
}
}
}],
"rangeLength": 0
});
// connection.sendNotification("textDocument/didChange",{"textDocument":{"uri":"file:///res://Temp/Rime/test.txt","version":100}, "contentChanges":[{"text":"kou"}]});
await sleep(600);
var c = await connection.sendRequest("textDocument/completion", {
"textDocument": {
"uri": "file:///res://Temp/Rime/test.txt",
},
"position": {
"line": 0,
"character": 2,
},
});
console.log("Comp:", JSON.stringify(c, null, 2));
});
}
main();
rime-ls 本质是个后端服务,编辑器等 LSP 客户端的相关适配对用户体验的影响更大。
欢迎 rime-ls 的用户在此讨论各种编辑器的使用情况
欢迎在此讨论好用的用户配置和插件
由于 rime-ls 并不是 LSP 的常规用法,难以要求编辑器来适配 rime-ls
Workaround: Check f9fbe3c
补全了一次后,直接输入就不再能触发补全了,需要输入一个“空格”之后才可以。
你好,我用的雾凇配置的小鹤双拼。
系统 Rime 和 rime-ls 共享一套配置。
在系统Rime里面,-
是直接上屏的,+
是直接上屏的,$
是直接作为¥
上屏的。
但是在 rime-ls 里面,+
和$
都不会触发补全, 直接上屏,但是-
就会触发补全。
不知道是否可以配置?
Hi,谢谢你的插件,非常好的想法。
我使用的是MacOS with M1,把项目拉到本地编译会有以下报错:
error: failed to run custom build command for `librime-sys v0.1.0 (https://github.com/lotem/librime-sys#094db695)`
Caused by:
process didn't exit successfully: `/Users/rain/code/rust/rime-ls/target/release/build/librime-sys-ce57fb0828704e4a/build-script-build` (exit status: 101)
--- stdout
cargo:rustc-link-lib=rime
--- stderr
wrapper.h:1:10: fatal error: 'rime_api.h' file not found
wrapper.h:1:10: fatal error: 'rime_api.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', /Users/rain/.cargo/git/checkouts/librime-sys-fbe83737eec7c58b/094db69/build.rs:15:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
我去看了librime-sys
这个项目,这个项目没有文档,而我也不是一个ruster,你知道是怎么回事嘛?
for macos
rime 初始化的时候有日志输入影响client解析,导致无法正常解析lsp返回的数据,这个怎么解决呢?
比如
https://github.com/cmyr/lsp-client
基于上面那个库的异步修改:
https://github.com/codestoryai/lsp_client
这两个库都无法直接调用rime-ls的
是否可以通过引入 server 模式,解决多开编辑器使用 rime-ls,数据库被锁的问题。
只有 server 模式下的 rime-ls 会访问数据库,其他的 rime-ls 访问 server。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.