Skip to content
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

merge vue-language-server #227

Merged
merged 9 commits into from
Jun 15, 2017
Merged

merge vue-language-server #227

merged 9 commits into from
Jun 15, 2017

Conversation

HerringtonDarkholme
Copy link
Member

This is a huge pull request.

Main idea:

  1. change server into a separate npm module. So debug/release can be independent of client.
  2. change client to depend on npm module. This keeps server code in same repo and issues concentrated. Development does not need installServerIntoExtension but a npm link

Other things include code improvement, stylus support and test code.

I think it might also be an option to create a repository for vetur in vuejs organization.

@mickdekkers
Copy link

If this is to be accepted, may I suggest using lerna? It would make it easier to add and manage additional packages in the repo in the future.

@HerringtonDarkholme
Copy link
Member Author

It only have two packages. learna might be an overkill, I think.

Disposable,
DocumentSelector
} from 'vscode-languageserver';
import { createConnection, TextDocuments, InitializeParams, InitializeResult, DocumentRangeFormattingRequest, Disposable, DocumentSelector } from 'vscode-languageserver';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name this as vueServerMain?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

'vue-html': true,
html: true,
css: true,
scss: true,
less: true,
javascript: true
javascript: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm against this styling, but if we were to do it I'd add it to the tslint rule.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add tslint rule after this pull request, definitely need it.

if (mode && mode.doComplete) {
return mode.doComplete(document, textDocumentPosition.position);
} else {
return getVls().doVueComplete();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0e56992 and #219.

let languageIdFromType = removeQuotes(lang);
if (languageIdFromType === 'jade') {
languageIdFromType = 'pug';
}
if (languageIdFromType === 'ts') {
} if (languageIdFromType === 'ts') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non if-else, I'd put if on another line for better visibility.

let modes = {
vue: getVueMode(),
let jsMode = getJavascriptMode(documentRegions, workspacePath)
let modes: {[k: string]: LanguageMode} = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put 'lang instead of k for key.

@@ -194,7 +203,7 @@ export interface Scanner {
getScannerState(): ScannerState;
}

const htmlScriptContents = {
const htmlScriptContents: {[k: string]: boolean} = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lang.

hover = { contents, range };
})
}
return hover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;

return getAttributeHover(node.tag, attribute, tagRange)
}

return NULL_HOVER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;

} else {
return Uri.parse(documentUri).path;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are still using this in js/script mode, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moved to script mode.

@@ -21,12 +21,25 @@ export function getWordAtText(text: string, offset: number, wordDefinition: RegE
return { start: offset, length: 0 };
}

export function repeat(value: string, count: number) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since lodash is a dep I'd just use _.repeat, 6b2c8ce

@octref
Copy link
Member

octref commented Jun 11, 2017

Overall comments:

  • Good job on bringing back test and the stylus support.
  • I think it's better to stick with yarn, since npm5 is buggy and not many people are using it.
  • There are some styling / consistency problems. If we are to do this together, what do you think about using prettier with a line width limit like 120 or 140? I'm using this plugin: https://github.com/esbenp/prettier-vscode
  • I haven't been able to build yet, since I'm having really slow connection now and not npm5 yet. I just took a general look but haven't looked some of the implementations more carefully.
  • Overall I'm pro for merging this asap and we can address bugs later. Otherwise I don't want to push too much changes to master. Once this settles down I can start adding some work for Type checking for template expressions #209.

Again, thanks a lot for the PR 👍

@octref
Copy link
Member

octref commented Jun 11, 2017

And BTW, would you be OK if I push some changes to your branch?

if (!languageServiceIncludesFile(jsLanguageService, doc.uri)) {
return [];
return []
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not remove semicolons randomly...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have consistently remove semicolons for new code.

The real problem is whether we need semicolons

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can agree on running it through prettier with printWidth 120?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

import Vue from 'vue'
export default function test<T>(t: T & Vue.ComponentOptions<{}>): T {
return t
}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

export default function test<T>(t: T & Vue.ComponentOptions<{}>): T {
  return t
}

Also, I'd like to not put too many things into this PR. Let's fix the existing problems and merge it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is important fix for resolving component info.

Note new Vue or Vue.extend will erase component definition info. But an identity function like before will keep component definition object's type. So we can resolve props/components.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, but maybe also update the comments on the TS mode file.

@@ -11,7 +11,7 @@ namespace ColorSymbolRequest {
export function activate (context: ExtensionContext) {

// The server is implemented in node
const serverModule = context.asAbsolutePath(path.join('client', 'server', 'vueServerMain.js'));
const serverModule = require.resolve('vue-langauge-server');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

langauge -> language

@octref
Copy link
Member

octref commented Jun 13, 2017

I pushed a change to master to make sure tslint works with tslint@5.
Can you download the tslint plugin and fix your styling issues.
Otherwise looks good, thanks!

setZeroPos(ts.createLiteral('vue-editor-bridge'))));
sourceFile.statements.unshift(vueImport);

// 2. find the export default and wrap it in `new Vue(...)` if it exists and is an object literal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then maybe update the description here too.

@HerringtonDarkholme
Copy link
Member Author

Fixes have been pushed.

@HerringtonDarkholme
Copy link
Member Author

One thing left is updating client folder's yarn lock. My yarn is configured to taobao's registry, not yarn-pkg. (Curse GFW).

@HerringtonDarkholme
Copy link
Member Author

@octref Ping

@octref octref merged commit f812f40 into vuejs:master Jun 15, 2017
@HerringtonDarkholme
Copy link
Member Author

Thanks!

@octref octref mentioned this pull request Jun 19, 2017
12 tasks
octref added a commit that referenced this pull request Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants