@ -60,7 +60,7 @@ Neovim supports loading an `init.lua` file for configuration instead of the usua
Note: `init.lua` is of course *completely* optional. Support for `init.vim` is not going away and is still a valid option for configuration. Do keep in mind that some features are not 100% exposed to Lua yet.
@ -235,13 +235,13 @@ Neovim provides 3 Ex commands to source Lua files
:1,10source
```
`:runtime` is a little different: it uses the `'runtimepath'` option to determine which files to source. See `:help :runtime` for more details
`:runtime` is a little different: it uses the `'runtimepath'` option to determine which files to source. See [`:help :runtime`](https://neovim.io/doc/user/repeat.html#:runtime) for more details.
You can get Lua syntax highlighting inside .vim files by putting `let g:vimsyn_embed = 'l'` in your configuration file. See `:help g:vimsyn_embed` for more on this option.
You can get Lua syntax highlighting inside .vim files by putting `let g:vimsyn_embed = 'l'` in your configuration file. See [`:help g:vimsyn_embed`](https://neovim.io/doc/user/syntax.html#g:vimsyn_embed) for more on this option.
## The vim namespace
@ -395,7 +395,7 @@ Some notable functions and modules include:
- `vim.lsp`: module that controls the built-in LSP client
- `vim.treesitter`: module that exposes the functionality of the tree-sitter library
This list is by no means comprehensive. If you wish to know more about what's made available by the `vim` variable, `:help lua-stdlib` and `:help lua-vim` are the way to go. Alternatively, you can do `:lua print(vim.inspect(vim))` to get a list of every module.
This list is by no means comprehensive. If you wish to know more about what's made available by the `vim` variable, [`:help lua-stdlib`](https://neovim.io/doc/user/lua.html#lua-stdlib) and [`:help lua-vim`](https://neovim.io/doc/user/lua.html#lua-vim) are the way to go. Alternatively, you can do `:lua print(vim.inspect(vim))` to get a list of every module.
A few meta-accessors are available if you want to set options in a more "idiomatic" way. They essentially wrap the above API functions and allow you to manipulate options as if they were variables:
- `vim.o.{option}`: behaves like `:set`
- `vim.go.{option}`: behaves like `:setglobal`
- `vim.bo.{option}`: behaves like `:setlocal` for buffer-local options
- `vim.wo.{option}`: behaves like `:setlocal` for window-local options
- [`vim.o.{option}`](https://neovim.io/doc/user/lua.html#vim.o): behaves like `:set`
- [`vim.go.{option}`](https://neovim.io/doc/user/lua.html#vim.go): behaves like `:setglobal`
- [`vim.bo.{option}`](https://neovim.io/doc/user/lua.html#vim.bo): behaves like `:setlocal` for buffer-local options
- [`vim.wo.{option}`](https://neovim.io/doc/user/lua.html#vim.wo): behaves like `:setlocal` for window-local options
With the exception of predefined Vim variables, they can also be deleted (the `:unlet` command is the equivalent in Vimscript). Local variables (`l:`), script variables (`s:`) and function arguments (`a:`) cannot be manipulated as they only make sense in the context of a Vim script, Lua has its own scoping rules.
If you are unfamiliar with what these variables do, `:help internal-variables` describes them in detail.
If you are unfamiliar with what these variables do, [`:help internal-variables`](https://neovim.io/doc/user/eval.html#internal-variables) describes them in detail.
These functions take a string containing the name of the variable to set/get/delete as well as the value you want to set it to.
@ -819,13 +819,13 @@ The functionality of `vim.fn` is identical to `vim.call`, but allows a more Lua-
It is distinct from `vim.api.nvim_call_function` in that converting Vim/Lua objects is automatic: `vim.api.nvim_call_function` returns a table for floating point numbers and does not accept Lua closures while `vim.fn` handles these types transparently.
Neovim has an extensive library of powerful built-in functions that are very useful for plugins. See `:help vim-function` for an alphabetical list and `:help function-list` for a list of functions grouped by topic.
Neovim has an extensive library of powerful built-in functions that are very useful for plugins. See [`:help vim-function`](https://neovim.io/doc/user/eval.html#vim-function) for an alphabetical list and [`:help function-list`](https://neovim.io/doc/user/usr_41.html#function-list) for a list of functions grouped by topic.
Neovim API functions can be used directly through `vim.api.{..}`. See `:help api` for information.
Neovim API functions can be used directly through `vim.api.{..}`. See [`:help api`](https://neovim.io/doc/user/api.html#API) for information.
#### Caveats
@ -850,13 +850,13 @@ end
Neovim provides a list of API functions to set, get and delete mappings:
Let's start with `vim.api.nvim_set_keymap()` and `vim.api.nvim_buf_set_keymap()`
@ -880,7 +880,7 @@ The second argument is a string containing the left-hand side of the mapping (th
The third argument is a string containing the right-hand side of the mapping (the command to execute).
The final argument is a table containing boolean options for the mapping as defined in `:help :map-arguments` (including `noremap` and excluding `buffer`).
The final argument is a table containing boolean options for the mapping as defined in [`:help :map-arguments`](https://neovim.io/doc/user/map.html#:map-arguments) (including `noremap` and excluding `buffer`).
Buffer-local mappings also take a buffer number as their first argument (`0` sets the mapping for the current buffer).
@ -935,6 +935,7 @@ For the time being, you're probably better off creating commands in Vimscript.
Augroups and autocommands do not have an interface yet but it is being worked on:
- [Pull request #14661](https://github.com/neovim/neovim/pull/14661) (lua: autocmds take 2)
In the meantime, you can either create autocommands in Vimscript or use [this wrapper from norcalli/nvim_utils](https://github.com/norcalli/nvim_utils/blob/master/lua/nvim_utils.lua#L554-L567)
@ -944,7 +945,7 @@ The syntax API is still a work in progress. Here are a couple of pointers:
`vim.lsp` is the module that controls the built-in LSP client. The [neovim/nvim-lspconfig](https://github.com/neovim/nvim-lspconfig/) repository contains default configurations for popular language servers.
The behavior of the client can be configured using "lsp-handlers". For more information:
@ -1135,7 +1136,7 @@ Probably one of the most well-known transpilers for Lua. Adds a lots of convenie
- [Fennel](https://fennel-lang.org/)
A lisp that compiles to Lua. You can write configuration and plugins for Neovim in Fennel with the [Olical/aniseed](https://github.com/Olical/aniseed) plugin. Additionally, the [Olical/conjure](https://github.com/Olical/conjure) plugin provides an interactive development environment that supports Fennel (among other languages).
A lisp that compiles to Lua. You can write configuration and plugins for Neovim in Fennel with the [Olical/aniseed](https://github.com/Olical/aniseed) or the [Hotpot](https://github.com/rktjmp/hotpot.nvim) plugin. Additionally, the [Olical/conjure](https://github.com/Olical/conjure) plugin provides an interactive development environment that supports Fennel (among other languages).