dotfiles
shell, editor, ssh.
git clone https://owenrusk.dev/dotfiles.git
commit 7ff5f06910992437cc275d9dc958e2d01b3e47dc parent 3a8d0adc838f5050d89e9f90e35639ad77698696 author Owen Rusk <owen@papermothgames.com> date 2024-04-17 13:02:58 -0500
nvim: put the cursor back where it was
| nvim/init.lua | +1 | -0 |
| nvim/lua/owen/autocmds.lua | +22 | -0 |
diff --git a/nvim/init.lua b/nvim/init.lua index 01339e1..c67ba1e 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,4 +1,5 @@ -- no plugins. neovim does enough on its own. require("owen.options") require("owen.keymaps") +require("owen.autocmds") require("owen.lsp") diff --git a/nvim/lua/owen/autocmds.lua b/nvim/lua/owen/autocmds.lua new file mode 100644 index 0000000..38c9291 --- /dev/null +++ b/nvim/lua/owen/autocmds.lua @@ -0,0 +1,22 @@ +local group = vim.api.nvim_create_augroup("owen", { clear = true }) + +local function au(event, opts) + opts.group = group + vim.api.nvim_create_autocmd(event, opts) +end + +-- back to where i was when i left the file +au("BufReadPost", { + callback = function(args) + local mark = vim.api.nvim_buf_get_mark(args.buf, '"') + if mark[1] > 0 and mark[1] <= vim.api.nvim_buf_line_count(args.buf) then + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, +}) + +au("TextYankPost", { + callback = function() + vim.highlight.on_yank({ timeout = 150 }) + end, +})