Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
fix(lua functions): vim.api should be used, if possible
Browse files Browse the repository at this point in the history
also hint why `vim.call` exists to prevent usage

fixes #6
  • Loading branch information
matu3ba authored and nanotee committed Feb 22, 2021
1 parent 29848a9 commit 2895446
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -779,13 +779,17 @@ For example, hashes (`#`) are not valid characters for indentifiers in Lua, so a
vim.fn['my#autoload#function']()
```

The functionality of `vim.fn` is identical to `vim.call`, but allows a more Lua-like syntax.

See also:
- `:help vim.fn`

#### Tips

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 API functions should be used directly through `vim.api.{..}`. For example, use `vim.api.nvim_list_uis()` instead of `vim.fn.nvim_list_uis`. See `:help api` for information.

#### Caveats

Some Vim functions that should return a boolean return `1` or `0` instead. This isn't a problem in Vimscript as `1` is truthy and `0` falsy, enabling constructs like these:
Expand Down

0 comments on commit 2895446

Please sign in to comment.