lsp-docker icon indicating copy to clipboard operation
lsp-docker copied to clipboard

Add ability to define docker lsp clients only for certain paths

Open aidalgol opened this issue 3 years ago • 1 comments

I have started using lsp-docker with elixir-ls along with elixir under docker so that I can use whichever version of the LS I need for a given Elixir project. But now that I have started another Elixir project using my system's Elixir version (instead of via docker), I have discovered that my elixir-ls docker client is taking precedence over the client defined in the lsp-elixir elisp package.

The lsp-related part of my init:

;; Set up LSP Docker
(add-to-list 'load-path "~/src/elisp/lsp-docker")
(load-library "lsp-docker")

(with-eval-after-load "lsp-elixir"
  (lsp-docker-init-clients
   :path-mappings '(("/home/aidan/src" . "/projects"))
   :client-configs '((:server-id elixir-ls
                      ;;:priority -5
                      :docker-server-id elixirls-docker:1-10
                      :docker-image-id "elixir-ls:1.10"
                      :docker-container-name "lsp-elixir-container"
                      :server-command "language_server.sh"))))

;; Specify which projects should use which LSP clients.
(dir-locals-set-class-variables 'elixirls-docker:1-10
  '((nil . ((lsp-enabled-clients . (elixirls-docker:1-10))
            (eval . (add-hook 'elixir-mode-hook #'lsp))))))

(dir-locals-set-directory-class
 "/home/aidan/src/junk" 'elixirls-docker:1-10)

On discord, @yyoncho proposed adding the ability to specify an lsp-docker client only for certain paths.

aidalgol avatar May 13 '21 04:05 aidalgol

@aidalgol , take a look into the current implementation: if you use wrapper functions (like lsp-docker-register) with a valid configuration, it will register an lsp docker client only for this particular path (in case you are using single folder mapping as in your example).

factyy avatar Feb 08 '22 15:02 factyy