facebookarchive / flow-language-server

An implementation of the Language Server Protocol for Flow
Other
188 stars 21 forks source link

Add code actions #77

Closed slonoed closed 6 years ago

slonoed commented 6 years ago

I'm thinking to implement codeActions and executeCommand and provide some AST based transformations, like convert function to arrow function.

My idea is to separate refactoring from language server itself. It could be done in this repo, or via plugins as it works in javascript-typescript-langserver. I like the idea of plugins because it allows me to publish changes easily. However requires some effort to implement a plugin system, which should be more general for future usage.

I already have simple prototype which uses babylon to parse code and vim-lsc plugin for vim.

ezgif-5-d1ad38801d

What do you think?

Similar tooling

js-refactor — works only in VSCode

hansonw commented 6 years ago

Why not have a standalone language server for the AST transformations? It's not super high overhead, and I'm not sure that there's a lot to share with the Flow server anyway.

On Thu, May 10, 2018 at 2:10 PM, Dmitry Manannikov <notifications@github.com

wrote:

I'm thinking to implement codeActions and executeCommand and provide some AST based transformations, like convert function to arrow function.

My idea is to separate refactoring from language server itself. It could be done in this repo, or via plugins as it works in javascript-typescript- langserver https://github.com/sourcegraph/javascript-typescript-langserver/blob/master/src/plugins.ts. I like the idea of plugins because it allows me to publish changes easily. However requires some effort to implement a plugin system, which should be more general for future usage.

I already have simple prototype which uses babylon https://github.com/babel/babel/tree/master/packages/babylon to parse code and vim-lsc plugin https://github.com/natebosch/vim-lsc for vim.

[image: ezgif-5-d1ad38801d] https://user-images.githubusercontent.com/463239/39893967-c1deaea4-54a5-11e8-8a21-adba0a22b34f.gif

What do you think? Similar tooling

js-refactor https://github.com/cmstead/js-refactor/blob/master/package.json — works only in VSCode

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/flowtype/flow-language-server/issues/77, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjPYl7WpSAP0vs4CfB336mp1M1HwCCYks5txKyvgaJpZM4T6jvu .

slonoed commented 6 years ago

@hansonw it was my initial idea. Just wanted to check in case someone already has this plan.

I think the main benefit from one package it is, well, one package. Most language clients don't support multiple language servers.

hansonw commented 6 years ago

Atom/VSCode certainly support multiple servers per filetype.. I'm not sure about vim, though.