[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",
  • 记得关闭扩展的自动更新功能
相关推荐
勤奋的大熊猫6 分钟前
Ruby 循环与迭代器
ruby
MonkeyKing_sunyuhua1 小时前
ubuntu22.04卸载vscode
ide·vscode·编辑器
一叶茶1 小时前
VsCode和AI的前端使用体验:分别使用了Copilot、通义灵码、iflyCode和Trae
前端·vscode·gpt·ai·chatgpt·copilot·deepseek
alladmin4 小时前
VSCode CMake Debug
ide·vscode·编辑器
德亦周15 小时前
如何在Mac电脑上的VScode去配置C/C++环境
c++·vscode·macos
七脉神剑19 小时前
一分钟在Cherry Studio和VSCode集成火山引擎veimagex-mcp
ide·vscode·编辑器
tonngw1 天前
【Mac 从 0 到 1 保姆级配置教程 12】- 安装配置万能的编辑器 VSCode 以及常用插件
git·vscode·后端·macos·开源·编辑器·github
tan180°2 天前
Linux进程信号处理(26)
linux·c++·vscode·后端·信号处理
和平宇宙2 天前
vscode extention踩坑记
ide·vscode·编辑器
yinhezhanshen2 天前
使用VSCode编辑Markdown+PlantUml
ide·vscode·编辑器