@@ -119,7 +119,7 @@ vim.schedule(function() vim.o.clipboard = 'unnamedplus' end)
119119-- Enable break indent
120120vim .o .breakindent = true
121121
122- -- Save undo history
122+ -- Enable undo/redo changes even after closing and reopening a file
123123vim .o .undofile = true
124124
125125-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
@@ -164,6 +164,12 @@ vim.o.scrolloff = 10
164164-- See `:help 'confirm'`
165165vim .o .confirm = true
166166
167+ -- Disable line wrapping
168+ vim .o .wrap = false
169+
170+ -- Highlight max chars per line
171+ -- vim.o.colorcolumn = '120'
172+
167173-- [[ Basic Keymaps ]]
168174-- See `:help vim.keymap.set()`
169175
@@ -182,6 +188,9 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
182188-- or just use <C-\><C-n> to exit terminal mode
183189vim .keymap .set (' t' , ' <Esc><Esc>' , ' <C-\\ ><C-n>' , { desc = ' Exit terminal mode' })
184190
191+ -- Close current buffer
192+ vim .keymap .set (' n' , ' <leader>Q' , ' :bd<CR>' , { desc = ' Close current buffer' })
193+
185194-- TIP: Disable arrow keys in normal mode
186195-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
187196-- 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
212221vim .api .nvim_create_autocmd (' TextYankPost' , {
213222 desc = ' Highlight when yanking (copying) text' ,
214223 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 ,
216251})
217252
218253-- [[ Install `lazy.nvim` plugin manager ]]
@@ -878,9 +913,22 @@ require('lazy').setup({
878913 },
879914
880915 sources = {
881- default = { ' lsp' , ' path' , ' snippets' , ' lazydev' },
916+ default = { ' lsp' , ' path' , ' snippets' , ' lazydev' , ' buffer ' },
882917 providers = {
883918 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+ },
884932 -- On WSL2, blink.cmp may cause the editor to freeze due to a known limitation.
885933 -- To address this issue, uncomment the following configuration:
886934 -- cmdline = {
0 commit comments