Skip to content

Commit 01dbedc

Browse files
oriori1703Louis Louis
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 d4ac940 commit 01dbedc

File tree

1 file changed

+48
-19
lines changed

1 file changed

+48
-19
lines changed

init.lua

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,75 +95,88 @@ vim.g.have_nerd_font = true
9595

9696
-- [[ Setting options ]]
9797
<<<<<<< HEAD
98+
<<<<<<< HEAD
9899
require 'options'
99100
=======
100101
-- See `:help vim.opt`
102+
=======
103+
-- See `:help vim.o`
104+
>>>>>>> c92ea7c (Replace vim.opt with vim.o (#1495))
101105
-- NOTE: You can change these options as you wish!
102106
-- For more options, you can see `:help option-list`
103107

104108
-- Make line numbers default
105-
vim.opt.number = true
109+
vim.o.number = true
106110
-- You can also add relative line numbers, to help with jumping.
107111
-- Experiment for yourself to see if you like it!
108-
-- vim.opt.relativenumber = true
112+
-- vim.o.relativenumber = true
109113

110114
-- Enable mouse mode, can be useful for resizing splits for example!
111-
vim.opt.mouse = 'a'
115+
vim.o.mouse = 'a'
112116

113117
-- Don't show the mode, since it's already in the status line
114-
vim.opt.showmode = false
118+
vim.o.showmode = false
115119

116120
-- Sync clipboard between OS and Neovim.
117121
-- Schedule the setting after `UiEnter` because it can increase startup-time.
118122
-- Remove this option if you want your OS clipboard to remain independent.
119123
-- See `:help 'clipboard'`
120124
vim.schedule(function()
121-
vim.opt.clipboard = 'unnamedplus'
125+
vim.o.clipboard = 'unnamedplus'
122126
end)
123127

124128
-- Enable break indent
125-
vim.opt.breakindent = true
129+
vim.o.breakindent = true
126130

127131
-- Save undo history
128-
vim.opt.undofile = true
132+
vim.o.undofile = true
129133

130134
-- 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
135+
vim.o.ignorecase = true
136+
vim.o.smartcase = true
133137

134138
-- Keep signcolumn on by default
135-
vim.opt.signcolumn = 'yes'
139+
vim.o.signcolumn = 'yes'
136140

137141
-- Decrease update time
138-
vim.opt.updatetime = 250
142+
vim.o.updatetime = 250
139143

140144
-- Decrease mapped sequence wait time
141-
vim.opt.timeoutlen = 300
145+
vim.o.timeoutlen = 300
142146

143147
-- Configure how new splits should be opened
144-
vim.opt.splitright = true
145-
vim.opt.splitbelow = true
148+
vim.o.splitright = true
149+
vim.o.splitbelow = true
146150

147151
-- Sets how neovim will display certain whitespace characters in the editor.
148152
-- See `:help 'list'`
149153
-- and `:help 'listchars'`
150-
vim.opt.list = true
154+
--
155+
-- Notice listchars is set using `vim.opt` instead of `vim.o`.
156+
-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables.
157+
-- See `:help lua-options`
158+
-- and `:help lua-options-guide`
159+
vim.o.list = true
151160
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
152161

153162
-- Preview substitutions live, as you type!
154-
vim.opt.inccommand = 'split'
163+
vim.o.inccommand = 'split'
155164

156165
-- Show which line your cursor is on
157-
vim.opt.cursorline = true
166+
vim.o.cursorline = true
158167

159168
-- Minimal number of screen lines to keep above and below the cursor.
169+
<<<<<<< HEAD
160170
vim.opt.scrolloff = 10
161171
>>>>>>> a8f5395 (Fix which-key delay settings (#1276))
172+
=======
173+
vim.o.scrolloff = 10
174+
>>>>>>> c92ea7c (Replace vim.opt with vim.o (#1495))
162175

163176
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
164177
-- instead raise a dialog asking if you wish to save the current file(s)
165178
-- See `:help 'confirm'`
166-
vim.opt.confirm = true
179+
vim.o.confirm = true
167180

168181
-- [[ Basic Keymaps ]]
169182
<<<<<<< HEAD
@@ -223,7 +236,23 @@ vim.api.nvim_create_autocmd('TextYankPost', {
223236
>>>>>>> e947649 (feat(keymap): move windows without `<C-w>` (#1368))
224237

225238
-- [[ Install `lazy.nvim` plugin manager ]]
239+
<<<<<<< HEAD
226240
require 'lazy-bootstrap'
241+
=======
242+
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
243+
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
244+
if not (vim.uv or vim.loop).fs_stat(lazypath) then
245+
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
246+
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
247+
if vim.v.shell_error ~= 0 then
248+
error('Error cloning lazy.nvim:\n' .. out)
249+
end
250+
end
251+
252+
---@type vim.Option
253+
local rtp = vim.opt.rtp
254+
rtp:prepend(lazypath)
255+
>>>>>>> c92ea7c (Replace vim.opt with vim.o (#1495))
227256

228257
-- [[ Configure and install plugins ]]
229258
<<<<<<< HEAD
@@ -297,7 +326,7 @@ require('lazy').setup({
297326
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
298327
opts = {
299328
-- delay between pressing a key and opening which-key (milliseconds)
300-
-- this setting is independent of vim.opt.timeoutlen
329+
-- this setting is independent of vim.o.timeoutlen
301330
delay = 0,
302331
icons = {
303332
-- set icon mappings to true if you have a Nerd Font

0 commit comments

Comments
 (0)