Rls: Add commands to the command line interface

Created on 3 May 2017  Â·  15Comments  Â·  Source: rust-lang/rls

Currently we only support 'goto def' (def). We should add all the other messages we support.

To do so (all in cmd.rs):

  • add a function for creating a ServerMessage, see def() for an example and server.rs to figure out what messages exist and their format. You'll also want to look at https://github.com/gluon-lang/languageserver-types/blob/master/src/lib.rs to see the format for params, etc.
  • add a branch to the match in run() to parse the command
  • add docs to help()
  • test that it works
good first issue

Most helpful comment

For anyone else wanting to add command, I found the following resources helpful:

Remaining todos:

  • CodeAction
  • Formatting
  • RangeFormatting
  • ResolveCompletion

All 15 comments

Can I pick this up?

@Nashenas88 there's quite a bit to do here - each request in the LSP needs implementing. I would do a few and then move on before you get bored :-) (That's a yes, to be clear)

I'll comment on the ones I get through and leave the rest for other people interested in joining RLS dev.

Update: Done

  • [x] hover
  • [x] rename

I'm interested in picking a few of these commands up — thanks for the steps @nrc. I'll aim to get a PR open within the next few days!

@samsymons awesome, thanks! Let me know if you need any pointers

This issue looks like it's still available. I'm interested in picking up this task and giving it a shot.

@furpuddle great! The first thing to do is to get the command line interface running so you can test it (it can be a bit tricky to put together a command that gives the expected result, you'll want to try it on a very small project so you're not waiting too long). Then pick a command and see if you can follow the other commands in cmd.rs to get support (you should only need to change that file). Ping me here, or on irc, or gitter if you get stuck :-)

I'm also interested in getting started contributing by work on this as well. I
guess I'll start with the Formatting command. (edit: I haven't started on this so anyone feel free).

Looks like the remaining work that needs to be done is the following:

done:

  • Definition
  • Hover
  • Rename
  • Symbols
  • References
  • FindImpls
  • Completion
  • DocumentHighlight
  • Deglob
  • ExecuteCommand

todo:

  • CodeAction
  • Formatting
  • RangeFormatting
  • ResolveCompletion
  • WorkspaceSymbol

I'm including what @furpuddle had done, but it looks like he or she hasn't made a
pull request yet?

I was thinking of making the command line a little more friendly with respect to
invalid input. For example, instead of panicking on invalid input, it would loop
and request a valid argument until they provide a valid one or Ctrl-C.

Another thing that would be nice is default arguments. For example, format takes
arguments whether to use tabs or spaces and how many for an indentation, and
these could have defaults. In addition, format takes additional optional properties, and seems like the default here would just be an empty collection.

Just wanted to know what you guys think before I do that.

instead of panicking on invalid input, it would loop and request a valid argument

This sounds great!

Another thing that would be nice is default arguments

This also sounds nice

@furpuddle Is there any reason not to create a pull request for your changes on September 22?

(Also, thanks for summarizing the status, @willbush!)

For anyone else wanting to add command, I found the following resources helpful:

Remaining todos:

  • CodeAction
  • Formatting
  • RangeFormatting
  • ResolveCompletion

Thanks for the merges @nrc. I resolved the conflicts in #573 and added the ranged formatting query.

Remaining todos (that I probably won't get to):

• CodeAction
• ResolveCompletion

Hi, @nrc. I am taking a stab at CodeAction, and had two questions.

1) Can I decide how many arguments to use and determine their orders my own in the cmd.rs run() function? I searched in code but can't find anything about the interface. Is the cli just for debug or test purpose?(find it in the contributing.md, sorry for not reading the document.)

2) I am not sure how to deal with the context: CodeActionContext in the CodeActionParams, it includes a diagnostics: Vec<Diagnostic> which would probably need to specify vary length of arguments in the code_action? And I don't know what should be pass in to Diagnostic::new() to make a Diagnostic struct? Can you give me some pointers?

@xiongmao86

Can I decide how many arguments to use and determine their orders my own in the cmd.rs run() function?

Yes, but they should basically match the parameters expected by the protocol

I am not sure how to deal with the context: CodeActionContext in the CodeActionParams

Hmm, this is a good point. I'm not sure if there is a good solution and therefore if CodeAction is suitable for use in the CLI. Would it make sense for diagnostics to always be empty? (We'd be able test deglob, but not error correction, iiuc).

  • [x] CodeAction
  • [x] ResolveCompletion

With @furpuddle ‘s change and all is done.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dpc picture dpc  Â·  4Comments

dnsco picture dnsco  Â·  5Comments

rcjsuen picture rcjsuen  Â·  5Comments

jaccarmac picture jaccarmac  Â·  3Comments

wagnerf42 picture wagnerf42  Â·  3Comments