• Stars
    star
    114
  • Rank 306,421 (Top 7 %)
  • Language
    Rust
  • Created almost 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dead Simple Pinyin Language Server

超,超简单的拼音输入法

中文 English

介绍

通过 LSP 实现的超简单拼音输入法,其主要的用途是在 (neo)vim 编辑器中不需要切换输入法也能输入中文。 避免忘记切换输入法而导致在 Normal 模式下弹出输入法的蛋疼问题。

注意

  • 非专业输入法,不是输入法的代替品,只适合少量需要输入中文的场景。
  • 只支持全拼, 需要配合 LSP 客户端使用,比如 coc.nvim (neo)vim / VS Code / lsp-bridge (Emacs) 等。

Emacs 用户可以配合 lsp-bridge 使用

lsp-bridge 已经添加了对 ds-pinyin 的支持

(neo)vim 用户可以配合 coc.nvim 或者 neovim 内置的 lsp 使用

1. 使用扩展 coc-ds-pinyin-lsp
:CocInstall coc-ds-pinyin-lsp

插件设置项:

  • ds-pinyin-lsp.enabled: 是否启用插件
  • ds-pinyin-lsp.trace.server: 打开日志项
  • ds-pinyin-lsp.prompt: 是否运行弹窗询问?比如询问下载 ds-pinyin-lsp dict.db3 文件
  • ds-pinyin-lsp.show_status_bar: 是否开启状态栏显示
  • ds-pinyin-lsp.status_bar_flag: 状态栏标志,默认 Pinyin
  • ds-pinyin-lsp.check_on_startup: 是否检查更新
  • 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 表示不开启先选
  • ds-pinyin-lsp.match_as_same_as_input: 是否只显示完全匹配结果,比如: 输入 pinyin 会只显示 拼音 选项,不会显示 拼音输入法 等选项
  • ds-pinyin-lsp.match_long_input: 是否显示长句匹配,比如:输入 nihaonishishei 在没有补全项的时候会把 你好 你是谁 两个选项拼起来作为补全选项
  • ds-pinyin-lsp.max_suggest: 中文补全列表最大显示个数

插件命令:

  • ds-pinyin-lsp.turn-on-completion: 开启自动补全
  • ds-pinyin-lsp.turn-off-completion: 关闭自动补全
  • ds-pinyin-lsp.toggle-completion: 切换自动补全
2. 使用 neovim 内置的 lsp

请先安装 nvim-lspconfig 插件,具体配置可参考其文档对应部分的配置。

如果需要配置选项,可参考如下的代码片段:

require('lspconfig').ds_pinyin_lsp.setup {
    init_options = {
        db_path = "your_path_to_database",
        completion_on = true,
        match_as_same_as_input = true,
    }
}

可配置项请参考 coc-settings.jsoninitializationOptions 部分。

3. 不使用扩展

Release 下载 ds-pinyin-lsp 或 通过 cargo install ds-pinyin-lsp 安装 ds-pinyin-lsp 然后添加以下配置到 coc-settings.json

  "languageserver": {
    "ds-pinyin": {
      "command": "path to ds-pinyin-lsp command",
      "filetypes": ["*"],
      "initializationOptions": {
        "db_path": "path to dict.db3",                             // dict.db3 字典文件
        "completion_on": true,                                     // 是否开启自动补全
        "completion_around_mode":                                  // 是否启用环绕(光标在汉字(包括中文标点符号)开头/中间/结尾)补全模式
        "completion_trigger_characters":                           // 触发补全字符,配合 completion_around_mode 使用,在启用环绕模式后,可以通过输入触发补全字符启用自动补全
        "show_symbols": true,                                      // 是否补全中文标点符号
        "show_symbols_only_follow_by_hanzi": false,                // 是否只在中文后面补全中文符号
        "show_symbols_by_n_times": 0,                              // 是否在输入 `n` 次符号后才显示中文符号补全选项,`0` 表示不开启先选
        "match_as_same_as_input": true,                            // 是否只显示完全匹配结果,比如: 输入 `pinyin` 会只显示 `拼音` 选项,不会显示 `拼音输入法` 选项
        "match_long_input": true,                                  // 是否显示长句匹配,比如:输入 `nihaonishishei` 在没有补全项的时候会把 `你好` `你是谁` 两个选项拼起来作为补全选项
        "max_suggest": 50                                          // 中文补全列表最大显示个数
      }
    }
  }

dict.db3 可以从 Release 下载。

可以通过向服务端发送通知(Notification)来关闭/开启/切换自动补全

  • $/turn/completion: 参数: { completion_on?: boolean }

Packages

关于使用的字典

所使用的字典来自 rime-ice 项目

请我吃个煎饼馃子 🤟

btc

image

More Repositories

1

markdown-preview.nvim

markdown preview plugin for (neo)vim
JavaScript
6,530
star
2

markdown-preview.vim

⚠️ PLEASE USE https://github.com/iamcco/markdown-preview.nvim INSTEAD
CSS
793
star
3

vim-language-server

VImScript language server, LSP for vim script
JavaScript
496
star
4

coc-flutter

flutter support for (Neo)vim
TypeScript
473
star
5

diagnostic-languageserver

diagnostic language server integrate with linters
TypeScript
410
star
6

coc-tailwindcss

tailwindcss class name completion for (neo)vim
TypeScript
333
star
7

coc-spell-checker

A basic spell checker that works well with camelCase code for (Neo)vim
TypeScript
263
star
8

coc-diagnostic

diagnostic-languageserver extension for coc.nvim
TypeScript
246
star
9

coc-vimlsp

viml language server
TypeScript
211
star
10

coc-angular

Angular Language Service coc extension for (neo)vim
TypeScript
145
star
11

coc-actions

Actions menu for Neovim
TypeScript
102
star
12

coc-rainbow-fart

🌈 rainbow-fart for (neo)vim 一个在你编程时疯狂称赞你的 coc.nvim 扩展插件 | An coc.nvim extension that keeps giving you compliment while you are coding, it will checks the keywords of code to play suitable sounds.
TypeScript
84
star
13

dict.vim

vim简单的翻译工具
Python
74
star
14

markdown.css

markdown styles
CSS
60
star
15

coc-post

post extension for coc.nvim
TypeScript
55
star
16

dotfiles

my dotfiles
Vim Script
52
star
17

git-p.nvim

Git plus for (neo)vim
JavaScript
38
star
18

clock.nvim

A Big Clock For Neovim
JavaScript
33
star
19

coc-leetcode

leetcode 扩展
TypeScript
33
star
20

coc-svg

A Powerful SVG Language Support coc Extension for (neo)vim
TypeScript
31
star
21

async-await.lua

Write async function more like javascript async/await
Lua
28
star
22

coc-zi

look or google 10000 english for (neo)vim
TypeScript
28
star
23

coc-cspell-dicts

Ext spell dictionary extension for coc-spell-checker
TypeScript
21
star
24

coc-gitignore

gitignore extension for coc.nvim
TypeScript
20
star
25

mathjax-support-for-mkdp

mathjax support for markdown-preview.vim plugin
JavaScript
19
star
26

coc-project

project extension for coc.nvim
TypeScript
18
star
27

bg.workflow

追番,alfred3 workflow 查看每日新番
Python
10
star
28

Bencode

解析torrent文件
Python
9
star
29

coc-clock

clock for neovim
TypeScript
8
star
30

coc-webpack

Autocomplete support for webpack config
TypeScript
7
star
31

htom

convert html to markdown
JavaScript
4
star
32

iamcco.github.io

Too young Too simple Sometimes naive
HTML
3
star
33

manga-download

漫画下载
Python
3
star
34

sran.nvim

simple request and notification call for (neo)vim
JavaScript
3
star
35

denite-source.vim

denite source of denite sources
Python
3
star
36

gh-pages-webpack-plugin

gh-pages plugin for webpack
JavaScript
3
star
37

file-manager.vim

Denite source for file management
Python
3
star
38

statusline.vim

Vim Script
3
star
39

smartIM.nvim

smart IM for neovim
Python
2
star
40

yuuko

An hexo theme inspire by Time axis of Qzone
CSS
2
star
41

buzuo.vim

😱 buzuo(不做)list for vim/neovim
Vim Script
2
star
42

coc-bootstrap-classname

JavaScript
2
star
43

HomePage

My home page
JavaScript
2
star
44

gitignore.vim

denite source for gitignore
Python
2
star
45

next-theme

refind next theme dark
2
star
46

rxjs-operators

rxjs 操作符补完计划
TypeScript
2
star
47

go-to-file.vim

go to the file from require or import
Vim Script
2
star
48

md-it-mermaid

markdown-it plugin for mermaid
JavaScript
1
star
49

coc-action-source.nvim

CocAction source of coc.nvim
Python
1
star
50

nichijou

yuuko mio mai hakase nano sakamoto no monogatari
1
star
51

git-blame.vim

git blame
Vim Script
1
star
52

vimrc.backup

vimrc配置/字体等备份
Vim Script
1
star
53

BEND

JavaScript
1
star
54

exec-frequent

exec function frequent
JavaScript
1
star
55

redux-async-combine-reducers

Asynchronous add reducers
JavaScript
1
star
56

RotateGame

JavaScript
1
star
57

react-error-codes.vim

Denite sources for react error codes
Python
1
star
58

hello-dt

Using DevTerm as a print server
TypeScript
1
star
59

fzf-source.vim

denite source of fzf source for (neo)vim
Python
1
star
60

.github

1
star
61

float2

move the dot of float
JavaScript
1
star
62

rxh

RxJS hook for React with no magic
JavaScript
1
star
63

save-cloud-vita

PSVita 游戏存档云备份工具!
Rust
1
star