Replies: 1 comment 3 replies
-
This gets weirder by the minute. I understand so far:
(define-derived-mode hk-typescript-mode prog-mode "HK-TS" ()
"Marks a file as typescript to get eglot going."
)
...
(add-to-list
'eglot-server-programs
`(hk-typescript-mode
"typescript-language-server" "--stdio"
:initializationOptions
(:tsserver (:path "./node_modules/typescript/lib/tsserver.js")))) Further I have (with-eval-after-load 'eglot
(define-key eglot-mode-map (kbd "M-Q") 'eglot-format-buffer)
(define-key eglot-mode-map (kbd "M-/") 'company-complete)
(define-key eglot-mode-map (kbd "C-\\") 'eglot-code-actions)
... and this starts to work. I don't get syntax highlighting yet (and get the impression it is not supported??) and there may be other things missing. But my assumption seems to be correct: if I can convince eglot to take over with a major-mode->language-server mapping and wire my preferred key-bindings, things get going. No other make-shift (sorry) language parsing necessary. And really, this is exactly how things should work and I am really happy with this slick and clean approach: the language server knows the language and the editor does the editing. Let me know if I am missing something important that tree-sitter and/or those parsers for it would add. |
Beta Was this translation helpful? Give feedback.
-
Eglot relies on
eglot-server-programs
to trigger a server based on language mode. There istypescript-mode
,js-ts-mode
,typescript-ts-mode
and more. Yet when I try to figure out which packages provide these modes, I find packages providding "language parsing" features (treesitter, tide), while I thought the language parsing is left to the language server.Is there a "canonical" typescript mode meanwhile or am I misunderstanding this. At least quite some people seem to combine treesitter with eglot. Would it work to use a completely empty
my-ts-mode
(I should really try this soon :-) and trigger the language server?Beta Was this translation helpful? Give feedback.
All reactions