Allow to use common word completion and snippets for Helix editor
demo.mp4
Based on comment
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 .
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
snippets_inline_by_word_tail = false # suggest snippets by WORD tail, for example text `xsq|` become `x^2|` when snippet `sq` has body `^2`
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
feature_citations = false # enable citation completion (only on `citation` feature enabled)
# 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" ]
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")'
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
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
Citation keys completion from bibliography file declared in current document.
When completion is triggered with a prefixed @
(which can be configured via citation_prefix_trigger
settings), scls will try to extract the bibliography file path from the current document (regex can be configured via the citation_bibfile_extract_regexp
setting) to parse and use it as a completion source.
To enable this feature, scls must be compiled with the --features citation
flag.
$ cargo install --features citation --git https://github.com/estin/simple-completion-language-server.git
And initialize scls with feature_citations = true
.
[language-server.scls.config]
max_completion_items = 20
feature_citations = true
For more info, please check #78
- erasin/hx-lsp
- metafates/buffer-language-server
- rajasegar/helix-snippets-ls
- quantonganh/snippets-ls
- Stanislav-Lapata/snippets-ls
- ...(please add another useful links here)
- rafamadriz/friendly-snippets
- ...(please add another useful links here)