[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",
  • 记得关闭扩展的自动更新功能
相关推荐
暮色驶过苍茫9 分钟前
VSCode 自动更新问题解决记录
ide·vscode·编辑器
春蕾夏荷_7282977252 小时前
vscode 创建第一个python程序
vscode·python
星空3 小时前
vscode开发环境配置
ide·vscode·编辑器
fzb5QsS1p6 小时前
Maomi.MQ 功能强大的 .NET RabbitMQ 消息队列通讯模型框架来了
rabbitmq·.net·ruby
70asunflower1 天前
VS Code 从 0 到 1 完全教程
vscode
蜗牛 Day Day Up1 天前
vscode运行TypeScript
ide·vscode·typescript
cmpxr_1 天前
【VSCode】在类似Trae的软件上使用VSCode的插件市场
ide·vscode·编辑器
lifewange1 天前
Ruby语言在测试领域的应用
开发语言·后端·ruby
时空无限2 天前
mac 如何用命令行操作 vscode 打开哪个文件夹
ide·vscode·macos
MarsBighead2 天前
VSCode Python 调试故障排查:`justMyCode` 配置项引发的血案
ide·vscode·python