@@ -164,6 +164,15 @@ vim.o.scrolloff = 10
164
164
-- See `:help 'confirm'`
165
165
vim .o .confirm = true
166
166
167
+ -- Enable undo/redo changes even after closing and reopening a file
168
+ vim .opt .undofile = true
169
+
170
+ -- Enable smooth scrolling
171
+ vim .opt .smoothscroll = true
172
+
173
+ -- Highlight max chars per line
174
+ -- vim.opt.colorcolumn = '100'
175
+
167
176
-- [[ Basic Keymaps ]]
168
177
-- See `:help vim.keymap.set()`
169
178
@@ -182,6 +191,9 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
182
191
-- or just use <C-\><C-n> to exit terminal mode
183
192
vim .keymap .set (' t' , ' <Esc><Esc>' , ' <C-\\ ><C-n>' , { desc = ' Exit terminal mode' })
184
193
194
+ -- Close current buffer
195
+ vim .keymap .set (' n' , ' <leader>Q' , ' :bd<CR>' , { desc = ' Close current buffer' })
196
+
185
197
-- TIP: Disable arrow keys in normal mode
186
198
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
187
199
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
@@ -212,9 +224,45 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
212
224
vim .api .nvim_create_autocmd (' TextYankPost' , {
213
225
desc = ' Highlight when yanking (copying) text' ,
214
226
group = vim .api .nvim_create_augroup (' kickstart-highlight-yank' , { clear = true }),
215
- callback = function () vim .hl .on_yank () end ,
227
+ callback = function () vim .hl .on_yank { timeout = 200 } end ,
228
+ })
229
+
230
+ -- Restore cursor position on file open
231
+ vim .api .nvim_create_autocmd (' BufReadPost' , {
232
+ desc = ' Restore cursor position on file open' ,
233
+ group = vim .api .nvim_create_augroup (' kickstart-restore-cursor' , { clear = true }),
234
+ pattern = ' *' ,
235
+ callback = function ()
236
+ local line = vim .fn .line ' \' "'
237
+ if line > 1 and line <= vim .fn .line ' $' then
238
+ vim .cmd ' normal! g\' "'
239
+ end
240
+ end ,
241
+ })
242
+
243
+ -- auto-create missing dirs when saving a file
244
+ vim .api .nvim_create_autocmd (' BufWritePre' , {
245
+ desc = ' Auto-create missing dirs when saving a file' ,
246
+ group = vim .api .nvim_create_augroup (' kickstart-auto-create-dir' , { clear = true }),
247
+ pattern = ' *' ,
248
+ callback = function ()
249
+ local dir = vim .fn .expand ' <afile>:p:h'
250
+ if vim .fn .isdirectory (dir ) == 0 then
251
+ vim .fn .mkdir (dir , ' p' )
252
+ end
253
+ end ,
216
254
})
217
255
256
+ -- disable automatic comment on newline
257
+ -- vim.api.nvim_create_autocmd('FileType', {
258
+ -- desc = 'Disable automatic comment on newline',
259
+ -- group = vim.api.nvim_create_augroup('kickstart-disable-auto-comment', { clear = true }),
260
+ -- pattern = '*',
261
+ -- callback = function()
262
+ -- vim.opt_local.formatoptions:remove { 'c', 'r', 'o' }
263
+ -- end,
264
+ -- })
265
+
218
266
-- [[ Install `lazy.nvim` plugin manager ]]
219
267
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
220
268
local lazypath = vim .fn .stdpath ' data' .. ' /lazy/lazy.nvim'
@@ -878,9 +926,21 @@ require('lazy').setup({
878
926
},
879
927
880
928
sources = {
881
- default = { ' lsp' , ' path' , ' snippets' , ' lazydev' },
929
+ default = { ' lsp' , ' path' , ' snippets' , ' lazydev' , ' buffer ' },
882
930
providers = {
883
931
lazydev = { module = ' lazydev.integrations.blink' , score_offset = 100 },
932
+ buffer = {
933
+ score_offset = - 1 ,
934
+ filter = function (buffer )
935
+ -- Filetypes for which buffer completions are enabled; add filetypes to extend
936
+ local enabled_filetypes = {
937
+ ' markdown' ,
938
+ ' text' ,
939
+ }
940
+ local filetype = vim .bo [buffer ].filetype
941
+ return vim .tbl_contains (enabled_filetypes , filetype )
942
+ end ,
943
+ },
884
944
-- On WSL2, blink.cmp may cause the editor to freeze due to a known limitation.
885
945
-- To address this issue, uncomment the following configuration:
886
946
-- cmdline = {
0 commit comments