svls icon indicating copy to clipboard operation
svls copied to clipboard

Completion Function Fails in neovim configured by Lua

Open DowneyFlyfan opened this issue 5 months ago • 7 comments

Here is my lsp.lua:

-- Mason Settings
Capabilities = require("cmp_nvim_lsp").default_capabilities()

vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, { noremap = true, silent = true })
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { noremap = true, silent = true })
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { noremap = true, silent = true })
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, { noremap = true, silent = true })

On_attach = function(_client, bufnr)
	require("lsp_signature").on_attach({
		bind = true,
		hint_enable = true,
		floating_window = true,
		fix_pos = false,
		hint_prefix = "🔍 ",
		hi_parameter = "LspSignatureActiveParameter",
		handler_opts = {
			border = "rounded",
		},
	}, bufnr)

	local bufopts = { noremap = true, silent = true, buffer = bufnr }
	vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
	vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
	vim.keymap.set("n", "<C-h>", vim.lsp.buf.hover, bufopts)
	vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
	vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, bufopts)
	vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
	vim.keymap.set("n", "<space>wl", function()
		print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
	end, bufopts)
	vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts)
	vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
	vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
	vim.api.nvim_create_autocmd("BufWritePre", {
		pattern = "*",
		callback = function(args)
			local filetype = vim.api.nvim_buf_get_option(args.buf, "filetype")
			if filetype == "matlab" then
				vim.lsp.buf.format({ bufnr = args.buf })
			else
				require("conform").format({ bufnr = args.buf })
			end
		end,
	})
end

require("mason-nvim-dap").setup({
	ensure_installed = { "python", "cppdbg", "bash" },
	automatic_setup = true,
})

require("mason-tool-installer").setup({
	ensure_installed = {
		"stylua",
		"black",
		"prettierd",
		"prettier",
		"tex-fmt",
		"verible",
		"clang-format",
		"beautysh",
	},

	auto_update = true,
	run_on_start = true,
	start_delay = 500,
	debounce_hours = 5,
	integrations = {
		["mason-lspconfig"] = true,
		["mason-nvim-dap"] = true,
	},
})

require("Languages.python")
require("Languages.c")
require("Languages.matlab")
require("Languages.lua_config")
require("Languages.typescript")
require("Languages.css")
require("Languages.html")
require("Languages.tex")
require("Languages.markdown")
require("Languages.verilog")

Here is my Languages.verilog.lua:

-- LSP config for svls
vim.lsp.config("svls", {
	on_attach = On_attach,
	capabilities = Capabilities,
	settings = {},
})

Here is my nvim-cmp":

local has_words_before = function()
	unpack = unpack or table.unpack
	local line, col = unpack(vim.api.nvim_win_get_cursor(0))
	return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end

local luasnip = require("luasnip")
local cmp = require("cmp")

cmp.setup({
	snippet = {
		expand = function(args)
			require("luasnip").lsp_expand(args.body) -- For `luasnip` users.
		end,
	},
	window = {
		completion = cmp.config.window.bordered(),
		documentation = cmp.config.window.bordered(),
	},
	mapping = cmp.mapping.preset.insert({
		-- ["<C-b>"] = cmp.mapping.scroll_docs(-4),
		-- ["<C-f>"] = cmp.mapping.scroll_docs(4),
		-- ["<C-Space>"] = cmp.mapping.complete(),
		["<C-q>"] = cmp.mapping.abort(),
		["<CR>"] = cmp.mapping.confirm({ select = true }),

		["<Tab>"] = cmp.mapping(function(fallback)
			if cmp.visible() then
				cmp.select_next_item()
			elseif has_words_before() then
				cmp.complete()
			else
				fallback()
			end
		end, { "i", "s" }), -- i - insert mode; s - select mode
		["<S-Tab>"] = cmp.mapping(function(fallback)
			if cmp.visible() then
				cmp.select_prev_item()
			elseif luasnip.jumpable(-1) then
				luasnip.jump(-1)
			else
				fallback()
			end
		end, { "i", "s" }),
	}),

	formatting = {
		fields = { "abbr", "menu" },

		-- customize the appearance of the completion menu
		format = function(entry, vim_item)
			vim_item.menu = ({
				nvim_lsp = "[Lsp]",
				luasnip = "[Luasnip]",
				buffer = "[File]",
				path = "[Path]",
			})[entry.source.name]
			return vim_item
		end,
	},

	-- Set source precedence
	sources = cmp.config.sources({
		{ name = "nvim_lsp" },
		{ name = "luasnip" },
		{ name = "vimtex" },
		{ name = "buffer" },
		{ name = "path" },
	}),
})

Even if I delete verible, svls still fails on completion. Does anyone have the same experience?

DowneyFlyfan avatar Jul 19 '25 07:07 DowneyFlyfan

Come on, nobody has this problem??

DowneyFlyfan avatar Jul 24 '25 09:07 DowneyFlyfan

Unfortunately, svls doesn't support completion feature.

dalance avatar Jul 24 '25 09:07 dalance

Unfortunately, svls doesn't support completion feature.

But completion feature is demonstrated in your readme(σ゚∀゚)σ

DowneyFlyfan avatar Jul 25 '25 06:07 DowneyFlyfan

But completion feature is demonstrated in your readme(σ゚∀゚)σ

OK. It seems to be confusing. It is keyword-based completion provided another plugin.

dalance avatar Jul 25 '25 06:07 dalance

But completion feature is demonstrated in your readme(σ゚∀゚)σ

OK. It seems to be confusing. It is keyword-based completion provided another plugin.

Got it. Thank you for your interpretation.

DowneyFlyfan avatar Jul 26 '25 01:07 DowneyFlyfan

But completion feature is demonstrated in your readme(σ゚∀゚)σ

OK. It seems to be confusing. It is keyword-based completion provided another plugin.

Can you please tell me which plugin is that?

DowneyFlyfan avatar Nov 26 '25 21:11 DowneyFlyfan

I think its provided by any snip plugin and related snips written by hand.

sevenninesixthree avatar Dec 15 '25 15:12 sevenninesixthree