fix: some pesky yank override

This commit is contained in:
Thomas Alcala Schneider 2023-09-01 12:10:23 +02:00
parent fd6cc1d405
commit 77f79275f7
4 changed files with 55 additions and 52 deletions

View File

@ -470,7 +470,7 @@ mason_lspconfig.setup_handlers {
settings = servers[server_name], settings = servers[server_name],
filetypes = (servers[server_name] or {}).filetypes, filetypes = (servers[server_name] or {}).filetypes,
} }
end end,
} }
-- [[ Configure nvim-cmp ]] -- [[ Configure nvim-cmp ]]

View File

@ -1,72 +1,72 @@
-- Taken from https://www.lazyvim.org/configuration/general -- Taken from https://www.lazyvim.org/configuration/general
local function augroup(name) local function augroup(name)
return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true }) return vim.api.nvim_create_augroup('lazyvim_' .. name, { clear = true })
end end
-- Check if we need to reload the file when it changed -- Check if we need to reload the file when it changed
vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { vim.api.nvim_create_autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, {
group = augroup("checktime"), group = augroup 'checktime',
command = "checktime", command = 'checktime',
}) })
-- Highlight on yank -- Highlight on yank
vim.api.nvim_create_autocmd("TextYankPost", { -- vim.api.nvim_create_autocmd("TextYankPost", {
group = augroup("highlight_yank"), -- group = augroup("highlight_yank"),
callback = function() -- callback = function()
vim.highlight.on_yank() -- vim.highlight.on_yank()
end, -- end,
}) -- })
-- resize splits if window got resized -- resize splits if window got resized
vim.api.nvim_create_autocmd({ "VimResized" }, { vim.api.nvim_create_autocmd({ 'VimResized' }, {
group = augroup("resize_splits"), group = augroup 'resize_splits',
callback = function() callback = function()
vim.cmd("tabdo wincmd =") vim.cmd 'tabdo wincmd ='
end, end,
}) })
-- go to last loc when opening a buffer -- go to last loc when opening a buffer
vim.api.nvim_create_autocmd("BufReadPost", { vim.api.nvim_create_autocmd('BufReadPost', {
group = augroup("last_loc"), group = augroup 'last_loc',
callback = function() callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"') local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0) local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark) pcall(vim.api.nvim_win_set_cursor, 0, mark)
end end
end, end,
}) })
-- close some filetypes with <q> -- close some filetypes with <q>
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd('FileType', {
group = augroup("close_with_q"), group = augroup 'close_with_q',
pattern = { pattern = {
"PlenaryTestPopup", 'PlenaryTestPopup',
"help", 'help',
"lspinfo", 'lspinfo',
"man", 'man',
"notify", 'notify',
"qf", 'qf',
"query", -- :InspectTree 'query', -- :InspectTree
"spectre_panel", 'spectre_panel',
"startuptime", 'startuptime',
"tsplayground", 'tsplayground',
}, },
callback = function(event) callback = function(event)
vim.bo[event.buf].buflisted = false vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true }) vim.keymap.set('n', 'q', '<cmd>close<cr>', { buffer = event.buf, silent = true })
end, end,
}) })
-- wrap and check for spell in text filetypes -- wrap and check for spell in text filetypes
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd('FileType', {
group = augroup("wrap_spell"), group = augroup 'wrap_spell',
pattern = { "gitcommit", "markdown" }, pattern = { 'gitcommit', 'markdown' },
callback = function() callback = function()
vim.opt_local.wrap = true vim.opt_local.wrap = true
vim.opt_local.spell = true vim.opt_local.spell = true
end, end,
}) })
return {} return {}

View File

@ -9,8 +9,8 @@ if has_unnamedplus then
vim.o.clipboard = 'unnamedplus' vim.o.clipboard = 'unnamedplus'
end end
vim.api.nvim_buf_set_keymap(0, 'n', 'y', '"+y', { noremap = true, silent = true }) -- vim.api.nvim_buf_set_keymap(0, 'n', 'y', '"+y', { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(0, 'n', 'p', '"+p', { noremap = true, silent = true }) -- vim.api.nvim_buf_set_keymap(0, 'n', 'p', '"+p', { noremap = true, silent = true })
local function set_json_filetype() local function set_json_filetype()
if string.match(vim.api.nvim_buf_get_name(0), '%.geojson$') or string.match(vim.api.nvim_buf_get_name(0), '%.json$') then if string.match(vim.api.nvim_buf_get_name(0), '%.geojson$') or string.match(vim.api.nvim_buf_get_name(0), '%.json$') then

View File

@ -0,0 +1,3 @@
return {
'lervag/vimtex',
}