GitXplorerGitXplorer
J

po-language-server

public
11 stars
1 forks
0 issues

Commits

List of commits on branch main.
Unverified
68bf9140e419443d18436039cd84ced5cba44560

Fixed issue, enhanced README.

JJulienPalard committed 4 years ago
Unverified
a5fb82f5b64ec1a0a3eb26146f91320c93628247

Initial commit

JJulienPalard committed 4 years ago

README

The README file for this repository.

po-language-server

This is a Markov-chain based completion language server for gettext po files.

Installation

python3 -m pip install po-language-server

It should be compatible with vim, emacs, vscode, and other text editors acting as language server clients. I only tried it using emacs though.

Emacs configuration

I did not packaged it yet (feel free to help), but it's not that hard to configure:

(require 'lsp-mode)

(add-to-list 'lsp-language-id-configuration '(po-mode . "gettext"))

(lsp-register-client
 (make-lsp-client
  :new-connection (lsp-stdio-connection "po-language-server")
  :activation-fn (lsp-activate-on "gettext" "plaintext")
  :priority -1
  :server-id 'po
))
(add-hook 'po-mode-hook #'lsp)

;; lsp-mode can only work on named buffers
(defun po-mode-name-buffer ()
  (setq-local buffer-file-name "msgstr.po")
  (lsp))

(defun po-mode-unname-buffer ()
  (setq-local buffer-file-name nil))

(add-hook 'po-mode-hook
 (lambda ()
   (advice-add 'po-edit-msgstr :after 'po-mode-name-buffer)
   (advice-add 'po-subedit-exit :before 'po-mode-unname-buffer)))

(add-to-list 'lsp-enabled-clients 'po)