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

fix: searchpair & searchpairpos param types #130

Merged
merged 1 commit into from
Mar 8, 2023
Merged

fix: searchpair & searchpairpos param types #130

merged 1 commit into from
Mar 8, 2023

Conversation

nguyenvukhang
Copy link
Contributor

@nguyenvukhang nguyenvukhang commented Feb 23, 2023

The param types can be read off the examples above the function declaration.

@folke
Copy link
Owner

folke commented Feb 28, 2023

Those types are auto-generated, so I can't just merge this.

There is a mechanism to override generated types though. Have a look at https://github.com/folke/neodev.nvim/blob/main/types/override/vim.fn.lua

@nguyenvukhang
Copy link
Contributor Author

I'm not sure how to locally build to test the changes, and would like some help if possible.

(The following list is taken from BUILD.md)

✅ 1. Clone the neovim repo somewhere on your system
✅ 2. Run ./scripts/gen_vimdoc.py
3. Copy mpack files to the neodev.nvim data directory

which of these files do I copy?

$ fd -I mpack
.deps/usr/lib/lua/5.1/mpack.so
.deps/usr/lib/luarocks/rocks-5.1/mpack/
.deps/usr/lib/luarocks/rocks-5.1/mpack/1.0.8-0/mpack-1.0.8-0.rockspec
build/.cache/clangd/index/lmpack.c.29A3CF495A064716.idx
build/.cache/clangd/index/lmpack.h.69D19CD0607E6498.idx
build/.cache/clangd/index/mpack_core.c.7BC58B1CADBB79BB.idx
build/.cache/clangd/index/mpack_core.h.4FC04DA8A750D0B1.idx
build/api_metadata.mpack
build/funcs_data.mpack
build/src/nvim/CMakeFiles/libnvim.dir/**/mpack/
build/src/nvim/CMakeFiles/nvim.dir/**/mpack/
build/src/nvim/CMakeFiles/nvim.dir/**/mpack/lmpack.c.o
build/src/nvim/CMakeFiles/nvim.dir/**/mpack/mpack_core.c.o
runtime/doc/api.mpack
runtime/doc/diagnostic.mpack
runtime/doc/lsp.mpack
runtime/doc/lua.mpack
runtime/doc/treesitter.mpack
src/mpack/
src/mpack/lmpack.c
src/mpack/lmpack.h
src/mpack/mpack_core.c
src/mpack/mpack_core.h
test/functional/fixtures/api_level_0.mpack
test/functional/fixtures/api_level_1.mpack
test/functional/fixtures/api_level_10.mpack
test/functional/fixtures/api_level_2.mpack
test/functional/fixtures/api_level_3.mpack
test/functional/fixtures/api_level_4.mpack
test/functional/fixtures/api_level_5.mpack
test/functional/fixtures/api_level_6.mpack
test/functional/fixtures/api_level_7.mpack
test/functional/fixtures/api_level_8.mpack
test/functional/fixtures/api_level_9.mpack
test/functional/lua/mpack_spec.lua

and doesn't seem to be a /data directory in the neodev.nvim repository
workspace. Do I have to create one?

  1. Open the file neodev.nvim/lua/parser.lua in Neovim

This file is no longer there. Which one is it currently?

  1. Execute :luafile %
  2. Create a PR with new EmmyLua annotations

@folke
Copy link
Owner

folke commented Mar 3, 2023

Hi! I've just updated the build instructions.
When your changes look right, make sure to not include the generated files in your PR commit. Those will be generated automatically when merging this PR

@nguyenvukhang
Copy link
Contributor Author

nguyenvukhang commented Mar 4, 2023

Thanks for updating the build instructions.
Though, I'm still unable to produce any output.

✅ 1. Clone the neovim repo somewhere on your system
✅ 2. Run ./scripts/gen_vimdoc.py
❓ 3. Copy neovim/runtime/doc/*.mpack files to the neodev.nvim data directory

For this I created a fresh directory /data at the root of the
neodev repo workspace, and copied neovim/runtime/doc/*.mpack there.

✅ 4. Open the file neodev.nvim/lua/build/api.lua in Neovim
❓ 5. Execute :luafile %

I put a test change inside of types/override/vim.fn.lua, but
no changes were observed in the *.mpack files, nor any of the files
in the neodev repo workspace

  1. You'll see a lot of annotations that might be changed due to your local
    system setup, so you can ignore those
  2. Check if the changes you intended are present
  3. Create a PR with your code changes, and without the new EmmyLua annotations

P.S. specifically, the *.mpack files I built from neovim and copied over are:

api.mpack
diagnostic.mpack
lsp.mpack
lua.mpack
treesitter.mpack

@laytan
Copy link
Contributor

laytan commented Mar 7, 2023

@nguyenvukhang Hey, thought I'd chime in, I recently did a PR with new overrides and ran into some of your issues.

I ultimately ignored build.md and checked what the GitHub workflow was doing for generating and copying the mpack, which then worked.

But it still did not update any types when running the :laufile % instruction.

What I had to do was change lua/neodev/build/docs.lua at line 23 to: local txtfile = "/absolute/path/to/neovim/runtime/doc/" .. name .. ".txt"

After this change, and then running :luafile % like in build.md it all worked.

I guess the $VIMRUNTIME was not set for me and might not be for you.

@nguyenvukhang nguyenvukhang reopened this Mar 8, 2023
@nguyenvukhang
Copy link
Contributor Author

Thanks for the help @laytan!

For completeness, here's the steps to take to go from fresh clone to build:

git clone https://github.com/folke/neodev.nvim.git
cd neodev.nvim
mkdir data
git clone --depth=1 https://github.com/neovim/neovim.git ./data/neovim
cd ./data/neovim
make all                         # build neovim but don't install it
python3 ./scripts/gen_vimdoc.py  # generate the *.mpack files

# back in the root of neodev.nvim
cd ../..
cp ./data/neovim/runtime/doc/*.mpack ./data/
nvim -u NONE -E -R --headless \
  --cmd "set rtp^=." --cmd "packloadall" \
  --cmd "luafile lua/neodev/build/init.lua" --cmd q # taken from the types workflow

and @folke I've reduced the changes to just inside of types/override/vim.fn.lua so this PR is ready to go.

@folke folke merged commit c87f69c into folke:main Mar 8, 2023
@folke
Copy link
Owner

folke commented Mar 8, 2023

thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants