*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.

image

image

FEATURES *lua-dev-features* - Automatically configures **lua-language-server** for your **Neovim** config, **Neovim** runtime and plugin directories - Annotations for completion, hover and signatures of: - Vim functions - Neovim api functions - `vim.opt` - vim.loop - 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 INSTALLATION *lua-dev-installation* Install the plugin with your preferred package manager: PACKER ~ > use "folke/lua-dev.nvim" < 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 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 and make them available for the Sumneko LSP as a workspace library. Generated by panvimdoc vim:tw=78:ts=8:noet:ft=help:norl: