Skip to content

Commit 393cbc6

Browse files
oriori1703loadre
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 13658d1 commit 393cbc6

File tree

2 files changed

+36
-37
lines changed

2 files changed

+36
-37
lines changed

init.lua

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,81 +8,77 @@ vim.g.maplocalleader = ' '
88
vim.g.have_nerd_font = false
99

1010
-- [[ Setting options ]]
11-
-- See `:help vim.opt`
11+
-- See `:help vim.o`
1212
-- NOTE: You can change these options as you wish!
1313
-- For more options, you can see `:help option-list`
1414

1515
-- Make line numbers default
16-
vim.opt.number = true
17-
-- You can also add relative line numbers, for help with jumping.
16+
vim.o.number = true
17+
-- You can also add relative line numbers, to help with jumping.
1818
-- Experiment for yourself to see if you like it!
19-
vim.opt.relativenumber = true
19+
-- vim.o.relativenumber = true
2020

2121
-- Enable mouse mode, can be useful for resizing splits for example!
22-
vim.opt.mouse = 'a'
22+
vim.o.mouse = 'a'
2323

24-
-- Don't show the mode, since it's already in status line
25-
vim.opt.showmode = false
24+
-- Don't show the mode, since it's already in the status line
25+
vim.o.showmode = false
2626

2727
-- Sync clipboard between OS and Neovim.
2828
-- Schedule the setting after `UiEnter` because it can increase startup-time.
2929
-- Remove this option if you want your OS clipboard to remain independent.
3030
-- See `:help 'clipboard'`
31-
-- vim.schedule(function()
32-
-- vim.opt.clipboard = 'unnamedplus'
33-
-- end)
34-
35-
-- Colorcolumn
36-
vim.opt.colorcolumn = '80'
37-
38-
-- Disable linewrap
39-
vim.opt.wrap = false
40-
41-
-- Global statusline
42-
vim.opt.laststatus = 3
31+
vim.schedule(function()
32+
vim.o.clipboard = 'unnamedplus'
33+
end)
4334

4435
-- Enable break indent
45-
vim.opt.breakindent = true
36+
vim.o.breakindent = true
4637

4738
-- Save undo history
48-
vim.opt.undofile = true
39+
vim.o.undofile = true
4940

50-
-- Case-insensitive searching UNLESS \C or capital in search
51-
vim.opt.ignorecase = true
52-
vim.opt.smartcase = true
41+
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
42+
vim.o.ignorecase = true
43+
vim.o.smartcase = true
5344

5445
-- Keep signcolumn on by default
55-
vim.opt.signcolumn = 'yes'
46+
vim.o.signcolumn = 'yes'
5647

5748
-- Decrease update time
58-
vim.opt.updatetime = 250
49+
vim.o.updatetime = 250
5950

6051
-- Decrease mapped sequence wait time
61-
vim.opt.timeoutlen = 300
52+
vim.o.timeoutlen = 300
6253

6354
-- Configure how new splits should be opened
64-
vim.opt.splitright = true
65-
vim.opt.splitbelow = true
55+
vim.o.splitright = true
56+
vim.o.splitbelow = true
6657

6758
-- Sets how neovim will display certain whitespace in the editor.
6859
-- See `:help 'list'`
6960
-- and `:help 'listchars'`
70-
vim.opt.list = true
61+
--
62+
-- Notice listchars is set using `vim.opt` instead of `vim.o`.
63+
-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables.
64+
-- See `:help lua-options`
65+
-- and `:help lua-options-guide`
66+
vim.o.list = true
7167
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
7268

7369
-- Preview substitutions live, as you type!
74-
vim.opt.inccommand = 'split'
70+
vim.o.inccommand = 'split'
7571

7672
-- Show which line your cursor is on
77-
vim.opt.cursorline = true
73+
vim.o.cursorline = true
7874

7975
-- Minimal number of screen lines to keep above and below the cursor.
80-
vim.opt.scrolloff = 10
76+
vim.o.scrolloff = 10
8177

8278
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
8379
-- instead raise a dialog asking if you wish to save the current file(s)
8480
-- See `:help 'confirm'`
85-
vim.opt.confirm = true
81+
vim.o.confirm = true
8682

8783
-- [[ Basic Keymaps ]]
8884
-- See `:help vim.keymap.set()`
@@ -155,8 +151,11 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
155151
if vim.v.shell_error ~= 0 then
156152
error('Error cloning lazy.nvim:\n' .. out)
157153
end
158-
end ---@diagnostic disable-next-line: undefined-field
159-
vim.opt.rtp:prepend(lazypath)
154+
end
155+
156+
---@type vim.Option
157+
local rtp = vim.opt.rtp
158+
rtp:prepend(lazypath)
160159

161160
-- [[ Configure and install plugins ]]
162161
--

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)