Hi! From the https://clojure-lsp.io/troubleshooting/#logs I see that every LSP instance has an autogenerated log file. Is it possible to access to the path of that log file from text editors?
In case someone finds this useful. Here's a snippet that laods the log file in a buffer when you press :
(fn get-clojure-lsp-client! []
(->> (vim.lsp.get_clients)
(filter (fn [client]
(= client.name :clojure_lsp)))
(first)))
(fn get-clojure-lsp-log-path [client raw-info]
(get-in raw-info [(get client :id) :result :log-path]))
(-> {:on_attach
(fn [_ bufnr]
(vim.api.nvim_buf_set_keymap
bufnr :n :cl ""
{:noremap true
:callback (fn []
(vim.lsp.buf_request_all
bufnr
:clojure/serverInfo/raw
{}
(fn [err _result _ctx]
(let [client (get-clojure-lsp-client!)]
(when (not client)
(error "No Clojure LSP client running!"))
(let [buf (-> (get-clojure-lsp-log-path client err)
(vim.fn.bufadd))]
(buf-set-opts! buf
{:modifiable false
:buflisted true
:autoread true})
(vim.api.nvim_set_current_buf buf))))))}))}
(lspconfig.clojure_lsp.setup))
It uses neovim with fennelNot sure why I have to access the err, instead of result (see https://neovim.io/doc/user/lsp.html#lsp-handler). But that's where the information is.
I also tried to use clojure/serverInfo/log, but I'm not completely sure how. I tried using https://neovim.io/doc/user/lsp.html#vim.lsp.buf_request_all() which is used in neovim to call LSP methods, but I get this error:
{
[4] = {
err = <1>{
code = -32601,
data = {
method = "clojure/serverInfo/log"
},
message = "Method not found",
<metatable> = {
__tostring = <function 1>
}
},
error = <table 1>
}
}clojure/serverInfo/log is a notification that will make server use window/showMessage while clojure/serverInfo/raw is a request which will return the data
https://github.com/emacs-lsp/lsp-mode/blob/284332acbdbe3d4b2719567f7c761bf9742d7b7d/clients/lsp-clojure.el#L309-L313 an example of that usage in emacs
Obrigado Eric 😃