• Stars
    star
    188
  • Rank 199,359 (Top 5 %)
  • Language
    TypeScript
  • Created over 5 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Solargraph extension for coc.nvim

coc-solargraph

Ruby language server extension using solargraph for coc.nvim.

Note: remember use fnameescape() for solargraph uri (solargraph:/) to open it by vim command.

Note: solargraph scheme returns html, but vim doesn't handle html, so it's converted to markdown.

Supporting

If you like my extension, consider supporting me on Patreon or PayPal:

Patreon donate button PayPal donate button

Install

Install solargraph by:

gem install solargraph

In your vim/neovim, run command:

:CocInstall coc-solargraph

Features

Coc.nvim support all features of solargraph

Configuration options

This extension contributes the following settings:

  • solargraph.trace.server: default: "off" Valid options: ["off","messages","verbose"]
  • solargraph.shell: The shell path used to launch solargraph server, default: null
  • solargraph.transport: The type of transport to use., default: "socket" Valid options: ["socket","stdio","external"]
  • solargraph.promptDownload: Prompt for download solargraph gem when not found., default: true
  • solargraph.externalServer: The host and port to use for external transports. (Ignored for stdio and socket transports.), default: {"host":"localhost","port":7658}
  • solargraph.commandPath: Path to the solargraph command. Set this to an absolute path to select from multiple installed Ruby versions., default: "solargraph"
  • solargraph.useBundler: Use bundle exec to run solargraph. (If this is true, the solargraph.commandPath setting is ignored.), default: false
  • solargraph.bundlerPath: Path to the bundle executable, defaults to 'bundle', default: "bundle"
  • solargraph.checkGemVersion: Automatically check if a new version of the Solargraph gem is available., default: true
  • solargraph.completion: Enable completion, default: true
  • solargraph.hover: Enable hover, default: true
  • solargraph.diagnostics: Enable diagnostics, default: false
  • solargraph.autoformat: Enable automatic formatting while typing (WARNING: experimental), default: false
  • solargraph.formatting: Enable document formatting, default: false
  • solargraph.symbols: Enable symbols, default: true
  • solargraph.definitions: Enable definitions (go to, etc.), default: true
  • solargraph.rename: Enable symbol renaming, default: true
  • solargraph.references: Enable finding references, default: true
  • solargraph.folding: Enable folding ranges, default: true
  • solargraph.logLevel: Level of debug info to log. warn is least and debug is most., default: "warn" Valid options: ["warn","info","debug"]

Use command :CocConfig to open config file.

Transport Options

Extension version 1.0.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
}

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

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 :CocCommand list.

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.

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 Solargraph Tips 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 restart vim, you can restart coc.nvim by :CocRestart.

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

License

MIT

More Repositories

1

coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
TypeScript
22,790
star
2

coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
TypeScript
1,000
star
3

coc-snippets

Snippets solution for coc.nvim
TypeScript
924
star
4

coc-python

Python extension for coc.nvim, fork of vscode-python
TypeScript
576
star
5

coc-prettier

Prettier extension for coc.nvim.
TypeScript
512
star
6

coc-tabnine

Tabnine integration of coc.nvim
TypeScript
470
star
7

coc-java

Java extension for coc.nvim
TypeScript
407
star
8

coc-git

Git integration of coc.nvim
TypeScript
401
star
9

coc-rls

Rust language server support for coc.nvim
TypeScript
378
star
10

coc-eslint

Eslint extension for coc.nvim
TypeScript
378
star
11

vim-jsx-improve

Syntax and indent plugin for React jsx.
Vim Script
285
star
12

coc-pairs

Basic auto pairs extension of coc.nvim
TypeScript
283
star
13

coc-lists

Common lists for coc.nvim
TypeScript
259
star
14

coc-json

Json language extension for coc.nvim
TypeScript
229
star
15

coc-yaml

Yaml language server extension for coc.nvim
TypeScript
226
star
16

coc-vetur

Vue language server extension for coc.nvim
TypeScript
217
star
17

coc-highlight

Document highlight and document colors LSP support for coc.nvim
TypeScript
210
star
18

coc-sources

Additional common sources of coc.nvim
JavaScript
200
star
19

coc-html

Html language server extension for coc.nvim.
TypeScript
196
star
20

coc-css

Css language server extension for coc.nvim
TypeScript
189
star
21

coc-yank

Yank highlight and persist yank history support for vim
TypeScript
188
star
22

coc-emmet

Emmet extension for coc.nvim
TypeScript
169
star
23

coc-vimtex

vimtex integration for coc.nvim
JavaScript
121
star
24

denite-git

Manger list of git objects with interface of denite.nvim
Python
73
star
25

coc-smartf

Make jump to character easier.
TypeScript
73
star
26

vim-node-rpc

Make vim behavior like neovim rpc server by use node server in the middle.
TypeScript
61
star
27

jsonc.vim

jsonc syntax support for vim
Vim Script
60
star
28

denite-extra

extra useful sources for denite.nvim
Python
55
star
29

coc-jest

Jest extension for coc.nvim
TypeScript
51
star
30

coc-tslint-plugin

coc.nvim extension that provides TSLint support using the typescript-tslint-plugin
TypeScript
49
star
31

coc-r-lsp

R LSP Client for coc.nvim
TypeScript
48
star
32

coc-stylelint

Stylelint language server extension for coc.nvim
JavaScript
42
star
33

vim-easygit

A git wrapper focus on simplity and usability
Vim Script
38
star
34

coc-imselect

Input method enhance for iTerm2 on mac.
TypeScript
37
star
35

coc-typos

Typos integration with coc.nvim
TypeScript
32
star
36

neovim

Node client API for both vim8 and neovim.
TypeScript
28
star
37

npm.nvim

Npm plugin to make vim user works with npm easier
Python
26
star
38

redismru.vim

MRU plugin build for speed with async IO operation
Vim Script
25
star
39

coc-neco

viml completion source for coc.nvim
Vim Script
23
star
40

coc-denite

Denite support of coc.nvim
Python
22
star
41

todoapp.vim

Todo management in vim using unite and sqlite
Vim Script
20
star
42

neoclide

Web enhanced IDE forked from Nyaovim
JavaScript
18
star
43

coc-tslint

Tslint language server extension of coc.nvim
TypeScript
17
star
44

rename.nvim

Rename plugin for neovim
TypeScript
16
star
45

plug.nvim

None block plugin manager for neovim
TypeScript
14
star
46

coc-repl

Read-Eval-Print-Loop (REPL) for coc.nvim
JavaScript
12
star
47

macnote.vim

Light weight note manager on mac using vim
Vim Script
11
star
48

macdown.vim

Live preview markdown in Chrome using applescript
JavaScript
11
star
49

wasm-fuzzy

Fuzzy match at native speed
C
10
star
50

mycomment.vim

one mapping for comment: <leader>c
Vim Script
10
star
51

coc-extension-codemod

Fix the code of coc.nvim extension.
JavaScript
10
star
52

coc-jedi

Deprecated, use https://github.com/neoclide/coc-python instead.
Python
10
star
53

coc-pyls

Deprecated, use https://github.com/neoclide/coc-python instead.
TypeScript
7
star
54

keep.nvim

Recover removed files made ease for neovim
JavaScript
5
star
55

neoclide-client

Embedding neovim as UI component with unified data flow
JavaScript
3
star
56

tern-neovim

Neovim tern plugin use remote plugin feature
Python
3
star
57

coc-wxml

wxml extension for coc.nvim
TypeScript
3
star
58

neovim-component

Editor component used for neoclide
JavaScript
2
star
59

electron-discuss

Discuss issues with electron
1
star