Open PaoloTorregroza opened 3 weeks ago
How did you install the plugin?
And if you're on an empty line and your LSP doesn't send code actions it can be normal to not have code action at this place. You might try to set your cursor to line 3 or 5, and retry to press ca
This is how I installed it. And no mather where I put my cursor no code actions or message is shown.
When I fix the error adding the semicolon, and press
This is how my lsp config looks like:
return {
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/nvim-cmp",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"j-hui/fidget.nvim",
},
config = function()
local cmp = require('cmp')
local cmp_lsp = require("cmp_nvim_lsp")
local capabilities = vim.tbl_deep_extend(
"force",
{},
vim.lsp.protocol.make_client_capabilities(),
cmp_lsp.default_capabilities())
require("fidget").setup({})
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"rust_analyzer",
"gopls",
"ruff_lsp", -- For python
},
handlers = {
function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup {
capabilities = capabilities
}
end,
zls = function()
local lspconfig = require("lspconfig")
lspconfig.zls.setup({
root_dir = lspconfig.util.root_pattern(".git", "build.zig", "zls.json"),
settings = {
zls = {
enable_inlay_hints = true,
enable_snippets = true,
warn_style = true,
},
},
})
vim.g.zig_fmt_parse_errors = 0
vim.g.zig_fmt_autosave = 0
end,
["lua_ls"] = function()
local lspconfig = require("lspconfig")
lspconfig.lua_ls.setup {
capabilities = capabilities,
settings = {
Lua = {
runtime = { version = "Lua 5.1" },
diagnostics = {
globals = { "bit", "vim", "it", "describe", "before_each", "after_each" },
}
}
}
}
end,
}
})
local cmp_select = { behavior = cmp.SelectBehavior.Select }
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = cmp.mapping.preset.insert({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<Tab>'] = cmp.mapping.confirm({ select = true}),
["<C-Space>"] = cmp.mapping.complete(),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' }, -- For luasnip users.
}, {
{ name = 'buffer' },
})
})
vim.diagnostic.config({
-- update_in_insert = true,
float = {
focusable = false,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
})
end
}
Try replacing event = "LspAttach"
to event = "VeryLazy"
, and checks if it is better
Did not work either. It looks like after I save the file, and it contains errors I cant show the code actions popup.
It really depends of how your LSP deals with code actions. If you have "No code actions available", it means that the plugin is correctly loaded so it's nice.
Do you have rustaceanvim installed ?
Nope, I dont use rustaceanvim, should I?
I think it requires having luarocks working. And Im having some trouble making nvim work with a version of luarocks installed using luaver (A version manager for lua and its tools).
You'll have more code actions, but I'm not well versed in rust.
When I test I get this (only with LSP, without rustaceanvim):
That's a strange issue. If you try simply with :lua vim.lsp.buf.code_action()
, do you have a popup ?
I get this, at the bottom of the screen, no popup at all.
The code actions shown at the bottom of the screen at least are right and are the expected ones.
Using default install settings and keymap nothing is shown when pressingca