Giter Club home page Giter Club logo

vscode-solargraph's Introduction

VS Code Solargraph Extension

Solargraph is a language server that provides intellisense, code completion, and inline documentation for Ruby.

Screenshot

Features

  • Context-aware suggestions and documentation for the Ruby core
  • Detection of some variable types and method return values (e.g., String.new. returns String instance methods)
  • Identification of local, class, and instance variables within the current scope
  • Find references and rename symbols (experimental as of solargraph gem v0.22.0)
  • Support for gems
  • Near-complete support for the Ruby core and stdlib
  • Partial support for Ruby on Rails

Requirements

You need to install the Ruby gem:

gem install solargraph

Usage

Code Completion

Open a Ruby file and start typing. Solargraph should start providing contextual code suggestions. To start a search manually, hit ctrl-space. Example:

Stri # <- Hitting ctrl-space here will suggest String

Method arguments and documentation can be seen by starting parentheses after the method call. Example:

String.new.casecmp( # <- Displays arguments and documentation for String#casecmp

Documentation

Solargraph provides a command to access searchable documentation directly from the IDE.

  • Hit ctrl+shift+r (or hit ctrl+shift+p and find Search Ruby Documentation).
  • Enter a keyword or path to search; e.g., String or Array#join.

The documentation includes the Ruby core, required gems, and the current workspace. Documentation from the workspace is automatically updated when you save the corresponding file.

You can also hover over variables, constants, and method calls to see popup information with links to more documentation.

Documenting Your Code

Using YARD for inline documentation is highly recommended. Solargraph will use YARD comments to provide the best code completion and API reference it can.

In addition to the standard YARD tags, Solargraph defines a @type tag for documenting variable types. It works with both local and instance variables. Example:

# @type [String]
my_variable = some_method_call
my_variable. # <= Hitting crtl-space here will suggest String instance methods

Intellisense

Solargraph also provides hovers and go to definition.

Hover your mouse over code to see method definitions, return values, and links to documentation.

To go to a method or variable's definition, right-click and select "Go to Definition" from the context menu, or press F12 for the definition at the cursor.

Gem Support

Solargraph is capable of providing code completion and documentation for gems. When your code uses require to include a gem, its classes and methods become available in completion and intellisense.

You can make sure your gems are available with the commands Build new gem documentation or Rebuild all gem documentation in the command palette.

Solargraph and Bundler

If your project uses Bundler, the most comprehensive way to use your bundled gems is to bundle Solargraph.

In the Gemfile:

gem 'solargraph', group: :development

Run bundle install and use bundle exec yard gems to generate the documentation. This process documents cached or vendored gems, or even gems that are installed from a local path.

In order to access intellisense for bundled gems, you'll need to start the language server with Bundler by setting the solargraph.useBundler option to true.

Note: solargraph.bundlerPath should be an absolute path to bundler executable.

Diagnostics (Linting)

To enable diagnostics, set the solargraph.diagnostics configuration to true.

Solargraph uses RuboCop for diagnostics by default. If your project has a .solargraph.yml file, you can configure the diagnostics in its reporters section. Example:

reporters:
- rubocop

See the configuration guide for more information about the .solargraph.yml file.

Use a .rubocop.yml file in your project's root folder to customize the linting rules.

Restarting Solargraph

Some changes you make to a project, such as updating the Gemfile, might require you to restart the Solargraph server. Instead of reloading the VS Code window, you can run Restart Solargraph from the Command Palette.

Project Configuration

Solargraph will use the .solargraph.yml file for configuration if it exists in the workspace root. The extension provides a command to Create a Solargraph config file, or you can do it from the command line:

$ solargraph config .

The default file should look something like this:

include:
  - ./**/*.rb
exclude:
  - spec/**/*

This configuration tells Solargraph to parse all .rb files in the workspace excluding the spec folder.

Updating the Core Documentation

The Solargraph gem ships with documentation for Ruby 2.2.2. As of gem version 0.15.0, there's an option to download additional documentation for other Ruby versions from the command line.

$ solargraph list-cores      # List the installed documentation versions
$ solargraph available-cores # List the versions available for download
$ solargraph download-core   # Install the best match for your Ruby version
$ solargraph clear-cores     # Clear the documentation cache

Extension Settings

This extension contributes the following settings:

  • solargraph.commandPath: Path to the solargraph command. Set this to an absolute path to select from multiple installed Ruby versions.
  • solargraph.useBundler: Use bundle exec to run solargraph. (If this is true, solargraph.commandPath is ignored.)
  • solargraph.bundlerPath: Path to the bundle command.
  • solargraph.checkGemVersion: Check if a new version of the Solargraph gem is available. Default is true (recommended).
  • solargraph.diagnostics: Enable diagnostics reporting. See the configuration guide for diagnostics options.
  • solargraph.completion: Enable autocompletion.
  • solargraph.hover: Enable tips on hover.
  • solargraph.autoformat: Enable automatic formatting while typing.
  • solargraph.formatting: Enable document formatting. The gem currently uses RuboCop for formatting.
  • solargraph.symbols: Enable search for document and workspace symbols.
  • solargraph.definitions: Enable go-to-definition.
  • solargraph.rename: Enable symbol renaming.
  • solargraph.references: Enable finding references.
  • solargraph.folding: Enable folding ranges.
  • solargraph.transport: socket (default), stdio, or external. See Transport Options for more information.
  • solargraph.externalServer: The host and port for external transports. See Transport Options for more information.
  • solargraph.logLevel: The logging level. Options in ascending amount of detail are warn, info, and debug. The default is warn.

Transport Options

Extension version 0.18.0 introduces the solargraph.transport setting with the following options:

  • socket: Run a TCP server. This is the default option.
  • stdio: Run a STDIO server.
  • external: Connect to an external server instead of starting a new one.

Most users should use the default socket option or switch to stdio in case of network issues.

The external option is intended for cases where the project is hosted in a different environment from the editor, such as a docker container or a remote server. Users can opt to run a socket server in the remote environment and connect to it via TCP. Example configuration:

"solargraph.transport": "external",
"solargraph.externalServer": {
    "host": "localhost",
    "port": 7658
}

More Information

See the Solargraph website for guides, tips, and updates.

Known Issues

vscode-solargraph's People

Contributors

a0n avatar castwide avatar cleancut avatar doudou avatar earlopain avatar electr0sheep avatar g-arjones avatar hakshu25 avatar matthiaswinkelmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-solargraph's Issues

html not parsed into doc completion and type not hinted for params method

When I autocomplete and the documentation is showed, the html not rendered properly
Here an example:
schermata da 2017-06-28 14-53-47
As you can see there are p tags and code tags not rendered properly.
Another problem is that the extension not hint you on the type of params of a method. For example i have a ruby class in my lib directory documented as showed below:
schermata da 2017-06-28 15-04-45
But when I initialize the object in my main file, the documentation provided by intellisense give me no informtion about the type of the opt variable. Here a screen:
schermata da 2017-06-28 15-05-04

I hope that you will resolve this problem.
P.S Great job guys! You have created the best intellisense/autocomplete extension for ruby that i have seen so far apart RubyMine

Solargraph Request textDocument/hover failed

I can't get solargraph to work at all :( I'm getting this error:

[Error - 4:06:03 PM] Request textDocument/hover failed.
  Message: [TypeError] no implicit conversion of Solargraph::Workspace into String
  Code: -32603 

solargraph 0.21.0
ruby 2.5.1
VSCode 1.23.0

Solargraph seems to handle go-to-definition/peek-definition too slow

I've found some amount of similar issues here, that go-to-definition/peek-definition takes around 10-20 seconds to perform (instantaneously in Sublime Text 3), and found a solution to change it for rubyLocate. I've tried it, but have waited for almost an hour and a half for VSCode to finish Indexing Ruby source files, and nothing. It keeps indexing forever.
Is there any way to explicitly check if it's even doing anything? Or is there any way to make solargragh perform go-to-definition as fast as it's done in rubymine/sublimetext?
Code indexing in Sublime Text on my code base takes roughly 7-10 minutes. I really like the flow and looks of VS Code, but the lack of go-to-definition function makes it almost unusable.

If there is already a solution, I would appreciate any help! Thanks in advance!

does it support include key word?

module MyModule
def helloworld
puts "helloworld"
end
end
include MyModule
hello

when i type hello then ctrl+space, can it suggest me the helloworld method?
thx!

"invalid byte sequence in US-ASCII" on latest version

After I open a Ruby project and use "Go to symbol in workspace", I get this in the Output panel:

[Error - 13:43:44] Server initialization failed.
  Message: invalid byte sequence in US-ASCII
  Code: -32603 

And this screenshot:

screenshot

Needless to say, due to these errors, the extension doesn't work.

Autocomplete doesn't work inside string interpolation

First of all I'd thank you for your awesome work.
I discovered that inside string interpolation intellisense does not show any suggestion.

(see the attachment for an example)

Here's my configuration:
VSCode 1.21
Solargraph gem 0.17.3
string_interpolation_autocomplete

Separate icons for snippets and keywords.

When starting to write "class" or "if", Solargraph suggests snippets using the keyword icon.

In Python (as seen under), separate icons are used (top = keyword, bottom = snippet).
In VS Code you can turn off snippet suggestions, but Solargraph still suggests them.
py_keyw_snipp

Solargraph::FileNotFoundError when opening a file

Every time I open a ruby file I get the following error:

[Error - 2:53:38 PM] Request textDocument/documentSymbol failed.
  Message: [Solargraph::FileNotFoundError] Source not found for myfile.rb
  Code: -32603 

I'm using the latest Solargraph version 0.19.1

Hide blank expanded documentation

The expanded documentation window should not be visible when there is no additional documentation available.

A fix for this is in the repo. Publication pending.

Solargraph::FileNotFoundError

I was having this issue and after uninstalling and reinstalling the Solargraph gem, I am now getting an error in the integrated terminal every time I open a file in my workspace:

[Error - 09:30:33] Request textDocument/documentSymbol failed.
  Message: [Solargraph::FileNotFoundError] Source not found for /path/to/whatever/file.rb
  Code: -32603 

Disable or customize linting?

I've installed solargraph and it seems to work well. However, we have a code base that does not follow the recommended linting patterns the extension suggests.

How can I customize the linter rules, or disable it entirely for the time being, while still getting code completion and intellisense?

[question] Performance issue

Currently my laptop uses 2 - 3 seconds to display any suggestions in the outer scope. Inside a definition Solargraph use at the fastest maybe 0.5 seconds.

Is there a specific reason for this?

Also I wondered if you have a list or something with upcoming features, what's being worked on?

Don't work

I have ubuntu 16.04, rvm, ruby 2.4, VS Code 1.10.2. I installed gem and extension, but it does not work

"Request textDocument/hover failed" in Vagrantfile

I'm going through the Consul "Getting Started" tutorial in my free time. I downloaded their demo Vagrantfile and opened it in Visual Studio Code. The global $script had a warning (I'm sure you can guess what for). When I hovered over it, the output pane popped up with this error message:

[Error - 07:57:30] Request textDocument/hover failed.
  Message: undefined method `empty?' for nil:NilClass
  Code: -32603

The output pane target was set to the Ruby Language Server.

I might take a look at fixing it myself (no promises), but I figured I ought to at least make the issue known. :)

Solargraph with Docker

I'm using docker in my rails app. How can I work with Solargraph and Docker? Is there any configuration to do?

Deprecation - use MarkdownString for command-links

This extension has been identified as using command-links in either hovers or decorations. The August release (1.16) is the last release to support this in the MarkedString and with September the MarkdownString must be used. We are doing this because of security concerns. Background and details are explained here: microsoft/vscode#33577 (comment)

The adoption should be straight forward and usages of MarkedString need to be replaced with:

let md = new MarkdownString(content);
md.isTrusted = true;

Please let us know if you need more information. Thanks and Happy Coding

Performance and config for bigger projects

This is a really cool project and already works great in many cases. The only problem I have that it does not work for bigger projects. For example in a Rails application with > 100.000 lines of code the auto completion does not work at all.

As a solution I tried to only opened app/ with vscode. After this the auto completion was still a bit slow but started to work. I would still like to open the root folder so I created a .solargraph.yml config file to achieve a similar behavior:

---
include:
- "app/**/*.rb"
extensions: []

Unfortunately the auto completion still does not work. Am I missing something or is this an issue with the solargraph config?

solargraph with VSCode and Ruby 2.5.1 uses all CPU and Memory

Platform: Mac OS X 10.11 El Capitan

$ top # or htop
...ruby-2.5.1@content/bin/solargraph

# 98% CPU , takes all memory

It makes it pretty much unusable with Ruby 2.5.1 . I noticed that it still works fine with Rails projects and Ruby versions up-to 2.4.3

Custom port for solargraph server?

It would be great to have a possibility to set custom port for solargraph server in extension settings (default is 0 which could be already in use).

Keeps trying to yardoc my node projects

So I installed the extension as I am starting to work on a legacy Ruby project but now all day whenever I open an Node project in VSCode yardoc keeps generating a .yardoc and a doc directory despite the project I have open having no Ruby code in it. Seems like a bug.

Thanks!

Solargraph gem not found

With yesterday's update, I'm getting this error:

Solargraph gem not found. Run gem install solargraph or update your Gemfile.

I have solargraph installed as a global gem, so I don't understand why I'm having this error. When I click on Install Now nothing happens.

[Feature-Request] add completion for hook methods

it is a common practice for ruby programmers to add methods dynamically when some modules are extended, prepended or included. For example:

module MyModule
  def self.included(klass)
    klass.class_eval do
     # This method add new functionality
     # @param an_argument [SomeType] a specific argument
     # @return [SomeType]
     def another_method(an_argument)
       #Some business code
     end
   end
 end
end

class MyClass
  include MyModule
end

kl = MyClass.new
kl. # => it would be great if in method suggestion appears another_method too

the same functionality would be great for the other ruby hook methods and for klass.instance_eval method

Extension starts multiple solargraph processes consuming all RAM

Hey, thanks for this extension.

I am not sure if the problem's root is in this extension or solargraph itself, but after a while (~10 minutes) of programming my Laptop becomes super slow and using top I notice that there are at least 10 if not more solargraph processes running consuming all RAM (and I have 12 GB of RAM). Is there a way of limiting the number of spawned processes?

Failed to install on mac

I tried to install this extension on my mac, but got next error: Solargraph gem not found. Run gem install solargraph or update your Gemfile.
When I run the command in the terminal, got next error. Any idea why it is happening?
image

Solargraph gets port "0" on VSCode start or when using "Solargraph: Restart Solargraph" command

System, VSCode, and extension info

OS: Windows 10 Pro 1709 build 16299.402
VSCode Version: 1.22.2
Solargraph extension: 0.16.0
Possibly relevant extensions:
Ruby extension: rebornix.ruby version 0.18.0
Chef Extension for Visual Studio Code Pendrica.chef version 0.6.4

Output of solargraph -t in VSCode integrated console:

PS C:\development\chefInfrastructure> solargraph -v
0.20.0

Relevant settings:

    // Ruby and Solargraph
    "solargraph.diagnostics": "rubocop",

Contents of .solargraph.yml:

---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- doc/**
- "**/*.md"
domains: []
required: []
# plugins:
# - runtime
All settings:

// Place your settings in this file to overwrite the default settings
{
    // Common core
    "editor.tabSize": 2,
    "editor.renderWhitespace": "boundary",
    "editor.wordWrap": "on",
    "editor.mouseWheelZoom": true,
    "editor.wordBasedSuggestions": false,
    "editor.fontFamily": "'Roboto Mono', monospace",
    "editor.fontSize": 13,
    "window.zoomLevel": 0,

    "explorer.confirmDelete": false,
    "explorer.confirmDragAndDrop": false,

    "workbench.editor.closeOnFileDelete": false,
    "workbench.iconTheme": "vscode-icons",

    "extensions.autoUpdate": false,

    // VSIcons
    "vsicons.associations.files": [
        { "icon": "config", "extensions": [".conf"] },
        { "icon": "docker", "filenamesGlob": ["docker-compose**"] }
    ],
    "files.associations": {
        //"*.env": "ini",
        "dockerfile**": "dockerfile"
    },

    // Markdown
    "markdown-toc.updateOnSave": true,

    // Ruby and Solargraph
    "solargraph.diagnostics": "rubocop",

    // Chef
    "rubocop.enable": false,
    //"rubocop.path": "C:\\Tools\\opscode\\chefdk\\bin\\cookstyle.bat",
    //"rubocop.configFile": ".rubocop.yml",
    "foodcritic.enable": false,

    // Git and source control
    "gitProjectManager.baseProjectsFolders": [
        "c:/development"
    ],
    "git.path": "C:/Program Files/Git/bin/git.exe",
    "git.confirmSync": false,
    "git.defaultCloneDirectory": "c:/development",
    "git.enableCommitSigning": true,
    "git.autofetch": true,

    "gitlens.advanced.messages": {
        "suppressCommitHasNoPreviousCommitWarning": false,
        "suppressCommitNotFoundWarning": false,
        "suppressFileNotUnderSourceControlWarning": false,
        "suppressGitVersionWarning": false,
        "suppressLineUncommittedWarning": false,
        "suppressNoRepositoryWarning": false,
        "suppressResultsExplorerNotice": false,
        "suppressShowKeyBindingsNotice": true
    },

    // PHP
    "php.validate.executablePath": "C:\\Tools\\php-7.0.27\\php.exe",
    "php.executablePath": "C:\\Tools\\php-7.0.27\\php.exe",
    "php.suggest.basic": false,

    // Powershell and terminal
    "powershell.codeFormatting.preset": "OTBS",
    "powershell.integratedConsole.focusConsoleOnExecute": false,
    "terminal.external.windowsExec": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
}

All extensions:

>code --list-extensions
AlanWalk.markdown-toc
bierner.markdown-preview-github-styles
castwide.solargraph
DavidAnson.vscode-markdownlint
donjayamanne.githistory
DotJoshJohnson.xml
eamodio.gitlens
felipecaputo.git-project-manager
felixfbecker.php-intellisense
formulahendry.code-runner
GrapeCity.gc-excelviewer
hangxingliu.vscode-nginx-conf-hint
humao.rest-client
irvinlim.language-modsecurity
le0zh.vscode-regexp-preivew
mechatroner.rainbow-csv
mikestead.dotenv
ms-vscode.PowerShell
Pendrica.chef
PeterJausovec.vscode-docker
RandomChance.logstash
rebornix.Ruby
ria.elastic
robertohuertasm.vscode-icons
Shan.code-settings-sync
shanoor.vscode-nginx
tuxtina.json2yaml
ziyasal.vscode-open-in-github


Hey there,

I can't say exactly when this started happening, but the Solargraph gem has started launching listening on port 0, and so is not functioning at all in VSCode, except for the documentation search feature. By not functioning, I mean there is no auto-complete, Ctrl + Space returns a No suggestions message, and linting (using Rubocop) is not running.

In the dev console, it shows the gem having launched successfully, and reports the correct PID. It also shows the port at what the gem should be running on.

This is what Process Explorer says about the running ruby instance:
solargraph-port0

This is the output of the dev console in VSCode during launch:
solargraph-vscode-launch

I'm not too sure how to troubleshoot this further, so please let me know if there's any additional information I can pass on to you!

Disable linter

Is it possible to disable the linter? If not we should have the option to do it!

Issue with installing the gem

Hello,

So I've come across an issue with 0.11.1 version of the gem, where I install the gem thru the console however when opening VS code I get the following:

image
image

My console shows me it is installed however VS code does not. I've tried rebooting, restarting VS Code etc. however that does not seem to fix my issue.

Now one possible solution or issue that I have is that my ruby code is NOT executed on my machine, but the code is being synced to a remote server. I do not run the code, so the gemfile is never executed, maybe this causes the issue ? (I'm fairly new to ruby, sorry If I'm missing something)

Server fails to launch due to bad arguments; extension can't handle user profile paths with spaces in the username?

Hey there,

OS: Windows 10 Pro 1709 build 16299.192
VSCode Version: 1.19.3
Solargraph extension: 0.11.1
Possibly relevant extensions:
Ruby extension: rebornix.ruby version 0.16.0
Chef Extension for Visual Studio Code Pendrica.chef version 0.6.4
All extensions:

code --list-extensions
AlanWalk.markdown-toc
bierner.markdown-preview-github-styles
burtlo.inspec
castwide.solargraph
codezombiech.gitignore
DavidAnson.vscode-markdownlint
donjayamanne.githistory
DotJoshJohnson.xml
felipecaputo.git-project-manager
felixfbecker.php-intellisense
formulahendry.code-runner
hangxingliu.vscode-nginx-conf-hint
hnw.vscode-auto-open-markdown-preview
irvinlim.language-modsecurity
jirkafajfr.vscode-kitchen
le0zh.vscode-regexp-preivew
mikestead.dotenv
ms-vscode.PowerShell
Pendrica.chef
PeterJausovec.vscode-docker
rebornix.Ruby
robertohuertasm.vscode-icons
shanoor.vscode-nginx
ziyasal.vscode-open-in-github

I've been trying to get your extension to work, and I think I found a bug. Entering Ctrl+Space to show suggestions was showing a Loading... prompt that would never finish. When I opened Process Explorer to see if VSCode had a Ruby process running, there was nothing. Running Solargraph: Restart Solargraph showed a Ruby process running for a split second, then exiting.

To make sure the Gem was working, I ran solargraph server -p 0 in a Powershell prompt (having seen you suggest that as a method for testing in another issue), and pointed my browser to the localhost port. I saw the "Sinatra doesn’t know this ditty.", and corresponding output in the server log in my terminal, so that confirmed there wasn't anything the matter with the Gem.

My username has a space in it, so my profile path does as well ("C:\Users\<Firstname> <Lastname>\..."). In the dev console, when running the Solargraph: Restart Solargraph command, this error is thrown: [Extension Host] ERROR: "solargraph server" was called with arguments ["<Lastname>\\.vscode\\extensions\\castwide.solargraph-0.11.1/views"] Usage: "solargraph server". It seems like the command is getting split by the space in my profile folder name?

Let me know if there's any further context I can provide!

Is the doc folder needed?

Hello,
I just checked it quickly and I think it's the YARD gem that's generating the doc folder, correct?

Is this then used by the solargraph server to provide auto-completion? Would it be possible not to have it or to specify a different path for it?

Thanks

Default `solargraph.diagnostics` to false

Adding solargraph to a project should not automatically enable Rubocop checking for the project. It's very difficult for people to track down:

  1. where the linter is actually coming from (why would anyone expect SolarGraph?)
  2. how to update the linter settings
  3. how to turn it off

Completion menu shows "Loading..." indefinitely

Installed VS Code and the extension to try it out on a real project.

I press Ctrl-Space, and the popup just says "Loading..." indefinitely.

The gem is installed, version 0.11.1 and the server is running (started by VS Code).

Solargraph not found with VSCode on Arch Linux

I've installed VSCode from the AUR, and I'm running binary version 1.20.0. I've got my solargraph gem installed in my local path located /home/egee/.gem/ruby/2.5.0/bin/solargraph (notice not installed in my /usr/ directory, no sudo required). I can run solargraph from any terminal, including the terminal from within VScode.

When I launch VSCode and open a Ruby file, I get the error message Solargraph gem not found. Run `gem install solargraph` or update your Gemfile..

Any idea what's going on here? My other Ruby extensions such as rubocop work just fine with VSCode.

Go to Definition nor hover working

Using VS Code 1.21.0 on macOS, Ruby extension 0.17.0 and Ruby Solargraph extension 0.17.3, nothing is working anymore.

  1. Hovering over things produces no visual change besides flashing "Loading" very quickly. The console states:
ERR An unknown error occurred. Please consult the log for more details.  log.ts:171
[Extension Host] 127.0.0.1 - - [12/Mar/2018:14:02:55 PDT] "POST /hover HTTP/1.1" 200 32  console.ts:136 
- -> /hover
  1. Right-clicking a class (of mine) and choosing Go to Definition animates a narrow blue line beneath the tabs for a second or so then shows a No definition found for 'MyClass' tooltip. The console states:
ERR An unknown error occurred. Please consult the log for more details.  log.ts:171
[Extension Host] 127.0.0.1 - - [12/Mar/2018:14:06:07 PDT] "POST /hover HTTP/1.1" 200 32  console.ts:136 
- -> /hover

What log am I supposed to consult for more details (and so I can provide them here)?

Support renaming symbols

Please add the ability to rename symbols in Ruby code, just like it's possible with JavaScript and Python.

Originally posted here.

Autocomplete for gems

Hi guys!

Is this extension supposed to show suggestions for methods in the gems I use?

Thanks

Autocomplete/documentation does not work

VSCode 1.20.1

When I type and press ctrl+space, the methods do show but there's no documentation.

image

I have gem installed. Should anything else be done to make this working?

When VSCode gets the autocomplete response for Solargraph it erases the simple word autocompletion

This extension have a really weird behaviour when it comes to autocompleting from the current dictionary of words (usually the active file) and from the solargraph gem itself.

It seems like whenever we get a response from the solargraph server with extension it automatically removes all the dictionary words from the suggestions.

Example:

foo

foo_string = "string"

# typing...
fo # trigger autocomplete here!

You won't see foo when you trigger the autocomplete there at the last line... you will only see foo_string. 😞

Make IntelliSense work in unsaved files

Right now, SolarGraph only works in unsaved files. But I'd like it if it also worked in unsaved files.

I've attached two GIFs if necessary.

Unsaved file, where extension doesn't work:

ruby - unsaved file

Saved file, where extension works:

ruby - saved file

Make IntelliSense work with my own functions

This works great for showing the parameters needed for standard Ruby functions, but how do I get it to work with functions that I've created myself? And especially those that are imported from other files using require_relative?

[question] Open definition in new tab

Is it possible to configure the extension to open definitions in a new tab instead of replacing the current tab? Once i go to a definition, i loose scope of the previous method i was debugging.

Peek definition is is a good replacement for that so far, but i was wondering if its possible to open a new tab to work on two files at the same time.

Thanks for the extension!
It's super usefull!

Errors when creating a function

I'm using a Mac.

I create a new file, and if I type "d", then I get the following error:

[Error - 14:26:16] Request completionItem/resolve failed.
  Message: Completion item could not be resolved
  Code: -32600 

GIF below:

vsc-ruby


If I change focus to another app then back to VSC, I get a different error:

[Error - 14:36:59] Request textDocument/completion failed.
  Message: Invalid offset
  Code: -32603 

GIF below. As you can see, it does show the snippet for def correctly here.

vsc-ruby

Gem support

Solargraph is capable of providing completion and intellisense for gems that have YARD documentation, which can be generated from the command-line via yard gems or yard gems --rebuild.

The extension should provide shortcuts to the build and rebuild commands in the palette.

Question: setup with multi Ruby install

I can not get solargraph works with VS code
What operating system are you using? Window 10 Edu
What version of Ruby? 2.0.0 as system path, 2.2.4 (solargraph gem installed).
What version of the vscode-solargraph extension? 0.8.0
Do you have any other extensions installed?

castwide.solargraph
donjayamanne.githistory
donjayamanne.python
formulahendry.code-runner
lei.theme-chromodynamics
magicstack.MagicPython
ms-vscode.cpptools
rebornix.Ruby
What version of the Solargraph gem? solargraph-0.12.2
Does running solargraph help return a list of commands? no
Did you change any of the Solargraph configuration settings? 

"solargraph.commandPath":"D:/SIM/script/ruby/setup/ruby22/lib/ruby/gems/2.2.0/gems/solargraph-0.12.2/bin/solargraph"

uninitialized constant Gem::MissingSpecError

Issue

When attempting code completing (command + tab) I experience a combination of:

  • Really slow completions and go-to navigation (5-10s on average)
  • Fatal errors ("LOADING" followed by no action)
  • Errors in the logs.

The main error I often see is uninitialized constant Gem::MissingSpecError followed by a stack trace that references this file: gems/solargraph-0.17.2/lib/solargraph/yard_map.rb (see attached stack trace in solargraph-0.17.2.log).

The rescue on line 336 does not seem to capture this, as I believe that constant is only available in 2.4.0:

331     def process_requires
332       required.each do |r|
333         spec = Gem::Specification.find_by_path(r)
334         begin
335           spec = Gem::Specification.find_by_name(r) if spec.nil?
336         rescue Gem::MissingSpecError => e
337           # @todo How to handle this?
338         end
339         if spec.nil?
340           STDERR.puts "Required path not found (pgp): #{r}"
341         else
342           @gem_paths[spec.name] = spec.full_gem_path
343           add_gem_dependencies spec
344           result = YARD::Registry.yardoc_file_for_gem(spec.name)
345           yardocs.unshift result unless result.nil? or yardocs.include?(result)
346         end
347       end
348     end

Changing line 336 to just catch a general Exception gets us further (see the solargraph-patched log below), however it still suffers from terrible lag.

Setup Details

Ruby: 2.3.4
Solargraph: 0.17.2
Source code project: https://github.com/pact-foundation/pact_broker
VS Code: Version 1.20.1 (1.20.1) f88bbf9137d24d36d968ea6b2911786bfe103002
VS Code Ruby: 0.16.0
VS Code Solargraph: 0.12.0

Files for debug

solargraph-0.17.2.log
solargraph-0.17.2-patched.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.