Add autocmd

Signed-off-by: TiagoRG <tiago.rgarcia@ua.pt>
This commit is contained in:
Tiago Garcia 2024-04-15 00:07:15 +01:00 committed by Tiago Garcia
parent 549e014262
commit 031481cac3
Signed by: TiagoRG
GPG Key ID: FF0A53A30B1ADF82
4 changed files with 36 additions and 9 deletions

View File

@ -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 <buffer> <Esc> :noh<CR>
autocmd CmdlineChanged /,\? :nnoremap <buffer> <Esc> :noh<CR>
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
})

View File

@ -1,5 +1,6 @@
require("tiagorg.set")
require("tiagorg.remap")
require("tiagorg.autocmd")
require('tiagorg.colors')
require('Comment').setup()

View File

@ -1,6 +1,6 @@
--vim.keymap.set("n", "<leader>e", vim.cmd.E)
vim.keymap.set("n", "<leader>w", vim.cmd.w)
vim.keymap.set({ "n", "i" }, "<C-S>", vim.cmd.w)
--vim.keymap.set("n", "<leader>e", vim.cmd.E)
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
@ -45,11 +45,3 @@ vim.keymap.set("n", "<leader>vpp", "<cmd>so ~/.config/nvim/lua/tiagorg/packer.lu
vim.keymap.set("n", "<C-q>", "<cmd>qa<CR>")
vim.keymap.set("n", "<A-t>", "<cmd>tabnew<CR><cmd>NvimTreeFocus<CR>")
vim.keymap.set("n", "<S-Tab>", "<C-w>w")
vim.api.nvim_exec([[
augroup SearchHighlight
autocmd!
autocmd CmdlineLeave /,\? :nnoremap <buffer> <Esc> :noh<CR>
autocmd CmdlineChanged /,\? :nnoremap <buffer> <Esc> :noh<CR>
augroup END
]], false)

10
.vimrc
View File

@ -23,6 +23,8 @@ let g:mapleader=" "
syntax on
colorscheme onedark
nnoremap <C-q> :qa<CR>
nnoremap <leader>q :q<CR>
nnoremap <leader>w :w<CR>
nnoremap <leader>e :E<CR>
nnoremap <leader>o o<Esc>
@ -63,3 +65,11 @@ augroup SearchHighlight
autocmd CmdlineChanged /,\? :nnoremap <buffer> <Esc> :noh<CR>
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