Skip to content

Commit

Permalink
feat(lsp): add more option for autocompletion (#6)
Browse files Browse the repository at this point in the history
* feat(lsp): add more option for autocompletion

- completion_around_mode
- completion_trigger_characters

* feat(coc): support new options

* refactor(lsp): add lsp mod

* feat(lsp): add more situations for around mode

* chore(dicts): add download.sh

* chore(package): v0.4.0
  • Loading branch information
iamcco authored Dec 31, 2022
1 parent 296a276 commit 87136e6
Show file tree
Hide file tree
Showing 13 changed files with 479 additions and 354 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
- `ds-pinyin-lsp.db_path`: `dict.db3` 文件
- `ds-pinyin-lsp.server_path`: `ds-pinyin-lsp` 命令或路经
- `ds-pinyin-lsp.completion_on`: 是否自动启用补全
- `ds-pinyin-lsp.completion_around_mode`: 是否启用环绕(光标在汉字(包括中文标点符号)开头/中间/结尾)补全模式
- `ds-pinyin-lsp.completion_trigger_characters`: 触发补全字符,配合 `completion_around_mode` 使用,在启用环绕模式后,可以通过输入触发补全字符启用自动补全
- `ds-pinyin-lsp.show_symbols`: 是否补全中文标点符号
- `ds-pinyin-lsp.show_symbols_only_follow_by_hanzi`: 是否只在中文后面补全中文符号
- `ds-pinyin-lsp.show_symbols_by_n_times`: 是否在输入 `n` 次符号后才显示中文符号补全选项,`0` 表示不开启先选
Expand Down
2 changes: 2 additions & 0 deletions packages/coc-ds-pinyin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
- `ds-pinyin-lsp.check_on_startup`: Check ds-pinyin-lsp release on start up
- `ds-pinyin-lsp.db_path`: db path
- `ds-pinyin-lsp.completion_on`: If enable auto completion
- `ds-pinyin-lsp.completion_around_mode`: If enable around mode for autocompletion
- `ds-pinyin-lsp.completion_trigger_characters`: Trigger characters for trigger autocompletion
- `ds-pinyin-lsp.show_symbols`: If show Chinese symbols
- `ds-pinyin-lsp.show_symbols_only_follow_by_hanzi`: If only show Chinese symbols follow by hanzi
- `ds-pinyin-lsp.show_symbols_by_n_times`: If show Chinese symbols by input n times
Expand Down
12 changes: 11 additions & 1 deletion packages/coc-ds-pinyin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coc-ds-pinyin-lsp",
"version": "0.3.0",
"version": "0.4.0",
"description": "pinyin input support for (Neo)vim",
"author": "iamcco <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -61,6 +61,16 @@
"default": true,
"description": "If enable auto completion"
},
"ds-pinyin-lsp.completion_around_mode": {
"type": "boolean",
"default": false,
"description": "If enable around mode for autocompletion"
},
"ds-pinyin-lsp.completion_trigger_characters": {
"type": "string",
"default": "",
"description": "Trigger characters for trigger autocompletion"
},
"ds-pinyin-lsp.show_symbols": {
"type": "boolean",
"default": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/coc-ds-pinyin/src/constant.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const extensionName = 'ds-pinyin-lsp';
export const dbName = 'dict.db3';
export const dbTag = 'v0.3.0';
export const dbTag = 'v0.4.0';
2 changes: 2 additions & 0 deletions packages/coc-ds-pinyin/src/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export class Ctx {
return {
db_path: config.get<string>('db_path') || (existsSync(db_path) ? db_path : ''),
completion_on: config.get<boolean>('completion_on', true),
completion_around_mode: config.get('completion_around_mode', false),
completion_trigger_characters: config.get('completion_trigger_characters', ''),
show_symbols: config.get<boolean>('show_symbols', true),
show_symbols_only_follow_by_hanzi: config.get<boolean>('show_symbols_only_follow_by_hanzi', false),
show_symbols_by_n_times: config.get<number>('show_symbols_by_n_times', 0),
Expand Down
10 changes: 10 additions & 0 deletions packages/dict-builder/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

curl https://raw.githubusercontent.com/iDvel/rime-ice/main/cn_dicts/8105.dict.yaml -o ./dicts/8105.dict.yaml
curl https://raw.githubusercontent.com/iDvel/rime-ice/main/cn_dicts/base.dict.yaml -o ./dicts/base.dict.yaml
curl https://raw.githubusercontent.com/iDvel/rime-ice/main/cn_dicts/ext.dict.yaml -o ./dicts/ext.dict.yaml
curl https://raw.githubusercontent.com/iDvel/rime-ice/main/cn_dicts/others.dict.yaml -o ./dicts/others.dict.yaml
curl https://raw.githubusercontent.com/iDvel/rime-ice/main/cn_dicts/sogou.dict.yaml -o ./dicts/sogou.dict.yaml
curl https://raw.githubusercontent.com/iDvel/rime-ice/main/cn_dicts/tencent.dict.yaml -o ./dicts/tencent.dict.yaml
curl https://raw.githubusercontent.com/iDvel/rime-ice/main/opencc/others.txt -o ./dicts/others.txt
curl https://raw.githubusercontent.com/iDvel/rime-ice/main/opencc/emoji.txt -o ./dicts/emoji.txt
2 changes: 1 addition & 1 deletion packages/ds-pinyin-lsp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ds-pinyin-lsp"
version = "0.3.0"
version = "0.4.0"
edition = "2021"
repository = "https://github.com/iamcco/ds-pinyin-lsp"
description = "Pinyin language server for input Chinese."
Expand Down
1 change: 1 addition & 0 deletions packages/ds-pinyin-lsp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod lsp;
pub mod sqlite;
pub mod types;
pub mod utils;
Loading

0 comments on commit 87136e6

Please sign in to comment.