Closed EmilyGraceSeville7cf closed 1 year ago
@kiennq is there anything else that the user has to do to get the package.json schema? I thought that it is built-in?
It should be built-in and I've tested it on Emacs 29, still working fine.
@EmilySeville7cfg, can you capture the lsp-io log from the start just until you type the first "
?
I didn't see any completion request in your log so the completion result should be cached (or not requested) already.
Do you have company-mode
enabled?
Steps done:
File mode specification error: (json-end-of-file)
) 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.
3 Command "/home/emilyseville7cfg/.emacs.d/.cache/lsp/npm/vscode-langservers-extracted/bin/vscode-json-language-server --stdio" is present on th\
e path.
End of file while parsing JSON
)My ~/.emacs is here.
@EmilySeville7cfg, might be it's because of the file mode error?
Can you try to see if you can repro this with lsp-plain? Try lsp-restart-workspace
as well
M-x lsp-plain RET
executes lsp-start-plain
and doesn't help: the same issue exists in the newly opened emacs windowlsp-restart-workspace
(immediately after opening package.json
) gives me this error: There are no active servers in the current buffer.I've checked this issue with the following config (~/.emacs.d is removed before this test):
;;; .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 look-settings()
"Theme settings."
(package-install 'spacemacs-theme)
(load-theme 'spacemacs-light t))
(defun general-folding-setup()
"General folding settings setup."
(package-install 'origami))
(defun general-lsp-setup()
"General LSP settings setup."
(package-install 'lsp-mode)
(package-install 'company)
(require 'lsp-mode))
(defun lisp-setup()
"Lisp plugin setup."
(let ((hook 'emacs-lisp-mode-hook))
(add-hook hook #'company-mode)
(add-hook hook #'origami-mode)))
(defun yaml-setup()
"YAML plugin setup."
(package-install 'yaml-mode)
(let ((hook 'yaml-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)
(add-hook hook #'origami-mode)))
(defun json-setup()
"JSON plugin setup."
(package-install 'json-mode)
(let ((hook 'json-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)
(add-hook hook #'origami-mode)))
(defun bash-setup()
"Bash plugin setup."
(let ((hook 'sh-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)
(add-hook hook #'origami-mode)))
(defun python-setup()
"Python plugin setup."
(package-install 'lsp-pyright)
(require 'dap-python)
(let ((hook 'python-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)
(add-hook hook #'origami-mode)
(add-hook hook #'dap-mode)))
(defun java-setup()
"Java plugin setup."
(package-install 'lsp-java)
(require 'dap-java)
(let ((hook 'java-mode-hook))
(add-hook hook #'lsp)
(add-hook hook #'company-mode)
(add-hook hook #'origami-mode)
(add-hook hook #'dap-mode)))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(general-settings)
;(look-settings)
;(general-folding-setup)
(general-lsp-setup)
;(lisp-setup)
;(yaml-setup)
(json-setup)
;(bash-setup)
;(python-setup)
;(java-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
Hmm, I can still using json-mode
just fine with this configuration.
Are you using lsp-use-plists
but doesn't set the LSP_USE_PLISTS
env variable?
Are you using lsp-use-plists but doesn't set the LSP_USE_PLISTS env variable?
What value must be used for this environment variable?
Installing and running yasnippet fixed this for me.
(use-package yasnippet :straight t :init (yas-global-mode))
https://github.com/emacs-lsp/lsp-mode/discussions/4033#discussioncomment-5736276
@sethidden, thanks. I'll try your way to solve this issue. :)
I can confirm, installing yasnippet solves the issue.
That said I'm not sure why we need yasnippet "A template system for Emacs" to make completions work in json modes. I've been using other modes and they have been working fine without yasnippet, why is json mode special?
@danielpza @EmilySeville7cfg @sethidden
FWIW it is not up to the client. Apparently, the server does not return completion when client-side does not support snippets. This one can be closed after documenting this server limitation.
@yyoncho Where can I add these docs? Best I found was https://github.com/emacs-lsp/lsp-mode/blob/master/docs/lsp-clients.json#L366 but it doesn't look like it supports adding arbitrary text
Ok, please see https://github.com/emacs-lsp/lsp-mode/pull/4035
@yyoncho Hm https://github.com/emacs-lsp/lsp-mode/blob/master/docs/manual-language-docs/lsp-json-ls.md doesn't show up on https://emacs-lsp.github.io/lsp-mode/page/lsp-json/
Did I mess something up a few months back in the code so it's not detected?
Thank you for the bug report
lsp-mode
related packages.M-x lsp-start-plain
Bug description
No completions are shown in .json files.
Steps to reproduce
json-ls
serverpackage.json
file anywheredescription
is expected to be shownExpected behavior
description
is expected to be suggested.Which Language Server did you use?
json-ls
OS
Linux
Error callstack
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.
3 Command "/home/emilyseville7cfg/.emacs.d/.cache/lsp/npm/vscode-langservers-extracted/bin/vscode-json-language-server --stdio" is present on th\ e path.
4 Command "/home/emilyseville7cfg/.emacs.d/.cache/lsp/npm/vscode-langservers-extracted/bin/vscode-json-language-server --stdio" is present on th\ e path.
5 Found the following clients for /home/emilyseville7cfg/Documents/Mine/Shell/personal-editor-configs/package.json: (server-id json-ls, priority\ 0)
6 The following clients were selected based on priority: (server-id json-ls, priority 0)
18 ‘spacemacs-theme’ is already installed
17 ‘flycheck’ is already installed
16 ‘json-mode’ is already installed
15 ‘yaml-mode’ is already installed
14 ‘markdown-mode’ is already installed
13 ‘lsp-mode’ is already installed
12 ‘lsp-pyright’ is already installed
11 ‘lsp-java’ is already installed
10 ‘format-all’ is already installed
9 ‘company’ is already installed
8 [Treemacs] Warning: coudn’t find default background colour for icons, falling back on #2d2d31.
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 package.json has auto save data; consider M-x recover-this-file
3 LSP :: Yasnippet is not installed, but
lsp-enable-snippet' is set to
t'. You must either install yasnippet, or disable snippet support.2 LSP :: Connected to [json-ls:25851/starting].
1 LSP :: json-ls:25851 initialized successfully in folders: (/home/emilyseville7cfg/Documents/Mine/Shell)