1

Regenerate nvim config

This commit is contained in:
2024-06-02 03:29:20 +02:00
parent 75eea0c030
commit ef2e28883d
5576 changed files with 604886 additions and 503 deletions

View File

@ -0,0 +1,89 @@
name: Bug Report
description: File a bug/issue
title: "bug: "
labels: [bug]
body:
- type: markdown
attributes:
value: |
**Before** reporting an issue, make sure to read the [documentation](https://github.com/folke/neodev.nvim) and search [existing issues](https://github.com/folke/neodev.nvim/issues). Usage questions such as ***"How do I...?"*** belong in [Discussions](https://github.com/folke/neodev.nvim/discussions) and will be closed.
- type: checkboxes
attributes:
label: Did you check docs and existing issues?
description: Make sure you checked all of the below before submitting an issue
options:
- label: I have read all the neodev.nvim docs
required: true
- label: I have searched the existing issues of neodev.nvim
required: true
- label: I have searched the existing issues of plugins related to this issue
required: true
- type: input
attributes:
label: "Neovim version (nvim -v)"
placeholder: "0.8.0 commit db1b0ee3b30f"
validations:
required: true
- type: input
attributes:
label: "Operating system/version"
placeholder: "MacOS 11.5"
validations:
required: true
- type: textarea
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is. Please include any related errors you see in Neovim.
validations:
required: true
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1.
2.
3.
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: A concise description of what you expected to happen.
validations:
required: true
- type: textarea
attributes:
label: Repro
description: Minimal `init.lua` to reproduce this issue. Save as `repro.lua` and run with `nvim -u repro.lua`
value: |
-- 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",
"folke/neodev.nvim",
-- add any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight")
-- add anything else here
render: Lua
validations:
required: false

View File

@ -0,0 +1,36 @@
name: Feature Request
description: Suggest a new feature
title: "feature: "
labels: [enhancement]
body:
- type: checkboxes
attributes:
label: Did you check the docs?
description: Make sure you read all the docs before submitting a feature request
options:
- label: I have read all the neodev.nvim docs
required: true
- type: textarea
validations:
required: true
attributes:
label: Is your feature request related to a problem? Please describe.
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
- type: textarea
validations:
required: true
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
- type: textarea
validations:
required: true
attributes:
label: Describe alternatives you've considered
description: A clear and concise description of any alternative solutions or features you've considered.
- type: textarea
validations:
required: false
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request here.

View File

@ -0,0 +1,72 @@
name: CI
on:
push:
pull_request:
jobs:
tests:
strategy:
matrix:
# os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Neovim
shell: bash
run: |
mkdir -p /tmp/nvim
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
cd /tmp/nvim
chmod a+x ./nvim.appimage
./nvim.appimage --appimage-extract
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
- name: Run Tests
run: |
nvim --version
[ ! -d tests ] && exit 0
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
docs:
runs-on: ubuntu-latest
needs: tests
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- name: panvimdoc
uses: kdheepak/panvimdoc@main
with:
vimdoc: neodev.nvim
version: "Neovim >= 0.8.0"
demojify: true
treesitter: true
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(build): auto-generate vimdoc"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
release:
name: release
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- docs
- tests
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: simple
package-name: neodev.nvim
- uses: actions/checkout@v3
- name: tag stable versions
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
git tag -d stable || true
git push origin :stable || true
git tag -a stable -m "Last Stable Release"
git push origin stable

View File

@ -0,0 +1,64 @@
name: Types
on:
workflow_dispatch:
schedule:
# Run this every hour
- cron: "0 * * * *"
jobs:
build-types-nightly:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup ./data
run: mkdir ./data
- name: Install dependencies
run: |
sudo apt-get -y install doxygen luajit python3-msgpack
- name: Install Neovim
shell: bash
run: |
mkdir -p /tmp/nvim
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
cd /tmp/nvim
chmod a+x ./nvim.appimage
./nvim.appimage --appimage-extract
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
- name: Generate new docs
run: |
nvim --version
nvim -u NONE -E -R --headless --cmd "set rtp^=." --cmd "packloadall" --cmd "luafile lua/neodev/build/init.lua" --cmd q
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: auto-generated types for Neovim nightly"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
build-types-stable:
needs: build-types-nightly
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Pull Updates
run: git pull
- name: Install Neovim
shell: bash
run: |
mkdir -p /tmp/nvim
wget -q https://github.com/neovim/neovim/releases/download/stable/nvim.appimage -O /tmp/nvim/nvim.appimage
cd /tmp/nvim
chmod a+x ./nvim.appimage
./nvim.appimage --appimage-extract
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
- name: Generate new docs
run: |
nvim --version
nvim -u NONE -E -R --headless --cmd "set rtp^=." --cmd "packloadall" --cmd "luafile lua/neodev/build/init.lua" --cmd q
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: auto-generated types for Neovim stable"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"

View File

@ -0,0 +1,8 @@
tt.*
.tests
doc/tags
debug
.repro
foo.*
*.log
data

View File

@ -0,0 +1,18 @@
{
"neodev": {
"library": {
"enabled": true,
"plugins": ["neoconf.nvim", "nvim-lspconfig"]
}
},
"neoconf": {
"plugins": {
"lua_ls": {
"enabled": true
}
}
},
"lspconfig": {
"sumneko_lua": {}
}
}

View File

@ -0,0 +1,11 @@
# Updating Lua API Docs
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
4. Open the file `neodev.nvim/lua/build/api.lua` in Neovim
5. Execute `:luafile %`
6. You'll see a lot of annotations that might be changed due to your local
system setup, so you can ignore those
7. Check if the changes you intended are present
8. Create a PR with your code changes, and **without** the new EmmyLua annotations

View File

@ -0,0 +1,266 @@
# Changelog
## [2.5.2](https://github.com/folke/neodev.nvim/compare/v2.5.1...v2.5.2) (2023-03-24)
### Bug Fixes
* parameter type for vim.fn.getline() ([#144](https://github.com/folke/neodev.nvim/issues/144)) ([ab56354](https://github.com/folke/neodev.nvim/commit/ab56354e0e85c3c3f20f770c699fb0038ce7bf42))
## [2.5.1](https://github.com/folke/neodev.nvim/compare/v2.5.0...v2.5.1) (2023-03-12)
### Bug Fixes
* **lua_ls:** plugin name detection of symlinked plugins ([#140](https://github.com/folke/neodev.nvim/issues/140)) ([a60eaee](https://github.com/folke/neodev.nvim/commit/a60eaee19e0c3dcb7e54c64fe9bcfb71420a95c0))
## [2.5.0](https://github.com/folke/neodev.nvim/compare/v2.4.2...v2.5.0) (2023-03-10)
### Features
* **luv:** use the luv addon instead of the deprecated 3rd party ([f06c113](https://github.com/folke/neodev.nvim/commit/f06c11344f76fadf2cd497b9490125dfc02946cb))
## [2.4.2](https://github.com/folke/neodev.nvim/compare/v2.4.1...v2.4.2) (2023-03-08)
### Bug Fixes
* parameter types for searchpair and searchpairpos ([#130](https://github.com/folke/neodev.nvim/issues/130)) ([c87f69c](https://github.com/folke/neodev.nvim/commit/c87f69c856505ea778f6fd883a90397e55c8e59d))
## [2.4.1](https://github.com/folke/neodev.nvim/compare/v2.4.0...v2.4.1) (2023-02-28)
### Bug Fixes
* parameter types for vim.wait and vim.fn.input ([#131](https://github.com/folke/neodev.nvim/issues/131)) ([55d3a74](https://github.com/folke/neodev.nvim/commit/55d3a747af136da527067e9fe59ad0bb938ecd50))
## [2.4.0](https://github.com/folke/neodev.nvim/compare/v2.3.0...v2.4.0) (2023-02-13)
### Features
* added lua_ls luv builtin library. Fixes [#127](https://github.com/folke/neodev.nvim/issues/127) ([8c32d8b](https://github.com/folke/neodev.nvim/commit/8c32d8b4e765de26b27b76f0072e7c12038cde52))
## [2.3.0](https://github.com/folke/neodev.nvim/compare/v2.2.1...v2.3.0) (2023-02-13)
### Features
* **luv:** more luv types ([39bb79b](https://github.com/folke/neodev.nvim/commit/39bb79b688300b0b4672ec83c564d72749482116))
## [2.2.1](https://github.com/folke/neodev.nvim/compare/v2.2.0...v2.2.1) (2023-02-12)
### Bug Fixes
* s/sumneko_lua/lua_ls/ ([#124](https://github.com/folke/neodev.nvim/issues/124)) ([307d0fb](https://github.com/folke/neodev.nvim/commit/307d0fbce02068eebdaa4ef7da279fdb1bfe6d8e))
* sumneko_lua -&gt; lua_ls ([5076ebb](https://github.com/folke/neodev.nvim/commit/5076ebbcbfd0e2164d91ff2073a6f21a561804df))
## [2.2.0](https://github.com/folke/neodev.nvim/compare/v2.1.0...v2.2.0) (2023-02-10)
### Features
* add more luv methods and types ([#122](https://github.com/folke/neodev.nvim/issues/122)) ([fc01efe](https://github.com/folke/neodev.nvim/commit/fc01efe11447a99808b06e362d95a296218fed68))
## [2.1.0](https://github.com/folke/neodev.nvim/compare/v2.0.1...v2.1.0) (2023-02-08)
### Features
* Add `treesitter.query` and `treesitter.language` to stable ([#119](https://github.com/folke/neodev.nvim/issues/119)) ([4b6ade9](https://github.com/folke/neodev.nvim/commit/4b6ade9bb879aad4d1b2e94e82c36957262ead53))
* add class to vim.api and vim.loop ([e27c03b](https://github.com/folke/neodev.nvim/commit/e27c03b3e312c08e2d4aeed2a0f76199a9729529))
### Bug Fixes
* handle cases where `vim.fn.stdpath("config")` does not exist. Fixes [#109](https://github.com/folke/neodev.nvim/issues/109) ([fc20483](https://github.com/folke/neodev.nvim/commit/fc20483383dac11b97df43c83db1bbbd35305172))
* provide a class for vim.api ([#117](https://github.com/folke/neodev.nvim/issues/117)) ([9737bfc](https://github.com/folke/neodev.nvim/commit/9737bfc085cbb8879c19471a65b12fe9bd1ae878))
* revert [#117](https://github.com/folke/neodev.nvim/issues/117) ([dd63031](https://github.com/folke/neodev.nvim/commit/dd630312eb978f554006a020554d64c197887644))
* use integer for buffer, window, etc ([#116](https://github.com/folke/neodev.nvim/issues/116)) ([71e3e0c](https://github.com/folke/neodev.nvim/commit/71e3e0c2239593e29e06ecc725ba346e29d3186a))
## [2.0.1](https://github.com/folke/neodev.nvim/compare/v2.0.0...v2.0.1) (2023-01-15)
### Bug Fixes
* ignore lua directory ([82c8586](https://github.com/folke/neodev.nvim/commit/82c85862e2aaa9c0b63f3176eb8dc513803f2865))
* **lsp:** make sure everything works when lua root not found. Fixes [#108](https://github.com/folke/neodev.nvim/issues/108) ([31cba85](https://github.com/folke/neodev.nvim/commit/31cba8554a8e37ecf240fa2e242f0e43e72ae930))
## [2.0.0](https://github.com/folke/neodev.nvim/compare/v1.0.0...v2.0.0) (2023-01-11)
### ⚠ BREAKING CHANGES
* `config.pathStrict` is now enabled by default. Needs sumneko >= 3.6.0. Much better performance
### Features
* **options:** allow setting an option to its type ([1569664](https://github.com/folke/neodev.nvim/commit/156966470d19a8b095f9ae620720be3fb85a3772))
### Bug Fixes
* simplified and improved plugin/config detection ([a34a9e7](https://github.com/folke/neodev.nvim/commit/a34a9e7e775f1513466940c31285292b7b8375de))
### Performance Improvements
* `config.pathStrict` is now enabled by default. Needs sumneko &gt;= 3.6.0. Much better performance ([5ff32d4](https://github.com/folke/neodev.nvim/commit/5ff32d4d50491f94667733362a52d0fe178e4714))
## 1.0.0 (2023-01-04)
### ⚠ BREAKING CHANGES
* removed config.plugin_library in favor of config.override for easier customization
* rewrite with easier setup and configuration. Backward compatible, but refer to the docs to use the optimized setup
### Features
* added [@meta](https://github.com/meta) to generated emmy-lua files ([97a3399](https://github.com/folke/neodev.nvim/commit/97a33996a1618bdc6647384fd605940c5adce743))
* added [@see](https://github.com/see) for `seealso` from help docs ([1e8a2b4](https://github.com/folke/neodev.nvim/commit/1e8a2b4427a73cf3f0a51f42c52cc367e71f04f5))
* added annotations for vim.filetype, vim.F, vim.fs, vim.health, vim.inspect ([2be3d3f](https://github.com/folke/neodev.nvim/commit/2be3d3ffc17609319090289561842a75dcbf5daf))
* added config.runtime() for new vim.fn parser ([87adbea](https://github.com/folke/neodev.nvim/commit/87adbeafc4d2813447e6a75c8f209cb2d637b178))
* added configuration option to set the runtime_path (slow). Fixes [#29](https://github.com/folke/neodev.nvim/issues/29) ([f7fecb7](https://github.com/folke/neodev.nvim/commit/f7fecb7deda6fe244b6a5b8edfca21128009baf5))
* added docs for options and vim.fn functions ([4eb0e89](https://github.com/folke/neodev.nvim/commit/4eb0e894795251e5381c55ef87e7a0053ad0659c))
* added function to check if a fiven fqname is a lua object ([3d1d469](https://github.com/folke/neodev.nvim/commit/3d1d4698a05be1099162812bf7893fb873f6a297))
* added luv docs ([e38838a](https://github.com/folke/neodev.nvim/commit/e38838a558a5f80d6a9c8ad7d0044c884254463b))
* added missing types ([76e7b48](https://github.com/folke/neodev.nvim/commit/76e7b48122a251b98057cc71823bdc50aa289016))
* added option shortnames to vim.opt, o, go, bo, wo, opt_local, opt_global ([309eca5](https://github.com/folke/neodev.nvim/commit/309eca5584eba48d2b77f3668b3c5db3dee7e838))
* added options ([9ec4a9c](https://github.com/folke/neodev.nvim/commit/9ec4a9c73b102163055d8d4e52edd833f9c22151))
* added overrides for vim.fn.expand and vim.fn.sign_define. Fixes [#72](https://github.com/folke/neodev.nvim/issues/72) ([868db41](https://github.com/folke/neodev.nvim/commit/868db41830bae23c70b4ed044f64f60870bc8f37))
* added overrides for vim.fn.glob ([43f51e9](https://github.com/folke/neodev.nvim/commit/43f51e9b86d1637644f0fbba5e1e11bef4341750))
* added overrides for vim.loop.new_timer() ([d15370e](https://github.com/folke/neodev.nvim/commit/d15370ee520a169bf6224668ccca175489833948))
* added possibility to define [@overload](https://github.com/overload) annotations ([a77f5db](https://github.com/folke/neodev.nvim/commit/a77f5dbfe2e972789c989e2f3909354b482705c0))
* added possibility to override auto generated annotations ([9d6b75b](https://github.com/folke/neodev.nvim/commit/9d6b75ba119cf825fb92830188724e6f0f31e4ed))
* added support for lazy.nvim ([6136979](https://github.com/folke/neodev.nvim/commit/61369790e4205b74f1667587b3dc5867716500eb))
* added support for vim.opt methods. Fixes [#73](https://github.com/folke/neodev.nvim/issues/73) ([9e56a56](https://github.com/folke/neodev.nvim/commit/9e56a56301a297bf8d0c675349c101023a723c22))
* added support for vimdoc code blocks ([6d8ce16](https://github.com/folke/neodev.nvim/commit/6d8ce1602a166c03695aaa976252bcb0fd49a7dc))
* added types for vim.cmd.* ([9962a1d](https://github.com/folke/neodev.nvim/commit/9962a1dd0db41ab6745be2d9e4b3dc70d1aa188c))
* added vim.diagnostic & vim.ui ([58796ba](https://github.com/folke/neodev.nvim/commit/58796ba3f0f7b3ab2197670998555f299cb3f471))
* added vim.treesitter.highlighter ([5ca1178](https://github.com/folke/neodev.nvim/commit/5ca117883f37c64ee15f4d6a8ba8ca9a673bfffe))
* added vim.treesitter.language ([8d2a950](https://github.com/folke/neodev.nvim/commit/8d2a950045450927d8f7652ef26548b28f3137c8))
* added warnings on old-style setup ([17e73ce](https://github.com/folke/neodev.nvim/commit/17e73ce2f9616d5b967e9f3996f3c3b84912ef99))
* added workspace support ([681c0fc](https://github.com/folke/neodev.nvim/commit/681c0fc46c49108ec4da9e190c7bfe0ec1393d83))
* aded experimental option pathStrict. You need the latest sumneko nightly for this ([60f1ec9](https://github.com/folke/neodev.nvim/commit/60f1ec9d73c7f8fb5537050f38b8921698315e55))
* allow config without using lspconfig. Fixes [#83](https://github.com/folke/neodev.nvim/issues/83) ([3b6b644](https://github.com/folke/neodev.nvim/commit/3b6b6442a036729d950f1b92924ac0f5827638ea))
* better type infer ([6b9ae84](https://github.com/folke/neodev.nvim/commit/6b9ae848c4b804a9f9179abcc72ee38e824a2fd8))
* debug log ([fdab800](https://github.com/folke/neodev.nvim/commit/fdab800ea2a9d4a62b67fe87109b937e6d85f5bf))
* docs.fqn ([8f61232](https://github.com/folke/neodev.nvim/commit/8f61232f815e134efdf4cf06e1cd6342f4e369ab))
* enable call snippets ([a267319](https://github.com/folke/neodev.nvim/commit/a26731909a6790ab80a4c7bc0c25b8d7402c35e9))
* enable lua-dev by default for the Neovim runtime directory when needed ([0001b27](https://github.com/folke/neodev.nvim/commit/0001b27ddce0a1cc620d325577cba9f3b48f9cad))
* fix indent of doc comments ([5abb32a](https://github.com/folke/neodev.nvim/commit/5abb32ab07a2e01726095dcc9bf224f874eeac69))
* fixed detection of definitions for vim.keymap ([63bdf08](https://github.com/folke/neodev.nvim/commit/63bdf085b17ff55c938763ca1f6c346af119277c))
* fixed option docs ([fb82dcc](https://github.com/folke/neodev.nvim/commit/fb82dcc58d7839a60a0da008049dc42c663bebae))
* format code blocks as markdown ([e85a190](https://github.com/folke/neodev.nvim/commit/e85a19015ceb8498f6e80cb0094eb2dc45603bde))
* full support of vim.go, wo, bo, o, opt, opt_local, opt_global ([261d29c](https://github.com/folke/neodev.nvim/commit/261d29c44328eb4b703e49ba4a6ae4e5297a96fc))
* generated types for stable (Neovim 0.8.0) ([4366cad](https://github.com/folke/neodev.nvim/commit/4366cada45729a4224cbdf9b34f085b678c64796))
* handle special Lua keywords ([142d456](https://github.com/folke/neodev.nvim/commit/142d456011e0a5df302e5cced535ecaa13be631a))
* hidden option to make sumneko use a different neovim runtime for testing ([d55299f](https://github.com/folke/neodev.nvim/commit/d55299fea0655a416d94cb11badcd342ec54d7f4))
* implemented optional parameters for lua api functions ([ee8e6af](https://github.com/folke/neodev.nvim/commit/ee8e6af506fc94763c59d336258de48b9f500988))
* improved docs.functions ([c3a6a8c](https://github.com/folke/neodev.nvim/commit/c3a6a8c77af8dc04a064fe9b75d68bf3c56e4d4d))
* improved vim.api and vim parsers ([60fce6d](https://github.com/folke/neodev.nvim/commit/60fce6dd0c60376f3a2d2253b314c6088ad067a9))
* initial version ([26bd607](https://github.com/folke/neodev.nvim/commit/26bd607564940dc56575b792d799366a0da56c1f))
* integrate with settings.nvim ([d95e691](https://github.com/folke/neodev.nvim/commit/d95e69166dbbef775140aecd02508db13c3606bb))
* integration with neoconf.nvim ([77e8aec](https://github.com/folke/neodev.nvim/commit/77e8aec83549db4f575aa99cd8e2a88ac85db662))
* keep original formatting when parsing docs ([6cf4af1](https://github.com/folke/neodev.nvim/commit/6cf4af1a026d63e676bddbdf8ad5b3fd726f1218))
* lua-dev is now neodev ([b43d272](https://github.com/folke/neodev.nvim/commit/b43d2726829c0fe2d3950372e13177daaff14ea4))
* lua-dev now properly sets up jsonls for .luarc.json, the sumneko local config files ([fb62007](https://github.com/folke/neodev.nvim/commit/fb620072c444404b2b55e9a0d8ba6d6f9e2dac69))
* lua.txt doc parser ([0e7a16b](https://github.com/folke/neodev.nvim/commit/0e7a16b070c6be725573bc8cc2b0d69694cefc62))
* merge defs of vim._editor in `vim` ([858bcd6](https://github.com/folke/neodev.nvim/commit/858bcd6840fa9578d14915f05fc15ca9b0959517))
* merge in lspconfig options ([1f7ee38](https://github.com/folke/neodev.nvim/commit/1f7ee38d0f4e3972c3768e360979f5670aba2070))
* more luv annotations ([b50621a](https://github.com/folke/neodev.nvim/commit/b50621a868004292372d91a03c88923b36659d99))
* new options parser ([0c65251](https://github.com/folke/neodev.nvim/commit/0c65251ef6f93c795b6d44e339d97670a3500e8b))
* new parser ([42e9c51](https://github.com/folke/neodev.nvim/commit/42e9c5126904d6715ece660224610f3a38e4b8d4))
* new vim functions parser ([4d9ee97](https://github.com/folke/neodev.nvim/commit/4d9ee97048c6b541c363cc99dce24c3e77527631))
* only load missing functions from mpack on nightly. hidden functions ([f0bf928](https://github.com/folke/neodev.nvim/commit/f0bf928719bf1b7eb0ee905e787c29e9a332e25f))
* optionally supply a list of plugins to add to the workspace [#2](https://github.com/folke/neodev.nvim/issues/2) ([1fb6cc8](https://github.com/folke/neodev.nvim/commit/1fb6cc81ca98aab4d46ded1d39dcd29a44e48fcc))
* parse luv return values from docs ([107b7d9](https://github.com/folke/neodev.nvim/commit/107b7d9413b8134a72ea838a624679f5a4e4fdf9))
* proper typing for vim.g, vim.v, vim.b, vim.w and vim.t ([b16231e](https://github.com/folke/neodev.nvim/commit/b16231e7af55be112fcb867fd7b5eddf2993e9da))
* properly configure runtime.path to make require work for plugins (slow). Fixes [#23](https://github.com/folke/neodev.nvim/issues/23) ([274f72b](https://github.com/folke/neodev.nvim/commit/274f72b6bc5c199f6d2d33956f9aa0603d4c3367))
* properly parse optional params like (*opts) ([48cca93](https://github.com/folke/neodev.nvim/commit/48cca93b6d5da62db8da46c6d81b8fde2f4c8914))
* removed config.plugin_library in favor of config.override for easier customization ([46a2eb0](https://github.com/folke/neodev.nvim/commit/46a2eb009062bef889dd05913f92c2c11a57b189))
* replace code regions by markdown lua code blocks ([23df3f4](https://github.com/folke/neodev.nvim/commit/23df3f4f5403dbf24ccc1c8fc998db5298a0d377))
* rewrite with easier setup and configuration. Backward compatible, but refer to the docs to use the optimized setup ([ae74bc9](https://github.com/folke/neodev.nvim/commit/ae74bc9987638da2e122aaaf155d6519f07e6197))
* set correct default option ([e9e1da3](https://github.com/folke/neodev.nvim/commit/e9e1da34d8faa4843fd6d860bc12f552fe2e4a2a))
* snippet option for setup ([#47](https://github.com/folke/neodev.nvim/issues/47)) ([8553f1c](https://github.com/folke/neodev.nvim/commit/8553f1c89aa53d2e9bb94b728bdf3ebd0abb625d))
* types for nightly ([3e97b3e](https://github.com/folke/neodev.nvim/commit/3e97b3e87fae815863a6276e14af734102d28be8))
* types for stable ([499bc32](https://github.com/folke/neodev.nvim/commit/499bc3286050ec5bf2332ee8c6cd726e10e75e6f))
* updated all the docs for Neovim 0.6 ([1933c7e](https://github.com/folke/neodev.nvim/commit/1933c7e014e69484572b7fa1bf73bc51c42f10f4))
* updated docs to 0.7 ([6063731](https://github.com/folke/neodev.nvim/commit/60637315d665652c59a6a4f99a82f2308d11dd8f))
* updated emmy lua files ([5e6caa9](https://github.com/folke/neodev.nvim/commit/5e6caa92b83a07a516d481593344bed1e6eebd6a))
* util.error ([c771c04](https://github.com/folke/neodev.nvim/commit/c771c040cb63cdbd2f01ae8698befb64011bbe93))
* vim.fn functions ([b1e7776](https://github.com/folke/neodev.nvim/commit/b1e7776e4c7adeaa799002cb8ee25fecdc40f444))
* vim.lua for nightly ([cae3dfa](https://github.com/folke/neodev.nvim/commit/cae3dfa0380c9a08a27c947f7de5ee719e087ff2))
* vimdoc parser ([ac2a760](https://github.com/folke/neodev.nvim/commit/ac2a7601c8c5d2160512d74746286ea9f9580a09))
* when param name is string, and unknown type, then use string ([ddb8162](https://github.com/folke/neodev.nvim/commit/ddb816294b62d7ab76ecbe0f26f2bfb8aef4a5e1))
### Bug Fixes
* add correct neovim config directory when pathstrict ([d20c601](https://github.com/folke/neodev.nvim/commit/d20c601836c05039926cbfec0b895a3028af70af))
* add lua directories to workspace.library ([563e365](https://github.com/folke/neodev.nvim/commit/563e365b96ea5848e950e216929c08c69d3f4dda))
* add vim itself to globals ([2c9311b](https://github.com/folke/neodev.nvim/commit/2c9311b5e45b2ad71843e7e9d49ce31f59cca630))
* added .luarc.jsonc validation also to jsonls ([8e2f046](https://github.com/folke/neodev.nvim/commit/8e2f04638f9cb6c297d16c4feef85a6f7615fafb))
* added # for parameter docs ([3c7dfda](https://github.com/folke/neodev.nvim/commit/3c7dfda68549b6152bc0aa3c04f81a87ee9af9f9))
* added support for builtin libraries and meta/3rd libraries ([8d47e3a](https://github.com/folke/neodev.nvim/commit/8d47e3a488eb8a05f6699036f98f8a9a7f41776b))
* added vim.log.levels ([4331626](https://github.com/folke/neodev.nvim/commit/4331626b02f636433b504b9ab6a8c11fb9de4a24))
* alias `buffer` type ([#103](https://github.com/folke/neodev.nvim/issues/103)) ([23b58ff](https://github.com/folke/neodev.nvim/commit/23b58ff4e486d32fe9740dcdec0084ee419e1522))
* append on_new_config instead of replacing it ([cff0972](https://github.com/folke/neodev.nvim/commit/cff09720d23f84fa4ae46005857d7c5d7a1a4844))
* append to existing workspace.library instead of replacing ([b4bc26d](https://github.com/folke/neodev.nvim/commit/b4bc26d91ab17b84e8f15926c18b0c0abea3b690))
* better detection of nvim config and plugins where root-dir is incorrect ([d6212c1](https://github.com/folke/neodev.nvim/commit/d6212c1527bb5fb4dbb593318cd937ad2d4d6eee))
* better method of finding typed directory [#6](https://github.com/folke/neodev.nvim/issues/6) ([2e1a816](https://github.com/folke/neodev.nvim/commit/2e1a81633bab27e2535d1ccf5f47dda0ba49b0ce))
* better package path ([03a44ec](https://github.com/folke/neodev.nvim/commit/03a44ec6a54b0a025a633978e8541584a02e46d9))
* broke require path completion again ([9da602d](https://github.com/folke/neodev.nvim/commit/9da602d023ca1af73ac2ea3813798592c904566d))
* correctly process global_local options ([2815a2a](https://github.com/folke/neodev.nvim/commit/2815a2acb5a0cd9a11aaadb8256af15c7bf7d513))
* docs ([7b96f30](https://github.com/folke/neodev.nvim/commit/7b96f30ca6af998b4e3caa9c3886539e3ae83384))
* **docs:** update sumneko_lua setup example ([#67](https://github.com/folke/neodev.nvim/issues/67)) ([8b2b228](https://github.com/folke/neodev.nvim/commit/8b2b228673a88baa9267cb4a9ceb5862b5ee5df4))
* don't add arena parameters to functions ([99ee7f2](https://github.com/folke/neodev.nvim/commit/99ee7f21e07f9979b8cf14f24ce24d49aca11494))
* don't include lua docs in generated docs. They are correctly set up through `types/vim.lua` ([130b35e](https://github.com/folke/neodev.nvim/commit/130b35e0f671c5729d106a4fe113129cb979e4b1))
* don't skip anything from shared, otherwise builtin lua function docs are missing like notify ([24d8cf9](https://github.com/folke/neodev.nvim/commit/24d8cf99ccdaf8ef370f3f2165538fa296cd8122))
* dont add root_dir to workspace library. Fixes [#21](https://github.com/folke/neodev.nvim/issues/21) ([e958850](https://github.com/folke/neodev.nvim/commit/e9588503e68fa32ac08b83d9cb7e42ec31b8907d))
* fixed lua-dev schema for settings.nvim ([d6900dc](https://github.com/folke/neodev.nvim/commit/d6900dc94a40a3215d1a8debdaaa3036c3df17e5))
* fixed requiring files and require path ([3c18da8](https://github.com/folke/neodev.nvim/commit/3c18da83e7d4e4199857721301b9ec52bd99e487))
* get all the lua docs for internal lua functions ([6b0d9b0](https://github.com/folke/neodev.nvim/commit/6b0d9b0559defd9840402610824aeb9339ef1319))
* improved emmy lua annotations ([4f5a10f](https://github.com/folke/neodev.nvim/commit/4f5a10f192c1fc2b080afc852a85403b1296da8e))
* indentation from docs ([a4e5103](https://github.com/folke/neodev.nvim/commit/a4e5103fd91e9db6d9ac924df3fff94eaca8402a))
* line context ([fbcdd6d](https://github.com/folke/neodev.nvim/commit/fbcdd6da18c124aa0f36a5981302ff29cd644115))
* **luv:** also parse sync return values ([7b495ec](https://github.com/folke/neodev.nvim/commit/7b495ec693ad0bd42268f12f678fdeffa2f62b98))
* make options generation deterministic ([136ec0e](https://github.com/folke/neodev.nvim/commit/136ec0eceaef775147034e35c35ff80ad407b7da))
* more markdown code blocks ([5b620d9](https://github.com/folke/neodev.nvim/commit/5b620d9059d28ff75aadb50b9a2be80ba0b88272))
* more neodev renames ([d23076d](https://github.com/folke/neodev.nvim/commit/d23076d66ab87cf2d2feae7d5ff4f3cf4f0c754d))
* move settings to lua-dev ([c62617e](https://github.com/folke/neodev.nvim/commit/c62617ee4f15e04e0e5a96f3a824a3a1c838df53))
* mpack functions can have multiple docs ([2c2293c](https://github.com/folke/neodev.nvim/commit/2c2293cede37c19ca2cc8349fafaa8a7fe132f7d))
* multi-line comments for parameters ([acfa55b](https://github.com/folke/neodev.nvim/commit/acfa55b291c83e6fa40a006ea824d92d624c11b6))
* new settings.nvim API ([6477ca9](https://github.com/folke/neodev.nvim/commit/6477ca95d081e2b2397a993699c8ff643c632f85))
* options now have proper types ([d9bd9b4](https://github.com/folke/neodev.nvim/commit/d9bd9b488e83939e746b8150f2b684e72bb1275e))
* other way to prevent name change issues ([d3f7002](https://github.com/folke/neodev.nvim/commit/d3f70023d925b0c2e3084bb08a42aad3b2c2f027))
* parse incorrect function signatures with missing {} ([7eb0f15](https://github.com/folke/neodev.nvim/commit/7eb0f15fe8eaef3c4204e12cd3a94e183dd8f843))
* prepend "lua/" to package path ([b24f225](https://github.com/folke/neodev.nvim/commit/b24f22588eab04d604be7816cf5dfe09f96e7245))
* remove duplication of lua/ ([#66](https://github.com/folke/neodev.nvim/issues/66)) ([ec50266](https://github.com/folke/neodev.nvim/commit/ec50266039f0e71178be8c1d22211f48af498efe))
* remove root_dir from library. otherwise rename is broken ([b9b721a](https://github.com/folke/neodev.nvim/commit/b9b721a5bed76374ae7d96a6a211737954e241c7))
* remove vimconfig from workspace library. not needed [#1](https://github.com/folke/neodev.nvim/issues/1) ([0faabb9](https://github.com/folke/neodev.nvim/commit/0faabb95aec5af07f4416a8adb3ff6a218f6a855))
* replace `dict(something)` by `dict`, otherwise sumneko fails to render the hover ([4667d53](https://github.com/folke/neodev.nvim/commit/4667d535e7d811f5003bf57f786a0ce05ce6f516))
* replace invalid param name characters ([e5a553c](https://github.com/folke/neodev.nvim/commit/e5a553c6ffd661ab6f42be3f6992baf42f452445))
* resolve realpath of neovim config ([42eab7e](https://github.com/folke/neodev.nvim/commit/42eab7e0a7950f0322794a580ff10f56d1d15ee7))
* set proper runtime.path for require completion ([7840b31](https://github.com/folke/neodev.nvim/commit/7840b31c020c04076dde9fb9e45a9f653320b3e4))
* sort functions before writing ([72c4e61](https://github.com/folke/neodev.nvim/commit/72c4e61a6d69e9907c271893a0822142fda1facf))
* sort vim.fn functions before writing file ([cc55fd1](https://github.com/folke/neodev.nvim/commit/cc55fd1b8aa7da0d8f75e2fa711095388fc54f0f))
* sumneko library should be a list instead of a dict ([14004d2](https://github.com/folke/neodev.nvim/commit/14004d29ff2d408367b1e6757b0923e67e319325))
* types for stable ([901660d](https://github.com/folke/neodev.nvim/commit/901660d70dfa98f1afe9304bf8e580125f591f12))
* use correct key for special lsp library paths ([f879e53](https://github.com/folke/neodev.nvim/commit/f879e53f9d4efcc0035a3b395a66ac5794954c74))
* use default values for vim.opt ([#87](https://github.com/folke/neodev.nvim/issues/87)) ([66b67cf](https://github.com/folke/neodev.nvim/commit/66b67cf8833a98f5e4f92821e4320be82f160916))
* use existing library on settings.Lua.workspace ([cf3b028](https://github.com/folke/neodev.nvim/commit/cf3b028043e86e0e659568aede9d0c8273800b3e))
* use lazy.plugins() ([c87f3c9](https://github.com/folke/neodev.nvim/commit/c87f3c9ffb256846e2a51f0292537073ca62d4d0))
* workspace.library uses a map ([350b579](https://github.com/folke/neodev.nvim/commit/350b579498a7eeeab33f0ff6496e4fa1d807469a))
### Performance Improvements
* add /lua to plugin directories ([6bf74db](https://github.com/folke/neodev.nvim/commit/6bf74dbe456711d410b905fb5fb4acb87fb4ce0c))
* disable callSnippets for now. Too slow ([616b559](https://github.com/folke/neodev.nvim/commit/616b559dff0307adbe62606f806c2b568a6322d5))
* disable legacy setup mechanism, but still show warning ([82423f5](https://github.com/folke/neodev.nvim/commit/82423f569d51c79733f5599fb11fb8df46b324d6))
* dont use glob to find lua dirs. Check bufs instead. Fixes [#80](https://github.com/folke/neodev.nvim/issues/80) ([97ebf23](https://github.com/folke/neodev.nvim/commit/97ebf23c0d4f5a11f1d68a5abd468751b14980a1))
* remove runtime path again. way too slow ([e151df6](https://github.com/folke/neodev.nvim/commit/e151df68973b3aca4c88f6d602f89574d7d32200))

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,143 @@
# 💻 neodev.nvim
Neovim setup for init.lua and plugin development with full signature help, docs and
completion for the nvim lua API.
![image](https://user-images.githubusercontent.com/292349/201495543-ff532160-c8bd-4651-a16f-4fb682c9b945.png)
## ✨ Features
- Automatically configures **lua-language-server** for your **Neovim** config, **Neovim** runtime and plugin
directories
- [Annotations](https://github.com/LuaLS/lua-language-server/wiki/Annotations) for completion, hover and signatures of:
- Vim functions
- Neovim api functions
- `vim.opt`
- [vim.loop](https://github.com/luvit/luv)
- properly configures the `require` path.
- adds all plugins in `opt` and `start` to the workspace so you get completion
for all installed plugins
- properly configure the vim runtime
## ⚡️ Requirements
- Neovim >= 0.7.0
- completion plugin like [nvim-cmp](https://github.com/hrsh7th/nvim-cmp)
## 📦 Installation
Install the plugin with your preferred package manager:
### [lazy.nvim](https://github.com/folke/lazy.nvim)
```lua
{ "folke/neodev.nvim", opts = {} }
```
### [vim-plug](https://github.com/junegunn/vim-plug)
```vim
Plug 'folke/neodev.nvim'
```
## ⚙️ Configuration
**neodev** comes with the following defaults:
```lua
{
library = {
enabled = true, -- when not enabled, neodev will not change any settings to the LSP server
-- these settings will be used for your Neovim config directory
runtime = true, -- runtime path
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
plugins = true, -- installed opt or start plugins in packpath
-- you can also specify the list of plugins to make available as a workspace library
-- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
},
setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files
-- for your Neovim config directory, the config.library settings will be used as is
-- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled
-- for any other directory, config.library.enabled will be set to false
override = function(root_dir, options) end,
-- With lspconfig, Neodev will automatically setup your lua-language-server
-- If you disable this, then you have to set {before_init=require("neodev.lsp").before_init}
-- in your lsp start options
lspconfig = true,
-- much faster, but needs a recent built of lua-language-server
-- needs lua-language-server >= 3.6.0
pathStrict = true,
}
```
## 🚀 Setup
**neodev** will **ONLY** change the **lua_ls** settings for:
- your Neovim config directory
- your Neovim runtime directory
- any plugin directory (this is an lsp root_dir that contains a `/lua`
directory)
For any other `root_dir`, **neodev** will **NOT** change any settings.
> **TIP** with [neoconf.nvim](https://github.com/folke/neoconf.nvim), you can easily set project local **Neodev** settings.
> See the example [.neoconf.json](https://github.com/folke/neodev.nvim/blob/main/.neoconf.json) file in this repository
```lua
-- IMPORTANT: make sure to setup neodev BEFORE lspconfig
require("neodev").setup({
-- add any options here, or leave empty to use the default settings
})
-- then setup your lsp server as usual
local lspconfig = require('lspconfig')
-- example to setup lua_ls and enable call snippets
lspconfig.lua_ls.setup({
settings = {
Lua = {
completion = {
callSnippet = "Replace"
}
}
}
})
```
<details>
<summary>Example for setting up **neodev** that overrides the settings for `/etc/nixos`</summary>
```lua
-- You can override the default detection using the override function
-- EXAMPLE: If you want a certain directory to be configured differently, you can override its settings
require("neodev").setup({
override = function(root_dir, library)
if root_dir:find("/etc/nixos", 1, true) == 1 then
library.enabled = true
library.plugins = true
end
end,
})
```
</details>
It's possible to setup Neodev without lspconfig, by configuring the `before_init`
of the options passed to `vim.lsp.start`.
<details>
<summary>Example without lspconfig</summary>
```lua
-- dont run neodev.setup
vim.lsp.start({
name = "lua-language-server",
cmd = { "lua-language-server" },
before_init = require("neodev.lsp").before_init,
root_dir = vim.fn.getcwd(),
settings = { Lua = {} },
})
```
</details>

View File

@ -0,0 +1,163 @@
*lua-dev.txt* For NVIM v0.5.0 Last change: 2022 October 14
==============================================================================
Table of Contents *lua-dev-table-of-contents*
1. lua-dev |lua-dev-lua-dev|
- Features |lua-dev-features|
- Requirements |lua-dev-requirements|
- Installation |lua-dev-installation|
- Configuration |lua-dev-configuration|
- Setup |lua-dev-setup|
- How? |lua-dev-how?|
==============================================================================
1. lua-dev *lua-dev-lua-dev*
Dev setup for init.lua and plugin development with full signature help, docs
and completion for the nvim lua API.
<div class="figure">
<img src="https://user-images.githubusercontent.com/292349/118822916-6af02080-b86d-11eb-9990-942fe9b55541.png" title="fig:"/>
<p class="caption">image</p>
</div>
<div class="figure">
<img src="https://user-images.githubusercontent.com/292349/118823099-9115c080-b86d-11eb-9a68-521c6cb9905a.png" title="fig:"/>
<p class="caption">image</p>
</div>
FEATURES *lua-dev-features*
- Automatically configures **lua-language-server** for your **Neovim** config, **Neovim** runtime and plugin
directories
- Annotations <https://github.com/sumneko/lua-language-server/wiki/Annotations> for completion, hover and signatures of:
- Vim functions
- Neovim api functions
- `vim.opt`
- vim.loop <https://github.com/luvit/luv>
- properly configures the `require` path.
- adds all plugins in `opt` and `start` to the workspace so you get completion
for all installed plugins
- properly configure the vim runtime
REQUIREMENTS *lua-dev-requirements*
- Neovim >= 0.7.0
- completion plugin like nvim-cmp <https://github.com/hrsh7th/nvim-cmp>
INSTALLATION *lua-dev-installation*
Install the plugin with your preferred package manager:
PACKER <HTTPS://GITHUB.COM/WBTHOMASON/PACKER.NVIM> ~
>
use "folke/lua-dev.nvim"
<
VIM-PLUG <HTTPS://GITHUB.COM/JUNEGUNN/VIM-PLUG> ~
>
Plug 'folke/lua-dev.nvim'
<
CONFIGURATION *lua-dev-configuration*
**lua-dev** comes with the following defaults:
>
{
library = {
enabled = true, -- when not enabled, lua-dev will not change any settings to the LSP server
-- these settings will be used for your Neovim config directory
runtime = true, -- runtime path
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
plugins = true, -- installed opt or start plugins in packpath
-- you can also specify the list of plugins to make available as a workspace library
-- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
},
setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files
-- for your Neovim config directory, the config.library settings will be used as is
-- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled
-- for any other directory, config.library.enabled will be set to false
override = function(root_dir, options) end,
}
<
SETUP *lua-dev-setup*
**lua-dev** will **ONLY** change the **lua_ls** settings for:
- your Neovim config directory
- your Neovim runtime directory
- any plugin directory (this is an lsp root_dir that contains a `/lua`
directory)
For any other `root_dir`, **lua-dev** will **NOT** change any settings.
>
-- IMPORTANT: make sure to setup lua-dev BEFORE lspconfig
require("lua-dev").setup({
-- add any options here, or leave empty to use the default settings
})
-- then setup your lsp server as usual
local lspconfig = require('lspconfig')
-- example to setup sumneko and enable call snippets
lspconfig.lua_ls.setup({
settings = {
Lua = {
completion = {
callSnippet = "Replace"
}
}
}
})
<
Example for setting up **lua-dev** that overrides the settings for `/etc/nixos`
>
-- You can override the default detection using the override function
-- EXAMPLE: If you want a certain directory to be configured differently, you can override its settings
require("lua-dev").setup({
override = function(root_dir, library)
if require("lua-dev.util").has_file(root_dir, "/etc/nixos") then
library.enabled = true
library.plugins = true
end
end,
})
<
HOW? *lua-dev-how?*
**Neovim** includes a script
<https://github.com/neovim/neovim/blob/master/scripts/gen_vimdoc.py> to
generate the nvim docs. That script also creates message pack files containing
all the API metadata in a structured way. Unfortunately these files are not
packaged in the releases.
Using the message pack files, I converted all the API data to EmmyLua
annotations
<https://github.com/sumneko/lua-language-server/wiki/EmmyLua-Annotations> and
make them available for the Sumneko LSP
<https://github.com/sumneko/lua-language-server> as a workspace library.
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@ -0,0 +1,167 @@
*neodev.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 March 29
==============================================================================
Table of Contents *neodev.nvim-table-of-contents*
1. neodev.nvim |neodev.nvim-neodev.nvim|
- Features |neodev.nvim-neodev.nvim-features|
- Requirements |neodev.nvim-neodev.nvim-requirements|
- Installation |neodev.nvim-neodev.nvim-installation|
- Configuration |neodev.nvim-neodev.nvim-configuration|
- Setup |neodev.nvim-neodev.nvim-setup|
2. Links |neodev.nvim-links|
==============================================================================
1. neodev.nvim *neodev.nvim-neodev.nvim*
Neovim setup for init.lua and plugin development with full signature help, docs
and completion for the nvim lua API.
FEATURES *neodev.nvim-neodev.nvim-features*
- Automatically configures **lua-language-server** for your **Neovim** config, **Neovim** runtime and plugin
directories
- Annotations <https://github.com/LuaLS/lua-language-server/wiki/Annotations> for completion, hover and signatures of:
- Vim functions
- Neovim api functions
- `vim.opt`
- vim.loop <https://github.com/luvit/luv>
- properly configures the `require` path.
- adds all plugins in `opt` and `start` to the workspace so you get completion
for all installed plugins
- properly configure the vim runtime
REQUIREMENTS *neodev.nvim-neodev.nvim-requirements*
- Neovim >= 0.7.0
- completion plugin like nvim-cmp <https://github.com/hrsh7th/nvim-cmp>
INSTALLATION *neodev.nvim-neodev.nvim-installation*
Install the plugin with your preferred package manager:
LAZY.NVIM ~
>lua
{ "folke/neodev.nvim", opts = {} }
<
VIM-PLUG ~
>vim
Plug 'folke/neodev.nvim'
<
CONFIGURATION *neodev.nvim-neodev.nvim-configuration*
**neodev** comes with the following defaults:
>lua
{
library = {
enabled = true, -- when not enabled, neodev will not change any settings to the LSP server
-- these settings will be used for your Neovim config directory
runtime = true, -- runtime path
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
plugins = true, -- installed opt or start plugins in packpath
-- you can also specify the list of plugins to make available as a workspace library
-- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
},
setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files
-- for your Neovim config directory, the config.library settings will be used as is
-- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled
-- for any other directory, config.library.enabled will be set to false
override = function(root_dir, options) end,
-- With lspconfig, Neodev will automatically setup your lua-language-server
-- If you disable this, then you have to set {before_init=require("neodev.lsp").before_init}
-- in your lsp start options
lspconfig = true,
-- much faster, but needs a recent built of lua-language-server
-- needs lua-language-server >= 3.6.0
pathStrict = true,
}
<
SETUP *neodev.nvim-neodev.nvim-setup*
**neodev** will **ONLY** change the **lua_ls** settings for:
- your Neovim config directory
- your Neovim runtime directory
- any plugin directory (this is an lsp root_dir that contains a `/lua`
directory)
For any other `root_dir`, **neodev** will **NOT** change any settings.
**TIP** with neoconf.nvim <https://github.com/folke/neoconf.nvim>, you can
easily set project local **Neodev** settings. See the example .neoconf.json
<https://github.com/folke/neodev.nvim/blob/main/.neoconf.json> file in this
repository
>lua
-- IMPORTANT: make sure to setup neodev BEFORE lspconfig
require("neodev").setup({
-- add any options here, or leave empty to use the default settings
})
-- then setup your lsp server as usual
local lspconfig = require('lspconfig')
-- example to setup lua_ls and enable call snippets
lspconfig.lua_ls.setup({
settings = {
Lua = {
completion = {
callSnippet = "Replace"
}
}
}
})
<
Example for setting up **neodev** that overrides the settings for `/etc/nixos` ~
>lua
-- You can override the default detection using the override function
-- EXAMPLE: If you want a certain directory to be configured differently, you can override its settings
require("neodev").setup({
override = function(root_dir, library)
if root_dir:find("/etc/nixos", 1, true) == 1 then
library.enabled = true
library.plugins = true
end
end,
})
<
Its possible to setup Neodev without lspconfig, by configuring the
`before_init` of the options passed to `vim.lsp.start`.
Example without lspconfig ~
>lua
-- dont run neodev.setup
vim.lsp.start({
name = "lua-language-server",
cmd = { "lua-language-server" },
before_init = require("neodev.lsp").before_init,
root_dir = vim.fn.getcwd(),
settings = { Lua = {} },
})
<
==============================================================================
2. Links *neodev.nvim-links*
1. *image*: https://user-images.githubusercontent.com/292349/201495543-ff532160-c8bd-4651-a16f-4fb682c9b945.png
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@ -0,0 +1,6 @@
vim.notify(
"'lua-dev' was renamed to 'neodev'. Please update your config.",
vim.log.levels.WARN,
{ title = "neodev.nvim" }
)
return require("neodev")

View File

@ -0,0 +1,261 @@
---@class LuaParam
---@field name? string
---@field type? string
---@field doc? string
---@field optional? boolean
--- @class LuaFunction
--- @field name string,
--- @field doc string,
--- @field deprecated? boolean
--- @field overload? string[]
--- @field params LuaParam[]
--- @field return LuaParam[]
local M = {}
M.name2type = {
boolean = { "set" },
buffer = { "buffer", "bufid", "bufnr", "buf" },
window = { "win", "window", "winid", "winnr" },
number = { "col", "lnum", "tabnr", "nr", "pos", "ns", "index", "from", "to", "start", "stop", "end_", "integer" },
string = { "str", "text", "string" },
["table<string, any>"] = { "opt", "opts", "options", "dict", "dictionary" },
["fun()"] = { "fn", "function", "callback", "func", "funcref", "luaref" },
["any[]"] = { "args", "list", "array" },
["nil"] = { "void", "none" },
}
M.keywords =
{ "or", "and", "repeat", "function", "end", "return", "do", "break", "else", "elseif", "for", "goto", "if", "while" }
M.nvim_types = {
window = "integer",
buffer = "integer",
tabpage = "integer",
job = "number",
channel = "integer",
sends = "number",
blob = "number",
object = "any",
float = "number",
}
M.lua_types = {
["nil"] = "nil",
number = "number",
string = "string",
boolean = "boolean",
["function"] = "fun()",
table = "table",
}
function M.is_keyword(str)
return vim.tbl_contains(M.keywords, str)
end
---@param str string
---@param first? string
function M.comment(str, first)
first = first or ""
local prefix = "-- "
return first .. prefix .. str:gsub("\n", "\n" .. prefix)
end
---@param param LuaParam
function M.type(param)
local type = param.type and param.type ~= "" and param.type or "any"
if type == "any" then
for t, names in pairs(M.name2type) do
if vim.tbl_contains(names, param.name) then
return t
end
end
end
for t, names in pairs(M.name2type) do
if vim.tbl_contains(names, type) then
return t
end
end
if M.nvim_types[type] then
return type
end
if M.lua_types[type] then
return M.lua_types[type]
end
if type == "arrayof(string)" then
type = "string[]"
elseif type == "arrayof(integer, 2)" then
type = "number[]"
elseif type == "dictionaryof(luaref)" then
type = "table<string, luaref>"
elseif type:find("^arrayof%(") then
return "any[]"
elseif type:find("^dict%(") or type:find("^dictionaryof%(") then
return "table<string, any>"
end
return type
end
---@param param LuaParam
function M.param(param)
local parts = {}
if param.name then
if M.is_keyword(param.name) then
param.name = param.name .. "_"
end
table.insert(parts, param.name .. (param.optional and "?" or ""))
end
local type = M.type(param)
if type == "nil" then
return ""
end
if type then
table.insert(parts, type)
end
if param.doc then
table.insert(parts, "# " .. param.doc)
end
if not param.doc and type == "any" and not param.optional then
return ""
end
local ret = table.concat(parts, " ")
if not param.name then
return M.comment("@return " .. ret, "-") .. "\n"
else
return M.comment("@param " .. ret, "-") .. "\n"
end
end
function M.fqn(name)
local real_fn = vim.tbl_get(_G, unpack(vim.split(name, ".", { plain = true })))
if vim.api[name] then
return "vim.api." .. name
elseif vim[name] then
return "vim." .. name
elseif name:find("^[a-zA-Z_]+$") and vim.fn.exists("*" .. name) == 1 then
return "vim.fn." .. name
elseif name:find("^vim") and real_fn then
return name
end
-- if we get here, it means the function is RPC only, or no longer exists
end
function M.is_lua(name)
local real_fn = vim.tbl_get(_G, unpack(vim.split(name, ".", { plain = true })))
-- some plugins (like Noice) wrap api functions. This deals with that
if real_fn and name:find("vim%.api%.") then
return false
elseif type(real_fn) == "function" then
local info = debug.getinfo(real_fn, "S")
return info.what == "Lua"
elseif type(real_fn) == "table" then
return true
elseif not real_fn then
return true
end
return false
end
--- @param fun LuaFunction
function M.fun(fun)
local ret = ""
if fun.doc ~= "" then
-- make markdown lua code blocks for code regions
local ft = fun.name:find("vim.fn") and "vim" or "lua"
local lines = vim.split(fun.doc, "\n")
local l = 1
while l < #lines do
local line = lines[l]
local from, to, before, lang = line:find("^(%s*.*)>([a-z]*)%s*$")
if from then
before = (not before:find("^%s*$")) and before or nil
lang = lang ~= "" and lang or nil
for i = l + 1, #lines do
if lines[i]:find("^%S") or lines[i]:find("^%s*<") or i == #lines then
lines[l] = (before and (before .. "\n") or "") .. "```" .. (lang or ft)
if lines[i]:find("^%s*<%s*$") then
lines[i] = "```"
elseif lines[i]:find("^%s*<") then
lines[i] = "```\n" .. lines[i]:gsub("<", "")
else
lines[i] = lines[i] .. "\n```"
end
l = i
break
end
end
end
l = l + 1
end
local doc = table.concat(lines, "\n")
doc = M.fix_indent(doc)
ret = ret .. (M.comment(doc)) .. "\n"
end
if fun.seealso and #fun.seealso > 0 then
for _, also in ipairs(fun.seealso) do
ret = ret .. "--- @see " .. also .. "\n"
end
end
local params = {}
for _, param in pairs(fun.params) do
ret = ret .. M.param(param)
table.insert(params, param.name)
end
for _, r in pairs(fun["return"]) do
ret = ret .. M.param(r)
end
local signature = "function %s(%s) end"
-- handle special Lua names. Set as a field instead of a function
if M.is_keyword(fun.name:match("[^.]+$")) then
local prefix, name = fun.name:match("(.*)%.([^.]+)$")
fun.name = name
signature = prefix .. "[%q] = function(%s) end"
end
if fun.overload then
for _, overload in ipairs(fun.overload) do
ret = ret .. "--- @overload " .. overload .. "\n"
end
end
ret = ret .. signature:format(fun.name, table.concat(params, ", "))
return ret .. "\n\n"
end
---@param text string
function M.fix_indent(text)
local lines = vim.split(text, "\n")
local indent = 10
for l, line in ipairs(lines) do
if not (line:find("^%s*$") or line:find("^```")) then
line = line:gsub(" ", "\t")
lines[l] = line
local prefix = line:match("^\t+")
if prefix then
indent = math.min(indent, #prefix)
end
end
end
if indent > 0 then
for l, line in ipairs(lines) do
lines[l] = line:gsub("^" .. ("\t"):rep(indent), ""):gsub("\t", " ")
end
end
return table.concat(lines, "\n")
end
return M

View File

@ -0,0 +1,80 @@
local Annotations = require("neodev.build.annotations")
local Docs = require("neodev.build.docs")
---@class NvimApiInfo
---@field functions NvimApiFunction[]
---@class NvimApiFunction
---@field name string
---@field deprecated_since? number
---@field parameters {[1]: string, [2]:string}[]
---@field return_type string
---@field since number
---@field method? boolean
---@class LuaApiFunction: LuaFunction
---@field params_index? table<string, LuaParam>
---@field info? NvimApiFunction
local M = {}
---@return table<string, LuaFunction>
function M.get()
local functions = Docs.parse_functions("api", {
name = Annotations.fqn,
})
---@cast functions table<string, LuaApiFunction>
-- add params index
for _, fun in pairs(functions) do
fun.params_index = {}
for _, param in ipairs(fun.params) do
local name = param.name
if name then
fun.params_index[name] = param
end
end
end
---@type NvimApiInfo
local info = vim.fn.api_info()
-- add api info
for _, fun in ipairs(info.functions) do
if not fun.deprecated_since then
local name = Annotations.fqn(fun.name)
if name then
if not functions[name] then
functions[name] = {
doc = "",
name = name,
params = {},
params_index = {},
}
end
functions[name].info = fun
end
end
end
-- merge api info
for _, fun in pairs(functions) do
if fun.info then
for _, param in ipairs(fun.info.parameters) do
if fun.params_index[param[2]] then
fun.params_index[param[2]].type = param[1]:lower()
else
fun.params_index[param[2]] = { name = param[2], type = param[1]:lower() }
end
end
local return_type = fun.info.return_type:lower()
fun["return"] = { { type = return_type == "nil" and nil or return_type } }
end
end
return functions
end
M.get()
return M

View File

@ -0,0 +1,340 @@
local Util = require("neodev.util")
local Annotations = require("neodev.build.annotations")
local M = {}
M.function_pattern = "^(%S-%([^(]-%))"
M.function_signature_pattern = "^(%S-)%(([^(]-)%)"
M.vim_type_map = {
number = "number",
float = "float",
string = "string",
list = "any[]",
any = "any",
funcref = "fun()",
dict = "table<string, any>",
none = "nil",
set = "boolean",
boolean = "boolean",
}
---@param name string
function M.read(name)
local docs = vim.fn.expand("$VIMRUNTIME/doc")
local txtfile = docs .. "/" .. name .. ".txt"
---@type string[]
local lines = {}
for line in io.lines(txtfile) do
table.insert(lines, line)
end
return lines
end
---@return string, string[]
function M.strip_tags(str)
local tags = {}
return str
:gsub(
"(%*%S-%*)",
---@param tag string
function(tag)
tag = tag:sub(2, -2)
table.insert(tags, tag)
return ""
end
)
:gsub("%s*$", ""),
tags
end
---@param text string
function M.trim(text)
return text:gsub("^%s*\n", ""):gsub("\n+$", "")
end
---@param name string
---@param opts { pattern: string, continuation?: string, context?: number}
function M.parse(name, opts)
opts = opts or {}
opts.continuation = opts.continuation or "^[%s<>]"
opts.context = opts.context or 1
local tags = {}
local line_tags = {}
local chunk_tags = {}
local chunk_match = {}
local chunk = {}
---@type {tags:string[], text:string, match: string[]}[]
local ret = {}
local function save()
if #chunk > 0 then
table.insert(ret, {
tags = vim.deepcopy(chunk_tags),
text = M.trim(table.concat(chunk, "\n")),
match = vim.deepcopy(chunk_match),
})
end
chunk = {}
chunk_tags = {}
end
local lines = M.read(name)
for l, line in ipairs(lines) do
line, line_tags = M.strip_tags(line)
if #line_tags > 0 then
tags = line_tags
end
local context = line
for c = 1, opts.context do
if lines[l + c] then
context = context .. "\n" .. lines[l + c]
end
end
local match = { context:match(opts.pattern) }
if #match > 0 then
save()
chunk_match = match
chunk_tags = vim.deepcopy(tags)
table.insert(chunk, line)
elseif #chunk > 0 and (line:find(opts.continuation) or line:find("^%s*$")) then
table.insert(chunk, line)
else
save()
end
end
return ret
end
---@return {name: string, params: {name:string, optional?:boolean}[], doc: string}?
---@return LuaFunction?
function M.parse_signature(line)
---@type string, string, string
local name, sig, doc = line:match(M.function_signature_pattern .. "(.*)")
if name then
-- Parse args
local optional_from = sig:find("%[")
sig = sig:gsub("%[", "")
sig = sig:gsub("%]", "")
sig = sig:gsub("\n", " ")
sig = sig:gsub("\t", " ")
local params = {}
---@type table<string,boolean>
local index = {}
local from = 0
local to = 0
local param = ""
while from do
---@type number, number, string
from, to, param = sig:find("{?([^ ,{}]+)}?", to + 1)
if from then
local optional = optional_from and from >= optional_from and true or nil
if param:sub(1, 1) == "*" then
optional = true
param = param:sub(2)
end
param = param:gsub("%-", "_")
if param:find("^%d+$") then
param = "p" .. param
end
-- check for duplicate params
local p = param
local c = 1
while index[param] do
param = p .. c
c = c + 1
end
index[param] = true
table.insert(params, {
name = param,
optional = optional,
})
end
end
return { name = name, params = params, doc = M.trim(doc) }
end
end
function M.options()
---@type table<string, string>
local ret = {}
local option_pattern = "^'(%S-)'%s*"
local options = M.parse("options", { pattern = option_pattern })
for _, option in ipairs(options) do
local name = option.match[1]
local doc = option.text:gsub("'(%S-)'", "`'%1'` ")
ret[name] = doc
end
return ret
end
---@param doc string
---@param opts? {filter?: (fun(name:string):boolean), name?: (fun(name:string):string)}
function M.parse_functions(doc, opts)
opts = opts or {}
---@type table<string, LuaFunction>
local ret = {}
local functions = M.parse(doc, { pattern = M.function_pattern, context = 2 })
for _, fun in ipairs(functions) do
local text = fun.text
-- replace function name by the function tag, to make sure it is fully qualified
for _, tag in ipairs(fun.tags) do
if tag:find("vim.*%(%)$") then
tag = tag:sub(1, -3)
local name = text:match(M.function_signature_pattern)
if tag:sub(-#name) == name then
text = text:gsub("^%S-%(", tag .. "(")
end
end
end
local parse = M.parse_signature(text)
if parse then
local name = parse.name
if opts.name then
name = opts.name(name)
end
if name and (opts.filter == nil or opts.filter(name)) then
ret[name] = {
name = name,
params = parse.params,
doc = parse.doc,
["return"] = {},
}
end
end
end
return ret
end
function M.lua()
return M.parse_functions("lua", {
filter = function(name)
return not Annotations.is_lua(name)
end,
})
end
function M.luv()
local ret = M.parse_functions("luvref", {
filter = function(name)
return not Annotations.is_lua(name)
end,
name = function(name)
local ret = name:gsub("^uv%.", "vim.loop.")
return ret
end,
})
Util.for_each(ret, function(_, fun)
local returns = fun.doc:match("%s*Returns: (.*)\n")
if not returns then
returns = fun.doc:match("%s*Returns %(sync version%): (.*)\n")
end
---@type LuaParam
local retval = {}
if returns then
---@diagnostic disable-next-line: no-unknown
for t in returns:gmatch("`(.-)`") do
if t == "nil" or t == "fail" then
retval.optional = true
elseif not retval.type then
retval.type = t:find("userdata") and "userdata" or t
end
end
end
if not vim.tbl_isempty(retval) then
fun["return"] = { retval }
end
end)
return ret
end
function M.commands()
local pattern = "|:%S-|%s+:([a-z]%S-)%s+(.*)"
local builtins = M.parse("index", { pattern = pattern, context = 0, continuation = "^%s+" })
---@type table<string,string>
local ret = {}
for _, builtin in ipairs(builtins) do
if vim.tbl_contains(builtin.tags, "ex-cmd-index") then
local cmd = builtin.match[1]
local desc = builtin.match[2]
local i = cmd:find("%[")
if i then
ret[cmd:sub(1, i - 1)] = desc
cmd = cmd:gsub("[%[%]]", "")
end
ret[cmd] = desc
end
end
return ret
end
function M.functions()
local builtins = M.parse("builtin", { pattern = M.function_pattern, context = 2 })
---@type table<string, string>
local retvals = {}
-- Parse return values from `:h builtin-function-list`
for _, builtin in ipairs(builtins) do
if vim.tbl_contains(builtin.tags, "builtin-function-list") then
local text = builtin.text
-- replace any whitespace after the function by a tab character
text = text:gsub(M.function_pattern .. "%s+", "%1\t")
-- replace consecutive whitespace by tabs
text = text:gsub("%s%s+", "\t")
---@type string, string, string
local name, _args, retval = text:match(M.function_signature_pattern .. "\t(%w+)")
if name then
retval = retval:lower()
if M.vim_type_map[retval] then
retval = M.vim_type_map[retval]
if retval ~= "nil" then
retvals["vim.fn." .. name] = retval
end
else
Util.debug("Unknown retval: " .. retval)
end
else
Util.error("Couldnt parse builtin-function-list: " .. vim.inspect(builtin))
end
end
end
local ret = M.parse_functions("builtin", {
filter = function(name)
name = name:match("vim%.fn%.(.*)")
if name:find("%.") then
return false
end
return name and (vim.fn.exists("*" .. name) == 1)
end,
name = function(name)
return "vim.fn." .. name
end,
})
for k, fun in pairs(ret) do
if retvals[k] then
fun["return"] = { { type = retvals[k]:lower() } }
end
end
return ret
end
return M

View File

@ -0,0 +1,126 @@
local Config = require("neodev.config")
local Util = require("neodev.util")
local Annotations = require("neodev.build.annotations")
local Api = require("neodev.build.api")
local Docs = require("neodev.build.docs")
local Mpack = require("neodev.build.mpack")
local Writer = require("neodev.build.writer")
local Options = require("neodev.build.options")
local M = {}
function M.api()
local api = Api.get()
-- Only load mpack on nightly and add any missing functions
-- Typically hidden functions
if Config.version() == "nightly" then
local functions = Mpack.read("api.mpack")
for k, v in pairs(functions) do
if not api[k] then
api[k] = v
end
end
end
M.write("api", api)
end
---@return table<string, LuaFunction>, string?
function M.override(fname)
local override = Config.root("/types/override/" .. fname .. ".lua")
if override then
local code = Util.read_file(override)
local mod = {}
local mod_code = code:match("\n(return.*)") or code:match("^(return.*)")
if mod_code then
mod = load(mod_code)()
end
code = code:gsub("\nreturn.*", "")
code = code:gsub("^return.*", "")
return mod, code
end
return {}
end
---@param fname string
---@param functions table<string, LuaFunction>
function M.write(fname, functions)
local override, override_code = M.override(fname)
functions = vim.tbl_deep_extend("force", functions, override)
local writer = Writer(fname)
if override_code then
writer:write(override_code .. "\n\n")
end
Util.for_each(functions, function(_, fun)
writer:write(Annotations.fun(fun))
end)
writer:close()
end
function M.alias()
local writer = Writer("alias")
Util.for_each(Annotations.nvim_types, function(key, value)
writer:write(("---@alias %s %s"):format(key, value) .. "\n")
end)
writer:close()
end
function M.commands()
local writer = Writer("cmd")
Util.for_each(Docs.commands(), function(cmd, desc)
writer:write(Annotations.comment(desc) .. "\n")
if Annotations.is_keyword(cmd) then
writer:write(("vim.cmd[%q] = function(...)end"):format(cmd) .. "\n\n")
else
writer:write(("function vim.cmd.%s(...)end"):format(cmd) .. "\n\n")
end
end)
writer:close()
end
function M.clean()
local types = Config.types()
for _, f in pairs(vim.fn.expand(types .. "/*.lua", false, true)) do
if not f:find("/vim.lua", 1, true) then
vim.loop.fs_unlink(f)
end
end
end
function M.uv()
local writer = Writer("uv")
writer:write(Util.fetch("https://raw.githubusercontent.com/Bilal2453/luvit-meta/main/library/uv.lua"))
end
function M.lpeg()
local writer = Writer("lpeg")
writer:write(Util.fetch("https://raw.githubusercontent.com/LuaCATS/lpeg/main/library/lpeg.lua"))
end
function M.build()
M.clean()
M.uv()
M.alias()
M.commands()
if vim.fn.has("nvim-0.10") == 0 then
M.lpeg()
Options.build()
M.api()
-- M.write("luv", Docs.luv())
M.write("lua", Docs.lua())
M.write("vim.fn", Docs.functions())
end
end
M.build()
return M

View File

@ -0,0 +1,73 @@
local Annotations = require("neodev.build.annotations")
local util = require("neodev.util")
local M = {}
---@class MpackFunction
---@field doc string[]
---@field parameters {[1]: string, [2]:string}[]
---@field parameters_doc table<string, string>
---@field return string[]
---@field seealso string[]
---@field signature string
function M.read(mpack)
mpack = "data/" .. mpack
---@type table<string, MpackFunction>
local data = vim.mpack.decode(util.read_file(mpack))
---@type table<string, LuaFunction>
local ret = {}
for name, fun in pairs(data) do
name = Annotations.fqn(name)
if name then
ret[name] = M.process(name, fun)
end
end
return ret
end
---@param name string
--- @param fun MpackFunction
--- @return LuaFunction
function M.process(name, fun)
---@type LuaFunction
local ret = {
doc = (fun.doc and fun.doc[1]) and table.concat(fun.doc, "\n\n") or "",
name = name,
params = {},
seealso = fun.seealso or {},
["return"] = {},
}
for _, r in pairs(fun["return"]) do
table.insert(ret["return"], { doc = r })
end
for i, p in ipairs(fun.parameters or {}) do
local type = p[1]
local pname = p[2]
local param = { name = pname }
if type ~= "" then
param.type = type:lower()
end
param.doc = fun.parameters_doc and fun.parameters_doc[pname] or nil
if param.type and param.type:find("%*$") then
param.type = param.type:sub(1, -2)
param.optional = true
end
-- only include err param if it's documented
-- most nvim_ functions have an err param at the end, but these should not be included
local skip = i == #fun.parameters and (pname == "err" or pname == "error")
-- skip self params
if param.name == "self" or param.name == "" or param.name == "arena" then
skip = true
end
if not skip then
table.insert(ret.params, param)
end
end
return ret
end
return M

View File

@ -0,0 +1,106 @@
local Docs = require("neodev.build.docs")
local Writer = require("neodev.build.writer")
local Annotations = require("neodev.build.annotations")
local Util = require("neodev.util")
local Config = require("neodev.config")
---@class OptionInfo
---@field allows_duplicates boolean
---@field commalist boolean
---@field default any
---@field flaglist boolean
---@field global_local boolean
---@field name string
---@field scope "global" | "win" | "buf"
---@field shortname string
---@field type string
---@alias OptionsInfo table<string, OptionInfo>
local M = {}
M.metatype2lua = {
map = function(info)
return ("table<string, %s>"):format(info.type)
end,
set = function(info)
return ("%s[]"):format(info.type)
end,
array = function(info)
return ("%s[]"):format(info.type)
end,
}
function M.build()
local writer = Writer("options")
local docs = Docs.options()
---@type OptionsInfo
local info = vim.api.nvim_get_all_options_info()
---@param scope string
local function write(scope)
local var = "vim." .. scope:sub(1, 1) .. "o"
writer:write("---@class " .. var .. "\n")
writer:write(var .. " = {}\n\n")
Util.for_each(info, function(name, option)
if option.scope == scope then
local default = vim.inspect(option.default)
local str = ""
if docs[name] then
str = str .. Annotations.comment(docs[name]) .. "\n"
end
str = str .. ("%s.%s = %s\n"):format(var, name, default)
if option.shortname ~= "" then
str = str .. ("%s.%s = %s.%s\n"):format(var, option.shortname, var, name)
end
writer:write(str)
end
end)
writer:write("\n\n")
end
write("global")
write("win")
write("buf")
-- Write vim.opt
Util.for_each(info, function(name, option)
local str = ""
if docs[name] then
str = str .. Annotations.comment(docs[name]) .. "\n"
end
---@type string
local return_type = option.type
pcall(function()
---@diagnostic disable-next-line: no-unknown
return_type = vim.opt[name]._info.metatype
if M.metatype2lua[return_type] then
---@diagnostic disable-next-line: no-unknown
return_type = M.metatype2lua[return_type](option)
end
end)
str = str .. ("--- @class vim.opt.%s: vim.Option,%s\n"):format(name, return_type)
str = str .. ("--- @operator add: vim.opt.%s\n"):format(name)
str = str .. ("--- @operator sub: vim.opt.%s\n"):format(name)
str = str .. ("--- @operator pow: vim.opt.%s\n"):format(name)
str = str .. ("vim.opt.%s = %s\n"):format(name, vim.inspect(option.default))
if option.shortname ~= "" then
str = str .. ("vim.opt.%s = vim.opt.%s\n"):format(option.shortname, name)
end
str = str .. ("--- @return %s\nfunction vim.opt.%s:get()end\n\n"):format(return_type, name)
writer:write(str)
end)
local code = Util.read_file(Config.root("/types/override/options.lua"))
writer:write(code .. "\n")
writer:close()
end
return M

View File

@ -0,0 +1,53 @@
local config = require("neodev.config")
---@class AnnotationWriter
---@field name string
---@field fd? number
---@field fnum number
---@field size number
local M = {}
M.__index = M
M.MAX_SIZE = 1024 * 200
---@return AnnotationWriter
function M.new(name)
local self = setmetatable({}, M)
self.name = name
self.size = 0
self.fnum = 0
return self
end
function M:close()
if self.fd then
vim.loop.fs_close(self.fd)
end
end
function M:check()
if not self.fd or self.size > M.MAX_SIZE then
self:close()
local types = config.types()
local fname = types .. "/" .. self.name
if self.fnum > 0 then
fname = fname .. "." .. self.fnum
end
self.fd = vim.loop.fs_open(fname .. ".lua", "w+", 420)
self.fnum = self.fnum + 1
self.size = 0
self:intro()
end
end
function M:intro()
self:write("---@meta\n\n")
end
function M:write(text)
self:check()
vim.loop.fs_write(self.fd, text, -1)
self.size = self.size + #text
end
return M.new

View File

@ -0,0 +1,57 @@
local M = {}
--- @class LuaDevOptions
M.defaults = {
library = {
enabled = true, -- when not enabled, neodev will not change any settings to the LSP server
-- these settings will be used for your neovim config directory
runtime = true, -- runtime path
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
---@type boolean|string[]
plugins = true, -- installed opt or start plugins in packpath
-- you can also specify the list of plugins to make available as a workspace library
-- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
},
setup_jsonls = true, -- configures jsonls to provide completion for .luarc.json files
-- for your neovim config directory, the config.library settings will be used as is
-- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled
-- for any other directory, config.library.enabled will be set to false
override = function(root_dir, options) end,
-- With lspconfig, Neodev will automatically setup your lua-language-server
-- If you disable this, then you have to set {before_init=require("neodev.lsp").before_init}
-- in your lsp start options
lspconfig = true,
-- much faster, but needs a recent built of lua-language-server
-- needs lua-language-server >= 3.6.0
pathStrict = true,
debug = false,
}
--- @type LuaDevOptions
M.options = {}
function M.setup(options)
M.options = vim.tbl_deep_extend("force", {}, M.defaults, options or {})
end
function M.types()
return M.root("/types/" .. M.version())
end
---@param root? string
function M.root(root)
local f = debug.getinfo(1, "S").source:sub(2)
return vim.loop.fs_realpath(vim.fn.fnamemodify(f, ":h:h:h") .. "/" .. (root or ""))
end
---@return "nightly" | "stable"
function M.version()
return vim.version().prerelease and "nightly" or "stable"
end
---@return LuaDevOptions
function M.merge(options)
return vim.tbl_deep_extend("force", {}, M.options, options or {})
end
return M

View File

@ -0,0 +1,39 @@
local M = {}
local function neoconf(config)
pcall(function()
require("neoconf.plugins").register({
on_schema = function(schema)
schema:import("neodev", config.defaults)
schema:set("neodev.library.plugins", {
description = "true/false or an array of plugin names to enable",
anyOf = {
{ type = "boolean" },
{ type = "array", items = { type = "string" } },
},
})
end,
})
end)
end
---@param opts? LuaDevOptions
function M.setup(opts)
local config = require("neodev.config")
config.setup(opts)
if config.options.lspconfig then
require("neodev.lsp").setup()
end
neoconf(config)
-- leave this for now for backward compatibility
return {
settings = {
legacy = true,
},
}
end
return M

View File

@ -0,0 +1,115 @@
local util = require("neodev.util")
local M = {}
function M.setup()
local opts = require("neodev.config").options
local lsputil = require("lspconfig.util")
local hook = lsputil.add_hook_after
lsputil.on_setup = hook(lsputil.on_setup, function(config)
if opts.setup_jsonls and config.name == "jsonls" then
M.setup_jsonls(config)
end
if config.name == "lua_ls" then
config.on_new_config = hook(config.on_new_config, M.on_new_config)
-- config.before_init = hook(config.before_init, M.before_init)
end
end)
end
function M.setup_jsonls(config)
local schemas = config.settings.json and config.settings.json.schemas or {}
table.insert(schemas, {
name = "LuaLS Settings",
url = "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
fileMatch = { ".luarc.json", ".luarc.jsonc" },
})
config.settings = vim.tbl_deep_extend("force", config.settings, {
json = {
schemas = schemas,
validate = {
enable = true,
},
},
})
end
function M.before_init(params, config)
M.on_new_config(config, params.rootPath)
end
function M.on_new_config(config, root_dir)
-- don't do anything when old style setup was used
if config.settings.legacy then
util.warn(
"You're using the old way of setting up neodev (previously lua-dev).\nPlease check the docs at https://github.com/folke/neodev.nvim#-setup"
)
return
end
local lua_root = util.find_root()
local opts = require("neodev.config").merge()
opts.library.enabled = util.is_nvim_config()
if not opts.library.enabled and lua_root then
opts.library.enabled = true
opts.library.plugins = false
end
pcall(function()
opts = require("neoconf").get("neodev", opts, { file = root_dir })
end)
pcall(opts.override, root_dir, opts.library)
local library = config.settings
and config.settings.Lua
and config.settings.Lua.workspace
and config.settings.Lua.workspace.library
or {}
local ignoreDir = config.settings
and config.settings.Lua
and config.settings.Lua.workspace
and config.settings.Lua.workspace.ignoreDir
or {}
if opts.library.enabled then
config.handlers = vim.tbl_extend("force", {}, config.handlers or {})
config.handlers["workspace/configuration"] = config.handlers["workspace/configuration"]
or function(err, result, ctx, cfg)
local ret = vim.lsp.handlers["workspace/configuration"](err, result, ctx, cfg)
ret = vim.deepcopy(ret)
-- when scopeUri is not set, then the requested config is for the fallback scope
-- Don't set workspace libraries for the fallback scope
-- Thanks to: https://github.com/LuaLS/lua-language-server/issues/1596#issuecomment-1855087288
for i, item in ipairs(result.items) do
if type(ret[i]) == "table" then
if not item.scopeUri and ret[i].workspace then
ret[i].workspace.library = nil
end
end
end
return ret
end
config.settings =
vim.tbl_deep_extend("force", config.settings or {}, require("neodev.luals").setup(opts, config.settings).settings)
for _, lib in ipairs(library) do
table.insert(config.settings.Lua.workspace.library, lib)
end
if require("neodev.config").options.pathStrict and lua_root then
table.insert(config.settings.Lua.workspace.library, lua_root)
end
for _, dir in ipairs(ignoreDir) do
table.insert(config.settings.Lua.workspace.ignoreDir, dir)
end
end
end
return M

View File

@ -0,0 +1,110 @@
local config = require("neodev.config")
local M = {}
---@param opts LuaDevOptions
function M.library(opts)
opts = config.merge(opts)
local ret = {}
if opts.library.types then
table.insert(ret, config.types())
end
local function add(lib, filter)
---@diagnostic disable-next-line: param-type-mismatch
for _, p in ipairs(vim.fn.expand(lib .. "/lua", false, true)) do
local plugin_name = vim.fn.fnamemodify(p, ":h:t")
p = vim.loop.fs_realpath(p)
if p and (not filter or filter[plugin_name]) then
if config.options.pathStrict then
table.insert(ret, p)
else
table.insert(ret, vim.fn.fnamemodify(p, ":h"))
end
end
end
end
if opts.library.runtime then
add(type(opts.library.runtime) == "string" and opts.library.runtime or "$VIMRUNTIME")
end
if opts.library.plugins then
---@type table<string, boolean>
local filter
if type(opts.library.plugins) == "table" then
filter = {}
for _, p in pairs(opts.library.plugins) do
filter[p] = true
end
end
for _, site in pairs(vim.split(vim.o.packpath, ",")) do
add(site .. "/pack/*/opt/*", filter)
add(site .. "/pack/*/start/*", filter)
end
-- add support for lazy.nvim
if package.loaded["lazy"] then
for _, plugin in ipairs(require("lazy").plugins()) do
add(plugin.dir, filter)
end
end
end
return ret
end
---@param settings? lspconfig.settings.lua_ls
function M.path(settings)
if config.options.pathStrict then
return { "?.lua", "?/init.lua" }
end
settings = settings or {}
local runtime = settings.Lua and settings.Lua.runtime or {}
local meta = runtime.meta or "${version} ${language} ${encoding}"
meta = meta:gsub("%${version}", runtime.version or "LuaJIT")
meta = meta:gsub("%${language}", "en-us")
meta = meta:gsub("%${encoding}", runtime.fileEncoding or "utf8")
return {
-- paths for builtin libraries
("meta/%s/?.lua"):format(meta),
("meta/%s/?/init.lua"):format(meta),
-- paths for meta/3rd libraries
"library/?.lua",
"library/?/init.lua",
-- Neovim lua files, config and plugins
"lua/?.lua",
"lua/?/init.lua",
}
end
---@param opts? LuaDevOptions
---@param settings? lspconfig.settings.lua_ls
function M.setup(opts, settings)
opts = config.merge(opts)
return {
---@type lspconfig.settings.lua_ls
settings = {
Lua = {
runtime = {
version = "LuaJIT",
path = M.path(settings),
pathStrict = config.options.pathStrict,
},
---@diagnostic disable-next-line: undefined-field
completion = opts.snippet and { callSnippet = "Replace" } or nil,
workspace = {
-- Make the server aware of Neovim runtime files
library = M.library(opts),
-- when pathStrict=false, we need to add the other types to ignoreDir,
-- otherwise they get indexed
ignoreDir = { config.version() == "stable" and "types/nightly" or "types/stable", "lua" },
},
},
},
}
end
return M

View File

@ -0,0 +1,87 @@
local config = require("neodev.config")
local M = {}
--- find the root directory that has /lua
---@param path string?
---@return string?
function M.find_root(path)
path = path or vim.api.nvim_buf_get_name(0)
return vim.fs.find({ "lua" }, { path = path, upward = true, type = "directory" })[1]
end
function M.fetch(url)
local fd = io.popen(string.format("curl -s -k %q", url))
if not fd then
error(("Could not download %s"):format(url))
end
local ret = fd:read("*a")
fd:close()
return ret
end
function M.is_nvim_config()
local path = vim.loop.fs_realpath(vim.api.nvim_buf_get_name(0))
if path then
path = vim.fs.normalize(path)
local config_root = vim.loop.fs_realpath(vim.fn.stdpath("config")) or vim.fn.stdpath("config")
config_root = vim.fs.normalize(config_root)
return path:find(config_root, 1, true) == 1
end
return false
end
function M.keys(tbl)
local ret = vim.tbl_keys(tbl)
table.sort(ret)
return ret
end
---@generic K
---@generic V
---@param tbl table<K, V>
---@param fn fun(key: K, value: V)
function M.for_each(tbl, fn)
local keys = M.keys(tbl)
for _, key in ipairs(keys) do
fn(key, tbl[key])
end
end
---@param file string
---@param flags? string
---@return string
function M.read_file(file, flags)
local fd = io.open(file, "r" .. (flags or ""))
if not fd then
error(("Could not open file %s for reading"):format(file))
end
local data = fd:read("*a")
fd:close()
return data
end
function M.write_file(file, data)
local fd = io.open(file, "w+")
if not fd then
error(("Could not open file %s for writing"):format(file))
end
fd:write(data)
fd:close()
end
function M.debug(msg)
if config.options.debug then
M.error(msg)
end
end
function M.error(msg)
vim.notify_once(msg, vim.log.levels.ERROR, { title = "neodev.nvim" })
end
function M.warn(msg)
vim.notify_once(msg, vim.log.levels.WARN, { title = "neodev.nvim" })
end
return M

View File

@ -0,0 +1 @@
std="lua51+vim"

View File

@ -0,0 +1,3 @@
indent_type = "Spaces"
indent_width = 2
column_width = 120

View File

@ -0,0 +1,11 @@
---@meta
---@alias blob number
---@alias buffer integer
---@alias channel integer
---@alias float number
---@alias job number
---@alias object any
---@alias sends number
---@alias tabpage integer
---@alias window integer

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,40 @@
---@meta
vim = {}
---@type uv
vim.loop = {}
vim.F = require("vim.F")
vim.diagnostic = require("vim.diagnostic")
vim.filetype = require("vim.filetype")
vim.fs = require("vim.fs")
vim.health = require("vim.health")
vim.highlight = require("vim.highlight")
vim.inspect = require("vim.inspect").inspect
vim.iter = require("vim.iter")
vim.keymap = require("vim.keymap")
vim.lsp = require("vim.lsp")
vim.secure = require("vim.secure")
vim.treesitter = require("vim.treesitter")
vim.treesitter.highlighter = require("vim.treesitter.highlighter")
vim.treesitter.language = require("vim.treesitter.language")
vim.treesitter.query = require("vim.treesitter.query")
vim.ui = require("vim.ui")
vim.uri_from_bufnr = require("vim.uri").uri_from_bufnr
vim.uri_from_fname = require("vim.uri").uri_from_fname
vim.uri_to_bufnr = require("vim.uri").uri_to_bufnr
vim.uri_to_fname = require("vim.uri").uri_to_fname
vim.version = require("vim.version")
vim.lpeg = require("lpeg")
---@type table<string,any>
vim.g = {}
---@type table<string,any>
vim.v = {}
---@type table<number,table<string, any>>
vim.b = {}
---@type table<number,table<string, any>>
vim.w = {}
---@type table<number,table<string, any>>
vim.t = {}

View File

@ -0,0 +1,2 @@
---@class vim.api
vim.api = {}

View File

@ -0,0 +1,13 @@
return {
["vim.wait"] = {
params = {
{ name = "time", type = "number" },
{ name = "condition", type = "fun(): boolean", optional = true },
{ name = "interval", type = "number", optional = true },
{ name = "fast_only", type = "boolean", optional = true },
},
["return"] = {
{ type = "boolean, nil|number" },
},
},
}

View File

@ -0,0 +1,27 @@
---@type table<number, vim.go>
vim.go = {}
---@type table<number, vim.bo>
vim.bo = {}
---@type table<number, vim.wo>
vim.wo = {}
---@type vim.go | vim.wo | vim.bo
vim.o = {}
---@class vim.opt
vim.opt = {}
---@type vim.opt
vim.opt_global = {}
---@type vim.opt
vim.opt_local = {}
---@class vim.Option
local Option = {}
function Option:append(right) end
function Option:prepend(right) end
function Option:remove(right) end

View File

@ -0,0 +1,73 @@
return {
["vim.fn.getline"] = {
params = {
{ name = "lnum", type = "number|string" },
},
overload = {
"fun(lnum:number|string, end:number|string):string[]|nil[]",
},
["return"] = {
{ type = "string" },
},
},
["vim.fn.expand"] = {
params = {
{ name = "string", type = "string" },
{ name = "nosuf", type = "boolean", optional = true },
},
overload = {
"fun(string:string, nosuf?:boolean, list:true):string[]",
},
["return"] = {
{ type = "string" },
},
},
["vim.fn.glob"] = {
params = {
{ name = "expr", type = "string" },
{ name = "nosuf", type = "boolean", optional = true },
},
overload = {
"fun(expr:string, nosuf?:boolean, list:true):string[]",
"fun(expr:string, nosuf?:boolean, list:true, alllinks:true):string[]",
},
["return"] = {
{ type = "string" },
},
},
["vim.fn.sign_define"] = {
overload = {
"fun(name:string, dict?:table)",
},
},
["vim.fn.input"] = {
params = {
{ name = "opts", type = "string|table<string, any>" },
},
["return"] = {
{ type = "string" },
},
},
["vim.fn.searchpair"] = {
params = {
{ name = "start", type = "string" },
{ name = "middle", type = "string", optional = true },
{ name = "end", type = "string" },
{ name = "flags", type = "string", optional = true },
{ name = "skip", type = "string", optional = true },
{ name = "stopline", type = "number", optional = true },
{ name = "timeout", type = "number", optional = true },
},
},
["vim.fn.searchpairpos"] = {
params = {
{ name = "start", type = "string" },
{ name = "middle", type = "string", optional = true },
{ name = "end", type = "string" },
{ name = "flags", type = "string", optional = true },
{ name = "skip", type = "string", optional = true },
{ name = "stopline", type = "number", optional = true },
{ name = "timeout", type = "number", optional = true },
},
},
}

View File

@ -0,0 +1,11 @@
---@meta
---@alias blob number
---@alias buffer integer
---@alias channel integer
---@alias float number
---@alias job number
---@alias object any
---@alias sends number
---@alias tabpage integer
---@alias window integer

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,640 @@
---@meta
---
---@meta
---The definitions are developed in this repository: https://github.com/LuaCATS/lpeg
---
---This type definition is based on the [HTML documentation](http://www.inf.puc-rio.br/~roberto/lpeg/) of the LPeg library. A different HTML documentation can be found at http://stevedonovan.github.io/lua-stdlibs/modules/lpeg.html.
---
---*LPeg* is a new pattern-matching library for Lua,
---based on
---[Parsing Expression Grammars](https://bford.info/packrat/) (PEGs).
---This text is a reference manual for the library.
---For a more formal treatment of LPeg,
---as well as some discussion about its implementation,
---see
---[A Text Pattern-Matching Tool based on Parsing Expression Grammars](http://www.inf.puc-rio.br/~roberto/docs/peg.pdf).
---(You may also be interested in my
---[talk about LPeg](https://vimeo.com/1485123)
---given at the III Lua Workshop.)
---
---Following the Snobol tradition,
---LPeg defines patterns as first-class objects.
---That is, patterns are regular Lua values
---(represented by userdata).
---The library offers several functions to create
---and compose patterns.
---With the use of metamethods,
---several of these functions are provided as infix or prefix
---operators.
---On the one hand,
---the result is usually much more verbose than the typical
---encoding of patterns using the so called
---*regular expressions*
---(which typically are not regular expressions in the formal sense).
---On the other hand,
---first-class patterns allow much better documentation
---(as it is easy to comment the code,
---to break complex definitions in smaller parts, etc.)
---and are extensible,
---as we can define new functions to create and compose patterns.
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
local lpeg = {}
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
---@class Pattern
---@operator unm: Pattern
---@operator add(Pattern): Pattern
---@operator sub(Pattern): Pattern
---@operator mul(Pattern): Pattern
---@operator mul(Capture): Pattern
---@operator div(string): Capture
---@operator div(number): Capture
---@operator div(table): Capture
---@operator div(function): Capture
---@operator pow(number): Pattern
---@operator mod(function): nil
local Pattern = {}
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
---@alias Capture Pattern
---@operator add(Capture): Pattern
---@operator mul(Capture): Pattern
---@operator mul(Pattern): Pattern
---@operator div(string): Capture
---@operator div(number): Capture
---@operator div(table): Capture
---@operator div(function): Capture
---@operator pow(number): Pattern
---
---Match the given `pattern` against the `subject` string.
---
---If the match succeeds,
---returns the index in the subject of the first character after the match,
---or the captured values
---(if the pattern captured any value).
---
---An optional numeric argument `init` makes the match
---start at that position in the subject string.
---As usual in Lua libraries,
---a negative value counts from the end.
---
---Unlike typical pattern-matching functions,
---`match` works only in anchored mode;
---that is, it tries to match the pattern with a prefix of
---the given subject string (at position `init`),
---not with an arbitrary substring of the subject.
---So, if we want to find a pattern anywhere in a string,
---we must either write a loop in Lua or write a pattern that
---matches anywhere.
---This second approach is easy and quite efficient;
---
---__Example:__
---
---```lua
---local pattern = lpeg.R('az') ^ 1 * -1
---assert(pattern:match('hello') == 6)
---assert(lpeg.match(pattern, 'hello') == 6)
---assert(pattern:match('1 hello') == nil)
---```
---
---@param pattern Pattern
---@param subject string
---@param init? integer
---
---@return any ...
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.match(pattern, subject, init) end
---
---Match the given `pattern` against the `subject` string.
---
---If the match succeeds,
---returns the index in the subject of the first character after the match,
---or the captured values
---(if the pattern captured any value).
---
---An optional numeric argument `init` makes the match
---start at that position in the subject string.
---As usual in Lua libraries,
---a negative value counts from the end.
---
---Unlike typical pattern-matching functions,
---`match` works only in anchored mode;
---that is, it tries to match the pattern with a prefix of
---the given subject string (at position `init`),
---not with an arbitrary substring of the subject.
---So, if we want to find a pattern anywhere in a string,
---we must either write a loop in Lua or write a pattern that
---matches anywhere.
---This second approach is easy and quite efficient;
---
---__Example:__
---
---```lua
---local pattern = lpeg.R('az') ^ 1 * -1
---assert(pattern:match('hello') == 6)
---assert(lpeg.match(pattern, 'hello') == 6)
---assert(pattern:match('1 hello') == nil)
---```
---
---@param subject string
---@param init? integer
---
---@return any ...
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function Pattern:match(subject, init) end
---
---Return the string `"pattern"` if the given value is a pattern, otherwise `nil`.
---
---@return 'pattern'|nil
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.type(value) end
---
---Return a string with the running version of LPeg.
---
---@return string
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.version() end
---
---Set a limit for the size of the backtrack stack used by LPeg to
---track calls and choices.
---
---The default limit is `400`.
---Most well-written patterns need little backtrack levels and
---therefore you seldom need to change this limit;
---before changing it you should try to rewrite your
---pattern to avoid the need for extra space.
---Nevertheless, a few useful patterns may overflow.
---Also, with recursive grammars,
---subjects with deep recursion may also need larger limits.
---
---@param max integer
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.setmaxstack(max) end
---
---Convert the given value into a proper pattern.
---
---The following rules are applied:
---
---* If the argument is a pattern,
---it is returned unmodified.
---
---* If the argument is a string,
---it is translated to a pattern that matches the string literally.
---
---* If the argument is a non-negative number `n`,
---the result is a pattern that matches exactly `n` characters.
---
---* If the argument is a negative number `-n`,
---the result is a pattern that
---succeeds only if the input string has less than `n` characters left:
---`lpeg.P(-n)`
---is equivalent to `-lpeg.P(n)`
---(see the unary minus operation).
---
---* If the argument is a boolean,
---the result is a pattern that always succeeds or always fails
---(according to the boolean value),
---without consuming any input.
---
---* If the argument is a table,
---it is interpreted as a grammar
---(see Grammars).
---
---* If the argument is a function,
---returns a pattern equivalent to a
---match-time capture over the empty string.
---
---@param value Pattern|string|integer|boolean|table|function
---
---@return Pattern
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.P(value) end
---
---Return a pattern that
---matches only if the input string at the current position
---is preceded by `patt`.
---
---Pattern `patt` must match only strings
---with some fixed length,
---and it cannot contain captures.
---
---Like the `and` predicate,
---this pattern never consumes any input,
---independently of success or failure.
---
---@param pattern Pattern|string|integer|boolean|table
---
---@return Pattern
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.B(pattern) end
---
---Return a pattern that matches any single character
---belonging to one of the given ranges.
---
---Each `range` is a string `xy` of length 2,
---representing all characters with code
---between the codes of `x` and `y`
---(both inclusive).
---
---As an example, the pattern
---`lpeg.R('09')` matches any digit,
---and `lpeg.R('az', 'AZ')` matches any ASCII letter.
---
---__Example:__
---
---```lua
---local pattern = lpeg.R('az') ^ 1 * -1
---assert(pattern:match('hello') == 6)
---```
---
---@param ... string
---
---@return Pattern
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.R(...) end
---
---Return a pattern that matches any single character that
---appears in the given string.
---(The `S` stands for Set.)
---
---As an example, the pattern
---`lpeg.S('+-*/')` matches any arithmetic operator.
---
---Note that, if `s` is a character
---(that is, a string of length 1),
---then `lpeg.P(s)` is equivalent to `lpeg.S(s)`
---which is equivalent to `lpeg.R(s..s)`.
---Note also that both `lpeg.S('')` and `lpeg.R()`
---are patterns that always fail.
---
---@param string string
---
---@return Pattern
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.S(string) end
---
---Create a non-terminal (a variable) for a grammar.
---
---This operation creates a non-terminal (a variable)
---for a grammar.
---The created non-terminal refers to the rule indexed by `v`
---in the enclosing grammar.
---
---__Example:__
---
---```lua
---local b = lpeg.P({'(' * ((1 - lpeg.S '()') + lpeg.V(1)) ^ 0 * ')'})
---assert(b:match('((string))') == 11)
---assert(b:match('(') == nil)
---```
---
---@param v string|integer
---
---@return Pattern
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.V(v) end
---
---@class Locale
---@field alnum userdata
---@field alpha userdata
---@field cntrl userdata
---@field digit userdata
---@field graph userdata
---@field lower userdata
---@field print userdata
---@field punct userdata
---@field space userdata
---@field upper userdata
---@field xdigit userdata
---
---Return a table with patterns for matching some character classes
---according to the current locale.
---
---The table has fields named
---`alnum`,
---`alpha`,
---`cntrl`,
---`digit`,
---`graph`,
---`lower`,
---`print`,
---`punct`,
---`space`,
---`upper`, and
---`xdigit`,
---each one containing a correspondent pattern.
---Each pattern matches any single character that belongs to its class.
--
---If called with an argument `table`,
---then it creates those fields inside the given table and
---returns that table.
---
---__Example:__
---
---```lua
---lpeg.locale(lpeg)
---local space = lpeg.space ^ 0
---local name = lpeg.C(lpeg.alpha ^ 1) * space
---local sep = lpeg.S(',;') * space
---local pair = lpeg.Cg(name * '=' * space * name) * sep ^ -1
---local list = lpeg.Cf(lpeg.Ct('') * pair ^ 0, rawset)
---local t = list:match('a=b, c = hi; next = pi')
---assert(t.a == 'b')
---assert(t.c == 'hi')
---assert(t.next == 'pi')
---
---local locale = lpeg.locale()
---assert(type(locale.digit) == 'userdata')
---```
---
---@param tab? table
---
---@return Locale
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.locale(tab) end
---
---Create a simple capture.
---
---Creates a simple capture,
---which captures the substring of the subject that matches `patt`.
---The captured value is a string.
---If `patt` has other captures,
---their values are returned after this one.
---
---__Example:__
---
---```lua
---local function split (s, sep)
--- sep = lpeg.P(sep)
--- local elem = lpeg.C((1 - sep) ^ 0)
--- local p = elem * (sep * elem) ^ 0
--- return lpeg.match(p, s)
---end
---
---local a, b, c = split('a,b,c', ',')
---assert(a == 'a')
---assert(b == 'b')
---assert(c == 'c')
---```
---
---@param patt Pattern|string|integer|boolean|table|function
---
---@return Capture
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.C(patt) end
---
---Create an argument capture.
---
---This pattern matches the empty string and
---produces the value given as the nth extra
---argument given in the call to `lpeg.match`.
---
---@param n integer
---
---@return Capture
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.Carg(n) end
---
---Create a back capture.
---
---This pattern matches the empty string and
---produces the values produced by the most recent
---group capture named `name`
---(where `name` can be any Lua value).
---
---Most recent means the last
---complete
---outermost
---group capture with the given name.
---A Complete capture means that the entire pattern
---corresponding to the capture has matched.
---An Outermost capture means that the capture is not inside
---another complete capture.
---
---In the same way that LPeg does not specify when it evaluates captures,
---it does not specify whether it reuses
---values previously produced by the group
---or re-evaluates them.
---
---@param name any
---
---@return Capture
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.Cb(name) end
---
---Create a constant capture.
---
---This pattern matches the empty string and
---produces all given values as its captured values.
---
---@param ... any
---
---@return Capture
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.Cc(...) end
---
---Create a fold capture.
---
---If `patt` produces a list of captures
---C1 C2 ... Cn,
---this capture will produce the value
---`func(...func(func(C1, C2), C3)...,Cn)`,
---that is, it will fold
---(or accumulate, or reduce)
---the captures from `patt` using function `func`.
---
---This capture assumes that `patt` should produce
---at least one capture with at least one value (of any type),
---which becomes the initial value of an accumulator.
---(If you need a specific initial value,
---you may prefix a constant capture to `patt`.)
---For each subsequent capture,
---LPeg calls `func`
---with this accumulator as the first argument and all values produced
---by the capture as extra arguments;
---the first result from this call
---becomes the new value for the accumulator.
---The final value of the accumulator becomes the captured value.
---
---__Example:__
---
---```lua
---local number = lpeg.R('09') ^ 1 / tonumber
---local list = number * (',' * number) ^ 0
---local function add(acc, newvalue) return acc + newvalue end
---local sum = lpeg.Cf(list, add)
---assert(sum:match('10,30,43') == 83)
---```
---
---@param patt Pattern|string|number|boolean|table|function
---@param func fun(acc, newvalue): (acc: any)
---
---@return Capture
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.Cf(patt, func) end
---
---Create a group capture.
---
---It groups all values returned by `patt`
---into a single capture.
---The group may be anonymous (if no name is given)
---or named with the given name
---(which can be any non-nil Lua value).
---
---@param patt Pattern|string|number|boolean|table|function
---@param name? string
---
---@return Capture
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.Cg(patt, name) end
---
---Create a position capture.
---
---It matches the empty string and
---captures the position in the subject where the match occurs.
---The captured value is a number.
---
---__Example:__
---
---```lua
---local I = lpeg.Cp()
---local function anywhere(p) return lpeg.P({I * p * I + 1 * lpeg.V(1)}) end
---
---local match_start, match_end = anywhere('world'):match('hello world!')
---assert(match_start == 7)
---assert(match_end == 12)
---```
---
---@return Capture
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.Cp() end
---
---Create a substitution capture.
---
---This function creates a substitution capture,
---which captures the substring of the subject that matches `patt`,
---with substitutions.
---For any capture inside `patt` with a value,
---the substring that matched the capture is replaced by the capture value
---(which should be a string).
---The final captured value is the string resulting from
---all replacements.
---
---__Example:__
---
---```lua
---local function gsub (s, patt, repl)
--- patt = lpeg.P(patt)
--- patt = lpeg.Cs((patt / repl + 1) ^ 0)
--- return lpeg.match(patt, s)
---end
---assert(gsub('Hello, xxx!', 'xxx', 'World') == 'Hello, World!')
---```
---
---@param patt Pattern|string|number|boolean|table|function
---
---@return Capture
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.Cs(patt) end
---
---Create a table capture.
---
---This capture returns a table with all values from all anonymous captures
---made by `patt` inside this table in successive integer keys,
---starting at 1.
---Moreover,
---for each named capture group created by `patt`,
---the first value of the group is put into the table
---with the group name as its key.
---The captured value is only the table.
---
---@param patt Pattern|string|number|boolean|table|function
---
---@return Capture
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.Ct(patt) end
---
---Create a match-time capture.
---
---Unlike all other captures,
---this one is evaluated immediately when a match occurs
---(even if it is part of a larger pattern that fails later).
---It forces the immediate evaluation of all its nested captures
---and then calls `function`.
---
---The given function gets as arguments the entire subject,
---the current position (after the match of `patt`),
---plus any capture values produced by `patt`.
---
---The first value returned by `fn`
---defines how the match happens.
---If the call returns a number,
---the match succeeds
---and the returned number becomes the new current position.
---(Assuming a subject and current position `i`,
---the returned number must be in the range `[i, len(s) + 1]`.)
---If the call returns true,
---the match succeeds without consuming any input.
---(So, to return true is equivalent to return `i`.)
---If the call returns `false`, `nil`, or no value,
---the match fails.
---
---Any extra values returned by the function become the
---values produced by the capture.
---
---@param patt Pattern|string|number|boolean|table|function
---@param fn fun(s: string, i: integer, ...: any): (position: boolean|number, ...: any)
---
---@return Capture
---
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
function lpeg.Cmt(patt, fn) end
return lpeg

View File

@ -0,0 +1,310 @@
---@meta
-- Invokes |vim-function| or |user-function| {func} with arguments {...}.
-- See also |vim.fn|.
-- Equivalent to:
-- ```lua
-- vim.fn[func]({...})
-- ```
--- @param func fun()
function vim.call(func, ...) end
-- Run diff on strings {a} and {b}. Any indices returned by this function,
-- either directly or via callback arguments, are 1-based.
--
-- Examples:
-- ```lua
-- vim.diff('a\n', 'b\nc\n')
-- -- =>
-- -- @@ -1 +1,2 @@
-- -- -a
-- -- +b
-- -- +c
--
-- vim.diff('a\n', 'b\nc\n', {result_type = 'indices'})
-- -- =>
-- -- {
-- -- {1, 1, 1, 2}
-- -- }
-- ```
-- Parameters: ~
-- • {a} First string to compare
-- • {b} Second string to compare
-- • {opts} Optional parameters:
-- • `on_hunk` (callback):
-- Invoked for each hunk in the diff. Return a negative number
-- to cancel the callback for any remaining hunks.
-- Args:
-- • `start_a` (integer): Start line of hunk in {a}.
-- • `count_a` (integer): Hunk size in {a}.
-- • `start_b` (integer): Start line of hunk in {b}.
-- • `count_b` (integer): Hunk size in {b}.
-- • `result_type` (string): Form of the returned diff:
-- • "unified": (default) String in unified format.
-- • "indices": Array of hunk locations.
-- Note: This option is ignored if `on_hunk` is used.
-- • `linematch` (boolean|integer): Run linematch on the resulting hunks
-- from xdiff. When integer, only hunks upto this size in
-- lines are run through linematch. Requires `result_type = indices`,
-- ignored otherwise.
-- • `algorithm` (string):
-- Diff algorithm to use. Values:
-- • "myers" the default algorithm
-- • "minimal" spend extra time to generate the
-- smallest possible diff
-- • "patience" patience diff algorithm
-- • "histogram" histogram diff algorithm
-- • `ctxlen` (integer): Context length
-- • `interhunkctxlen` (integer):
-- Inter hunk context length
-- • `ignore_whitespace` (boolean):
-- Ignore whitespace
-- • `ignore_whitespace_change` (boolean):
-- Ignore whitespace change
-- • `ignore_whitespace_change_at_eol` (boolean)
-- Ignore whitespace change at end-of-line.
-- • `ignore_cr_at_eol` (boolean)
-- Ignore carriage return at end-of-line
-- • `ignore_blank_lines` (boolean)
-- Ignore blank lines
-- • `indent_heuristic` (boolean):
-- Use the indent heuristic for the internal
-- diff library.
--
-- Return: ~
-- See {opts.result_type}. nil if {opts.on_hunk} is given.
--- @param opts table<string, any>
function vim.diff(a, b, opts) end
-- The result is a String, which is the text {str} converted from
-- encoding {from} to encoding {to}. When the conversion fails `nil` is
-- returned. When some characters could not be converted they
-- are replaced with "?".
-- The encoding names are whatever the iconv() library function
-- can accept, see ":Man 3 iconv".
--
-- Parameters: ~
-- • {str} (string) Text to convert
-- • {from} (string) Encoding of {str}
-- • {to} (string) Target encoding
--
-- Returns: ~
-- Converted string if conversion succeeds, `nil` otherwise.
--- @param str string
--- @param from number
--- @param to number
--- @param opts? table<string, any>
function vim.iconv(str, from, to, opts) end
-- Returns true if the code is executing as part of a "fast" event handler,
-- where most of the API is disabled. These are low-level events (e.g.
-- |lua-loop-callbacks|) which can be invoked whenever Nvim polls for input.
-- When this is `false` most API functions are callable (but may be subject
-- to other restrictions such as |textlock|).
function vim.in_fast_event() end
-- Decodes (or "unpacks") the JSON-encoded {str} to a Lua object.
--
-- {opts} is a table with the key `luanil = { object: bool, array: bool }`
-- that controls whether `null` in JSON objects or arrays should be converted
-- to Lua `nil` instead of `vim.NIL`.
--- @param str string
--- @param opts? table<string, any>
function vim.json.decode(str, opts) end
-- Encodes (or "packs") Lua object {obj} as JSON in a Lua string.
function vim.json.encode(obj) end
-- Decodes (or "unpacks") the msgpack-encoded {str} to a Lua object.
--- @param str string
function vim.mpack.decode(str) end
-- Encodes (or "packs") Lua object {obj} as msgpack in a Lua string.
function vim.mpack.encode(obj) end
-- Parse the Vim regex {re} and return a regex object. Regexes are "magic"
-- and case-sensitive by default, regardless of 'magic' and 'ignorecase'.
-- They can be controlled with flags, see |/magic| and |/ignorecase|.
function vim.regex(re) end
-- Sends {event} to {channel} via |RPC| and returns immediately. If {channel}
-- is 0, the event is broadcast to all channels.
--
-- This function also works in a fast callback |lua-loop-callbacks|.
--- @param args? any[]
--- @param ...? any
function vim.rpcnotify(channel, method, args, ...) end
-- Sends a request to {channel} to invoke {method} via |RPC| and blocks until
-- a response is received.
--
-- Note: NIL values as part of the return value is represented as |vim.NIL|
-- special value
--- @param args? any[]
--- @param ...? any
function vim.rpcrequest(channel, method, args, ...) end
-- Schedules {callback} to be invoked soon by the main event-loop. Useful
-- to avoid |textlock| or other temporary restrictions.
--- @param callback fun()
function vim.schedule(callback) end
-- Check {str} for spelling errors. Similar to the Vimscript function
-- |spellbadword()|.
--
-- Note: The behaviour of this function is dependent on: 'spelllang',
-- 'spellfile', 'spellcapcheck' and 'spelloptions' which can all be local to
-- the buffer. Consider calling this with |nvim_buf_call()|.
--
-- Example:
-- ```lua
-- vim.spell.check("the quik brown fox")
-- -- =>
-- -- {
-- -- {'quik', 'bad', 5}
-- -- }
-- ```
-- Parameters: ~
-- • {str} String to spell check.
--
-- Return: ~
-- List of tuples with three items:
-- - The badly spelled word.
-- - The type of the spelling error:
-- "bad" spelling mistake
-- "rare" rare word
-- "local" word only valid in another region
-- "caps" word should start with Capital
-- - The position in {str} where the word begins.
--- @param str string
function vim.spell.check(str) end
-- Convert UTF-32 or UTF-16 {index} to byte index. If {use_utf16} is not
-- supplied, it defaults to false (use UTF-32). Returns the byte index.
--
-- Invalid UTF-8 and NUL is treated like by |vim.str_byteindex()|.
-- An {index} in the middle of a UTF-16 sequence is rounded upwards to
-- the end of that sequence.
--- @param str string
--- @param index number
--- @param use_utf16? any
function vim.str_byteindex(str, index, use_utf16) end
-- Convert byte index to UTF-32 and UTF-16 indices. If {index} is not
-- supplied, the length of the string is used. All indices are zero-based.
-- Returns two values: the UTF-32 and UTF-16 indices respectively.
--
-- Embedded NUL bytes are treated as terminating the string. Invalid UTF-8
-- bytes, and embedded surrogates are counted as one code point each. An
-- {index} in the middle of a UTF-8 sequence is rounded upwards to the end of
-- that sequence.
--- @param str string
--- @param index? number
function vim.str_utfindex(str, index) end
-- Compares strings case-insensitively. Returns 0, 1 or -1 if strings are
-- equal, {a} is greater than {b} or {a} is lesser than {b}, respectively.
function vim.stricmp(a, b) end
-- Attach to ui events, similar to |nvim_ui_attach()| but receive events
-- as lua callback. Can be used to implement screen elements like
-- popupmenu or message handling in lua.
--
-- {options} should be a dictionary-like table, where `ext_...` options should
-- be set to true to receive events for the respective external element.
--
-- {callback} receives event name plus additional parameters. See |ui-popupmenu|
-- and the sections below for event format for respective events.
--
-- WARNING: This api is considered experimental. Usability will vary for
-- different screen elements. In particular `ext_messages` behavior is subject
-- to further changes and usability improvements. This is expected to be
-- used to handle messages when setting 'cmdheight' to zero (which is
-- likewise experimental).
--
-- Example (stub for a |ui-popupmenu| implementation):
-- ```lua
--
-- ns = vim.api.nvim_create_namespace('my_fancy_pum')
--
-- vim.ui_attach(ns, {ext_popupmenu=true}, function(event, ...)
-- if event == "popupmenu_show" then
-- local items, selected, row, col, grid = ...
-- print("display pum ", #items)
-- elseif event == "popupmenu_select" then
-- local selected = ...
-- print("selected", selected)
-- elseif event == "popupmenu_hide" then
-- print("FIN")
-- end
-- end)
-- ```
--- @param ns number
--- @param options table<string, any>
--- @param callback fun()
function vim.ui_attach(ns, options, callback) end
-- Detach a callback previously attached with |vim.ui_attach()| for the
-- given namespace {ns}.
--- @param ns number
function vim.ui_detach(ns) end
-- Wait for {time} in milliseconds until {callback} returns `true`.
--
-- Executes {callback} immediately and at approximately {interval}
-- milliseconds (default 200). Nvim still processes other events during
-- this time.
--
-- Parameters: ~
-- • {time} Number of milliseconds to wait
-- • {callback} Optional callback. Waits until {callback} returns true
-- • {interval} (Approximate) number of milliseconds to wait between polls
-- • {fast_only} If true, only |api-fast| events will be processed.
-- If called from while in an |api-fast| event, will
-- automatically be set to `true`.
--
-- Returns: ~
-- If {callback} returns `true` during the {time}:
-- `true, nil`
--
-- If {callback} never returns `true` during the {time}:
-- `false, -1`
--
-- If {callback} is interrupted during the {time}:
-- `false, -2`
--
-- If {callback} errors, the error is raised.
--
-- Examples:
-- ```lua
--
-- ---
-- -- Wait for 100 ms, allowing other events to process
-- vim.wait(100, function() end)
--
-- ---
-- -- Wait for 100 ms or until global variable set.
-- vim.wait(100, function() return vim.g.waiting_for_var end)
--
-- ---
-- -- Wait for 1 second or until global variable set, checking every ~500 ms
-- vim.wait(1000, function() return vim.g.waiting_for_var end, 500)
--
-- ---
-- -- Schedule a function to set a value in 100ms
-- vim.defer_fn(function() vim.g.timer_result = true end, 100)
--
-- -- Would wait ten seconds if results blocked. Actually only waits 100 ms
-- if vim.wait(10000, function() return vim.g.timer_result end) then
-- print('Only waiting a little bit of time!')
-- end
-- ```
--- @param time number
--- @param condition? fun(): boolean
--- @param interval? number
--- @param fast_only? boolean
--- @return boolean, nil|number
function vim.wait(time, condition, interval, fast_only) end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,40 @@
---@meta
vim = {}
---@type uv
vim.loop = {}
vim.F = require("vim.F")
vim.diagnostic = require("vim.diagnostic")
vim.filetype = require("vim.filetype")
vim.fs = require("vim.fs")
vim.health = require("vim.health")
vim.highlight = require("vim.highlight")
vim.inspect = require("vim.inspect").inspect
vim.iter = require("vim.iter")
vim.keymap = require("vim.keymap")
vim.lsp = require("vim.lsp")
vim.secure = require("vim.secure")
vim.treesitter = require("vim.treesitter")
vim.treesitter.highlighter = require("vim.treesitter.highlighter")
vim.treesitter.language = require("vim.treesitter.language")
vim.treesitter.query = require("vim.treesitter.query")
vim.ui = require("vim.ui")
vim.uri_from_bufnr = require("vim.uri").uri_from_bufnr
vim.uri_from_fname = require("vim.uri").uri_from_fname
vim.uri_to_bufnr = require("vim.uri").uri_to_bufnr
vim.uri_to_fname = require("vim.uri").uri_to_fname
vim.version = require("vim.version")
vim.lpeg = require("lpeg")
---@type table<string,any>
vim.g = {}
---@type table<string,any>
vim.v = {}
---@type table<number,table<string, any>>
vim.b = {}
---@type table<number,table<string, any>>
vim.w = {}
---@type table<number,table<string, any>>
vim.t = {}

View File

@ -0,0 +1,2 @@
[vim]
any = true