Skip to content

etherealHero/glscript-language-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

105 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Glscript-language-server is a language server that provides IDE functionality for writing glscript programs. You can use it with any editor that supports the Language Server Protocol (VS Code, Vim, Emacs, Zed, etc).

After initialization, glscript-language-server creates a proxy workspace for the TSServer project located at <project_dir>/.local/glproxy-workspace/.

Glproxy workspace files Description Can edit/delete
DEFAULT_INCLUDED.js includes for all scripts by default for TSServer ✔️
_debug.emitted.js synced current client buffer for debug ❌*
_bundle.<hash>.js required for TSServer correct work ❌*
jsconfig.json copied from <project_dir> for the TSServer project ❌**
debug/*/*.* emitted files in debug mode (for developers)

* do not edit or delete these files while working on the project.

** you should edit the source jsconfig.json and than restart the glscript service (glscript overwrites the jsconfig in the glproxy workspace on init).

Installation

Prerequisites

  1. NodeJS
  2. typescript & tsserver dependencies (version ^5 of tsserver not supported yet)
    npm i -D typescript typescript-language-server@4

Setup

  1. Download glscript-language-server from Release page and move it to <project_dir>/.local/glscript-language-server.exe

  2. Configure Language Client

    Visual Studio Code
    1. Install Generic LSP Proxy extension. Then, create a configuration file at <project_dir>/.vscode/lsp-proxy.json with the following content[1][2]:

      [
        {
          "languageId": "glscript",
          "command": "%CD%/.local/glscript-language-server.exe",
          "args": ["./node_modules/.bin/typescript-language-server.cmd"],
          "fileExtensions": [".ts", ".js"],
          "initializationOptions": {
            "locale": "en"
          }
        }
      ]
    2. Add <project_dir>/.vscode/launch.json for debugging[1][2]:

      {
        "version": "0.2.0",
        "configurations": [
          {
            "name": "Debug NodeJS runtime",
            "type": "node",
            "request": "launch",
            "runtimeExecutable": "node",
            "runtimeArgs": ["--enable-source-maps", "--inspect-brk"],
            "program": "${workspaceFolder}/.local/glproxy-workspace/_debug.emitted.js"
          }
        ]
      }
    3. It is recommended to disable the built-in TypeScript extension. Running both the built-in TypeScript service and glscript-language-server simultaneously may cause conflicts. Press Ctrl+Shift+X, search for "@builtin TypeScript and JavaScript Language Features", and disable that extension.

    4. Press Ctrl+Shift+P, search for "LSP Proxy: Reload LSP Configuration", then press Enter.

    WebStorm
    1. Install the LSP4IJ plugin.
    2. Add a new language server (User guide):

    Server

    Field Value
    Name glscript-language-server
    Command $PROJECT_DIR$/.local/glscript-language-server.exe $PROJECT_DIR$/node_modules/.bin/typescript-language-server.cmd

    Mappings / File type

    File type Language Id
    JavaScript javascript
    TypeScript typescript

    Mappings / File name patterns

    File name patterns Language Id
    *.js javascript
    *.ts typescript

    Configuration / Server / Initialization Options[1]

    {
      "locale": "en"
    }
    1. It is recommended to disable the built-in JavaScript and TypeScript language support to avoid conflicts.

Examples

For more detailed usage examples, including how to structure your project and use the #include directive, please see the examples directory in the repository.

References

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages