update options section

Addresses part of #63, will add `vim.opt` later
This commit is contained in:
Timothée Sterle 2021-05-29 10:38:16 +02:00
parent 209b2ef924
commit 40d7b056a9
No known key found for this signature in database
GPG Key ID: 136D558122196ED5
2 changed files with 10 additions and 29 deletions

View File

@ -579,15 +579,16 @@ print(vim.api.nvim_buf_get_option(10, 'shiftwidth')) -- 4
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: 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}`: global options - `vim.o.{option}`: behaves like `:set`
- `vim.bo.{option}`: buffer-local options - `vim.go.{option}`: behaves like `:setglobal`
- `vim.wo.{option}`: window-local options - `vim.bo.{option}`: behaves like `:setlocal` for buffer-local options
- `vim.wo.{option}`: behaves like `:setlocal` for window-local options
```lua ```lua
vim.o.smarttab = false vim.o.smarttab = false
print(vim.o.smarttab) -- false print(vim.o.smarttab) -- false
vim.o.isfname = vim.o.isfname .. ',@-@' -- on Linux: set isfname+=@-@ vim.o.isfname = vim.o.isfname .. ',@-@' -- on Linux: set isfname+=@-@
print(vim.o.listchars) -- '@,48-57,/,.,-,_,+,,,#,$,%,~,=,@-@' print(vim.o.isfname) -- '@,48-57,/,.,-,_,+,,,#,$,%,~,=,@-@'
vim.bo.shiftwidth = 4 vim.bo.shiftwidth = 4
print(vim.bo.shiftwidth) -- 4 print(vim.bo.shiftwidth) -- 4
@ -603,15 +604,6 @@ vim.wo.number = true -- same as vim.api.nvim_win_set_option(0, 'number', true)
See also: See also:
- `:help lua-vim-options` - `:help lua-vim-options`
#### Caveats
There is no equivalent to the `:set` command in Lua, you either set an option globally or locally. If you're setting options from your `init.lua`, some of them will require you to set both `vim.o.{option}` and `vim.{wo/bo}.{option}` to work properly.
See also:
- `:help :setglobal`
- `:help global-local`
- [Pull request #13479](https://github.com/neovim/neovim/pull/13479)
## Managing vim internal variables ## Managing vim internal variables
### Using api functions ### Using api functions

View File

@ -714,15 +714,16 @@ 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 "idiomatic" way. They essentially wrap the above API functions and allow
you to manipulate options as if they were variables: you to manipulate options as if they were variables:
- `vim.o.{option}`: global options - `vim.o.{option}`: behaves like `:set`
- `vim.bo.{option}`: buffer-local options - `vim.go.{option}`: behaves like `:setglobal`
- `vim.wo.{option}`: window-local options - `vim.bo.{option}`: behaves like `:setlocal` for buffer-local options
- `vim.wo.{option}`: behaves like `:setlocal` for window-local options
> >
vim.o.smarttab = false vim.o.smarttab = false
print(vim.o.smarttab) -- false print(vim.o.smarttab) -- false
vim.o.isfname = vim.o.isfname .. ',@-@' -- on Linux: set isfname+=@-@ vim.o.isfname = vim.o.isfname .. ',@-@' -- on Linux: set isfname+=@-@
print(vim.o.listchars) -- '@,48-57,/,.,-,_,+,,,#,$,%,~,=,@-@' print(vim.o.isfname) -- '@,48-57,/,.,-,_,+,,,#,$,%,~,=,@-@'
vim.bo.shiftwidth = 4 vim.bo.shiftwidth = 4
print(vim.bo.shiftwidth) -- 4 print(vim.bo.shiftwidth) -- 4
@ -741,18 +742,6 @@ no number is given, the current buffer/window is used:
See also: See also:
- |lua-vim-options| - |lua-vim-options|
Caveats~
There is no equivalent to the `:set` command in Lua, you either set
an option globally or locally. If you're setting options from your
`init.lua`, some of them will require you to set both `vim.o.{option}`
and `vim.{wo/bo}.{option}` to work properly.
See also:
- |:setglobal|
- |global-local|
- Pull request #13479: https://github.com/neovim/neovim/pull/13479
============================================================================== ==============================================================================
MANAGING VIM INTERNAL VARIABLES MANAGING VIM INTERNAL VARIABLES
*luaguide-managing-vim-internal-variables* *luaguide-managing-vim-internal-variables*