Skip to content

Commit

Permalink
plugin/emacs: add lsp-quicklintjs Emacs command
Browse files Browse the repository at this point in the history
Unlike M-x lsp, M-x lsp-quicklintjs doesn't prompt for a root folder.
It does this by always before calling (lsp) saving on its own state
file the buffer default directory as a project root.

Signed-off-by: wagner riffel <[email protected]>
  • Loading branch information
wgrr committed Aug 11, 2021
1 parent 7646781 commit 316e270
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions plugin/emacs/lsp-quicklintjs.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@
(require 'lsp-mode)
(require 'quicklintjs)

;;;###autoload
(defun lsp-quicklintjs ()
"Like `lsp', but set root folder to `default-directory' to avoid project root\
prompts."
(interactive)
;; Don't mess with user's session state file
(set (make-local-variable 'lsp-session-file)
(expand-file-name (locate-user-emacs-file
".lsp-quicklintjs-session-v1")))
(let* ((session (lsp-session)))
(cl-pushnew (expand-file-name default-directory)
(lsp-session-folders session) :test 'equal)
(lsp--persist-session session))
(lsp))

;;;###autoload
(with-eval-after-load 'lsp-mode
(lsp-register-client
Expand Down

0 comments on commit 316e270

Please sign in to comment.