[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",
  • 记得关闭扩展的自动更新功能
相关推荐
任磊abc11 小时前
vscode无法检测到typescript环境解决办法
ide·vscode·typescript
hfut028811 小时前
【vscode使用说明】
vscode·编辑器·vim
weixin_3077791314 小时前
VS Code配置MinGW64编译GNU 科学库 (GSL)
开发语言·c++·vscode·算法
ala咪15 小时前
切换VSCODE 中的默认 shell
vscode
BIBI204916 小时前
自定义 VSCode 标题栏以区分不同版本
ide·vscode·编辑器
蔡俊锋18 小时前
Javar如何用RabbitMQ订单超时处理
java·python·rabbitmq·ruby
谱写秋天1 天前
Qt 5.5 的安装与配置(使用 VSCode编辑)
开发语言·vscode·qt
骑着毛驴数星星2 天前
CANDB++中的CAN_DBC快速编辑方法,使用文本编辑器(如notepad++和VScode)
vscode·can
weixin_307779132 天前
VS Code配置MinGW64编译Ipopt库
开发语言·c++·vscode·算法
weixin_307779132 天前
VS Code配置MinGW64编译backward库
开发语言·c++·vscode·算法