diff options
| author | JackJ30 <jackqjamison@gmail.com> | 2025-05-27 21:45:51 -0400 |
|---|---|---|
| committer | JackJ30 <jackqjamison@gmail.com> | 2025-05-27 21:45:51 -0400 |
| commit | 80351c2cde0845c894466dd83b0554e4f96cbcb0 (patch) | |
| tree | 8783146cc0319df20e3edb85615c09e6d1b8a3e0 /.config/nvim/lua/user/autocmds.lua | |
| parent | 41b74f66946213b6efc4134a514fd5ab76b03353 (diff) | |
new nvim
Diffstat (limited to '.config/nvim/lua/user/autocmds.lua')
| -rw-r--r-- | .config/nvim/lua/user/autocmds.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/.config/nvim/lua/user/autocmds.lua b/.config/nvim/lua/user/autocmds.lua new file mode 100644 index 0000000..bff808a --- /dev/null +++ b/.config/nvim/lua/user/autocmds.lua @@ -0,0 +1,22 @@ +-- Wrap and check for spell in text filetypes. +vim.api.nvim_create_autocmd('FileType', { + group = vim.api.nvim_create_augroup('wrap_spell', { clear = true }), + pattern = { 'gitcommit', 'markdown' }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +-- Go to last loc when opening a buffer. +vim.api.nvim_create_autocmd('BufReadPost', { + group = vim.api.nvim_create_augroup('last_loc', { clear = true }), + callback = function() + local mark = vim.api.nvim_buf_get_mark(0, '"') + local lcount = vim.api.nvim_buf_line_count(0) + if mark[1] > 0 and mark[1] <= lcount then + -- Protected call to catch errors. + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, +}) |
