williamboman / mason-lspconfig.nvim

Extension to mason.nvim that makes it easier to use lspconfig with mason.nvim.
Apache License 2.0
2.87k stars 174 forks source link

bufls is deprecated, use buf_ls instead #488

Open fira42073 opened 1 week ago

fira42073 commented 1 week ago

First of all, thanks for this great project <3

Problem description

bufls is deprecated, use buf_ls instead. Feature will be removed in lspconfig 0.2.1

mason does not support buf_ls

Why do you think this is an issue with mason-lspconfig.nvim?

new change?

Neovim version (>= 0.7)

NVIM v0.10.1 Build type: RelWithDebInfo LuaJIT 2.1.1720049189 Run "nvim -V1 -v" for more info

Operating system/version

Linux fedorapc 6.10.12-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Sep 30 21:38:25 UTC 2024 x86_64 GNU/Linux

I've manually reviewed the Nvim LPS client log (:LspLog) to find potential errors

I've recently downloaded the latest plugin version of mason.nvim, mason-lspconfig.nvim, and nvim-lspconfig

Affected language servers

bufls/buf_ls

Steps to reproduce

require("mason").setup({})
require("mason-lspconfig").setup({
            ensure_installed = {
                    "bufls",
                },
    handlers = {
        default_setup,
    },
})

Actual behavior

Not relevant

Expected behavior

Not relevant

LspInfo

==============================================================================
lspconfig: require("lspconfig.health").check()

LSP configs active in this session (globally) ~
- Configured servers: clangd, ts_ls, pylsp, golangci_lint_ls, terraformls, gitlab_ci_ls, jsonls, lua_ls, gopls, buf_ls
- WARNING Deprecated servers: bufls -> buf_ls

LSP configs active in this buffer (bufnr: 1) ~
- Language client log: ~/.local/state/nvim/lsp.log
- Detected filetype: `alpha`
- 0 client(s) attached to this buffer
- 1 active client(s) not attached to this buffer:
- Client: `copilot` (id: 1, bufnr: [])
  root directory:    ~/Documents/fira-vault/
  filetypes:         
  cmd:               ~/Documents/fira-vault/node /home/fira/.local/share/nvim/site/pack/packer/start/copilot.lua/copilot/index.js
  version:           `v20.17.0`
  executable:        true
  autostart:         false

Docs for active configs: ~

LspLog

No response

Healthcheck

==============================================================================
mason: require("mason.health").check()

mason.nvim ~
- OK mason.nvim version v1.10.0
- OK PATH: prepend
- OK Providers: 
    mason.providers.registry-api
    mason.providers.client
- OK neovim version >= 0.7.0

mason.nvim [Registries] ~
- OK Registry `github.com/mason-org/mason-registry version: 2024-11-12-clear-north` is installed.

mason.nvim [Core utils] ~
- OK unzip: `UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send`
- OK wget: `GNU Wget2 2.1.0 - multithreaded metalink/file/website downloader`
- OK curl: `curl 8.6.0 (x86_64-redhat-linux-gnu) libcurl/8.6.0 OpenSSL/3.2.2 zlib/1.3.1.zlib-ng libidn2/2.3.7 nghttp2/1.59.0`
- OK gzip: `gzip 1.13`
- OK gtar: `tar (GNU tar) 1.35`
- OK bash: `GNU bash, version 5.2.26(1)-release (x86_64-redhat-linux-gnu)`
- OK sh: `Ok`

mason.nvim [Languages] ~
- WARNING Ruby: not available
  - ADVICE:
    - spawn: ruby failed with exit code - and signal -. ruby is not executable
- WARNING Composer: not available
  - ADVICE:
    - spawn: composer failed with exit code - and signal -. composer is not executable
- WARNING PHP: not available
  - ADVICE:
    - spawn: php failed with exit code - and signal -. php is not executable
- WARNING RubyGem: not available
  - ADVICE:
    - spawn: gem failed with exit code - and signal -. gem is not executable
- OK Go: `go version go1.23.1 linux/amd64`
- OK node: `v20.17.0`
- OK cargo: `cargo 1.80.1 (376290515 2024-07-16)`
- WARNING julia: not available
  - ADVICE:
    - spawn: julia failed with exit code - and signal -. julia is not executable
- OK luarocks: `/usr/bin/luarocks 3.9.2`
- OK java: `openjdk version "21.0.4" 2024-07-16`
- OK python: `Python 3.12.6`
- OK javac: `javac 11.0.24`
- OK npm: `10.8.2`
- OK pip: `pip 23.3.2 from /usr/lib/python3.12/site-packages/pip (python 3.12)`
- OK python venv: `Ok`

mason.nvim [GitHub] ~
- OK GitHub API rate limit. Used: 0. Remaining: 60. Limit: 60. Reset: Wed 13 Nov 2024 01:03:59 AM CET.
  Install and authenticate via gh-cli to increase rate limit.

Screenshots or recordings

No response

fira42073 commented 1 week ago

not sure if that was the right label, please feel free to fix it

fira42073 commented 1 week ago

as far as I understand, we will need something like

this in registry

---
name: buf-ls
description: |
  buf cli tool's builtin lsp server.
homepage: https://github.com/bufbuild/buf
licenses: [Apache-2.0]
languages: [Protobuf]
categories: [LSP]
source:
  id: pkg:golang/github.com/bufbuild/buf@v1.46.0#cmd/buf
bin:
  buf: golang:buf

Also perhaps update to add buf_ls, so that it's aligned with lspconfig https://github.com/williamboman/mason-lspconfig.nvim/blob/main/lua/mason-lspconfig/mappings/filetype.lua#L157

fira42073 commented 1 week ago

This may be a different issue, may be related, I'm not sure, but Even if that worked, clangd tries to do something and that yields this error in lsp log

[START][2024-11-13 01:55:06] LSP logging initiated
[ERROR][2024-11-13 01:55:06] .../vim/lsp/rpc.lua:770    "rpc"   "/home/fira/.local/share/nvim/mason/bin/clangd" "stderr"    "I[01:55:06.988] clangd version 19.1.0 (https://github.com/llvm/llvm-project a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)\nI[01:55:06.988] Features: linux+grpc\nI[01:55:06.988] PID: 2055070\nI[01:55:06.988] Working directory: /home/fira/Projects/xxx\nI[01:55:06.988] argv[0]: /home/fira/.local/share/nvim/mason/bin/clangd\nI[01:55:06.988] Starting LSP over stdin/stdout\nI[01:55:06.988] <-- initialize(1)\nI[01:55:06.989] --> reply:initialize(1) 0 ms\n"
[ERROR][2024-11-13 01:55:07] .../vim/lsp/rpc.lua:770    "rpc"   "/home/fira/.local/share/nvim/mason/bin/clangd" "stderr"    "I[01:55:07.032] <-- initialized\nI[01:55:07.032] <-- textDocument/didOpen\nI[01:55:07.032] Failed to find compilation database for /home/fira/Projects/xxx/xxx.proto\nI[01:55:07.032] ASTWorker building file /home/fira/Projects//xxx/xxx.proto version 0 with command clangd fallback\n[/home/fira/Projects/xxx]\n/usr/bin/clang -resource-dir=/home/fira/.local/share/nvim/mason/packages/clangd/clangd_19.1.0/lib/clang/19 -- /home/fira/Projects/xxx/xxx.proto\nE[01:55:07.033] Could not build CompilerInvocation for file /home/fira/Projects/xxx/xxx.proto\nI[01:55:07.033] --> textDocument/publishDiagnostics\nI[01:55:07.033] <-- textDocument/inlayHint(2)\nI[01:55:07.033] --> reply:textDocument/inlayHint(2) 0 ms, error: invalid AST\nI[01:55:07.038] <-- textDocument/documentSymbol(3)\nI[01:55:07.038] --> reply:textDocument/documentSymbol(3) 0 ms, error: invalid AST\nI[01:55:07.038] <-- textDocument/documentSymbol(4)\nI[01:55:07.038] --> reply:textDocument/documentSymbol(4) 0 ms, error: invalid AST\n"
[ERROR][2024-11-13 01:55:07] .../vim/lsp/rpc.lua:770    "rpc"   "/home/fira/.local/share/nvim/mason/bin/clangd" "stderr"    "I[01:55:07.046] <-- textDocument/inlayHint(5)\nI[01:55:07.046] --> reply:textDocument/inlayHint(5) 0 ms, error: invalid AST\n"
[ERROR][2024-11-13 01:55:07] .../vim/lsp/rpc.lua:770    "rpc"   "/home/fira/.local/share/nvim/mason/bin/clangd" "stderr"    "I[01:55:07.048] <-- textDocument/semanticTokens/full(6)\nI[01:55:07.048] --> reply:textDocument/semanticTokens/full(6) 0 ms, error: invalid AST\n"
[ERROR][2024-11-13 01:55:07] .../vim/lsp/rpc.lua:770    "rpc"   "/home/fira/.local/share/nvim/mason/bin/clangd" "stderr"    "I[01:55:07.334] <-- textDocument/documentHighlight(7)\nI[01:55:07.334] --> reply:textDocument/documentHighlight(7) 0 ms, error: invalid AST\n"
[ERROR][2024-11-13 01:55:07] .../vim/lsp/rpc.lua:770    "rpc"   "/home/fira/.local/share/nvim/mason/bin/clangd" "stderr"    "I[01:55:07.543] <-- textDocument/inlayHint(8)\nI[01:55:07.543] --> reply:textDocument/inlayHint(8) 0 ms, error: invalid AST\n"
[WARN][2024-11-13 01:55:08] ...lsp/handlers.lua:625 "[certificates] Failed to parse certificate # ACCVRAIZ1\n Error: error:0480006C:PEM routines::no start line\n    at new X509Certificate (node:internal/crypto/x509:119:21)\n    at /home/fira/.local/share/nvim/site/pack/packer/start/copilot.lua/copilot/lib/src/network/certificateReaders.ts:79:36\n    at Array.filter (<anonymous>)\n    at Cle.removeExpiredCertificates (/home/fira/.local/share/nvim/site/pack/packer/start/copilot.lua/copilot/lib/src/network/certificateReaders.ts:77:32)\n    at Cle.getAllRootCAs (/home/fira/.local/share/nvim/site/pack/packer/start/copilot.lua/copilot/lib/src/network/certificateReaders.ts:68:38)\n    at Rge.createSecureContext (/home/fira/.local/share/nvim/site/pack/packer/start/copilot.lua/copilot/lib/src/network/certificates.ts:46:23) {\n  opensslErrorStack: [\n    'error:0688010A:asn1 encoding routines::nested asn1 error',\n    'error:06800066:asn1 encoding routines::bad object header',\n    'error:0680009B:asn1 encoding routines::too long'\n  ],\n  library: 'PEM routines',\n  reason: 'no start line',\n  code: 'ERR_OSSL_PEM_NO_START_LINE'\n}"
[WARN][2024-11-13 01:55:08] ...lsp/handlers.lua:625 "[certificates] Failed to parse certificate # ACCVRAIZ1\n Error: error:0480006C:PEM routines::no start line\n    at new X509Certificate (node:internal/crypto/x509:119:21)\n    at /home/fira/.local/share/nvim/site/pack/packer/start/copilot.lua/copilot/lib/src/network/certificateReaders.ts:79:36\n    at Array.filter (<anonymous>)\n    at Cle.removeExpiredCertificates (/home/fira/.local/share/nvim/site/pack/packer/start/copilot.lua/copilot/lib/src/network/certificateReaders.ts:77:32)\n    at Cle.getAllRootCAs (/home/fira/.local/share/nvim/site/pack/packer/start/copilot.lua/copilot/lib/src/network/certificateReaders.ts:68:38)\n    at Rge.createSecureContext (/home/fira/.local/share/nvim/site/pack/packer/start/copilot.lua/copilot/lib/src/network/certificates.ts:46:23) {\n  opensslErrorStack: [\n    'error:0688010A:asn1 encoding routines::nested asn1 error',\n    'error:06800066:asn1 encoding routines::bad object header',\n    'error:0680009B:asn1 encoding routines::too long'\n  ],\n  library: 'PEM routines',\n  reason: 'no start line',\n  code: 'ERR_OSSL_PEM_NO_START_LINE'\n}"
[ERROR][2024-11-13 01:55:08] .../vim/lsp/rpc.lua:770    "rpc"   "/home/fira/.local/share/nvim/mason/bin/clangd" "stderr"    "I[01:55:08.584] <-- textDocument/documentHighlight(9)\nI[01:55:08.584] --> reply:textDocument/documentHighlight(9) 0 ms, error: invalid AST\n"
[ERROR][2024-11-13 01:55:09] .../vim/lsp/rpc.lua:770    "rpc"   "/home/fira/.local/share/nvim/mason/bin/clangd" "stderr"    "I[01:55:09.051] <-- textDocument/documentHighlight(10)\n"
[ERROR][2024-11-13 01:55:09] .../vim/lsp/rpc.lua:770    "rpc"   "/home/fira/.local/share/nvim/mason/bin/clangd" "stderr"    "I[01:55:09.051] --> reply:textDocument/documentHighlight(10) 0 ms, error: invalid AST\n"
[ERROR][2024-11-13 01:55:10] .../vim/lsp/rpc.lua:770    "rpc"   "/home/fira/.local/share/nvim/mason/bin/clangd" "stderr"    "I[01:55:10.371] <-- textDocument/documentHighlight(11)\nI[01:55:10.371] --> reply:textDocument/documentHighlight(11) 0 ms, error: invalid AST\n"

LspInfo

==============================================================================
lspconfig: require("lspconfig.health").check()

LSP configs active in this session (globally) ~
- Configured servers: clangd, ts_ls, pylsp, golangci_lint_ls, terraformls, gitlab_ci_ls, jsonls, gopls, lua_ls
- OK Deprecated servers: (none)

LSP configs active in this buffer (bufnr: 1) ~
- Language client log: ~/.local/state/nvim/lsp.log
- Detected filetype: `proto`
- 2 client(s) attached to this buffer
- Client: `copilot` (id: 1, bufnr: [1])
  root directory:    ~/Projects/xxx/
  filetypes:         
  cmd:               ~/Projects/xxx/node /home/fira/.local/share/nvim/site/pack/packer/start/copilot.lua/copilot/index.js
  version:           `v20.17.0`
  executable:        true
  autostart:         false
- Client: `clangd` (id: 2, bufnr: [1])
  root directory:    ~/Projects/xxx/
  filetypes:         c, cpp, objc, objcpp, cuda, hpp
  cmd:               ~/.local/share/nvim/mason/bin/clangd
  version:           `clangd version 19.1.0 (https://github.com/llvm/llvm-project a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)`
  executable:        true
  autostart:         true
fira42073 commented 1 week ago

Also, no clue how to change the filetype association.

require("mason-lspconfig").setup_handlers({
    function(server_name)
        if server_name == "clangd" then
            require("lspconfig")[server_name].setup({
                capabilities = lsp_capabilities,
                filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "hpp" },
            })
        end
    end,
})

I tried this.

Also googled and found this stuff, but it didn't help, it just overrides it on start and lsplog shows proto filetype for clangd.

https://www.reddit.com/r/neovim/comments/15s54hf/how_to_add_a_file_type_to_a_language_server/

https://github.com/LazyVim/LazyVim/discussions/3997

bqv commented 1 day ago

Is there a workaround?