-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
Conversation
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. |
It only have two packages. learna might be an overkill, I think. |
server/src/htmlServerMain.ts
Outdated
Disposable, | ||
DocumentSelector | ||
} from 'vscode-languageserver'; | ||
import { createConnection, TextDocuments, InitializeParams, InitializeResult, DocumentRangeFormattingRequest, Disposable, DocumentSelector } from 'vscode-languageserver'; |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
server/src/htmlServerMain.ts
Outdated
'vue-html': true, | ||
html: true, | ||
css: true, | ||
scss: true, | ||
less: true, | ||
javascript: true | ||
javascript: true, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
server/src/htmlServerMain.ts
Outdated
if (mode && mode.doComplete) { | ||
return mode.doComplete(document, textDocumentPosition.position); | ||
} else { | ||
return getVls().doVueComplete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server/src/modes/embeddedSupport.ts
Outdated
let languageIdFromType = removeQuotes(lang); | ||
if (languageIdFromType === 'jade') { | ||
languageIdFromType = 'pug'; | ||
} | ||
if (languageIdFromType === 'ts') { | ||
} if (languageIdFromType === 'ts') { |
There was a problem hiding this comment.
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.
server/src/modes/languageModes.ts
Outdated
let modes = { | ||
vue: getVueMode(), | ||
let jsMode = getJavascriptMode(documentRegions, workspacePath) | ||
let modes: {[k: string]: LanguageMode} = { |
There was a problem hiding this comment.
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} = { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
server/src/utils/strings.ts
Outdated
@@ -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) { |
There was a problem hiding this comment.
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
Overall comments:
Again, thanks a lot for the PR 👍 |
And BTW, would you be OK if I push some changes to your branch? |
if (!languageServiceIncludesFile(jsLanguageService, doc.uri)) { | ||
return []; | ||
return [] | ||
} | ||
|
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
server/src/modes/script/bridge.ts
Outdated
import Vue from 'vue' | ||
export default function test<T>(t: T & Vue.ComponentOptions<{}>): T { | ||
return t | ||
}` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
client/src/htmlMain.ts
Outdated
@@ -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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
langauge
-> language
I pushed a change to master to make sure tslint works with tslint@5. |
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 |
There was a problem hiding this comment.
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.
Fixes have been pushed. |
One thing left is updating client folder's yarn lock. My yarn is configured to taobao's registry, not yarn-pkg. (Curse GFW). |
@octref Ping |
Thanks! |
This is a huge pull request.
Main idea:
installServerIntoExtension
but anpm 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.