jessevanmuijden / pact-lsp

LSP server for the Pact language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pact Language Server

Pact is an open-source, Turing-incomplete smart contract language that has been purpose-built with blockchains first in mind. Pact focuses on facilitating transactional logic with the optimal mix of functionality in authorization, data management, and workflow.

The LSP server requires Pact 4.6

Supported Features

The Pact language server currently supports the following features:

  • Document diagnostics Every time a file is opened or saved, the file is analyzed using the pact executable and diagnostic information is supplied. document diagnostic

  • Completion of natives While typing, the LSP server provides completions for natives. completion

  • Documentation of natives Hovering over natives populates the documentation. documentation

Server Configuration

The LSP server needs to access the pact executable. Therefore, users can configure the path of the executable at server initialization by sending a configuration as follows:

{
  "pact": {
    "pactExe": "/path/to/pact"
  }
}

Troubleshooting

The pact-lsp executable accepts the --debug flag to generate a log file which can be used to further debug issues.

Editor Configuration

Emacs

Using eglot:

(require 'pact-mode)
(require 'eglot)

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs '(pact-mode . ("pact-lsp" ))))

(add-hook 'pact-mode-hook 'eglot-ensure)

Using lsp-mode

(require 'pact-mode)
(require 'lsp-mode)

(add-to-list 'lsp-language-id-configuration '(pact-mode . "pact"))
  (lsp-register-client (make-lsp-client
                           :new-connection (lsp-stdio-connection "pact-lsp")
                           :activation-fn (lsp-activate-on "pact")
                           :server-id 'pact-lsp
                           :major-modes 'pact-mode)
                       )
 (add-hook 'pact-mode-hook 'lsp-deferred)
  )

or, in Doom Emacs

(after! (:all pact-mode lsp-mode)
  (add-to-list 'lsp-language-id-configuration '(pact-mode . "pact"))
  (lsp-register-client (make-lsp-client
                           :new-connection (lsp-stdio-connection "pact-lsp")
                           :activation-fn (lsp-activate-on "pact")
                           :server-id 'pact-lsp
                           :major-modes 'pact-mode)
                       )
  )

(after! pact-mode
  (add-hook 'pact-mode-hook (lambda () (lsp-deferred)))
  )


emacs

Vim

Using vim-lsp:

if (executable('pact-lsp'))
  au User lsp_setup call lsp#register_server({
      \ 'name': 'pact-lsp',
      \ 'cmd': {server_info->['pact-lsp']},
      \ 'whitelist': ['pact'],
      \ })
endif

vim

About

LSP server for the Pact language

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Haskell 92.4%Language:Nix 7.6%Language:Pact 0.0%