Skip to content

Commit 6c2f952

Browse files
oriori1703kmha915
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 b50fb2d commit 6c2f952

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

init.lua

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -95,72 +95,77 @@ vim.g.maplocalleader = ' '
9595
vim.g.have_nerd_font = true
9696

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

102102
-- Make line numbers default
103-
vim.opt.number = true
103+
vim.o.number = true
104104
-- You can also add relative line numbers, to help with jumping.
105105
-- Experiment for yourself to see if you like it!
106-
vim.opt.relativenumber = true
106+
vim.o.relativenumber = true
107107

108108
-- Enable mouse mode, can be useful for resizing splits for example!
109-
vim.opt.mouse = 'a'
109+
vim.o.mouse = 'a'
110110

111111
-- Don't show the mode, since it's already in the status line
112-
vim.opt.showmode = false
112+
vim.o.showmode = false
113113

114114
-- Sync clipboard between OS and Neovim.
115115
-- Schedule the setting after `UiEnter` because it can increase startup-time.
116116
-- Remove this option if you want your OS clipboard to remain independent.
117117
-- See `:help 'clipboard'`
118118
vim.schedule(function()
119-
vim.opt.clipboard = 'unnamedplus'
119+
vim.o.clipboard = 'unnamedplus'
120120
end)
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
-- Preview substitutions live, as you type!
152-
vim.opt.inccommand = 'split'
157+
vim.o.inccommand = 'split'
153158

154159
-- Show which line your cursor is on
155-
vim.opt.cursorline = true
160+
vim.o.cursorline = true
156161

157162
-- Minimal number of screen lines to keep above and below the cursor.
158-
vim.opt.scrolloff = 10
163+
vim.o.scrolloff = 10
159164

160165
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
161166
-- instead raise a dialog asking if you wish to save the current file(s)
162167
-- See `:help 'confirm'`
163-
vim.opt.confirm = true
168+
vim.o.confirm = true
164169

165170
-- [[ Basic Keymaps ]]
166171
-- See `:help vim.keymap.set()`
@@ -224,8 +229,11 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
224229
if vim.v.shell_error ~= 0 then
225230
error('Error cloning lazy.nvim:\n' .. out)
226231
end
227-
end ---@diagnostic disable-next-line: undefined-field
228-
vim.opt.rtp:prepend(lazypath)
232+
end
233+
234+
---@type vim.Option
235+
local rtp = vim.opt.rtp
236+
rtp:prepend(lazypath)
229237

230238
-- [[ Configure and install plugins ]]
231239
--
@@ -299,7 +307,7 @@ require('lazy').setup({
299307
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
300308
opts = {
301309
-- delay between pressing a key and opening which-key (milliseconds)
302-
-- this setting is independent of vim.opt.timeoutlen
310+
-- this setting is independent of vim.o.timeoutlen
303311
delay = 0,
304312
icons = {
305313
-- 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)