doom emacs LSP Lua-mode

配置了 lang: (lua + lsp)

并且参照 lsp-lua-language-server

启动了server 随便打开一个lua

我裂开了。。到底怎么玩。。难受~ lsp-log 都没有打开

1赞

你更新一下lsp-mode,我这两天刚加了下载lua-language-sever的功能,打开后按提示确认下载就行了。

我用的doom 好像包都是锁版本的 要怎么更新呀

doom不熟悉啊…看看可有熟悉的人能帮上忙。

好的 感谢~ https://github.com/hlissner/doom-emacs/tree/develop/modules/tools/lsp

看起来好像不支持

我之前用 doom 的时候,记得有个自定义的函数叫 unpin,你可以搜一下看看。

如果没有安装lua lsp server , 你需要安装一个。

lsp-mode 支持3个server, 我贴一下我使用得比较多的sumneko/lua-language-server 吧。

参考repo 文档编译安装: https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone)

为了通用(比如我可以多个编辑器共用这个lsp binary), 我一般是安装到:

~/.local/share/lua-language-server/

# clone project
git clone https://github.com/sumneko/lua-language-server ~/.local/share/lua-language-server
cd ~/.local/share/lua-language-server
git submodule update --init --recursive


cd 3rd/luamake
ninja -f ninja/linux.ninja
cd ../..
./3rd/luamake/luamake rebuild

然后在config.el 中配置好:

;; https://emacs-lsp.github.io/lsp-mode/page/performance/
(after! lsp-mode
(setq lsp-log-io nil) ; if set to true can cause a performance hit
(setq lsp-print-performance t)
(setq lsp-auto-guess-root t) ; auto detect workspace and start lang server

;; lua
;; https://emacs-lsp.github.io/lsp-mode/page/lsp-lua-language-server/
(setq lsp-clients-lua-language-server-install-dir (f-join (getenv "HOME") ".local/share/lua-language-server/"); Default: ~/.emacs.d/.cache/lsp/lua-language-server/
        lsp-clients-lua-language-server-bin (f-join lsp-clients-lua-language-server-install-dir "bin/Linux/lua-language-server")
        lsp-clients-lua-language-server-main-location (f-join lsp-clients-lua-language-server-install-dir "main.lua")
        lsp-lua-workspace-max-preload 2048 ; Default: 300, Max preloaded files
        lsp-lua-workspace-preload-file-size 1024; Default: 100, Skip files larger than this value (KB) when preloading.
        )

相关配置项: https://emacs-lsp.github.io/lsp-mode/page/lsp-lua-language-server/

现在doom可以自动下载lua-language-server了 但是貌似解压有问题

LSP :: Download lua-language-server started.
LSP :: Starting to download https://marketplace.visualstudio.com/_apis/public/gallery/publishers/sumneko/vsextensions/lua/1.17.4/vspackage to /Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/vs-lua.zip...
Contacting host: marketplace.visualstudio.com:443
Wrote /Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/vs-lua.zip
LSP :: Finished downloading /Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/vs-lua.zip...
LSP :: Decompressing /Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/vs-lua.zip...
[/Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/vs-lua.zip]
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of /Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/vs-lua.zip or
        /Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/vs-lua.zip.zip, and cannot find /Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/vs-lua.zip.ZIP, period.
LSP :: Decompressed /Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/vs-lua...
LSP :: Server lua-language-server install process failed with the following error message: (file-missing Doing chmod No such file or directory /Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/bin/macOS).
Check `*lsp-install*' and `*lsp-log*' buffer.

然后我手动下载 解压 放在了 /Users/donney/.emacs.d/.local/etc/lsp/lua-language-server/bin/macOS 下面 重启 还是提示我没有 让我下载 吐了

找到lsp-lua.el,将里面的(lsp-vscode-extension-url “sumneko” “lua” “1.17.4”)改成1.20.1试试.

doom貌似改不了 全编译成elc了