-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get solargraph tcp lsp server to work for completion? #1874
Comments
ALE doesn't use the omnicompletion keybinds to trigger completion because the function for omnicompletion is synchronous. ALE instead makes a request for completion as you type, and sends the keys to open the omnicomplete menu after the results have come back. @hsanson You added support for the linter. Does it support completion? |
@w0rp yes, solargraph supports auto-completion. @Frydac the issue here is that for the solargraph linter to start you must have a valid ruby project root. Open the a.rb file in vim/nvim and then run the following command:
If this returns an empty string it means ALE is unable to find the root path of the ruby project. The way ALE finds the root folder are:
If you create an empty Rakefile or Gemfile in the same folder as the a.rb file then you should get autocompletion working (see screen below). Not that the first time it can take some time to get any auto-complete suggestions so be patient. Also I am not 100% certain but I think you must start the solargraph server inside the same root folder. |
If it's the working directory that's the problem, we can fix that by prefixing the command with |
Thanks for the quick help! Not having a root directory seemed to have been the problem, after adding an emtpy Gemfile it works. Working with a Gemfile/Rakefile is be workable for me, though, just my 2 cents, in my case, ideal would be if it took the furthest git directory (directory with .git file or directory), we work with modules and submodules, with different loadpaths into the submodules where the ruby code is spread out over. Though I would have to put a |
Maybe we could make it look for |
Solargraph allows to set configuration options by creating a .solargraph.yml file at the root of the project using it. Therfore this file is a good canditate for finding ruby projects root paths. Initial discussion: dense-analysis#1874 (comment)
I created a PR that adds .solargraph.yml as search candidate for ruby root paths. Regarding the .git I believe that this functionality is generic and applies to all projects, thus should be considered sort of global fallback by Ale. Maybe adding a FindRepoRoot() method that searches for common version control folders (e.g. .git, .svn, etc) similar to what the vim-projectroot plugin does. Then individual ale linters may use that method as last resource to find the project root paths. |
It depends on the language and the program. Some programs don't work at all without a configuration file or additional settings, like ESLint or |
Solargraph allows to set configuration options by creating a .solargraph.yml file at the root of the project using it. Therfore this file is a good canditate for finding ruby projects root paths. Initial discussion: dense-analysis#1874 (comment)
Now @hsanson has made it so it searches for |
@Frydac if solargraph is working for you it would be good to close this issue. |
Thx for all the help, I'm trying to make it work in tandem with youcompleteme (it has some extra features, e.g. fuzzy search into the list of suggestions, suggestions based on symbols in the open documents, ..), which on windows seems to work, but not on linux.. But I'll open a new issue once I understand things better and can ask a proper question about this. |
Solargraph now runs in |
Just wondering, I had a ruby project folder and completion wasn't working until I created an empty Gemfile as suggested by @w0rp. From what I understood of this issue, Ale should be able to set the root project falling back where a .git directory is found, but it seems that is not working (or I didn't understand 😅) |
|
vim-ale seems to need to work in a source project for solargraph to work: dense-analysis/ale#1874
Information
VIM version
VIM - Vi IMproved 8.1 (2018 May 17, compiled May 25 2018 00:50:25)
Included patches: 1-22
Operating System: manjaro linux
:ALEInfo
What went wrong
Hi, I'm trying to get the solargraph lsp server to work.
I've been using ale for some time for ruby with e.g. rubocop, which seems to be workig as intended.
In order to get better completion in ruby I wanted to try solargraph.
But there doesn't seem to be coming any suggestions from it.
When I use rubocop, I can see the command history in ALEInfo the
Command History
section, but when only solargraph is enabled, I never see anything appearing in that section.Reproducing the bug
I installed the solargraph gem:
I enabled ale completion and disabled all other linters, as the ALEInfo confirms
I'm not sure, but looking at the commit that added solargraph (09e43ab) there doesn't seem to be any information on how to start the server, so I presume I have to start it myself manually (Is this in the docs somewhere?):
Quick test with netcat to see if the port is actually used
I create a new rubyfile
a.rb
, and can check its filetype in vim to be ruby.I put some code similar to the example page on solargraph (http://solargraph.org/demo):
On the last line, I expect omnicomplete to be able to suggest
func_a
when press<C-x><C-o>
, but it doesn't.I expect to see communication logs in ALEInfo, but I don't.
After a few characters of func_a, I get a suggestion, but I'm guessing that is the built in ruby omnicomplete (or I also have vim-ruby installed).
The text was updated successfully, but these errors were encountered: