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

LSP 3.16.0 #2756

Merged
merged 98 commits into from
Jun 15, 2021
Merged

LSP 3.16.0 #2756

merged 98 commits into from
Jun 15, 2021

Conversation

fannheyward
Copy link
Member

@fannheyward fannheyward commented Dec 22, 2020

Major features in LSP 3.16:

  • Semantic Token
  • Call Hierarchy
  • Linked Editing
  • Moniker support, not needed in coc
  • Events for file operations
  • Change annotation support for text edits and file operations

What's have done:

  1. vscode-languageserver-protocol, vscode-languageserver-types to 3.16.0
  2. use RegistrationType microsoft/vscode-languageserver-node@bb85e80
  3. add client.end, microsoft/vscode-languageserver-node@44ab977, but breaks src/__tests__/client/features.test.ts
  4. LanguageClientOptions adds connectionOptions and markdown
  5. new capabilites, disabled by default, needs more to test
  6. completionItem.insertTextModeSupport
  7. Call Hierarchy provider and manager
  8. Call Hierarchy tests passed src/__tests__/client/features.test.ts
  9. call CocAction('incomingCalls') and :call CocAction('outgoingCalls') work, use list UI for now, a better tree view UI is needed Support call hierarchies #1649
  10. resolveCodeAction support, tests passed
  11. WindowMiddleware and ShowDocumentRequest support
  12. add SemanticTokensFeature
  13. :call CocAction('semanticHighlight')
  14. LinkedEditingRanges API ready
  15. fileOperations is working, tests passed!
  16. willRename event is added in workspace.renameCurrentFile, tested with rust-analyzer and it works!

Steps to test semanticTokens highlights (nvim 0.5 is needed):

  1. define CocSem_{tokenType} in vimrc, for example hi! link CocSem_semicolon Variable
  2. you can get all tokenTypes by :call CocActionAsync('showSemanticHighlightInfo')

Thanks to @statiolake's codes and tests, the semanticTokens highlights are working for full document, still needs improvement on delta update

截屏2021-01-21 18 04 41

截屏2021-02-19 18 52 46

Next:

  1. UI for Call Hierarchy, tree view?
  2. coc-json/coc-html/coc-css needs upgrade microsoft/vscode@a22b5d5#diff-c953a54ba3e8cb1ac4d9b1b35daa451698e1d5a4975d38d26ad07741aa0a5d60

@fannheyward fannheyward force-pushed the feat/lsp-316 branch 8 times, most recently from 81e5ef6 to 551e4d9 Compare December 25, 2020 03:36
@fannheyward fannheyward marked this pull request as ready for review December 25, 2020 10:36
@fannheyward fannheyward force-pushed the feat/lsp-316 branch 8 times, most recently from 0171ba9 to 889f911 Compare January 2, 2021 08:07
@fannheyward
Copy link
Member Author

The tests are failed because client.end, still haven't found the reason. If I revert this, tests still fails.

@fannheyward
Copy link
Member Author

I've reverted client.end, from LSP spec, https://microsoft.github.io/language-server-protocol/specifications/specification-current/#shutdown, client only needs to do shutdown - exit, no end.

@fannheyward fannheyward force-pushed the feat/lsp-316 branch 2 times, most recently from 7648463 to d9e7321 Compare January 7, 2021 08:28
@fannheyward

This comment has been minimized.

@fannheyward fannheyward force-pushed the feat/lsp-316 branch 4 times, most recently from c80fa1f to 43c8c2b Compare January 12, 2021 01:36
@chemzqm
Copy link
Member

chemzqm commented Jan 12, 2021

workspace.registerBufferSync and buffer.highlightRanges can be used for semantic tokens

@@ -61,7 +61,7 @@
"@types/marked": "^1.2.1",
"@types/minimatch": "^3.0.3",
"@types/mkdirp": "^1.0.1",
"@types/node": "^10.12.0",
"@types/node": "12.12.12",
Copy link
Member

Choose a reason for hiding this comment

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

We should support node 10.12.0, avoid upgrade types.

Copy link
Member Author

@fannheyward fannheyward Jun 9, 2021

Choose a reason for hiding this comment

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

node 10 is EOL in April 2021, maybe we can start from node 12? https://nodejs.org/en/about/releases/

Copy link
Member Author

@fannheyward fannheyward Jun 9, 2021

Choose a reason for hiding this comment

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

There're two reason I bump it to node 12:

  1. errors from tsc -p tsconfig.json shows that Namespace '"fs"' has no exported member 'Dir' from fs-extra.
  2. cp.SpawnOptionsWithoutStdio in 06e4b6c, the createMessageTransports changes.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

@fannheyward fannheyward Jun 9, 2021

Choose a reason for hiding this comment

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

Limit to 12.12, is the minor version ok? (the minor 12 just jumped into my mind without any search/tests...

private _legend: SemanticTokensLegend

public register(selector: DocumentSelector, provider: DocumentSemanticTokensProvider, legend: SemanticTokensLegend): Disposable {
this._legend = legend
Copy link
Member

Choose a reason for hiding this comment

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

Seems different document could have different legend, can be added to item.

Copy link
Member Author

@fannheyward fannheyward Jun 10, 2021

Choose a reason for hiding this comment

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

The legend is came from LS in initialize request, it's not document related. Did I misunderstand something?

coc requests with all tokenTypes and tokenModifiers, LS responses supported legend, so I don't think it's document related.

Copy link
Member

Choose a reason for hiding this comment

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

I've check the doc, it is language server related, so different language server could have different SemanticTokensLegend.

Copy link
Member

Choose a reason for hiding this comment

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

Should be property of DocumentSemanticTokensProvider

Copy link
Member Author

Choose a reason for hiding this comment

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

SemanticTokensManager has legend property, is this what you expect?

Copy link
Member

Choose a reason for hiding this comment

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

Also DocumentRangeSemanticTokensProvider

Copy link
Member Author

Choose a reason for hiding this comment

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

DocumentRangeSemanticTokensProvider missed a lot, will update it ASAP.

Copy link
Member Author

Choose a reason for hiding this comment

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

is 004ab14 ok?

Copy link
Member

@chemzqm chemzqm Jun 10, 2021

Choose a reason for hiding this comment

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

https://github.com/neoclide/coc.nvim/blob/feat/lsp-316/src/languages.ts#L433 need be replaced with a function that accept document, which return legend from matched provider when possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

fannheyward added a commit to fannheyward/coc-tsserver that referenced this pull request Jun 10, 2021
fannheyward added a commit to fannheyward/coc-tsserver that referenced this pull request Jun 10, 2021
chemzqm pushed a commit to neoclide/coc-tsserver that referenced this pull request Jun 10, 2021
@chemzqm
Copy link
Member

chemzqm commented Jun 15, 2021

Model src/handler/semanticTokensHighlights/buffer.ts can be improved, I will make some updates.

@chemzqm chemzqm merged commit 70a7903 into master Jun 15, 2021
@chemzqm chemzqm deleted the feat/lsp-316 branch June 15, 2021 06:17
@oblitum oblitum mentioned this pull request Jun 15, 2021
chemzqm added a commit that referenced this pull request Jun 22, 2021
91c1114 fix(diagnostic): avoid change range of diagnostics
cad8c6b fix(workspace): fix range of getSelectedRange with line mode
18f81ab chore(picker): use await to avoid test fail
3efce54 fix(diagnostic): no more emptyRange check (#3147)
837941f fix float window position control to consider multigrid ui (#3150)
046505c test(ci): use node12
acd723d fix(completion): avoid unnecessary redraw for floating window (#3151)
10cfe59 docs: inconsistent suggest.triggerCompletionWait value (#3152)
dafed9d fix: remove polyfill of Promise.prototyp.finally (#3153)
493ea2e fix(diagnostic): check diagnostic next to eol character
31e76d4 refactor(handler): fetch codelens for all buffers on CursorHold
e47e472 fix(diagnostic): adjust diagnostic range which pass last line
ba9c5c8 chore(yarn): upgrade esbuild.js
9b60af3 chore(bin): remove unnecessary check.js
179ca72 fix: typos found by github.com/crate-ci/typos (#3146)
70a7903 LSP 3.16.0 (#2756)
8cb6bdc fix(float): should give foldcolumn a default value (#3140)
171ff2b chore(bin): remove unnecessary check.js
1377f3b fix: yarn.lock (#3136)
@ssh352
Copy link

ssh352 commented Jun 25, 2022

the Call Hierarchy doesn't support filter
CocOutline window supports filter though.

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.

9 participants