[emacs] eglot instead of tide
This commit is contained in:
parent
0bd50328f5
commit
124575531a
1 changed files with 34 additions and 26 deletions
|
|
@ -362,7 +362,7 @@
|
||||||
(use-package company :ensure t
|
(use-package company :ensure t
|
||||||
:commands company-mode
|
:commands company-mode
|
||||||
:init
|
:init
|
||||||
;; 2023-08-26: Enable comapny mode globally.
|
;; 2023-08-26: Enable company mode globally.
|
||||||
(global-company-mode t)
|
(global-company-mode t)
|
||||||
:config
|
:config
|
||||||
;; 2023-08-26: Enable comapny mode globally.
|
;; 2023-08-26: Enable comapny mode globally.
|
||||||
|
|
@ -402,16 +402,24 @@
|
||||||
(eq major-mode 'c-mode))
|
(eq major-mode 'c-mode))
|
||||||
(eglot-signal-didChangeConfiguration server)))
|
(eglot-signal-didChangeConfiguration server)))
|
||||||
|
|
||||||
|
(defun ts/server-program (interactive)
|
||||||
|
"Choose which server program to run."
|
||||||
|
(cond ((ts/is-deno-project) '("deno" "lsp" :initializationOptions :enable t :lint t))
|
||||||
|
(t '("typescript-language-server" "--stdio"))))
|
||||||
|
|
||||||
|
|
||||||
(use-package eglot :ensure
|
(use-package eglot :ensure
|
||||||
:commands (eglot-ensure eglot)
|
:commands (eglot-ensure eglot)
|
||||||
:hook
|
:hook
|
||||||
(python-mode . eglot-ensure)
|
(python-mode . eglot-ensure)
|
||||||
(rust-mode . eglot-ensure)
|
(rust-mode . eglot-ensure)
|
||||||
(rust-ts-mode . eglot-ensure) ;; 2023-08-26 Add eglot for tree-sitter rust?
|
(rust-ts-mode . eglot-ensure) ;; 2023-08-26 Add eglot for tree-sitter rust?
|
||||||
(c++-mode . eglot-ensure)
|
(c++-mode . eglot-ensure)
|
||||||
(c-mode . eglot-ensure)
|
(c-mode . eglot-ensure)
|
||||||
(go-mode . eglot-ensure) ;; 2022-07-29 Add eglot for go
|
(go-mode . eglot-ensure) ;; 2022-07-29 Add eglot for go
|
||||||
(before-save . eglot-format) ;; 2023-05-25 Format buffers on save
|
(before-save . eglot-format) ;; 2023-05-25 Format buffers on save
|
||||||
|
(typescript-mode . eglot-ensure) ;; 2023-09-03 Eglot for typescript
|
||||||
|
(typescript-ts-mode . eglot-ensure) ;; 2023-09-03 Eglot for typescript
|
||||||
:bind
|
:bind
|
||||||
("C-c r" . eglot-rename) ;; 2022-08-23 Make rename more accessible
|
("C-c r" . eglot-rename) ;; 2022-08-23 Make rename more accessible
|
||||||
("C-c \\" . eglot-code-actions) ;; 2022-07-29 I want to make code actions easier.
|
("C-c \\" . eglot-code-actions) ;; 2022-07-29 I want to make code actions easier.
|
||||||
|
|
@ -431,13 +439,9 @@
|
||||||
;; (add-to-list 'eglot-server-programs
|
;; (add-to-list 'eglot-server-programs
|
||||||
;; `(python-mode . (,py-executable)))))
|
;; `(python-mode . (,py-executable)))))
|
||||||
|
|
||||||
;; 2022-04-28 Configuration for Deno.
|
;; 2023-09-03 Re-work the way that the JS/Deno switch is handled.
|
||||||
(defclass eglot-deno (eglot-lsp-server) ()
|
|
||||||
:documentation "A custom class for deno lsp.")
|
|
||||||
(cl-defmethod eglot-initialization-options ((server eglot-deno))
|
|
||||||
(list :enable t :lint t))
|
|
||||||
(add-to-list 'eglot-server-programs
|
(add-to-list 'eglot-server-programs
|
||||||
'((js-mode typescript-mode) . (eglot-deno "deno" "lsp")))
|
'((js-mode typescript-mode) . ts/server-program))
|
||||||
;; --
|
;; --
|
||||||
|
|
||||||
(add-hook 'eglot-managed-mode-hook 'my-disable-flycheck-on-eglot)
|
(add-hook 'eglot-managed-mode-hook 'my-disable-flycheck-on-eglot)
|
||||||
|
|
@ -950,20 +954,23 @@ Or, uh, Objective C, I guess."
|
||||||
"Return non-nil if this is a deno project, otherwise nil."
|
"Return non-nil if this is a deno project, otherwise nil."
|
||||||
(locate-dominating-file (buffer-file-name) ".deno"))
|
(locate-dominating-file (buffer-file-name) ".deno"))
|
||||||
|
|
||||||
(defun ts/enable-eglot-or-tide ()
|
;; 2023-09-03 Trying eglot instead of TIDE for now.
|
||||||
"Enable eglot if this is a deno project, otherwise enable tide."
|
;; (defun ts/enable-eglot-or-tide ()
|
||||||
(if (ts/is-deno-project)
|
;; "Enable eglot if this is a deno project, otherwise enable tide."
|
||||||
(eglot-ensure)
|
;; (if (ts/is-deno-project)
|
||||||
|
;; (eglot-ensure)
|
||||||
|
|
||||||
;; Not a deno project; just enable tide and the normal
|
;; ;; Not a deno project; just enable tide and the normal
|
||||||
(tide-setup)
|
;; (tide-setup)
|
||||||
(flycheck-mode +1)
|
;; (flycheck-mode +1)
|
||||||
(tide-hl-identifier-mode)
|
;; (tide-hl-identifier-mode)
|
||||||
(eldoc-mode +1)))
|
;; (eldoc-mode +1)))
|
||||||
|
|
||||||
(use-package typescript-mode :ensure t
|
(use-package typescript-mode :ensure t
|
||||||
:config
|
;; 2023-09-03 Trying eglot instead of TIDE for now.
|
||||||
(add-hook 'typescript-mode-hook 'ts/enable-eglot-or-tide))
|
;; :config
|
||||||
|
;; (add-hook 'typescript-mode-hook 'ts/enable-eglot-or-tide)
|
||||||
|
)
|
||||||
|
|
||||||
(use-package add-node-modules-path :ensure t
|
(use-package add-node-modules-path :ensure t
|
||||||
:hook typescript-mode)
|
:hook typescript-mode)
|
||||||
|
|
@ -971,7 +978,8 @@ Or, uh, Objective C, I guess."
|
||||||
(use-package prettier-js :ensure t
|
(use-package prettier-js :ensure t
|
||||||
:hook (typescript-mode . prettier-js-mode))
|
:hook (typescript-mode . prettier-js-mode))
|
||||||
|
|
||||||
(use-package tide :ensure t)
|
;; 2023-09-03 Trying eglot instead of TIDE for now.
|
||||||
|
;; (use-package tide :ensure t)
|
||||||
|
|
||||||
;; =================================================================
|
;; =================================================================
|
||||||
;; Archive mode for appx
|
;; Archive mode for appx
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue