项目作者: anka-213

项目描述 :
高级语言: Haskell
项目地址: git://github.com/anka-213/gf-lsp.git
创建时间: 2021-05-26T12:52:37Z
项目社区:https://github.com/anka-213/gf-lsp

开源协议:

下载


Language Server for Grammatical Framework

This language server provides some very basic IDE support for Grammatical Framework

Currently, it only provides error messages for the currently opened file and it only checks when you save, so I recommend enabling auto-save in your editor (VS Code).

Installation

Only Mac and Linux is currently supported. Windows support will come in the future.

Visual Studio Code

For VS Code, you can install the Grammatical Framework Language Server extension and it will automatically install the language server for you.

Emacs

Install the version of gf-lsp for your system according to the sections below, then install eglot and put this config in your emacs config file

  1. (use-package eglot
  2. :ensure t
  3. :config
  4. (add-hook 'gf-mode-hook 'eglot-ensure)
  5. :custom
  6. (eglot-autoshutdown t) ;; shutdown language server after closing last file
  7. (eglot-confirm-server-initiated-edits nil) ;; allow edits without confirmation
  8. )
  9. (with-eval-after-load 'eglot
  10. (add-to-list 'eglot-server-programs
  11. '(gf-mode . ("gf-lsp" "--lsp"))))

Linux and Intel Macs

Prebuilt binaries are available with installation instructions in the latest release.

On M1 or M2 macs you will need to build from source. See the next section.

Building from source (necessary on M1 and M2 Macs)

This currently requires a patched version of Grammatical Framework, so the easiest way to build it is using nix.

Run the following commands in a shell

  1. # Install the nix build system
  2. curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
  3. # Ensure that the newly installed commands are available
  4. . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
  5. # Build and install the GF Language Server
  6. nix-env -if https://github.com/anka-213/gf-lsp/archive/main.tar.gz

After this you need to configure your editor to use ~/.nix-profile/bin/gf-lsp as the language server for .gf files.

Developing

You need to install the dependencies using nix.

First install nix:

  1. curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

Optionally use my binary cache to speed up builds:

  1. nix-env -iA cachix -f https://cachix.org/api/v1/install
  2. cachix use anka-213

Finally enable the nix-shell, to get all the necessary dependencies for building:

  1. nix-shell

From the new shell you can install it using

  1. nix-shell
  2. cabal install

or with

  1. nix-env -if .

or

  1. nix-env -if https://github.com/anka-213/gf-lsp/archive/main.tar.gz

How to use

You need to enable LSP client in your editor to use this. For example, you can download the VS Code plugin at https://github.com/anka-213/gf-vscode.
For other editors, configure .gf files to be handled by gf-lsp.

After installing both the server and client, it should show error messages inline at the location of the error.