Skip to content
This repository was archived by the owner on Jul 6, 2024. It is now read-only.

Popup every time asking about Request Actions #88

Closed
zdcthomas opened this issue Nov 14, 2022 · 9 comments
Closed

Popup every time asking about Request Actions #88

zdcthomas opened this issue Nov 14, 2022 · 9 comments

Comments

@zdcthomas
Copy link

With the default config from the README, I get

Request Actions:
1. Apply and modify settings
2. Apply but do not modify settings
3. Don't show again
Type number and <Enter> or click with the mouse (q or empty cancels):

This message every time I load a lua file in my nvim config. No matter what I select, the popup continues to happen. It goes away once I remove the neodev setup call and just have the lspconfig setup.

I've tried adding the checkThirdParty = false field in the workpace field in the lspconfig setup call, but it makes no difference. Am I doing something wrong?

Thanks for the plugin and all the hard work! Sorry If i missed something dumb!

@folke
Copy link
Owner

folke commented Nov 14, 2022

You can set Lua.workspace.checkThirdParty = false

@folke
Copy link
Owner

folke commented Nov 14, 2022

You;re probably setting it worng. What does your lspconfig look like?

@zdcthomas
Copy link
Author

	-- IMPORTANT: make sure to setup neodev BEFORE lspconfig
	require("neodev").setup({
		-- add any options here, or leave empty to use the default settings
	})

	-- then setup your lsp server as usual
	local lspconfig = require("lspconfig")

	-- example to setup sumneko and enable call snippets
	lspconfig.sumneko_lua.setup({
		settings = {
			Lua = {
				workspace = {
					checkThirdParty = false,
				},
				completion = {
					callSnippet = "Replace",
				},
			},
		},
	})

@zdcthomas
Copy link
Author

Thanks for the fast reply btw!

@folke
Copy link
Owner

folke commented Nov 14, 2022

that looks right to me. It's exactly the same as I set it. Do you also have a .luarc.json file maybe?

@zdcthomas
Copy link
Author

Oh! I realized what the issue was, I was setting it wrong! Super sorry for not doing my due diligence!

@zdcthomas
Copy link
Author

For anyone that finds this in the future, setting it as shown above works fine. My issue was unrelated in my config, writing over that configuration.

@folke
Copy link
Owner

folke commented Nov 14, 2022

Glad you got it fixed!

@d-r-a-b
Copy link

d-r-a-b commented Apr 4, 2023

Spent a couple hours running up against an issue with this behavior and wanted to post a specific example of how cmp-nvim-lsp and neodev.nvim can easily be misconfigured if you are just getting into the plugin game and trying to follow along with the instructions. Hopefully it helps someone else avoid this.

In my case, it wasn't really the order of plugins loading, but that I called lspconfig.setup a second time when I loaded nvim-cmp later in my setup.

My config goal was nvim-cmp and cmp-nvim-lsp working with neodev.nvim and a lazy.nvim spec that reproduces the Request Action behavior is below (assumes lua-language-server is installed).

Click to expand the spec that reproduces this issue
    spec={
        {
            "neovim/nvim-lspconfig",
            event = { "BufReadPre", "BufNewFile" },
            dependencies = {
                { "folke/neodev.nvim",opts={} }
            },
            config = function()
                ---@diagnostic disable-next-line: missing-parameter
                local runtime_path = vim.split(package.path, ";")
                table.insert(runtime_path, "lua/?.lua")
                table.insert(runtime_path, "lua/?/init.lua")

                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',
                                path = runtime_path,
                            },
                            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),
                                checkThirdParty = false,
                            },
                            -- Do not send telemetry data containing a randomized but unique identifier
                            telemetry = {
                                enable = false,
                            },
                            completion = {
                                callSnippet = "Replace",
                            },
                        },
                    },
                })
            end
        },
        {
            "hrsh7th/nvim-cmp",
            event = "VeryLazy",
            dependencies = {
                'hrsh7th/cmp-nvim-lsp', -- no setup()
                'hrsh7th/cmp-buffer', -- no setup()
                'hrsh7th/cmp-path', -- no setup()
                'hrsh7th/cmp-cmdline', -- no setup()
            },
            config = function()
                local cmp = require'cmp'
                -- without noselect, nvim-cmp breaks C-X_C-L and C-X_C-P completion.
                -- See issue #1326 in hrsh7th/nvim-cmp github
                vim.opt.completeopt = 'menu,menuone,noselect'

                -- Global setup.
                cmp.setup({
                    mapping = cmp.mapping.preset.insert({
                        ['<C-d>'] = cmp.mapping.scroll_docs(-4),
                        ['<C-f>'] = cmp.mapping.scroll_docs(4),
                        ['<C-Space>'] = cmp.mapping.complete(),
                        ['<CR>'] = cmp.mapping.confirm({ select = false }),  -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
                    }),
                    sources = cmp.config.sources(
                    {
                        { name = 'nvim_lsp' },
                        { name = 'luasnip' }, -- For luasnip users.
                    },
                    {
                        { name = 'buffer' },
                    }
                    )
                })
                -- `/` cmdline setup.
                cmp.setup.cmdline('/', {
                    mapping = cmp.mapping.preset.cmdline(),
                    sources = {
                        { name = 'buffer' }
                    }
                })

                -- `:` cmdline setup.
                cmp.setup.cmdline(':', {
                    mapping = cmp.mapping.preset.cmdline(),
                    sources = cmp.config.sources({
                        { name = 'path' }
                    }, {
                        { name = 'cmdline' , keyword_pattern=[=[[^[:blank:]\!]*]=] }
                    })
                })

                -- Setup lspconfig.
                local capabilities = require('cmp_nvim_lsp').default_capabilities()
                require('lspconfig')["lua_ls"].setup {
                    capabilities = capabilities
                }
            end,
        },
    },

:Lazy profile showed that neodev was loading before lspconfig so the load order looked fine. nvim-cmp was loading after both of these as well, so even though I was basing my config on the tiny snippet at hrsh7th/cmp-nvim-lsp to set capabilities using lspconfig, I thought it was probably fine.

Reader, it was not fine. Notice that there are 2 require'lspconfig's going on, one in the spec for neovim/nvim-lspconfig and one in the spec for hrsh7th/nvim-cmp. This results in 2 behaviors.

  1. :Lazy profile doesn't show that you are loading lspconfig when you load nvim-cmp with that require statement, but of course you actually are. In my case, it didn't affect order, but it's a subtle misconfiguration that :Lazy profile won't reveal in the ordering. To see this, remove the event key from the nvim-cmp block and replace it with lazy=false, then run :Lazy profile.
  2. A second requirelspconfig.setup messes something up and you get the same Request Actions bug. lspconfig.setup also has replace semantics on subsequent calls, not merge semantics, so in my case it was also erasing any of the settings I made in the first lspconfig.setup call.

To fix

  • add hrsh7th/cmp-nvim-lsp in the dependencies for neovim/nvim-lspconfig
  • remove the lspconfig.setup that was only adding capabilities from the nvim-cmp spec
  • set capabilities in the config function in the lspconfig spec instead

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants