[ruby on rails] ruby使用vscode做开发

ruby LSP实现

ruby插件推荐用这个来实现,但是现在这个在加载文件索引时候,特别慢,时好时坏,所以现在推荐用Solargraph实现

ruby 复制代码
$ mkdir ruby-extensions
$ cd ruby-extensions
$ touch Gemfile
$ touch .ruby-version

# Gemfile
source 'https://rubygems.org'

ruby '3.1.4'

# Ruby LSP
gem 'rubocop'
gem 'ruby-lsp'

# .ruby-version
3.1.4
  • setting中配置
ruby 复制代码
   "rubyLsp.enableExperimentalFeatures": false,
    "rubyLsp.rubyVersionManager": "rbenv",
    "rubyLsp.bundleGemfile": "/Users/pagorn/ruby-extensions/Gemfile",
    "rubyLsp.enabledFeatures": {
        "codeActions": true,
        "diagnostics": true,
        "documentHighlights": true,
        "documentLink": true,
        "documentSymbols": true,
        "foldingRanges": true,
        "formatting": true,
        "hover": false,
        "inlayHint": true,
        "onTypeFormatting": true,
        "selectionRanges": true,
        "semanticHighlighting": true,
        "completion": false,
        "codeLens": true,
        "definition": true,
        "workspaceSymbol": true,
        "signatureHelp": true
    },

Solargraph实现方法跳转

  • 安装ruby插件 0.27.0,高版本的在vscode新版本中启动会报错
    插件市场下载0.27.0rebornix.Ruby-0.27.0.vsix,放在/Applications/Visual Studio Code.app/Contents/Resources/app/bin目录下,然后 code --install-extension rebornix.Ruby-0.27.0.vsix --force

  • 安装Ruby Solargraph

  • vscode setting设置

ruby 复制代码
	"solargraph.diagnostics": true,
    "solargraph.definitions": true,
    "solargraph.formatting": true,
    "solargraph.completion": true,
    "solargraph.hover": true,
    "solargraph.commandPath": "/Users/rushboy/.rbenv/shims/solargraph",
    "ruby.useLanguageServer": true,
    "ruby.intellisense": "rubyLocate",
  • 记得关闭扩展的自动更新功能
相关推荐
猿儿本无心11 小时前
快速搭建Python项目(Vscode+uv+FastAPI)
vscode·python·uv
π同学15 小时前
ESP-IDF+vscode开发ESP32第十二讲——event
vscode·esp32·事件循环库event
诗水人间16 小时前
VsCode 中使用Copilot调用Deepseek V4模型
ide·vscode·copilot
梦想家加一16 小时前
vscode为什么下载了汉化插件却不生效
ide·vscode·编辑器
多云的夏天18 小时前
IDE-VSCODE-Continue + DeepSeek V4
ide·vscode·编辑器·deepseek
或与且与或非18 小时前
rabbitmq选举集群搭建
分布式·rabbitmq·ruby
Robot_Nav19 小时前
Claude Code cli 以及vscode版本的各种命令参考手册
ide·vscode·编辑器
屋外雨大,惊蛰出没2 天前
Vscode自动生成类图
ide·vscode·编辑器·类图绘制
qq_14030341442 天前
vscode过滤文件
ide·vscode·编辑器
2501_915921432 天前
使用Swift和Xcode创建简单iOS应用完整教程
ide·vscode·ios·个人开发·xcode·swift·敏捷流程