simple-completion-language-server icon indicating copy to clipboard operation
simple-completion-language-server copied to clipboard

external snippets

Open dsisnero opened this issue 1 year ago • 6 comments

I am trying to get external snippets working. When I copy the and paste the external-snippets.toml the snippets validate. Not getting any snippets when it is set in languages.toml.

Also, with the external-snippets.toml - it always looks for [sources.path] . how can you set it so it changes snippets for the language file that is open? .py - scope python - .rb -> scope ruby

dsisnero avatar Sep 10 '24 21:09 dsisnero

You did remember to run fetch external snippets, correct?

I'm pretty sure the scope flag exists purely to change the snippets based on the file open. Eg. Only snippets in scope python are used in .py files.

GameDungeon avatar Sep 11 '24 00:09 GameDungeon

@dsisnero Hi. Did you run simple-completion-language-server fetch-external-snippet ?

estin avatar Sep 13 '24 08:09 estin

my external snippets are working. I am on windows and when I have something like this in external-snippets.json. If I run

[[sources.paths]]
scope = ["ruby"]
path = "snippets/ruby/ruby.json"

if I run simple-completion-language-server validate-snippets I get 2024-12-02T19:42:01.399352Z ERROR simple_completion_language_server::snippets::config: On read dir "C:\\Users\\Dominic E Sisneros\\AppData\\Roaming\\helix\\snippets": The system cannot find the path specified. (os error 3)

What I want is the snippets directory to be relative to the external-snippets.toml file which is in c:\windows_home.config\helix

dsisnero avatar Dec 02 '24 19:12 dsisnero

Try to set env variable EXTERNAL_SNIPPETS_CONFIG=c:\windows_home.config\helix and SNIPPETS_PATH=c:\windows_home.config\helix for all

  • simple-completion-language-server fetch-external-snippet
  • simple-completion-language-server validate-snippets
  • and lsp mod

estin avatar Dec 03 '24 14:12 estin

@estin the issue here is the sample config in the README does not work if one only copies:

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

and puts nothing else in the file the paths complain OP saw occurs.

It is not really clear what the [[source.paths]] is doing.... I copied the example into my external-snippets.toml to satisfy it. Would an empty [[source.paths]] work?

shaleh avatar Apr 14 '25 01:04 shaleh

@shaleh if not declared at least one [[source.paths]] the external snippets feature would not work.

here validation routine

simple-completion-language-server validate-snippets

that was output this

thread 'main' panicked at src/main.rs:193:55:
Failed to validate snippets: TOML parse error at line 1, column 1
  |
1 | [[sources]]
  | ^^^^^^^^^^^^
missing field `paths`

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

But behavior was changed now in https://github.com/estin/simple-completion-language-server/commit/6c508fffc428f7080e82ec6baee0789e5aa5cf7c on master - [[source.paths]] is optional now

And scls tries to load all snippets from declared source. Readme updated. But I'm bad docs writer at all and especially on english...

estin avatar Apr 16 '25 08:04 estin