diff --git a/.config/nvim/lua/tiagorg/autocmd.lua b/.config/nvim/lua/tiagorg/autocmd.lua new file mode 100644 index 0000000..3977df1 --- /dev/null +++ b/.config/nvim/lua/tiagorg/autocmd.lua @@ -0,0 +1,24 @@ +vim.api.nvim_create_autocmd({ "BufWritePre" }, { + pattern = {"*"}, + callback = function() + local save_cursor = vim.fn.getpos(".") + vim.cmd([[%s/\s\+$//e]]) + vim.fn.setpos(".", save_cursor) + end, +}) + +vim.api.nvim_exec([[ + augroup SearchHighlight + autocmd! + autocmd CmdlineLeave /,\? :nnoremap :noh + autocmd CmdlineChanged /,\? :nnoremap :noh + augroup END +]], false) + +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight yanked text", + group = vim.api.nvim_create_augroup("HighlightYank", { clear = true}), + callback = function() + vim.highlight.on_yank() + end +}) diff --git a/.config/nvim/lua/tiagorg/init.lua b/.config/nvim/lua/tiagorg/init.lua index 7d3d47d..7f859a0 100644 --- a/.config/nvim/lua/tiagorg/init.lua +++ b/.config/nvim/lua/tiagorg/init.lua @@ -1,5 +1,6 @@ require("tiagorg.set") require("tiagorg.remap") +require("tiagorg.autocmd") require('tiagorg.colors') require('Comment').setup() diff --git a/.config/nvim/lua/tiagorg/remap.lua b/.config/nvim/lua/tiagorg/remap.lua index 92546f6..e9eb6f6 100644 --- a/.config/nvim/lua/tiagorg/remap.lua +++ b/.config/nvim/lua/tiagorg/remap.lua @@ -1,6 +1,6 @@ ---vim.keymap.set("n", "e", vim.cmd.E) vim.keymap.set("n", "w", vim.cmd.w) vim.keymap.set({ "n", "i" }, "", vim.cmd.w) +--vim.keymap.set("n", "e", vim.cmd.E) vim.keymap.set("v", "J", ":m '>+1gv=gv") vim.keymap.set("v", "K", ":m '<-2gv=gv") @@ -45,11 +45,3 @@ vim.keymap.set("n", "vpp", "so ~/.config/nvim/lua/tiagorg/packer.lu vim.keymap.set("n", "", "qa") vim.keymap.set("n", "", "tabnewNvimTreeFocus") vim.keymap.set("n", "", "w") - -vim.api.nvim_exec([[ - augroup SearchHighlight - autocmd! - autocmd CmdlineLeave /,\? :nnoremap :noh - autocmd CmdlineChanged /,\? :nnoremap :noh - augroup END -]], false) diff --git a/.vimrc b/.vimrc index 19abaee..aa4b243 100644 --- a/.vimrc +++ b/.vimrc @@ -23,6 +23,8 @@ let g:mapleader=" " syntax on colorscheme onedark +nnoremap :qa +nnoremap q :q nnoremap w :w nnoremap e :E nnoremap o o @@ -63,3 +65,11 @@ augroup SearchHighlight autocmd CmdlineChanged /,\? :nnoremap :noh augroup END +let &t_SI = "\e[6 q" +let &t_EI = "\e[2 q" + +augroup myCmds + au! + autocmd VimEnter * silent !echo -ne "\e[2 q" +augroup END +