From 1e137c92c333cc1ba6abf667fd0c9b9579421245 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 16 Aug 2024 22:39:42 +0545 Subject: [PATCH] huge updates --- lua/config/1diagnostics.lua | 73 ---------- lua/config/remaps.lua | 283 ------------------------------------ 2 files changed, 356 deletions(-) delete mode 100644 lua/config/1diagnostics.lua delete mode 100644 lua/config/remaps.lua diff --git a/lua/config/1diagnostics.lua b/lua/config/1diagnostics.lua deleted file mode 100644 index 86f2dc2..0000000 --- a/lua/config/1diagnostics.lua +++ /dev/null @@ -1,73 +0,0 @@ -local fn = vim.fn -local api = vim.api -local ns_id = vim.api.nvim_create_namespace('md-codeblaock') -local M = {} - -vim.cmd([[ -hi DError guibg=#2F1D29 guifg=#EB4838 -hi DBError guibg=#2F1D29 -hi DWarn guibg=#322425 guifg=#FA9535 -hi DBWarn guibg=#322425 -]]) - -function get_hl_group_bg_color(hl_group) - local hl_info = vim.api.nvim_get_hl_by_name(hl_group, true) - if hl_info and hl_info.background then - local bg_color = string.format('#%06x', hl_info.background) - return bg_color - else - return nil - end -end - -function hl_line(bufnr, line, hl, vtext) - local text = string.rep(' ', fn.winwidth(fn.bufwinnr(bufnr))) - local opts = { - virt_text = { { ' ' .. vtext .. text, hl.vig } }, - hl_eol = true, - virt_text_pos = 'overlay', - } - api.nvim_buf_add_highlight(bufnr, ns_id, hl.gui, line, 0, -1) - pcall(api.nvim_buf_set_extmark, bufnr, ns_id, line, fn.len(fn.getline(line + 1)), opts) -end - -function show_diag(bufnr, level, message, lnum) - local hl = { - [1] = { - gui = 'DBError', - vig = 'DError', - }, - [2] = { - gui = 'DBWarn', - vig = 'DWarn', - }, - [3] = { - gui = 'DBWarn', - vig = 'DWarn', - }, - [4] = { - gui = 'DBWarn', - vig = 'DWarn', - }, - [5] = { - gui = 'DBWarn', - vig = 'DWarn', - }, - } - hl_line(bufnr, lnum, hl[level], message) -end - -vim.lsp.handlers['textDocument/publishDiagnostics'] = function(_, result, ctx, _) - if not result.diagnostics then - return - end - local bufnr = vim.uri_to_bufnr(result.uri) - vim.api.nvim_buf_clear_namespace(bufnr, ns_id, 0, -1) - for _, diagnostic in ipairs(result.diagnostics) do - local line = diagnostic.range.start.line - local severity = diagnostic.severity - local message = diagnostic.message - show_diag(bufnr, severity, message, line) - end -end -return M diff --git a/lua/config/remaps.lua b/lua/config/remaps.lua deleted file mode 100644 index c1ef226..0000000 --- a/lua/config/remaps.lua +++ /dev/null @@ -1,283 +0,0 @@ -local function map(mode, lhs, rhs, opts) - local options = { - noremap = true, - silent = true, - } - if opts then - options = vim.tbl_extend('force', options, opts) - end - vim.keymap.set(mode, lhs, rhs, options) -end - --- Save File -map( - { - 'i', - 'v', - 'n', - 's', - }, - '', - 'w', - { - desc = 'Save file', - } -) - -map('i', '', '"+pa', { - desc = 'Paste from clipboard', -}) - -map('n', '', 'm`op``', { - desc = 'Paste below', -}) - -map('n', '', 'm`Op``', { - desc = 'Paste above', -}) - -map( - { - 'n', - 'x', - }, - '', - '"+y', - { - desc = 'Copy to clipboard', - } -) - -map( - { - 'n', - 'x', - }, - '', - '"+ydd', - { - desc = 'Cut to clipboard', - } -) - --- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933. -map('n', '', "printf('`[%s`]', getregtype()[0])", { - expr = true, - desc = 'reselect last pasted area', -}) - -map( - { - 'i', - 'v', - 'n', - 's', - }, - '', - 'wq!', - { - desc = 'Force Save file and quit', - } -) - --- Select all text in the current buffer -map('n', '', ':keepjumps normal! ggyG', { - desc = 'Select all', -}) - --- quit -map('n', '', 'wqa!', { - desc = 'Quit all', -}) - --- go to beginning and end in insert mode -map('i', '', '^i', { - desc = 'Go to beginning of line', -}) -map('i', '', '', { - desc = 'Go to end of line', -}) - --- Go to the beginning and end of current line in insert mode quickly -map('i', '', '') -map('i', '', '') - --- insert semicolon in the end -map('i', '', 'miA;`ii', { - desc = 'insert semicolon in the end', -}) - --- Turn the word under cursor to upper case -map('i', '', 'viwUea') --- Turn the current word into lower case -map('i', '', 'b~lea') - --- Undo -map('i', '', 'u') - --- navigate within insert mode -map('i', '', '', { - desc = 'Move Left', -}) -map('i', '', '', { - desc = 'Move Right', -}) -map('i', '', '', { - desc = 'Move Down', -}) -map('i', '', '', { - desc = 'Move Up', -}) - --- Copy whole buffer -map('n', '', '%y+', { - desc = 'Copy whole buffer', -}) - --- Go to start or end of line easier -map( - { - 'n', - 'x', - }, - 'H', - '^', - { - desc = 'Go to beginning of line', - } -) -map( - { - 'n', - 'x', - }, - 'L', - 'g_', - { - desc = 'Go to end of line', - } -) - --- Change text without putting it into the vim register, -map( - { - 'n', - 'x', - }, - 'c', - '"_c', - { - desc = 'Change without yanking', - } -) -map( - { - 'n', - 'x', - }, - 'C', - '"_C', - { - desc = 'Change without yanking', - } -) -map( - { - 'n', - 'x', - }, - 'cc', - '"_cc', - { - desc = 'Change without yanking', - } -) -map( - { - 'n', - 'x', - }, - 'x', - '"_x', - { - desc = 'delete without yanking', - } -) - --- Better escape using jk in insert and terminal mode -map('i', 'jk', '') -map('i', 'kj', '') -map('i', 'jj', '') - --- Terminal Mappings -map('t', 'jk', '') -map('t', 'kj', '') -map('t', '', '') - --- Move with shift-arrows -map('n', '', '', { - desc = 'Move window to the left', -}) -map('n', '', '', { - desc = 'Move window down', -}) -map('n', '', '', { - desc = 'Move window up', -}) -map('n', '', '', { - desc = 'Move window to the right', -}) - --- Search -map( - { - 'n', - 'x', - }, - 'gw', - '*N', - { - desc = 'Search word under cursor', - } -) - --- Some cool remaps -map('n', 'n', 'nzzzv') -map('n', 'N', 'Nzzzv') -map('n', 'J', 'mzJ`z') -map('n', '}', '}zzzv') -map('n', '{', '{zzzv') -map('n', 'g,', 'g,zvzz') -map('n', 'g;', 'g;zvzz') -map('n', '', 'zz') -map('n', '', 'zz') -map('n', '^', 'g^') -map('n', '0', 'g0') --- Do not include white space characters when using $ in visual mode, -map('x', '$', 'g_') --- Always use very magic mode for searching -map('n', '/', [[/\v]]) - --- Add undo break-points -map('i', '?', '?u') -map('i', '!', '!u') -map('i', ',', ',u') -map('i', '.', '.u') -map('i', ';', ';u') - --- compromised backward search when comma is being used as localleader -map('n', '', ',') - --- Better up/down -map({ 'n', 'x' }, 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) -map({ 'n', 'x' }, '', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) -map({ 'n', 'x' }, 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -map({ 'n', 'x' }, '', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) - --- Move text up and down -map('n', '', 'm .+1==', { desc = 'Move Down' }) -map('n', '', 'm .-2==', { desc = 'Move Up' }) -map('i', '', 'm .+1==gi', { desc = 'Move Down' }) -map('i', '', 'm .-2==gi', { desc = 'Move Up' }) -map('v', '', ":m '>+1gv=gv", { desc = 'Move Down' }) -map('v', '', ":m '<-4gv=gv", { desc = 'Move Up' })