emacs-lsp / lsp-docker

Scripts and configurations to leverage lsp-mode in docker environment
GNU General Public License v3.0
245 stars 34 forks source link

Issue evaluating hashtable on default mappings config #82

Closed thatnerdjosh closed 10 months ago

thatnerdjosh commented 10 months ago

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.

thatnerdjosh commented 10 months ago

Here is the error I was running into:

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

thatnerdjosh commented 10 months ago

cc: @rnikoopour

factyy commented 10 months ago

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

yyoncho commented 10 months ago

I pushed a fix for the ht usage: https://github.com/emacs-lsp/lsp-docker/commit/a9beb0b5c3cdb3fb1b6e34c6ad752f3b8474ae8a . Not sure if this will be enough to unblock the issue.

thatnerdjosh commented 10 months ago

I'll test this now

thatnerdjosh commented 10 months ago

Seems to work :)

thatnerdjosh commented 10 months ago

Thanks @yyoncho - closing the issue now.

Wilfred commented 10 months ago

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]
thatnerdjosh commented 10 months ago

@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 10 months ago

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