https://github.com/whatacold/lsa
A simple Language Server Adapter
https://github.com/whatacold/lsa
Last synced: about 2 months ago
JSON representation
A simple Language Server Adapter
- Host: GitHub
- URL: https://github.com/whatacold/lsa
- Owner: whatacold
- Created: 2018-12-16T12:44:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-16T16:11:37.000Z (over 6 years ago)
- Last Synced: 2025-01-31T09:28:43.313Z (4 months ago)
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
A trivial Language Server adapter
# Why?
As there are some projects using non-UTF-8 encoding, e.g. GBK, at work,
and LSP specification only supports UTF-8, I need a way to adapt the response
from GBK to UTF-8 encoding.# How to use
1. Download `lsa.py` from this repo, or clone it if you like.
2. Replace whatever language server you use with `lsa.py`For me, I start the server with `eglot` in Emacs like this:
(defcustom eglot-ls-output-encoding "utf-8"
"The LS's output encoding")(defun whatacold/eglot-ccls-contact (interactive-p)
"A contact function to assemble args for ccls.
Argument INTERACTIVE-P indicates where it's called interactively."
(let ((json-object-type 'plist)
(json-array-type 'list)
result)
(push (format "-log-file=/tmp/ccls-%s.log"
(file-name-base
(directory-file-name
(car
(project-roots
(project-current))))))
result)
(when whatacold/ccls-init-args
(push (format "-init=%s" (json-encode
whatacold/ccls-init-args))
result))
(push "ccls" result)
; adapt the response encoding
(unless (equal eglot-ls-output-encoding "utf-8")
(dolist (item (reverse (list "lsa.py"
(concat "--original-response-encoding="
eglot-ls-output-encoding)
"--log-level=DEBUG"
"--")))
(push item result)))
result))# Notes
- Only Python 3 is currently supported