emacs-lsp/lsp-docker

Issue evaluating hashtable on default mappings config

thatnerdjosh opened this issue · 10 comments

I was having trouble registering a custom image/dockerfile as an LSP server following the GitHub readme...

After about 5h of debugging, I found out the issue was because I was happy with the default mappings and tried using them.

There is some issue where the hashtable in the list of mappings (below) is not evaluated:

(defcustom lsp-docker-persistent-default-config
  (ht ('server (ht ('type "docker")
                   ('subtype "image")
                   ('name "emacslsp/lsp-docker-langservers")
                   ('server nil)
                   ('launch_command nil)))
      ('mappings [
                  (ht ('source ".")
                      ('destination "/projects"))
                  ]))
  "Default configuration for all language servers with persistent configurations"
  :type 'hash-table
  :group 'lsp-docker
)

This is seen when printing the hashtable via an interactive function:

#s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (server #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data (launch_command "blah" server "custom-lsp" name "custom-lsp" subtype "image" type "docker")) mappings [(ht ('source ".") ('destination "/projects"))]))

I would fix this, but it may be quicker for you, as I am not experienced with development of elisp plugins.

If you can point me in the right direction for setting up my environment to work on an elisp plugin, I can fix it and create a PR.

Here is the error I was running into:

condition-case: Wrong type argument: hash-table-p, (ht ('source ".") ('destination "/projects")) [2 times]

factyy commented

This feature was written by me but I'm really out of time right now :(
Could you give it a try first?

I pushed a fix for the ht usage: a9beb0b . Not sure if this will be enough to unblock the issue.

I'll test this now

Seems to work :)

Thanks @yyoncho - closing the issue now.

FWIW the problem is how you're using a vector [] literal syntax for mappings. Vector elements in literals aren't evaluated.

ELISP> [(+ 1 2)]
[(+ 1 2)]

ELISP> (vector (+ 1 2))
[3]

@Wilfred - good to know - thanks!

@yyoncho - if you want I can submit a pull request which changes it to not use a vector literal instead of changing the library/method for creating the mapping. It works fine as is, just let me know.

factyy commented

@Wilfred , thanks a lot! To be honest I just wasn't aware of this when was implementing this feature. My bad :/