nvim-lspconfig icon indicating copy to clipboard operation
nvim-lspconfig copied to clipboard

[vim.lsp.config] ast-grep is trying to get attached even if root_markers are not available

Open ahmedelgabri opened this issue 7 months ago • 3 comments

Description

By default, it has root_markers set as { 'sgconfig.yaml', 'sgconfig.yml' }

vim.lsp.enable({'ast_grep'})

When I open any file from a language that's if the filetypes list, I always get the following error.

Client ast_grep quit with exit code 2 and signal 0. Check log for errors: /Users/ahmed/.local/state/nvim/lsp.log

Looking at the logs, I see

[ERROR][2025-04-13 18:49:53] ...p/_transport.lua:36	"rpc"	"ast-grep"	"stderr"	"Error: No ast-grep project configuration is found.\nHelp: You need to create an ast-grep project for this command. Try `sg new` to create one.\nSee also: https://ast-grep.github.io/guide/scan-project.html\n\n"

But why is it trying to run if the root_markers are not available?

ahmedelgabri avatar Apr 13 '25 16:04 ahmedelgabri

I think it's because vim.lsp.config assumes "single-file support" by default. If the LS doesn't support that, then the config should specify workspace_required: https://github.com/neovim/nvim-lspconfig/pull/3716#issuecomment-2800006283

If that fixes the issue, please send a PR

justinmk avatar Apr 13 '25 21:04 justinmk

@justinmk as far as I know, workspace_required is not available in 0.11, it will be in 0.11.1 https://github.com/neovim/nvim-lspconfig/issues/3705#issuecomment-2800041732?

ahmedelgabri avatar Apr 13 '25 21:04 ahmedelgabri

yes it will be in 0.11.1

you can try out the nightly: https://github.com/neovim/neovim/releases/tag/nightly

justinmk avatar Apr 13 '25 22:04 justinmk

@justinmk Thanks for fixing this, I just upgraded and was planning to open the PR 👍🏼

ahmedelgabri avatar Apr 30 '25 13:04 ahmedelgabri