Closed jclsn closed 8 months ago
Hi, We use a language server rather for responsiveness by offloading work rather than portability to other IDEs. Indeed, we implement the language server protocol but we also rely on specific VSCode client behaviors which probably wouldn't work with VIM out of the box. While in theory our language server could provide some part of the feature set like Completion items, Hover and Definition to other IDEs, I think our extension is very tied in to VSCode and starting from scratch could very much be considered for a vim implementation. Notably, all the stuff to interface with bitbake or embedded languages lives in the client and is communicated to the server.
Guess I have to wait for https://github.com/Freed-Wu/bitbake-language-server to be ready then!
I advice to split this project into two projects, one is server, publish it to npm to make all editors can use it. one is client, only VS Code need it. And we can fork the client and replace vscode-languageclient
to coc.nvim
to get a coc extension from VS Code extension like this commit. Now combine them into one project make the editors other than VS Code cannot enjoy it.
In fact, other VS Code extensions are splited mostly. Such as markdown-preview-enhanced, its VS Code extension is vscode-markdown-preview-enhanced, its Coc extension is coc-markdown-preview-enhanced. all of them are in different repos, which make the code of server can be shared.
I try to transplant the project to coc.nvim.
diff --git a/package-lock.json b/package-lock.json
index bec5b0f..408c152 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
- "name": "yocto-bitbake",
- "version": "2.0.0",
+ "name": "coc-yocto-bitbake",
+ "version": "2.0.1",
"lockfileVersion": 3,
"requires": true,
"workspaces": [
@@ -8,8 +8,8 @@
],
"packages": {
"": {
- "name": "yocto-bitbake",
- "version": "2.0.0",
+ "name": "coc-yocto-bitbake",
+ "version": "2.0.1",
"hasInstallScript": true,
"license": "MIT",
"workspaces": [
@@ -36,6 +36,9 @@
"ts-jest": "^29.1.1",
"typescript": "^5.1.3",
"vscode-tmgrammar-test": "^0.1.2"
+ },
+ "engines": {
+ "coc": ">0.0.71"
}
},
"client": {
diff --git a/package.json b/package.json
index 06c1d3f..69269e5 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
- "name": "yocto-bitbake",
+ "name": "coc-yocto-bitbake",
"description": "Extended Yocto Project and BitBake language support",
"author": {
"name": "Savoir-faire Linux",
@@ -10,7 +10,11 @@
"Eugen Wiens"
],
"license": "MIT",
- "version": "2.0.0",
+ "keywords": ["coc.nvim"],
+ "engines": {
+ "coc": ">0.0.71"
+ },
+ "version": "2.0.1",
"publisher": "yocto-project",
"bugs": {
"url": "https://github.com/yoctoproject/vscode-bitbake/issues"
diff --git a/server/package-lock.json b/server/package-lock.json
index c372a26..8e9e1ff 100644
--- a/server/package-lock.json
+++ b/server/package-lock.json
@@ -12,9 +12,8 @@
"../client/src/lib"
],
"dependencies": {
+ "coc.nvim": ">=0.0.71",
"find": "^0.2.7",
- "vscode-languageserver": "^8.1.0",
- "vscode-languageserver-textdocument": "^1.0.8",
"web-tree-sitter": "^0.20.8"
},
"engines": {
@@ -41,6 +40,28 @@
"node": "*"
}
},
+ "node_modules/@types/node": {
+ "version": "12.20.55",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz",
+ "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==",
+ "peer": true
+ },
+ "node_modules/coc.nvim": {
+ "version": "0.0.82",
+ "resolved": "https://registry.npmjs.org/coc.nvim/-/coc.nvim-0.0.82.tgz",
+ "integrity": "sha512-+70ap6FH8FSdaQ0CPijaasQzg6ue84j4/LkX6ZSpALX7YKBcGGDkCcd6adgaC/86b/ZqT3iTTEbMh3mdaI5qPA==",
+ "engines": {
+ "node": ">=12.12.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/cocnvim"
+ },
+ "peerDependencies": {
+ "@types/node": "^12.12.0",
+ "typescript": "^4"
+ }
+ },
"node_modules/find": {
"version": "0.2.9",
"resolved": "https://registry.npmjs.org/find/-/find-0.2.9.tgz",
@@ -54,47 +75,22 @@
"resolved": "https://registry.npmjs.org/traverse-chain/-/traverse-chain-0.1.0.tgz",
"integrity": "sha512-up6Yvai4PYKhpNp5PkYtx50m3KbwQrqDwbuZP/ItyL64YEWHAvH6Md83LFLV/GRSk/BoUVwwgUzX6SOQSbsfAg=="
},
- "node_modules/vscode-bitbake-lib": {
- "resolved": "../client/src/lib",
- "link": true
- },
- "node_modules/vscode-jsonrpc": {
- "version": "8.1.0",
- "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz",
- "integrity": "sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==",
- "engines": {
- "node": ">=14.0.0"
- }
- },
- "node_modules/vscode-languageserver": {
- "version": "8.1.0",
- "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-8.1.0.tgz",
- "integrity": "sha512-eUt8f1z2N2IEUDBsKaNapkz7jl5QpskN2Y0G01T/ItMxBxw1fJwvtySGB9QMecatne8jFIWJGWI61dWjyTLQsw==",
- "dependencies": {
- "vscode-languageserver-protocol": "3.17.3"
- },
+ "node_modules/typescript": {
+ "version": "4.9.5",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
+ "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
+ "peer": true,
"bin": {
- "installServerIntoExtension": "bin/installServerIntoExtension"
- }
- },
- "node_modules/vscode-languageserver-protocol": {
- "version": "3.17.3",
- "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3.tgz",
- "integrity": "sha512-924/h0AqsMtA5yK22GgMtCYiMdCOtWTSGgUOkgEDX+wk2b0x4sAfLiO4NxBxqbiVtz7K7/1/RgVrVI0NClZwqA==",
- "dependencies": {
- "vscode-jsonrpc": "8.1.0",
- "vscode-languageserver-types": "3.17.3"
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=4.2.0"
}
},
- "node_modules/vscode-languageserver-textdocument": {
- "version": "1.0.11",
- "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.11.tgz",
- "integrity": "sha512-X+8T3GoiwTVlJbicx/sIAF+yuJAqz8VvwJyoMVhwEMoEKE/fkDmrqUgDMyBECcM2A2frVZIUj5HI/ErRXCfOeA=="
- },
- "node_modules/vscode-languageserver-types": {
- "version": "3.17.3",
- "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz",
- "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA=="
+ "node_modules/vscode-bitbake-lib": {
+ "resolved": "../client/src/lib",
+ "link": true
},
"node_modules/web-tree-sitter": {
"version": "0.20.8",
diff --git a/server/package.json b/server/package.json
index 87f2639..a42d268 100644
--- a/server/package.json
+++ b/server/package.json
@@ -20,8 +20,7 @@
},
"dependencies": {
"find": "^0.2.7",
- "vscode-languageserver": "^8.1.0",
- "vscode-languageserver-textdocument": "^1.0.8",
+ "coc.nvim": ">=0.0.71",
"web-tree-sitter": "^0.20.8"
},
"scripts": {
But I get
- ✗ coc-yocto-bitbake main file index.js not found, you may need to build the project.
I have known what happened. VS Code use .vscodeignore
and Coc.nvim and npm use .npmignore
. Because this project doesn't have .npmignore, so it ignore all compiled js and include all source ts. So it tell main file index.js not found
.
Hello @Freed-Wu contributions are welcome if you can get a coc.nvim integration to work in some way :)
That's really cool @Freed-Wu! Did you just need to compile the server as a separate package for this to work? (https://github.com/Freed-Wu/coc-bitbake/commit/f72e2a825482060f823e7990bc8c020deee809b6) I don't know how COC.nvim packaging works. Does it just needs a yarn package with the server to work?
Ideally we could integrate packaging and publishing for COC.nvim on this repo. Let me know if you have a clear view on how it can be done from your experiment or submit PRs?
The limited features that should be ported first would be:
Did you just need to compile the server as a separate package for this to work?
Yes, just language-server-bitbake --stdio
should be out of box for all editors which support LSPs.
PR will be provided.
If you want language-server-bitbake --node-ipc
, the client also should be ported to coc.nvim
.
Does it just needs a yarn package with the server to work?
coc.nvim
don't use vsce package
. It use npm pack
(or yarn pack
or bun pack
). That is why it use .npmignore
not .vscodeignore
. (It costs me a long time to find it)coc.nvim
also don't use vscode-marketplace. It use npmjs.org. coc-marketplace only search packages contains keyword coc.nvim
in npmjs.org and provide a UI.coc.nvim
need node > 16.18.0
Ideally we could integrate packaging and publishing for COC.nvim on this repo.
However, IMO, coc.nvim's API looks like an old VS Code, some new APIs are not available. For example,
In vscode, function workspace.openTextDocument()
have 3 overloads, however, in coc.nvim, there have 2 overloads and miss the latest overload.
If you want to package them in same repo, you should avoid many new APIs and use old API to realize same functions. I think it will limit your development.
syntax highlighting (are you using ours for your screenshot?)
No. vim has builtin syntax highlight for 688 languages, included bitbake. https://github.com/neovim/neovim/tree/master/runtime/syntax Except syntax highlight, comment symbol, indent, ... also be provided by vim. vim just let their users install language servers.
documentation hover (in your screenshot)
completion suggestions from the documentation (in your screenshot)
All lsp features should work.
@Freed-Wu Packaging for NVIM in this repo is definetely what we want to do!
With some changes we should be able to have a compatible code for both environments, then add packaging and auto publishing in our CI with the right tags for COC.nvim.
Our LSP has more features which require to communicate with the bash-ide and python extensions as well as the client to probe bitbake. However the features you currently demonstrate should be our target for the time being.
Thanks for your PR. I added some comments on it. But I think we'll need more changes before we get it fully working? Like the API calls you mention and also all the packaging logic.
Also if you want to be very thorough, you could try to design an integration test that launches the server under COC.nvim (if possible), or simply simulate the environment. This will be needed if we want to maintain nvim in the long run.
The COC LSP plugin for Vim should in theory be able to use this. Here is a link
https://github.com/neoclide/coc.nvim/wiki/Language-servers#register-custom-language-servers
I have compiled the server and tried the following configuration
It doesn't respond though, although it should if it uses VSCode's LSP protocol. Can you give any hints on how to get this to work?