nvim-lspconfig
nvim-lspconfig copied to clipboard
[vim.lsp.config] ast-grep is trying to get attached even if root_markers are not available
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?
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 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?
yes it will be in 0.11.1
you can try out the nightly: https://github.com/neovim/neovim/releases/tag/nightly
@justinmk Thanks for fixing this, I just upgraded and was planning to open the PR 👍🏼