ruby LSP实现
ruby插件推荐用这个来实现,但是现在这个在加载文件索引时候,特别慢,时好时坏,所以现在推荐用Solargraph实现
- ruby LSP要求ruby版本3以上,如果在旧版本中使用,需要指定bundleGemfile路径
旧版本ruby使用ruby LSP教程
$ 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中配置
"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
文章来源:https://www.toymoban.com/news/detail-852416.html -
vscode setting设置文章来源地址https://www.toymoban.com/news/detail-852416.html
"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",
- 记得关闭扩展的自动更新功能
到了这里,关于[ruby on rails] ruby使用vscode做开发的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!