LuaLS / LuaLS/lua-language-server

Formatting is not working

未关闭
#2,191 5 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Info Needed
主要语言
Lua
星标
4.4k
派生
442
PR 合并指标
30 天内没有已合并 PR

描述

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Formatting

Expected Behaviour

The document gets formatted.

Actual Behaviour

I get [LSP] Format request failed, no matching language servers. logged. Formatters for other lsps are working. :LspInfo shows lua_ls is running.

Reproduction steps
  1. I installed lua-language-server 3.6.22 via nix
  2. Here is my lspconfig:
require'lspconfig'.lua_ls.setup{
    settings = {
    Lua = {
      runtime = {
        -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
        version = 'LuaJIT',
      },
      diagnostics = {
        -- Get the language server to recognize the `vim` global
        globals = {'vim'},
      },
      workspace = {
        -- Make the server aware of Neovim runtime files
        library = vim.api.nvim_get_runtime_file("", true),
      },
      -- Do not send telemetry data containing a randomized but unique identifier
      telemetry = {
        enable = false,
      },
      format = {
        enable = true,
        defaultConfig = {
          indent_style = "tab",
        },
      },
    },
  },
}
Additional Notes

:LspInfo:

 Press q or <Esc> to close this window. Press <Tab> to view server doc.
 
 Language client log: /home/marcel/.local/state/nvim/lsp.log
 Detected filetype:   lua
 
 0 client(s) attached to this buffer: 
 
 Other clients that match the filetype: lua
 
 Config: lua_ls
 	filetypes:         lua
 	root directory:    /home/marcel/.dotfiles
 	cmd:               /nix/var/nix/profiles/default/bin/lua-language-server
 	cmd is executable: true
 	autostart:         true
 	custom handlers:   
 
 Configured servers list: phpactor, tsserver, lua_ls, ccls, elmls, rust_analyzer, pyright, vuels, texlab
Log File
[START][2023-02-22 23:00:05] LSP logging initiated
[INFO][2023-02-22 23:01:41] .../lua/vim/lsp.lua:1392    "exit_handler"  {}
[START][2023-02-22 23:01:42] LSP logging initiated
[START][2023-02-22 23:03:42] LSP logging initiated
[START][2023-02-22 23:04:00] LSP logging initiated
[START][2023-02-22 23:05:11] LSP logging initiated
[START][2023-02-22 23:06:26] LSP logging initiated

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,使用所示的 lspconfig.lua_ls.setup 配置在 NeoVim 中重现故障,然后检查 :LspInfo 以及所引用的 /home/marcel/.local/state/nvim/lsp.log。完成的标准是 Lua 缓冲区能够连接到 lua_ls,并且格式化请求成功,且不出现“no matching language servers”错误。

由索引模型根据 Issue 内容生成。

评估

技术栈
lua, neovim
领域
developer-experience, tooling
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。