@@ -119,7 +119,7 @@ vim.schedule(function() vim.o.clipboard = 'unnamedplus' end)
119
119
-- Enable break indent
120
120
vim .o .breakindent = true
121
121
122
- -- Save undo history
122
+ -- Enable undo/redo changes even after closing and reopening a file
123
123
vim .o .undofile = true
124
124
125
125
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
@@ -164,6 +164,12 @@ vim.o.scrolloff = 10
164
164
-- See `:help 'confirm'`
165
165
vim .o .confirm = true
166
166
167
+ -- Disable line wrapping
168
+ vim .o .wrap = false
169
+
170
+ -- Highlight max chars per line
171
+ -- vim.o.colorcolumn = '120'
172
+
167
173
-- [[ Basic Keymaps ]]
168
174
-- See `:help vim.keymap.set()`
169
175
@@ -182,6 +188,9 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
182
188
-- or just use <C-\><C-n> to exit terminal mode
183
189
vim .keymap .set (' t' , ' <Esc><Esc>' , ' <C-\\ ><C-n>' , { desc = ' Exit terminal mode' })
184
190
191
+ -- Close current buffer
192
+ vim .keymap .set (' n' , ' <leader>Q' , ' :bd<CR>' , { desc = ' Close current buffer' })
193
+
185
194
-- TIP: Disable arrow keys in normal mode
186
195
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
187
196
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
@@ -212,7 +221,33 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
212
221
vim .api .nvim_create_autocmd (' TextYankPost' , {
213
222
desc = ' Highlight when yanking (copying) text' ,
214
223
group = vim .api .nvim_create_augroup (' kickstart-highlight-yank' , { clear = true }),
215
- callback = function () vim .hl .on_yank () end ,
224
+ callback = function () vim .hl .on_yank { timeout = 200 } end ,
225
+ })
226
+
227
+ -- Restore cursor position on file open
228
+ vim .api .nvim_create_autocmd (' BufReadPost' , {
229
+ desc = ' Restore cursor position on file open' ,
230
+ group = vim .api .nvim_create_augroup (' kickstart-restore-cursor' , { clear = true }),
231
+ pattern = ' *' ,
232
+ callback = function ()
233
+ local line = vim .fn .line ' \' "'
234
+ if line > 1 and line <= vim .fn .line ' $' then
235
+ vim .cmd ' normal! g\' "'
236
+ end
237
+ end ,
238
+ })
239
+
240
+ -- auto-create missing dirs when saving a file
241
+ vim .api .nvim_create_autocmd (' BufWritePre' , {
242
+ desc = ' Auto-create missing dirs when saving a file' ,
243
+ group = vim .api .nvim_create_augroup (' kickstart-auto-create-dir' , { clear = true }),
244
+ pattern = ' *' ,
245
+ callback = function ()
246
+ local dir = vim .fn .expand ' <afile>:p:h'
247
+ if vim .fn .isdirectory (dir ) == 0 then
248
+ vim .fn .mkdir (dir , ' p' )
249
+ end
250
+ end ,
216
251
})
217
252
218
253
-- [[ Install `lazy.nvim` plugin manager ]]
@@ -878,9 +913,22 @@ require('lazy').setup({
878
913
},
879
914
880
915
sources = {
881
- default = { ' lsp' , ' path' , ' snippets' , ' lazydev' },
916
+ default = { ' lsp' , ' path' , ' snippets' , ' lazydev' , ' buffer ' },
882
917
providers = {
883
918
lazydev = { module = ' lazydev.integrations.blink' , score_offset = 100 },
919
+ buffer = {
920
+ -- Make buffer compeletions appear at the end.
921
+ score_offset = - 100 ,
922
+ enabled = function ()
923
+ -- Filetypes for which buffer completions are enabled; add filetypes to extend:
924
+ local enabled_filetypes = {
925
+ ' markdown' ,
926
+ ' text' ,
927
+ }
928
+ local filetype = vim .bo .filetype
929
+ return vim .tbl_contains (enabled_filetypes , filetype )
930
+ end ,
931
+ },
884
932
-- On WSL2, blink.cmp may cause the editor to freeze due to a known limitation.
885
933
-- To address this issue, uncomment the following configuration:
886
934
-- cmdline = {
0 commit comments