Code Monkey home page Code Monkey logo

codemirror-languageserver's People

Contributors

alex-kinokon avatar bushev avatar hjr265 avatar marc2332 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

codemirror-languageserver's Issues

What is the proper way to import with Rollup?

Thanks for what looks like an amazing plugin.

I'm trying to import using the most minimal example possible and getting this error:

[!] Error: 'CompletionItemKind' is not exported by node_modules/vscode-languageserver-protocol/lib/node/main.js, imported by node_modules/codemirror-languageserver/dist/index.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
node_modules/codemirror-languageserver/dist/index.js (7:9)

I went down the rabbit-hole of that link, leading to a removed option and many open issues in Rollup's repo, and the commonjs plugin which didn't seem to work.

Appreciate any tips on the required config/plugins to get this up and running.

Wrong types

I just realized some of the TypeScript types I implemented in the last PR are not accurate at all:

  • LanguageServerClientOptions requires a documentUri, which is not necessary for the client
  • And languageServerWithTransport doesn't actually always need a transport if client is passed

I will fix this asap

"Events" error

I'm having solid js project which use vite to start the front-end. I'm having a codemirror based code editor in my project, and I'm using jsonrpc-ws-proxy to start the lsp server (I'm using tsserver). Everything was working fine but after using codmirror-languageserver I'm getting an error which looks like this:

events_1.EventEmitter is not a constructor
at new RequestManager3 (http://localhost:5173/node_modules/.vite/deps/codemirror-languageserver.js?v=1f2a4f85:166:33)
at new LanguageServerClient (http://localhost:5173/node_modules/.vite/deps/codemirror-languageserver.js?v=1f2a4f85:8253:27)
at Editor (http://localhost:5173/src/components/editor/Editor.jsx?t=1693083118230:26:13)
at http://localhost:5173/@solid-refresh:25:42
at untrack (http://localhost:5173/node_modules/.vite/deps/chunk-QUWHAVPQ.js?v=1f2a4f85:493:12)
at HMRComp.createMemo.name [as fn] (http://localhost:5173/@solid-refresh:25:28)
at runComputation (http://localhost:5173/node_modules/.vite/deps/chunk-QUWHAVPQ.js?v=1f2a4f85:796:22)
at updateComputation (http://localhost:5173/node_modules/.vite/deps/chunk-QUWHAVPQ.js?v=1f2a4f85:775:3)
at createMemo (http://localhost:5173/node_modules/.vite/deps/chunk-QUWHAVPQ.js?v=1f2a4f85:270:5)
at [solid-refresh]Editor (http://localhost:5173/@solid-refresh:22:20)

Not just that, i also had another warning from vite which said:

Module "events" has been externalized for browser compatibility. Cannot access "events.EventEmitter" in client code. See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

I followed the link they provided, it ironically mentions "it's advised to report the issue to the respective library".

I've tried various ways but nothing works. I've checked server, it works fine so looks problem from frontend side.
I think it's somewhere problem with dependencies of codemirror-languageserver package, how do I resolve this ?

Here is how I used the codemirror-languageserver package at Frontend:

const serverUri = new WebSocket("ws://localhost:3000/typescript");

var ls = new languageServer({
    serverUri,
    rootUri: "file:///",
    documentUri: `file:///index.ts`,
    languageId: "typescript",
  });
const extensions = [
    basicSetup,
    javascript(),
    ls,
    autocompletion({
      override: [myCompletions],
    }),
  ];
const state = EditorState.create({
    doc: " ",
    extensions,
  });

Lua language server not working: `Loading workspace (0/0)`

I would like to switch from monaco to codemirror 6, but somehow I can't get the lua language server to work. I'm using sumneko's https://github.com/sumneko/lua-language-server/.

The same setup is working with monaco editor https://github.com/arnoson/monaco-lua-example (linux only for now).
Here I put together a simple setup illustrating the issue:
https://github.com/arnoson/codemirror-lua (lua has to be installed for the language server to work)

Do you have any idea what the problem could be or where I might have an error in my codemirror editor setup?

Anyway to make the lsp project aware?

Hi, sorry for opening another issue.

Finally I was able to make this work with the svelte language server and it works wonderfully.

Now while this is already very very good it would be very cool of I could also provide import autocompletion from the whole project (which the language server should be able to handle). To do so obviously I should be able to notify the language server about the whole project structure while also update it whenever some new file is created.

One thing I thought of trying while I was writing this issue is that maybe I declare the transport client myself so that I can notify the language server? Would this be a correct way?

Sharing lsp clients between mutliple editors

I'm using this library in a project which implements an online IDE. When I open a Project I also open a Language Server on the server side. Now I'm trying to connect all the open editors to this language server but of course they all open a new connection and therefor open a new language server. This wastes many resources, it would be better to just open one language server.

Is it possible to share the Extension returned by languageServer({...}) between multiple Editor Instances?

Module loader error

in ./node_modules/codemirror-languageserver/dist/index.js

Module parse failed: Unexpected token (327:8)
You may need an appropriate loader to handle this file type.
|     delete options.serverUri;
|     return languageServerWithTransport({
|         ...options,
|         transport: new WebSocketTransport(serverUri)
|     });

 @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/pages/sql-intellisense/PythonEditor.vue 23:0-59
 @ ./src/pages/sql-intellisense/PythonEditor.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

"codemirror-languageserver": "^1.8.1"

I am getting this error. Any help? Is it because of version?

Is the autocompletion provided by the language server reconfigurable?

For my project, I am using Code mirror 6 and python-lsp-server as my language server.

I spawn up my language server using the following code

pylsp --ws --port 3001

I attach the serverUri to the extension. Now I am particularly concerned about 2 things

  1. First being, when I autocomplete using the autocompletions provided by python-lsp-sever to the codemirror-languageserver
    extension, the suggestion adds the variables also as shown in the below figures

image

image

  1. Right now, the source code codemirror-languageserver overrides the autocompletion. However I would like to add custom autocompletions. Would that be possible? Or would I be able to wrap the code with custom variables and send it across?

Any help would be greatly appreciated!

Codemirror not recognizing returned extensions and throwing "Unrecognized extension value in extension set"

When I use codemirror-languageserver as a dependency, Extensions returned by languageServerWithTransport() and passed to codemirror cause it to throw

Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks

I've read codemirror issue #608 related to this and while I do have several occurrences of @codemirror/state in my project dependency tree, they are the same version. Nevertheless, I added the npm "overrides" key in package.json to ensure they were all the same version (@codemirror/[email protected] in this case) but it made no difference. After a couple days troubleshooting this (debugging the @codemirror/state module trying to make sense of why it refused to recognize extensions) I found that a simple codemirror Facet (a FacetProvider) worked if it was created in my project code, but not if it was returned from languageServerWithTransport(). So, I copied codemirror-languageserver/src/index.ts into my project, removed the dependency on codemirror-languageserver, updated the affected imports, and everything worked.

I would really like to understand the reason behind this, so if any maintainers/contributors can offer tips or further insight, I would appreciate it.

For further context, my project is an electron+react application and I'm using @uiw/react-codemirror to work with codemirror. The LSP (typescript-language-server) is forked by the electron main process, and I have my own transport code to handle LSP+JSON-RPC over electron IPC, which is the reason I'm calling languageServerWithTransport().

Issue with dependencies;

Bug Report: Rollup Build Errors

Issue 1: CompletionItemKind Import

Error: "CompletionItemKind" is not exported by "node_modules/vscode-languageserver-protocol/lib/node/main.js".
Suggested Fix: Update the import statement to reflect the correct source:
javascript
Copy code
// Before
import { CompletionItemKind } from 'vscode-languageserver-protocol';

// After
import { CompletionItemKind } from 'vscode-languageserver-types';
Issue 2: RequestManager Export

Error: "RequestManager" is not exported by "node_modules/@open-rpc/client-js/build/index.js".
Action Needed: Verify the availability of "RequestManager" in @open-rpc/client-js. Refer to the documentation or GitHub repository for the correct import statement.

Added my project as a zip

codemirror-rollup 2.zip

Is there perhaps somewhere a working example using npm that I could start with

Issue with wrong diagnostic info position

Hey @hjr265,

Thanks for the great usage example!!!

Sometimes, I could see the error that says that a position in a code is wrong to set diagnostics data. It 100% happens when I adding something by clicking to autocomplete tooltip and then trying to remove it with backspace as the end of the document.

Do you know, is it is some known issue?

image

Can't integrate with sveltekit

When I try to call the languageServer function directly in the script tag it crashes with some weird error from svelte. If I try to call the languageServer function onMount it throws this error

caught (in promise) TypeError: events_1.EventEmitter is not a constructor
    at new TransportRequestManager2 (codemirror-languageserver.js?v=a7fd2213:318:40)
    at WebSocketTransport3.Transport2 (codemirror-languageserver.js?v=a7fd2213:467:42)
    at new WebSocketTransport3 (codemirror-languageserver.js?v=a7fd2213:1500:30)
    at languageServer (codemirror-languageserver.js?v=a7fd2213:8519:16)
    at +page.svelte?t=1682723499451:156:25
    at run (chunk-PUOMPBAM.js?v=a7fd2213:19:10)
    at Array.map (<anonymous>)
    at chunk-PUOMPBAM.js?v=a7fd2213:1806:52
    at flush (chunk-PUOMPBAM.js?v=a7fd2213:1092:9)
    at init (chunk-PUOMPBAM.js?v=a7fd2213:1888:5)
T

Can you provide some hints on how can I fix this?

P.s. the fact that you can connect to an lsp from codemirror is just magical...thanks for your work โœจ

How would you configure this if you don't have a server?

I primarily work on backendless apps, and would not be able to host anything anywhere (other than static assets via CDN).

ideally, I'd like to import / bundle language servers with the codemirror bundle I'm building so I don't even need to worry about providing public asset path mapping (I totally understand this adds a lot to initial load time).

Is this possible today? Maybe via WebWorkers?

got "SyntaxError: Cannot use import statement outside a module" when running

I followed the sample code and run into this error. Anyone knows why? thanks.

Server Error
SyntaxError: Cannot use import statement outside a module

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
.../node_modules/codemirror-languageserver/dist/index.js (1)
Object.compileFunction
node:vm (352:18)
wrapSafe
node:internal/modules/cjs/loader (1025:15)
Module._compile
node:internal/modules/cjs/loader (1059:27)
Object.Module._extensions..js
node:internal/modules/cjs/loader (1124:10)
Module.load
node:internal/modules/cjs/loader (975:32)
Function.Module._load
node:internal/modules/cjs/loader (816:12)
Module.require
node:internal/modules/cjs/loader (999:19)
require
node:internal/modules/cjs/helpers (93:18)

Better tooltips

I think it would be very cool to have a colored signature and maybe even a markdown renderer, just like most editors, like Monaco. And better tooltips stacking.

Right now:
image

Monaco:
image

I might try to do something some day, I think it could re-use @codemirror/view and @codemirror/state for the signature preview thing.

How does filename work?

Not really an issue more a question:

In your example you use a filename variable in the language server setup. Can you explain how this works exactly? Right now my file will only exist in codemirror and not in a filesystem. How can I still connect a language server?

thanks,
Arno

[enhancement] Transport Agnostic

Hi!

It would be awesome to make this transport-agnostic instead of going fully with the WebSockets transport. I personally would like to use the EventEmitterTransport for a project of mine.

What are your thoughts? I can try to contribute ๐Ÿ˜„

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.