Fork me on GitHub
#emacs
<
2022-06-28
>
Vinicius Vieira Tozzi16:06:17

I am using LSP in emacs to code Clojure and it works perfect, but when I open a ClojureScript project it does not work and I get the following error: File mode specification error: (json-object-format , 34) Any ideas on why is this happening? Thanks!

ericdallo16:06:40

this is a error on emacs side, try toggle-debug-on-error and repro the error again to get a stacktrace

Vinicius Vieira Tozzi16:06:58

I did it, but I can’t really interpret what’s happening:

Debugger entered--Lisp error: (json-object-format "," 34)
  signal(json-object-format ("," 34))
  json-read-object()
  json-read()
  json-read-file("/Users/tozzi/Projects/recipe-webapp-poc/package.json")
  lsp-volar--vue-project-p("/Users/tozzi/Projects/recipe-webapp-poc")
  lsp-volar--activate-p("/Users/tozzi/Projects/recipe-webapp-poc/src/recipe..." clojurescript-mode)
  lsp--supports-buffer\?(#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode -0x10f8e60a0a5f712c>) :test\? #f(compiled-function () #<bytecode 0x1eaab965c7e2a0f>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x4a5986d5> :request-handlers #<hash-table equal 0/65 0x4a5f4ec7> :response-handlers #<hash-table eql 0/65 0x43a302bd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x539acdbf> :action-handlers #<hash-table equal 0/65 0x539acddf> :major-modes nil :activation-fn lsp-volar--activate-p :priority 0 :server-id volar-api :multi-root nil :initialization-options #f(compiled-function () #<bytecode -0x10bc6736bf26aaab>) :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn #f(compiled-function (workspace) #<bytecode 0x89004ca9ed8999a>) :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers #<hash-table equal 0/65 0x4a5f4691> :download-server-fn #f(compiled-function (client callback error-callback update\?) #<bytecode 0x1730d1a6c7284d23>) :download-in-progress? nil :buffers nil :synchronize-sections nil))
  apply(lsp--supports-buffer\? #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode -0x10f8e60a0a5f712c>) :test\? #f(compiled-function () #<bytecode 0x1eaab965c7e2a0f>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x4a5986d5> :request-handlers #<hash-table equal 0/65 0x4a5f4ec7> :response-handlers #<hash-table eql 0/65 0x43a302bd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x539acdbf> :action-handlers #<hash-table equal 0/65 0x539acddf> :major-modes nil :activation-fn lsp-volar--activate-p :priority 0 :server-id volar-api :multi-root nil :initialization-options #f(compiled-function () #<bytecode -0x10bc6736bf26aaab>) :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn #f(compiled-function (workspace) #<bytecode 0x89004ca9ed8999a>) :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers #<hash-table equal 0/65 0x4a5f4691> :download-server-fn #f(compiled-function (client callback error-callback update\?) #<bytecode 0x1730d1a6c7284d23>) :download-in-progress? nil :buffers nil :synchronize-sections nil))
  #f(compiled-function (&rest args) #<bytecode 0x1a4af9ff4e837cef>)(#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode -0x10f8e60a0a5f712c>) :test\? #f(compiled-function () #<bytecode 0x1eaab965c7e2a0f>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x4a5986d5> :request-handlers #<hash-table equal 0/65 0x4a5f4ec7> :response-handlers #<hash-table eql 0/65 0x43a302bd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x539acdbf> :action-handlers #<hash-table equal 0/65 0x539acddf> :major-modes nil :activation-fn lsp-volar--activate-p :priority 0 :server-id volar-api :multi-root nil :initialization-options #f(compiled-function () #<bytecode -0x10bc6736bf26aaab>) :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn #f(compiled-function (workspace) #<bytecode 0x89004ca9ed8999a>) :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers #<hash-table equal 0/65 0x4a5f4691> :download-server-fn #f(compiled-function (client callback error-callback update\?) #<bytecode 0x1730d1a6c7284d23>) :download-in-progress? nil :buffers nil :synchronize-sections nil))
  -filter(#f(compiled-function (&rest args) #<bytecode 0x1a4af9ff4e837cef>) (... ... ... ... ... ... ... ... ... ... ... ... ... ... ...))
  lsp--filter-clients(#f(compiled-function (&rest args) #<bytecode 0x1a4af9ff4e837cef>))
  lsp(nil)
  funcall-interactively(lsp nil)
  call-interactively(lsp record nil)
  command-execute(lsp record)
  execute-extended-command(nil "lsp" "lsp")
  funcall-interactively(execute-extended-command nil "lsp" "lsp")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

ericdallo16:06:50

sounds like it's using lsp-volar instead of clojure :thinking_face:

Vinicius Vieira Tozzi16:06:16

hmm I don’t even know what’s this 😅 but if it helps, this is my config:

(use-package lsp-mode
  :init
  ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
  (setq lsp-keymap-prefix "C-c l")
  :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
         (clojure-mode . lsp)
         (clojurescript-mode . lsp)
	 (clojurec-mode . lsp)
	 (rust-mode . lsp)
	 (c-mode . lsp)
	 (go-mode . lsp)
         ;; if you want which-key integration
         (lsp-mode . lsp-enable-which-key-integration))
  :commands lsp)

(use-package lsp-ui :commands lsp-ui-mode)

;;Syntax checking
(use-package flycheck
  :ensure t
  :init (global-flycheck-mode))

;;For debugging
(use-package dap-mode)

Vinicius Vieira Tozzi16:06:20

ah I see, volar is for Vue.js, interesting that I can’t find any function trough M-x lsp-volar…

Vinicius Vieira Tozzi16:06:16

I also tried creating a new shadow-cljs project and that seems to work fine, the LSP connects and it works just fine so I guess it is really something with my project

ericdallo16:06:07

hum, it seems like your lsp-mode is missing some elisp to load so

ericdallo16:06:12

try recompile it

Vinicius Vieira Tozzi16:06:03

dumb question, but how do I recompile lsp-mode? or do you mean really recompile emacs?

ericdallo16:06:38

are you using doom or spaceemacs os something like that or just vanila emacs?

ericdallo16:06:59

if vanilla, are you using straight.el or something like that or just installing packages with package-install ?

Vinicius Vieira Tozzi17:06:01

I am using straight.el

ericdallo17:06:07

so straight usually persits the compiled elisp somewhere in your .emacs.d folder

ericdallo17:06:17

I think you can remove it

ericdallo17:06:46

on doom-emacs, straight persists it here ~/.emacs.d/.local/straight/repos/lsp-mode

Vinicius Vieira Tozzi17:06:46

so just to be sure I deleted the correct files, I just deleted the whole .emacs.d folder and cloned from my repository again and after rebuilding everything it works just fine

Vinicius Vieira Tozzi17:06:05

perfect, thank you for the help!

dpsutton18:06:42

i forget the exact args and syntax but i do something to this effect: find -name *.elc | xargs rm . You can just remove the compiled files (elc) and then restart emacs

Vinicius Vieira Tozzi19:06:12

ah ok, I thought there was some specific command, but this is good to know, thanks

jjttjj17:06:17

I have org-babel working with inf-clojure. Is there a way to get paredit/clojure-mode working inside the the clojure code blocks? Is that supposed to work by default?

apt18:06:36

I think you can use C-c ' for opening the code block in another buffer with the proper major mode

jjttjj18:06:17

woah cool, thanks!

otfrom19:06:27

I'd love to see your config for that

jjttjj02:06:09

I just started messing with it today and jumbled this together from google results until it worked, not totally sure it will work if repeated

(require 'ob-clojure)
(setq org-babel-clojure-backend 'inf-clojure)

;;; might be a bad default?
(setq org-confirm-babel-evaluate nil)

(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
   (shell . t)
   (clojure . t)))
Then, in an org file:
#+begin_src clojure
  (println "hi")
  (+ 1 2 3)
#+end_src
And c-c to eval the result (in the current inf-clojure repl)