Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-server feature #85

Merged
merged 23 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e28b28c
chores: solve few warnings, clarify code through indentation
sfavazza Sep 10, 2023
9bfdb35
chores: complete removal of unused arguments
sfavazza Sep 10, 2023
1c53d35
feat: rm unneeded function, improve doc
sfavazza Sep 21, 2023
40984b1
chores: keep unused inputs for future feature
sfavazza Oct 21, 2023
b79691c
feat: adapt hash-table getter functions to work on server-config node
sfavazza Sep 10, 2023
8848718
feat: add support for multi-server configuration
sfavazza Sep 10, 2023
55328d4
fix: correct argument to get base client instance, style fix
sfavazza Sep 14, 2023
2404c48
chores: complete "config" to "server-config" renaming, improve functi…
sfavazza Sep 16, 2023
0b5450c
feat: add error messages, correct some doc-strings
sfavazza Oct 23, 2023
c5ac2af
feat: use defconst for 'server and 'multi-server keywords, fix config…
sfavazza Oct 23, 2023
73a1b8b
feat: encode all keywords into 'defconst'
sfavazza Dec 9, 2023
1a51778
feat: merge 'lsp-docker-get-server-container-name' and 'lsp-docker-ge…
sfavazza Dec 9, 2023
a0c9621
feat: complete YAML keys replacement with defconst
sfavazza Dec 9, 2023
8461f24
feat: prepare to server list concept
sfavazza Dec 9, 2023
e6dd277
feat: remove 'multi-server' key, implement list of server config inst…
sfavazza Dec 9, 2023
b06eae9
Merge pull request #2 from sfavazza/multi_server_feature
sfavazza Dec 13, 2023
79da5a4
feat: add manual test files
sfavazza Dec 17, 2023
fbe10b4
fix: restore initial form of lsp-docker-get-server-id
sfavazza-duagon Dec 21, 2023
f962a70
feat: update test sources
sfavazza-duagon Dec 22, 2023
07a1602
feat: revert "feat: merge 'lsp-docker-get-server-container-name' and …
sfavazza-duagon Dec 22, 2023
d091264
chores: test files improvements
sfavazza Jan 6, 2024
935c814
chores: test files improvements
sfavazza Jan 6, 2024
b23d606
doc: fix typo (review #85)
sfavazza Feb 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ emacs.d
Debug
.log
*.ccls-cache*

# test files
test/.lsp-docker.yml
33 changes: 25 additions & 8 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
- [[#flags][Flags]]
- [[#emacs][Emacs]]
- [[#spacemacs][Spacemacs]]
- [[#custom-language-server-containers][Custom language server containers]]
- [[#custom-language-server-containers][Custom language server containers]]
- [[#building-a-container-or-an-image-manually][Building a container (or an image) manually:]]
- [[#registering-a-language-server-using-a-persistent-configuration-file][Registering a language server using a persistent configuration file:]]
- [[#registering-a-language-server-using-a-dir-locals-file][Registering a language server using a =.dir-locals= file:]]
- [[#automatic-image-building][Automatic image building:]]
- [[#docker-over-tramp-tbd][Docker over TRAMP (TBD)]]
- [[#see-also][See also]]
- [[#maintainers][Maintainers]]
Expand Down Expand Up @@ -115,11 +119,11 @@
#+begin_src bash
EMACS_D_VOLUME=/path/to/spacemacs bash start-spacemacs.sh
#+end_src
** Custom language server containers

** Custom language server containers
You can use manually built language containers or images hosting language server(s), just follow a few simple rules (shown below).
The docker images may feature an optional tag, if omitted _latest_ will be assumed.

*** Building a container (or an image) manually:
You have 2 constraints:
- A language server must be launched in =stdio= mode (other types of communication are yet to be supported)
Expand All @@ -143,6 +147,7 @@
It is structured in the following way:

#+begin_src yaml
# signle server configuration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in b23d606

lsp:
server:
type: docker
Expand All @@ -152,11 +157,11 @@ It is structured in the following way:
# (see Automatic image building). An image might feature an optional tag, i.e. '<image>:<tag>'. If a
# tagless image is indicated 'latest' will be assumed.
subtype: container
# image/container name to use for this language server
# Image/container name to use for this language server.
name: image-container-name
# server id of a registered LSP server. You can find the list of registered servers evaluating:
#
# `(let ((keys ())) (maphash (lambda (k v) (push k keys)) lsp-clients) keys)`
# `(ht-keys lsp-clients)`
#
# source:
# https://stackoverflow.com/questions/17066169/retrieve-keys-from-hash-table-sorted-by-the-values-efficiently
Expand All @@ -169,14 +174,26 @@ It is structured in the following way:
# NOTE: the paths must be within the project this server is being build for
- source: "/your/host/source/path"
destination: "/your/path/inside/the/container"

# multiple server configuration
lsp:
server:
- type: ...
subtype: ...
... # keys as in the classic single server case, e.g. type, subtype, etc...
- ... # other single server configuration(s)
mappings: # shared among each server
- source: <path-on-host>
destination: <path-on-lang-server>
... # other mappings
#+end_src

*** Registering a language server using a =.dir-locals= file:
Just refer to the source code and general conventions of using =.dir-locals=. The variable you need is =lsp-docker-persistent-default-config=, its content is merged with the =lsp= section from a configuration file (if present).

*** Automatic image building:
You can also build an image automatically (currently supported only for =image= subtype): just drop the corresponding =Dockerfile= into the =.lsp-docker= folder in the project root (=Dockerfile= may be named as =Dockerfile= or =Dockerfile.lsp=). Building process is triggered by the =lsp-docker-register= call (you will be prompted whether you want to build the image). Image building *takes place in the project root* (*not* in the =.lsp-docker= subfolder)! In case of an automatic build the image will be registered automatically (based on the values from the config or =.dir-locals= file).

You can also troubleshoot any issues with supplemental docker calls (checking whether the required image already exists, building a new image) using the supplemental logging functionality: there are 2 variables: first you have to set =lsp-docker-log-docker-supplemental-calls= to true-like value (by default it is =nil=) and then specify the log buffer in the =lsp-docker-log-docker-supplemental-calls-buffer-name= variable (by default it is set to =*lsp-docker-supplemental-calls*=)

** Docker over TRAMP (TBD)
Expand Down
Loading
Loading