-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vim._with()
does not properly restore global-local options
#29253
Comments
I think the better design might be to have explicit |
I'm cautiously optimistic about this suggestion. My only worry is that it will sacrifice convenience over maximal flexibility. I assume one would in majority of the cases want to change the options of the buffer you switched to rather than another buffer. I'm guessing you were thinking something like the following signature? vim._with({buf = 1, bo = {buf = 2, options = { comments = spelllang= 'fr'}}}, function()
end) It is for sure more flexible. I don't mind testing this out and see if it's something we like. I was wondering though if this couldn't be achieved with the current approach already? I haven't tested this out but something like the following should work (or at least be made to work): vim._with({buf = 2, options = { comments = spelllang= 'fr'}}}, function()
vim._with({buf = 1}, function()
end)
end) There is about as much code, but we'd be avoiding the |
The global options are not properly restored after using `vim._with`. Circumvent this problem by always using "local" scope. A solution to allow modifying global options might be added later on, but this is a good enough fix for the time being. Closes neovim#29253.
The global options are not properly restored after using `vim._with`. Circumvent this problem by always using "local" scope. A solution to allow modifying global options might be added later on, but this is a good enough fix for the time being. Closes neovim#29253.
No, not quite. I had in mind one nesting level less: vim._with({ buf = 1, bo = { commentstring = '## %s' }, go = { spelllang = 'fr' } }, callback) Which is essentially a thin wrapper for the following: vim._with({ buf = 1 }, function()
local cache_bo_cms, cache_go_spl = vim.bo.commentstring, vim.go.spelllang
vim.bo.commentstring, vim.go.spelllang = '## %s', 'fr'
callback()
vim.bo.commentstring, vim.go.spelllang = cache_bo_cms, cache_go_spl
end) This both reuses existing notation for global-local options and allows precise explicit intention on which option is meant to be used in context. |
Replace `options` context with `bo`, `wo` and `go` contexts. This allows users to specify which scope the option should work on. Closes neovim#29253.
Replace `options` context with `bo`, `wo` and `go` contexts. This allows users to specify which scope the option should work on. Also add `env` context for changing `vim.env`. Closes neovim#29253.
Replace `options` context with `o`, `bo`, `wo` and `go` contexts. This allows users to specify which scope the option should work on. Also add `env` context for changing `vim.env`. Closes neovim#29253.
Replace `options` context with `o`, `bo`, `wo` and `go` contexts. This allows users to specify which scope the option should work on. Also add `env` context for changing `vim.env`. Closes neovim#29253.
Add optional `scope` parameter to each option. Closes neovim#29253. --- Alternative to neovim#29268. Alternative to neovim#29269. Alternative to touching grass. Will add tests once we've decided the the design/function signature.
Add optional `scope` parameter to each option. Closes neovim#29253.
Replace `options` context with `o`, `bo`, `wo` and `go` contexts. This allows users to specify which scope the option should work on. Also add `env` context for changing `vim.env`. Closes neovim#29253.
Replace `options` context with `o`, `bo`, `wo` and `go` contexts. This allows users to specify which scope the option should work on. Also add `env` context for changing `vim.env`. Closes neovim#29253.
Problem
When using
options
context invim._with()
, it can result into unwanted side effects.Steps to reproduce
nvim --clean -- script.lua
:source
:=log
.The output now (notice difference in
go
values):Expected behavior
Both global and local option values are the same after executing
vim._with()
as they were before it.Neovim version (nvim -v)
NVIM v0.11.0-dev-200+g9afa1fd35
Vim (not Nvim) behaves the same?
No (doesn't have this functionality)
Operating system/version
EndeavourOS Linux x86_64 (6.9.3-arch1-1)
Terminal name/version
st-0.9
$TERM environment variable
st-256color
Installation
appimage
The text was updated successfully, but these errors were encountered: