[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",
  • 记得关闭扩展的自动更新功能
相关推荐
鸡啄米的时光机7 小时前
vscode的一些实用操作
vscode·学习
灰色人生qwer11 小时前
React + TypeScript+ Vite 配置路径别名和vscode智能路径提示
vscode·react.js·typescript
莲动渔舟11 小时前
赶AI大潮:在VSCode中使用DeepSeek及近百种模型的极简方法
ide·人工智能·vscode·deepseek
咩咩大主教12 小时前
VSCode运行Go程序报错:Unable to process `evaluate`: debuggee is running
开发语言·ide·vscode·golang·编辑器
佛曰我不想说话12 小时前
通过VSCode直接连接使用 GPT的编程助手
ide·vscode·copilot
羊村懒哥15 小时前
VScode内接入deepseek包过程(本地部署版包会)
人工智能·vscode·deepseek
温酒往事·16 小时前
无缝对接[系列2]:在VSCode中继续接入本地DeepSeek的完整指南
ide·vscode·编辑器
Tom·猫1 天前
VSCODE - 连接远程linux服务器,报错XHR failed 解决方法
linux·服务器·vscode
艾斯比的日常1 天前
更高效实用 vscode 的常用设置
ide·vscode·编辑器
大得3691 天前
Visual Studio Code使用ai大模型编成
ide·vscode·编辑器