Chaitanyabsprip / fastaction.nvim

Efficiency plugin designed to optimize code actions in Neovim
MIT License
90 stars 7 forks source link

Get "no code actions available" even if code actions are available with `vim.lsp.buf.code_action` #22

Open galou opened 4 days ago

galou commented 4 days ago

fastaction doesn't list code actions that vim.lsp.buf.code_action proposes.

Config, in lazy: {'Chaitanyabsprip/fastaction.nvim'}, in lua/bindings.lua:

local opts = {noremap = true, silent = true}
local fastaction = require('fastaction')
vim.keymap.set('n', '<leader>fa', fastaction.code_action, opts)
vim.keymap.set('v', '<leader>fa', fastaction.range_code_action, opts

I get no code actions available.

NVIM v0.11.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.1703358377

Chaitanyabsprip commented 3 days ago

Can you please share a sample project where I can reproduce this behavior?

kanium3 commented 1 day ago

I had the same issue with my Neovim. I don't know if it will be helpful, but I've attached a minimal configuration file.

Version

NVIM v0.10.2 Build type: RelWithDebInfo LuaJIT 2.1.1731601260

Reproduction

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
vim.g.mapleader = " " -- leaderkey is <space>

require("lazy.minit").repro({
    spec = {
        {
            "Chaitanyabsprip/fastaction.nvim",
            opts = {},
        },
        {
            "neovim/nvim-lspconfig",
            config = function()
                -- Some Language Server Settings
                -- As an example, luals
                require("lspconfig").lua_ls.setup({
                    cmd = { "<the path of lua-language-server>" }
                })
                local opts = { noremap = true, silent = true }
                local fastaction = require("fastaction")
                vim.keymap.set("n", "<leader>fa", fastaction.code_action, opts)
                vim.keymap.set("v", "<leader>fa", fastaction.range_code_action, opts)
            end,
        },
    },
})
Chaitanyabsprip commented 1 day ago

I was expecting a minimal project where you had this discrepancy between fastaction and vim.lsp.buf.code_actions. I tried reproducing this case in my other repositories, haven't found anything yet.

As a point of clarification, are you getting >20 code actions?

galou commented 6 hours ago

Sorry, this example is only minimal if you already have clangd installed but I didn't manage to have it work with lua_ls.

init.lua:

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    spec = {
        {
            "Chaitanyabsprip/fastaction.nvim",
            opts = {},
        },
        {
            "neovim/nvim-lspconfig",
            config = function()
                -- Some Language Server Settings
                -- As an example, luals
                require("lspconfig").clangd.setup({
                    --cmd = {vim.fn.expand("~/.local/share/nvim/mason/bin/clangd") }
                })
                local opts = { noremap = true, silent = true }
                local fastaction = require("fastaction")
                vim.keymap.set("n", "<leader>fa", fastaction.code_action, opts)
                vim.keymap.set("v", "<leader>fa", fastaction.range_code_action, opts)
            end,
        },
    },
})

main.cpp:

#include <iostream>

int main(int, char**)
{
}

Install clangd.

vim -u init.lua main.cpp, the code action on l.1 can be executed with :lua vim.lsp.buf.code_action() but Fastaction doesn't propose anything.

galou commented 6 hours ago

Only one code action available.