Skip to content

Commit 1d02b87

Browse files
oriori1703CamilleMo
authored andcommitted
Replace vim.opt with vim.o (nvim-lua#1495)
* Replace vim.opt with vim.o Because it offers a nicer interface and info on hover. For now leave vim.opt when using the table interface (until vim.o with tables is implemented) * Add type hint for vim.opt.rtp * Add a comment about using vim.opt instead of vim.o
1 parent f0828a4 commit 1d02b87

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed

init.lua

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,81 +94,90 @@ vim.g.maplocalleader = ' '
9494
vim.g.have_nerd_font = true
9595

9696
-- [[ Setting options ]]
97-
-- See `:help vim.opt`
97+
-- See `:help vim.o`
9898
-- NOTE: You can change these options as you wish!
9999
-- For more options, you can see `:help option-list`
100100

101101
-- Make line numbers default
102-
vim.opt.number = true
102+
vim.o.number = true
103103
-- You can also add relative line numbers, to help with jumping.
104104
-- Experiment for yourself to see if you like it!
105-
vim.opt.relativenumber = true
105+
vim.o.relativenumber = true
106106

107107
-- Enable mouse mode, can be useful for resizing splits for example!
108-
vim.opt.mouse = 'a'
108+
vim.o.mouse = 'a'
109109

110110
-- Don't show the mode, since it's already in the status line
111-
vim.opt.showmode = false
111+
vim.o.showmode = false
112112

113113
-- Sync clipboard between OS and Neovim.
114114
-- Schedule the setting after `UiEnter` because it can increase startup-time.
115115
-- Remove this option if you want your OS clipboard to remain independent.
116116
-- See `:help 'clipboard'`
117117
vim.schedule(function()
118-
vim.opt.clipboard = 'unnamedplus'
118+
vim.o.clipboard = 'unnamedplus'
119119
end)
120120
-- install xclip for this to work
121121

122122
-- Enable break indent
123-
vim.opt.breakindent = true
123+
vim.o.breakindent = true
124124

125125
-- Save undo history
126-
vim.opt.undofile = true
126+
vim.o.undofile = true
127127

128128
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
129-
vim.opt.ignorecase = true
130-
vim.opt.smartcase = true
129+
vim.o.ignorecase = true
130+
vim.o.smartcase = true
131131

132132
-- Keep signcolumn on by default
133-
vim.opt.signcolumn = 'yes'
133+
vim.o.signcolumn = 'yes'
134134

135135
-- Decrease update time
136-
vim.opt.updatetime = 250
136+
vim.o.updatetime = 250
137137

138138
-- Decrease mapped sequence wait time
139-
vim.opt.timeoutlen = 300
139+
vim.o.timeoutlen = 300
140140

141141
-- Configure how new splits should be opened
142-
vim.opt.splitright = true
143-
vim.opt.splitbelow = true
142+
vim.o.splitright = true
143+
vim.o.splitbelow = true
144144

145145
-- Sets how neovim will display certain whitespace characters in the editor.
146146
-- See `:help 'list'`
147147
-- and `:help 'listchars'`
148-
vim.opt.list = true
148+
--
149+
-- Notice listchars is set using `vim.opt` instead of `vim.o`.
150+
-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables.
151+
-- See `:help lua-options`
152+
-- and `:help lua-options-guide`
153+
vim.o.list = true
149154
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
150155

151156
-- display a tab as the same width as four spaces
152157
vim.opt.tabstop = 4
153158

154159
-- Preview substitutions live, as you type!
155-
vim.opt.inccommand = 'split'
160+
vim.o.inccommand = 'split'
156161

157162
-- Show which line your cursor is on
158-
vim.opt.cursorline = true
163+
vim.o.cursorline = true
159164

160165
-- Minimal number of screen lines to keep above and below the cursor.
166+
<<<<<<< HEAD
161167
vim.opt.scrolloff = 100
162168

163169
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
164170
-- instead raise a dialog asking if you wish to save the current file(s)
165171
-- See `:help 'confirm'`
166172
vim.opt.confirm = true
173+
=======
174+
vim.o.scrolloff = 10
175+
>>>>>>> c92ea7c (Replace vim.opt with vim.o (#1495))
167176

168177
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
169178
-- instead raise a dialog asking if you wish to save the current file(s)
170179
-- See `:help 'confirm'`
171-
vim.opt.confirm = true
180+
vim.o.confirm = true
172181

173182
-- [[ Basic Keymaps ]]
174183
-- See `:help vim.keymap.set()`
@@ -232,8 +241,11 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
232241
if vim.v.shell_error ~= 0 then
233242
error('Error cloning lazy.nvim:\n' .. out)
234243
end
235-
end ---@diagnostic disable-next-line: undefined-field
236-
vim.opt.rtp:prepend(lazypath)
244+
end
245+
246+
---@type vim.Option
247+
local rtp = vim.opt.rtp
248+
rtp:prepend(lazypath)
237249

238250
-- [[ Configure and install plugins ]]
239251
--
@@ -304,7 +316,7 @@ require('lazy').setup({
304316
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
305317
opts = {
306318
-- delay between pressing a key and opening which-key (milliseconds)
307-
-- this setting is independent of vim.opt.timeoutlen
319+
-- this setting is independent of vim.o.timeoutlen
308320
delay = 0,
309321
icons = {
310322
-- set icon mappings to true if you have a Nerd Font

lua/kickstart/plugins/lint.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ return {
5050
-- Only run the linter in buffers that you can modify in order to
5151
-- avoid superfluous noise, notably within the handy LSP pop-ups that
5252
-- describe the hovered symbol using Markdown.
53-
if vim.opt_local.modifiable:get() then
53+
if vim.bo.modifiable then
5454
lint.try_lint()
5555
end
5656
end,

0 commit comments

Comments
 (0)