Closed EmilyGraceSeville7cf closed 2 years ago
That is the expected behavior. If lsp
function is not attached to the major mode, the language server won't start.
I don't understand why it's not attached to a major mode. I have these lines in my config:
(defvar emacs-hooks '(cmake-mode-hook
xml-mode-hook ; <--
json-mode-hook
yaml-mode-hook
shell-mode-hook
python-mode-hook
java-mode-hook
csharp-mode-hook
c++-mode-hook))
(dolist (hook emacs-hooks)
(add-hook hook #'lsp))
There is no xml-mode, there is nxml-mode or some are using web-mode for xml. Use M-: major-mode
to find out what is your major mode.
LSP still does't work even I replaced xml-mode-hook
with nxml-mode-hook
. Now it doesn't want to start lsp at all...
and what is your major mode?
nxml-mode
The first error occures when I open empty test.xml file: File mode specification error: (json-end-of-file).
The second when I press M-x lsp
: End of file while parsing JSON.
can you do M-x toggle-debug-on-error and do M-x lsp again?
*lsp-log*
:
1 Command "/usr/local/bin/bash-language-server start" is present on the path.
1 Command "/home/emilyseville7cfg/.emacs.d/.cache/lsp/npm/vscode-langservers-extracted/bin/vscode-json-language-server --stdio" is present on th\
e path.
2 Command "/home/emilyseville7cfg/.emacs.d/.cache/lsp/npm/yaml-language-server/bin/yaml-language-server --stdio" is present on the path.
The first error occures when I open empty test.xml file: File mode specification error: (json-end-of-file).
Please, do M-x toggle-debug-on-error and reproduce that error.
I start emacs as emacs -nw --eval '(toggle-debug-on-error) (setq lsp-print-io t)' test.xml
. But I don't see any notable differences. What am I doing wrong?
Here what I see:
*Messages*
:
21 ‘spacemacs-theme’ is already installed
20 ‘flycheck’ is already installed
19 ‘json-mode’ is already installed
18 ‘yaml-mode’ is already installed
17 ‘markdown-mode’ is already installed
16 ‘lsp-mode’ is already installed
15 ‘cmake-mode’ is already installed
14 ‘lsp-pyright’ is already installed
13 ‘lsp-java’ is already installed
12 ‘lsp-pascal’ is already installed
11 ‘format-all’ is already installed
10 ‘company’ is already installed
9 [Treemacs] Warning: coudn’t find default background colour for icons, falling back on #2d2d31.
8 Saving file /home/emilyseville7cfg/.emacs...
7 Wrote /home/emilyseville7cfg/.emacs
6 For information about GNU Emacs and the GNU system, type C-h C-a.
5 Debug on Error enabled globally
4 test.xml has auto save data; consider M-x recover-this-file
3 Using vacuous schema
2 File mode specification error: (json-end-of-file)
1 Making completion list...
*lsp-log*
:
1 Command "/usr/local/bin/bash-language-server start" is present on the path.
1 Command "/home/emilyseville7cfg/.emacs.d/.cache/lsp/npm/vscode-langservers-extracted/bin/vscode-json-language-server --stdio" is present on th\
e path.
2 Command "/home/emilyseville7cfg/.emacs.d/.cache/lsp/npm/yaml-language-server/bin/yaml-language-server --stdio" is present on the path.
when you do M-x toggle-debug-on-error and then the error like the one you have happens, you should see the error callstack. Apparently, you have something problematic in your config but without providing that info I cannot help.
The issue is I don't know what causes this problem in my config.
@EmilySeville7cfg delete your packages and then start adding them one by one.
@EmilySeville7cfg delete your packages and then start adding them one by one.
@yyoncho, my current ~/.emacs
config:
;;; .emacs --- My custom .emacs config.
;;; Commentary:
;;; Installs different packages for code linting and formatting to enable user feel Emacs like an IDE.
;;; All language servers and linters can be installed separately.
;;; Code:
(require 'package)
(defun general-settings()
"Settings accessible without any plugins setup."
(defvar bookmark-save-flag 1)
(menu-bar-mode -1)
(setq-default tab-width 4)
(setq-default display-line-numbers 'relative))
(defun general-lsp-setup()
"General LSP settings setup."
(package-install 'lsp-mode)
(package-install 'company)
(require 'lsp-mode))
(defun xml-setup()
"XML plugin setup."
(lsp-ensure-server 'xmlls)
(let ((hook 'nxml-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)
;(add-hook hook #'origami-mode)
))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(general-settings)
(general-lsp-setup)
(xml-setup)
(provide '.emacs)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages '(json-mode yaml-mode lsp-mode spacemacs-theme)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;;; .emacs ends here
Almost everything is disabled except lsp mode. When I start emacs -nw --eval '(toggle-debug-on-error) (setq lsp-print-io t)' test.xml
where test.xml
is an empty new file I get File mode specification error: (json-end-of-file)
error.
*Messages*
:
9 ‘lsp-mode’ is already installed
8 ‘company’ is already installed
7 Saving file /home/emilyseville7cfg/.emacs...
6 Wrote /home/emilyseville7cfg/.emacs
5 For information about GNU Emacs and the GNU system, type C-h C-a.
4 Debug on Error enabled globally
3 test.xml has auto save data; consider M-x recover-this-file
2 Using vacuous schema
1 File mode specification error: (json-end-of-file)
*lsp-log*
: no such buffer available
Thank you for the bug report
lsp-mode
related packages.M-x lsp-start-plain
Bug description
No LSP started automatically for
*.xml
files.Steps to reproduce
Expected behavior
xmlls server started automatically.
Which Language Server did you use?
xmlls
OS
Linux
Error callstack
*lsp-log*
:Anything else?
view my ~/.emacs
The original bug report is here.
M-x lsp
starts xmlls normally: