Skip to content

Latest commit

 

History

History
152 lines (105 loc) · 4.19 KB

File metadata and controls

152 lines (105 loc) · 4.19 KB

simple-completion-language-server

Allow to use common word completion and snippets for Helix editor

demo.mp4

Based on comment

Install (from source only)

From GitHub:

$ cargo install --git https://github.com/estin/simple-completion-language-server.git

From local repository:

$ git clone https://github.com/estin/simple-completion-language-server.git
$ cd simple-completion-language-server
$ cargo install --path .

Configure

For Helix on ~/.config/helix/languages.toml

# introduce new language server
[language-server.scls]
command = "simple-completion-language-server"

[language-server.scls.config]
max_completion_items = 20     # set max completion results len for each group: words, snippets, unicode-input
snippets_first = true         # completions will return before snippets by default
feature_words = true          # enable completion by word
feature_snippets = true       # enable snippets
feature_unicode_input = true  # enable "unicode input"
feature_paths = true          # enable path completion


# write logs to /tmp/completion.log
[language-server.scls.environment]
RUST_LOG = "info,simple-completion-language-server=info"
LOG_FILE = "/tmp/completion.log"

# append language server to existed languages
[[language]]
name = "rust"
language-servers = [ "scls", "rust-analyzer" ]

[[language]]
name = "git-commit"
language-servers = [ "scls" ]

# etc..

# introduce a new language to enable completion on any doc by forcing set language with :set-language stub
[[language]]
name = "stub"
scope = "text.stub"
file-types = []
shebangs = []
roots = []
auto-format = false
language-servers = [ "scls" ]

Snippets

Read snippets from dir ~/.config/helix/snippets or specify snippets path via SNIPPETS_PATH env.

Currently, it supports our own toml format and vscode json (a basic effort).

Filename used as snippet scope (language), filename snippets.(toml|json) will not attach scope to snippets.

For example, snippets with the filename python.toml or python.json would have a python scope.

Snippets format

[[snippets]]
prefix = "ld"
scope = [ "python" ]
body = 'log.debug("$1")'

Use external snippets collections from git repos

Configure sources in ~/.config/helix/external-snippets.toml (or via env EXTERNAL_SNIPPETS_CONFIG)

[[sources]] # list of sources to load
name = "friendly-snippets"  # optional name shown on snippet description
git = "https://github.com/rafamadriz/friendly-snippets.git" # git repo with snippets collections

[[sources.paths]] # list of paths to load on current source
scope = ["python"]  # optional scopes for current snippets
path = "snippets/python/python.json"  # where snippet file or dir located in repo

Clone or update snippets source repos to ~/.config/helix/external-snippets/<repo path>

$ simple-completion-language-server fetch-external-snippets

Validate snippets

$ simple-completion-language-server validate-snippets

Unicode input

Read unicode input config as each file from dir ~/.config/helix/unicode-input (or specify path via UNICODE_INPUT_PATH env).

Unicode input format (toml key-value), for example ~/.config/helix/unicode-input/base.toml

alpha = "α"
betta = "β"
gamma = "γ"
fire = "🔥"

Validate unicode input config

$ simple-completion-language-server validate-unicode-input

Similar projects

Useful snippets collections