How to add a new language?

Tips and information on how to install and use language servers with the editor.
Post Reply
bprlhe
Posts: 26
Joined: 01 Apr 2023 06:26

How to add a new language?

Post by bprlhe »

Used Syntax Editor, I created a partial working syntax highlighting for the new language and I enabled the syntax highlighter for it. Unfortunately, on language server templates when I trying to add the language server of the new language, I can't find the new language I just added syntax highlighting for. I ended up choosing an existing language but with the source file extension of the new language. When I opened a source file of the newly added language, syntax highlighting worked fine. But there is no sights that the language server is working. This is confirmed using Task Manager as there is no process of the language server running.
User avatar
Rickard Johansson
Site Admin
Posts: 6577
Joined: 19 Jul 2006 14:29

Re: How to add a new language?

Post by Rickard Johansson »

First you need a language server installed on your system. Find the home page of a language server and follow the instructions on how to install.

Then create a project and add the language server in project settings.

You can check out the instructions given for other language servers, in this forum, and see if that helps.

If you manage to install and use a language server - please post, or send me, instructions on how to do it.
bprlhe
Posts: 26
Joined: 01 Apr 2023 06:26

Re: How to add a new language?

Post by bprlhe »

This is objeck-lsp: https://github.com/objeck/objeck-lsp

I extracted it to C drive. You could extract it to anywhere you want, but you have to modify the paths accordingly.

You must have Objeck VM installed and added to PATH:

https://github.com/objeck/objeck-lang/releases

For example, I extracted to zip release into C drive so I have to put C:/objeck-lang/bin to PATH.

If you are on Windows like me, you have to put C:/objeck-lang/lib/sdl to PATH too.

You must have these environment variables set:

OBJECK_LIB_PATH set to C:/objeck-lang/lib and OBJECK_STDIO set to binary.

If you extracted Objeck VM to another location, you have to modify the paths according to your setup.
bprlhe
Posts: 26
Joined: 01 Apr 2023 06:26

Re: How to add a new language?

Post by bprlhe »

Objeck Language Server

Command: obr

Command line arguments: C:/objeck-lsp/objeck_lsp.obe C:/objeck-lsp/objk_apis.json stdio

File extension and language id:

.obs as file extension

The problem is there is no Objeck entry on Language identifiers to choose!
User avatar
Rickard Johansson
Site Admin
Posts: 6577
Joined: 19 Jul 2006 14:29

Re: How to add a new language?

Post by Rickard Johansson »

Most language servers know which file extensions to use. So it's possible you can leave this blank and not add an extension/language id. Or you could try .obs=c

Anyway, is the language server up and running? Is it working?
bprlhe
Posts: 26
Joined: 01 Apr 2023 06:26

Re: How to add a new language?

Post by bprlhe »

Rickard Johansson wrote: 03 Apr 2023 07:43 Most language servers know which file extensions to use. So it's possible you can leave this blank and not add an extension/language id. Or you could try .obs=c

Anyway, is the language server up and running? Is it working?
I don't see anything indicating the language server is running when I edit .obs file. Checked with Task Manager, there is indeed no process of the language server running. Perhaps you need to test it yourself and write a guide like for other language servers you posted. I'm a completely new user. I don't know much about the text editor so it could be me doing something wrong.
User avatar
Rickard Johansson
Site Admin
Posts: 6577
Joined: 19 Jul 2006 14:29

Re: How to add a new language?

Post by Rickard Johansson »

Apparently, you need to build the server first. I tried but after a few times - I gave up.
I installed the runtime files to the %Program%\Objeck folder (used the windows installer). Set the environment variables, unpacked the code to the E:\ drive:

e:\objeck-lang
e:\objeck-lsp

and tried to build the server. Nothing worked though :( Maybe you need to build a few files in the objeck-lang\core\release folder with Microsoft Visual Studio first?
bprlhe
Posts: 26
Joined: 01 Apr 2023 06:26

Re: How to add a new language?

Post by bprlhe »

Rickard Johansson wrote: 03 Apr 2023 12:54 Apparently, you need to build the server first. I tried but after a few times - I gave up.
I installed the runtime files to the %Program%\Objeck folder (used the windows installer). Set the environment variables, unpacked the code to the E:\ drive:

e:\objeck-lang
e:\objeck-lsp

and tried to build the server. Nothing worked though :( Maybe you need to build a few files in the objeck-lang\core\release folder with Microsoft Visual Studio first?
My guide is for the portable version of the Objeck VM. If you used the installer then it's much easier. You could forgot the guide above. After you installed the Objeck VM, download and extract objeck-lsp, for example, into C drive. On the directory objeck-lsp you create this objeck_lsp.bat file:

Code: Select all

@ECHO OFF

SET OBJECK_STDIO=binary

obr %~dp0\objeck_lsp.obe %~dp0\objk_apis.json stdio
You then use C:\objeck-lsp\objeck_lsp.bat as the command instead and leave command line arguments empty.

p/s: the server was distributed in binary form, why do you need to build it?

https://github.com/objeck/objeck-lsp/re ... 23.4.0.zip

The Objeck VM is also distributed in binary form. The portable version is:

https://github.com/objeck/objeck-lang/r ... 23.4.0.zip

You mentioned objeck-lang\core\release, did you mistakenly download the zipped source code on the release page? It's not the same thing as the portable version!
bprlhe
Posts: 26
Joined: 01 Apr 2023 06:26

Re: How to add a new language?

Post by bprlhe »

With the objeck_lsp.bat file, I could confirm the language server is running when I edit .obs source file. The problem is there is absolutely no code completion at all. I think the problem is with your LSP client. I think I should find another text editor with a better LSP client. Wasted so many days without any results. Goodbye.
User avatar
Rickard Johansson
Site Admin
Posts: 6577
Joined: 19 Jul 2006 14:29

Re: How to add a new language?

Post by Rickard Johansson »

I don't think you can use a .bat file. The lsp client should communicate with the server. Not cmd.exe.

This seems to work.

Server name
Objeck Language Server

Command
obr.exe

Command line arguments
objeck_lsp.obe objk_apis.json stdio

Initial dir
E:\lsp\objeck-lsp

File extension and language id
.obs=c

Communication channel
-stdio

Source folders
<Path to project folder>

At least I'm getting some diagnostics (errors, warnings etc.) and hover information. Ctrl+Space send a completion request to the server but doesn't always return anything:

Code: Select all

Read from server:
{"id":34,"jsonrpc":"2.0","result":null}
bprlhe
Posts: 26
Joined: 01 Apr 2023 06:26

Re: How to add a new language?

Post by bprlhe »

I will report back to the Objeck developer. Thank you.
Post Reply