Skip to content

Commit 5af1e5a

Browse files
oriori17032takker
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 a8b3643 commit 5af1e5a

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

init.lua

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,21 @@ 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!
105105
vim.opt.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
-- Force language to be in english
114114
-- vim.cmd 'language en_UK'
@@ -118,51 +118,56 @@ vim.opt.showmode = false
118118
-- Remove this option if you want your OS clipboard to remain independent.
119119
-- See `:help 'clipboard'`
120120
vim.schedule(function()
121-
vim.opt.clipboard = 'unnamedplus'
121+
vim.o.clipboard = 'unnamedplus'
122122
end)
123123

124124
-- Enable break indent
125-
vim.opt.breakindent = true
125+
vim.o.breakindent = true
126126

127127
-- Save undo history
128-
vim.opt.undofile = true
128+
vim.o.undofile = true
129129

130130
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
131-
vim.opt.ignorecase = true
132-
vim.opt.smartcase = true
131+
vim.o.ignorecase = true
132+
vim.o.smartcase = true
133133

134134
-- Keep signcolumn on by default
135-
vim.opt.signcolumn = 'yes'
135+
vim.o.signcolumn = 'yes'
136136

137137
-- Decrease update time
138-
vim.opt.updatetime = 250
138+
vim.o.updatetime = 250
139139

140140
-- Decrease mapped sequence wait time
141-
vim.opt.timeoutlen = 300
141+
vim.o.timeoutlen = 300
142142

143143
-- Configure how new splits should be opened
144-
vim.opt.splitright = true
145-
vim.opt.splitbelow = true
144+
vim.o.splitright = true
145+
vim.o.splitbelow = true
146146

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

153158
-- Preview substitutions live, as you type!
154-
vim.opt.inccommand = 'split'
159+
vim.o.inccommand = 'split'
155160

156161
-- Show which line your cursor is on
157-
vim.opt.cursorline = true
162+
vim.o.cursorline = true
158163

159164
-- Minimal number of screen lines to keep above and below the cursor.
160-
vim.opt.scrolloff = 10
165+
vim.o.scrolloff = 10
161166

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

167172
-- [[ Basic Keymaps ]]
168173
-- See `:help vim.keymap.set()`
@@ -236,8 +241,11 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
236241
if vim.v.shell_error ~= 0 then
237242
error('Error cloning lazy.nvim:\n' .. out)
238243
end
239-
end ---@diagnostic disable-next-line: undefined-field
240-
vim.opt.rtp:prepend(lazypath)
244+
end
245+
246+
---@type vim.Option
247+
local rtp = vim.opt.rtp
248+
rtp:prepend(lazypath)
241249

242250
-- [[ Configure and install plugins ]]
243251
--
@@ -308,7 +316,7 @@ require('lazy').setup({
308316
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
309317
opts = {
310318
-- delay between pressing a key and opening which-key (milliseconds)
311-
-- this setting is independent of vim.opt.timeoutlen
319+
-- this setting is independent of vim.o.timeoutlen
312320
delay = 0,
313321
icons = {
314322
-- 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)