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