[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa a7ddce6 080/139: Support javascript's javascript-t
From: |
João Távora |
Subject: |
[elpa] externals/elpa a7ddce6 080/139: Support javascript's javascript-typescript-langserver |
Date: |
Mon, 14 May 2018 09:53:40 -0400 (EDT) |
branch: externals/elpa
commit a7ddce694ac1f35c240700ff6f9edd379704feeb
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Support javascript's javascript-typescript-langserver
* README.md: Improve a bit
* eglot.el (eglot--make-process): Take MANAGED-MAJOR-MODE arg
(eglot-executables): Add basic javascript support.
(eglot--connect): Pass mode to eglot--make-process
(eglot--interactive): Check that guessed command is a listp.
(eglot): Minor improvement to message.
(eglot--current-buffer-TextDocumentItem): Guess language from mode
symbol.
---
README.md | 42 +++++++++++++++++++++++++++++++++++++-----
eglot.el | 41 +++++++++++++++++++++++------------------
2 files changed, 60 insertions(+), 23 deletions(-)
diff --git a/README.md b/README.md
index 8809421..0314664 100644
--- a/README.md
+++ b/README.md
@@ -11,14 +11,41 @@ M-x eglot
```
*That's it*. Either this guesses the local LSP program to start for
-the language of your choice or it prompts you for such a thing. You
-can also enter a `server:port` pattern to connect to an LSP server. To
-skip the guess and always be prompted use `C-u M-x eglot`.
+the language of your choice or it prompts you for such a
+thing. Currently, if you have these programs installed, it works
+out-of-the-box for:
-## Differences to lsp-mode.el
+* Javascript's [javascript-typescript-stdio][javascript-typescript-langserver]
+* Rust's [rls][rls]
+* Python's [pyls][pyls]
+
+You can also enter a `server:port` pattern to connect to an LSP
+server. To skip the guess and always be prompted use `C-u M-x eglot`.
+
+# Supported Protocol features
+
+- [x] textDocument/didChange (incremental)
+- [x] textDocument/didClose
+- [x] textDocument/didOpen
+- [x] textDocument/didSave
+
+- [ ] textDocument/codeAction
+- [ ] textDocument/completion (incl. completion/resolve)
+- [x] textDocument/definition
+- [ ] textDocument/documentHighlight
+- [ ] textDocument/documentSymbol
+- [ ] textDocument/executeCommand
+- [ ] textDocument/format
+- [ ] textDocument/hover
+- [ ] textDocument/rename
+- [x] textDocument/references
+- [ ] textDocument/signatureHelp
+- [x] workspace/symbol
+
+# Differences to lsp-mode.el
This is really beta and currently does less than
-[lsp-mode.el](https://github.com/emacs-lsp/lsp-mode) which is more
+[lsp-mode.el][emacs-lsp] which is more
mature. Though I think `eglot.el` will eventually beat it, you could
be better served with `lsp-mode.el` for now.
@@ -45,5 +72,10 @@ Differences under the hood:
tiny change.
- Its missing tests! This is *not good*
+[rls]: https://github.com/rust-lang-nursery/rls
+[pyls]: https://github.com/palantir/python-language-server
+[javascript-typescript-langserver]:
https://github.com/sourcegraph/javascript-typescript-langserver
+[emacs-lsp]: https://github.com/emacs-lsp/lsp-mode
+
diff --git a/eglot.el b/eglot.el
index cd48519..045588d 100644
--- a/eglot.el
+++ b/eglot.el
@@ -42,8 +42,10 @@
:prefix "eglot-"
:group 'applications)
-(defvar eglot-executables '((rust-mode . ("rls"))
- (python-mode . ("pyls")))
+(defvar eglot-executables
+ '((rust-mode . ("rls"))
+ (python-mode . ("pyls"))
+ (js-mode . ("javascript-typescript-stdio")))
"Alist mapping major modes to server executables.")
(defface eglot-mode-line
@@ -145,23 +147,24 @@ list of a single string of the form <host>:<port>")
(eglot--define-process-var eglot--buffer-open-count (make-hash-table)
"Keeps track of didOpen/didClose notifs for each buffer.")
-(defun eglot--make-process (name contact)
+(defun eglot--make-process (name managed-major-mode contact)
"Make a process from CONTACT.
NAME is a name to give the inferior process or connection.
+MANAGED-MAJOR-MODE is a symbol naming a major mode.
CONTACT is as `eglot--contact'. Returns a process object."
- (let* ((readable-name (format "EGLOT server (%s)" name))
+ (let* ((readable-name (format "EGLOT server (%s/%s)" name
managed-major-mode))
(buffer (get-buffer-create
(format "*%s inferior*" readable-name)))
- (singleton (and (null (cdr contact)) (car contact)))
+ singleton
(proc
- (if (and
- singleton
- (string-match "^[\s\t]*\\(.*\\):\\([[:digit:]]+\\)[\s\t]*$"
- singleton))
+ (if (and (setq singleton (and (null (cdr contact)) (car contact)))
+ (string-match "^[\s\t]*\\(.*\\):\\([[:digit:]]+\\)[\s\t]*$"
+ singleton))
(open-network-stream readable-name
buffer
(match-string 1 singleton)
- (string-to-number (match-string 2
singleton)))
+ (string-to-number
+ (match-string 2 singleton)))
(make-process
:name readable-name
:buffer buffer
@@ -236,7 +239,7 @@ CONTACT is as `eglot--contact'. Returns a process object."
short-name contact &optional success-fn)
"Connect for PROJECT, MANAGED-MAJOR-MODE, SHORT-NAME and CONTACT.
SUCCESS-FN with no args if all goes well."
- (let* ((proc (eglot--make-process short-name contact))
+ (let* ((proc (eglot--make-process short-name managed-major-mode contact))
(buffer (process-buffer proc)))
(setf (eglot--contact proc) contact
(eglot--project proc) project
@@ -297,15 +300,16 @@ SUCCESS-FN with no args if all goes well."
managed-major-mode
(let ((prompt
(cond (current-prefix-arg
- "[eglot] Execute program (or connect to <host>:<port>) ")
+ "[eglot] Enter program to execute (or <host>:<port>): ")
((null guessed-command)
(format "[eglot] Sorry, couldn't guess for `%s'!\n\
-Execute program (or connect to <host>:<port>) "
+Enter program to execute (or <host>:<port>): "
managed-major-mode)))))
(if prompt
(split-string-and-unquote
(read-shell-command prompt
- (combine-and-quote-strings guessed-command)
+ (if (listp guessed-command)
+ (combine-and-quote-strings
guessed-command))
'eglot-command-history))
guessed-command))
t)))
@@ -347,7 +351,7 @@ INTERACTIVE is t if called interactively."
command
(lambda (proc)
(eglot--message "Connected! Process `%s' now managing `%s' \
-buffers in project %s."
+buffers in project `%s'."
proc
managed-major-mode
short-name)))))))
@@ -1101,9 +1105,10 @@ running. INTERACTIVE is t if called interactively."
"Compute TextDocumentItem object for current buffer."
(append
(eglot--current-buffer-VersionedTextDocumentIdentifier)
- (eglot--obj :languageId (cdr (assoc major-mode
- '((rust-mode . rust)
- (emacs-lisp-mode . emacs-lisp))))
+ (eglot--obj :languageId
+ (if (string-match "\\(.*\\)-mode" (symbol-name major-mode))
+ (match-string 1 (symbol-name major-mode))
+ "unknown")
:text
(save-restriction
(widen)
- [elpa] externals/elpa 7d0bf64 062/139: Workaround RLS's regusal to treat nil as empty json object, (continued)
- [elpa] externals/elpa 7d0bf64 062/139: Workaround RLS's regusal to treat nil as empty json object, João Távora, 2018/05/14
- [elpa] externals/elpa e7ffc31 067/139: Make reported capabilities into its own function, João Távora, 2018/05/14
- [elpa] externals/elpa c2862f4 063/139: Don't auto-reconnect if last attempt lasted less than 3 seconds, João Távora, 2018/05/14
- [elpa] externals/elpa e86f9b4 073/139: New helper eglot--sync-request, João Távora, 2018/05/14
- [elpa] externals/elpa 95187cf 058/139: Connect to LSP server via TCP, João Távora, 2018/05/14
- [elpa] externals/elpa f8bfb7e 064/139: Handle requests from server correctly, João Távora, 2018/05/14
- [elpa] externals/elpa 8160cd4 071/139: Handle dynamic registration in general (but nothing specific yet), João Távora, 2018/05/14
- [elpa] externals/elpa 9ff97a6 079/139: Increase request timeout length to 10 seconds, João Távora, 2018/05/14
- [elpa] externals/elpa 193c57d 075/139: Half-decent xref support, João Távora, 2018/05/14
- [elpa] externals/elpa d254f97 082/139: Solve another textDocument/didChange bug, João Távora, 2018/05/14
- [elpa] externals/elpa a7ddce6 080/139: Support javascript's javascript-typescript-langserver,
João Távora <=
- [elpa] externals/elpa af14364 093/139: Only request stuff that server says it's capable of, João Távora, 2018/05/14
- [elpa] externals/elpa d33a9b5 103/139: Simplify eglot--signal-textDocument/didChange, João Távora, 2018/05/14
- [elpa] externals/elpa 56c2e1d 104/139: Get rid of eglot-mode, João Távora, 2018/05/14
- [elpa] externals/elpa bbc64b4 087/139: Clean up client capabilities, João Távora, 2018/05/14
- [elpa] externals/elpa 23b79e0 111/139: Shorten summary line to appease package-lint.el, João Távora, 2018/05/14
- [elpa] externals/elpa 24466a9 096/139: When killing server, always wait 3 seconds, João Távora, 2018/05/14
- [elpa] externals/elpa 3a6c637 099/139: Support textDocument/rename, João Távora, 2018/05/14
- [elpa] externals/elpa 458bc69 110/139: More correctly setup rust-mode-related autoloads, João Távora, 2018/05/14
- [elpa] externals/elpa 3dcbc30 109/139: Add minimal headers, commentary and autoloads, João Távora, 2018/05/14
- [elpa] externals/elpa 581608f 115/139: Resist server failure during synchronous requests, João Távora, 2018/05/14