github github
stars 2,012
issues 30
subscribers 12
forks 58



18 days ago

💻 neodev.nvim

Development of neodev.nvim is now EOL. If you're on Neovim >= 0.10, then I highly suggest you to use lazydev.nvim It's a much faster and better replacement for neodev.

Neovim setup for init.lua and plugin development with full signature help, docs and completion for the nvim lua API.


✨ 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

  • Neovim >= 0.7.0
  • completion plugin like nvim-cmp

📦 Installation

Install the plugin with your preferred package manager:


{ "folke/neodev.nvim", opts = {} }


Plug 'folke/neodev.nvim'

⚙️ Configuration

neodev comes with the following 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
    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, you can easily set project local Neodev settings. See the example .neoconf.json file in this repository

-- IMPORTANT: make sure to setup neodev BEFORE lspconfig
  -- 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
  settings = {
    Lua = {
      completion = {
        callSnippet = "Replace"
-- 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
  override = function(root_dir, library)
    if root_dir:find("/etc/nixos", 1, true) == 1 then
      library.enabled = true
      library.plugins = true

It's possible to setup Neodev without lspconfig, by configuring the before_init of the options passed to vim.lsp.start.

-- dont run neodev.setup
  name = "lua-language-server",
  cmd = { "lua-language-server" },
  before_init = require("neodev.lsp").before_init,
  root_dir = vim.fn.getcwd(),
  settings = { Lua = {} },