Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

bug: vim.iter is not found after https://github.com/neovim/neovim/pull/23303 #153

Closed
3 tasks done
seblj opened this issue Apr 28, 2023 · 7 comments · Fixed by #155
Closed
3 tasks done

bug: vim.iter is not found after https://github.com/neovim/neovim/pull/23303 #153

seblj opened this issue Apr 28, 2023 · 7 comments · Fixed by #155
Labels
bug Something isn't working

Comments

@seblj
Copy link

seblj commented Apr 28, 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-216+g4720f4379

Operating system/version

MacOS 13.1

Describe the bug

It won't complete methods on vim.iter after this PR: neovim/neovim#23303
Before this, it would work correctly. Probably because it is a module now as well as a function. I also noticed that vim.version also don't work which is the example in the PR of another module and function.

Steps To Reproduce

Use the repro-config and open a file lua file and try to get completion for vim.iter or vim.version.

Expected Behavior

I would expect it to complete all the functions on vim.iter. Both the functions vim.iter.filter, vim.iter.map and all the others vim.iter({ 1, 2, 3 }):each(...) etc...

Repro

-- DO NOT change the paths and don't remove the colorscheme
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",
	"neovim/nvim-lspconfig",
	"hrsh7th/nvim-cmp",
	"hrsh7th/cmp-nvim-lsp",
	"L3MON4D3/LuaSnip",
	"folke/neodev.nvim",
	-- add any other plugins here
}
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
local cmp = require("cmp")
require("cmp").setup({
	sources = {
		{ name = "nvim_lsp" },
	},
	snippet = {
		expand = function(args)
			require("luasnip").lsp_expand(args.body)
		end,
	},
	mapping = cmp.mapping.preset.insert({
		["<C-d>"] = cmp.mapping.scroll_docs(4),
		["<C-u>"] = cmp.mapping.scroll_docs(-4),
		["<C-Space>"] = cmp.mapping.complete({}),
		["<CR>"] = cmp.mapping.confirm({ select = false }),
	}),
})

require("neodev").setup({})

local lspconfig = require("lspconfig")

-- example to setup lua_ls and enable call snippets
lspconfig.lua_ls.setup({
	settings = {
		Lua = {
			completion = {
				callSnippet = "Replace",
			},
		},
	},
})
@seblj seblj added the bug Something isn't working label Apr 28, 2023
@max397574
Copy link

@folke any updates on this?

@folke folke closed this as completed in 76bdb81 May 24, 2023
@folke
Copy link
Owner

folke commented May 24, 2023

Thank you for reporting! Just fixed this

@folke
Copy link
Owner

folke commented May 24, 2023

There may be others missing as well, so feel free to submit a PR to update those :)

@seblj
Copy link
Author

seblj commented May 30, 2023

Is it possible to get completion when calling vim.iter?. For example get completion on the find method defined on vim.iter(src):find.

With the fix provided, it only completes totable, map, and filter which is defined on the module vim.iter like vim.iter.map(src)

@folke

folke added a commit that referenced this issue May 30, 2023
@folke
Copy link
Owner

folke commented May 30, 2023

Just changed it a bit. Should work now. vim.iter is a function, but lua-ls will complete it as a field. But as soon as you add (), you'll get proper completion of the function

@folke
Copy link
Owner

folke commented May 30, 2023

will actually still be wrong. Needs to be fixed in neovim with an @override.
Will revert my changes

@seblj
Copy link
Author

seblj commented May 30, 2023

neovim/neovim#23845 should fix it

Thanks for the hint on how to fix it!

@folke

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

Successfully merging a pull request may close this issue.

3 participants