Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: vim.fn.getreg third parameter type is incorrect #150

Open
3 tasks done
aarondill opened this issue Apr 16, 2023 · 2 comments
Open
3 tasks done

bug: vim.fn.getreg third parameter type is incorrect #150

aarondill opened this issue Apr 16, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@aarondill
Copy link

aarondill commented Apr 16, 2023

Did you check docs and existing issues?

  • I have read all the neodev.nvim docs
  • I have searched the existing issues of neodev.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0-dev

Operating system/version

Ubuntu 22.04.2 LTS

Describe the bug

The types for the vim.fn.getreg function are incorrect, current types are function vim.fn.getreg(regname?: any, p1?: any, list?: any[]) -> string, the correct types would be the following (these can likely be simplified):

--- @param regname? string
--- @param p1? 1
--- @param list? boolean
--- @return string
--- @overload fun(regname: string, p1?:1, list?:false): string
--- @overload fun(regname: string, p1:1, list:true): string[]

Steps To Reproduce

  1. Install an lsp (and optionally a diagnostic) so type errors can be seen
  2. Install neodev with any plugin manager (or manually)
  3. nvim ~/.config/nvim/init.lua
  4. type vim.fn.getreg("+", 1, true)
  5. observe diagnostic issue, even though usage is correct

Expected Behavior

Types match usage types

Repro

~/.config/nvim/init.lua
-- Set keymap for diagnostics
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/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", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
	"folke/tokyonight.nvim",
	-- mason to install lua-language-server
	{
		"williamboman/mason.nvim",
		build = ":MasonUpdate",
		config = true,
	},
	-- mason-lspconfig to load lua-language-server
	{
		"williamboman/mason-lspconfig.nvim",
		dependencies = "williamboman/mason.nvim",
		opts = { ensure_installed = { "lua_ls" } },
	},
	-- nvim-lspconfig to setup lsp
	{
		"neovim/nvim-lspconfig",
		dependencies = {
			{ "folke/neodev.nvim" }, -- Load neodev
			"mason.nvim",
			"williamboman/mason-lspconfig.nvim",
		},
		config = function()
			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",
						},
						workspace = {
							-- Make the server aware of Neovim runtime files
							library = vim.api.nvim_get_runtime_file("", true),
							checkThirdParty = false, -- save some time on startup
						},
						-- Do not send telemetry data containing a randomized but unique identifier
						telemetry = {
							enable = false,
						},
					},
				},
			})
		end,
	},
	{ -- is it working?
		"mrded/nvim-lsp-notify",
		main = "lsp-notify",
		config = true,
	},
}
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
@aarondill aarondill added the bug Something isn't working label Apr 16, 2023
@TheBlob42
Copy link

In a similar way the types for vim.fn.setreg are also incorrect.
Current types are function vim.fn.setreg(regname: any, value: any, options?: table<string, any>) -> number but should rather be:

--- @param regname string
--- @param value string[]|string
--- @param options table|string <-- from how I understand it only an empty table is allowed here
--- @return number

@wookayin
Copy link

wookayin commented Jan 22, 2024

Anything that you believe is not correct in https://github.com/neovim/neovim/blob/master/runtime/lua/vim/_meta/vimfn.lua as well can be reported to https://github.com/neovim/neovim/issues. Due to the (suboptimal) way neodev's annotations are generated, there could be some mismatches. See #175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants