From f5ffaca10f3e91fa17d64578d9a9498f14fb4ccb Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Sat, 29 Mar 2025 12:13:31 -0400 Subject: [PATCH 1/6] Add snippets from Ruby LSP --- snippets.json | 155 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 snippets.json diff --git a/snippets.json b/snippets.json new file mode 100644 index 0000000..9c99285 --- /dev/null +++ b/snippets.json @@ -0,0 +1,155 @@ +{ + "New Minitest spec": { + "prefix": ["Minitest"], + "body": [ + "# frozen_string_literal: true", + "", + "require \"spec_helper\"", + "", + "class $1 < Minitest::Spec", + " describe \"$2\" do", + " it \"$3\" do", + " $0", + " assert(true)", + " end", + " end", + "end", + "" + ], + "description": "New Minitest class using the spec syntax." + }, + "New Minitest test": { + "prefix": ["Minitest"], + "body": [ + "# frozen_string_literal: true", + "", + "require \"test_helper\"", + "", + "class $1 < Minitest::Test", + " def test_$2", + " $0", + " assert(true)", + " end", + "end", + "" + ], + "description": "New Minitest class using the test syntax." + }, + "New Rspec test": { + "prefix": ["Rspec"], + "body": [ + "# frozen_string_literal: true", + "", + "describe $1 do", + " describe \"$2\" do", + " it \"$3\" do", + " $0", + " expect(true).to eq(true)", + " end", + " end", + "end", + "" + ], + "description": "New Minitest class using the spec syntax." + }, + "New class": { + "prefix": ["class"], + "body": ["class $1", " def initialize", " $0", " end", "end", ""], + "description": "New Ruby class." + }, + "New module": { + "prefix": ["module"], + "body": ["module $1", " def $2", " $0", " end", "end", ""], + "description": "New Ruby module." + }, + "Begin rescue block": { + "prefix": ["begin"], + "body": ["begin", " $0", "rescue $1", "end", ""], + "description": "New Ruby begin block with rescue." + }, + "Begin rescue ensure": { + "prefix": ["begin"], + "body": ["begin", " $0", "rescue $1", "ensure", "end", ""], + "description": "New Ruby begin block with rescue and ensure." + }, + "Each inline": { + "prefix": ["each"], + "body": ["each { |$1| $0 }"], + "description": "New Ruby inline each loop." + }, + "Each block": { + "prefix": ["each"], + "body": ["each do |$1|", " $0", "end"], + "description": "New Ruby each loop." + }, + "Map inline": { + "prefix": ["map"], + "body": ["map { |$1| $0 }"], + "description": "New Ruby inline map loop." + }, + "Map block": { + "prefix": ["map"], + "body": ["map do |$1|", " $0", "end"], + "description": "New Ruby map loop." + }, + "Flat map inline": { + "prefix": ["flat_map"], + "body": ["flat_map { |$1| $0 }"], + "description": "New Ruby inline flat_map loop." + }, + "Flat Map block": { + "prefix": ["flat_map"], + "body": ["flat_map do |$1|", " $0", "end"], + "description": "New Ruby flat_map loop." + }, + "Select inline": { + "prefix": ["select"], + "body": ["select { |$1| $0 }"], + "description": "New Ruby inline select loop." + }, + "Select block": { + "prefix": ["select"], + "body": ["select do |$1|", " $0", "end"], + "description": "New Ruby select loop." + }, + "Find inline": { + "prefix": ["find"], + "body": ["find { |$1| $0 }"], + "description": "New Ruby inline find loop." + }, + "Find block": { + "prefix": ["find"], + "body": ["find do |$1|", " $0", "end"], + "description": "New Ruby find loop." + }, + "Define singleton method": { + "prefix": ["def"], + "body": ["def self.$1", " $0", "end"], + "description": "New singleton method." + }, + "Define attribute accessor": { + "prefix": ["attr"], + "body": ["attr_accessor :$1"], + "description": "New attribute accessor." + }, + "Define attribute reader": { + "prefix": ["attr"], + "body": ["attr_reader :$1"], + "description": "New attribute reader." + }, + "Define attribute writer": { + "prefix": ["attr"], + "body": ["attr_writer :$1"], + "description": "New attribute writer." + }, + "If else": { + "prefix": ["if"], + "body": ["if $1", " $0", "else", "end"], + "description": "New if statement with else." + }, + "If elsif": { + "prefix": ["if"], + "body": ["if $1", " $0", "elsif $2", " $0", "end"], + "description": "New if statement with elsif." + } +} From 61451c553c459adf927e6076422cfc5807d4aa9e Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Sat, 29 Mar 2025 12:13:48 -0400 Subject: [PATCH 2/6] Configure extension to use snippets --- extension.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/extension.toml b/extension.toml index f0cf46a..802f0d3 100644 --- a/extension.toml +++ b/extension.toml @@ -5,6 +5,7 @@ version = "0.4.6" schema_version = 1 authors = ["Vitaly Slobodin "] repository = "https://github.com/zed-extensions/ruby" +snippets = "snippets.json" [language_servers.solargraph] name = "Solargraph" From 87d646e97c0e5e32ca8e568781d1ec323b70bc7f Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Fri, 18 Apr 2025 08:51:00 -0400 Subject: [PATCH 3/6] Add note to license --- LICENSE-APACHE | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/LICENSE-APACHE b/LICENSE-APACHE index f5f68b6..97208db 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -220,3 +220,15 @@ Apache License END OF TERMS AND CONDITIONS + +--- + +The contents of snippets.json are derived from Ruby LSP: + +https://github.com/Shopify/ruby-lsp + https://github.com/Shopify/ruby-lsp/blob/main/vscode/LICENSE.txt + +which are in turn derived from: + +https://github.com/textmate/ruby.tmbundle + https://github.com/textmate/ruby.tmbundle#license From 6a728dd8b2516756adf7eecfbe649656b45d6faa Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Tue, 22 Apr 2025 15:45:33 -0400 Subject: [PATCH 4/6] Add snippet for def --- snippets.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/snippets.json b/snippets.json index 9c99285..4bb39a8 100644 --- a/snippets.json +++ b/snippets.json @@ -122,6 +122,11 @@ "body": ["find do |$1|", " $0", "end"], "description": "New Ruby find loop." }, + "Define method method": { + "prefix": ["def"], + "body": ["def $1", " $0", "end"], + "description": "New method." + }, "Define singleton method": { "prefix": ["def"], "body": ["def self.$1", " $0", "end"], From 19715acefbd482aa4d8eb769bf430e5ff6d6adda Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Tue, 22 Apr 2025 15:46:17 -0400 Subject: [PATCH 5/6] Rename def singleton snippet prefix --- snippets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets.json b/snippets.json index 4bb39a8..8873f2f 100644 --- a/snippets.json +++ b/snippets.json @@ -128,7 +128,7 @@ "description": "New method." }, "Define singleton method": { - "prefix": ["def"], + "prefix": ["defs"], "body": ["def self.$1", " $0", "end"], "description": "New singleton method." }, From 6eedb6ef481dce072f219241dfb4d6c0532068f4 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Wed, 23 Apr 2025 10:46:39 -0400 Subject: [PATCH 6/6] Update Ruby LSP attribution --- LICENSE-APACHE | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/LICENSE-APACHE b/LICENSE-APACHE index 97208db..2392b09 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -225,10 +225,8 @@ Apache License The contents of snippets.json are derived from Ruby LSP: -https://github.com/Shopify/ruby-lsp - https://github.com/Shopify/ruby-lsp/blob/main/vscode/LICENSE.txt - -which are in turn derived from: + Copyright (c) 2022-present, Shopify Inc. + https://github.com/Shopify/ruby-lsp -https://github.com/textmate/ruby.tmbundle - https://github.com/textmate/ruby.tmbundle#license + Released under the MIT license + https://github.com/Shopify/ruby-lsp/blob/main/vscode/LICENSE.txt