@@ -166,6 +166,15 @@ vim.o.scrolloff = 10
166166-- See `:help 'confirm'`
167167vim .o .confirm = true
168168
169+ -- Enable undo/redo changes even after closing and reopening a file
170+ vim .opt .undofile = true
171+
172+ -- Enable smooth scrolling
173+ vim .opt .smoothscroll = true
174+
175+ -- Highlight max chars per line
176+ -- vim.opt.colorcolumn = '100'
177+
169178-- [[ Basic Keymaps ]]
170179-- See `:help vim.keymap.set()`
171180
@@ -184,6 +193,9 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
184193-- or just use <C-\><C-n> to exit terminal mode
185194vim .keymap .set (' t' , ' <Esc><Esc>' , ' <C-\\ ><C-n>' , { desc = ' Exit terminal mode' })
186195
196+ -- Close current buffer
197+ vim .keymap .set (' n' , ' <leader>Q' , ' :bd<CR>' , { desc = ' Close current buffer' })
198+
187199-- TIP: Disable arrow keys in normal mode
188200-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
189201-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
@@ -215,10 +227,46 @@ vim.api.nvim_create_autocmd('TextYankPost', {
215227 desc = ' Highlight when yanking (copying) text' ,
216228 group = vim .api .nvim_create_augroup (' kickstart-highlight-yank' , { clear = true }),
217229 callback = function ()
218- vim .hl .on_yank ()
230+ vim .hl .on_yank { timeout = 200 }
231+ end ,
232+ })
233+
234+ -- Restore cursor position on file open
235+ vim .api .nvim_create_autocmd (' BufReadPost' , {
236+ desc = ' Restore cursor position on file open' ,
237+ group = vim .api .nvim_create_augroup (' kickstart-restore-cursor' , { clear = true }),
238+ pattern = ' *' ,
239+ callback = function ()
240+ local line = vim .fn .line ' \' "'
241+ if line > 1 and line <= vim .fn .line ' $' then
242+ vim .cmd ' normal! g\' "'
243+ end
219244 end ,
220245})
221246
247+ -- auto-create missing dirs when saving a file
248+ vim .api .nvim_create_autocmd (' BufWritePre' , {
249+ desc = ' Auto-create missing dirs when saving a file' ,
250+ group = vim .api .nvim_create_augroup (' kickstart-auto-create-dir' , { clear = true }),
251+ pattern = ' *' ,
252+ callback = function ()
253+ local dir = vim .fn .expand ' <afile>:p:h'
254+ if vim .fn .isdirectory (dir ) == 0 then
255+ vim .fn .mkdir (dir , ' p' )
256+ end
257+ end ,
258+ })
259+
260+ -- disable automatic comment on newline
261+ -- vim.api.nvim_create_autocmd('FileType', {
262+ -- desc = 'Disable automatic comment on newline',
263+ -- group = vim.api.nvim_create_augroup('kickstart-disable-auto-comment', { clear = true }),
264+ -- pattern = '*',
265+ -- callback = function()
266+ -- vim.opt_local.formatoptions:remove { 'c', 'r', 'o' }
267+ -- end,
268+ -- })
269+
222270-- [[ Install `lazy.nvim` plugin manager ]]
223271-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
224272local lazypath = vim .fn .stdpath ' data' .. ' /lazy/lazy.nvim'
@@ -854,9 +902,21 @@ require('lazy').setup({
854902 },
855903
856904 sources = {
857- default = { ' lsp' , ' path' , ' snippets' , ' lazydev' },
905+ default = { ' lsp' , ' path' , ' snippets' , ' lazydev' , ' buffer ' },
858906 providers = {
859907 lazydev = { module = ' lazydev.integrations.blink' , score_offset = 100 },
908+ buffer = {
909+ score_offset = - 1 ,
910+ filter = function (buffer )
911+ -- Filetypes for which buffer completions are enabled; add filetypes to extend
912+ local enabled_filetypes = {
913+ ' markdown' ,
914+ ' text' ,
915+ }
916+ local filetype = vim .bo [buffer ].filetype
917+ return vim .tbl_contains (enabled_filetypes , filetype )
918+ end ,
919+ },
860920 },
861921 },
862922
0 commit comments