Git Product home page Git Product logo

rime-ls's People

Contributors

eagleoflqj avatar evpeople avatar rainzm avatar twistoy avatar wlh320 avatar zwlin98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rime-ls's Issues

rime启动失败

arch下之前一直正常, 最近发现无法自动完成rime的build了。使用的rime配置为rime-ice
难道随着nvim或者lsp插件更新 无法用了 ?

Windows10一直配置不成功

感谢大佬的项目,但是我在Win10上一直没有配置成功。
我用的是neovim+nvim-cmp,配置文件用的是配置示例里第一个,每个路径都改好了。
但是打开nvim后提示
Client 2 quit with exit code 3221225781 and signal 0
敲几个字母也没有rime的补全。
LspLog看不到相关报错,配置的日志文件目录下也看不到输出。

MacOS 的编译和运行遇到缺少库时的解决方案

将下载好的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中

此时可以运行了,但是会因权限报错,这时就是去系统设置解决权限问题了

rime_ls启动了但是没有cmp的补全

平台archlinux
neovim lspconfig+cmp

大佬,我第一次用rime,用的是添加了custom server
的那个方法,但是没有cmp的补全,是我配置的问题还是rime需要额外的配置呢

rust编译出错 v0.1.0

发行版: 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...

didChange with full text can't work

执行全部文本变动的通知,插入新值这里似乎发生了死锁,服务器后续不工作也没有报错,客户端也无法正常连接了。

rime-ls/src/lsp.rs

Lines 60 to 63 in 0b8ad0c

async fn on_change(&self, params: TextDocumentItem) {
let rope = Rope::from_str(&params.text);
self.documents.insert(params.uri.to_string(), rope);
}

通过把这里的 获取文本rope的操作,放到下面进行文本局部插入的if分支里,就可以进行全部文本替换和局部插入。

rime-ls/src/lsp.rs

Lines 333 to 336 in 0b8ad0c

let mut rope = self
.documents
.get_mut(params.text_document.uri.as_str())
.unwrap();

不懂Rust,不知道上面修改后的原理,我去看dashMap的文档和issue里提到过insert会有死锁的问题。

JavaScript lsp客户端测试代码 需要nodejs和 vscode-jsonrpc 库依赖 根据实际修改初始化的initializationOptions值 切换下面didChange部分range更改和全文更改的注释,观察服务器返回的补全,文本打开默认值是zh
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();

Tracking: 编辑器适配情况

rime-ls 本质是个后端服务,编辑器等 LSP 客户端的相关适配对用户体验的影响更大。

欢迎 rime-ls 的用户在此讨论各种编辑器的使用情况

支持 LSP 协议的编辑器

支持 vim 模式的编辑器

日常可用的编辑器:

  • Vim + coc
  • Neovim + nvim-cmp

欢迎在此讨论好用的用户配置和插件

由于 rime-ls 并不是 LSP 的常规用法,部分编辑器能用但有些小问题:

  • Zed
    • 候选项过滤比较严格,需要将 filterText 放入 label,稍后会在 rime-ls 这里加一个配置项
    • 中文不被当作单词边界(这是合理的,因为很多语言 unicode 可以是变量名),导致中文后面继续输入时补全项被过
      滤掉
    • 已解决,见 https://github.com/wlh320/zed-ext-rime-ls
  • Helix
  • Qt Creator
    • 问题类似
    • 已解决,参考 helix

由于 rime-ls 并不是 LSP 的常规用法,难以要求编辑器来适配 rime-ls

Workaround: Check f9fbe3c

基本不可用,待实现插件:

  • VS Code
  • Lapce
  • Sublime Text

如何让`-`直接上屏

你好,我用的雾凇配置的小鹤双拼。

系统 Rime 和 rime-ls 共享一套配置。

在系统Rime里面,- 是直接上屏的,+是直接上屏的,$是直接作为¥上屏的。

但是在 rime-ls 里面,+$都不会触发补全, 直接上屏,但是- 就会触发补全。

不知道是否可以配置?

MacOS Support

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,你知道是怎么回事嘛?

折腾了一天,贴一个展示

non-ascii

我重新做了一个 librime-api 的绑定, 把 librime 的源代码通过 cmake 包直接封装到 crate 中了,这样编译起来就方便了,而且全是静态链接,可以直接放编译好的二进制包给大家用,也可以直接通过:

cargo install rime-ls

安装,目前只测试了 macos 和 linux 下的,再测测晚点发布到 crates.io 上去。😁

[Feature] 支持 c/s 模式

是否可以通过引入 server 模式,解决多开编辑器使用 rime-ls,数据库被锁的问题。

只有 server 模式下的 rime-ls 会访问数据库,其他的 rime-ls 访问 server。

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.