Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.54k stars 174 forks source link

More language servers #4423

Closed ghost closed 2 years ago

ghost commented 2 years ago

Some language servers are missing: https://wiki.freepascal.org/CudaText_plugins

Please have a look: https://www.zeusedit.com/lsp/lsp.html

Alexey-T commented 2 years ago

Feel free to give correct config-info here, i will add the info to the wiki. I will wait for a week-two, and will close the issue.

Alexey-T commented 2 years ago

I begin with C# OmniSharp server. On Win10. Result: I am blocked on MS site ("my" country is blocked , seems) so VS installer (I can get it and can run it, 2Mb) cannot download its files and I cannot install MSBuild from this installer.

Here is my draft text file.


  1. Get OmniSharp from GitHub https://github.com/OmniSharp/omnisharp-roslyn/releases . For Windows it is the package "omnisharp-win-x64.zip".

  2. You need to install MSBuild. As of May 2022, OmniSharp does not include MSBuild. Download link can be found at the bottom of this page: https://visualstudio.microsoft.com/downloads/?q=build+tools . See "Build Tools for Visual Studio 2022". In the installation check the following option: ".NET desktop build tools".

More info: https://github.com/OmniSharp/omnisharp-vscode/issues/5120

maybe @veksha is in different country and he is not blocked?

Alexey-T commented 2 years ago

And my config (cudatext)/settings/lsp_cs.json

{
  "lexers": {
    "C#": "csharp"
  },
  "cmd_windows": [
      "C:\\OmniSharp\\OmniSharp.exe", "-lsp", "-z"
  ]
}

With it, OmniSharp gives the error that it cannot locate MSBuild and fails to work. In the LSP panel log of Cud.

OmniSharp.Services.DotNetCliService: Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK | 
OmniSharp.Services.DotNetCliService: Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK | 
OmniSharp.Services.DotNetCliService: Using the 'dotnet' on the PATH. | 
OmniSharp.Services.DotNetCliService: Using the 'dotnet' on the PATH. | 
OmniSharp.Services.DotNetCliService: DotNetPath set to dotnet | 
OmniSharp.Services.DotNetCliService: DotNetPath set to dotnet | 
OmniSharp.MSBuild.Discovery.MSBuildLocator: Located 0 MSBuild instance(s) | 
OmniSharp.MSBuild.Discovery.MSBuildLocator: Located 0 MSBuild instance(s) | 
OmniSharp.Extensions.JsonRpc.InputHandler: Failed to handle request initialize 0 - OmniSharp.MSBuild.Discovery.MSBuildNotFoundException: Could not locate MSBuild instance to register with OmniSharp.

The C# testing file

using System;

public class DateExample
{
    public static void Main()
    {
        DateTime  date;
        date.A
    }
}
veksha commented 2 years ago

image

veksha commented 2 years ago

And my config (cudatext)/settings/lsp_cs.json

this config works for me fine

Alexey-T commented 2 years ago

did you run it after you installed MSBuild? did you get MSBuild by my link?

veksha commented 2 years ago

MSBuild was already installed on my system

Alexey-T commented 2 years ago

The C# info is now in the WIki. Thanks.

Now I follow the Java server info here: https://www.zeusedit.com/lsp/java.html Current result: LSP shows in console:

LSP: starting server - Java; root: None
ReadLoopError: LSP: Java - [Errno 10] No child processes

I unzipped .tar.gz from https://download.eclipse.org/jdtls/milestones/1.9.0/ to the C:\Java\jdt-language-server . I made jLSP.cmd as shown in Zeus docs. I can run jLSP.cmd and it shows

Microsoft Windows [Version 10.0.19044.2006]
(c) Microsoft Corporation. All rights reserved.

C:\Java>jlsp c:\work c:\work
Directory: C:/Java/jdt-language-server
  JarFile: C:/Java/jdt-language-server/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
   Config: C:/Java/jdt-language-server/config_win
java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar C:/Java/jdt-language-server/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar -configuration C:/Java/jdt-language-server/config_win --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data "c:\work"
An error has occurred. See the log file
C:\Java\jdt-language-server\config_win\1665436817104.log.

C:\Java>

so it almost works.

LSP config for Cud: (cudatext)/settings/lsp_java.json

{
  "lexers": {
    "Java": "java"
  },
  "cmd_windows": [
      "C:\\Java\\jLSP.cmd", "${fdir}", "${fdir}"
  ]
}

Java testing file

public class Example {
    public static void main(String[] args) {
        System.g
    }
}
Alexey-T commented 2 years ago

@veksha you cannot fix that, it is Java affairs. we need ANOTHER Java server or another CMD file or docs

Alexey-T commented 2 years ago

Info about DLang server just added to wiki. Was easy to config.

Alexey-T commented 2 years ago

Info about Go, Fortran servers - added. We only miss

ghost commented 2 years ago

Info about Go, Fortran servers - added. We only miss

  • Java
  • Go 2nd and 3rd servers (bingo - gives errors; sourcegraph - cannot compile)

It seems you miss this too: https://www.zeusedit.com/lsp/python-lsp-ms.html

Alexey-T commented 2 years ago

'Check that the .Net Core is correctly installed run the following command: ' - so I cannot compile it, my Win10 cannot install the VS and MSBuild.

if you or @veksha give me the ready topic for the wiki, I take it.

ghost commented 2 years ago

'Check that the .Net Core is correctly installed run the following command: ' - so I cannot compile it, my Win10 cannot install the VS and MSBuild.

if you or @veksha give me the ready topic for the wiki, I take it.

So does me. I'm on Windows 8.1 and Visual Studio doesn't support my OS. I listed C# and Java only as examples to prove that there are more language servers to add. What I really need is this: https://www.zeusedit.com/lsp/python-lsp-ms.html

Sorry for the misleading.

Alexey-T commented 2 years ago

See the new topic #4432 and try to repeat my steps, from the wiki-file (attached in zip).

Alexey-T commented 2 years ago

'sourcegraph' server for Go is not supported!

Hey we no longer maintain this server (in fact I am about to archive this repository). Please use the official gopls language server from the go team.

Alexey-T commented 2 years ago

Microsoft Python server repo: This repository has been archived by the owner. It is now read-only. https://github.com/Microsoft/python-language-server

It is not updated since February. so I don't want to support it.

RESDXChgfore9hing commented 2 years ago

the java lsp doesnt seems to work.Did you get it to work?

Running the start batch script itself seems to worked fine

ctrun2 "%cd%\work" "%cd%\work"
Directory: D:\testlsp\jdt
  JarFile: D:\testlsp\jdt/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar
   Config: D:\testlsp\jdt/config_win
java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar D:\testlsp\jdt/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar -configuration D:\testlsp\jdt/config_win --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data "D:\testlsp\work"
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Content-Length: 120

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2022/10/26 1:38:08 Main thread is waiting"}}

Meanwhile in from cudatext

Alexey-T commented 2 years ago
veksha commented 2 years ago

the java lsp doesnt seems to work.Did you get it to work?

Running the start batch script itself seems to worked fine

Got it working, @RESDXChgfore9hing! commented out four "echo" lines in batch file:

::echo Directory: %Directory%
::echo   JarFile: %JarFile%
::echo    Config: %Config%
...
::echo java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar %JarFile% -configuration %Config% --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data %CacheDirctory%

I need to check why Cuda_lsp can't get past them.

veksha commented 2 years ago

@Alexey-T, prepared PR. please test. https://github.com/CudaText-addons/cuda_lsp/pull/93

Alexey-T commented 2 years ago

Thanks. Do I need to install Java server again , or you can write wiki part ? Write it here

veksha commented 2 years ago

better you try and install it on your linux. we need at least Windows and Linux examples. for Windows we could steal copy-paste from https://www.zeusedit.com/lsp/java.html

This is not ready yet, just a template:

For Windows:

set CacheDirctory=%~1

if NOT "%CacheDirctory%" == "" goto test_cache set CacheDirctory=%~2

if NOT "%CacheDirctory%" == "" goto test_cache echo Error: No cache directory was provided. goto usage

:test_cache

set CacheDirctory="%CacheDirctory%"

if EXIST %CacheDirctory% goto check_server echo Error: The cache directory provided does not exist: %CacheDirctory% goto complete

:check_server

:: language server installation folder (adjust to suit) set Directory=C:/Java/jdt-language-server

:: language server jar file (update based on version file of jar) set JarFile=%Directory%/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar

if EXIST %JarFile% goto run_server echo Error: The following Jar file was not found: echo '%JarFile%' echo Check the folder above to see if the version number of the Jar has changed and update the jLSP.cmd file to suit. goto complete

:run_server

:: language server config folder location set Config=%Directory%/config_win

echo Directory: %Directory% echo JarFile: %JarFile% echo Config: %Config%

:: java --Declipse.application=org.eclipse.jdt.ls.core.id1 :: -Dosgi.bundles.defaultStartLevel=4 :: -Declipse.product=org.eclipse.jdt.ls.core.product :: -Dlog.level=ALL :: -noverify :: -Xmx1G :: -jar %JarFile% :: -configuration %Congfig% :: --add-modules=ALL-SYSTEM :: --add-opens java.base/java.util=ALL-UNNAMED :: --add-opens java.base/java.lang=ALL-UNNAMED :: -data %CacheDirctory%

:: echo the command for debugging echo java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar %JarFile% -configuration %Config% --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data %CacheDirctory%

:: run the language server using stdio communications java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar %JarFile% -configuration %Config% --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data %CacheDirctory% goto complete

:usage echo. echo Usage: jLSP.cmd WorkspaceDirectory FileDirectory echo Example: jLSP.cmd "$wdd" "$fdd" echo.

:complete


create `lsp_java.json` file:
```json
{
  "name": "Java",
  "lexers": {
    "Java": "java",
  },
  "cmd_windows": ["C:\\Java\\jLSP.cmd", "."]
}
RESDXChgfore9hing commented 2 years ago

mine have some weird error though after configuring everything and commented out the 4 lines workedbuthave_err

RESDXChgfore9hing commented 2 years ago

My custom JDK installess version jlsp.cmd for alexey reference if lazy install JDK into win,but have it in some folder.mine is in drive X

@echo off

set CacheDirctory=%~1

if NOT "%CacheDirctory%" == "" goto test_cache
set CacheDirctory=%~2

if NOT "%CacheDirctory%" == "" goto test_cache
echo Error: No cache directory was provided.
goto usage

:test_cache

set CacheDirctory="%CacheDirctory%"

if EXIST %CacheDirctory% goto check_server
echo Error: The cache directory provided does not exist: %CacheDirctory%
goto complete

:check_server

:: language server installation folder (adjust to suit)
set Directory=D:\testlsp\jdt

:: language server jar file (update based on version file of jar)
set JarFile=%Directory%/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar

if EXIST %JarFile% goto run_server
echo Error: The following Jar file was not found:
echo            '%JarFile%'
echo Check the folder above to see if the version number of the Jar has changed and update the jLSP.cmd file to suit.
goto complete

:run_server

:: language server config folder location
set Config=%Directory%/config_win

::echo Directory: %Directory%
::echo   JarFile: %JarFile%
::echo    Config: %Config%

:: java --Declipse.application=org.eclipse.jdt.ls.core.id1
::      -Dosgi.bundles.defaultStartLevel=4
::      -Declipse.product=org.eclipse.jdt.ls.core.product
::      -Dlog.level=ALL
::      -noverify
::      -Xmx1G
::      -jar %JarFile%
::      -configuration %Congfig%
::      --add-modules=ALL-SYSTEM
::      --add-opens java.base/java.util=ALL-UNNAMED
::      --add-opens java.base/java.lang=ALL-UNNAMED
::      -data %CacheDirctory%

:: echo the command for debugging
:: echo java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar %JarFile% -configuration %Config% --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data %CacheDirctory%

:: run the language server using stdio communications,HERE get the JDK and then run lap server
X:&&X:\\XJava\\FSetnearbyJDK.bat&&d:&&echo %PATH%&&java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar %JarFile% -configuration %Config% --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data %CacheDirctory%
goto complete

:usage
echo.
echo   Usage: jLSP.cmd WorkspaceDirectory FileDirectory
echo Example: jLSP.cmd "$wdd" "$fdd"
echo.

:complete
veksha commented 2 years ago

what if you just run batch file with parameters in terminal?

veksha commented 2 years ago

@RESDXChgfore9hing ensure you provide parameters: "cmd_windows": ["C:\\Java\\jLSP.cmd", "."],

created issue: https://github.com/CudaText-addons/cuda_lsp/issues/95

RESDXChgfore9hing commented 2 years ago

i updated the cudatext to ver1.174.0.0 and reinstalled the lsp the queue error is gone now however i still dont see any lsp popup. hmm.... my lsp config is '''{ "lexers": { "Java": "java" }, "cmd_unix": [ "", ], "cmd_windows": [ "D:\testlsp\ctrun2.bat","D:\testlsp\jdt\work", "D:\testlsp\jdt\work"] }

'''

workedbutnopopupsuggest

RESDXChgfore9hing commented 2 years ago

i can run the lsp server from terminal directly.

ctrun2.bat "%cd%\work" "%cd%\work" OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release. Content-Length: 121

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2022/10/27 19:40:29 Main thread is waiting"}}

RESDXChgfore9hing commented 2 years ago

tried your config

ctrun2.bat ".\work" ".\work"
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Content-Length: 121

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2022/10/27 19:48:33 Main thread is waiting"}}

but its still same though no suggestion maybe there is some options i need to enable show?

Alexey-T commented 2 years ago

@RESDXChgfore9hing Use triple BACKticks please for code blocks. See Markdown docs.

RESDXChgfore9hing commented 2 years ago

backticks? " or ' i dont think my keyboard have backticks

RESDXChgfore9hing commented 2 years ago

ps i think i got it working. i think it needs the java lexer installed also the lsp pop up uses the same setting as config as fixed autosuggestion.

Alexey-T commented 2 years ago

it needs the java lexer installed also

Of course.

Alexey-T commented 2 years ago

the lsp pop up uses the same setting as config as fixed autosuggestion.

What does it mean? do you see LSP completions?

RESDXChgfore9hing commented 2 years ago

config

RESDXChgfore9hing commented 2 years ago

"${fdir}" dont work on my side,need to give a valid folder if not wrong.

Alexey-T commented 2 years ago

But ${fdir} must give the valid folder, no?

RESDXChgfore9hing commented 2 years ago

oh so you mean the user need to replace?the ${fdir} with an actual path? like>D:\testlsp\work

Alexey-T commented 2 years ago

No, user must not do this, ${fdir} inside lsp_java.json must be handled by lsp plugin.

RESDXChgfore9hing commented 2 years ago

huh thats weird,i think the lsp plugin need some fix then. since when i put ${fdir} the server just crashed.

Alexey-T commented 2 years ago

@RESDXChgfore9hing my mistake, "fdir" is not supported here.

Alexey-T commented 2 years ago

@RESDXChgfore9hing we discuss java server in the https://github.com/CudaText-addons/cuda_lsp/issues/98 . this topic -overheated, closing it. Make new topic for other servers in https://github.com/CudaText-addons/cuda_lsp/issues

Alexey-T commented 2 years ago

@RESDXChgfore9hing Info about Java server was added to the wiki. it is working (Win/Linux).

RESDXChgfore9hing commented 2 years ago

Nice.