nvimdev / lspsaga.nvim

improve neovim lsp experience
MIT License
3.42k stars 286 forks source link

`Lspsaga code_action` failed #1124

Closed 0x00-ketsu closed 1 year ago

0x00-ketsu commented 1 year ago

Describe the bug

image image

Steps to reproduce

  1. Create a project with git
  2. nvim --clean -u min.lua main.go

main.go

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

min.lua

local api = vim.api

api.nvim_command('set nu')
api.nvim_command('set relativenumber')

-- Plugins
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system(
      {
        'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git',
        '--branch=stable', -- latest stable release
        lazypath
      }
  )
end
vim.opt.rtp:prepend(lazypath)

-- Example using a list of specs with the default options
vim.g.mapleader = ',' -- Make sure to set `mapleader` before lazy so your mappings are correct

require('lazy').setup(
    {
      -- LuaFormatter off
      {'ellisonleao/gruvbox.nvim', config = function()
          require('gruvbox').setup {}
        end
      },
      {
        'hrsh7th/nvim-cmp',
        event = 'InsertEnter',
        config = function()
          require('cmp').setup {}
        end,
        dependencies = {
          {'hrsh7th/cmp-nvim-lsp'},
        },
      },
      {
        'neovim/nvim-lspconfig',
        config = function()
          require'lspconfig'.pyright.setup {}
          require'lspconfig'.gopls.setup {}
        end
      },
      {
        'williamboman/mason.nvim',
        config = function()
          require('mason').setup()
        end
      },
      {'williamboman/mason-lspconfig.nvim'},
      {
        'jose-elias-alvarez/null-ls.nvim',
        config = function()
          local null_ls = require('null-ls')
          local code_actions = null_ls.builtins.code_actions
          local diagnostics = null_ls.builtins.diagnostics
          null_ls.setup {
          sources = {
            code_actions.gitsigns,
            diagnostics.golangci_lint
          }
        }
        end,
        dependencies = {{'nvim-lua/plenary.nvim'}}
      },
      -- LuaFormatter on

      {
        'lewis6991/gitsigns.nvim',
        lazy = true,
        event = {'BufRead', 'BufNewFile'},
        config = function()
          require('gitsigns').setup {}
        end,
        dependencies = {'nvim-lua/plenary.nvim'}
      },
      {
        'glepnir/lspsaga.nvim',
        event = 'BufRead',
        config = function()
          require('lspsaga').setup({})
        end,
        dependencies = {{'nvim-tree/nvim-web-devicons'}, {'nvim-treesitter/nvim-treesitter'}}
      }
    }
)

Expected behavior

Can do code actions.

Neovim version (nvim -v)

0.9.1

lspsaga commit

8a05cb1

Terminal name/version

iterm2 3.4.19

glepnir commented 1 year ago

wired .I can't reproduce ..

0x00-ketsu commented 1 year ago

gitsigns.nvim commit : dc2962f (latest)

eXvimmer commented 1 year ago

Did anyone find a solution for this? Should I open a new issue in gitsigns.nvim repo? BTW, I don't think this is a gitsigns.nvim bug; Because I checked out commit from 2 months ago, and the problem persists. I just checked out the lspsaga.nvim commit from last month, and it works fine; So I think this issue should be reopened.

glepnir commented 1 year ago

this issue has been fixed

eXvimmer commented 1 year ago

I have updated to the latest version. I don't get the error, but I still get the exact same thing as show in the above picture (i.e. gitsigns.nvim actions).

glepnir commented 1 year ago

What do you mean? I don't get your problem? No error .so what is the problem?

eXvimmer commented 1 year ago

If you look at the top picture, instead of showing code actions for fixing problems (like auto import, etc.), it only shows gitsigns.nvim commands.

glepnir commented 1 year ago

Why show auto import?there is no lsp actions it has import fmt? All the code of picture is correct?

eXvimmer commented 1 year ago

It was just an example. If there's an error, and you try to do Lspsaga diagnostic_jump_next, it won't show the options for code action. It only shows gitsigns actions.

eXvimmer commented 1 year ago

So here's a simple example. It says fix available, but doesn't show anything.

Screencast from 11-07-23 04:07:22.webm

glepnir commented 1 year ago

I think igot your point ,test later reopen

eXvimmer commented 1 year ago

thanks

glepnir commented 1 year ago

does vim.lsp.buf.code action has output?

eXvimmer commented 1 year ago

It works now. Thanks