lsp

frankitox 2025-07-11T04:52:36.323609Z

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?

frankitox 2025-07-14T04:23:30.727639Z

In case someone finds this useful. Here's a snippet that laods the log file in a buffer when you press cl:

(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 fennel

frankitox 2025-07-14T04:28:13.362509Z

Not 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.

frankitox 2025-07-11T05:09:09.260789Z

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>
  }
}

ericdallo 2025-07-11T16:09:56.847579Z

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

frankitox 2025-07-11T16:25:05.638289Z

Obrigado Eric 😃