Hi Zig enthusiasts and experts,
Does anyone could kindly share working emacs eglot + zls config snippets? And also hints how to tweak it to work greatly?
Thank you very much in advance!
Cheers,
Pawel
Hi Zig enthusiasts and experts,
Does anyone could kindly share working emacs eglot + zls config snippets? And also hints how to tweak it to work greatly?
Thank you very much in advance!
Cheers,
Pawel
I can’t help on eglot, but I installed ziglang/zig-mode: Zig mode for Emacs. - Codeberg.org and the added the snippet below to my init.el to invoke lsp-mode when I edit zig files.
(use-package lsp-mode
:init
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "C-c l")
:hook (
(zig-mode . lsp)
;; if you want which-key integration
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp)
Since emacs 29 eglot is included in its core.
All you have to do is to install zig-mode and start eglot.
M-x package-install RET zig-mode RETM-x eglot RET (you must be able to see the argument names in the function calls and the types with gray colors).Documentation for zls setup for emacs: GNU Emacs - zigtools
(use-package zig-mode
:config
;; these are the defaults
(setq zig-indent-offset 4)
(setq zig-format-on-save t)
(setq zig-run-optimization-mode “Debug”)
:ensure t)
(use-package eglot
:init
(setq read-process-output-max (* 1024 1024))
(add-hook 'zig-mode-hook 'eglot-ensure)
:config
(setq eglot-autoshutdown t)
(setq eglot-ignored-server-capabilities '(:inlayHintProvider))
:ensure t)